GET /firm-quote
Get signed order data for selling a ERC20 / native token. Submit the return data to Native router to execute swap.
This endpoint provides transaction data given the requested token and token amount. Please refer to execute swap section for examples of using the endpoint.
Native supports native token swap by using 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
to represent the token address of the native token.
Headers
Name | Description |
---|---|
apiKey | API Key retrieved from the Native app. |
Params
Name | Description |
---|---|
src_chain* | The blockchain name belonging to the token_in address. You can refer to supported chain API. |
dst_chain* | The blockchain name belonging to the token_out address. You can refer to supported chain API. |
token_in* | Address of the token to be sold. |
token_out* | Address of the token to be bought. |
amount | Amount of token to be sold, in ether unit. |
amount_wei | Amount of token to be sold, in wei unit. |
from_address* | Address of the user that sells the |
beneficiary_address | Address of the end user that initiated the swap request. |
to_address | Address of the user that receives the |
expiry_time | Expiry time in seconds. This variable will be passed on to the market makers to consider when they give the quote. Market makers would be able to give better quote for a shorter expiry time. It will affect the deadlineTimestamp in the response if the quote from that market maker is chosen. If not provided we will just use the default expiry time by the liquidity source. |
slippage | Number in percent. For example, passing the value 5 means 5%, 0.1 means 0.1% slippage tolerance. By default it's 0. |
Example
In this example, wallet 0x42d4e9ee3f725c84b7934e4fda64f2be0f803130 requests for transaction data for swapping 1 ETH to USDT on Ethereum.
Response
Name | Description |
---|---|
success | Indicates if the signing of the firm quote was successful. |
orders | |
widgetFee | Contains the widgetFee details. |
widgetFeeSignature | The signature of the transaction request and the widget fee. |
recipient | The address of the seller/swapper. |
calldata | The byte encoding for the |
amountIn | The amount of sellerToken in wei, that will be sold to the buyer. |
amountOut | The amount of buyerToken in wei, that the buyer will be receiving. |
toWrap | Indicates if the order needs to be wrapped. |
toUnwrap | Indicates if the order needs to be unwrapped. |
fallbackSwapDataArray | This is the raw input data that will be executed by Native fallback. |
source | Indicates the liquidity provider that is providing this firm-quote. |
txRequest | The transaction request to be executed by the NativeRouter. The |
Example response:
In the response above, Native returns 1,864.151208 USDT for the order sent in the example.
Note that to send the transaction on chain, you can utilize the txRequest
response. This response will be exactly the same as GET /calldata API endpoint.
You may try this endpoint out here.
Last updated