UNPKG

eulith-web3js

Version:

Official Eulith Typescript client library

75 lines (74 loc) 2.73 kB
import { RequestArguments } from "web3-core"; import * as Eulith from "./index"; interface IFlashLoanableX { generateLoanRequest(): RequestArguments; get tokenValues(): Eulith.Tokens.Value.ITokenValue[]; } /** * Defines parameters to start a flash loan/swap transaction * Eulith's APIs are generic to exactly what type of flash transaction you'd like to do * If you take and pay different tokens, it's a swap; if you take and pay the same tokens, it's a loan * * Swaps are routed through Uniswap; loans may either be routed through Aave or Uniswap */ interface TakePayDefinition { take: Eulith.Contracts.ERC20TokenContract; pay: Eulith.Contracts.ERC20TokenContract; takeAmount: number; recipient?: string; payTransferFrom?: string; } /** * Create a loan or swap available for the duration of a transaction. * * What is a flash (loan/swap)? * * Put simply, a flash loan/swap gives you access to liquidity at the START of a transaction * provided you pay it back at the end. Otherwise, the whole transaction reverts. * * Eulith supports flash loans & swaps from Aave and Uniswap. The fee for the loan depends on the provider: * o Uniswap: 0.05%, 0.3% or 1% (depending on which fee the specific pool is using) * o Aave: 0.09% * * It acts as a nested transaction. */ export declare class FlashLiquidity extends Eulith.AtomicTx.NestedTransaction { private constructor(); /** * returns fee (float) as percent; * The fee is applied to all tokens converted. * See feeAmt for the actual fees. */ get feePct(): number; /** * Returns the fee for this transaction as a list of token values (since the fee may comprise multiple values for multiple tokens) */ get feeAmt(): Eulith.Tokens.Value.ITokenValue[]; /** * In the case of swap, returns the exchange price */ get price(): number; /** * Start a flash liquidity transaction. * * You can either pass a loan or a takePay definition. * * In the case of a loan, the resulting tx is clear: you will originate a flash loan. * * In the case of a takePay, you will either originate a flash loan or a swap depending * on the take and pay tokens. If you're taking and paying the same thing, that's a loan. * Otherwise, it's a swap. */ static start({ parentTx, loan, takePay }: { parentTx: Eulith.AtomicTx.Transaction; loan?: Eulith.FlashLiquidity.IFlashLoanable; takePay?: TakePayDefinition; }): Promise<FlashLiquidity>; private price_; private feePct_; private feeAmt_; } export declare module FlashLiquidity { type IFlashLoanable = IFlashLoanableX; } export {};