yearn / yearn-vaults-v2-subgraph

26 stars 41 forks source link

fix: update balanceShares on AccountVaultPosition on transfers to/from the account #56

Closed jstashh closed 3 years ago

jstashh commented 3 years ago

fixes https://github.com/yearn/yearn-vaults-v2-subgraph/issues/54 and https://github.com/yearn/yearn-vaults-v2-subgraph/issues/53

I'm not sure we want to store balanceTokens on AccountVaultPosition because won't it always be out of date as the pricePerShare changes? We should just derive this property from numShares * latestVaultPosition.pricePerShare? Not sure

Also I had to do the dance around the u8 in getBalancePosition because I was getting this error when deploying the subgraph:

{
  "data": {
    "indexingStatusForCurrentVersion": {
      "fatalError": {
        "message": "out of range integral type conversion attempted\twasm backtrace:\t    0: 0x256e - <unknown>!src/utils/account/vault-position/getBalancePosition\t    1: 0x2873 - <unknown>!src/utils/account/vault-position/deposit\t    2: 0x2ac0 - <unknown>!src/utils/vault/vault/deposit\t    3: 0x2bbb - <unknown>!src/mappings/vaultMappings/handleDepositWithAmount\t in handler handleDepositWithAmount at block #11579817 (edbc0c6a8a3946bd0b01493398b73a57516e6f5258e325b86c525e942212644e)"
      },
      "nonFatalErrors": [],
      "subgraph": "QmTcCeGHq8xD4uPF2KDHZxRxWgsABgLxtGcEkapqwZFHnR"
    }
  }
}