/** @module core/services/swap-quotes */ import type { IAddress } from '../../types'; /** Quote-provider discriminant. Will widen as new providers are added. */ export type ISwapQuoteProvider = 'paraswap'; /** * Input to {@link fetchSwapQuote}. */ export interface ISwapQuoteRequest { /** EVM chain ID where the swap will execute. */ chainId: number; /** ERC-20 the user holds. */ srcToken: IAddress; /** `srcToken.decimals()`. */ srcDecimals: number; /** ERC-20 the SwapRouter should produce — typically the vault's `referenceAsset`. */ destToken: IAddress; /** `destToken.decimals()`. */ destDecimals: number; /** Input amount in `srcToken`'s smallest unit. */ amount: bigint; /** * Address that will execute the resulting calldata. For SwapRouter use, * pass the SwapRouter's address — the aggregator's calldata is bound to * this address, so it must hold the tokens at swap time. */ receiver: IAddress; /** * Slippage tolerance in bps (1 bp = 0.01%). Defaults to 100 (1%). Must be * in `[0, 10_000)` — 10_000 disables protection entirely and is rejected. */ slippageBps?: number; /** * Optional aggregator contract-method filter. When set, the aggregator is * constrained to this single method (ParaSwap's `/prices` * `includeContractMethods`), so the returned calldata's leading 4-byte * selector is deterministic — required when the on-chain SwapRouter only * authorizes one selector per router. When omitted, the aggregator picks the * optimal method freely and the selector may vary between quotes. */ contractMethod?: string; /** Aggregator partner key. Defaults to `'august'`. */ partner?: string; /** Aggregator partner-fee receiver. Defaults to the August partner address. */ partnerAddress?: IAddress; /** * `fetch`-compatible function override. Defaults to `globalThis.fetch`. * Exposed so callers in Node environments lacking a global `fetch` can * inject one, and so tests can mock without touching the global. */ fetchImpl?: typeof fetch; /** Optional AbortSignal to cancel the in-flight Paraswap requests. */ signal?: AbortSignal; } /** * Output of {@link fetchSwapQuote}. The `router` + `payload` pair maps * directly into one entry of an `ISwapParams[]` passed to * `SwapRouter.swapAndDeposit`. * * Modeled as a discriminated union on `provider` so adding 1inch/0x is an * additive change rather than a breaking widening. */ export type ISwapQuoteResult = { /** Quote provider that produced this calldata. */ provider: 'paraswap'; /** DEX router that will execute the swap (the contract `payload` is calldata for). */ router: IAddress; /** ABI-encoded calldata for `router`. */ payload: `0x${string}`; /** Expected output in `destToken` units before slippage. */ expectedAmountOut: bigint; /** Slippage-adjusted minimum output. Below this the on-chain call reverts. */ minAmountOut: bigint; /** * Epoch ms when the quote was fetched. Callers that prefetch a quote * before submitting should re-fetch when this is older than ~60s — DEX * pool state moves and a stale `minAmountOut` may have been computed * against a price that no longer holds. */ fetchedAt: number; }; /** * Fetch a swap quote and the calldata required for the on-chain SwapRouter * to execute it. * * @throws {@link AugustValidationError} on invalid input (slippage out of * range, zero amount, src===dst). * @throws {@link AugustNetworkError} on transport failure. * @throws {@link AugustServerError} on aggregator-side errors. * * @example * ```ts * const quote = await fetchSwapQuote({ * chainId: 1, * srcToken: WBTC, * srcDecimals: 8, * destToken: USDC, * destDecimals: 6, * amount: 100_000_000n, * receiver: SWAP_ROUTER_ADDRESSES[1]!, * }); * // quote.router -> Paraswap augustor * // quote.payload -> calldata * ``` */ export declare function fetchSwapQuote(request: ISwapQuoteRequest): Promise;