generated from bgd-labs/bgd-forge-template
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add payload to deposit into v3 * feat: add polygon bridge payload * fix: update tusd oracle to usd based * feat: add tests for swaps * chore: tighten checks on numbers in emits * feat: add withdrawal from arc * chore: rearrange tests * chore: remove usdt migration * chore: update readme * feat: withdraw arc poc * feat: add busd swap * Update src/20231102_Multi_AaveFundingUpdates/AaveFundingUpdates_20231102.s.sol * chore: update block for tests * feat: update to use gov v3 helpers * feat: update README with better description and easier migration on payload * chore: update readme * feat: add payload addresses --------- Co-authored-by: Lukas <lukasstrassel@googlemail.com>
- Loading branch information
Showing
8 changed files
with
661 additions
and
1 deletion.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
src/20231102_Multi_AaveFundingUpdates/AaveFundingUpdates.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
title: "Aave Funding Updates" | ||
author: "TokenLogic" | ||
discussions: "https://governance.aave.com/t/arfc-aave-funding-update/15194" | ||
--- | ||
|
||
## Simple Summary | ||
|
||
This AIP aims to consolidate Aave DAO's stablecoin holdings. It is divided into different parts that are detailed below. Part one is depositing DAI into aEthDAI, part two is migrating aDAI and aUSDT into aEthDAI and aEthUSDT, part three bridges assets from Polygon to Mainnet and part four swaps some holdings into GHO. | ||
|
||
## Motivation | ||
|
||
This proposal intends to ensure the DAO is well capitalised. A separate DAO budget publication will be shared during Q4 2023. | ||
|
||
The DAO has sufficient USDC, DAI and USDT deposited across the various instances of Aave Protocol to support existing streams and the AURA purchase 3. | ||
|
||
However, with the emergence of new service provider proposal expected, the DAO needs to adjust its stable coin holdings. This publication supports transferring additional funds from Polygon to Mainnet and acquiring GHO on the market to ensure the DAO is well capitalised for the next 6 months. It also aims to move assets from the old V2 to the newer V3 aToken. | ||
|
||
## Specification | ||
|
||
- Deposit 1M units of DAI from treasury (Aave V3 Ethereum Collector) into Aave v3 Ethereum | ||
- Migrate all aDAI from Aave v2 Ethereum to Aave v3 Ethereum | ||
|
||
- Redeem 1.7M USDC from Aave v2 Polygon and bridge to Ethereum treasury | ||
- Redeem 0.5M from Aave v2 Polygon DAI and bridge to Ethereum treasury | ||
- Redeem 0.75M from Aave v2 Polygon USDT and bridge to Ethereum treasury | ||
|
||
Swap the following asset holdings to GHO on Ethereum mainnet: | ||
|
||
- All available aTUSD that can be redeemed (~175,000 units at time of writing) | ||
- 500k units of DAI held in treasury (received from previous Polygon bridge) | ||
- All available aBUSD (~72,000 units at time of writing) | ||
|
||
Swap the following asset holdings on Ethereum treasury to USDC (there is no GHO / ETH oracle thus these tokens cannot be swapped to GHO directly, they are Aave v2 Assets with no Aave v3 equivalent oracle): | ||
|
||
- All GUSD (18,464.03) | ||
- All UST (893,257.63) | ||
|
||
## References | ||
|
||
- Implementation: [AaveV2Ethereum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20231102_Multi_AaveFundingUpdates/AaveV2Ethereum_AaveFundingUpdates_20231102.sol), [AaveV2Polygon](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20231102_Multi_AaveFundingUpdates/AaveV2Polygon_AaveFundingUpdates_20231102.sol), [AaveV3Ethereum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20231102_Multi_AaveFundingUpdates/AaveV3Ethereum_AaveFundingUpdates_20231102.sol) | ||
- Tests: [AaveV2Ethereum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20231102_Multi_AaveFundingUpdates/AaveV2Ethereum_AaveFundingUpdates_20231102.t.sol), [AaveV2Polygon](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20231102_Multi_AaveFundingUpdates/AaveV2Polygon_AaveFundingUpdates_20231102.t.sol), [AaveV3Ethereum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20231102_Multi_AaveFundingUpdates/AaveV3Ethereum_AaveFundingUpdates_20231102.t.sol) | ||
- [Snapshot](https://snapshot.org/#/aave.eth/proposal/0x099f88e1728760952be26fcb8fc99b26c29336e6a109820b391751b108399ee5) | ||
- [Discussion](https://governance.aave.com/t/arfc-aave-funding-update/15194) | ||
|
||
## Copyright | ||
|
||
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). |
75 changes: 75 additions & 0 deletions
75
src/20231102_Multi_AaveFundingUpdates/AaveFundingUpdates_20231102.s.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import {GovV3Helpers, IPayloadsControllerCore, PayloadsControllerUtils} from 'aave-helpers/GovV3Helpers.sol'; | ||
import {EthereumScript, PolygonScript} from 'aave-helpers/ScriptUtils.sol'; | ||
import {AaveV2Polygon_AaveFundingUpdates_20231102} from './AaveV2Polygon_AaveFundingUpdates_20231102.sol'; | ||
import {AaveV3Ethereum_AaveFundingUpdates_20231102} from './AaveV3Ethereum_AaveFundingUpdates_20231102.sol'; | ||
|
||
/** | ||
* @dev Deploy Ethereum | ||
* command: make deploy-ledger contract=src/20231102_Multi_AaveFundingUpdates/AaveFundingUpdates_20231102.s.sol:DeployEthereum chain=mainnet | ||
*/ | ||
contract DeployEthereum is EthereumScript { | ||
function run() external broadcast { | ||
// deploy payloads | ||
AaveV3Ethereum_AaveFundingUpdates_20231102 payload0 = new AaveV3Ethereum_AaveFundingUpdates_20231102(); | ||
|
||
// compose action | ||
IPayloadsControllerCore.ExecutionAction[] | ||
memory actions = new IPayloadsControllerCore.ExecutionAction[](1); | ||
actions[0] = GovV3Helpers.buildAction(address(payload0)); | ||
|
||
// register action at payloadsController | ||
GovV3Helpers.createPayload(actions); | ||
} | ||
} | ||
|
||
/** | ||
* @dev Deploy Polygon | ||
* command: make deploy-ledger contract=src/20231102_Multi_AaveFundingUpdates/AaveFundingUpdates_20231102.s.sol:DeployPolygon chain=polygon | ||
*/ | ||
contract DeployPolygon is PolygonScript { | ||
function run() external broadcast { | ||
// deploy payloads | ||
AaveV2Polygon_AaveFundingUpdates_20231102 payload0 = new AaveV2Polygon_AaveFundingUpdates_20231102(); | ||
|
||
// compose action | ||
IPayloadsControllerCore.ExecutionAction[] | ||
memory actions = new IPayloadsControllerCore.ExecutionAction[](1); | ||
actions[0] = GovV3Helpers.buildAction(address(payload0)); | ||
|
||
// register action at payloadsController | ||
GovV3Helpers.createPayload(actions); | ||
} | ||
} | ||
|
||
/** | ||
* @dev Create Proposal | ||
* command: make deploy-ledger contract=src/20231102_Multi_AaveFundingUpdates/AaveFundingUpdates_20231102.s.sol:CreateProposal chain=mainnet | ||
*/ | ||
contract CreateProposal is EthereumScript { | ||
function run() external { | ||
// create payloads | ||
PayloadsControllerUtils.Payload[] memory payloads = new PayloadsControllerUtils.Payload[](1); | ||
|
||
// compose actions for validation | ||
IPayloadsControllerCore.ExecutionAction[] | ||
memory actionsEthereum = new IPayloadsControllerCore.ExecutionAction[](1); | ||
actionsEthereum[0] = GovV3Helpers.buildAction(0x0B60713B53Cf01Ff53111D0BC29743eF1E03C296); | ||
payloads[0] = GovV3Helpers.buildMainnetPayload(vm, actionsEthereum); | ||
|
||
IPayloadsControllerCore.ExecutionAction[] | ||
memory actionsPolygon = new IPayloadsControllerCore.ExecutionAction[](1); | ||
actionsPolygon[0] = GovV3Helpers.buildAction(0x6a226aF2eC3B4B40A669469c1DE48eD26CAB4607); | ||
payloads[1] = GovV3Helpers.buildPolygonPayload(vm, actionsPolygon); | ||
|
||
// create proposal | ||
vm.startBroadcast(); | ||
GovV3Helpers.createProposal2_5( | ||
vm, | ||
payloads, | ||
GovV3Helpers.ipfsHashFile(vm, 'src/20231102_Multi_AaveFundingUpdates/AaveFundingUpdates.md') | ||
); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
src/20231102_Multi_AaveFundingUpdates/AaveV2Polygon_AaveFundingUpdates_20231102.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import {AaveV2Polygon, AaveV2PolygonAssets} from 'aave-address-book/AaveV2Polygon.sol'; | ||
import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol'; | ||
import {MiscPolygon} from 'aave-address-book/MiscPolygon.sol'; | ||
import {IProposalGenericExecutor} from 'aave-helpers/interfaces/IProposalGenericExecutor.sol'; | ||
|
||
interface IAavePolEthERC20Bridge { | ||
function bridge(address token, uint256 amount) external; | ||
} | ||
|
||
/** | ||
* @title Aave Funding Updates | ||
* @author efecarranza.eth | ||
* - Snapshot: https://snapshot.org/#/aave.eth/proposal/0x099f88e1728760952be26fcb8fc99b26c29336e6a109820b391751b108399ee5 | ||
* - Discussion: https://governance.aave.com/t/arfc-aave-funding-update/15194 | ||
*/ | ||
contract AaveV2Polygon_AaveFundingUpdates_20231102 is IProposalGenericExecutor { | ||
IAavePolEthERC20Bridge public constant bridge = | ||
IAavePolEthERC20Bridge(MiscPolygon.AAVE_POL_ETH_BRIDGE); | ||
uint256 public constant USDC_TO_WITHDRAW = 1_700_000e6; | ||
uint256 public constant USDT_TO_WITHDRAW = 750_000e6; | ||
uint256 public constant DAI_TO_WITHDRAW = 500_000e18; | ||
|
||
function execute() external { | ||
AaveV2Polygon.COLLECTOR.transfer( | ||
AaveV2PolygonAssets.USDC_A_TOKEN, | ||
address(this), | ||
USDC_TO_WITHDRAW | ||
); | ||
AaveV2Polygon.COLLECTOR.transfer( | ||
AaveV2PolygonAssets.USDT_A_TOKEN, | ||
address(this), | ||
USDT_TO_WITHDRAW | ||
); | ||
AaveV2Polygon.COLLECTOR.transfer( | ||
AaveV2PolygonAssets.DAI_A_TOKEN, | ||
address(this), | ||
DAI_TO_WITHDRAW | ||
); | ||
|
||
uint256 usdcWithdrawn = AaveV2Polygon.POOL.withdraw( | ||
AaveV2PolygonAssets.USDC_UNDERLYING, | ||
type(uint256).max, | ||
MiscPolygon.AAVE_POL_ETH_BRIDGE | ||
); | ||
uint256 usdtWithdrawn = AaveV2Polygon.POOL.withdraw( | ||
AaveV2PolygonAssets.USDT_UNDERLYING, | ||
type(uint256).max, | ||
MiscPolygon.AAVE_POL_ETH_BRIDGE | ||
); | ||
uint256 daiWithdrawn = AaveV2Polygon.POOL.withdraw( | ||
AaveV2PolygonAssets.DAI_UNDERLYING, | ||
type(uint256).max, | ||
MiscPolygon.AAVE_POL_ETH_BRIDGE | ||
); | ||
|
||
bridge.bridge(AaveV2PolygonAssets.USDC_UNDERLYING, usdcWithdrawn); | ||
bridge.bridge(AaveV2PolygonAssets.USDT_UNDERLYING, usdtWithdrawn); | ||
bridge.bridge(AaveV2PolygonAssets.DAI_UNDERLYING, daiWithdrawn); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
src/20231102_Multi_AaveFundingUpdates/AaveV2Polygon_AaveFundingUpdates_20231102.t.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol'; | ||
import {GovV3Helpers} from 'aave-helpers/GovV3Helpers.sol'; | ||
import {GovernanceV3Polygon} from 'aave-address-book/GovernanceV3Polygon.sol'; | ||
import {AaveV2Polygon, AaveV2PolygonAssets} from 'aave-address-book/AaveV2Polygon.sol'; | ||
import {MiscPolygon} from 'aave-address-book/MiscPolygon.sol'; | ||
import {ProtocolV2TestBase, ReserveConfig} from 'aave-helpers/ProtocolV2TestBase.sol'; | ||
import {AaveV2Polygon_AaveFundingUpdates_20231102} from './AaveV2Polygon_AaveFundingUpdates_20231102.sol'; | ||
|
||
/** | ||
* @dev Test for AaveV2Polygon_AaveFundingUpdates_20231102 | ||
* command: make test-contract filter=AaveV2Polygon_AaveFundingUpdates_20231102 | ||
*/ | ||
contract AaveV2Polygon_AaveFundingUpdates_20231102_Test is ProtocolV2TestBase { | ||
event Bridge(address token, uint256 amount); | ||
|
||
AaveV2Polygon_AaveFundingUpdates_20231102 internal proposal; | ||
|
||
function setUp() public { | ||
vm.createSelectFork(vm.rpcUrl('polygon'), 50216002); | ||
proposal = new AaveV2Polygon_AaveFundingUpdates_20231102(); | ||
} | ||
|
||
function test_execute() public { | ||
uint256 usdcBalanceBefore = IERC20(AaveV2PolygonAssets.USDC_A_TOKEN).balanceOf( | ||
address(AaveV2Polygon.COLLECTOR) | ||
); | ||
uint256 usdtBalanceBefore = IERC20(AaveV2PolygonAssets.USDT_A_TOKEN).balanceOf( | ||
address(AaveV2Polygon.COLLECTOR) | ||
); | ||
uint256 daiBalanceBefore = IERC20(AaveV2PolygonAssets.DAI_A_TOKEN).balanceOf( | ||
address(AaveV2Polygon.COLLECTOR) | ||
); | ||
|
||
vm.expectEmit(true, true, false, false, MiscPolygon.AAVE_POL_ETH_BRIDGE); | ||
emit Bridge(AaveV2PolygonAssets.USDC_UNDERLYING, proposal.USDC_TO_WITHDRAW()); | ||
|
||
vm.expectEmit(true, true, false, false, MiscPolygon.AAVE_POL_ETH_BRIDGE); | ||
emit Bridge(AaveV2PolygonAssets.USDT_UNDERLYING, proposal.USDT_TO_WITHDRAW()); | ||
|
||
vm.expectEmit(true, true, false, false, MiscPolygon.AAVE_POL_ETH_BRIDGE); | ||
emit Bridge(AaveV2PolygonAssets.DAI_UNDERLYING, proposal.DAI_TO_WITHDRAW()); | ||
|
||
GovV3Helpers.executePayload(vm, address(proposal)); | ||
|
||
assertApproxEqRel( | ||
IERC20(AaveV2PolygonAssets.USDC_A_TOKEN).balanceOf(address(AaveV2Polygon.COLLECTOR)), | ||
usdcBalanceBefore - proposal.USDC_TO_WITHDRAW(), | ||
0.001e18 | ||
); | ||
assertApproxEqRel( | ||
IERC20(AaveV2PolygonAssets.USDT_A_TOKEN).balanceOf(address(AaveV2Polygon.COLLECTOR)), | ||
usdtBalanceBefore - proposal.USDT_TO_WITHDRAW(), | ||
0.001e18 | ||
); | ||
assertApproxEqRel( | ||
IERC20(AaveV2PolygonAssets.DAI_A_TOKEN).balanceOf(address(AaveV2Polygon.COLLECTOR)), | ||
daiBalanceBefore - proposal.DAI_TO_WITHDRAW(), | ||
0.001e18 | ||
); | ||
} | ||
} |
Oops, something went wrong.
b45e67c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Foundry report
Build log
Test success 🌈