Get a Quote
The /quote
endpoint lets you generate a quote & retrieve the best route for a swap.
https://api.hypersonic.exchange/v1/quote
Request type: POST
Body Parameters
chainId
: number - Chain id to use for quote generation. *requiredinToken
: string - Address of the input token. *requiredoutToken
: string - Address of the output token. *requiredinAmount
: string - Amount of the input token.(wei)
*requiredslippage
: number - Slippage percent.(1 = 1%)
*requiredrefCode
: number - Referral code. Learn more. *optional
Example Body
{
"chainId": 10,
"inToken": "0x4200000000000000000000000000000000000006",
"outToken": "0x4200000000000000000000000000000000000042",
"inAmount": "1000000000000000000",
"slippage": 1,
}
Responses
200
Successful request.400
Unsupported chain.404
Unsupported tokens.406
Slippage error.5xx
Service unavailable.
{
"success": true,
"data": {
"chainId": 10,
"inToken": "0x4200000000000000000000000000000000000006",
"inDecimals": 18,
"inAmount": "1000000000000000000",
"outToken": "0x4200000000000000000000000000000000000042",
"outDecimals": 18,
"outAmount": "1603772673769497210334",
"slippage": 1,
"minReceived': "1587734947031802238231",
"bestRoute": [
{"percent": 14, "swaps": [[Array], [Array]]},
{"percent": 32, "swaps": [[Array], [Array]]},
{"percent": 54, "swaps": [[Array], [Array]]},
],
"contractAddress": "0xf9d5DCFB8490F67F1f7CFd148846D666d4ff6F25",
"contractMethod": "hyperswap",
"blockNumber": 100000000,
},
"timestamp": "2000-01-01T00:00:00.000Z",
}
Response Fields
success
: Boolean indicating the request was successful.chainId
: Number of the chain id.inToken
: Address of the input token.inDecimals
: Decimals of the input token.inAmount
: Amount of the input token.outToken
: Address of the output token.outDecimals
: Decimals of the input token.outAmount
: Amount of the output token.slippage
: Percentage of slippage accepted.minReceived
: Minimum amount of the output token.bestRoute
: An array of objects containing the swaps to execute.contractAddress
: An execution helper contract of Hypersonic that should be used.contractMethod
: A method that should be triggered on Hypersonic router contract.blockNumber
: Current block number on the chain.timestamp
: UTC timestamp of the generated quote.
Try it yourself
To ping the API using curl, you can use the following command:
curl -X POST https://api.hypersonic.exchange/v1/quote \
-H "Content-Type: application/json" \
-d '{
"chainId": 10,
"inToken": "0x4200000000000000000000000000000000000006",
"outToken": "0x4200000000000000000000000000000000000042",
"inAmount": "1000000000000000000",
"slippage": 1
}'
This will send a POST
request to the infos endpoint and return the response.