-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
1d88712
commit 457ff5a
Showing
7 changed files
with
148 additions
and
11 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
65 changes: 65 additions & 0 deletions
65
...p/test/pools/SiloedLockReleaseTokenPool/SiloedLockReleaseTokenPool.provideLiquidity.t.sol
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,65 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.24; | ||
|
||
import {SiloedLockReleaseTokenPoolSetup} from "./SiloedLockReleaseTokenPoolSetup.t.sol"; | ||
|
||
import {SiloedLockReleaseTokenPool} from "../../../pools/SiloedLockReleaseTokenPool.sol"; | ||
import {TokenPool} from "../../../pools/TokenPool.sol"; | ||
|
||
contract SiloedLockReleaseTokenPool_provideLiqudity is SiloedLockReleaseTokenPoolSetup { | ||
address public UNAUTHORIZED_ADDRESS = address(0xdeadbeef); | ||
|
||
function setUp() public override { | ||
super.setUp(); | ||
|
||
s_siloedLockReleaseTokenPool.setRebalancer(SILOED_CHAIN_SELECTOR, OWNER); | ||
} | ||
|
||
function test_ProvideLiquidity_ChainNotSiloed_Success() public { | ||
uint256 amount = 1e24; | ||
|
||
vm.expectEmit(); | ||
emit SiloedLockReleaseTokenPool.LiquidityAdded(DEST_CHAIN_SELECTOR, OWNER, amount); | ||
|
||
s_siloedLockReleaseTokenPool.provideLiquidity(DEST_CHAIN_SELECTOR, amount); | ||
|
||
assertEq(s_token.balanceOf(address(s_siloedLockReleaseTokenPool)), amount); | ||
|
||
// Since the funds for the destination chain are not siloed, | ||
// the locked token amount should not be increased | ||
assertEq(s_siloedLockReleaseTokenPool.getLockedTokensByChain(DEST_CHAIN_SELECTOR), 0); | ||
} | ||
|
||
function test_ProvideLiquidity_ChainSiloed_Success() public { | ||
uint256 amount = 1e24; | ||
|
||
vm.expectEmit(); | ||
emit SiloedLockReleaseTokenPool.LiquidityAdded(SILOED_CHAIN_SELECTOR, OWNER, amount); | ||
|
||
s_siloedLockReleaseTokenPool.provideLiquidity(SILOED_CHAIN_SELECTOR, amount); | ||
|
||
assertEq(s_token.balanceOf(address(s_siloedLockReleaseTokenPool)), amount); | ||
|
||
// Since the funds for the destination chain are not siloed, | ||
// the locked token amount should not be increased | ||
assertEq(s_siloedLockReleaseTokenPool.getLockedTokensByChain(SILOED_CHAIN_SELECTOR), amount); | ||
} | ||
|
||
// Reverts | ||
|
||
function test_ProvideLiquidity_RevertWhen_UnauthorizedForSiloedChain() public { | ||
vm.startPrank(UNAUTHORIZED_ADDRESS); | ||
|
||
vm.expectRevert(abi.encodeWithSelector(TokenPool.Unauthorized.selector, UNAUTHORIZED_ADDRESS)); | ||
|
||
s_siloedLockReleaseTokenPool.provideLiquidity(SILOED_CHAIN_SELECTOR, 1); | ||
} | ||
|
||
function test_ProvideLiquidity_RevertWhen_UnauthorizedForNotSiloedChain() public { | ||
vm.startPrank(UNAUTHORIZED_ADDRESS); | ||
|
||
vm.expectRevert(abi.encodeWithSelector(TokenPool.Unauthorized.selector, UNAUTHORIZED_ADDRESS)); | ||
|
||
s_siloedLockReleaseTokenPool.provideLiquidity(DEST_CHAIN_SELECTOR, 1); | ||
} | ||
} |
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
19 changes: 19 additions & 0 deletions
19
...ccip/test/pools/SiloedLockReleaseTokenPool/SiloedLockReleaseTokenPool.setRebalancer.t.sol
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,19 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.24; | ||
|
||
import {SiloedLockReleaseTokenPool} from "../../../pools/SiloedLockReleaseTokenPool.sol"; | ||
import {SiloedLockReleaseTokenPoolSetup} from "./SiloedLockReleaseTokenPoolSetup.t.sol"; | ||
|
||
contract SiloedLockReleaseTokenPool_setRebalancer is SiloedLockReleaseTokenPoolSetup { | ||
address public REBALANCER_ADDRESS = address(0xdeadbeef); | ||
|
||
function test_setRebalancer_Success() public { | ||
vm.expectEmit(); | ||
emit SiloedLockReleaseTokenPool.RebalancerSet(SILOED_CHAIN_SELECTOR, REBALANCER_ADDRESS, OWNER); | ||
|
||
s_siloedLockReleaseTokenPool.setRebalancer(SILOED_CHAIN_SELECTOR, REBALANCER_ADDRESS); | ||
|
||
assertEq(s_siloedLockReleaseTokenPool.getRebalancerByChain(SILOED_CHAIN_SELECTOR), REBALANCER_ADDRESS); | ||
assertEq(s_siloedLockReleaseTokenPool.getRebalancerByChain(DEST_CHAIN_SELECTOR), OWNER); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
.../test/pools/SiloedLockReleaseTokenPool/SiloedLockReleaseTokenPool.withdrawLiquidity.t.sol
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,47 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.24; | ||
|
||
import {SiloedLockReleaseTokenPoolSetup} from "./SiloedLockReleaseTokenPoolSetup.t.sol"; | ||
|
||
import {SiloedLockReleaseTokenPool} from "../../../pools/SiloedLockReleaseTokenPool.sol"; | ||
|
||
contract SiloedLockReleaseTokenPool_withdrawLiqudity is SiloedLockReleaseTokenPoolSetup { | ||
address public UNAUTHORIZED_ADDRESS = address(0xdeadbeef); | ||
|
||
function setUp() public override { | ||
super.setUp(); | ||
|
||
s_siloedLockReleaseTokenPool.setRebalancer(SILOED_CHAIN_SELECTOR, OWNER); | ||
} | ||
|
||
function test_withdrawLiquidity_Success() public { | ||
uint256 amount = 1e24; | ||
|
||
uint256 balanceBefore = s_token.balanceOf(OWNER); | ||
|
||
// Provide the Liquidity first | ||
s_siloedLockReleaseTokenPool.provideLiquidity(SILOED_CHAIN_SELECTOR, amount); | ||
|
||
vm.expectEmit(); | ||
emit SiloedLockReleaseTokenPool.LiquidityRemoved(SILOED_CHAIN_SELECTOR, OWNER, amount); | ||
|
||
// Remove the Liquidity | ||
s_siloedLockReleaseTokenPool.withdrawLiquidity(SILOED_CHAIN_SELECTOR, amount); | ||
|
||
assertEq(s_token.balanceOf(OWNER), balanceBefore); | ||
assertEq(s_token.balanceOf(address(s_siloedLockReleaseTokenPool)), 0); | ||
} | ||
|
||
// Reverts | ||
|
||
function test_withdrawLiquidity_RevertWhen_NotEnoughLiquidity() public { | ||
uint256 amount = 1e24; | ||
|
||
s_siloedLockReleaseTokenPool.provideLiquidity(SILOED_CHAIN_SELECTOR, amount); | ||
|
||
// Call should revert due to underflow error due to trying to burn more tokens than are locked via CCIP. | ||
vm.expectRevert(abi.encodeWithSignature("Panic(uint256)", 0x11)); | ||
|
||
s_siloedLockReleaseTokenPool.withdrawLiquidity(SILOED_CHAIN_SELECTOR, amount + 1); | ||
} | ||
} |
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