aave / aave/protocol-subgraphs

Aave V2 Ethereum - reserve.totalLiquidityAsCollateral appears to be overstated in some markets

Open
#89 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
150
Forks
130
PR merge metrics
No merged PRs in 30d

Description

Describe the bug
In the Aave V2 Ethereum subgraph, the reserve.totalLiquidityAsCollateral return value appears to be incorrect for some markets. It returns a value which is greater than the reserve.totalLiquidity for that market.

Incorrect markets include stETH (below), USDC and Frax. This list isn't exhaustive - there may be more.

To Reproduce
Query:

query MyQuery {
  reserve(
    id: "0xae7ab96520de3a18e5e111b5eaab095312d7fe840xb53c1a33016b2dc2ff3653530bff1848a515c8c5"
    block: {number: 16501589}
  ) {
    totalLiquidity
    totalLiquidityAsCollateral
  }
}

Response:

{
  "data": {
    "reserve": {
      "totalLiquidity": "899695114262182690563902",
      "totalLiquidityAsCollateral": "1070577614223086581220014"
    }
  }
}

Expected behavior
The totalLiquidityAsCollateral value should be less than or equal to the totalLiquidity value.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the supplied GraphQL query for the stETH reserve at block 16501589, then trace the subgraph implementation that computes reserve.totalLiquidity and reserve.totalLiquidityAsCollateral. Compare the collateral aggregation for stETH, USDC, and Frax with the reported values. Done means totalLiquidityAsCollateral no longer exceeds totalLiquidity for the affected markets.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
api, blockchain
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.