Skip to content

Commit

Permalink
doc: update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
DhairyaSethi committed Dec 23, 2024
1 parent 4fb7885 commit 4e0e90f
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 60 deletions.
35 changes: 15 additions & 20 deletions contracts/src/v0.8/ccip/pools/GHO/UpgradeableBurnMintTokenPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ import {IRouter} from "../../interfaces/IRouter.sol";
/// @dev Contract adaptations:
/// - Implementation of Initializable to allow upgrades
/// - Move of allowlist and router definition to initialization stage
/// - Add GHO-Specific onlyOwner `directMint` which mints liquidity to the old pool &
/// increases facilitator level.
/// - Add GHO-Specific onlyOwner `directBurn` which burns liquidity & reduces facilitator level.
/// - Remove i_token decimal check in UpgradeableTokenPool constructor
/// - Addition of authorized functions to to directly mint/burn liquidity, thereby increasing/reducing the facilitator's bucket level.
/// - Modifications from inherited contract (see contract for more details):
/// - UpgradeableTokenPool: Remove i_token decimal check in constructor

/// @dev Pool whitelisting mode is set in the constructor and cannot be modified later.
/// It either accepts any address as originalSender, or only accepts whitelisted originalSender.
Expand All @@ -44,28 +43,24 @@ contract UpgradeableBurnMintTokenPool is Initializable, UpgradeableBurnMintToken
if (i_allowlistEnabled) _applyAllowListUpdates(new address[](0), allowlist);
}

/// @notice This function allows the owner to mint `amount` tokens on behalf of the pool
/// and transfer them to `to`. This is GHO-Specific and is called to match the facilitator
/// level of the new pool with the old pool such that it can burn the bridged supply once
/// the old pool is deprecated. The old pool is then expected to burn `amount` of tokens
/// so that it can be removed as a facilitator on GHO (ideally using `directBurn`).
/// @dev This is only called while offboarding an old token pool (or facilitator) in favor
/// of this pool.
/// @notice Mint 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 to The address to which the minted tokens will be transferred.
/// @param to The address to which the minted tokens will be transferred. This needs to
/// be the old token pool,
/// or the facilitator being offboarded.
/// be the old token pool, or the facilitator being offboarded.
/// @param amount The amount of tokens to mint and transfer to old pool.
function directMint(address to, uint256 amount) external onlyOwner {
IBurnMintERC20(address(i_token)).mint(to, amount);
}

/// @notice This function allows the owner to burn `amount` of the pool's token. This is
/// expected to be called while migrating facilitators by offboarding this facilitator in
/// favor of a new token pool.
/// @dev New token pool should mint and transfer liquidity to this pool (since this pool
/// does not hold tokens at any point in time) which can be burnt and hence will reduce
/// the facilitator bucket level on GHO. The naming convention is inspired from that in
/// LockRelease type token pools for the sake of consistency.
/// @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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ import {UpgradeableTokenPool} from "./UpgradeableTokenPool.sol";
/// - Implementation of Initializable to allow upgrades
/// - Move of allowlist and router definition to initialization stage
/// - Addition of a bridge limit to regulate the maximum amount of tokens that can be transferred out (burned/locked)
/// - Permissioned bridgedAmount setter to facilitate liquidity migration
/// - Remove i_token decimal check in UpgradeableTokenPool constructor
/// - Addition of authorized function to update amount of tokens that are currently bridged
/// - Modifications from inherited contract (see contract for more details):
/// - UpgradeableTokenPool: Remove i_token decimal check in constructor

/// @dev Token pool used for tokens on their native chain. This uses a lock and release mechanism.
/// Because of lock/unlock requiring liquidity, this pool contract also has function to add and remove
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 30203a4ced..1571d9c7f3 100644
index 30203a4ced..8a41f89709 100644
--- a/src/v0.8/ccip/pools/BurnMintTokenPool.sol
+++ b/src/v0.8/ccip/pools/GHO/UpgradeableBurnMintTokenPool.sol
@@ -1,33 +1,78 @@
@@ -1,33 +1,73 @@
// SPDX-License-Identifier: BUSL-1.1
-pragma solidity 0.8.24;
+pragma solidity ^0.8.0;
Expand All @@ -27,10 +27,9 @@ index 30203a4ced..1571d9c7f3 100644
+/// @dev Contract adaptations:
+/// - Implementation of Initializable to allow upgrades
+/// - Move of allowlist and router definition to initialization stage
+/// - Add GHO-Specific onlyOwner `directMint` which mints liquidity to the old pool &
+/// increases facilitator level.
+/// - Add GHO-Specific onlyOwner `directBurn` which burns liquidity & reduces facilitator level.
+/// - Remove i_token decimal check in UpgradeableTokenPool constructor
+/// - Addition of authorized functions to to directly mint/burn liquidity, thereby increasing/reducing the facilitator's bucket level.
+/// - Modifications from inherited contract (see contract for more details):
+/// - UpgradeableTokenPool: Remove i_token decimal check in constructor

-/// @notice This pool mints and burns a 3rd-party token.
/// @dev Pool whitelisting mode is set in the constructor and cannot be modified later.
Expand Down Expand Up @@ -65,28 +64,24 @@ index 30203a4ced..1571d9c7f3 100644
+ if (i_allowlistEnabled) _applyAllowListUpdates(new address[](0), allowlist);
+ }
+
+ /// @notice This function allows the owner to mint `amount` tokens on behalf of the pool
+ /// and transfer them to `to`. This is GHO-Specific and is called to match the facilitator
+ /// level of the new pool with the old pool such that it can burn the bridged supply once
+ /// the old pool is deprecated. The old pool is then expected to burn `amount` of tokens
+ /// so that it can be removed as a facilitator on GHO (ideally using `directBurn`).
+ /// @dev This is only called while offboarding an old token pool (or facilitator) in favor
+ /// of this pool.
+ /// @notice Mint 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 to The address to which the minted tokens will be transferred.
+ /// @param to The address to which the minted tokens will be transferred. This needs to
+ /// be the old token pool,
+ /// or the facilitator being offboarded.
+ /// be the old token pool, or the facilitator being offboarded.
+ /// @param amount The amount of tokens to mint and transfer to old pool.
+ function directMint(address to, uint256 amount) external onlyOwner {
+ IBurnMintERC20(address(i_token)).mint(to, amount);
+ }
+
+ /// @notice This function allows the owner to burn `amount` of the pool's token. This is
+ /// expected to be called while migrating facilitators by offboarding this facilitator in
+ /// favor of a new token pool.
+ /// @dev New token pool should mint and transfer liquidity to this pool (since this pool
+ /// does not hold tokens at any point in time) which can be burnt and hence will reduce
+ /// the facilitator bucket level on GHO. The naming convention is inspired from that in
+ /// LockRelease type token pools for the sake of consistency.
+ /// @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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
```diff
diff --git a/src/v0.8/ccip/pools/LockReleaseTokenPool.sol b/src/v0.8/ccip/pools/GHO/UpgradeableLockReleaseTokenPool.sol
index ecc28a14dd..21bd2df50d 100644
index ecc28a14dd..68655c345e 100644
--- a/src/v0.8/ccip/pools/LockReleaseTokenPool.sol
+++ b/src/v0.8/ccip/pools/GHO/UpgradeableLockReleaseTokenPool.sol
@@ -1,25 +1,44 @@
// SPDX-License-Identifier: BUSL-1.1
diff --git a/src/v0.8/ccip/pools/LockReleaseTokenPool.sol b/src/v0.8/ccip/pools/GHO/UpgradeableLockReleaseTokenPool.sol
index ecc28a14dd..16e1103542 100644
--- a/src/v0.8/ccip/pools/LockReleaseTokenPool.sol
+++ b/src/v0.8/ccip/pools/GHO/UpgradeableLockReleaseTokenPool.sol
@@ -1,25 +1,43 @@
// SPDX-License-Identifier: BUSL-1.1
-pragma solidity 0.8.24;
+pragma solidity ^0.8.0;

Expand Down Expand Up @@ -42,8 +36,9 @@ index ecc28a14dd..16e1103542 100644
+/// - Implementation of Initializable to allow upgrades
+/// - Move of allowlist and router definition to initialization stage
+/// - Addition of a bridge limit to regulate the maximum amount of tokens that can be transferred out (burned/locked)
+/// - Permissioned bridgedAmount setter to facilitate liquidity migration
+/// - Remove i_token decimal check in UpgradeableTokenPool constructor
+/// - Addition of authorized function to update amount of tokens that are currently bridged
+/// - Modifications from inherited contract (see contract for more details):
+/// - UpgradeableTokenPool: Remove i_token decimal check in constructor
+
+/// @dev Token pool used for tokens on their native chain. This uses a lock and release mechanism.
/// Because of lock/unlock requiring liquidity, this pool contract also has function to add and remove
Expand All @@ -63,7 +58,7 @@ index ecc28a14dd..16e1103542 100644

event LiquidityTransferred(address indexed from, uint256 amount);

@@ -33,30 +51,69 @@ contract LockReleaseTokenPool is TokenPool, ILiquidityContainer, ITypeAndVersion
@@ -33,30 +52,69 @@ contract LockReleaseTokenPool is TokenPool, ILiquidityContainer, ITypeAndVersion
/// @notice The address of the rebalancer.
address internal s_rebalancer;

Expand Down Expand Up @@ -142,7 +137,7 @@ index ecc28a14dd..16e1103542 100644
}

/// @notice Release tokens from the pool to the recipient
@@ -64,11 +121,18 @@ contract LockReleaseTokenPool is TokenPool, ILiquidityContainer, ITypeAndVersion
@@ -64,11 +122,18 @@ contract LockReleaseTokenPool is TokenPool, ILiquidityContainer, ITypeAndVersion
function releaseOrMint(
Pool.ReleaseOrMintInV1 calldata releaseOrMintIn
) external virtual override returns (Pool.ReleaseOrMintOutV1 memory) {
Expand All @@ -163,7 +158,7 @@ index ecc28a14dd..16e1103542 100644

// Release to the recipient
getToken().safeTransfer(releaseOrMintIn.receiver, localAmount);
@@ -79,9 +143,7 @@ contract LockReleaseTokenPool is TokenPool, ILiquidityContainer, ITypeAndVersion
@@ -79,9 +144,7 @@ contract LockReleaseTokenPool is TokenPool, ILiquidityContainer, ITypeAndVersion
}

/// @inheritdoc IERC165
Expand All @@ -174,7 +169,7 @@ index ecc28a14dd..16e1103542 100644
return interfaceId == type(ILiquidityContainer).interfaceId || super.supportsInterface(interfaceId);
}

@@ -93,12 +155,55 @@ contract LockReleaseTokenPool is TokenPool, ILiquidityContainer, ITypeAndVersion
@@ -93,12 +156,55 @@ contract LockReleaseTokenPool is TokenPool, ILiquidityContainer, ITypeAndVersion

/// @notice Sets the LiquidityManager address.
/// @dev Only callable by the owner.
Expand Down Expand Up @@ -233,7 +228,7 @@ index ecc28a14dd..16e1103542 100644
/// @notice Checks if the pool can accept liquidity.
/// @return true if the pool can accept liquidity, false otherwise.
function canAcceptLiquidity() external view returns (bool) {
@@ -107,9 +212,7 @@ contract LockReleaseTokenPool is TokenPool, ILiquidityContainer, ITypeAndVersion
@@ -107,9 +213,7 @@ contract LockReleaseTokenPool is TokenPool, ILiquidityContainer, ITypeAndVersion

/// @notice Adds liquidity to the pool. The tokens should be approved first.
/// @param amount The amount of liquidity to provide.
Expand All @@ -244,7 +239,7 @@ index ecc28a14dd..16e1103542 100644
if (!i_acceptLiquidity) revert LiquidityNotAccepted();
if (s_rebalancer != msg.sender) revert Unauthorized(msg.sender);

@@ -119,9 +222,7 @@ contract LockReleaseTokenPool is TokenPool, ILiquidityContainer, ITypeAndVersion
@@ -119,9 +223,7 @@ contract LockReleaseTokenPool is TokenPool, ILiquidityContainer, ITypeAndVersion

/// @notice Removed liquidity to the pool. The tokens will be sent to msg.sender.
/// @param amount The amount of liquidity to remove.
Expand All @@ -255,7 +250,7 @@ index ecc28a14dd..16e1103542 100644
if (s_rebalancer != msg.sender) revert Unauthorized(msg.sender);

if (i_token.balanceOf(address(this)) < amount) revert InsufficientLiquidity();
@@ -141,7 +242,7 @@ contract LockReleaseTokenPool is TokenPool, ILiquidityContainer, ITypeAndVersion
@@ -141,7 +243,7 @@ contract LockReleaseTokenPool is TokenPool, ILiquidityContainer, ITypeAndVersion
/// @param from The address of the old pool.
/// @param amount The amount of liquidity to transfer.
function transferLiquidity(address from, uint256 amount) external onlyOwner {
Expand Down

0 comments on commit 4e0e90f

Please sign in to comment.