-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bbb36e1
commit aed6a70
Showing
21 changed files
with
536 additions
and
429 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.23; | ||
|
||
// Test imports | ||
import {Fork_Shared_Test_} from "test/fork/shared/Shared.sol"; | ||
|
||
contract Fork_Concrete_LidoFixedPriceMultiLpARM_Constructor_Test is Fork_Shared_Test_ { | ||
////////////////////////////////////////////////////// | ||
/// --- SETUP | ||
////////////////////////////////////////////////////// | ||
function setUp() public override { | ||
super.setUp(); | ||
} | ||
|
||
////////////////////////////////////////////////////// | ||
/// --- PASSING TESTS | ||
////////////////////////////////////////////////////// | ||
function test_Initial_State() public { | ||
assertEq(lidoARM.name(), "Lido ARM"); | ||
assertEq(lidoARM.symbol(), "ARM-ST"); | ||
assertEq(lidoARM.owner(), address(this)); | ||
assertEq(lidoARM.operator(), operator); | ||
assertEq(lidoARM.feeCollector(), feeCollector); | ||
assertEq(lidoARM.fee(), 2000); | ||
assertEq(lidoARM.lastTotalAssets(), 1e12); | ||
assertEq(lidoARM.feesAccrued(), 0); | ||
// the 20% performance fee is removed on initialization | ||
assertEq(lidoARM.totalAssets(), 1e12); | ||
assertEq(lidoARM.totalSupply(), 1e12); | ||
assertEq(weth.balanceOf(address(lidoARM)), 1e12); | ||
assertEq(lidoARM.totalAssetsCap(), 100 ether); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.23; | ||
|
||
// Test imports | ||
import {Fork_Shared_Test_} from "test/fork/shared/Shared.sol"; | ||
|
||
contract Fork_Concrete_LidoFixedPriceMultiLpARM_Deposit_Test_ is Fork_Shared_Test_ { | ||
AssertData beforeData; | ||
DeltaData noChangeDeltaData = | ||
DeltaData({totalAssets: 10, totalSupply: 0, totalAssetsCap: 0, armWeth: 0, armSteth: 0, feesAccrued: 0}); | ||
|
||
struct AssertData { | ||
uint256 totalAssets; | ||
uint256 totalSupply; | ||
uint256 totalAssetsCap; | ||
uint256 armWeth; | ||
uint256 armSteth; | ||
uint256 feesAccrued; | ||
} | ||
|
||
struct DeltaData { | ||
int256 totalAssets; | ||
int256 totalSupply; | ||
int256 totalAssetsCap; | ||
int256 armWeth; | ||
int256 armSteth; | ||
int256 feesAccrued; | ||
} | ||
|
||
function _snapData() internal view returns (AssertData memory data) { | ||
return AssertData({ | ||
totalAssets: lidoARM.totalAssets(), | ||
totalSupply: lidoARM.totalSupply(), | ||
totalAssetsCap: lidoARM.totalAssetsCap(), | ||
armWeth: weth.balanceOf(address(lidoARM)), | ||
armSteth: steth.balanceOf(address(lidoARM)), | ||
feesAccrued: lidoARM.feesAccrued() | ||
}); | ||
} | ||
|
||
function assertData(AssertData memory before, DeltaData memory delta) internal view { | ||
AssertData memory afterData = _snapData(); | ||
|
||
assertEq(int256(afterData.totalAssets), int256(before.totalAssets) + delta.totalAssets, "totalAssets"); | ||
assertEq(int256(afterData.totalSupply), int256(before.totalSupply) + delta.totalSupply, "totalSupply"); | ||
assertEq( | ||
int256(afterData.totalAssetsCap), int256(before.totalAssetsCap) + delta.totalAssetsCap, "totalAssetsCap" | ||
); | ||
assertEq(int256(afterData.feesAccrued), int256(before.feesAccrued) + delta.feesAccrued, "feesAccrued"); | ||
assertEq(int256(afterData.armWeth), int256(before.armWeth) + delta.armWeth, "armWeth"); | ||
assertEq(int256(afterData.armSteth), int256(before.armSteth) + delta.armSteth, "armSteth"); | ||
} | ||
|
||
////////////////////////////////////////////////////// | ||
/// --- SETUP | ||
////////////////////////////////////////////////////// | ||
function setUp() public override { | ||
super.setUp(); | ||
} | ||
|
||
////////////////////////////////////////////////////// | ||
/// --- PASSING TESTS | ||
////////////////////////////////////////////////////// | ||
function test_Deposit_SimpleCase() public setLiquidityProviderCap(address(this), 20 ether) { | ||
deal(address(weth), address(this), 10 ether); | ||
beforeData = _snapData(); | ||
|
||
lidoARM.deposit(10 ether); | ||
|
||
DeltaData memory delta = noChangeDeltaData; | ||
delta.totalAssets = 10 ether; | ||
delta.totalSupply = 10 ether; | ||
delta.armWeth = 10 ether; | ||
assertData(beforeData, delta); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.23; | ||
|
||
// Test imports | ||
import {Fork_Shared_Test_} from "test/fork/shared/Shared.sol"; | ||
|
||
contract Fork_Concrete_LidoFixedPriceMultiLpARM_RequestRedeem_Test_ is Fork_Shared_Test_ { | ||
////////////////////////////////////////////////////// | ||
/// --- SETUP | ||
////////////////////////////////////////////////////// | ||
function setUp() public override { | ||
super.setUp(); | ||
} | ||
|
||
////////////////////////////////////////////////////// | ||
/// --- PASSING TESTS | ||
////////////////////////////////////////////////////// | ||
function test_RequestRedeem_SimpleCase() public setLiquidityProviderCap(address(this), 20 ether) { | ||
deal(address(weth), address(this), 10 ether); | ||
|
||
lidoARM.deposit(10 ether); | ||
lidoARM.requestRedeem(8 ether); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.23; | ||
|
||
// Test imports | ||
import {Fork_Shared_Test_} from "test/fork/shared/Shared.sol"; | ||
|
||
contract Fork_Concrete_LidoOwnerLpARM_Setters_Test_ is Fork_Shared_Test_ { | ||
////////////////////////////////////////////////////// | ||
/// --- SETUP | ||
////////////////////////////////////////////////////// | ||
function setUp() public override { | ||
super.setUp(); | ||
} | ||
|
||
////////////////////////////////////////////////////// | ||
/// --- REVERTING TESTS | ||
////////////////////////////////////////////////////// | ||
function test_RevertWhen_SetPrices_Because_PriceCross() public { | ||
vm.expectRevert("ARM: Price cross"); | ||
lidoOwnerLpARM.setPrices(90 * 1e33, 89 * 1e33); | ||
vm.expectRevert("ARM: Price cross"); | ||
lidoOwnerLpARM.setPrices(72, 70); | ||
vm.expectRevert("ARM: Price cross"); | ||
lidoOwnerLpARM.setPrices(1005 * 1e33, 1000 * 1e33); | ||
} | ||
|
||
function test_RevertWhen_SetPrices_Because_TraderateTooHigh() public { | ||
//vm.expectRevert("ARM: Traderates too high"); | ||
//lidoOwnerLpARM.setPrices(1010 * 1e33, 1020 * 1e33); | ||
//vm.expectRevert("ARM: Traderates too high"); | ||
//lidoOwnerLpARM.setPrices(993 * 1e33, 994 * 1e33); | ||
} | ||
|
||
function test_RevertWhen_SetPrices_Because_TooMuchLoss() public { | ||
// Failing | ||
/* | ||
uint256 currentFunds = lidoOwnerLpARM.token0().balanceOf(address(lidoOwnerLpARM)) | ||
+ lidoOwnerLpARM.token1().balanceOf(address(lidoOwnerLpARM)); | ||
// Reduce minimum funds by 100 | ||
lidoOwnerLpARM.setMinimumFunds(currentFunds + 100 ether); | ||
vm.expectRevert("ARM: Too much loss"); | ||
lidoOwnerLpARM.setPrices(992 * 1e33, 1001 * 1e33); | ||
*/ | ||
} | ||
|
||
function test_RevertWhen_SetPrices_Because_NotOwnerOrOperator() public asRandomAddress { | ||
vm.expectRevert("ARM: Only operator or owner can call this function."); | ||
lidoOwnerLpARM.setPrices(0, 0); | ||
} | ||
|
||
function test_RevertWhen_SetOwner_Because_NotOwner() public asRandomAddress { | ||
vm.expectRevert("ARM: Only owner can call this function."); | ||
lidoOwnerLpARM.setOwner(address(0)); | ||
} | ||
|
||
function test_RevertWhen_SetOperator_Because_NotOwner() public asRandomAddress { | ||
vm.expectRevert("ARM: Only owner can call this function."); | ||
lidoOwnerLpARM.setOperator(address(0)); | ||
} | ||
|
||
////////////////////////////////////////////////////// | ||
/// --- PASSING TESTS | ||
////////////////////////////////////////////////////// | ||
// Todo: create a aslidoOwnerLpARMOwner modifier | ||
function test_SetPrices() public { | ||
lidoOwnerLpARM.setPrices(992 * 1e33, 1001 * 1e33); | ||
lidoOwnerLpARM.setPrices(1001 * 1e33, 1004 * 1e33); | ||
lidoOwnerLpARM.setPrices(992 * 1e33, 2000 * 1e33); | ||
|
||
// Check the traderates | ||
assertEq(lidoOwnerLpARM.traderate0(), 500 * 1e33); | ||
assertEq(lidoOwnerLpARM.traderate1(), 992 * 1e33); | ||
} | ||
|
||
function test_SetPrices_When_MinimumFundsHasBeenDecrease() public { | ||
deal(address(weth), address(lidoOwnerLpARM), 100 ether); | ||
uint256 currentFunds = lidoOwnerLpARM.token0().balanceOf(address(lidoOwnerLpARM)) | ||
+ lidoOwnerLpARM.token1().balanceOf(address(lidoOwnerLpARM)); | ||
|
||
// Reduce minimum funds by 100 | ||
lidoOwnerLpARM.setMinimumFunds(currentFunds - 100); | ||
|
||
lidoOwnerLpARM.setPrices(992 * 1e33, 1001 * 1e33); | ||
} | ||
|
||
function test_SetOperator() public { | ||
lidoOwnerLpARM.setOperator(address(this)); | ||
assertEq(lidoOwnerLpARM.operator(), address(this)); | ||
} | ||
|
||
function test_SetMinimumFunds() external { | ||
lidoOwnerLpARM.setMinimumFunds(100 ether); | ||
assertEq(lidoOwnerLpARM.minimumFunds(), 100 ether); | ||
} | ||
} |
Oops, something went wrong.