UNPKG

@lifi/composer-sdk

Version:

Public Composer SDK for building and submitting flows

56 lines (52 loc) 1.83 kB
import { RouteAmountAll, RouteAmountExact } from '@lifi/compose-spec'; /** * Spend an exact amount of the route's `fromToken`. * * @param amount - Amount in the token's smallest unit. `bigint` is serialised * to a decimal string when the request is sent. * @returns The `EXACT` member of the route amount union. * * @example * ```ts * const result = await sdk.route({ * chainId: 1, * fromToken: NATIVE_ETH, * toToken: WETH, * amount: routeAmount.exact(10n ** 17n), // 0.1 ETH, wrapped * signer: OWNER, * }); * ``` */ declare const exact: (amount: bigint | string) => RouteAmountExact; /** * Spend the signer's entire `fromToken` balance, resolved on-chain at execution * time. * * Not supported when `fromToken` is the chain's native sentinel — the server * rejects it. A gas coin is sent via `msg.value`, so there is no on-chain * balance to sweep; use {@link exact} for native inputs. * * @param simAmount - A realistic estimate of that balance, in the token's * smallest unit. The server quotes and simulates against this value, so it * shapes the returned quote and preconditions — but the amount actually moved * is whatever the balance turns out to be. * @returns The `ALL` member of the route amount union. * * @example * ```ts * const result = await sdk.route({ * chainId: 1, * fromToken: USDC, * toToken: A_ETH_USDC, * amount: routeAmount.all(1_000_000n), // estimate: ~1 USDC on hand * signer: OWNER, * }); * ``` */ declare const all: (simAmount: bigint | string) => RouteAmountAll; declare const routeAmountMod_all: typeof all; declare const routeAmountMod_exact: typeof exact; declare namespace routeAmountMod { export { routeAmountMod_all as all, routeAmountMod_exact as exact }; } export { all as a, exact as e, routeAmountMod as r };