Skip to content

Creating a swap

Endpoints

EndpointPurpose
GET /api/tokensEvery supported token and chain
GET /api/swap/configRuntime configuration, including the fee percent
GET /api/swap/pool-price/bsc-wknyx-usdtCurrent BSC pool spot price
GET /api/swapUsage help for swap creation
POST /api/swapCreate a swap

Create

bash
curl -X POST https://bridge.testnet.kriptonyx.com/api/swap \
  -H 'Content-Type: application/json' \
  -d '{
        "source_chain": "BSC",
        "source_token": "USDT",
        "target_chain": "KRIPTONYX",
        "target_token": "KNYX",
        "source_token_amount": 10,
        "target_wallet": "0xYourWallet"
      }'
FieldMeaning
source_chainChain you are sending from
source_tokenAsset you are sending
target_chainChain you want to receive on
target_tokenAsset you want to receive
source_token_amountAmount to send
target_walletWhere the output goes
refund_addressOptional. Where a failed swap returns funds

Chain and token names must match GET /api/tokens exactly.

The response

The response carries a deposit address unique to this swap, an expiry, and the swap ID you will use to track it.

Three things to get right

  1. Send to the deposit address, not to the bridge's main address.
  2. Send the exact asset on the exact chain the swap expects. A USDT-on-BSC swap will not detect USDT sent on Ethereum.
  3. Send before the window expires. After expiry the swap moves to swap_expired and the address is no longer monitored.

Set a refund address

If the swap fails after you have deposited, funds return to refund_address. On chains where the sending address cannot be inferred reliably, this is the only way the bridge knows where to send them. Set it.

After depositing

The blockchain monitor polls the deposit address every 20 seconds. Once the deposit is seen, the rate locks and the rest proceeds automatically.

Follow progress by tracking the swap.

A worked example

Swap20 KNYX → 1.95 KUSD
Routeinternal_multi_hop
Rate / fee0.10 — fee 0.05 (2.50%)
Deposit address0x26A59146915ED7E2CB97669Dbc04715593e02D92
Payout0xa8137e6ed03ed52f9bebc46c3e195092717e51aa96d8ac73787bd7cf9b614ea0
Block6,179,202
Elapsed82 seconds

Lifecycle: deposit_wallet_createdsource_token_depositedrate_lockedvault_lockingvault_lockedpayout_processingtarget_token_sent

KriptoNyx testnet — chain ID 3009 (kriptonyx_3009-1)