Get price for a swap
POST /api/v1/price
Use this API to quickly get the fee data for a cross-chain swap.
- application/json
Request Body required
- from string (chain:token) required
The initial chain and token type. See supported chains.
- to string (chain:token) required
The target chain and token type. See supported chains.
- amount string_of_number required
Amount of tokens to initialize the cross-chain swap.
- fromAddress address
The address on initial chain to initialize the cross-chain swap.
- fromContract boolean
The
fromAddress
parameter can refer to either an externally owned address (EOA) or a smart contract address. This API will check the token balance when the swap originates from an EOA, but this step will be bypassed if initiated from a smart contract. If you intend to send a swap from a smart contract that has not yet been deployed, you should set thefromContract
parameter totrue
.
- 200
- 400
Successful operation
- application/json
- Schema
- Example (from schema)
- Example
Schema
result object
Fee data of this swap
serviceFee string_of_numberFee charged by Meson protocol
lpFee string_of_numberFee charged by liquidity providers on Meson
totalFee string_of_numberTotal fee to be charged
converted optional
For some swap routes (i.e.
arb:usdc
->merlin:btc
) token conversion is allowed.amount string_of_numberAmount of converted token to receive
token stringConverted token
{
"result": {
"serviceFee": "string",
"lpFee": "string",
"totalFee": "string",
"converted": {
"amount": "string",
"token": "string"
}
}
}
{
"result": {
"serviceFee": "0",
"lpFee": "0.005",
"totalFee": "0.005"
}
}
Error
- application/json
- Schema
- Example (from schema)
Schema
error object
code int32message stringdata object
code string
{
"error": {
"code": -1,
"message": "[error_message]",
"data": {
"code": "[error_code]"
}
}
}