Skip to main content

DeFi API Execution Reference

Quotes

Get the Best Quote

Retrieve the best available swap quote for a given source token, destination token, and amount. This endpoint returns pricing details, limits, and metadata required to proceed with a swap.

Quotes are time-limited and must be executed before they expire.

POST /v1/quotes

Request body example:

application/json
{
"from": {
"from_network_id": 1,
"from_token": "0xc02aaa3********9083c756cc2"
},
"to": {
"to_network_id": 4,
"to_token": "So11111111111111111111111111111111111111112",
},
"amount": 100,
"slippage_bps": "50"
}

Request notes:

  • amount must be specified in decimal-adjusted format.
  • slippage_bps is expressed in basis points and must be sent as a string.

Response example:

application/json
{
"id": "bea66e69-64c3-4b88-96ac-29f1ce7d454d",
"from": {
"from_network_id": 1,
"from_token": "0xdac17f9********13d831ec7",
"from_amount_lots": 100000000,
"from_amount_decimals": 6
},
"mid": {
"mid_token_id": null,
"mid_token": null,
"mid_token_min_amount": null,
"mid_token_max_amount": null,
"mid_token_decimals": null
},
"to": {
"to_network_id": 4,
"to_token": "0xdac17f9********13d831ec7",
"to_min_amount_lots": 857382336,
"to_max_amount_lots": 861690790,
"to_amount_decimals": 9
},
"slippage_bps": "50",
"expires_at": 1769777954084
}

Quote Expiry

The expires_at field is a Unix timestamp in milliseconds (ms since epoch). After this timestamp, the quote is no longer valid and must be refreshed. Quotes should always be executed before expiry to guarantee pricing.

Middle Token Routing

If the user attempts to swap a volatile token, the system may automatically route the swap through a highly liquid intermediate token, typically USDC, to improve execution reliability and manage price volatility. All fields prefixed with mid_ describe this routing behavior and the token used internally.

Affiliate fees

To set your reward amount, please contact your manager or reach out to us at [email protected].


Intents

An intent represents a user's request to perform a swap and can only be created based on a quote, to which it is attached. It defines what the user wants to do, while the protocol handles how it gets executed.

Intents are chain-agnostic and support multiple blockchains and approval mechanisms.

Intent lifecycle

A typical intent goes through the following steps:

  1. Creation - An intent is created via the API with swap parameters such as source chain, destination chain, tokens, and amounts.
  2. Approval - The user authorizes fund usage using a chain-specific approval mechanism (for example, Permit2 on EVM, PSBT on Bitcoin, Cosigned transaction on Solana).
  3. Execution - Once approved, the resolver processes the intent and executes the swap.
  4. Status tracking - The intent status can be queried at any time to track progress or final outcome.

Create Intent

Create a new swap intent that describes what the user wants to swap. An intent is created off-chain and later executed on-chain by a resolver.

POST /v1/intents

Request example:

application/json
{
"quote_id": "bea66e69-64c3-4b88-96ac-29f1ce7d454d",
"from": {
"from_network_id": 1,
"from_token": "0xc02aaa3********9083c756cc2",
"from_address": "0x000000000000000000000000000000000000000"
},
"to": {
"to_network_id": 4,
"to_token": "So11111111111111111111111111111111111111112",
"to_address": "0x000000000000000000000000000000000000000"
},
"refund_address": "0x000000000000000000000000000000000000000",
"amount": 100,
"slippage_bps": "50"
}

Response example (EVM and Tron):

application/json
{
"id": "8a2d3f92-2a2b-4e4c-9d8a-3c9f92e4a111",
"deadline_at": 1761545456,
"approval_type": "permit2",
"params_to_sign": {
"escrow_contract_address": "0x000000000000000000000000000000000000000",
"permit2_contract_address": "0x000000000000000000000000000000000000000",
"resolver_deposit_address": "0x000000000000000000000000000000000000000",
"nonce": 10000,
"additional_data": {
"domain": { /* EIP-712 domain data */ },
"types": { /* EIP-712 types */ },
"witness": { /* witness data */ },
"witness_type_string": "ExampleTrade witness)ExampleTrade(address exampleTokenAddress,uint256 exampleMinimumAmountOut)",
"witness_hash": "0x000000000000000000000000000000000000000000000000000000000000000"
}
}
}

Approval Mechanism

The approval flow depends on the blockchain and swap type. The value of approval_type may change, and the structure of params_to_sign depends on the selected approval mechanism. Clients must always check approval_type and handle params_to_sign accordingly.

Approval Mechanism Examples:

Permit2 (used for EVM-based blockchains):

