GET /calldata

Similar to `/firm-quote`. Just that response is raw calldata that can be submitted on-chain directly

bGET https://newapi.native.org/v1/firm-quote/calldata

Header and params are exactly the same as /firm-quote.

Headers

NameDescription

apiKey

API Key retrieved from the Native app.

Params

NameDescription

chain*

Blockchain name, you can refer to supported chain API.

token_in*

Token address for the token to be sold.

token_out*

Token address for the token to be bought.

amount

(optional) Amount of token to be sold, in ether unit.

amount_wei

(optional) amount of token to be sold, in wei unit.

from_address*

Address of the user that sells the token_in.

beneficiary_address

Address of the end user that initiated the swap request.

to_address

Address of the user that receives the token_out. If empty, this address will be the same as from_address.

expiry_time

(optional) 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

(optional) Number in percent. For example, passing the value 5 means 5%, 0.1 means 0.1% slippage tolerance. By default it's 0.

Example

https://newapi.native.org/v1/firm-quote/calldata?chain=ethereum&token_in=0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE&token_out=0xdAC17F958D2ee523a2206206994597C13D831ec7&amount=1&from_address=0x42d4e9ee3f725c84b7934e4fda64f2be0f803130&deadline_timestamp=1692085583

In this example, wallet 0x42d4e9ee3f725c84b7934e4fda64f2be0f803130 requests for transaction data for swapping 1 ETH to USDT on Ethereum.

Response

NameDescription

from

The address that will send the calldata to the Native router.

to

The address of the Native router.

calldata

The raw input data that will be executed by the NativeRouter.

value

The msg.value for the transaction. Will be 0 if the seller token is a non-native token.

amountOut

Amount of token to be sold, in wei unit.

amountInOffset (optional)

The offset position (in bytes) of the param amountIn. You can modify this value freely. Will be undefined if the target liquidity pool is not a native pool (non-PMM pool).

amountOutMinimumOffset (optional)

The offset position (in bytes) of the param amountOutMinimum. You can modify this value to protect yourself from slippage accordingly. Will be undefined if the target liquidity pool is not a native pool (non-PMM pool).

Example response:

{
    "from": "0x42d4e9ee3f725c84b7934e4fda64f2be0f803130",
    "to": "0xEAd050515E10fDB3540ccD6f8236C46790508A76",
    "calldata": "0xc7cd97480000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000012000000000000000000000000042d4e9ee3f725c84b7934e4fda64f2be0f8031300000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000006d0060b000000000000000000000000067297ee4eb097e072b4ab6f1620268061ae804640000000000000000000000002397d2fde31c5704b02ac1ec9b770f23d70d8ec4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000003200000000000000000000000000000000000000000000000000000000000000149000000000000000000000000000000000000000000000000000c94c046e2059d2008b6c3d07b061a84f790c035c2f6dc11a0be703d130bf4686b3d4b6eb91a8e26ac629c5bea608242d4e9ee3f725c84b7934e4fda64f2be0f803130dac17f958d2ee523a2206206994597c13d831ec7c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000006e1a3d770000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000653a214342d4e9ee3f725c84b7934e4fda64f2be0f8031309b7994d5ee304111ba952c1ceb20b03928017af9661bfc8653fbd7d27c26c7db5f43ccf2927ae147e41f9e18e9a0b0f81e766bc67dfbcca6e954c10d7e93ddd24f94c1ce8db4ee49d96c11c84a153f801b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041360a02816ec26c8cfb04d0f0ad10c480f184332c62d9e56c6180ab4d1992166e79d4a135dff39bc8f8159d14b5e3c57e6e4d030a27ca6590f05739c8c66cc2ef1b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    "value": "1000000000000000000", // Amount of native token, will be 0 for non-native tokens
    "amountOut": "2375239915",
    "amountInOffset": 100, // <OPTIONAL> Will be undefined if the target liquidity pool is not a native pool (non-PMM pool).
    "amountOutMinimumOffset": 132 // <OPTIONAL> Will be undefined if the target liquidity pool is not a native pool (non-PMM pool).
}
  • from, to, calldata: The calldata could be sent to the to address from the from address to execute the swap. from address should have enough allowance to NativeRouter (which is the to address)

  • amountInOffset: The offset position (in bytes) of the param amountIn. For example in the sample response above the amountIn (uint256) is taking the bytes in 100-131. Useful when the user wants to adjust the amount in in calldata.

  • amountOutMinimumOffset: The offset position (in bytes) of the param amountOutMinimum. For example in the sample response above the amountIn (uint256) is taking the bytes in 132-163. Useful when the user wants to adjust the amount out minimum (for slippage protection) in calldata.

If you only want to use native pools (PMM only pricing), you can reach out to the native team and we will configure this option for you.

You may try this endpoint out here.

Last updated