UNPKG

@bombearn/sdk

Version:

Interaction framework for the yearn protocol

104 lines (103 loc) 3.16 kB
import { CallOverrides, PopulatedTransaction } from "@ethersproject/contracts"; import { TransactionResponse } from "@ethersproject/providers"; export declare class CustomError extends Error { error_type: string; constructor(message: string, error_type: string); } /** * Generic SDK error. Wrapped errors are: * * - ethers.js errors * - http request errors */ export declare class SdkError extends CustomError { error_code?: string; static NO_SLIPPAGE: string; constructor(message: string, error_code?: string); } /** * Time aliases */ export declare type Seconds = number; export declare type Milliseconds = number; export declare type Weeks = number; /** * Type alias for an address type. */ export declare type Address = string; /** * Type for anything that has an address property. */ export declare type Addressable = { address: Address; }; /** * Type alias for a stringified big number. SDK tries to be bignumber-lib * agnostic so integer values are returned as strings. */ export declare type Integer = string; /** * Utility type to help distinguish [[Integer]]s that represent a USDC (6 dec) * value. */ export declare type Usdc = string; /** * Utility type to help distinguish [[Integer]]s that represents an already * normalized value with the corresponding decimals from their Integer form. */ export declare type Unit = string; /** * Utility type to describe a map of predefined keys with the same value. */ export declare type TypedMap<K extends string | number | symbol, V> = { [key in K]: V; }; /** * Accepted locales. */ export declare type Locale = "de" | "el" | "en" | "es" | "fr" | "hi" | "id" | "ja" | "pt" | "ru" | "tr" | "vi" | "zh"; /** * Interface to implement support for call overrides */ export interface Overridable { overrides?: CallOverrides; } /** * Props to use on transactions with write contract functionality */ export interface WriteTransactionProps extends Overridable { populate?: boolean; } /** * Interface to indicate if a write transaction will result in a populated transaction rather than execute */ export interface WillPopulate extends WriteTransactionProps { populate: true; } /** * Result to use on transactions with write contract functionality */ export declare type WriteTransactionResult<P> = Promise<P extends WillPopulate ? PopulatedTransaction : TransactionResponse>; /** * Expected transaction outcome */ export interface TransactionOutcome { sourceTokenAddress: Address; sourceTokenAmount: Integer; sourceTokenAmountUsdc?: Usdc; targetTokenAddress: Address; targetTokenAmount: Integer; targetTokenAmountUsdc: Usdc; targetUnderlyingTokenAddress?: Address; targetUnderlyingTokenAmount?: Integer; conversionRate?: number; slippage?: number; sourceTokenAmountFee?: Integer; } export interface SimpleTransactionOutcome { sourceTokenAddress: Address; sourceTokenAmount: Integer; targetTokenAddress: Address; targetTokenAmount: Integer; sourceTokenAmountFee?: Integer; }