aave / aave/protocol-subgraphs
Negative values for borrowedReservesCount in User schema
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 150
- Forks
- 130
- PR merge metrics
- No merged PRs in 30d
Description
There are occurrences of negative values for borrowedReservesCount field in the User schema.
To Reproduce
On the playground https://thegraph.com/hosted-service/subgraph/aave/protocol-v2?version=current the borrowedReservesCount can be a negative value.
{
users (where: {borrowedReservesCount_lt:0}) {
id
borrowedReservesCount
reserves {
reserve {
name
}
currentTotalDebt
currentATokenBalance
}
}
}
Expected behavior
The borrowedReservesCount should be always >=0. I assumed that a negative value meant that no reserves have been used for borrowing, however by querying
{
users (where: {borrowedReservesCount_lt:0}) {
id
borrowedReservesCount
reserves (where: {currentTotalDebt_gt:0}) {
reserve {
name
}
currentTotalDebt
currentATokenBalance
}
}
}
you can see that there are reserves with non zero debt (e.g.
{
"id": "0x0360414fa5e5846f687096c82e1434151743e886",
"borrowedReservesCount": -1,
"reserves": [
{
"reserve": {
"name": "USD Coin"
},
"currentTotalDebt": "488152768",
"currentATokenBalance": "0"
}
]
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the User schema and the code that updates borrowedReservesCount, then reproduce the two GraphQL queries from the issue against the Aave protocol-v2 subgraph. Trace the example user with nonzero currentTotalDebt and determine why the count becomes negative; done means the count remains >= 0 while matching the user's borrowed reserves.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend, data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100