Swap

Start a swap.

Opens a deposit channel and returns the deposit address the user sends sourceAsset to. Once the deposit arrives the swap runs and pays out to destinationAddress, with your broker fee taken. minimumPrice, refundAddress and retryDurationInBlocks protect against slippage: if the price cannot be met within that time, the deposit is refunded. livePriceSlippageTolerancePercent adds a limit against Chainflip's oracle price. Optional parameters add Boost (Bitcoin), DCA, a commission override and up to four affiliates. Follow the swap with getStatusById or getStatusByDepositChannel.

get/swap

Request

  • Base URL: https://chainflip-broker.io
  • URL: https://chainflip-broker.io/swap
  • Auth: one of:
    • API key in query parameter apiKey
    • API key in header X-API-Key

Query parameters

apiKeystring

Your partner API key. A key is required through this parameter OR the X-API-Key header; when both are present, this query parameter wins, even when it is empty, which fails validation rather than falling back to the header.

sourceAssetstring required

The asset to swap from.

destinationAssetstring required

The asset to swap to.

destinationAddressstring required

The address on the destination chain to swap to.

commissionBpsinteger

An optional override to the charged commission bps.

boostFeeinteger

Maximum accepted boost fee in basis points (100th of a percent).

minimumPricenumber double required

Minimum accepted human readable price.

refundAddressstring required

Address on the source chain to which the refund will be sent, if the minimum price cannot be met.

retryDurationInBlocksinteger required

Number of blocks after which a deposit is refunded if the minimum price cannot be met. One block corresponds to 6 seconds. Max 14400 = 24 hours. Recommended: 150.

livePriceSlippageTolerancePercentnumber double

Live price protection: how far, in percent (0 to 100, at most 2 decimals), the execution price may fall below Chainflip's oracle price; a swap below it is retried and, after retryDurationInBlocks, refunded. Use the quote's recommendedLivePriceSlippageTolerancePercent when it has one. Rejected with code live_price_protection_unavailable when either asset has no oracle price on Chainflip. When set, a stale oracle price also counts as a violation. Omit it to keep Chainflip's default protection for the pair.

numberOfChunksinteger

The number of "sub-swaps" to perform for a DCA swap.

chunkIntervalBlocksinteger

The delay between the "sub-swaps" of a DCA swap in number of blocks.

affiliate1string

First optional extra affiliate ss58 address to share commission with.

affiliate1CommissionBpsinteger

First optional extra affiliate commission in basis points.

affiliate2string

Second optional extra affiliate ss58 address to share commission with.

affiliate2CommissionBpsinteger

Second optional extra affiliate commission in basis points.

affiliate3string

Third optional extra affiliate ss58 address to share commission with.

affiliate3CommissionBpsinteger

Third optional extra affiliate commission in basis points.

affiliate4string

Fourth optional extra affiliate ss58 address to share commission with.

affiliate4CommissionBpsinteger

Fourth optional extra affiliate commission in basis points.

platformstring

Optional provider to route the swap through. Defaults to chainflip.

Response

A deposit address for the given swap.

idinteger nullable

The BaaS swap id: pass it as swapId to getStatusById. Absent in the rare case the swap could not be recorded right away; follow it with getStatusByDepositChannel then.

addressstring required

The deposit address to send source assets to.

issuedBlockinteger required

The block in which the deposit address was issued.

networkstring required

The network to send the source assets over.

channelIdinteger required

The channel id to monitor the deposit.

sourceExpiryBlockinteger required

The block (on the source network) in which the deposit address will expire.

explorerUrlstring required

The explorer url to monitor the deposit.

channelOpeningFeenumber double required

Fee in $FLIP to open the deposit channel.

channelOpeningFeeNativestring required

Fee in $FLIP flipperinos to open the deposit channel.

destinationAddressstring required

The destination address the swap was accepted for, exactly as you sent it (no change of case, prefix or encoding). Always present.

Example response

{
  "id": 42,
  "address": "0x8127c88e8b5a92917486bc68a4b481befab12534",
  "issuedBlock": 1504251,
  "network": "Ethereum",
  "channelId": 107,
  "sourceExpiryBlock": 850819,
  "explorerUrl": "https://scan.chainflip.io/channels/1504251-Ethereum-107",
  "channelOpeningFeeNative": "0",
  "destinationAddress": "bc1qujr7jlxeh4m20lldqh4fcsl63ff2ee6uk60g8r"
}

Changes

No recorded changes to this operation across all 1 revision of this API.