Skip to content

Commit

Permalink
TL: May Funding Update Part B (bgd-labs#465)
Browse files Browse the repository at this point in the history
  • Loading branch information
defijesus authored Oct 4, 2024
1 parent fa2b9f3 commit 6b92283
Show file tree
Hide file tree
Showing 6 changed files with 428 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
## Reserve changes

### Reserve altered

#### DAI ([0x6B175474E89094C44Da98b954EedeAC495271d0F](https://etherscan.io/address/0x6B175474E89094C44Da98b954EedeAC495271d0F))

| description | value before | value after |
| --- | --- | --- |
| aTokenUnderlyingBalance | 9,959,119.1684 DAI [9959119168440593981367052] | 10,412,279.1136 DAI [10412279113680893868774808] |
| virtualBalance | 9,959,077.9501 DAI [9959077950161256517910498] | 10,412,237.8954 DAI [10412237895401556405318254] |


#### USDC ([0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48](https://etherscan.io/address/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48))

| description | value before | value after |
| --- | --- | --- |
| aTokenUnderlyingBalance | 170,416,398.0105 USDC [170416398010523] | 173,156,644.6678 USDC [173156644667898] |
| virtualBalance | 170,410,060.0852 USDC [170410060085249] | 173,150,306.7426 USDC [173150306742624] |


#### WETH ([0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2](https://etherscan.io/address/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2))

| description | value before | value after |
| --- | --- | --- |
| aTokenUnderlyingBalance | 125,525.8289 WETH [125525828903647493339324] | 125,645.1966 WETH [125645196632342373482070] |
| virtualBalance | 125,525.8224 WETH [125525822450101205809733] | 125,645.1901 WETH [125645190178796085952479] |


#### USDT ([0xdAC17F958D2ee523a2206206994597C13D831ec7](https://etherscan.io/address/0xdAC17F958D2ee523a2206206994597C13D831ec7))

| description | value before | value after |
| --- | --- | --- |
| aTokenUnderlyingBalance | 279,591,839.3705 USDT [279591839370520] | 282,560,728.7530 USDT [282560728753066] |
| virtualBalance | 279,590,685.1563 USDT [279590685156308] | 282,559,574.5388 USDT [282559574538854] |


## Raw diff

```json
{
"reserves": {
"0x6B175474E89094C44Da98b954EedeAC495271d0F": {
"aTokenUnderlyingBalance": {
"from": "9959119168440593981367052",
"to": "10412279113680893868774808"
},
"virtualBalance": {
"from": "9959077950161256517910498",
"to": "10412237895401556405318254"
}
},
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48": {
"aTokenUnderlyingBalance": {
"from": 170416398010523,
"to": 173156644667898
},
"virtualBalance": {
"from": 170410060085249,
"to": 173150306742624
}
},
"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2": {
"aTokenUnderlyingBalance": {
"from": "125525828903647493339324",
"to": "125645196632342373482070"
},
"virtualBalance": {
"from": "125525822450101205809733",
"to": "125645190178796085952479"
}
},
"0xdAC17F958D2ee523a2206206994597C13D831ec7": {
"aTokenUnderlyingBalance": {
"from": 279591839370520,
"to": 282560728753066
},
"virtualBalance": {
"from": 279590685156308,
"to": 282559574538854
}
}
}
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IProposalGenericExecutor} from 'aave-helpers/src/interfaces/IProposalGenericExecutor.sol';
import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol';
import {SafeERC20} from 'solidity-utils/contracts/oz-common/SafeERC20.sol';
import {AaveV2Ethereum, AaveV2EthereumAssets} from 'aave-address-book/AaveV2Ethereum.sol';
import {AaveV3Ethereum, AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol';
import {CollectorUtils} from 'aave-helpers/src/CollectorUtils.sol';

/**
* @title May Funding Update Part B
* @author karpatkey_TokenLogic
* - Snapshot: Direct-to-AIP
* - Discussion: https://governance.aave.com/t/arfc-may-funding-update/17768/5
*/
contract AaveV3Ethereum_MayFundingUpdatePartB_20240917 is IProposalGenericExecutor {
using SafeERC20 for IERC20;

address public constant COLLECTOR = address(AaveV3Ethereum.COLLECTOR);
address public constant POOL_V2 = address(AaveV2Ethereum.POOL);
address public constant POOL_V3 = address(AaveV3Ethereum.POOL);
address public constant RECIPIENT_500 = 0x1770776deB0A5CA58439759FAdb5cAA014501241;
address public constant RECIPIENT_1000 = 0x7dF98A6e1895fd247aD4e75B8EDa59889fa7310b;
address public constant IMMUNEFI = 0x7119f398b6C06095c6E8964C1f58e7C1BAa79E18;

struct Migration {
address underlying;
address aToken;
uint256 leaveBehind;
}

function execute() external {
AaveV3Ethereum.COLLECTOR.transfer(AaveV3EthereumAssets.GHO_UNDERLYING, RECIPIENT_500, 500e18);

AaveV3Ethereum.COLLECTOR.transfer(AaveV3EthereumAssets.GHO_UNDERLYING, RECIPIENT_1000, 1000e18);

AaveV3Ethereum.COLLECTOR.transfer(AaveV3EthereumAssets.GHO_UNDERLYING, IMMUNEFI, 150e18);

Migration[] memory migrations = new Migration[](4);
migrations[0] = Migration({
underlying: AaveV2EthereumAssets.USDT_UNDERLYING,
aToken: AaveV2EthereumAssets.USDT_A_TOKEN,
leaveBehind: 200_000e6
});
migrations[1] = Migration({
underlying: AaveV2EthereumAssets.DAI_UNDERLYING,
aToken: AaveV2EthereumAssets.DAI_A_TOKEN,
leaveBehind: 1e18
});
migrations[2] = Migration({
underlying: AaveV2EthereumAssets.USDC_UNDERLYING,
aToken: AaveV2EthereumAssets.USDC_A_TOKEN,
leaveBehind: 1e6
});
migrations[3] = Migration({
underlying: AaveV2EthereumAssets.WETH_UNDERLYING,
aToken: AaveV2EthereumAssets.WETH_A_TOKEN,
leaveBehind: 1e18
});

for (uint i = 0; i < migrations.length; i++) {
// withdraw underlying
uint256 withdrawAmount = IERC20(migrations[i].aToken).balanceOf(COLLECTOR) -
migrations[i].leaveBehind;
CollectorUtils.IOInput memory input = CollectorUtils.IOInput(
POOL_V2,
migrations[i].underlying,
withdrawAmount
);
CollectorUtils.withdrawFromV2(AaveV3Ethereum.COLLECTOR, input, COLLECTOR);

/// deposit
uint256 balance = IERC20(migrations[i].underlying).balanceOf(COLLECTOR);
input = CollectorUtils.IOInput(POOL_V3, migrations[i].underlying, balance);
CollectorUtils.depositToV3(AaveV3Ethereum.COLLECTOR, input);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {AaveV3Ethereum, AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol';
import {AaveV2EthereumAssets} from 'aave-address-book/AaveV2Ethereum.sol';

import 'forge-std/Test.sol';
import {ProtocolV3TestBase} from 'aave-helpers/src/ProtocolV3TestBase.sol';
import {AaveV3Ethereum_MayFundingUpdatePartB_20240917} from './AaveV3Ethereum_MayFundingUpdatePartB_20240917.sol';
import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol';

/**
* @dev Test for AaveV3Ethereum_MayFundingUpdatePartB_20240917
* command: FOUNDRY_PROFILE=mainnet forge test --match-path=src/20240917_AaveV3Ethereum_MayFundingUpdatePartB/AaveV3Ethereum_MayFundingUpdatePartB_20240917.t.sol -vv
*/
contract AaveV3Ethereum_MayFundingUpdatePartB_20240917_Test is ProtocolV3TestBase {
AaveV3Ethereum_MayFundingUpdatePartB_20240917 internal proposal;

address internal COLLECTOR = address(AaveV3Ethereum.COLLECTOR);

function setUp() public {
vm.createSelectFork(vm.rpcUrl('mainnet'), 20880954);
proposal = new AaveV3Ethereum_MayFundingUpdatePartB_20240917();
}

/**
* @dev executes the generic test suite including e2e and config snapshots
*/
function test_defaultProposalExecution() public {
defaultTest(
'AaveV3Ethereum_MayFundingUpdatePartB_20240917',
AaveV3Ethereum.POOL,
address(proposal)
);
}

function test_payout() public {
uint256 balanceBefore500 = IERC20(AaveV3EthereumAssets.GHO_UNDERLYING).balanceOf(
proposal.RECIPIENT_500()
);
uint256 balanceBefore1000 = IERC20(AaveV3EthereumAssets.GHO_UNDERLYING).balanceOf(
proposal.RECIPIENT_1000()
);
uint256 balanceBeforeImmunefy = IERC20(AaveV3EthereumAssets.GHO_UNDERLYING).balanceOf(
proposal.IMMUNEFI()
);

executePayload(vm, address(proposal));

uint256 balanceAfter500 = IERC20(AaveV3EthereumAssets.GHO_UNDERLYING).balanceOf(
proposal.RECIPIENT_500()
);
uint256 balanceAfter1000 = IERC20(AaveV3EthereumAssets.GHO_UNDERLYING).balanceOf(
proposal.RECIPIENT_1000()
);
uint256 balanceAfterImmunefy = IERC20(AaveV3EthereumAssets.GHO_UNDERLYING).balanceOf(
proposal.IMMUNEFI()
);

assertEq(balanceAfter500, balanceBefore500 + 500e18);
assertEq(balanceAfter1000, balanceBefore1000 + 1000e18);
assertEq(balanceAfterImmunefy, balanceBeforeImmunefy + 150e18);
}

function test_migration() public {
/// USDT
uint256 aUsdtV2Before = IERC20(AaveV2EthereumAssets.USDT_A_TOKEN).balanceOf(COLLECTOR);
uint256 aUsdtV3Before = IERC20(AaveV3EthereumAssets.USDT_A_TOKEN).balanceOf(COLLECTOR);
uint256 usdtBefore = IERC20(AaveV2EthereumAssets.USDT_UNDERLYING).balanceOf(COLLECTOR);

/// DAI
uint256 aDaiV2Before = IERC20(AaveV2EthereumAssets.DAI_A_TOKEN).balanceOf(COLLECTOR);
uint256 aDaiV3Before = IERC20(AaveV3EthereumAssets.DAI_A_TOKEN).balanceOf(COLLECTOR);
uint256 daiBefore = IERC20(AaveV2EthereumAssets.DAI_UNDERLYING).balanceOf(COLLECTOR);

/// USDC
uint256 aUsdcV2Before = IERC20(AaveV2EthereumAssets.USDC_A_TOKEN).balanceOf(COLLECTOR);
uint256 aUsdcV3Before = IERC20(AaveV3EthereumAssets.USDC_A_TOKEN).balanceOf(COLLECTOR);
uint256 usdcBefore = IERC20(AaveV2EthereumAssets.USDC_UNDERLYING).balanceOf(COLLECTOR);

/// WETH
uint256 aWethV2Before = IERC20(AaveV2EthereumAssets.WETH_A_TOKEN).balanceOf(COLLECTOR);
uint256 aWethV3Before = IERC20(AaveV3EthereumAssets.WETH_A_TOKEN).balanceOf(COLLECTOR);
uint256 wethBefore = IERC20(AaveV2EthereumAssets.WETH_UNDERLYING).balanceOf(COLLECTOR);

executePayload(vm, address(proposal));

/// USDT
/// note we re-use these variables to avoid stack too deep errors
uint256 v3After = IERC20(AaveV3EthereumAssets.USDT_A_TOKEN).balanceOf(COLLECTOR);
uint256 underlyingAfter = IERC20(AaveV2EthereumAssets.USDT_UNDERLYING).balanceOf(COLLECTOR);
verifyBalances(
aUsdtV2Before,
aUsdtV3Before,
usdtBefore,
v3After,
underlyingAfter,
200_000e6,
0.05e18
);

// /// DAI
v3After = IERC20(AaveV3EthereumAssets.DAI_A_TOKEN).balanceOf(COLLECTOR);
underlyingAfter = IERC20(AaveV2EthereumAssets.DAI_UNDERLYING).balanceOf(COLLECTOR);
verifyBalances(aDaiV2Before, aDaiV3Before, daiBefore, v3After, underlyingAfter, 1e18, 0.10e18);

/// USDC
v3After = IERC20(AaveV3EthereumAssets.USDC_A_TOKEN).balanceOf(COLLECTOR);
underlyingAfter = IERC20(AaveV2EthereumAssets.USDC_UNDERLYING).balanceOf(COLLECTOR);
verifyBalances(
aUsdcV2Before,
aUsdcV3Before,
usdcBefore,
v3After,
underlyingAfter,
1e6,
0.10e18
);

/// WETH
v3After = IERC20(AaveV3EthereumAssets.WETH_A_TOKEN).balanceOf(COLLECTOR);
underlyingAfter = IERC20(AaveV2EthereumAssets.WETH_UNDERLYING).balanceOf(COLLECTOR);
verifyBalances(
aWethV2Before,
aWethV3Before,
wethBefore,
v3After,
underlyingAfter,
1e18,
0.02e18
);
}

function verifyBalances(
uint256 v2Before,
uint256 v3Before,
uint256 underlyingBefore,
uint256 v3After,
uint256 underlyingAfter,
uint256 leaveBehind,
uint256 errorMargin
) internal pure {
/// verify underlying
assertApproxEqRel(underlyingAfter, 0, errorMargin);

/// verify v3 balance
assertApproxEqRel(v3After, (v2Before - leaveBehind) + v3Before + underlyingBefore, errorMargin);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
title: "May Funding Update Part B"
author: "karpatkey_TokenLogic"
discussions: "https://governance.aave.com/t/arfc-may-funding-update/17768/5"
---

## Simple Summary

This AIP will deposit idle assets and migrate v2 treasury holdings to Aave v3 on Ethereum. This AIP also executes the [Request for Bounty Payout - September 2024](https://governance.aave.com/t/bgd-request-for-bounty-payout-september-2024/19256).

## Motivation

This AIP furthers the ongoing migration of Aave DAO Treasury assets from v2 to v3. Additionally, it proposes depositing assets currently not generating yield, which are held in the Treasury from previous funding proposals, into Aave v3 on Ethereum.

## Specification

This AIP will implement the following when executes:

- Deposit idle assets into Aave v3:
- USDC
- DAI
- USDT
- wETH
- Migrate the following assets from v2 to v3 main market:
- All aUSDT excluding 200k
- All aDAI excluding 1
- All aUSDC excluding 1
- All awETH excluding 1
- Pay the following bug bounties:
- $500 to 0x1770776deB0A5CA58439759FAdb5cAA014501241
- $1’000 to 0x7dF98A6e1895fd247aD4e75B8EDa59889fa7310b
- $150 to 0x7119f398b6C06095c6E8964C1f58e7C1BAa79E18 (immunefi.eth). This is the fee corresponding to the 10% of the previous bounties.

## References

- Implementation: [AaveV3Ethereum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240917_AaveV3Ethereum_MayFundingUpdatePartB/AaveV3Ethereum_MayFundingUpdatePartB_20240917.sol)
- Tests: [AaveV3Ethereum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240917_AaveV3Ethereum_MayFundingUpdatePartB/AaveV3Ethereum_MayFundingUpdatePartB_20240917.t.sol)
- [Discussion](https://governance.aave.com/t/arfc-may-funding-update/17768/5)

## Copyright

Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).
Loading

0 comments on commit 6b92283

Please sign in to comment.