Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ampl supply and utilization are broken #35

Open
sakulstra opened this issue Oct 18, 2021 · 0 comments
Open

ampl supply and utilization are broken #35

sakulstra opened this issue Oct 18, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@sakulstra
Copy link
Contributor

sakulstra commented Oct 18, 2021

Ampl data on the graph is broken which is affecting rate-history and other services that might rely on thegraph data.

https://governance.aave.com/t/arc-fix-ui-bugs-in-reserve-overview-for-ampl/5885/5

// https://etherscan.io/address/0x6fBC3BE5ee5273598d1491D41bB45F6d05a7541A#code
  @title Aave-AMPL ERC20 AToken
  @dev Implementation of the interest bearing AMPL token for the Aave protocol
  @author AmpleforthOrg

  The AMPL AToken externally behaves similar to every other aTOKEN. It always maintains a 1:1 peg with
  the underlying AMPL. The following should always be true.

  1) At any time, user can deposit x AMPLs to mint x aAMPLs.
     Total aAMPL supply increases by exactly x.
  2) At any time, user can burn x aAMPLs for x AMPLs.
     Total aAMPL supply decreases by exactly x.
  3) At any time, userA can transfer x aAMPLs to userB.
     userA's aAMPL balance reduces by X.
     userB's aAMPL balance increases by X.
     Total aAMPL supply exactly remains same.
  4) When AMPL's supply rebases, only the 'unborrowed' aAMPL should rebase.
      * Say there are 1000 aAMPL, and 200 AMPL is lent out. AMPL expands by 10%.
        Thew new aAMPL supply should be 1080 aAMPL.
      * Say there are 1000 aAMPL, and 200 AMPL is lent out. AMPL contracts by 10%.
        Thew new aAMPL supply should be 920 aAMPL.
  5) When AMPL's supply rebases, only the part of the balance of a user proportional to  the available liquidity ('unborrowed') should rebase.
      * Say a user has deposited 1000 AMPL and receives 1000 aAMPL, and
        20% of the total underlying AMPL is lent out. AMPL expands by 10%.
        The new aAMPL user balance should be 1080 aAMPL.
      * Say a user has deposited 1000 AMPL and receives 1000 aAMPL, and
        20% of the total underlying AMPL is lent out. AMPL contracts by 10%.
        The new aAMPL supply should be 920 aAMPL.
  6) The totalSupply of aAMPL should always be equal to (total AMPL held in the system) + (total principal borrowed denominated in AMPL) + (interest)

aAMPL tokens are effected by rebase, but thegraph doesn't account for that.

  1. should be solvable by listening to rebase events
  2. i have no idea. fear this might not be solvable at all on thegraph as one would need to iterate trough userReserves on the rebase which is not possible 🤔
@sakulstra sakulstra added the bug Something isn't working label Oct 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant