Skip to content

Commit

Permalink
feat: Add DirectBurn function on RemotePool (#21)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
DhairyaSethi and miguelmtzinf authored Jan 2, 2025
1 parent 46a4bdc commit c66ad1e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
11 changes: 11 additions & 0 deletions contracts/src/v0.8/ccip/pools/GHO/UpgradeableBurnMintTokenPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {IRouter} from "../../interfaces/IRouter.sol";
/// - Implementation of Initializable to allow upgrades
/// - Move of allowlist and router definition to initialization stage
/// - Inclusion of rate limit admin who may configure rate limits in addition to owner
/// - Addition of authorized function to to directly burn liquidity, thereby reducing the facilitator's bucket level.
/// - Modifications from inherited contract (see contract for more details):
/// - UpgradeableTokenPool: Modify `onlyOnRamp` & `onlyOffRamp` modifier to accept transactions from ProxyPool
contract UpgradeableBurnMintTokenPool is Initializable, UpgradeableBurnMintTokenPoolAbstract, ITypeAndVersion {
Expand Down Expand Up @@ -84,6 +85,16 @@ contract UpgradeableBurnMintTokenPool is Initializable, UpgradeableBurnMintToken
_setRateLimitConfig(remoteChainSelector, outboundConfig, inboundConfig);
}

/// @notice Burn an amount of tokens with no additional logic.
/// @dev This GHO-specific functionality is designed for migrating bucket levels between
/// facilitators. The new pool is expected to mint amount of tokens, while the old pool
/// burns an equivalent amount. This ensures the facilitator can be offboarded, as all
/// liquidity minted by it must be fully burned
/// @param amount The amount of tokens to burn.
function directBurn(uint256 amount) external onlyOwner {
_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..f19106fd4d 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,101 @@
// SPDX-License-Identifier: BUSL-1.1
-pragma solidity 0.8.19;
+pragma solidity ^0.8.0;
Expand All @@ -28,6 +28,7 @@ index 9af0f22f4c..a5cecc0430 100644
+/// - Implementation of Initializable to allow upgrades
+/// - Move of allowlist and router definition to initialization stage
+/// - Inclusion of rate limit admin who may configure rate limits in addition to owner
+/// - Addition of authorized function to to directly burn liquidity, thereby reducing the facilitator's bucket level.
+/// - Modifications from inherited contract (see contract for more details):
+/// - UpgradeableTokenPool: Modify `onlyOnRamp` & `onlyOffRamp` modifier to accept transactions from ProxyPool
+contract UpgradeableBurnMintTokenPool is Initializable, UpgradeableBurnMintTokenPoolAbstract, ITypeAndVersion {
Expand Down Expand Up @@ -106,6 +107,16 @@ index 9af0f22f4c..a5cecc0430 100644
+ _setRateLimitConfig(remoteChainSelector, outboundConfig, inboundConfig);
+ }
+
+ /// @notice Burn an amount of tokens with no additional logic.
+ /// @dev This GHO-specific functionality is designed for migrating bucket levels between
+ /// facilitators. The new pool is expected to mint amount of tokens, while the old pool
+ /// burns an equivalent amount. This ensures the facilitator can be offboarded, as all
+ /// liquidity minted by it must be fully burned
+ /// @param amount The amount of tokens to burn.
+ function directBurn(uint256 amount) external onlyOwner {
+ _burn(amount);
+ }
+
+ /// @inheritdoc UpgradeableBurnMintTokenPoolAbstract
function _burn(uint256 amount) internal virtual override {
IBurnMintERC20(address(i_token)).burn(amount);
Expand Down
21 changes: 21 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,24 @@ contract GhoTokenPoolRemote_proxyPool is GhoTokenPoolRemoteSetup {
assertEq(s_pool.getProxyPool(), proxyPool);
}
}

contract GhoTokenPoolRemote_directBurn is GhoTokenPoolRemoteSetup {
function testDirectBurnOnlyOwner() public {
vm.startPrank(STRANGER);
vm.expectRevert("Only callable by owner");
s_pool.directBurn(13e7);
}

function testFuzzDirectBurnSuccess(uint256 amount) public {
amount = bound(amount, 1, type(uint128).max); // bound to bucket capacity
// prank previously bridged supply
vm.startPrank(address(s_pool));
s_burnMintERC677.mint(address(s_pool), amount);

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

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

0 comments on commit c66ad1e

Please sign in to comment.