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

Add test for AVAX retro funding payload, fix amounts #14

Merged
merged 9 commits into from Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;


import {AaveV3Avalanche, AaveV3AvalancheAssets} from 'aave-address-book/AaveV3Avalanche.sol';
import {IProposalGenericExecutor} from 'aave-helpers/interfaces/IProposalGenericExecutor.sol';


/**
* @title AAVE V3 AVAX Retro funding proposal
* @author @marczeller - Aave-Chan Initiative
* Governance Forum Post: https://governance.aave.com/t/arc-aave-v3-retroactive-funding/9250
* Snapshot: https://snapshot.org/#/aave.eth/proposal/bafkreia45d5m6y3o4b476ykp6q65v3zlecxvz6h57tdfhowqm5wb5nzdvq
*/
contract AaveV3AvaxretrofundingPayload is IProposalGenericExecutor {
address public constant AAVECO_ADDRESS = 0xa8F8E9c54e099c4fADB797f5196E07ce484824aF;
address public constant aAvaWAVAX = AaveV3AvalancheAssets.WAVAX_A_TOKEN;
address public constant avWAVAX = 0xDFE521292EcE2A4f44242efBcD66Bc594CA9714B;
address public constant aAvaWBTC = AaveV3AvalancheAssets.WBTCe_A_TOKEN;
address public constant avWBTC = 0x686bEF2417b6Dc32C50a3cBfbCC3bb60E1e9a15D;

uint256 public constant AMOUNT_aAvaWAVAX = 9_584_301837000000000000;
uint256 public constant AMOUNT_avWAVAX = 19_415_698163000000000000;

uint256 public constant AMOUNT_aAvaWBTC = 1_07727500;
uint256 public constant AMOUNT_avWBTC = 1_80714600;


function execute() external {
AaveV3Avalanche.COLLECTOR.transfer(aAvaWAVAX, AAVECO_ADDRESS, AMOUNT_aAvaWAVAX);
AaveV3Avalanche.COLLECTOR.transfer(avWAVAX, AAVECO_ADDRESS, AMOUNT_avWAVAX);
AaveV3Avalanche.COLLECTOR.transfer(aAvaWBTC, AAVECO_ADDRESS, AMOUNT_aAvaWBTC);
AaveV3Avalanche.COLLECTOR.transfer(avWBTC, AAVECO_ADDRESS, AMOUNT_avWBTC);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;

import 'forge-std/Test.sol';

import {AaveV3AvaxretrofundingPayload} from './AaveV3AvaxretrofundingPayload_20230626.sol';
import {AaveV3Avalanche} from 'aave-address-book/AaveV3Avalanche.sol';
import {GovHelpers, TestWithExecutor} from 'aave-helpers/GovHelpers.sol';
marczeller marked this conversation as resolved.
Show resolved Hide resolved
import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol';

contract AaveV3AvaxretrofundingPayloadTest is TestWithExecutor {
struct TokenBalances {
uint256 aAvaWAVAX;
uint256 avWAVAX;
uint256 aAvaWBTC;
uint256 avWBTC;
}

address public constant COLLECTOR_ADDRESS = address(AaveV3Avalanche.COLLECTOR);
address public constant AAVECO_ADDRESS = 0xa8F8E9c54e099c4fADB797f5196E07ce484824aF;

address public constant aAvaWAVAX = 0x6d80113e533a2C0fe82EaBD35f1875DcEA89Ea97;
address public constant avWAVAX = 0xDFE521292EcE2A4f44242efBcD66Bc594CA9714B;
address public constant aAvaWBTC = 0x078f358208685046a11C85e8ad32895DED33A249;
address public constant avWBTC = 0x686bEF2417b6Dc32C50a3cBfbCC3bb60E1e9a15D;

uint256 public constant AMOUNT_aAvaWAVAX = 9584.301837e18;
uint256 public constant AMOUNT_avWAVAX = 19415.698163e18;
uint256 public constant AMOUNT_aAvaWBTC = 1.077275e8;
uint256 public constant AMOUNT_avWBTC = 1.807146e8;

function setUp() public {
vm.createSelectFork(vm.rpcUrl('avalanche'), 32737321);
// Address of the AVAX Guardian
_selectPayloadExecutor(AaveV3Avalanche.ACL_ADMIN);
}

function testExecute() public {
TokenBalances memory collectorBefore = TokenBalances({
aAvaWAVAX: IERC20(aAvaWAVAX).balanceOf(COLLECTOR_ADDRESS),
avWAVAX: IERC20(avWAVAX).balanceOf(COLLECTOR_ADDRESS),
aAvaWBTC: IERC20(aAvaWBTC).balanceOf(COLLECTOR_ADDRESS),
avWBTC: IERC20(avWBTC).balanceOf(COLLECTOR_ADDRESS)
});
TokenBalances memory aaveCoBefore = TokenBalances({
aAvaWAVAX: IERC20(aAvaWAVAX).balanceOf(AAVECO_ADDRESS),
avWAVAX: IERC20(avWAVAX).balanceOf(AAVECO_ADDRESS),
aAvaWBTC: IERC20(aAvaWBTC).balanceOf(AAVECO_ADDRESS),
avWBTC: IERC20(avWBTC).balanceOf(AAVECO_ADDRESS)
});

_executePayload(address(new AaveV3AvaxretrofundingPayload()));

TokenBalances memory collectorAfter = TokenBalances({
aAvaWAVAX: IERC20(aAvaWAVAX).balanceOf(COLLECTOR_ADDRESS),
avWAVAX: IERC20(avWAVAX).balanceOf(COLLECTOR_ADDRESS),
aAvaWBTC: IERC20(aAvaWBTC).balanceOf(COLLECTOR_ADDRESS),
avWBTC: IERC20(avWBTC).balanceOf(COLLECTOR_ADDRESS)
});
TokenBalances memory aaveCoAfter = TokenBalances({
aAvaWAVAX: IERC20(aAvaWAVAX).balanceOf(AAVECO_ADDRESS),
avWAVAX: IERC20(avWAVAX).balanceOf(AAVECO_ADDRESS),
aAvaWBTC: IERC20(aAvaWBTC).balanceOf(AAVECO_ADDRESS),
avWBTC: IERC20(avWBTC).balanceOf(AAVECO_ADDRESS)
});

// Check before/after amounts to ensure they match, allowing a delta of 1 due to AToken rounding
assertApproxEqAbs(collectorBefore.aAvaWAVAX - collectorAfter.aAvaWAVAX, AMOUNT_aAvaWAVAX, 1);
assertApproxEqAbs(aaveCoAfter.aAvaWAVAX - aaveCoBefore.aAvaWAVAX, AMOUNT_aAvaWAVAX, 1);

assertApproxEqAbs(collectorBefore.avWAVAX - collectorAfter.avWAVAX, AMOUNT_avWAVAX, 1);
assertApproxEqAbs(aaveCoAfter.avWAVAX - aaveCoBefore.avWAVAX, AMOUNT_avWAVAX, 1);

assertApproxEqAbs(collectorBefore.aAvaWBTC - collectorAfter.aAvaWBTC, AMOUNT_aAvaWBTC, 1);
assertApproxEqAbs(aaveCoAfter.aAvaWBTC - aaveCoBefore.aAvaWBTC, AMOUNT_aAvaWBTC, 1);

assertApproxEqAbs(collectorBefore.avWBTC - collectorAfter.avWBTC, AMOUNT_avWBTC, 1);
assertApproxEqAbs(aaveCoAfter.avWBTC - aaveCoBefore.avWBTC, AMOUNT_avWBTC, 1);
}
marczeller marked this conversation as resolved.
Show resolved Hide resolved
}
11 changes: 11 additions & 0 deletions src/AaveV3AvaxretrofundingPayload_20230626/DeployAvaxRetro.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
import {AvalancheScript, EthereumScript} from 'aave-helpers/ScriptUtils.sol';
import {GovHelpers} from 'aave-helpers/GovHelpers.sol';
import {AaveV3AvaxretrofundingPayload} from 'src/AaveV3AvaxretrofundingPayload_20230626/AaveV3AvaxretrofundingPayload_20230626.sol';

contract DeployAvaxRetroPayload is AvalancheScript {
function run() external broadcast {
new AaveV3AvaxretrofundingPayload();
}
}
Loading