POST
/
api
/
swap
/
native
curl --request POST \
  --url https://public-retro-staging-be.codemelt.codes/api/swap/native \
  --header 'Content-Type: application/json' \
  --data '{
  "tokenAId": 123,
  "tokenBId": 123,
  "slippage": 50,
  "amount": 123,
  "sender": "<string>",
  "recipient": "<string>",
  "skipNonSwapTransactions": false
}'
{
  "message": "<string>",
  "data": {
    "path": [
      "<string>"
    ],
    "transactions": [
      {
        "type": "<any>",
        "data": "<string>",
        "order": 123,
        "value": 123,
        "gasAmount": 123,
        "gasUsd": 123,
        "to": "<string>",
        "chainType": "<any>",
        "rpcUrl": "<string>"
      }
    ],
    "dexToUse": "<string>",
    "minAmountOut": 123
  },
  "status": "<any>"
}

Overview

This endpoint provides native swap functionality for token exchanges. It allows for cross-chain swaps and uses the native DEX of the platform.

Using the sdk

import api, { IConnection } from "codemelt-retro-api-sdk"
const connection: IConnection = {
  host: '<enter you host url here>',
  headers: {
    'x-api-key': '<enter your api key here>'
  }
}
const result = await api.functional.api.swap.native.getSwapData(
  connection,
  {
    tokenAId: 1,
    tokenBId: 2,
    slippage: 50,
    amount: 1.5,
    //can also be BTC address or solana address
    sender: '0x0000000000000000000000000000000000000000', 
    recipient: '0x0000000000000000000000000000000000000000',
    //if true, the sdk will skip non-swap transactions and only return swap transactions
    //this will greatly reduce the request time since some rpc calls are no logner executed
    //default is not required: this will also add approvals, etc.
    skipNonSwapTransactions: true //or false
  }
)

Body

application/json

Response

201 - application/json

The response is of type object.