Quote & Swap
Find the potential quote for user's input and target output
Every swap starts with a call to /quote, then the caller can decide whether they want to proceed. If the price/path looks good, the caller should proceed to call /swap with a selected path to build the calldata for the contract call.
Quote
Request Fields
amount_in
String
Amount with token's decimals
slippage_tolerance
Number
In basis points, 100% is 1000000(1M)
native_out
Boolean
Whether the user wants native token as output (only applicable if the dst_token is set to a native wrap)
only_swaps
Array<String>
Swap will be executed only at these dexes if there are specific swap array. Dexes supported are SushiSwap, UniswapV2/V3, Curve, Platypus, 1inch, more will be added
only_bridges
Array<String>
Bridge selection filter. 'cbridge', 'stargate', 'anyswap', 'hop', 'hyphen', 'across'.
nonce
Number
Nonce is used for uniquely tracking a swap on a per user per swap basis. Typically this is set to a unix timestamp
Token
symbol
String
Token symbol
chain_id
Number
Id of chain on which token is deployed
address
String
Token Address
decimals
Number
Token decimals
name
String
Token name
logo_uri
String
Token logo's URI
logo_uri and name are not required for token
Response Fields
err
Optional Error Message
src_token_usd_price
Number
Source token's usd price
dst_token_usd_price
Number
Destination token's usd price
swap_id
String
Path
amount_out
String
Estimated receiving amount. All non-native fees for destination chain swap will be deducted.
amount_out_raw
String
amount_out plus non-native fees
amount_out_min
String
The minium destination token value that the receiver will receive
return_amount
String
The return estimation for user's swap, which is denominated in destination token
bridge_fee
String
All fees that are charged through the token bridge. Native token fees charged up front in the source chain transaction will not be included. It is denominated in source token
tx_data
String
Abi encoded transaction data field.
tx_value
String
Abi encoded transaction value field. If the path involves sending message through cBridge, it will be set to a non-zero value to facilitate the message fee. If the bridge has native gas requirement, such as stargate, it will be also a positive value. Otherwise, the fee will be "0"
price_impact
Number
Calculation below
eta_seconds
Number
ETA of the path. It will include bridge time and message execution time if there is any
src_gas_fee
String
Gas token amount with decimals
src_gas_fee_usd
Number
Gas token value in USD, no decimals included
price_impact = (amount_in / amount_out) / (token_out_usd_price / token_in_usd_price) - 1
Step
StepType
STEP_UNKNOWN(0)
Unknown Step
STEP_DEX(1)
Step fulfilled by a DEX
STEP_BRIDGE(2)
Step fulfilled by a Bridge
Since the step type is enum, ChainHop will return a number to represent the type.
Swap
Last updated