Skip to main content
POST
/
api
/
{blockchain}
/
swap
TypeScript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    dstAddress: '<string>',
    path: {
      steps: [
        [
          {
            exchanger: {address: '<string>', fee: 1, name: '<string>'},
            percentBps: 1,
            tokenIn: '<string>',
            tokenOut: '<string>'
          }
        ]
      ],
      totalAmountOut: '<string>',
      totalPriceImpact: 1,
      addressTokenIn: '<string>',
      addressTokenOut: '<string>',
      amountIn: '<string>'
    }
  })
};

fetch('https://swap.ggp.gg/api/{blockchain}/swap', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
curl --request POST \
--url https://swap.ggp.gg/api/{blockchain}/swap \
--header 'Content-Type: application/json' \
--data '
{
"dstAddress": "<string>",
"path": {
"steps": [
[
{
"exchanger": {
"address": "<string>",
"fee": 1,
"name": "<string>"
},
"percentBps": 1,
"tokenIn": "<string>",
"tokenOut": "<string>"
}
]
],
"totalAmountOut": "<string>",
"totalPriceImpact": 1,
"addressTokenIn": "<string>",
"addressTokenOut": "<string>",
"amountIn": "<string>"
}
}
'
import requests

url = "https://swap.ggp.gg/api/{blockchain}/swap"

payload = {
"dstAddress": "<string>",
"path": {
"steps": [[
{
"exchanger": {
"address": "<string>",
"fee": 1,
"name": "<string>"
},
"percentBps": 1,
"tokenIn": "<string>",
"tokenOut": "<string>"
}
]],
"totalAmountOut": "<string>",
"totalPriceImpact": 1,
"addressTokenIn": "<string>",
"addressTokenOut": "<string>",
"amountIn": "<string>"
}
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
{
  "data": "<string>",
  "minReturnAmountOut": "<string>",
  "to": "<string>",
  "value": "<string>",
  "computeUnits": 1,
  "tokenApprovalAddress": "<string>"
}
{
"code": 400,
"error": "string"
}
{
"code": 404,
"error": "string"
}
{
"code": 408,
"error": "string"
}
{
"code": 500,
"error": "string"
}

Path Parameters

blockchain
enum<string>
required
Available options:
ethereum,
bsc,
arbitrum

Body

application/json

Params for building swap calldata

dstAddress
string
required

Destination/taker wallet or contract

path
object
required

Quote path

apiKey
string | null
deadline
integer<int64> | null

Deadline in seconds, default 3600 seconds (1 hour)

Required range: x >= 0
fromAddress
string | null

Source wallet or contract

permit
null | object

Permit2 data with EIP-2612 signature, if exist

skipSimulation
boolean | null

Whether to skip simulation

slippageBps
integer<int32> | null

Custom slippage in bps, default using totalPriceImpact from the quote

Required range: x >= 0
usePermit
boolean | null

Whether to use permit

Response

Built swap calldata for 8dx aggregation smart contract

data
string
required

Calldata to send to the aggregator contract

minReturnAmountOut
string
required
to
string
required

Aggregator contract address - recipient of the transaction (transaction to)

value
string
required

Native value (msg.value) attached to the transaction, in wei

computeUnits
integer<int64> | null
Required range: x >= 0
tokenApprovalAddress
string | null

Address that the user must approve for ERC20 spending (null for native-token swaps; equals to for non-permit ERC20 swaps; equals Permit2 address when use_permit = true)