UNPKG

@ape.swap/v2-zap-sdk

Version:
89 lines (88 loc) • 2.67 kB
import { ZapType } from './constants'; import JSBI from 'jsbi'; import { Currency, CurrencyAmount, Percent, SupportedChainId, Token } from '@ape.swap/sdk-core'; import { Pair } from '@ape.swap/v2-sdk'; /** * Options for producing the arguments to send call to zap. */ export interface ZapOptions { /** * How much the execution price is allowed to move unfavorably from the trade execution price. */ allowedSlippage: Percent; /** * How long the zap is valid until it expires, in seconds. * This will be used to produce a `deadline` parameter which is computed from when the zap call parameters * are generated. */ ttl: number; /** * The account that should receive the output of the zap. */ recipient: string; zapType: ZapType; stakingContractAddress?: string; stakingPid?: string; maxPrice?: string; } export interface ZapOptionsDeadline extends Omit<ZapOptions, '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 ZapParameters { /** * The method to call on the Uniswap V2 Router. */ methodName: string; /** * The arguments to pass to the method, all hex encoded. */ args: (string | string[] | number[])[]; /** * The amount of wei to send in hex. */ value: string; } declare type CurrencyOut = { outputCurrency: Token; path: Token[]; outputAmount: CurrencyAmount<Currency>; minOutputAmount: string; }; declare type MergedZap = { currencyIn: { currency: Currency; inputAmount: string | JSBI; }; currencyOut1: CurrencyOut; currencyOut2: CurrencyOut; pairOut: { pair: Pair; minInAmount: { token1: string; token2: string; }; totalPairSupply: CurrencyAmount<Token>; liquidityMinted: CurrencyAmount<Token>; }; chainId: SupportedChainId; }; export declare abstract class ZapV1 { /** * 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 zap get zap values * @param options options for the call parameters */ static zapCallParameters(zap: MergedZap, options: ZapOptions | ZapOptionsDeadline): ZapParameters; } export {};