generated from bgd-labs/bgd-forge-template
-
Notifications
You must be signed in to change notification settings - Fork 17
/
AaveV3Ethereum_RequestForBountyPayoutDecember2023_20231213.t.sol
64 lines (52 loc) · 2.38 KB
/
AaveV3Ethereum_RequestForBountyPayoutDecember2023_20231213.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
64
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {AaveV3Ethereum, AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol';
import 'forge-std/Test.sol';
import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol';
import {ProtocolV3TestBase, ReserveConfig} from 'aave-helpers/ProtocolV3TestBase.sol';
import {AaveV3Ethereum_RequestForBountyPayoutDecember2023_20231213} from './AaveV3Ethereum_RequestForBountyPayoutDecember2023_20231213.sol';
/**
* @dev Test for AaveV3Ethereum_RequestForBountyPayoutDecember2023_20231213
* command: make test-contract filter=AaveV3Ethereum_RequestForBountyPayoutDecember2023_20231213
*/
contract AaveV3Ethereum_RequestForBountyPayoutDecember2023_20231213_Test is ProtocolV3TestBase {
AaveV3Ethereum_RequestForBountyPayoutDecember2023_20231213 internal proposal;
uint256 TOTAL_AMOUNT = 23_600 ether;
function setUp() public {
vm.createSelectFork(vm.rpcUrl('mainnet'), 18784397);
proposal = new AaveV3Ethereum_RequestForBountyPayoutDecember2023_20231213();
}
/**
* @dev Checking:
* - Balances post-transfer are correct
* - Collector has enough funds
*/
function test_consistentBalances() public {
AaveV3Ethereum_RequestForBountyPayoutDecember2023_20231213.Bounty[4] memory bounties = proposal
.getBounties();
uint256[] memory balancesRecipientsBefore = new uint256[](4);
uint256 balanceCollectorBefore = IERC20(AaveV3EthereumAssets.DAI_A_TOKEN).balanceOf(
address(AaveV3Ethereum.COLLECTOR)
);
// Validate the Collector has enough aDAI v3
assertGe(balanceCollectorBefore, TOTAL_AMOUNT);
for (uint256 i = 0; i < bounties.length; i++) {
balancesRecipientsBefore[i] = IERC20(AaveV3EthereumAssets.DAI_A_TOKEN).balanceOf(
bounties[i].recipient
);
}
executePayload(vm, address(proposal));
for (uint256 i = 0; i < bounties.length; i++) {
assertApproxEqAbs(
IERC20(AaveV3EthereumAssets.DAI_A_TOKEN).balanceOf(bounties[i].recipient),
balancesRecipientsBefore[i] + bounties[i].amount,
1
);
}
uint256 balanceCollectorAfter = IERC20(AaveV3EthereumAssets.DAI_A_TOKEN).balanceOf(
address(AaveV3Ethereum.COLLECTOR)
);
// Checking worst case scenario of 4 wei imprecision, but probabilistically pretty rare
assertApproxEqAbs(balanceCollectorAfter, balanceCollectorBefore - TOTAL_AMOUNT, 4);
}
}