generated from bgd-labs/bgd-forge-template
/
AaveV3Ethereum_RequestForBountyPayoutJanuary2024_20240125.t.sol
63 lines (52 loc) · 2.34 KB
/
AaveV3Ethereum_RequestForBountyPayoutJanuary2024_20240125.t.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import 'forge-std/Test.sol';
import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol';
import {AaveV2Ethereum, AaveV2EthereumAssets} from 'aave-address-book/AaveV2Ethereum.sol';
import {CommonTestBase} from 'aave-helpers/CommonTestBase.sol';
import {AaveV3Ethereum_RequestForBountyPayoutJanuary2024_20240125} from './AaveV3Ethereum_RequestForBountyPayoutJanuary2024_20240125.sol';
/**
* @dev Test for AaveV3Ethereum_RequestForBountyPayoutJanuary2024_20240125
* command: make test-contract filter=AaveV3Ethereum_RequestForBountyPayoutJanuary2024_20240125
*/
contract AaveV3Ethereum_RequestForBountyPayoutJanuary2024_20240125_Test is CommonTestBase {
AaveV3Ethereum_RequestForBountyPayoutJanuary2024_20240125 internal proposal;
uint256 TOTAL_AMOUNT = 16_000e6;
function setUp() public {
vm.createSelectFork(vm.rpcUrl('mainnet'), 19081060);
proposal = new AaveV3Ethereum_RequestForBountyPayoutJanuary2024_20240125();
}
/**
* @dev Checking:
* - Balances post-transfer are correct
* - Collector has enough funds
*/
function test_consistentBalances() public {
AaveV3Ethereum_RequestForBountyPayoutJanuary2024_20240125.Bounty[3] memory bounties = proposal
.getBounties();
uint256[] memory balancesRecipientsBefore = new uint256[](3);
uint256 balanceCollectorBefore = IERC20(AaveV2EthereumAssets.USDC_A_TOKEN).balanceOf(
address(AaveV2Ethereum.COLLECTOR)
);
// Validate the Collector has enough aUSDC v2
assertGe(balanceCollectorBefore, TOTAL_AMOUNT);
for (uint256 i = 0; i < bounties.length; i++) {
balancesRecipientsBefore[i] = IERC20(AaveV2EthereumAssets.USDC_A_TOKEN).balanceOf(
bounties[i].recipient
);
}
executePayload(vm, address(proposal));
for (uint256 i = 0; i < bounties.length; i++) {
assertApproxEqAbs(
IERC20(AaveV2EthereumAssets.USDC_A_TOKEN).balanceOf(bounties[i].recipient),
balancesRecipientsBefore[i] + bounties[i].amount,
1
);
}
uint256 balanceCollectorAfter = IERC20(AaveV2EthereumAssets.USDC_A_TOKEN).balanceOf(
address(AaveV2Ethereum.COLLECTOR)
);
// Checking worst case scenario of 3 wei imprecision, but probabilistically pretty rare
assertApproxEqAbs(balanceCollectorAfter, balanceCollectorBefore - TOTAL_AMOUNT, 3);
}
}