swap.v1.SwapService
QuoteSwap
QuoteSwap prices terms against current order-book depth and the account's taker fee. Nothing is reserved. Errors: - INVALID_ARGUMENT: malformed request, AMOUNT_OUT_OF_RANGE or INVALID_SUBACCOUNT_ID. - FAILED_PRECONDITION: ROUTE_UNSUPPORTED, DIRECTION_UNSUPPORTED, PROTECTION_UNACHIEVABLE or SUBACCOUNT_INACTIVE. - NOT_FOUND: SUBACCOUNT_NOT_FOUND. - PERMISSION_DENIED: SWAP_NOT_PERMITTED. - UNAVAILABLE: QUOTE_UNAVAILABLE or SERVICE_UNAVAILABLE; retry later. - UNAUTHENTICATED: missing or invalid credentials.
Request
curl --request POST \ \
--url 'https://api.testnet.polyester.com/swap.v1.SwapService/QuoteSwap' \
--header 'Content-Type: application/json' \
--header 'Connect-Protocol-Version: 1' \
--data '{
"maxSlippageBps": 1,
"terms": {
"amountE18": {
"hi": "1",
"lo": "1"
},
"destinationAssetId": 100,
"sourceAssetId": 100,
"subaccountId": "6789012345678"
}
}'Responses
{
"quote": {
"expectedAmountOutE18": {
"hi": "1",
"lo": "1"
},
"expiresAt": "2025-01-01T00:00:00Z",
"legs": [
{
"averagePrice": "61000.25",
"feeAssetId": 100,
"feeE18": {
"hi": "1",
"lo": "1"
},
"priceImpactBps": 1,
"side": "BUY",
"symbolId": 1,
"takerFeeRatePercent": "0.03"
}
],
"minAmountOutE18": {
"hi": "1",
"lo": "1"
},
"quotedAt": "2025-01-01T00:00:00Z",
"terms": {
"amountE18": {
"hi": "1",
"lo": "1"
},
"destinationAssetId": 100,
"sourceAssetId": 100,
"subaccountId": "6789012345678"
}
}
}swap.v1.QuoteSwapRequestswap.v1.QuoteSwapResponseOptional sub-account public ID whose Trading balance funds the Swap. When omitted, the caller's root account funds it, or the sub-account an API key is bound to.
Asset spent: a unified asset ID, as used for balances and internal transfers.
Asset received: a unified asset ID.
Most significant 64 bits.
Least significant 64 bits.
Accepted shortfall from the expected output, in basis points (1 bp = 0.01%), from 1 to 1000; sets the quote's min_amount_out.
Optional sub-account public ID whose Trading balance funds the Swap. When omitted, the caller's root account funds it, or the sub-account an API key is bound to.
Asset spent: a unified asset ID, as used for balances and internal transfers.
Asset received: a unified asset ID.
Most significant 64 bits.
Least significant 64 bits.
Stable numeric pair ID from GetSpotConfig.
Side of the order on the market.
Estimated average fill price, quote asset per base asset, as a decimal string; for display.
Distance of average_price from the best price of the book, in basis points, rounded up: the cost of the order's size against current depth.
The account's spot taker fee rate on the market, in percent (for example "0.1" for 0.1%), as a decimal string.
Most significant 64 bits.
Least significant 64 bits.
Asset the fee is charged in: the asset the leg receives.
Most significant 64 bits.
Least significant 64 bits.
Most significant 64 bits.
Least significant 64 bits.
When the quote was priced.
Last moment the quote may be accepted, 30 seconds after quoted_at. Pass it as quote_expires_at when creating the Swap.
| Key | HTTP status | Connect code | Error | When |
|---|---|---|---|---|
| unauthenticated | 401 | unauthenticated | Unauthenticated | Authentication required. |
| permission-denied | 403 | permission_denied | Permission Denied | Permission denied. |
| invalid-argument | 400 | invalid_argument | Invalid Argument | Invalid argument. |
| not-found | 404 | not_found | Not Found | Not found. |
| unavailable | 503 | unavailable | Unavailable | Service unavailable. |