Skip to content

Commit

Permalink
feat: withdraw liquidity on burnMint
Browse files Browse the repository at this point in the history
  • Loading branch information
DhairyaSethi committed Dec 11, 2024
1 parent 46a4bdc commit 38d2861
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
12 changes: 12 additions & 0 deletions contracts/src/v0.8/ccip/pools/GHO/UpgradeableBurnMintTokenPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ contract UpgradeableBurnMintTokenPool is Initializable, UpgradeableBurnMintToken
_setRateLimitConfig(remoteChainSelector, outboundConfig, inboundConfig);
}

/// @notice This function allows the owner to burn `amount` of the pool's token. This is
/// expected to be called while migrating liquidity to another pool and offboarding this
/// facilitator.
/// @dev New token pool should mint and transfer liquidity to this pool (since it does not
/// hold tokens any point in point, only mints/burns) which can be burnt and hence will reset
/// the facilitator bucket level GHO. This is needed to migrate facilitators, by offboarding
/// this token pool subsequently.
/// @param amount The amount of tokens to burn.
function withdrawLiquidity(uint256 amount) external onlyOwner {
IBurnMintERC20(address(i_token)).burn(amount);
}

/// @inheritdoc UpgradeableBurnMintTokenPoolAbstract
function _burn(uint256 amount) internal virtual override {
IBurnMintERC20(address(i_token)).burn(amount);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
```diff
diff --git a/src/v0.8/ccip/pools/BurnMintTokenPool.sol b/src/v0.8/ccip/pools/GHO/UpgradeableBurnMintTokenPool.sol
index 9af0f22f4c..a5cecc0430 100644
index 9af0f22f4c..bbd4d018a5 100644
--- a/src/v0.8/ccip/pools/BurnMintTokenPool.sol
+++ b/src/v0.8/ccip/pools/GHO/UpgradeableBurnMintTokenPool.sol
@@ -1,28 +1,90 @@
@@ -1,28 +1,102 @@
// SPDX-License-Identifier: BUSL-1.1
-pragma solidity 0.8.19;
+pragma solidity ^0.8.0;
Expand Down Expand Up @@ -106,6 +106,18 @@ index 9af0f22f4c..a5cecc0430 100644
+ _setRateLimitConfig(remoteChainSelector, outboundConfig, inboundConfig);
+ }
+
+ /// @notice This function allows the owner to burn `amount` of the pool's token. This is
+ /// expected to be called while migrating liquidity to another pool and offboarding this
+ /// facilitator.
+ /// @dev New token pool should mint and transfer liquidity to this pool (since it does not
+ /// hold tokens any point in point, only mints/burns) which can be burnt and hence will reset
+ /// the facilitator bucket level GHO. This is needed to migrate facilitators, by offboarding
+ /// this token pool subsequently.
+ /// @param amount The amount of tokens to burn.
+ function withdrawLiquidity(uint256 amount) external onlyOwner {
+ IBurnMintERC20(address(i_token)).burn(amount);
+ }
+
+ /// @inheritdoc UpgradeableBurnMintTokenPoolAbstract
function _burn(uint256 amount) internal virtual override {
IBurnMintERC20(address(i_token)).burn(amount);
Expand Down
20 changes: 20 additions & 0 deletions contracts/src/v0.8/ccip/test/pools/GHO/GhoTokenPoolRemote.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -398,3 +398,23 @@ contract GhoTokenPoolRemote_proxyPool is GhoTokenPoolRemoteSetup {
assertEq(s_pool.getProxyPool(), proxyPool);
}
}

contract GhoTokenPoolRemote_withdrawLiquidity is GhoTokenPoolRemoteSetup {
function testWithdrawLiquidityOnlyOwner() public {
vm.startPrank(STRANGER);
vm.expectRevert("Only callable by owner");
s_pool.withdrawLiquidity(13e7);
}

function testFuzzWithdrawLiquiditySuccess(uint256 amount) public {
amount = bound(amount, 1, type(uint128).max); // bound to bucket capacity
// prank newTokenPool.transferLiquidity
vm.startPrank(address(s_pool));
s_burnMintERC677.mint(address(s_pool), amount);

vm.startPrank(AAVE_DAO);
s_pool.withdrawLiquidity(amount);

assertEq(s_burnMintERC677.balanceOf(address(s_pool)), 0);
}
}

0 comments on commit 38d2861

Please sign in to comment.