protocol-subgraphs icon indicating copy to clipboard operation
protocol-subgraphs copied to clipboard

Negative values for borrowedReservesCount in User schema

Open AntonioMarsella opened this issue 3 years ago • 1 comments

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"
          }
        ]
      }

AntonioMarsella avatar Jun 29 '22 09:06 AntonioMarsella

honestly I think this should just be removed completely :sweat_smile: it's a bit unnecessary bloat on the subgraph

sakulstra avatar Jul 06 '22 16:07 sakulstra