Skip to content
API v2 · Deprecated

Quote a trade

Deprecated
GET
/v2/quote
curl --request GET \
--url 'https://api.hyperstream.dev/v2/quote?fromChainId=42161&from=0xaf88d065e77c8cC2239327C5EDb3A432268e5831&toChainId=8453&to=0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913&mode=exact_input&srcAmount=100000000' \
--header 'X-API-Key: <X-API-Key>'

Prices one direction and size without creating an order. Nothing is stored: build carries a signed attestation, valid for five minutes (60 seconds on a pair with 50 bps or more of slippage), that pins /v2/build to these numbers.

Send srcAmount, what the depositor spends. You get back receive.amount, what the depositor is expected to get, and receive.minAmount, the least.

A 200 means the size is fillable now. Too small is a 400 carrying detail.minSrcAmount; too large is a 409 carrying detail.maxSrcAmount. Re-quote at the returned figure.

fromChainId
required
integer

Source spoke chain id.

Example

42161
from
required
Any of:
string
/^0x[0-9a-fA-F]{64}$/

Source spoke-token address or Stellar bytes32 asset id. TRON accepts base58 or hex41.

Example

0xaf88d065e77c8cC2239327C5EDb3A432268e5831
toChainId
required
integer

Destination spoke chain id.

Example

8453
to
required
Any of:
string
/^0x[0-9a-fA-F]{64}$/

Destination spoke-token address or Stellar bytes32 asset id. TRON accepts base58 or hex41.

Example

0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
mode
string
default: exact_input
Allowed values: exact_input

Only exact_input: you fix srcAmount.

Example

exact_input
srcAmount
required
string
/^[1-9]\d*$/

What the depositor spends, in source base units. At most 2^128 - 1.

Example

100000000

Fillable now. Show spend and receive; send build to /v2/build.

Media typeapplication/json

A price for one direction and size. A 200 means the amount is fillable now. Nothing is stored.

object
spend
required

What the depositor sends, in source base units. Includes every fee.

object
chainId
required

Spoke chain id.

integer
token
required

Address in the chain’s native display form: EVM 0x hex, TRON base58.

string
symbol
required
string
decimals
required
integer
amount
required
string
/^\d+$/
receive
required

What the depositor is expected to receive if the order fills completely, and the most a fill pays, in destination base units. Truncated, never rounded up.

object
chainId
required

Spoke chain id.

integer
token
required

Address in the chain’s native display form: EVM 0x hex, TRON base58.

string
symbol
required
string
decimals
required
integer
amount
required
string
/^\d+$/
minAmount
required

The least a complete fill pays, enforced on-chain; a partial fill pays at least the same per unit. Equals amount when slippageBps is 0.

string
/^\d+$/
slippageBps
required

The order’s slippage tolerance, in bps.

integer
earlyCancelDisabled
required

When true, an order built from this quote cannot be cancelled before its deadline: it settles when it fills or the deadline passes. Always true when either token is on a non-EVM chain.

boolean
details
required
object
intentOutcomeRate
required

The solver’s rate, 1e18-scaled, less slippageBps: the floor the order enforces. Destination per source unit of the published amount (after fees), not of the deposit. Not a token amount.

string
/^\d+$/
protocolFee
required

The flat fee plus Khalani’s bps, in source base units. Your commission is not included.

string
/^\d+$/
build
required

The /v2/build request, already assembled. Send it back with depositor (and recipients where required) added.

object
srcToken
required
object
chainId
required

Spoke chain id.

integer
token
required

Address in the chain’s native display form: EVM 0x hex, TRON base58.

string
dstToken
required
object
chainId
required

Spoke chain id.

integer
token
required

Address in the chain’s native display form: EVM 0x hex, TRON base58.

string
amount
required

The deposit, in source base units.

string
/^\d+$/
intentOutcomeRate
required

The rate the order will publish at, 1e18-scaled.

string
/^\d+$/
terms
required

Attestation that pins /v2/build to this quote. Always send it back.

object
flatFee
required

Flat fee in 18-decimal hub units. Signed over, so echo it unchanged.

string
/^\d+$/
expiresAt
required

Unix seconds. The attestation is valid for five minutes, or 60 seconds on a pair with 50 bps or more of slippage.

string
/^\d+$/
slippageBps
required

The slippage the attestation covers, in bps. Echo it unchanged.

integer
signature
required

Khalani’s EIP-712 attestation over the quoted trade.

string
/^0x[0-9a-fA-F]*$/

Example

