--- title: Get a quote description: Requesting a price, what comes back, and the optional fields that change it. --- `GetQuote` prices a trade and persists it. The `quote_hash` it returns is what the deposit carries, so call it once the user is ready to act. For prices that update as the user types, use `PreviewQuote`, which is identical minus the persistence and the addresses. ## Request | Field | Required | Notes | | --- | --- | --- | | `src_chain`, `dst_chain` | yes | Lowercase chain names. Equal values produce a same-chain swap quote. | | `src_token`, `dst_token` | yes | Token addresses from the catalog. | | `trade_type` | yes | Which side `amount` fixes and whether the output is guaranteed. See [Trade types](/concepts/trade-types). | | `amount` | yes | Decimal string in base units: source token's for exact input, destination token's for expected output. | | `recipient` | yes | Destination address. Must match the destination chain's address format. | | `refund_address` | yes | Source-chain address a refund is paid to. | | `gas_drop` | yes | Native asset to deliver on the destination, in base units. Empty string for none. | | `slippage_bps` | no | Floor for the destination swap leg. Omit to let the operator pick a tier. | | `src_slippage_bps` | no | Floor for the source swap leg. | | `referrers` | no | Referrer addresses and their basis points. | | `gasless` | no | Price the quote for a relayed, signature-only deposit. See [Sponsoring gas](/integration/gas-sponsorship). | | `sponsor_fees` | no | With `gasless`, charge the relay gas to your partner funding balance. Requires an API key. See [Sponsoring gas](/integration/gas-sponsorship). | ```ts import { TradeType, quoteOf, isSameChainSwap } from "@mayanfinance/hular-sdk"; const response = await hular.getQuote({ srcChain: "arbitrum", dstChain: "solana", srcToken: src.address, dstToken: dst.address, tradeType: TradeType.EXACT_INPUT, amount: "25000000", recipient: userAddress, refundAddress: userAddress, gasDrop: "2000000", referrers: [{ address: myFeeAddress, bps: 10 }], }); const quote = quoteOf(response); if (!quote) throw new Error("no quote"); ``` ```bash grpcurl \ -H "x-api-key: $HULAR_API_KEY" \ -d '{ "src_chain": "arbitrum", "dst_chain": "solana", "src_token": "0x...", "dst_token": "EPjF...", "trade_type": "TRADE_TYPE_EXACT_INPUT", "amount": "25000000", "recipient": "EPjF...", "refund_address": "0x...", "gas_drop": "2000000", "referrers": [{ "address": "0x...", "bps": 10 }] }' \ $HULAR_HOST hular.v1.HularApi/GetQuote ``` ## Response `QuoteResponse` is a `oneof`: `cross_chain` or `same_chain_swap`. Both carry the fields below (`cross_chain` adds the gasless fields, see [GetQuote](/api-reference/get-quote#response)), so read the case and branch on execution, not on shape. | Field | Use | | --- | --- | | `quote_hash` | Bind the deposit to it. Store it before signing. | | `amount_in` | The deposit amount. Echoes the request for exact input; the solved input for expected output. | | `amount_out` | Expected output, already net of every fee. | | `min_amount_out` | Guaranteed floor. Show it alongside the expected output. | | `slippage_bps` | The tier actually applied, which may differ from what you sent. | | `fee_breakdown` | Itemized costs. See [Fees](/concepts/fees). | | `router_address` | The contract to deposit into. Use this, not a hardcoded address. | | `order_params` | The full bound parameter set, needed to build the deposit. | | `deposit_deadline` | Deposit-by timestamp, 30 minutes after issuance. Re-quote past it; the SDK's `isQuoteExpired(quote)` checks it, and the chain adapters refuse to build deposit steps for an expired quote when `depositDeadline` is passed in the options. | | `amount_in_usd_micros`, `amount_out_usd_micros` | Notional values for display. Optional; absent when a price is unavailable. | ## Preview while typing `PreviewQuote` takes the same economic inputs and omits `recipient` and `refund_address`. It returns `amount_out`, `min_amount_out`, `slippage_bps`, `fee_breakdown`, and a `same_chain_swap` flag, without writing anything. ```ts const preview = await hular.previewQuote({ srcChain: "arbitrum", dstChain: "solana", srcToken: src.address, dstToken: dst.address, tradeType: TradeType.EXACT_INPUT, amount: "25000000", gasDrop: "", }); ``` Debounce it against the amount field, then call `GetQuote` when the user commits. ## Quoting from the output side When the user edits the buy field instead of the sell field, quote with `TRADE_TYPE_EXPECTED_OUTPUT` and pass the desired payout as `amount`, in the destination token's base units. The response's `amount_in` is the deposit that achieves it; render it in the sell field and build the deposit from `order_params` as usual. See [Trade types](/concepts/trade-types) for how it is priced and the 150 bps slippage default. ## Refresh before signing A quote's price is fixed when it is issued and does not track the market. Re-quote if the user has been sitting on a confirmation screen: refreshing costs one request, while a stale quote either prices badly or, if the market moved past a floor, fails to fill and refunds. A common pattern is to re-quote on an interval while a confirmation screen is open, and to block the deposit button during the refresh so the hash being signed is always the one displayed. ## Source swaps When `src_token` differs from `bridge_token_src` in the returned params, the deposit has to route through an aggregator on the source chain. That routing is not in the quote; fetch it with `GetSwapInstructions` at deposit time so it is fresh. See [Deposit on EVM](/integration/deposit-evm). ## Failures Quote failures split cleanly. `INVALID_ARGUMENT` means the request itself is wrong (unsupported pair, size outside the accepted band, gas drop over the cap) and retrying it unchanged will fail again. `UNAVAILABLE` means the operator cannot price right now (insufficient inventory, a stale price feed, an aggregator that did not respond) and the same request may succeed shortly after. See [Error handling](/integration/errors).