When to call
CallgetFlowQuote when executionState is source_attached, quoted, or signing. Calling it from quoted refreshes the quote. Calling it from signing returns the flow to quoted, so do not sign the previous transaction afterward.
Exchange sources have no quote. The payer pays through the exchange’s purchase link instead.
Usage
Parameters
Only
deposit mode accepts amount. Use at most 2 decimals for USD and at most the token’s decimals for SOURCE_TOKEN. When amount is omitted, the flow’s current amount in USD is quoted, so resend a SOURCE_TOKEN amount on every quote to keep it fixed in the token. When the source is a wallet, changing the amount screens the wallet again.
Returns
Promise<Flow>: the flow with executionState: 'quoted' and a new quote. For a deposit-address source, flow.depositAddress is the address the payer sends funds to.
Format
fromAmount and toAmount with formatTokenAmount from @dynamic-labs-sdk/client and the token’s decimals. For example, '1500000' with 6 decimals is 1.5.
A wallet quote is valid for 60 seconds, and expiresAt marks that time. A deposit-address quote guarantees the amount to send for 60 seconds too, but its expiresAt shows the flow’s expiry instead, so time a refresh from createdAt. The deposit address itself stays open until the flow ends. Expiry and cancellation explains both.
Examples
Refresh an expired wallet quote
Quote a payer-chosen deposit amount
Show a deposit address
Errors
Some rejections have no dedicated class, for example a flow with
disableSwaps whose source does not match a settlement, or a token that cannot be priced. Show error.message for those. Handle Flow errors describes each error and the quote failure reasons.
React
useGetFlowQuote is a mutation hook. It takes the same parameters, and it writes the returned flow into the useGetFlow cache.
Related
- Build a custom payment UI: review a wallet quote, show a deposit address, and enter a deposit amount.
attachFlowSource: attach the source to quote.submitFlowTransaction: send a quoted wallet payment.