πΈQuotes & Swaps
This guide explains how to get exact swap quotes and find the best trading paths (multi-hop) using the Dozer Pool Manager.
Contract IDs
Mainnet:
000080350ca5ef204bc29b3232bb197e12bec6b473f5e6bdb749a6921197e83cTestnet:
00000eecf6a990576c12bfa9e12ee089a5b1ea65e6de1456687ba1f4dc7fd463
1. Best Swap Path (Quote)
Calculate the optimal swap path and expected output amount for a given input. This method checks direct pools and multi-hop paths to find the best price.
Method: find_best_swap_path(amount_in, token_in, token_out, max_hops)
Args:
amount_in(Integer): The input amount (remember to include decimals).token_in(Hex String): UID of the token being sold.token_out(Hex String): UID of the token being bought.max_hops(Integer): Maximum trading pairs to route through (e.g., 2 or 3).
Example Request
Get a quote for swapping 100 HTR (00) to hUSDC.
amount_in= 100 * 10^0 = 100 (HTR is 2 decimals? No, native HTR is handled as integer cents usually? Actually contract uses 8 decimals for pricing but reserves are native. Let's assume input is 100 units).Wait, HTR decimals on Hathor are 2, but the contract might use raw integer values. Always check token decimals.
Response Structure
Returns a SwapPathInfo object.
2. Simple Quote (No Fees)
Get a simple k = x * y quote for a single pair without considering fees or liquidity depths. Useful for quick estimations but not for actual execution.
Method: quote(amount_a, reserve_a, reserve_b)
Args: Inputs for the constant product formula.
Note: You must fetch reserves first using get_reserves to use this method effectively. We recommend using find_best_swap_path instead for accuracy.
Last updated