-
Notifications
You must be signed in to change notification settings - Fork 102
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
1 parent
2b87923
commit cd06a01
Showing
25 changed files
with
1,190 additions
and
17 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
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,38 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
// End consumer library. | ||
library Client { | ||
/// @dev RMN depends on this struct, if changing, please notify the RMN maintainers. | ||
struct EVMTokenAmount { | ||
address token; // token address on the local chain. | ||
uint256 amount; // Amount of tokens. | ||
} | ||
|
||
struct Any2EVMMessage { | ||
bytes32 messageId; // MessageId corresponding to ccipSend on source. | ||
uint64 sourceChainSelector; // Source chain selector. | ||
bytes sender; // abi.decode(sender) if coming from an EVM chain. | ||
bytes data; // payload sent in original message. | ||
EVMTokenAmount[] destTokenAmounts; // Tokens and their amounts in their destination chain representation. | ||
} | ||
|
||
// If extraArgs is empty bytes, the default is 200k gas limit. | ||
struct EVM2AnyMessage { | ||
bytes receiver; // abi.encode(receiver address) for dest EVM chains | ||
bytes data; // Data payload | ||
EVMTokenAmount[] tokenAmounts; // Token transfers | ||
address feeToken; // Address of feeToken. address(0) means you will send msg.value. | ||
bytes extraArgs; // Populate this with _argsToBytes(EVMExtraArgsV1) | ||
} | ||
|
||
// bytes4(keccak256("CCIP EVMExtraArgsV1")); | ||
bytes4 public constant EVM_EXTRA_ARGS_V1_TAG = 0x97a657c9; | ||
struct EVMExtraArgsV1 { | ||
uint256 gasLimit; | ||
} | ||
|
||
function _argsToBytes(EVMExtraArgsV1 memory extraArgs) internal pure returns (bytes memory bts) { | ||
return abi.encodeWithSelector(EVM_EXTRA_ARGS_V1_TAG, extraArgs); | ||
} | ||
} |
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,10 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import {ConfirmedOwnerWithProposal} from './ConfirmedOwnerWithProposal.sol'; | ||
|
||
/// @title The ConfirmedOwner contract | ||
/// @notice A contract with helpers for basic contract ownership. | ||
contract ConfirmedOwner is ConfirmedOwnerWithProposal { | ||
constructor(address newOwner) ConfirmedOwnerWithProposal(newOwner, address(0)) {} | ||
} |
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,65 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import {IOwnable} from './IOwnable.sol'; | ||
|
||
/// @title The ConfirmedOwner contract | ||
/// @notice A contract with helpers for basic contract ownership. | ||
contract ConfirmedOwnerWithProposal is IOwnable { | ||
address private s_owner; | ||
address private s_pendingOwner; | ||
|
||
event OwnershipTransferRequested(address indexed from, address indexed to); | ||
event OwnershipTransferred(address indexed from, address indexed to); | ||
|
||
constructor(address newOwner, address pendingOwner) { | ||
// solhint-disable-next-line custom-errors | ||
require(newOwner != address(0), 'Cannot set owner to zero'); | ||
|
||
s_owner = newOwner; | ||
if (pendingOwner != address(0)) { | ||
_transferOwnership(pendingOwner); | ||
} | ||
} | ||
|
||
/// @notice Allows an owner to begin transferring ownership to a new address. | ||
function transferOwnership(address to) public override onlyOwner { | ||
_transferOwnership(to); | ||
} | ||
|
||
/// @notice Allows an ownership transfer to be completed by the recipient. | ||
function acceptOwnership() external override { | ||
// solhint-disable-next-line custom-errors | ||
require(msg.sender == s_pendingOwner, 'Must be proposed owner'); | ||
|
||
address oldOwner = s_owner; | ||
s_owner = msg.sender; | ||
s_pendingOwner = address(0); | ||
|
||
emit OwnershipTransferred(oldOwner, msg.sender); | ||
} | ||
|
||
/// @notice Get the current owner | ||
function owner() public view override returns (address) { | ||
return s_owner; | ||
} | ||
|
||
/// @notice validate, transfer ownership, and emit relevant events | ||
function _transferOwnership(address to) internal { | ||
s_pendingOwner = to; | ||
|
||
emit OwnershipTransferRequested(s_owner, to); | ||
} | ||
|
||
/// @notice validate access | ||
function _validateOwnership() internal view { | ||
// solhint-disable-next-line custom-errors | ||
require(msg.sender == s_owner, 'Only callable by owner'); | ||
} | ||
|
||
/// @notice Reverts if called by anyone other than the contract owner. | ||
modifier onlyOwner() { | ||
_validateOwnership(); | ||
_; | ||
} | ||
} |
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,17 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
/// @notice This interface contains the only ARM-related functions that might be used on-chain by other CCIP contracts. | ||
interface IARM { | ||
/// @notice A Merkle root tagged with the address of the commit store contract it is destined for. | ||
struct TaggedRoot { | ||
address commitStore; | ||
bytes32 root; | ||
} | ||
|
||
/// @notice Callers MUST NOT cache the return value as a blessed tagged root could become unblessed. | ||
function isBlessed(TaggedRoot calldata taggedRoot) external view returns (bool); | ||
|
||
/// @notice When the ARM is "cursed", CCIP pauses until the curse is lifted. | ||
function isCursed() external view returns (bool); | ||
} |
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,29 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; | ||
|
||
interface IBurnMintERC20 is IERC20 { | ||
/// @notice Mints new tokens for a given address. | ||
/// @param account The address to mint the new tokens to. | ||
/// @param amount The number of tokens to be minted. | ||
/// @dev this function increases the total supply. | ||
function mint(address account, uint256 amount) external; | ||
|
||
/// @notice Burns tokens from the sender. | ||
/// @param amount The number of tokens to be burned. | ||
/// @dev this function decreases the total supply. | ||
function burn(uint256 amount) external; | ||
|
||
/// @notice Burns tokens from a given address.. | ||
/// @param account The address to burn tokens from. | ||
/// @param amount The number of tokens to be burned. | ||
/// @dev this function decreases the total supply. | ||
function burn(address account, uint256 amount) external; | ||
|
||
/// @notice Burns tokens from a given address.. | ||
/// @param account The address to burn tokens from. | ||
/// @param amount The number of tokens to be burned. | ||
/// @dev this function decreases the total supply. | ||
function burnFrom(address account, uint256 amount) external; | ||
} |
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,16 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.0; | ||
|
||
/// @notice Interface for a liquidity container, this can be a CCIP token pool. | ||
interface ILiquidityContainer { | ||
event LiquidityAdded(address indexed provider, uint256 indexed amount); | ||
event LiquidityRemoved(address indexed provider, uint256 indexed amount); | ||
|
||
/// @notice Provide additional liquidity to the container. | ||
/// @dev Should emit LiquidityAdded | ||
function provideLiquidity(uint256 amount) external; | ||
|
||
/// @notice Withdraws liquidity from the container to the msg sender | ||
/// @dev Should emit LiquidityRemoved | ||
function withdrawLiquidity(uint256 amount) external; | ||
} |
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,10 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
interface IOwnable { | ||
function owner() external returns (address); | ||
|
||
function transferOwnership(address recipient) external; | ||
|
||
function acceptOwnership() external; | ||
} |
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,46 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; | ||
|
||
// Shared public interface for multiple pool types. | ||
// Each pool type handles a different child token model (lock/unlock, mint/burn.) | ||
interface IPool { | ||
/// @notice Lock tokens into the pool or burn the tokens. | ||
/// @param originalSender Original sender of the tokens. | ||
/// @param receiver Receiver of the tokens on destination chain. | ||
/// @param amount Amount to lock or burn. | ||
/// @param remoteChainSelector Destination chain Id. | ||
/// @param extraArgs Additional data passed in by sender for lockOrBurn processing | ||
/// in custom pools on source chain. | ||
/// @return retData Optional field that contains bytes. Unused for now but already | ||
/// implemented to allow future upgrades while preserving the interface. | ||
function lockOrBurn( | ||
address originalSender, | ||
bytes calldata receiver, | ||
uint256 amount, | ||
uint64 remoteChainSelector, | ||
bytes calldata extraArgs | ||
) external returns (bytes memory); | ||
|
||
/// @notice Releases or mints tokens to the receiver address. | ||
/// @param originalSender Original sender of the tokens. | ||
/// @param receiver Receiver of the tokens. | ||
/// @param amount Amount to release or mint. | ||
/// @param remoteChainSelector Source chain Id. | ||
/// @param extraData Additional data supplied offchain for releaseOrMint processing in | ||
/// custom pools on dest chain. This could be an attestation that was retrieved through a | ||
/// third party API. | ||
/// @dev offchainData can come from any untrusted source. | ||
function releaseOrMint( | ||
bytes memory originalSender, | ||
address receiver, | ||
uint256 amount, | ||
uint64 remoteChainSelector, | ||
bytes memory extraData | ||
) external; | ||
|
||
/// @notice Gets the IERC20 token that this pool can lock or burn. | ||
/// @return token The IERC20 token representation. | ||
function getToken() external view returns (IERC20 token); | ||
} |
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,38 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import {Client} from './Client.sol'; | ||
|
||
interface IRouter { | ||
error OnlyOffRamp(); | ||
|
||
/// @notice Route the message to its intended receiver contract. | ||
/// @param message Client.Any2EVMMessage struct. | ||
/// @param gasForCallExactCheck of params for exec | ||
/// @param gasLimit set of params for exec | ||
/// @param receiver set of params for exec | ||
/// @dev if the receiver is a contracts that signals support for CCIP execution through EIP-165. | ||
/// the contract is called. If not, only tokens are transferred. | ||
/// @return success A boolean value indicating whether the ccip message was received without errors. | ||
/// @return retBytes A bytes array containing return data form CCIP receiver. | ||
/// @return gasUsed the gas used by the external customer call. Does not include any overhead. | ||
function routeMessage( | ||
Client.Any2EVMMessage calldata message, | ||
uint16 gasForCallExactCheck, | ||
uint256 gasLimit, | ||
address receiver | ||
) external returns (bool success, bytes memory retBytes, uint256 gasUsed); | ||
|
||
/// @notice Returns the configured onramp for a specific destination chain. | ||
/// @param destChainSelector The destination chain Id to get the onRamp for. | ||
/// @return onRampAddress The address of the onRamp. | ||
function getOnRamp(uint64 destChainSelector) external view returns (address onRampAddress); | ||
|
||
/// @notice Return true if the given offRamp is a configured offRamp for the given source chain. | ||
/// @param sourceChainSelector The source chain selector to check. | ||
/// @param offRamp The address of the offRamp to check. | ||
function isOffRamp( | ||
uint64 sourceChainSelector, | ||
address offRamp | ||
) external view returns (bool isOffRamp); | ||
} |
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,6 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
interface ITypeAndVersion { | ||
function typeAndVersion() external pure returns (string memory); | ||
} |
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,10 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import {ConfirmedOwner} from './ConfirmedOwner.sol'; | ||
|
||
/// @title The OwnerIsCreator contract | ||
/// @notice A contract with helpers for basic contract ownership. | ||
contract OwnerIsCreator is ConfirmedOwner { | ||
constructor() ConfirmedOwner(msg.sender) {} | ||
} |
Oops, something went wrong.