POST
/
createSwap

Request Body:

{
  "Pair": {
    "tokenA": "<offer_token_address>",
    "tokenB": "<ask_token_address>"
  },
  "amount": {
    "tokenA": <offer_token_amount>
  }
}

Parameter Explanation:

  • Pair.tokenA: The address of the token being offered
  • Pair.tokenB: The address of the token being requested
  • amount.tokenA: The price of the token being offered

Example Request:

POST /createSwap

Request Body:

{
  "Pair": {
    "tokenA": "0x1234567890",
    "tokenB": "0x0987654321"
  },
  "amount": {
    "tokenA": 0.5
  }
}

This request will create a swap, where the user offers a token with address 0x1234567890 and requests a token with address 0x0987654321 at a price of 0.5.

Successful Response:

{
  "success": true,
  "data": {
    "transactionId": "tx_1234567890",
    "status": "completed"
  }
}

Response Field Explanation:

  • success: Whether the request was successful
  • data.transactionId: The transaction ID of the swap
  • data.status: The status of the swap

Error Response:

{
  "error": "An unknown error occurred"
}

By calling this API endpoint and providing the necessary parameters, you can create a new token swap on the ONTON Finance platform. Once the swap is created, the system will automatically match the trade and execute the token swap. You can use the returned transaction ID to track the status of the swap.

Note that when creating a swap, you must provide accurate token addresses and a reasonable price. If the provided parameters are invalid or the swap cannot be completed, the API will return an error response.

Body

application/json
Pair
object
price
object

Response

200 - application/json
success
boolean
data
object