Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
Merge branch 'main' of github.com:aave/aave-proposals-aip
Browse files Browse the repository at this point in the history
  • Loading branch information
foodaka committed Oct 20, 2023
2 parents 8f047f4 + b1fe972 commit 195b073
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,78 +2,22 @@
pragma solidity ^0.8.0;

import {IProposalGenericExecutor} from 'aave-helpers/interfaces/IProposalGenericExecutor.sol';
import {AaveSwapper} from 'aave-helpers/swaps/AaveSwapper.sol';
import {AaveMisc} from 'aave-address-book/AaveMisc.sol';
import {AaveV3Ethereum, AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol';

/**
* @title Aave Events & Sponsorship Budget Proposal
* @dev (1) Swap aEthDAI & aEthUSDT to GHO; (2) Transfer GHO to Aave Co receiver address.
* @dev Transfer GHO to Aave Co receiver address.
* @author AaveCo
* - Snapshot: https://snapshot.org/#/aave.eth/proposal/0xdcb072d9782c5160d824ee37919c1be35024bd5aec579a86fdfc024f60213ca1
* - Discussion: https://governance.aave.com/t/temp-check-aave-events-sponsorship-budget/14953
*/
contract AaveV3_Ethereum_EventsAip_20231010 is IProposalGenericExecutor {
address public constant MILKMAN = 0x11C76AD590ABDFFCD980afEC9ad951B160F02797;
address public constant CL_PRICE_CHECKER = 0xe80a1C615F75AFF7Ed8F08c9F21f9d00982D666c;
address public constant RECEIVER = 0x1c037b3C22240048807cC9d7111be5d455F640bd;

uint256 public constant USDT_AMOUNT = 275_000e6;
uint256 public constant DAI_AMOUNT = 275_000e18;

address public constant USDT_ORACLE = 0x3E7d1eAB13ad0104d2750B8863b489D65364e32D;
address public constant GHO_ORACLE = 0x3f12643D3f6f874d39C2a4c9f2Cd6f2DbAC877FC;
address public constant DAI_ORACLE = 0xAed0c38402a5d19df6E4c03F4E2DceD6e29c1ee9;

uint256 public constant SWAP_SLIPPAGE = 100; // 1.00%
uint256 public constant GHO_AMOUNT = 550_000e18;

function execute() external {
// transfers aTokens to this contract
AaveV3Ethereum.COLLECTOR.transfer(
AaveV3EthereumAssets.USDT_A_TOKEN,
address(this),
USDT_AMOUNT
);
AaveV3Ethereum.COLLECTOR.transfer(AaveV3EthereumAssets.DAI_A_TOKEN, address(this), DAI_AMOUNT);

AaveSwapper swapper = AaveSwapper(AaveMisc.AAVE_SWAPPER_ETHEREUM);

// Withdraws aTokens for swap
uint256 executorUsdtBalance = AaveV3Ethereum.POOL.withdraw(
AaveV3EthereumAssets.USDT_UNDERLYING,
type(uint256).max,
address(swapper)
);

uint256 executorDAIBalance = AaveV3Ethereum.POOL.withdraw(
AaveV3EthereumAssets.DAI_UNDERLYING,
type(uint256).max,
address(swapper)
);

// Do Swaps
swapper.swap(
MILKMAN,
CL_PRICE_CHECKER,
AaveV3EthereumAssets.USDT_UNDERLYING,
AaveV3EthereumAssets.GHO_UNDERLYING,
USDT_ORACLE,
GHO_ORACLE,
RECEIVER,
executorUsdtBalance,
SWAP_SLIPPAGE
);

swapper.swap(
MILKMAN,
CL_PRICE_CHECKER,
AaveV3EthereumAssets.DAI_UNDERLYING,
AaveV3EthereumAssets.GHO_UNDERLYING,
DAI_ORACLE,
GHO_ORACLE,
RECEIVER,
executorDAIBalance,
SWAP_SLIPPAGE
);
// transfers gho tokens to receiver
AaveV3Ethereum.COLLECTOR.transfer(AaveV3EthereumAssets.GHO_UNDERLYING, RECEIVER, GHO_AMOUNT);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,81 +16,63 @@ import 'forge-std/console.sol';
* @dev Test for AaveV3_Ethereum_EventsAip_20231010
* command: make test-contract filter=AaveV3_Ethereum_EventsAip_20231010
*/
// https://github.com/charlesndalton/milkman

contract AaveV3_Ethereum_EventsAip_20231010_Test is ProtocolV2TestBase {
AaveV3_Ethereum_EventsAip_20231010 internal proposal;

address daiMilkmanCreatedContract = 0x0eB322ac55dB67a5cA0810BA0eDae3501b1B7263;
address usdtMilkmanCreatedContract = 0x3Df592eae98c2b4f312ADE339C01BBE2C8444618;
address RECEIVER = 0x1c037b3C22240048807cC9d7111be5d455F640bd;
address COLLECTOR = 0x464C71f6c2F760DdA6093dCB91C24c39e5d6e18c;

uint256 public constant GHO_AMOUNT = 550_000e18;

function setUp() public {
vm.createSelectFork(vm.rpcUrl('mainnet'), 18334762);
vm.createSelectFork(vm.rpcUrl('mainnet'), 18390065);
proposal = new AaveV3_Ethereum_EventsAip_20231010();
}

function testProposalExecution() public {
uint256 FUNDING_AMOUNT = 550_000 * 1e18;

uint256 usdtAmount = 275_000e6;
uint256 daiAmount = 275_000e18;

AaveV3_Ethereum_EventsAip_20231010 payload = new AaveV3_Ethereum_EventsAip_20231010();

uint256 balanceBefore = IERC20(AaveV3EthereumAssets.GHO_UNDERLYING).balanceOf(RECEIVER);

console.log('balance before --->', balanceBefore);

GovHelpers.executePayload(vm, address(payload), AaveGovernanceV2.SHORT_EXECUTOR);

/// check if proxy contracts got the assets to swap
uint256 usdtBalanceAfter = IERC20(AaveV3EthereumAssets.USDT_UNDERLYING).balanceOf(
usdtMilkmanCreatedContract
uint256 ghoBalanceBeforeFunding = IERC20(AaveV3EthereumAssets.GHO_UNDERLYING).balanceOf(
COLLECTOR
);

uint256 daiBalanceAfter = IERC20(AaveV3EthereumAssets.DAI_UNDERLYING).balanceOf(
daiMilkmanCreatedContract
// Simulates having appropriate funds in proxy
// https://app.aave.com/governance/proposal/?proposalId=347
// 0x121fE3fC3f617ACE9730203d2E27177131C4315e
// https://github.com/bgd-labs/aave-proposals/blob/545b17d8817e8aa86d99db94bfd1e4a2ae575f3d/src/20230926_AaveV3_Eth_GHOFunding/AaveV3_Ethereum_GHOFunding_20230926.t.sol#L39
uint256 daiBalanceProxyBefore = IERC20(AaveV2EthereumAssets.DAI_UNDERLYING).balanceOf(
0x0eB322ac55dB67a5cA0810BA0eDae3501b1B7263
);
console.log('usdtBalanceAfter', usdtBalanceAfter);
console.log('daiBalanceAfter', daiBalanceAfter);
uint256 simulatedSwapBalance = 370_000e18 +
IERC20(AaveV2EthereumAssets.DAI_A_TOKEN).balanceOf(COLLECTOR);

/// aaveSwapper never really holds any assets that are earmarked for a swap
/// the swap function creates a proxy contract for each swap, and those proxies hold the assets waiting to be swapped
assertEq(usdtBalanceAfter, usdtAmount);
assertEq(daiBalanceAfter, daiAmount);
}

function testGHOTransferFromUSDTSwap() public {
uint256 amount = 1000 * 1e18;
deal(AaveV3EthereumAssets.GHO_UNDERLYING, usdtMilkmanCreatedContract, amount);
GovHelpers.passVoteAndExecute(vm, 347);

uint256 balanceBefore = IERC20(AaveV3EthereumAssets.GHO_UNDERLYING).balanceOf(
usdtMilkmanCreatedContract
uint256 daiBalanceProxyAfter = IERC20(AaveV2EthereumAssets.DAI_UNDERLYING).balanceOf(
0x0eB322ac55dB67a5cA0810BA0eDae3501b1B7263
);

assertEq(balanceBefore, amount);
// 0.001e18 is 0.1%
assertApproxEqRel(daiBalanceProxyBefore + simulatedSwapBalance, daiBalanceProxyAfter, 0.001e18);

vm.prank(usdtMilkmanCreatedContract);
IERC20(AaveV3EthereumAssets.GHO_UNDERLYING).transfer(RECEIVER, amount);

uint256 balanceAfter = IERC20(AaveV3EthereumAssets.GHO_UNDERLYING).balanceOf(RECEIVER);
assertEq(balanceAfter, amount);
}
// assume DAI swapped for GHO
deal(
address(AaveV3EthereumAssets.GHO_UNDERLYING),
COLLECTOR,
GHO_AMOUNT + ghoBalanceBeforeFunding
);
uint256 ghoBalanceAfterFunding = IERC20(AaveV3EthereumAssets.GHO_UNDERLYING).balanceOf(
COLLECTOR
);

function testGHOTransferFromDAISwap() public {
uint256 amount = 1000 * 1e18;
deal(AaveV3EthereumAssets.GHO_UNDERLYING, daiMilkmanCreatedContract, amount);
assertEq(ghoBalanceAfterFunding, ghoBalanceBeforeFunding + GHO_AMOUNT);

uint256 balanceBefore = IERC20(AaveV3EthereumAssets.GHO_UNDERLYING).balanceOf(
daiMilkmanCreatedContract
);
uint256 receiverBalanceBefore = IERC20(AaveV3EthereumAssets.GHO_UNDERLYING).balanceOf(RECEIVER);

assertEq(balanceBefore, amount);
GovHelpers.executePayload(vm, address(payload), AaveGovernanceV2.SHORT_EXECUTOR);

vm.prank(daiMilkmanCreatedContract);
IERC20(AaveV3EthereumAssets.GHO_UNDERLYING).transfer(RECEIVER, amount);
uint256 receiverBalanceAfter = IERC20(AaveV3EthereumAssets.GHO_UNDERLYING).balanceOf(RECEIVER);

uint256 balanceAfter = IERC20(AaveV3EthereumAssets.GHO_UNDERLYING).balanceOf(RECEIVER);
assertEq(balanceAfter, amount);
assertEq(receiverBalanceAfter, receiverBalanceBefore + GHO_AMOUNT);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {AaveV3_Ethereum_EventsAip_20231010} from './AaveV3_Ethereum_EventsAip_20

/**
* @dev Deploy AaveV3_Ethereum_EventsAip_20231010
* command: make deploy-ledger contract=src/20231010_AaveV3_Eth_EventsAip/AaveV2_EventsAip_20231010.s.sol:DeployEthereum chain=mainnet
* command: make deploy-ledger contract=src/20231010_AaveV3_Eth_EventsAip/AaveV3_Ethereum_EventsAip_20231010.s.sol:DeployEthereum chain=mainnet
*/
contract DeployEthereum is EthereumScript {
function run() external broadcast {
Expand All @@ -17,7 +17,7 @@ contract DeployEthereum is EthereumScript {

/**
* @dev Create Proposal
* command: make deploy-ledger contract=src/20231010_AaveV3_Eth_EventsAip/AaveV2_EventsAip_20231010.s.sol:CreateProposal chain=mainnet
* command: make deploy-ledger contract=src/20231010_AaveV3_Eth_EventsAip/AaveV3_Ethereum_EventsAip_20231010.s.sol:CreateProposal chain=mainnet
*/
contract CreateProposal is EthereumScript {
function run() external broadcast {
Expand Down

0 comments on commit 195b073

Please sign in to comment.