UNPKG

@polycity/sdk

Version:

🛠 An SDK for building applications on top of PolyCityDex Protocol.

69 lines (68 loc) • 2.38 kB
import { Currency } from './entities/Currency'; import { CurrencyAmount } from './entities/CurrencyAmount'; import { Percent } from './entities/Percent'; import { Trade } from './entities/Trade'; import { TradeType } from './enums/TradeType'; /** * Options for producing the arguments to send call to the router. */ export interface TradeOptions { /** * How much the execution price is allowed to move unfavorably from the trade execution price. */ allowedSlippage: Percent; /** * How long the swap is valid until it expires, in seconds. * This will be used to produce a `deadline` parameter which is computed from when the swap call parameters * are generated. */ ttl: number; /** * The account that should receive the output of the swap. */ recipient: string; /** * Whether any of the tokens in the path are fee on transfer tokens, which should be handled with special methods */ feeOnTransfer?: boolean; } export interface TradeOptionsDeadline extends Omit<TradeOptions, 'ttl'> { /** * When the transaction expires. * This is an atlernate to specifying the ttl, for when you do not want to use local time. */ deadline: number; } /** * The parameters to use in the call to the Uniswap V2 Router to execute a trade. */ export interface SwapParameters { /** * The method to call on the Uniswap V2 Router. */ methodName: string; /** * The arguments to pass to the method, all hex encoded. */ args: (string | string[])[]; /** * The amount of wei to send in hex. */ value: string; } export declare function toHex(currencyAmount: CurrencyAmount<Currency>): string; /** * Represents the Uniswap V2 Router, and has static methods for helping execute trades. */ export declare abstract class Router { /** * Cannot be constructed. */ private constructor(); /** * Produces the on-chain method name to call and the hex encoded parameters to pass as arguments for a given trade. * @param trade to produce call parameters for * @param options options for the call parameters */ static swapCallParameters(trade: Trade<Currency, Currency, TradeType>, options: TradeOptions | TradeOptionsDeadline): SwapParameters; }