Hooks
useGetSwapQuote
Hook for fetching executable swap quotes with transaction data
Import
Usage
Return Type: UseQueryResult<SwapQuote>
The hook returns all properties from React Query’s UseQueryResult
with swap quote data. Here’s the detailed structure:
Properties
data
SwapQuote | undefined
The swap quote object containing:
currencyAddress
: Address of the currency to be swappedcurrencyBalance
: Balance of the currency in the user’s walletprice
: The current price for the swapmaxPrice
: Maximum price allowed for the swap (includes slippage)to
: The target contract address for the swaptransactionData
: Encoded transaction data for executing the swaptransactionValue
: The value to be sent with the transactionapproveData
: Encoded approval transaction data (if includeApprove is true)
isLoading
boolean
Loading state for the data fetch.
isError
boolean
Error state indicating if the query failed.
error
Error | null
Any error that occurred during data fetching.
Parameters
The hook accepts two parameters:
args: UseGetSwapQuoteArgs
Parameter | Type | Description |
---|---|---|
userAddress | string | The address of the user’s wallet |
buyCurrencyAddress | string | The address of the currency to buy |
sellCurrencyAddress | string | The address of the currency to sell |
buyAmount | string | The amount of currency to buy (in base units) |
chainId | number | The chain ID where the swap will occur |
includeApprove | boolean | (Optional) Whether to include approval transaction data |
slippagePercentage | number | (Optional) Maximum allowed slippage percentage |
options: HooksOptions
Parameter | Type | Description |
---|---|---|
disabled | boolean | (Optional) Disable the query from automatically running |
retry | boolean | (Optional) Whether to retry failed queries |
Was this page helpful?