Skip to Content
Synthetic USD

Create swap

POST/synthetic-usd/swapPrivate

Swap inAmount between your BTC and synthetic USD balances. BTC to USD swaps fill at the best bid, USD to BTC swaps at the best ask (see GET /synthetic-usd/best-price). Returns the swap with the amount received.

Permissions: synthetic-usd:write

Request Body

application/json
  1. body
inAsset*string

Asset to swap from

Value in"BTC""USD"
outAsset*string

Asset to swap to

Value in"BTC""USD"
inAmount*number

Amount to swap (in satoshis if BTC, in dollars if USD)

Response Body

OK

application/json
  1. response
id*string

Swap ID

Match^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
Formatuuid
inAmount*number

Amount to swap (in satoshis if BTC, in dollars with 2 decimal places if USD)

Range0 < value
inAsset*string

Asset to swap from

Value in"BTC""USD"
outAmount*number

Amount received after conversion (in satoshis if BTC, in dollars with 2 decimal places if USD)

Range0 < value
outAsset*string

Asset to swap to

Value in"BTC""USD"
import { createHttpClient } from '@ln-markets/sdk/rest/v3'

const client = createHttpClient({
  key: 'your-key',
  secret: 'your-secret',
  passphrase: 'your-passphrase',
})

const result = await client.syntheticUsd.newSwap({
  inAsset: 'BTC',
  outAsset: 'USD',
  inAmount: 1337
})
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "inAmount": 1337,
  "inAsset": "BTC",
  "outAmount": 0.5969,
  "outAsset": "USD"
}