import BigNumber from "bignumber.js"; import { TransactionConfig } from "web3-eth"; import { Token } from "../Tokens"; import { Address, BigNumberString, ChainId } from "../constants"; import { Wallet } from "../wallet"; export declare type NodeRoute = { path: string[]; pairs: string[]; extras: (string | number[])[]; inputAmount: string | number; expectedOutputAmount: string | number; deadline: string | number; partner: string | number; sig: string | number[]; }; export declare type RouterResponse = { expectedOut: BigNumberString; routerAddress: Address; details: NodeRoute; txn: TransactionConfig | { error: string; }; minimumExpectedOut: BigNumberString; priceImpact: { numerator: number; denominator: number; }; }; export declare type RouterPayloadRequest = { tokenIn: Address; tokenOut: Address; amountIn: BigNumberString; deadlineMs?: number; chainId?: ChainId; to?: Address; from?: Address; slippage?: number; maxHops?: number; includeTxn?: boolean; priceImpact?: boolean; }; export declare function convertNodeRouteToContractPayload(route: NodeRoute, slippage: number, to: Address): [ string[], string[], (string | number[])[], string | number, string | number, string | number, string, string | number, string | number, string | number[] ]; /** * @class SmartRouter * Utility Class to Wrap Minima Functionality and facilitate swaps * * @example * * ```ts * const router = new SmartRouter('abc-123-987-beef') * const {details, txn} = await router.getRouteBase(CELO, CUSD, '10000', { includeTxn: true, maxHops: 3 }) * const await provider.signTransaction(txn); * ``` */ export declare class SmartRouter { private apiKey?; private wallet?; constructor(apiKey?: string | undefined, wallet?: Wallet | undefined); /** * Pings the minima service to find the most efficient trade to go from input to output. * * @param input Token to be traded in. Provide either the address or the Token object * @param output Token to be traded for. Provide either the address or the Token object * @param amountIn Total input amount for the trade, can be BigNumber or Stringified BigNumber * @param options Additional options * @returns Trade information, including a pre-formatted txn to sign and send to execute a trade */ getRouteBase(input: Token | string, output: Token | string, amountIn: BigNumber | BigNumberString, options?: Partial): Promise<{ details?: NodeRoute; routerAddress?: Address; expectedOut?: BigNumber; error?: string; txn?: TransactionConfig | { error: string; }; priceImpact?: number; }>; /** * * Formats the route as a transaction to sign and execute. * * @param route Route returned from `getRouteBase` * @param to Recipient address of trade * @param slippage Allowed slippage for the trade, in bips * @param routerAddress Address of router that will execute the trade * @returns TransactionConfig corresponding to the given route * * @example * * ```ts * const { details, routerAddress } = await router.getRouteBase(CELO, CUSD, '10000') * const transactionConfig = router.formatTransaction(details, wallet.address, 10, routerAddress) * ``` */ static formatTransaction(route: NodeRoute, to: Address, slippage: number, routerAddress: Address): { to: string; data: string; gas: string; }; /** * * If a Wallet object is attached, will execute the given swal * * @param route * @param to * @param slippage * @param routerAddress * @returns transaction receipt */ performSwap(route: NodeRoute, to: Address, slippage: number, routerAddress: Address): Promise; }