{
"spend": {
"chainId": 42161,
"token": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
"symbol": "USDC",
"decimals": 6,
"amount": "100000000"
},
"receive": {
"chainId": 8453,
"token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"symbol": "USDC",
"decimals": 6,
"amount": "99620254",
"minAmount": "99620254"
},
"slippageBps": 0,
"earlyCancelDisabled": false,
"details": {
"intentOutcomeRate": "999700000000000000",
"protocolFee": "329910"
},
"build": {
"srcToken": {
"chainId": 42161,
"token": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831"
},
"dstToken": {
"chainId": 8453,
"token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
},
"amount": "100000000",
"intentOutcomeRate": "999700000000000000",
"terms": {
"flatFee": "300000000000000000",
"expiresAt": "1787000000",
"slippageBps": 0,
"signature": "0x60ce0a47bc64e07a5437de5fd4e6008bce46756d4d7c971710283924888b2a137a91ed09461b5848bb2b7341f5c258da3f97853e73662275f047e0c3c20882211b"
}
}
}

Invalid query (ValidationError), an unsupported token, or a size below the minimum (Error with detail.minSrcAmount).

Media typeapplication/json
Any of:

The request failed schema validation. Carries message, not error.

object
message
required
string
Allowed value: Validation failed
name
required
string
Allowed value: ValidationException
details
required
Array<object>
object
field
required
string
message
required
string
code
required
string

Example

{
"error": "Requested amount is below what the solver will fill",
"detail": {
"minSrcAmount": "5000000"
}
}

The X-API-Key header is missing.

Media typeapplication/json

An error raised by the route itself.

object
error
required
string
detail
object
minSrcAmount

Smallest deposit that would quote, in source base units.

string
/^\d+$/
maxSrcAmount

Largest deposit that would quote, in source base units.

string
/^\d+$/
missing

The deployment setting this direction needs.

string

Example

{
"error": "X-API-Key required"
}

The key is unknown or past its rotation window, or your integrator registry row is disabled or invalid. A 403 is always about your account: do not retry.

Media typeapplication/json

An error raised by the route itself.

object
error
required
string
detail
object
minSrcAmount

Smallest deposit that would quote, in source base units.

string
/^\d+$/
maxSrcAmount

Largest deposit that would quote, in source base units.

string
/^\d+$/
missing

The deployment setting this direction needs.

string

Example

{
"error": "Unknown or inactive integrator"
}

Source and destination are the same asset.

Media typeapplication/json

An error raised by the route itself.

object
error
required
string
detail
object
minSrcAmount

Smallest deposit that would quote, in source base units.

string
/^\d+$/
maxSrcAmount

Largest deposit that would quote, in source base units.

string
/^\d+$/
missing

The deployment setting this direction needs.

string

Example

{
"error": "Source and destination resolve to the same mToken"
}

Larger than what can be filled now. Re-quote at detail.maxSrcAmount.

Media typeapplication/json

An error raised by the route itself.

object
error
required
string
detail
object
minSrcAmount

Smallest deposit that would quote, in source base units.

string
/^\d+$/
maxSrcAmount

Largest deposit that would quote, in source base units.

string
/^\d+$/
missing

The deployment setting this direction needs.

string

Example

{
"error": "Requested amount exceeds what the solver can fill",
"detail": {
"maxSrcAmount": "250000000000"
}
}

Rate limited per integrator and per IP. No Retry-After; back off and retry.

Media typeapplication/json

Rate limited. No Retry-After; back off and retry.

object
errorCode
required
string
Allowed value: RATE_LIMITED
message
required
string

Example

{
"errorCode": "RATE_LIMITED",
"message": "Too many requests, please retry later"
}

Unhandled failure. Retry once, then escalate with the x-request-id response header.

Media typeapplication/json

Maintenance, a malformed JSON body, or an unhandled failure. Carries message, not error.

object
message
required
string
name
required

MaintenanceException (503), BadRequestException (malformed JSON) or InternalErrorException (500).

string

Example

{
"message": "Internal Error",
"name": "InternalErrorException"
}

Temporarily unavailable: your terms could not be read, a price or fee configuration is missing, or no solver can serve the direction (Error), or the API is in maintenance (NamedError with Retry-After). The variants cannot be told apart reliably, so cap your retries.

Media typeapplication/json
Any of:

An error raised by the route itself.

object
error
required
string
detail
object
minSrcAmount

Smallest deposit that would quote, in source base units.

string
/^\d+$/
maxSrcAmount

Largest deposit that would quote, in source base units.

string
/^\d+$/
missing

The deployment setting this direction needs.

string

Example

{
"name": "MaintenanceException",
"message": "SystemMaintenance"
}
Retry-After
integer

Seconds to wait. Sent only by the maintenance response.