MayanCircle
Inherits: ReentrancyGuard
Constants
ETH_DECIMALS
uint8 constant ETH_DECIMALS = 18
CCTP_DOMAIN_INDEX
uint256 constant CCTP_DOMAIN_INDEX = 4
CCTP_NONCE_INDEX
uint256 constant CCTP_NONCE_INDEX = 12
CCTP_TOKEN_INDEX
uint256 constant CCTP_TOKEN_INDEX = 120
CCTP_RECIPIENT_INDEX
uint256 constant CCTP_RECIPIENT_INDEX = 152
CCTP_AMOUNT_INDEX
uint256 constant CCTP_AMOUNT_INDEX = 208
State Variables
wormhole
IWormhole public wormhole
cctpTokenMessenger
ITokenMessenger public cctpTokenMessenger
feeManager
IFeeManager public feeManager
localDomain
uint32 public localDomain
auctionChainId
uint16 public auctionChainId
auctionAddr
bytes32 public auctionAddr
consistencyLevel
uint8 public consistencyLevel
guardian
address public guardian
paused
bool public paused
chainIdToEmitter
mapping(uint16 => bytes32) public chainIdToEmitter
Functions
constructor
constructor(
address _cctpTokenMessenger,
address _wormhole,
address _feeManager,
uint16 _auctionChainId,
bytes32 _auctionAddr,
uint8 _consistencyLevel
) ;
setWormhole
function setWormhole(address _wormhole) external;
setCctpTokenMessenger
function setCctpTokenMessenger(address _cctpTokenMessenger) external;
setFeeManager
function setFeeManager(address _feeManager) external;
bridgeWithFee
function bridgeWithFee(
address tokenIn,
uint256 amountIn,
uint64 redeemFee,
uint64 gasDrop,
bytes32 destAddr,
uint32 destDomain,
uint8 payloadType,
bytes memory customPayload
) external payable nonReentrant returns (uint64 sequence);
bridgeWithLockedFee
function bridgeWithLockedFee(
address tokenIn,
uint256 amountIn,
uint64 gasDrop,
uint256 redeemFee,
uint32 destDomain,
bytes32 destAddr
) external nonReentrant returns (uint64 cctpNonce);
createOrder
function createOrder(OrderParams memory params) external payable nonReentrant returns (uint64 sequence);
redeemWithLockedFee
function redeemWithLockedFee(bytes memory cctpMsg, bytes memory cctpSigs, bytes32 unlockerAddr)
external
payable
nonReentrant
returns (uint64 sequence);
refineFee
function refineFee(uint32 cctpNonce, uint32 cctpDomain, bytes32 destAddr, bytes32 unlockerAddr)
external
payable
nonReentrant
returns (uint64 sequence);
unlockFee
function unlockFee(bytes memory encodedVm, UnlockFeeMsg memory unlockMsg) external nonReentrant;
unlockFeeRefined
function unlockFeeRefined(
bytes memory encodedVm1,
bytes memory encodedVm2,
UnlockFeeMsg memory unlockMsg,
UnlockRefinedFeeMsg memory refinedMsg
) external nonReentrant;
fulfillOrder
function fulfillOrder(
bytes memory cctpMsg,
bytes memory cctpSigs,
bytes memory encodedVm,
FulfillParams memory params,
address swapProtocol,
bytes memory swapData
) external payable nonReentrant;
refund
function refund(
bytes memory encodedVm,
bytes memory cctpMsg,
bytes memory cctpSigs,
OrderParams memory orderParams,
ExtraParams memory extraParams
) external payable nonReentrant;
setMintRecipient
function setMintRecipient(uint32 destDomain, address tokenIn, bytes32 mintRecipient) public;
setDomainCallers
function setDomainCallers(uint32 domain, bytes32 caller) public;
setEmitter
function setEmitter(uint16 chainId, bytes32 emitter) public;
setDomains
function setDomains(uint16[] memory chainIds, uint32[] memory domains) public;
setConsistencyLevel
function setConsistencyLevel(uint8 _consistencyLevel) public;
setPause
function setPause(bool _pause) public;
rescueToken
function rescueToken(address token, uint256 amount, address to) public;
rescueEth
function rescueEth(uint256 amount, address payable to) public;
changeGuardian
function changeGuardian(address newGuardian) public;
claimGuardian
function claimGuardian() public;
calculatePayloadHashForTest
Debug function to calculate payload hash for testing
This allows tests to compare their hash calculation with the contract’s
function calculatePayloadHashForTest(bytes memory cctpMsg, BridgeWithFeeParams memory bridgeParams)
public
pure
returns (bytes32);
recreateBridgeWithFeeForTest
Debug function to recreate bridge message for testing
function recreateBridgeWithFeeForTest(BridgeWithFeeParams memory bridgeParams, bytes memory cctpMsg)
public
pure
returns (BridgeWithFeeMsg memory);
encodeBridgeWithFeeForTest
Debug function to encode bridge message for testing
function encodeBridgeWithFeeForTest(BridgeWithFeeMsg memory bridgeMsg) public pure returns (bytes memory);
redeemWithFee
function redeemWithFee(
bytes memory cctpMsg,
bytes memory cctpSigs,
bytes memory encodedVm,
BridgeWithFeeParams memory bridgeParams
) external payable nonReentrant;
receiveCctp
function receiveCctp(bytes memory cctpMsg, bytes memory cctpSigs) internal returns (address, uint256);
validateEmitter
function validateEmitter(bytes32 emitter, uint16 chainId) internal view;
recreateBridgeWithFee
function recreateBridgeWithFee(BridgeWithFeeParams memory bridgeParams, bytes memory cctpMsg)
internal
pure
returns (BridgeWithFeeMsg memory);
encodeBridgeWithFee
function encodeBridgeWithFee(BridgeWithFeeMsg memory bridgeMsg) internal pure returns (bytes memory);
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, uint64 sourceNonce, uint256 amount);
OrderRefunded
event OrderRefunded(uint32 sourceDomain, uint64 sourceNonce, uint256 amount);
Errors
Paused
error Paused();
Unauthorized
error Unauthorized();
InvalidDomain
error InvalidDomain();
InvalidNonce
error InvalidNonce();
InvalidOrder
error InvalidOrder();
CctpReceiveFailed
error CctpReceiveFailed();
InvalidGasDrop
error InvalidGasDrop();
InvalidAction
error InvalidAction();
InvalidEmitter
error InvalidEmitter();
EmitterAlreadySet
error EmitterAlreadySet();
InvalidDestAddr
error InvalidDestAddr();
InvalidMintRecipient
error InvalidMintRecipient();
InvalidRedeemFee
error InvalidRedeemFee();
InvalidPayload
error InvalidPayload();
CallerNotSet
error CallerNotSet();
MintRecipientNotSet
error MintRecipientNotSet();
InvalidCaller
error InvalidCaller();
DeadlineViolation
error DeadlineViolation();
InvalidAddress
error InvalidAddress();
InvalidReferrerFee
error InvalidReferrerFee();
InvalidProtocolFee
error InvalidProtocolFee();
EthTransferFailed
error EthTransferFailed();
InvalidAmountOut
error InvalidAmountOut();
DomainNotSet
error DomainNotSet();
AlreadySet
error AlreadySet();
Structs
BridgeWithFeeParams
struct BridgeWithFeeParams {
uint8 payloadType;
bytes32 destAddr;
uint64 gasDrop;
uint64 redeemFee;
uint64 burnAmount;
bytes32 burnToken;
bytes32 customPayload;
}
BridgeWithFeeMsg
struct BridgeWithFeeMsg {
uint8 action;
uint8 payloadType;
uint64 cctpNonce;
uint32 cctpDomain;
bytes32 destAddr;
uint64 gasDrop;
uint64 redeemFee;
uint64 burnAmount;
bytes32 burnToken;
bytes32 customPayload;
}
OrderParams
struct OrderParams {
address tokenIn;
uint256 amountIn;
uint64 gasDrop;
bytes32 destAddr;
uint16 destChain;
bytes32 tokenOut;
uint64 minAmountOut;
uint64 deadline;
uint64 redeemFee;
bytes32 referrerAddr;
uint8 referrerBps;
}
ExtraParams
struct ExtraParams {
bytes32 trader;
uint16 sourceChainId;
uint8 protocolBps;
}
UnlockFeeMsg
struct UnlockFeeMsg {
uint8 action;
uint8 payloadType;
uint64 cctpNonce;
uint32 cctpDomain;
bytes32 unlockerAddr;
uint64 gasDrop;
}
UnlockRefinedFeeMsg
struct UnlockRefinedFeeMsg {
uint8 action;
uint8 payloadType;
uint64 cctpNonce;
uint32 cctpDomain;
bytes32 unlockerAddr;
uint64 gasDrop;
bytes32 destAddr;
}
FulfillParams
struct FulfillParams {
bytes32 destAddr;
uint16 destChainId;
bytes32 tokenOut;
uint64 promisedAmount;
uint64 gasDrop;
uint64 redeemFee;
uint64 deadline;
bytes32 referrerAddr;
uint8 referrerBps;
uint8 protocolBps;
bytes32 driver;
}
Enums
Action
enum Action {
NONE,
SWAP,
FULFILL,
BRIDGE_WITH_FEE,
UNLOCK_FEE,
UNLOCK_FEE_REFINE
}