Skip to content

Commit c66ad1e

Browse files
feat: Add DirectBurn function on RemotePool (#21)
* feat: withdraw liquidity on burnMint * test: more verbose * doc: expand and fix typo * chore: mv withdrawLiquidity burnLiquidity * chore: mv burnLiquidity directBurn * doc: upd for `directBurn` * Update contracts/src/v0.8/ccip/pools/GHO/UpgradeableBurnMintTokenPool.sol Co-authored-by: miguelmtz <[email protected]> * Update contracts/src/v0.8/ccip/pools/GHO/UpgradeableBurnMintTokenPool.sol Co-authored-by: miguelmtz <[email protected]> * chore: doc on burnMint * doc: update `directBurn` doc --------- Co-authored-by: miguelmtz <[email protected]>
1 parent 46a4bdc commit c66ad1e

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed

contracts/src/v0.8/ccip/pools/GHO/UpgradeableBurnMintTokenPool.sol

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {IRouter} from "../../interfaces/IRouter.sol";
1717
/// - Implementation of Initializable to allow upgrades
1818
/// - Move of allowlist and router definition to initialization stage
1919
/// - Inclusion of rate limit admin who may configure rate limits in addition to owner
20+
/// - Addition of authorized function to to directly burn liquidity, thereby reducing the facilitator's bucket level.
2021
/// - Modifications from inherited contract (see contract for more details):
2122
/// - UpgradeableTokenPool: Modify `onlyOnRamp` & `onlyOffRamp` modifier to accept transactions from ProxyPool
2223
contract UpgradeableBurnMintTokenPool is Initializable, UpgradeableBurnMintTokenPoolAbstract, ITypeAndVersion {
@@ -84,6 +85,16 @@ contract UpgradeableBurnMintTokenPool is Initializable, UpgradeableBurnMintToken
8485
_setRateLimitConfig(remoteChainSelector, outboundConfig, inboundConfig);
8586
}
8687

88+
/// @notice Burn an amount of tokens with no additional logic.
89+
/// @dev This GHO-specific functionality is designed for migrating bucket levels between
90+
/// facilitators. The new pool is expected to mint amount of tokens, while the old pool
91+
/// burns an equivalent amount. This ensures the facilitator can be offboarded, as all
92+
/// liquidity minted by it must be fully burned
93+
/// @param amount The amount of tokens to burn.
94+
function directBurn(uint256 amount) external onlyOwner {
95+
_burn(amount);
96+
}
97+
8798
/// @inheritdoc UpgradeableBurnMintTokenPoolAbstract
8899
function _burn(uint256 amount) internal virtual override {
89100
IBurnMintERC20(address(i_token)).burn(amount);

contracts/src/v0.8/ccip/pools/GHO/diffs/UpgradeableBurnMintTokenPool_diff.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
```diff
22
diff --git a/src/v0.8/ccip/pools/BurnMintTokenPool.sol b/src/v0.8/ccip/pools/GHO/UpgradeableBurnMintTokenPool.sol
3-
index 9af0f22f4c..a5cecc0430 100644
3+
index 9af0f22f4c..f19106fd4d 100644
44
--- a/src/v0.8/ccip/pools/BurnMintTokenPool.sol
55
+++ b/src/v0.8/ccip/pools/GHO/UpgradeableBurnMintTokenPool.sol
6-
@@ -1,28 +1,90 @@
6+
@@ -1,28 +1,101 @@
77
// SPDX-License-Identifier: BUSL-1.1
88
-pragma solidity 0.8.19;
99
+pragma solidity ^0.8.0;
@@ -28,6 +28,7 @@ index 9af0f22f4c..a5cecc0430 100644
2828
+/// - Implementation of Initializable to allow upgrades
2929
+/// - Move of allowlist and router definition to initialization stage
3030
+/// - Inclusion of rate limit admin who may configure rate limits in addition to owner
31+
+/// - Addition of authorized function to to directly burn liquidity, thereby reducing the facilitator's bucket level.
3132
+/// - Modifications from inherited contract (see contract for more details):
3233
+/// - UpgradeableTokenPool: Modify `onlyOnRamp` & `onlyOffRamp` modifier to accept transactions from ProxyPool
3334
+contract UpgradeableBurnMintTokenPool is Initializable, UpgradeableBurnMintTokenPoolAbstract, ITypeAndVersion {
@@ -106,6 +107,16 @@ index 9af0f22f4c..a5cecc0430 100644
106107
+ _setRateLimitConfig(remoteChainSelector, outboundConfig, inboundConfig);
107108
+ }
108109
+
110+
+ /// @notice Burn an amount of tokens with no additional logic.
111+
+ /// @dev This GHO-specific functionality is designed for migrating bucket levels between
112+
+ /// facilitators. The new pool is expected to mint amount of tokens, while the old pool
113+
+ /// burns an equivalent amount. This ensures the facilitator can be offboarded, as all
114+
+ /// liquidity minted by it must be fully burned
115+
+ /// @param amount The amount of tokens to burn.
116+
+ function directBurn(uint256 amount) external onlyOwner {
117+
+ _burn(amount);
118+
+ }
119+
+
109120
+ /// @inheritdoc UpgradeableBurnMintTokenPoolAbstract
110121
function _burn(uint256 amount) internal virtual override {
111122
IBurnMintERC20(address(i_token)).burn(amount);

contracts/src/v0.8/ccip/test/pools/GHO/GhoTokenPoolRemote.t.sol

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,3 +398,24 @@ contract GhoTokenPoolRemote_proxyPool is GhoTokenPoolRemoteSetup {
398398
assertEq(s_pool.getProxyPool(), proxyPool);
399399
}
400400
}
401+
402+
contract GhoTokenPoolRemote_directBurn is GhoTokenPoolRemoteSetup {
403+
function testDirectBurnOnlyOwner() public {
404+
vm.startPrank(STRANGER);
405+
vm.expectRevert("Only callable by owner");
406+
s_pool.directBurn(13e7);
407+
}
408+
409+
function testFuzzDirectBurnSuccess(uint256 amount) public {
410+
amount = bound(amount, 1, type(uint128).max); // bound to bucket capacity
411+
// prank previously bridged supply
412+
vm.startPrank(address(s_pool));
413+
s_burnMintERC677.mint(address(s_pool), amount);
414+
415+
vm.startPrank(AAVE_DAO);
416+
s_pool.directBurn(amount);
417+
418+
assertEq(s_burnMintERC677.balanceOf(address(s_pool)), 0);
419+
assertEq(GhoToken(address(s_burnMintERC677)).getFacilitator(address(s_pool)).bucketLevel, 0);
420+
}
421+
}

0 commit comments

Comments
 (0)