{"id":18704969,"url":"https://github.com/aave/protocol-subgraphs","last_synced_at":"2025-04-13T02:18:15.860Z","repository":{"id":38293842,"uuid":"331963499","full_name":"aave/protocol-subgraphs","owner":"aave","description":"The code of Aave protocol subgraphs","archived":false,"fork":false,"pushed_at":"2025-03-21T13:54:46.000Z","size":949,"stargazers_count":128,"open_issues_count":24,"forks_count":105,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-04-04T04:11:56.226Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aave.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-22T14:05:20.000Z","updated_at":"2025-03-21T13:54:52.000Z","dependencies_parsed_at":"2024-05-28T18:00:27.407Z","dependency_job_id":"6005fbc2-2b84-4423-8d47-5b99b61c9212","html_url":"https://github.com/aave/protocol-subgraphs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aave%2Fprotocol-subgraphs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aave%2Fprotocol-subgraphs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aave%2Fprotocol-subgraphs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aave%2Fprotocol-subgraphs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aave","download_url":"https://codeload.github.com/aave/protocol-subgraphs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248654158,"owners_count":21140247,"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":[],"created_at":"2024-11-07T12:09:18.736Z","updated_at":"2025-04-13T02:18:15.835Z","avatar_url":"https://github.com/aave.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Aave Protocol Subgraphs\n\nThe Aave Protocol subgraphs index data from the protocol smart contracts, and expose a GraphQL endpoint hosted by [The Graph](https://thegraph.com).\n\n- [Active Deployments](#active-deployments)\n- [Usage](#usage)\n- [Development](#deployment)\n\n# Active deployments\n\n## Protocol Subgraphs\n\n### Production networks\n\n- [ETH Mainnet V3](https://thegraph.com/explorer/subgraphs/Cd2gEDVeqnjBn1hSeqFMitw8Q1iiyV9FYUZkLNRcL87g)\n- [ETH Mainnet V3 GHO](https://thegraph.com/explorer/subgraphs/BQN5t5Mgti3BNLsZYEiL1MtiBJLa1DQJnaquXR1zTBjn)\n- [ETH Mainnet V3 Lido Market](https://thegraph.com/explorer/subgraphs/5vxMbXRhG1oQr55MWC5j6qg78waWujx1wjeuEWDA6j3)\n- [ETH Mainnet V3 Etherfi Market](https://thegraph.com/explorer/subgraphs/8o4HGApJkAqnvxAHShG4w5xiXihHyL7HkeDdQdRUYmqZ)\n- [ETH Mainnet V2](https://thegraph.com/explorer/subgraphs/8wR23o1zkS4gpLqLNU4kG3JHYVucqGyopL5utGxP2q1N)\n- [Polygon V2](https://thegraph.com/explorer/subgraphs/H1Et77RZh3XEf27vkAmJyzgCME2RSFLtDS2f4PPW6CGp)\n- [Avalanche V2](https://thegraph.com/explorer/subgraphs/EZvK18pMhwiCjxwesRLTg81fP33WnR6BnZe5Cvma3H1C)\n- [Polygon V3](https://thegraph.com/explorer/subgraphs/Co2URyXjnxaw8WqxKyVHdirq9Ahhm5vcTs4dMedAq211)\n- [Avalanche V3](https://thegraph.com/explorer/subgraphs/2h9woxy8RTjHu1HJsCEnmzpPHFArU33avmUh4f71JpVn)\n- [Arbitrum V3](https://thegraph.com/explorer/subgraphs/DLuE98kEb5pQNXAcKFQGQgfSQ57Xdou4jnVbAEqMfy3B)\n- [Optimism V3](https://thegraph.com/explorer/subgraphs/DSfLz8oQBUeU5atALgUFQKMTSYV9mZAVYp4noLSXAfvb)\n- [Fantom V3](https://thegraph.com/explorer/subgraphs/6L1vPqyE3xvkzkWjh6wUKc1ABWYYps5HJahoxhrv2PJn)\n- [Harmony V3](https://thegraph.com/explorer/subgraphs/FifJapBdCqT9vgNqJ5axmr6eNyUpUSaRAbbZTfsViNsT)\n- [Metis V3](https://metisapi.0xgraph.xyz/subgraphs/name/aave/protocol-v3-metis)\n- [Gnosis V3](https://thegraph.com/explorer/subgraphs/HtcDaL8L8iZ2KQNNS44EBVmLruzxuNAz1RkBYdui1QUT)\n- [BNB Chain V3](https://thegraph.com/explorer/subgraphs/7Jk85XgkV1MQ7u56hD8rr65rfASbayJXopugWkUoBMnZ)\n- [Base V3](https://thegraph.com/explorer/subgraphs/GQFbb95cE6d8mV989mL5figjaGaKCQB3xqYrr1bRyXqF)\n- [Scroll V3](https://thegraph.com/explorer/subgraphs/74JwenoHZb2aAYVGCCSdPWzi9mm745dyHyQQVoZ7Sbub)\n- [ZKsync V3](https://thegraph.com/explorer/subgraphs/ENYSc8G3WvrbhWH8UZHrqPWYRcuyCaNmaTmoVp7uzabM)\n- [Linea V3](https://thegraph.com/explorer/subgraphs/Gz2kjnmRV1fQj3R8cssoZa5y9VTanhrDo4Mh7nWW1wHa)\n- [Sonic V3](https://thegraph.com/explorer/subgraphs/FQcacc4ZJaQVS9euWb76nvpSq2GxavBnUM6DU6tmspbi)\n- [Celo V3](https://thegraph.com/explorer/subgraphs/GAVWZzGwQ6d6QbFojyFWxpZ2GB9Rf5hZgGyJHCEry8kn)\n\n### Test networks\n\n- [Goerli V2](https://thegraph.com/hosted-service/subgraph/aave/protocol-v2-goerli)\n- [Goerli V3](https://thegraph.com/hosted-service/subgraph/aave/protocol-v3-goerli)\n- [Mumbai V2](https://thegraph.com/hosted-service/subgraph/aave/aave-v2-polygon-mumbai)\n- [Mumbai V3](https://thegraph.com/hosted-service/subgraph/aave/protocol-v3-mumbai)\n- [Fuji V2](https://thegraph.com/explorer/subgraphs/CkLPS5QuGQR5Ys6w9TSLCbUQ6zvKoa6R5SJmmRqFQjpd)\n- [Fuji V3](https://thegraph.com/hosted-service/subgraph/aave/protocol-v3-fuji)\n- [Arbitrum Goerli V3](https://thegraph.com/hosted-service/subgraph/aave/protocol-v3-arbitrum-goerli)\n- [Optimism Goerli V3](https://thegraph.com/hosted-service/subgraph/aave/protocol-v3-optimism-goerli)\n- [Fantom Testnet V3](https://thegraph.com/hosted-service/subgraph/aave/protocol-v3-fantom-testnet)\n\n## Governance Subgraphs\n\n- [Aave Governance V3](https://thegraph.com/explorer/subgraphs/A7QMszgomC9cnnfpAcqZVLr2DffvkGNfimD8iUSMiurK)\n- [Aave Governance V3 Voting Polygon](https://thegraph.com/explorer/subgraphs/32WLrLTQctAgfoshbkteHfxLu3DpAeZwh2vUPWXV6Qxu)\n- [Aave Governance V3 Voting Ethereum](https://thegraph.com/explorer/subgraphs/2QPwuCfFtQ8WSCZoN3i9SmdoabMzbq2pmg4kRbrhymBV?view=Query\u0026chain=arbitrum-one)\n- [Aave Governance V3 Voting Avalache](https://thegraph.com/explorer/subgraphs/FngMWWGJV45McvV7GUBkrta9eoEi3sHZoH7MYnFQfZkr?view=Query\u0026chain=arbitrum-one)\n- [Aave Governance V2](https://thegraph.com/explorer/subgraphs/CfdJBpzFXCCCagNhMt2uQgqjDSVbaSNLV5f5c3BbGwip)\n\n## Usage\n\nSubgraphs can be queried directly from the graph explorer, or from [another application](https://thegraph.com/docs/en/developer/querying-from-your-app/). The following section gives common queries for Aave protocol data.\n\n### Helpful Queries\n\nSee [TheGraph API](https://thegraph.com/docs/en/developer/graphql-api/) docs for a complete guide on querying capabilities.\n\n#### User Transaction History\n\n\u003cdetails\u003e\n  \u003csummary\u003eV2\u003c/summary\u003e\n\n```\n{\n  userTransactions(\n    where: { user: \"insert_lowercase_address_here\" }\n    orderBy: timestamp\n    orderDirection: desc\n  ) {\n    id\n    timestamp\n    txHash\n    action\n    ... on Deposit {\n      amount\n      reserve {\n        symbol\n        decimals\n      }\n      assetPriceUSD\n    }\n    ... on RedeemUnderlying {\n      amount\n      reserve {\n        symbol\n        decimals\n      }\n      assetPriceUSD\n    }\n    ... on Borrow {\n      amount\n      borrowRateMode\n      borrowRate\n      stableTokenDebt\n      variableTokenDebt\n      reserve {\n        symbol\n        decimals\n      }\n      assetPriceUSD\n    }\n    ... on UsageAsCollateral {\n      fromState\n      toState\n      reserve {\n        symbol\n      }\n    }\n    ... on Repay {\n      amount\n      reserve {\n        symbol\n        decimals\n      }\n      assetPriceUSD\n    }\n    ... on Swap {\n      borrowRateModeFrom\n      borrowRateModeTo\n      variableBorrowRate\n      stableBorrowRate\n      reserve {\n        symbol\n        decimals\n      }\n    }\n    ... on LiquidationCall {\n      collateralAmount\n      collateralReserve {\n        symbol\n        decimals\n      }\n      principalAmount\n      principalReserve {\n        symbol\n        decimals\n      }\n      collateralAssetPriceUSD\n      borrowAssetPriceUSD\n    }\n  }\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eV3\u003c/summary\u003e\n\n```\n{\n  userTransactions(\n    where: { user: \"insert_lowercase_address_here\" }\n    orderBy: timestamp\n    orderDirection: desc\n  ) {\n    id\n    timestamp\n    txHash\n    action\n    ... on Supply {\n      amount\n      reserve {\n        symbol\n        decimals\n      }\n      assetPriceUSD\n    }\n    ... on RedeemUnderlying {\n      amount\n      reserve {\n        symbol\n        decimals\n      }\n      assetPriceUSD\n    }\n    ... on Borrow {\n      amount\n      borrowRateMode\n      borrowRate\n      stableTokenDebt\n      variableTokenDebt\n      reserve {\n        symbol\n        decimals\n      }\n      assetPriceUSD\n    }\n    ... on UsageAsCollateral {\n      fromState\n      toState\n      reserve {\n        symbol\n      }\n    }\n    ... on Repay {\n      amount\n      reserve {\n        symbol\n        decimals\n      }\n      assetPriceUSD\n    }\n    ... on SwapBorrowRate {\n      borrowRateModeFrom\n      borrowRateModeTo\n      variableBorrowRate\n      stableBorrowRate\n      reserve {\n        symbol\n        decimals\n      }\n    }\n    ... on LiquidationCall {\n      collateralAmount\n      collateralReserve {\n        symbol\n        decimals\n      }\n      principalAmount\n      principalReserve {\n        symbol\n        decimals\n      }\n      collateralAssetPriceUSD\n      borrowAssetPriceUSD\n    }\n  }\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eReserve Data\u003c/summary\u003e\n\n#### Reserve Summary\n\nThe `reserve` entity gives data on the assets of the protocol including rates, configuration, and total supply/borrow amounts.\n\nThe aave-utilities library includes a [`formatReserves`](https://github.com/aave/aave-utilities/#formatReserves) function which can be used to format all data into a human readable format. The queries to fetch data for passing into this function can be found [here](https://github.com/aave/aave-utilities#subgraph).\n\nWhy does the raw subgraph data not match app.aave.com?\n\n- aToken and debtToken balances are continuously increasing. The subgraph provides a snapshot of the balance at the time of indexing (not querying), which means fields affected by interest such as `totalLiquidity`, `availableLiquidity`, and `totalCurrentVariableDebt` will need to be formatted to get real-time values\n- All rates (liquidityRate, variableBorrowRate, stableBorrowRate) are expressed as _APR_ with RAY units (10**27). To convert to the APY percentage as shown on the Aave frontend: `supplyAPY = (((1 + ((liquidityRate / 10**27) / 31536000)) ^ 31536000) - 1) \\* 100`. [`formatReserves`](https://github.com/aave/aave-utilities/#formatReserves) will perform this calculation for you.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eUser Data\u003c/summary\u003e\n\n#### User Summary\n\nThe `userReserve` entity gives the supply and borrow balances for a particular user along with the underlying reserve data.\n\nThe aave-utilities library includes a [`formatUserSummary`](https://github.com/aave/aave-utilities#formatUserSummary) function which can be used to format all data into a human readable format. The queries to fetch data for passing into this function can be found [here](https://github.com/aave/aave-utilities#subgraph).\n\nWhy does the raw subgraph data not match my account balances on app.aave.com?\n\n- aToken and debtToken balances are continuously increasing. The subgraph provides a snapshot of the balance at the time of indexing (not querying), which means fields affected by interest such as `currentATokenBalance`, `currentVariableDebt`, and `currentStableDebt` will need to be formatted to get the real-time values\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eQuerying Tips\u003c/summary\u003e\n\n### Historical Queries\n\nYou can query for historical data by specifying a block number:\n\n```\n{\n\treserves(block: {number: 14568297}){\n  \tsymbol\n  \tliquidityRate\n\t}\n}\n```\n\nTo query based on a historical timestamp, you will need to convert the timstamp to the most recent block number, you will need to use an external tool such as [this](https://www.npmjs.com/package/ethereum-block-by-date).\n\n### Pagination\n\nThe Graph places a limit on the number of items which can returned by a single query (currently 100). To fetch a larger number of items, the `first` and `skip` parameters can be used to create paginated queries.\n\nFor example, if you wanted to fetch the first 200 transactions for an Aave market, you can't query 200 items at once, but you can achieve the same thing by concatenating the output of these queries:\n\n```\n{\n  userTransactions(orderBy: timestamp, orderDirection: asc, first: 100, skip: 0){\n    timestamp\n  }\n}\n```\n\n```\n{\n  userTransactions(orderBy: timestamp, orderDirection: asc, first: 100, skip: 100){\n    timestamp\n  }\n}\n```\n\n\u003c/details\u003e\n\n## Development\n\n```bash\n\n# copy env and adjust its content with your personal access token and subgraph name\n\n# you can get an access token from https://thegraph.com/explorer/dashboard\ncp .env.test .env\n\n# install project dependencies\nnpm i\n\n# to regenrate types if schema.graphql has changed\nnpm run subgraph:codegen\n\n# to run a test build of your subgraph\nnpm run subgraph:build\n\n# now you're able to deploy to thegraph hosted service with one of the deploy commands:\nnpm run deploy:hosted:mainnet\n\n```\n\n### Troubleshooting\n\nIf a subgraph encounters an error while indexing, the logs on the explorer may not display the error. You can check for errors on a pending or synced subgraph with the following commands, replacing `aave/protocol-v2` with your subgraph name:\n\nPending:\n\n```\ncurl --location --request POST 'https://api.thegraph.com/index-node/graphql' --data-raw '{\"query\":\"{ indexingStatusForPendingVersion(subgraphName: \\\"aave/protocol-v2\\\") { subgraph fatalError { message } nonFatalErrors {message } } }\"}'\n```\n\nSynced:\n\n```\ncurl --location --request POST 'https://api.thegraph.com/index-node/graphql' --data-raw '{\"query\":\"{ indexingStatusForCurrentVersion(subgraphName: \\\"aave/protocol-v2\\\") { subgraph fatalError { message } nonFatalErrors {message } } }\"}'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faave%2Fprotocol-subgraphs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faave%2Fprotocol-subgraphs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faave%2Fprotocol-subgraphs/lists"}