FastMCTP
Inherits: ReentrancyGuard
Constants
ETH_DECIMALS
uint8 internal constant ETH_DECIMALS = 18
CCTPV2_SOURCE_DOMAIN_INDEX
uint256 internal constant CCTPV2_SOURCE_DOMAIN_INDEX = 4
CCTPV2_DESTINATION_DOMAIN_INDEX
uint256 internal constant CCTPV2_DESTINATION_DOMAIN_INDEX = 8
CCTPV2_NONCE_INDEX
uint256 internal constant CCTPV2_NONCE_INDEX = 12
CCTPV2_DETINATION_CALLER_INDEX
uint256 internal constant CCTPV2_DETINATION_CALLER_INDEX = 108
CCTPV2_MESSAGE_BODY_INDEX
uint256 internal constant CCTPV2_MESSAGE_BODY_INDEX = 148
CCTPV2_SOURCE_TOKEN_INDEX
uint256 internal constant CCTPV2_SOURCE_TOKEN_INDEX = CCTPV2_MESSAGE_BODY_INDEX + 4
CCTPV2_MINT_RECIPIENT_INDEX
uint256 internal constant CCTPV2_MINT_RECIPIENT_INDEX = CCTPV2_MESSAGE_BODY_INDEX + 36
HOOK_DATA_INDEX
uint256 internal constant HOOK_DATA_INDEX = CCTPV2_MESSAGE_BODY_INDEX + 228
GAS_LIMIT_FEE_MANAGER
uint256 internal constant GAS_LIMIT_FEE_MANAGER = 1000000
State Variables
cctpTokenMessengerV2
ITokenMessengerV2 public cctpTokenMessengerV2
feeManager
address public feeManager
guardian
address public guardian
paused
bool public paused
whitelistedSwapProtocols
mapping(address => bool) public whitelistedSwapProtocols
whitelistedMsgSenders
mapping(address => bool) public whitelistedMsgSenders
Functions
checkRecipient
modifier checkRecipient(bytes memory cctpMsg) ;
whenNotPaused
modifier whenNotPaused() ;
constructor
constructor(address _cctpTokenMessengerV2, address _feeManager) ;
setCctpTokenMessengerV2
function setCctpTokenMessengerV2(address _cctpTokenMessengerV2) external;
setFeeManager
function setFeeManager(address _feeManager) external;
bridge
function bridge(
address tokenIn,
uint256 amountIn,
uint64 redeemFee,
uint256 circleMaxFee,
uint64 gasDrop,
bytes32 destAddr,
uint32 destDomain,
bytes32 referrerAddress,
uint8 referrerBps,
uint8 payloadType,
uint32 minFinalityThreshold,
bytes memory customPayload
) external nonReentrant whenNotPaused;
createOrder
function createOrder(
address tokenIn,
uint256 amountIn,
uint256 circleMaxFee,
uint32 destDomain,
uint32 minFinalityThreshold,
OrderPayload memory orderPayload
) external nonReentrant whenNotPaused;
fulfillOrder
function fulfillOrder(bytes memory cctpMsg, bytes memory cctpSigs, address swapProtocol, bytes memory swapData)
external
payable
nonReentrant
checkRecipient(cctpMsg);
refund
function refund(bytes memory cctpMsg, bytes memory cctpSigs) external payable nonReentrant checkRecipient(cctpMsg);
setMintRecipient
function setMintRecipient(uint32 destDomain, address tokenIn, bytes32 mintRecipient) public;
setDomainCallers
function setDomainCallers(uint32 domain, bytes32 caller) public;
setWhitelistedSwapProtocols
function setWhitelistedSwapProtocols(address protocol, bool isWhitelisted) public;
setWhitelistedMsgSenders
function setWhitelistedMsgSenders(address sender, bool isWhitelisted) public;
setPause
function setPause(bool _pause) public;
changeGuardian
function changeGuardian(address newGuardian) public;
claimGuardian
function claimGuardian() public;
rescueToken
function rescueToken(address token, uint256 amount, address to) public;
rescueEth
function rescueEth(uint256 amount, address payable to) public;
rescueRedeem
function rescueRedeem(bytes memory cctpMsg, bytes memory cctpSigs) public;
redeem
function redeem(bytes memory cctpMsg, bytes memory cctpSigs) external payable nonReentrant checkRecipient(cctpMsg);
receiveCctp
function receiveCctp(bytes memory cctpMsg, bytes memory cctpSigs) internal returns (address, uint256);
recreateBridgePayload
function recreateBridgePayload(bytes memory cctpMsg) internal pure returns (BridgePayload memory);
safeCalcFastMCTPProtocolBps
function safeCalcFastMCTPProtocolBps(
uint8 payloadType,
address localToken,
uint256 cctpAmount,
address tokenOut,
address referrerAddr,
uint8 referrerBps
) internal returns (uint8);
safeGetFeeCollector
function safeGetFeeCollector() internal view returns (address);
depositRelayerFee
function depositRelayerFee(address relayer, address token, uint256 amount) internal;
deNormalizeAmount
function deNormalizeAmount(uint256 amount, uint8 decimals) internal pure returns (uint256);
payEth
function payEth(address to, uint256 amount, bool revertOnFailure) internal;
truncateAddress
function truncateAddress(bytes32 b) internal pure returns (address);
receive
receive() external payable;
Events
OrderFulfilled
event OrderFulfilled(uint32 sourceDomain, bytes32 sourceNonce, uint256 amount);
OrderRefunded
event OrderRefunded(uint32 sourceDomain, bytes32 sourceNonce, uint256 amount);
Errors
Paused
error Paused();
Unauthorized
error Unauthorized();
CctpReceiveFailed
error CctpReceiveFailed();
InvalidGasDrop
error InvalidGasDrop();
InvalidMintRecipient
error InvalidMintRecipient();
InvalidRedeemFee
error InvalidRedeemFee();
InvalidPayload
error InvalidPayload();
DeadlineViolation
error DeadlineViolation();
InvalidAddress
error InvalidAddress();
InvalidPayloadType
error InvalidPayloadType();
EthTransferFailed
error EthTransferFailed();
InvalidAmountOut
error InvalidAmountOut();
MintRecipientNotSet
error MintRecipientNotSet();
CallerNotSet
error CallerNotSet();
InvalidRefundFee
error InvalidRefundFee();
AlreadySet
error AlreadySet();
UnauthorizedSwapProtocol
error UnauthorizedSwapProtocol();
UnauthorizedMsgSender
error UnauthorizedMsgSender();
Structs
BridgePayload
struct BridgePayload {
uint8 payloadType;
bytes32 destAddr;
uint64 gasDrop;
uint64 redeemFee;
bytes32 referrerAddr;
uint8 referrerBps;
bytes32 customPayload;
}
OrderPayload
struct OrderPayload {
uint8 payloadType;
bytes32 destAddr;
bytes32 tokenOut;
uint64 amountOutMin;
uint64 gasDrop;
uint64 redeemFee;
uint64 refundFee;
uint64 deadline;
bytes32 referrerAddr;
uint8 referrerBps;
}