Skip to content

Commit

Permalink
style: format contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
0xtekgrinder committed Feb 2, 2024
1 parent c2b0bd3 commit 212ffbd
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 18 deletions.
15 changes: 11 additions & 4 deletions contracts/src/Zapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,17 @@ contract Zapper is Owned2Step {
CONSTRUCTOR
//////////////////////////////////////////////////////////////*/

constructor(address initialOwner, address initialSwapRouter, address initialTokenTransferAddress, address initialWarMinter, address initialVault)
Owned2Step(initialOwner)
{
if (initialSwapRouter == address(0) || initialTokenTransferAddress == address(0) || initialWarMinter == address(0) || initialVault == address(0)) revert Errors.ZeroAddress();
constructor(
address initialOwner,
address initialSwapRouter,
address initialTokenTransferAddress,
address initialWarMinter,
address initialVault
) Owned2Step(initialOwner) {
if (
initialSwapRouter == address(0) || initialTokenTransferAddress == address(0)
|| initialWarMinter == address(0) || initialVault == address(0)
) revert Errors.ZeroAddress();

swapRouter = initialSwapRouter;
tokenTransferAddress = initialTokenTransferAddress;
Expand Down
12 changes: 10 additions & 2 deletions contracts/test/Zapper/Constructor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,19 @@ import "./ZapperTest.sol";

contract Constructor is ZapperTest {
function test_constructor_Normal() public {
assertEq(address(zapper.swapRouter()), address(augustusSwapper), "swapRouter is not assigned correctly in constructor");
assertEq(
address(zapper.swapRouter()),
address(augustusSwapper),
"swapRouter is not assigned correctly in constructor"
);
assertEq(address(zapper.owner()), address(owner), "owner is not assigned correctly in constructor");
assertEq(address(zapper.vault()), address(vault), "vault is not assigned correctly in constructor");
assertEq(address(zapper.warMinter()), address(minter), "warMinter is not assigned correctly in constructor");
assertEq(address(zapper.tokenTransferAddress()), address(tokenTransferAddress), "tokenTransferAddress is not assigned correctly in constructor");
assertEq(
address(zapper.tokenTransferAddress()),
address(tokenTransferAddress),
"tokenTransferAddress is not assigned correctly in constructor"
);
}

function test_constructor_ZeroAddressAugustusSwapper() public {
Expand Down
8 changes: 6 additions & 2 deletions contracts/test/Zapper/ZapERC20ToMultipleTokens.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ contract ZapERC20ToMultipleTokens is ZapperTest {
deal(address(cvx), address(zapper), tokenAmount[1]);
deal(alice, erc20Amount);

uint256 expectedMintedAmount = ratios.getMintAmount(address(aura), tokenAmount[0]) + ratios.getMintAmount(address(cvx), tokenAmount[1]);
uint256 expectedMintedAmount =
ratios.getMintAmount(address(aura), tokenAmount[0]) + ratios.getMintAmount(address(cvx), tokenAmount[1]);
uint256 expectedShares = vault.previewDeposit(expectedMintedAmount);

vm.startPrank(alice);
Expand All @@ -33,7 +34,10 @@ contract ZapERC20ToMultipleTokens is ZapperTest {
assertEqDecimal(aura.balanceOf(address(zapper)), 0, 18, "Vault should have no AURA");
assertEqDecimal(cvx.balanceOf(address(zapper)), 0, 18, "Vault should have no CVX");
assertEqDecimal(
staker.balanceOf(address(vault)), stakerBalance + expectedMintedAmount, 18, "Vault should have same staker balance"
staker.balanceOf(address(vault)),
stakerBalance + expectedMintedAmount,
18,
"Vault should have same staker balance"
);
assertEqDecimal(vault.balanceOf(alice), expectedShares, 18, "Alice should have expected shares");
}
Expand Down
5 changes: 4 additions & 1 deletion contracts/test/Zapper/ZapERC20ToSingleToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ contract ZapERC20ToSingleToken is ZapperTest {

assertEqDecimal(IERC20(token).balanceOf(address(zapper)), 0, 18, "Vault should have no AURA");
assertEqDecimal(
staker.balanceOf(address(vault)), stakerBalance + expectedMintedAmount, 18, "Vault should have same staker balance"
staker.balanceOf(address(vault)),
stakerBalance + expectedMintedAmount,
18,
"Vault should have same staker balance"
);
assertEqDecimal(vault.balanceOf(alice), expectedShares, 18, "Alice should have expected shares");
}
Expand Down
13 changes: 8 additions & 5 deletions contracts/test/Zapper/ZapEtherToMultipleTokens.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,20 @@ contract ZapEtherToMultipleTokens is ZapperTest {
deal(address(cvx), address(zapper), tokenAmount[1]);
deal(alice, etherAmount);

uint256 expectedMintedAmount = ratios.getMintAmount(address(aura), tokenAmount[0]) + ratios.getMintAmount(address(cvx), tokenAmount[1]);
uint256 expectedMintedAmount =
ratios.getMintAmount(address(aura), tokenAmount[0]) + ratios.getMintAmount(address(cvx), tokenAmount[1]);
uint256 expectedShares = vault.previewDeposit(expectedMintedAmount);

vm.prank(alice);
zapper.zapEtherToMultipleTokens{value: etherAmount}(tokens, alice, datas);

zapper.zapEtherToMultipleTokens{ value: etherAmount }(tokens, alice, datas);

assertEqDecimal(aura.balanceOf(address(zapper)), 0, 18, "Vault should have no AURA");
assertEqDecimal(cvx.balanceOf(address(zapper)), 0, 18, "Vault should have no CVX");
assertEqDecimal(
staker.balanceOf(address(vault)), stakerBalance + expectedMintedAmount, 18, "Vault should have same staker balance"
staker.balanceOf(address(vault)),
stakerBalance + expectedMintedAmount,
18,
"Vault should have same staker balance"
);
assertEqDecimal(vault.balanceOf(alice), expectedShares, 18, "Alice should have expected shares");
}
Expand All @@ -43,6 +46,6 @@ contract ZapEtherToMultipleTokens is ZapperTest {

vm.prank(alice);
vm.expectRevert(Errors.ZeroValue.selector);
zapper.zapEtherToMultipleTokens{value: 0}(tokens, alice, datas);
zapper.zapEtherToMultipleTokens{ value: 0 }(tokens, alice, datas);
}
}
10 changes: 6 additions & 4 deletions contracts/test/Zapper/ZapEtherToSingleToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ contract ZapEtherToSingleToken is ZapperTest {
uint256 expectedShares = vault.previewDeposit(expectedMintedAmount);

vm.prank(alice);
zapper.zapEtherToSingleToken{value: etherAmount}(address(token), alice, data);

zapper.zapEtherToSingleToken{ value: etherAmount }(address(token), alice, data);

assertEqDecimal(IERC20(token).balanceOf(address(zapper)), 0, 18, "Vault should have no AURA");
assertEqDecimal(
staker.balanceOf(address(vault)), stakerBalance + expectedMintedAmount, 18, "Vault should have same staker balance"
staker.balanceOf(address(vault)),
stakerBalance + expectedMintedAmount,
18,
"Vault should have same staker balance"
);
assertEqDecimal(vault.balanceOf(alice), expectedShares, 18, "Alice should have expected shares");
}
Expand All @@ -36,6 +38,6 @@ contract ZapEtherToSingleToken is ZapperTest {

vm.prank(alice);
vm.expectRevert(Errors.ZeroValue.selector);
zapper.zapEtherToSingleToken{value: 0}(address(token), alice, data);
zapper.zapEtherToSingleToken{ value: 0 }(address(token), alice, data);
}
}

0 comments on commit 212ffbd

Please sign in to comment.