-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
5,469 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
"prepublishOnly": "pnpm compile && ./scripts/prepublish_generate_abi_folder", | ||
"publish-beta": "pnpm publish --tag beta", | ||
"publish-prod": "npm dist-tag add @chainlink/[email protected] latest", | ||
"lint:ccip": "solhint --config ./src/v0.8/ccip/.solhint.json --ignore-path .ccip-solhint-ignore --max-warnings 0 \"./src/v0.8/ccip/**/*.sol\"" | ||
"solhint": "solhint --config ./src/v0.8/ccip/.solhint.json --ignore-path .ccip-solhint-ignore --max-warnings 0 \"./src/v0.8/ccip/**/*.sol\"" | ||
}, | ||
"files": [ | ||
"src/v0.8/ccip/**/*.sol", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity 0.8.19; | ||
|
||
import {ITypeAndVersion} from "../../shared/interfaces/ITypeAndVersion.sol"; | ||
import {IBurnMintERC20} from "../../shared/token/ERC20/IBurnMintERC20.sol"; | ||
|
||
import {TokenPool} from "./TokenPool.sol"; | ||
import {BurnMintTokenPoolAbstract} from "./BurnMintTokenPoolAbstract.sol"; | ||
|
||
/// @notice This pool mints and burns a 3rd-party token. | ||
/// @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. | ||
/// The only way to change whitelisting mode is to deploy a new pool. | ||
/// If that is expected, please make sure the token's burner/minter roles are adjustable. | ||
contract BurnFromMintTokenPool is BurnMintTokenPoolAbstract, ITypeAndVersion { | ||
// solhint-disable-next-line chainlink-solidity/all-caps-constant-storage-variables | ||
string public constant override typeAndVersion = "BurnFromMintTokenPool 1.2.0"; | ||
|
||
constructor( | ||
IBurnMintERC20 token, | ||
address[] memory allowlist, | ||
address armProxy | ||
) TokenPool(token, allowlist, armProxy) { | ||
// 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.approve(address(this), type(uint256).max); | ||
} | ||
|
||
/// @inheritdoc BurnMintTokenPoolAbstract | ||
function _burn(uint256 amount) internal virtual override { | ||
IBurnMintERC20(address(i_token)).burnFrom(address(this), amount); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
contracts/src/v0.8/ccip/pools/BurnMintTokenPoolAbstract.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity 0.8.19; | ||
|
||
import {IBurnMintERC20} from "../../shared/token/ERC20/IBurnMintERC20.sol"; | ||
|
||
import {TokenPool} from "./TokenPool.sol"; | ||
|
||
abstract contract BurnMintTokenPoolAbstract is TokenPool { | ||
/// @notice Contains the specific burn call for a pool. | ||
/// @dev overriding this method allows us to create pools with different burn signatures | ||
/// without duplicating the underlying logic. | ||
function _burn(uint256 amount) internal virtual; | ||
|
||
/// @notice Burn the token in the pool | ||
/// @param amount Amount to burn | ||
/// @dev The whenHealthy check is important to ensure that even if a ramp is compromised | ||
/// we're able to stop token movement via ARM. | ||
function lockOrBurn( | ||
address originalSender, | ||
bytes calldata, | ||
uint256 amount, | ||
uint64, | ||
bytes calldata | ||
) external virtual override onlyOnRamp checkAllowList(originalSender) whenHealthy returns (bytes memory) { | ||
_consumeOnRampRateLimit(amount); | ||
_burn(amount); | ||
emit Burned(msg.sender, amount); | ||
return ""; | ||
} | ||
|
||
/// @notice Mint tokens from the pool to the recipient | ||
/// @param receiver Recipient address | ||
/// @param amount Amount to mint | ||
/// @dev The whenHealthy check is important to ensure that even if a ramp is compromised | ||
/// we're able to stop token movement via ARM. | ||
function releaseOrMint( | ||
bytes memory, | ||
address receiver, | ||
uint256 amount, | ||
uint64, | ||
bytes memory | ||
) external virtual override whenHealthy onlyOffRamp { | ||
_consumeOffRampRateLimit(amount); | ||
IBurnMintERC20(address(i_token)).mint(receiver, amount); | ||
emit Minted(msg.sender, receiver, amount); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
contracts/src/v0.8/ccip/pools/BurnWithFromMintTokenPool.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity 0.8.19; | ||
|
||
import {ITypeAndVersion} from "../../shared/interfaces/ITypeAndVersion.sol"; | ||
import {IBurnMintERC20} from "../../shared/token/ERC20/IBurnMintERC20.sol"; | ||
|
||
import {TokenPool} from "./TokenPool.sol"; | ||
import {BurnMintTokenPoolAbstract} from "./BurnMintTokenPoolAbstract.sol"; | ||
|
||
/// @notice This pool mints and burns a 3rd-party token. | ||
/// @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. | ||
/// The only way to change whitelisting mode is to deploy a new pool. | ||
/// If that is expected, please make sure the token's burner/minter roles are adjustable. | ||
contract BurnWithFromMintTokenPool is BurnMintTokenPoolAbstract, ITypeAndVersion { | ||
// solhint-disable-next-line chainlink-solidity/all-caps-constant-storage-variables | ||
string public constant override typeAndVersion = "BurnWithFromMintTokenPool 1.2.0"; | ||
|
||
constructor( | ||
IBurnMintERC20 token, | ||
address[] memory allowlist, | ||
address armProxy | ||
) TokenPool(token, allowlist, armProxy) { | ||
// 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.approve(address(this), type(uint256).max); | ||
} | ||
|
||
/// @inheritdoc BurnMintTokenPoolAbstract | ||
function _burn(uint256 amount) internal virtual override { | ||
IBurnMintERC20(address(i_token)).burn(address(this), amount); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.