MayanAdapter
Inherits: BaseAdapter
Title: MayanAdapter
Adapter for settling Mayan protocol claims and forwarding to MetaIntentReceiver
Uses pull configuration - any third-party settler can trigger settlements
Constants
MAYAN_CIRCLE
MayanCircle public immutable MAYAN_CIRCLE
FAST_MCTP
FastMCTP public immutable FAST_MCTP
SWIFT_DEST
SwiftDest public immutable SWIFT_DEST
CCTP_TOKEN_INDEX
uint256 internal constant CCTP_TOKEN_INDEX = 120
CCTP_RECIPIENT_INDEX
uint256 internal constant CCTP_RECIPIENT_INDEX = 152
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
HOOK_DATA_INDEX
uint256 internal constant HOOK_DATA_INDEX = CCTPV2_MESSAGE_BODY_INDEX + 228
Functions
constructor
Constructor sets immutable references to Mayan contracts and receiver
constructor(address receiver, address payable mayanCircle, address payable fastMctp, address payable swiftDest)
BaseAdapter(receiver);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | Address of the MetaIntentReceiver contract |
mayanCircle | address payable | Address of the MayanCircle contract |
fastMctp | address payable | Address of the FastMCTP contract |
swiftDest | address payable | Address of the SwiftDest contract |
settleMayanCircle
Settle tokens from MayanCircle and forward to MetaIntentReceiver
function settleMayanCircle(
bytes calldata cctpMsg,
bytes calldata cctpSigs,
bytes calldata encodedVm,
MayanCircle.BridgeWithFeeParams calldata bridgeParams,
RelayedOrderOutput calldata expectedOutput
) external payable returns (bytes32 payloadHash);
Parameters
| Name | Type | Description |
|---|---|---|
cctpMsg | bytes | The CCTP message bytes |
cctpSigs | bytes | The CCTP attestation signatures |
encodedVm | bytes | The encoded Wormhole VM |
bridgeParams | MayanCircle.BridgeWithFeeParams | The bridge parameters containing custom payload |
expectedOutput | RelayedOrderOutput | The expected output details (amount is minimum required) |
Returns
| Name | Type | Description |
|---|---|---|
payloadHash | bytes32 | The payload hash returned by the receiver |
settleFastMCTP
Settle tokens from FastMCTP and forward to MetaIntentReceiver
function settleFastMCTP(bytes calldata cctpMsg, bytes calldata cctpSigs, RelayedOrderOutput calldata expectedOutput)
external
payable
returns (bytes32 payloadHash);
Parameters
| Name | Type | Description |
|---|---|---|
cctpMsg | bytes | The CCTP V2 message bytes |
cctpSigs | bytes | The CCTP V2 attestation signatures |
expectedOutput | RelayedOrderOutput | The expected output details (amount is minimum required) |
Returns
| Name | Type | Description |
|---|---|---|
payloadHash | bytes32 | The payload hash returned by the receiver |
settleSwiftDest
Settle tokens from SwiftDest and forward to MetaIntentReceiver
function settleSwiftDest(
OrderParams calldata params,
ExtraParams calldata extraParams,
RelayedOrderOutput calldata expectedOutput
) external returns (bytes32 payloadHash);
Parameters
| Name | Type | Description |
|---|---|---|
params | OrderParams | The order parameters |
extraParams | ExtraParams | The extra parameters containing custom payload hash |
expectedOutput | RelayedOrderOutput | The expected output details (amount is minimum required) |
Returns
| Name | Type | Description |
|---|---|---|
payloadHash | bytes32 | The payload hash returned by the receiver |
_extractTokenFromCctpV1Msg
Extract token address from CCTP V1 message (MayanCircle)
function _extractTokenFromCctpV1Msg(bytes calldata cctpMsg) internal pure returns (address token);
Parameters
| Name | Type | Description |
|---|---|---|
cctpMsg | bytes | The CCTP V1 message bytes |
Returns
| Name | Type | Description |
|---|---|---|
token | address | The token address extracted from the message |
_extractTokenFromCctpV2Msg
Extract token address from CCTP V2 message (FastMCTP)
function _extractTokenFromCctpV2Msg(bytes calldata cctpMsg) internal pure returns (address token);
Parameters
| Name | Type | Description |
|---|---|---|
cctpMsg | bytes | The CCTP V2 message bytes |
Returns
| Name | Type | Description |
|---|---|---|
token | address | The token address extracted from the message |
_extractOrderIdFromCctpV2Msg
Extract orderId from CCTP V2 message hook data (FastMCTP)
Hook data format: payloadType(1) + destAddr(32) + gasDrop(8) + redeemFee(8) + referrerAddr(32) + referrerBps(1) + customPayload(32) Total: 84 bytes before customPayload, customPayload at index HOOK_DATA_INDEX + 82
function _extractOrderIdFromCctpV2Msg(bytes calldata cctpMsg) internal pure returns (bytes32 orderId);
Parameters
| Name | Type | Description |
|---|---|---|
cctpMsg | bytes | The CCTP V2 message bytes |
Returns
| Name | Type | Description |
|---|---|---|
orderId | bytes32 | The orderId extracted from the custom payload field |
_fulfillToReceiverWithAmount
Internal helper to fulfill to receiver with a specific amount
This allows us to use the expectedOutput structure but with the actual received amount
function _fulfillToReceiverWithAmount(RelayedOrderOutput calldata baseOutput, uint256 actualAmount)
internal
returns (bytes32 payloadHash);
Parameters
| Name | Type | Description |
|---|---|---|
baseOutput | RelayedOrderOutput | The base output structure (orderId, recipient, token, callData) |
actualAmount | uint256 | The actual amount received from Mayan |
Returns
| Name | Type | Description |
|---|---|---|
payloadHash | bytes32 | The payload hash returned by the receiver |
_decodeMessage
Override _decodeMessage for BaseAdapter compliance
function _decodeMessage(bytes calldata message) internal pure override returns (RelayedOrderOutput memory output);
Parameters
| Name | Type | Description |
|---|---|---|
message | bytes | The encoded message bytes |
Returns
| Name | Type | Description |
|---|---|---|
output | RelayedOrderOutput | The decoded RelayedOrderOutput |
receive
receive() external payable override;
Errors
InvalidMayanContract
error InvalidMayanContract();
SettlementFailed
error SettlementFailed();
InsufficientSettlementAmount
error InsufficientSettlementAmount(uint256 received, uint256 expected);
InvalidCctpMessage
error InvalidCctpMessage();
OrderIdMismatch
error OrderIdMismatch(bytes32 expected, bytes32 actual);
TokenMismatch
error TokenMismatch(bytes32 expected, bytes32 actual);