application/json
{
"id": "528d72ae-61cd-4fbc-9940-48ce4104abbb",
"deadline_at": 1772124002,
"secret_hash": "0x19875e12d834bc24********44dd26f37d367a44926",
"approval_type": "permit2",
"params_to_sign": {
"escrow_contract_address": "0x8DcbE1aCf********18F8e8836",
"permit2_contract_address": "0x0000000********6B43aC78BA3",
"resolver_deposit_address": "0xF3B3a4edB********f69f557029",
"nonce": 499,
"additional_data": {
"domain": { /* EIP-712 domain data */ },
"types": { /* EIP-712 types */ },
"witness": { /* witness data */ },
"secretHash": "0xabcde...",
"witness_type_string": "DepositWitness witness)DepositWitness(address resolverDepositAddress,bytes32 secretHash,uint256 deadline)TokenPermissions(address token,uint256 amount)",
"witness_hash": "0xc77ff4a96e********b8c12636c39f7f"
}
}
}

HTLC (used for Bitcoin blockchain):

application/json
{
"id": "0a47fbd6-056a-4e4d-a1e3-9b9a1bf947e5",
"approval_type": "htlc",
"params_to_sign": {
"psbt": "cHNidP8BAJ0CAAAAAQEBAQEB...",
"inputs": [0, 1, 2]
}
}

Cosigned transaction (used for Solana blockchain):

application/json
{
"id": "0a47fbd6-056a-4e4d-a1e3-9b9a1bf947e5",
"deadline_at": 1772124152,
"secret_hash": "0x84edcf7********dd0fb60baccf",
"approval_type": "cosign",
"params_to_sign": {
"transaction": "02000..."
}
}

Approvals

After an intent is created, an approval must be added before it can be executed. This endpoint attaches a signed approval to an existing intent. The approval proves the user has authorized the swap and allows it to proceed.

warning

You can find examples of how to generate the approval signed data on this page.

POST /v1/intents/{intent_id}/approvals

Request Body

The request body depends on the approval mechanism. It includes the approval type and the signed data generated by the user.

Permit2 (EVM):

application/json
{
"approval_type": "permit2",
"signed_data": "0x..."
}

signed_data is the Permit2 signature.

Possible errors: If the backend returns error code 25, the user has not approved Permit2 yet for the selected token. The user must approve Permit2 on-chain before continuing.

PSBT (Bitcoin):

application/json
{
"approval_type": "psbt",
"signed_data": "cHNid..."
}

signed_data is a signed PSBT.

Cosign (Solana):

application/json
{
"approval_type": "cosign",
"signed_data": {
"transaction": "02000...",
"user_address": "F8ZRdxv********ETTDFg"
}
}

signed_data.transaction is a signed versioned transaction.


Retrieving Intent Status

This endpoint allows you to check the current status of a swap intent. It provides the intent's lifecycle state, associated transactions, and additional metadata.

GET /v1/intents/{intent_id}

Response Example:

application/json
{
"intent_id": "fe5601fb-60f2-4cb0-8a67-c55bd3640411",
"status": "Deposited",
"from_amount_lots": "123456",
"from_network_id": 1,
"from_token": "0x000000000000000000000000000000000000000",
"from_token_id": 1,
"to_network_id": 2,
"to_token": "0x000000000000000000000000000000000000000",
"to_token_id": 4,
"to_min_amount_lots": "123456",
"to_max_amount_lots": "123456",
"swap_metadata": {
"id": "19b44362-bc4d-4b2e-824f-f712c6c80eff",
"proxy_address": "0x000000000000000000000000000000000000000",
"user_deposit_tx": "0x000000000000000000000000000000000000000",
"fulfill_tx": null,
"swap_tx": null,
"created_at": "2026-01-15T12:00:00Z",
"user_deposited_at": "2026-01-15T12:05:00Z",
"fulfilled_at": null,
"swapped_at": null,
"refunded_at": null
}
}

The status field represents the overall progress of the swap, combining both intent and swap state.

Possible swap statuses:

StatusDescription
CreatedThe intent has been created but no approval has been added yet.
ApprovedUser has added approval/signature for the swap.
VerifiedResolver has accepted the intent and is ready to execute.
FailedThe intent was declined by the resolver.
DepositedResolver has deposited user tokens on source network into the escrow.
FinishedUser has received funds on destination network in target token.
ExpiredThe intent expired before execution.
RefundRequestedA refund has been requested for this intent.
RefundedTokens have been refunded to the user.

Additional Notes:

  • Use this endpoint to poll the status of an intent or check its progress.
  • swap_metadata provides transaction hashes and timestamps to track each stage.