Skip to content

Aave V2 Migration #496

@micahalcorn

Description

@micahalcorn

It's getting time to migrate to AAVE v2. Interest rates are higher, liquidity is bigger and gas cost is supposed to be cheaper.

The API has changed in AAVE v2, so we will need to deploy a new strategy contract.

API changes

Our current AAVE strategy code. New v2 AAVE lending pool code.

Deposit method has changed from

deposit(address _reserve, uint256 _amount, uint16 _referralCode)

to:

deposit(
    address asset,
    uint256 amount,
    address onBehalfOf,
    uint16 referralCode
  )

Withdraw method has changed be on the pool contract instead of on the aToken:

I think the method signature remains the same, but we should check that we match the new:

withdraw(
    address asset,
    uint256 amount,
    address to
  )

Balance checking remains the same, just using the new atoken.

We'll need to add the ability to set the platformAddress storage slot in the AaveStrategy. Unless I'm missing something obvious, I don't see a setter. Alternately, we could just hardcode it in the new contract.

Governance Proposal

We'll need a governance proposal to:

  1. Pull funds out from strategy - VaultAdmin.withdrawAllFromStrategy(0x9f2b18751376cF6a3432eb158Ba5F9b1AbD2F7ce)
  2. Upgrade strategy
  3. Set atoken AAVEStrategy.setPTokenAddress(0x6b175474e89094c44da98b954eedeac495271d0f, 0x028171bca77440897b824ca71d1c56cac55b68a3 )
  4. Set platform
    AAVEStrategy.setPlatformToken(0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9)
  5. Reallocate Funds - VaultCore.allocate()

Token cheatsheet

V Name Address
v1 aDAI 0xfC1E690f61EFd961294b3e1Ce3313fBD8aa4f85d
v2 aDAI 0x028171bca77440897b824ca71d1c56cac55b68a3
v1 LendingPool 0x398ec7346dcd622edc5ae82352f02be94c62d119
v2 LendingPool 0xd97fE382b923F75Ab8951915eCF07CBf12c102D4
v1 LendingPoolProvider 0x24a42fd28c976a61df5d00d0599c34c4f90748c8
v2 LendingPoolProvider 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9

To Do

  • Update contract
  • Update mocks
  • Write deploy script
  • Test on fork
  • Deploy contract
  • Test on fork
  • Governance Actions

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Large amount of significant user impact, a meaningful feature is brokencontractsWorks related to contractsenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions