Skip to content

Commit

Permalink
Update token pools
Browse files Browse the repository at this point in the history
  • Loading branch information
RensR committed Nov 28, 2024
1 parent 26f0275 commit 4b4cfaf
Show file tree
Hide file tree
Showing 38 changed files with 510 additions and 4,640 deletions.
5 changes: 3 additions & 2 deletions contracts/src/v0.8/ccip/pools/BurnFromMintTokenPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ import {SafeERC20} from "../../vendor/openzeppelin-solidity/v4.8.3/contracts/tok
contract BurnFromMintTokenPool is BurnMintTokenPoolAbstract, ITypeAndVersion {
using SafeERC20 for IBurnMintERC20;

string public constant override typeAndVersion = "BurnFromMintTokenPool 1.5.0";
string public constant override typeAndVersion = "BurnFromMintTokenPool 1.5.1";

constructor(
IBurnMintERC20 token,
uint8 localTokenDecimals,
address[] memory allowlist,
address rmnProxy,
address router
) TokenPool(token, allowlist, rmnProxy, router) {
) TokenPool(token, localTokenDecimals, allowlist, rmnProxy, router) {
// Some tokens allow burning from the sender without approval, but not all do.
// To be safe, we approve the pool to burn from the pool.
token.safeIncreaseAllowance(address(this), type(uint256).max);
Expand Down
5 changes: 3 additions & 2 deletions contracts/src/v0.8/ccip/pools/BurnMintTokenPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ import {TokenPool} from "./TokenPool.sol";
/// If that is expected, please make sure the token's burner/minter roles are adjustable.
/// @dev This contract is a variant of BurnMintTokenPool that uses `burn(amount)`.
contract BurnMintTokenPool is BurnMintTokenPoolAbstract, ITypeAndVersion {
string public constant override typeAndVersion = "BurnMintTokenPool 1.5.0";
string public constant override typeAndVersion = "BurnMintTokenPool 1.5.1";

constructor(
IBurnMintERC20 token,
uint8 localTokenDecimals,
address[] memory allowlist,
address rmnProxy,
address router
) TokenPool(token, allowlist, rmnProxy, router) {}
) TokenPool(token, localTokenDecimals, allowlist, rmnProxy, router) {}

/// @inheritdoc BurnMintTokenPoolAbstract
function _burn(
Expand Down
15 changes: 11 additions & 4 deletions contracts/src/v0.8/ccip/pools/BurnMintTokenPoolAbstract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ abstract contract BurnMintTokenPoolAbstract is TokenPool {

emit Burned(msg.sender, lockOrBurnIn.amount);

return Pool.LockOrBurnOutV1({destTokenAddress: getRemoteToken(lockOrBurnIn.remoteChainSelector), destPoolData: ""});
return Pool.LockOrBurnOutV1({
destTokenAddress: getRemoteToken(lockOrBurnIn.remoteChainSelector),
destPoolData: _encodeLocalDecimals()
});
}

/// @notice Mint tokens from the pool to the recipient
Expand All @@ -35,11 +38,15 @@ abstract contract BurnMintTokenPoolAbstract is TokenPool {
) external virtual override returns (Pool.ReleaseOrMintOutV1 memory) {
_validateReleaseOrMint(releaseOrMintIn);

// Calculate the local amount
uint256 localAmount =
_calculateLocalAmount(releaseOrMintIn.amount, _parseRemoteDecimals(releaseOrMintIn.sourcePoolData));

// Mint to the receiver
IBurnMintERC20(address(i_token)).mint(releaseOrMintIn.receiver, releaseOrMintIn.amount);
IBurnMintERC20(address(i_token)).mint(releaseOrMintIn.receiver, localAmount);

emit Minted(msg.sender, releaseOrMintIn.receiver, releaseOrMintIn.amount);
emit Minted(msg.sender, releaseOrMintIn.receiver, localAmount);

return Pool.ReleaseOrMintOutV1({destinationAmount: releaseOrMintIn.amount});
return Pool.ReleaseOrMintOutV1({destinationAmount: localAmount});
}
}
55 changes: 0 additions & 55 deletions contracts/src/v0.8/ccip/pools/BurnMintTokenPoolAndProxy.sol

This file was deleted.

This file was deleted.

5 changes: 3 additions & 2 deletions contracts/src/v0.8/ccip/pools/BurnWithFromMintTokenPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ contract BurnWithFromMintTokenPool is BurnMintTokenPoolAbstract, ITypeAndVersion

constructor(
IBurnMintERC20 token,
uint8 localTokenDecimals,
address[] memory allowlist,
address rmnProxy,
address router
) TokenPool(token, allowlist, rmnProxy, router) {
) TokenPool(token, localTokenDecimals, allowlist, rmnProxy, router) {
// Some tokens allow burning from the sender without approval, but not all do.
// To be safe, we approve the pool to burn from the pool.
token.safeIncreaseAllowance(address(this), type(uint256).max);
Expand All @@ -37,6 +38,6 @@ contract BurnWithFromMintTokenPool is BurnMintTokenPoolAbstract, ITypeAndVersion
}

function typeAndVersion() external pure virtual override returns (string memory) {
return "BurnWithFromMintTokenPool 1.5.0";
return "BurnWithFromMintTokenPool 1.5.1";
}
}

This file was deleted.

98 changes: 0 additions & 98 deletions contracts/src/v0.8/ccip/pools/LegacyPoolWrapper.sol

This file was deleted.

Loading

0 comments on commit 4b4cfaf

Please sign in to comment.