Skip to content

Commit

Permalink
Merge branch 'feat/CCIP-384-remove-signature' of github.com:smartcont…
Browse files Browse the repository at this point in the history
…ractkit/ccip into feat/CCIP-384-remove-signature
  • Loading branch information
agusaldasoro committed Jun 26, 2024
2 parents d38e495 + e6db30d commit 2eebd54
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 23 deletions.
42 changes: 22 additions & 20 deletions contracts/gas-snapshots/liquiditymanager.gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
LiquidityManager__report:test_EmptyReportReverts() (gas: 11159)
LiquidityManager__report:test_EmptyReportReverts() (gas: 11181)
LiquidityManager_addLiquidity:test_addLiquiditySuccess() (gas: 279154)
LiquidityManager_rebalanceLiquidity:test_InsufficientLiquidityReverts() (gas: 206745)
LiquidityManager_rebalanceLiquidity:test_InvalidRemoteChainReverts() (gas: 192319)
LiquidityManager_rebalanceLiquidity:test_rebalanceBetweenPoolsSuccess() (gas: 9052364)
LiquidityManager_rebalanceLiquidity:test_rebalanceBetweenPoolsSuccess_AlreadyFinalized() (gas: 8854958)
LiquidityManager_rebalanceLiquidity:test_rebalanceBetweenPools_MultiStageFinalization() (gas: 8850164)
LiquidityManager_rebalanceLiquidity:test_rebalanceBetweenPools_NativeRewrap() (gas: 8777971)
LiquidityManager_rebalanceLiquidity:test_rebalanceLiquiditySuccess() (gas: 382889)
LiquidityManager_rebalanceLiquidity:test_rebalanceBetweenPoolsSuccess() (gas: 9141768)
LiquidityManager_rebalanceLiquidity:test_rebalanceBetweenPoolsSuccess_AlreadyFinalized() (gas: 8899695)
LiquidityManager_rebalanceLiquidity:test_rebalanceBetweenPools_MultiStageFinalization() (gas: 8894901)
LiquidityManager_rebalanceLiquidity:test_rebalanceBetweenPools_NativeRewrap() (gas: 8822699)
LiquidityManager_rebalanceLiquidity:test_rebalanceLiquiditySuccess() (gas: 382897)
LiquidityManager_receive:test_receive_success() (gas: 21182)
LiquidityManager_removeLiquidity:test_InsufficientLiquidityReverts() (gas: 184852)
LiquidityManager_removeLiquidity:test_OnlyFinanceRoleReverts() (gas: 10850)
LiquidityManager_removeLiquidity:test_removeLiquiditySuccess() (gas: 236324)
LiquidityManager_setCrossChainRebalancer:test_OnlyOwnerReverts() (gas: 16983)
LiquidityManager_setCrossChainRebalancer:test_ZeroAddressReverts() (gas: 21630)
LiquidityManager_setCrossChainRebalancer:test_ZeroChainSelectorReverts() (gas: 13105)
LiquidityManager_setCrossChainRebalancer:test_setCrossChainRebalancerSuccess() (gas: 162164)
LiquidityManager_removeLiquidity:test_InsufficientLiquidityReverts() (gas: 184869)
LiquidityManager_removeLiquidity:test_OnlyFinanceRoleReverts() (gas: 10872)
LiquidityManager_removeLiquidity:test_removeLiquiditySuccess() (gas: 236342)
LiquidityManager_setCrossChainRebalancer:test_OnlyOwnerReverts() (gas: 17005)
LiquidityManager_setCrossChainRebalancer:test_ZeroAddressReverts() (gas: 21624)
LiquidityManager_setCrossChainRebalancer:test_ZeroChainSelectorReverts() (gas: 13099)
LiquidityManager_setCrossChainRebalancer:test_setCrossChainRebalancerSuccess() (gas: 162186)
LiquidityManager_setFinanceRole:test_OnlyOwnerReverts() (gas: 10987)
LiquidityManager_setFinanceRole:test_setFinanceRoleSuccess() (gas: 21792)
LiquidityManager_setLocalLiquidityContainer:test_OnlyOwnerReverts() (gas: 11030)
LiquidityManager_setLocalLiquidityContainer:test_ReverstWhen_CalledWithTheZeroAddress() (gas: 10621)
LiquidityManager_setLocalLiquidityContainer:test_setLocalLiquidityContainerSuccess() (gas: 3437694)
LiquidityManager_setFinanceRole:test_setFinanceRoleSuccess() (gas: 21836)
LiquidityManager_setLocalLiquidityContainer:test_OnlyOwnerReverts() (gas: 11052)
LiquidityManager_setLocalLiquidityContainer:test_ReverstWhen_CalledWithTheZeroAddress() (gas: 10643)
LiquidityManager_setLocalLiquidityContainer:test_setLocalLiquidityContainerSuccess() (gas: 3437651)
LiquidityManager_setMinimumLiquidity:test_OnlyOwnerReverts() (gas: 10925)
LiquidityManager_setMinimumLiquidity:test_setMinimumLiquiditySuccess() (gas: 36434)
LiquidityManager_withdrawNative:test_OnlyFinanceRoleReverts() (gas: 13024)
LiquidityManager_withdrawNative:test_withdrawNative_success() (gas: 51376)
LiquidityManager_setMinimumLiquidity:test_setMinimumLiquiditySuccess() (gas: 36389)
LiquidityManager_withdrawERC20:test_withdrawERC20Reverts() (gas: 180359)
LiquidityManager_withdrawERC20:test_withdrawERC20Success() (gas: 205858)
LiquidityManager_withdrawNative:test_OnlyFinanceRoleReverts() (gas: 13046)
LiquidityManager_withdrawNative:test_withdrawNative_success() (gas: 51398)
OCR3Base_setOCR3Config:testFMustBePositiveReverts() (gas: 12245)
OCR3Base_setOCR3Config:testFTooHighReverts() (gas: 12429)
OCR3Base_setOCR3Config:testOracleOutOfRegisterReverts() (gas: 14847)
Expand Down
8 changes: 8 additions & 0 deletions contracts/src/v0.8/liquiditymanager/LiquidityManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,14 @@ contract LiquidityManager is ILiquidityManager, OCR3Base {
emit LiquidityRemovedFromContainer(msg.sender, amount);
}

