Swaps

Create Swap

Executes a swap from the account's wallet. Crypto swaps run asynchronously; poll GET /swaps/{id} for status. A pair of fiat currency codes instead converts ledger balances to repay a negative to_token balance: by default the conversion brings that balance exactly to zero, or pass amount to repay part of the debt. Fiat conversions complete synchronously, except when funding from USD on a stablecoin-rails account, which starts an asynchronous repayment (status "processing"). The id on a pending repayment is a reference to the repayment workflow; GET /swaps/{id} reports status for crypto swaps only, so watch the account balance for settlement instead of polling.

post/swaps

Headers

Idempotency-Keystring
Example:d9105228-4a08-46b1-8b91-42fed586d383

A unique key that makes this request safe to retry. See Idempotent requests.

Request body

account_idstring required

Business or user account ID (biz_* / user_*).

amountstring nullable

Source token amount. Required for crypto swaps. Optional for fiat pairs: the portion of the negative to_token balance to repay, which must not exceed the debt; omit to repay the full debt.

from_tokenstring required

Source token contract address or ticker symbol, such as "USDT".

slippage_bpsinteger nullable

Maximum slippage tolerance in basis points.

to_tokenstring required

Destination token contract address or ticker symbol, such as "XAUT".

Response

swap created

account_idstring required

Account ID that owns the wallet used for the swap.

amount_innumber nullable

Fiat pairs only: amount of the funding currency converted. Null while a stablecoin repayment is processing.

amount_outnumber nullable

Fiat pairs only: amount credited in the repaid currency. Null while a stablecoin repayment is processing.

amount_out_expectedstring

Expected destination token amount.

amount_out_minstring

Minimum destination amount after slippage.

idstring

Swap ID. Poll GET /swaps/:id for status.

object'swap' required
ratestring

Quoted exchange rate used to create the swap.

statusstring required

Initial swap status.

to_chainstring

Destination chain for the swap.

Changes