Skip to content

Commit ed557e3

Browse files
checkpoint
Signed-off-by: Elliot <[email protected]>
1 parent ccc8768 commit ed557e3

File tree

6 files changed

+57
-18
lines changed

6 files changed

+57
-18
lines changed
File renamed without changes.

src/exercises/03/Vault03.sol

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {VaultStorageOwnable} from
1010
"src/exercises/storage/VaultStorageOwnable.sol";
1111

1212
/// @notice Add maxsupply to the vault and update getNormalizedAmount logic
13-
/// deploy Vault 03 to mainnet
1413
/// add integration tests
1514
contract Vault is VaultStorageOwnable {
1615
using SafeERC20 for IERC20;
@@ -180,7 +179,7 @@ contract Vault is VaultStorageOwnable {
180179
uint8 decimals = IERC20Metadata(token).decimals();
181180
normalizedAmount = amount;
182181
if (decimals < 18) {
183-
normalizedAmount = amount ** (10 * (18 - decimals));
182+
normalizedAmount = amount * (10 ** (18 - decimals));
184183
}
185184
}
186185
}

src/exercises/04/SIP04.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ contract SIP04 is GovernorBravoProposal {
7070
override
7171
buildModifier(addresses.getAddress("COMPOUND_TIMELOCK_BRAVO"))
7272
{
73+
/// static calls - filtered out
7374
address vaultProxy = addresses.getAddress("VAULT_PROXY");
7475
bytes32 adminSlot =
7576
vm.load(vaultProxy, ERC1967Utils.ADMIN_SLOT);
@@ -115,6 +116,9 @@ contract SIP04 is GovernorBravoProposal {
115116
vm.load(vaultProxy, ERC1967Utils.ADMIN_SLOT);
116117
address proxyAdmin = address(uint160(uint256(adminSlot)));
117118

119+
/// check not paused
120+
/// check logic contract address is v4 impl
121+
118122
assertEq(
119123
ProxyAdmin(proxyAdmin).owner(),
120124
addresses.getAddress("COMPOUND_TIMELOCK_BRAVO"),

src/exercises/storage/VaultStoragePausable.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {Authorized} from "src/exercises/storage/Authorized.sol";
1212
contract VaultStoragePausable is
1313
OwnableUpgradeable,
1414
Supply,
15+
Authorized,
1516
Balances,
16-
PausableUpgradeable,
17-
Authorized
17+
PausableUpgradeable
1818
{}

src/proposals/sips/sips.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

test/TestVault04.t.sol

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,23 @@ contract TestVault04 is Test, SIP04 {
2424
address public usdc;
2525
address public usdt;
2626

27+
function _loadUsers() private {
28+
address[] memory users = new address[](3);
29+
users[0] = userA;
30+
users[1] = userB;
31+
users[2] = userC;
32+
33+
for (uint256 i = 0; i < users.length; i++) {
34+
uint256 daiDepositAmount = 1_000e18;
35+
uint256 usdtDepositAmount = 1_000e8;
36+
uint256 usdcDepositAmount = 1_000e6;
37+
38+
_vaultDeposit(dai, users[i], daiDepositAmount);
39+
_vaultDeposit(usdc, users[i], usdcDepositAmount);
40+
_vaultDeposit(usdt, users[i], usdtDepositAmount);
41+
}
42+
}
43+
2744
function setUp() public {
2845
/// set the environment variables
2946
vm.setEnv("DO_RUN", "false");
@@ -38,10 +55,23 @@ contract TestVault04 is Test, SIP04 {
3855
sip03.setupProposal();
3956
sip03.deploy();
4057

58+
/// set the addresses contrac to the SIP03 addresses for integration testing
59+
setAddresses(sip03.addresses());
60+
dai = addresses.getAddress("DAI");
61+
usdc = addresses.getAddress("USDC");
62+
usdt = addresses.getAddress("USDT");
63+
vault = Vault(addresses.getAddress("VAULT_PROXY"));
64+
65+
vm.prank(vault.owner());
66+
vault.setMaxSupply(100_000_000e18);
67+
68+
/// load data into newly deployed contract
69+
_loadUsers();
70+
4171
/// setup the proposal
4272
setupProposal();
4373

44-
/// copy SIP03 addresses into this contract for integration testing
74+
/// overwrite the newly created proposal Addresses contract
4575
setAddresses(sip03.addresses());
4676

4777
/// deploy contracts from MIP-04
@@ -50,11 +80,20 @@ contract TestVault04 is Test, SIP04 {
5080
/// build and run proposal
5181
build();
5282
simulate();
83+
}
5384

54-
dai = addresses.getAddress("DAI");
55-
usdc = addresses.getAddress("USDC");
56-
usdt = addresses.getAddress("USDT");
57-
vault = Vault(addresses.getAddress("VAULT_PROXY"));
85+
function testSetup() public view {
86+
assertTrue(
87+
vault.authorizedToken(address(dai)), "Dai not whitelisted"
88+
);
89+
assertTrue(
90+
vault.authorizedToken(address(usdc)),
91+
"Usdc not whitelisted"
92+
);
93+
assertTrue(
94+
vault.authorizedToken(address(usdt)),
95+
"Usdt not whitelisted"
96+
);
5897
}
5998

6099
function testVaultDepositDai() public {
@@ -67,16 +106,20 @@ contract TestVault04 is Test, SIP04 {
67106
uint256 daiDepositAmount = 1_000e18;
68107

69108
_vaultDeposit(dai, address(this), daiDepositAmount);
109+
uint256 startingVaultBalance = vault.balanceOf(address(this));
110+
uint256 startingTotalSupplied = vault.totalSupplied();
70111

71112
vault.withdraw(dai, daiDepositAmount);
72113

73114
assertEq(
74115
vault.balanceOf(address(this)),
75-
0,
116+
startingVaultBalance - daiDepositAmount,
76117
"vault dai balance not 0"
77118
);
78119
assertEq(
79-
vault.totalSupplied(), 0, "vault total supplied not 0"
120+
vault.totalSupplied(),
121+
startingTotalSupplied - daiDepositAmount,
122+
"vault total supplied not 0"
80123
);
81124
assertEq(
82125
IERC20(dai).balanceOf(address(this)),

0 commit comments

Comments
 (0)