/// @notice escape hatch to manually withdraw any ERC20 token from the LM contract
/// @param token The address of the token to withdraw
/// @param amount The amount of tokens to withdraw
/// @param destination The address to send the tokens to
function withdrawERC20(address token, uint256 amount, address destination) external onlyFinance {
IERC20(token).safeTransfer(destination, amount);
}

/// @notice Transfers liquidity to another chain.
/// @dev This function is a public version of the internal _rebalanceLiquidity function.
/// to allow the owner to also initiate a rebalancing when needed.
Expand Down
21 changes: 21 additions & 0 deletions contracts/src/v0.8/liquiditymanager/test/LiquidityManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -922,3 +922,24 @@ contract LiquidityManager_receive is LiquidityManagerSetup {
assertEq(address(s_liquidityManager).balance, before + 100);
}
}

contract LiquidityManager_withdrawERC20 is LiquidityManagerSetup {
function test_withdrawERC20Success() external {
uint256 amount = 100;
deal(address(s_otherToken), address(s_liquidityManager), amount);
assertEq(s_otherToken.balanceOf(address(1)), 0);
assertEq(s_otherToken.balanceOf(address(s_liquidityManager)), amount);
vm.startPrank(FINANCE);
s_liquidityManager.withdrawERC20(address(s_otherToken), amount, address(1));
assertEq(s_otherToken.balanceOf(address(1)), amount);
assertEq(s_otherToken.balanceOf(address(s_liquidityManager)), 0);
}

function test_withdrawERC20Reverts() external {
uint256 amount = 100;
deal(address(s_otherToken), address(s_liquidityManager), amount);
vm.startPrank(STRANGER);
vm.expectRevert(LiquidityManager.OnlyFinanceRole.selector);
s_liquidityManager.withdrawERC20(address(s_otherToken), amount, address(1));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ contract LiquidityManagerBaseTest is Test {

IERC20 internal s_l1Token;
IERC20 internal s_l2Token;
IERC20 internal s_otherToken;
WETH9 internal s_l1Weth;
WETH9 internal s_l2Weth;

Expand All @@ -28,6 +29,7 @@ contract LiquidityManagerBaseTest is Test {
function setUp() public virtual {
s_l1Token = new ERC20("l1", "L1");
s_l2Token = new ERC20("l2", "L2");
s_otherToken = new ERC20("other", "OTHER");

s_l1Weth = new WETH9();
s_l2Weth = new WETH9();
Expand Down
Loading

0 comments on commit 2eebd54

Please sign in to comment.