{"id":21531979,"url":"https://github.com/chainbound/apollo","last_synced_at":"2025-04-10T00:28:59.389Z","repository":{"id":37453729,"uuid":"484440485","full_name":"chainbound/apollo","owner":"chainbound","description":"cross-chain ETL tool for EVM chaindata","archived":false,"fork":false,"pushed_at":"2022-07-10T15:24:51.000Z","size":607,"stargazers_count":32,"open_issues_count":3,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T02:12:26.569Z","etag":null,"topics":["blockchain","data-science","dsl","ethereum","etl","evm","golang","hcl","web3"],"latest_commit_sha":null,"homepage":"https://apollo.chainbound.io","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chainbound.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-04-22T13:17:32.000Z","updated_at":"2024-08-01T06:38:55.000Z","dependencies_parsed_at":"2022-07-09T09:46:08.306Z","dependency_job_id":null,"html_url":"https://github.com/chainbound/apollo","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainbound%2Fapollo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainbound%2Fapollo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainbound%2Fapollo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainbound%2Fapollo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chainbound","download_url":"https://codeload.github.com/chainbound/apollo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248133863,"owners_count":21053341,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain","data-science","dsl","ethereum","etl","evm","golang","hcl","web3"],"created_at":"2024-11-24T02:18:23.251Z","updated_at":"2025-04-10T00:28:59.326Z","avatar_url":"https://github.com/chainbound.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Apollo\n\u003e **Query**, **transform**, **filter** and **save** EVM based chaindata using a simple schema\n\n![apollo-diagram drawio](./docs/apollo-flow.png)\n\n## Documentation\nFor detailed documentation, visit [apollo.chainbound.io](https://apollo.chainbound.io).\n\n## Installation\n```bash\ngo install github.com/chainbound/apollo\n```\n\n## Usage\n### Setting up\nFirst, generate the config directory and files:\n```\napollo init\n```\nThis will generate the configuration files (`config.yml` and `schema.hcl`) and put it into your configuration\ndirectory, which will either be `$XDG_CONFIG_HOME/apollo` or `$HOME/.config/apollo`. This is the directory\nin which you have to configure `apollo`, and it's also the directory where `apollo` will try to find the specified\ncontract ABIs.\n\n`$HOME/.config/apollo/config.yml` will be configured with some standard chains and public RPC APIs. These will not do\nfor most queries, and we recommend either using your own node, or getting one with a node provider\nlike Alchemy or Chainstack.\n\n### Schema\n`$HOME/.config/apollo/schema.hcl` is configured with a default schema (below) that you can try out, but for a more in depth\nexplanation visit the [schema documentation](https://apollo.chainbound.io/schema/intro) or check out \nsome [examples](https://apollo.chainbound.io/schema/schema-examples).\n```hcl\nstart_time = format_date(\"02-01-2006 15:04\", \"25-05-2022 12:00\")\nend_time = now\n\nvariables = {\n  b = upper(\"eth_buy\")\n  s = upper(\"eth_sell\")\n}\n\n// query defines the name of your query -\u003e name of your output files and SQL tables\nquery usdc_eth_swaps {\n  // Each query can have a different chain\n  chain = \"arbitrum\"\n\n  contract {\n    address = \"0x905dfCD5649217c42684f23958568e533C711Aa3\"\n    abi = \"unipair.abi.json\"\n    // Listen for events\n    event Swap {\n      // The outputs we're interested in, same way as with methods.\n      outputs = [\"amount1In\", \"amount0Out\", \"amount0In\", \"amount1Out\"]\n    }\n\n    // \"transform\" blocks are at the contract-level\n    transform {\n      usdc_sold = parse_decimals(amount1In, 6)\n      eth_sold = parse_decimals(amount0In, 18)\n\n      usdc_bought = parse_decimals(amount1Out, 6)\n      eth_bought = parse_decimals(amount0Out, 18)\n\n      buy = amount0Out != 0\n    }\n  }\n\n  filter = [\n    eth_bought != 0\n  ]\n\n  // Besides the normal context, the \"save\" block for events provides an additional\n  // variable \"tx_hash\". \"save\" blocks are at the query-level and have access to variables\n  // defined in the \"transform\" block\n  save {\n    timestamp = timestamp\n    block = blocknumber\n    contract = contract_address\n    tx_hash = tx_hash\n\n    // Example: we want to calculate the price of the swap.\n    // We have to make sure we don't divide by 0, so we use the ternary operator.\n    swap_price = eth_bought != 0 ? (usdc_sold / eth_bought) : (usdc_bought / eth_sold)\n    direction = buy ? b : s\n    size_in_udsc = eth_bought != 0 ? usdc_sold : usdc_bought\n  }\n}\n```\n\n### Running\n**Important**: running `apollo` with the default parameters will send out a lot of requests, and your node provider might rate limit you.\nPlease check the [rate limiting](https://apollo.chainbound.io/getting-started#rate-limiting) section in the documentation. You can set\nthe `--rate-limit` option to something low like 20 to start.\n\n#### Realtime mode\nAfter defining the schema, run\n```bash\napollo --realtime --stdout\n```\nIn the case of events, this will listen for events in real-time and save them in your output option.\nIn the case of methods, you will have to define one of the `interval` parameters,\nand `apollo` will run that query at every interval.\n\n#### Historical mode\nAfter defining the schema with `start`, `end` and `interval` parameters, just run\n```bash\napollo --stdout\n```\nThe default mode is historical mode.\n\n## Output\nThere are 3 output options:\n* `stdout`: this will just print the results to your terminal.\n* `csv`: this will save your output into a csv file. The name of your file will be the name of your `query`. The other columns\nwill be made up of what's defined in the `save` block.\n* `db`: this will save your output into a Postgres SQL table, with the table name matching your `query` name. The settings are defined in `config.yml` in your `apollo` config directory.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchainbound%2Fapollo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchainbound%2Fapollo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchainbound%2Fapollo/lists"}