Options
All
  • Public
  • Public/Protected
  • All
Menu

@vanilladefi/sdk

Index

Type aliases

AddressBalance

AddressBalance: { address: string; amount: BigNumber }

Type declaration

  • address: string
  • amount: BigNumber

SnapshotState

SnapshotState: { accounts: {}; blockNumber: number; conversionDeadline: number; timeStamp: number }

Type declaration

  • accounts: {}
    • [address: string]: BigNumber
  • blockNumber: number
  • conversionDeadline: number
  • timeStamp: number

Variables

blockDeadlineThreshold

blockDeadlineThreshold: 60000 = 60000

A trade deadline for submitted trades. 10 minutes by default.

chainId

chainId: 1 = 1

Chain ID where Vanilla resides

conservativeGasLimit

conservativeGasLimit: 800000 = 800_000

Conservative gas limit to use for Uniswap v2/v3 trades.

conservativeMigrationGasLimit

conservativeMigrationGasLimit: 120000 = 120_000

Conservative gas limit to use for $VNL token migration

contractAddresses

contractAddresses: { uniswap: { [ version in UniswapVersion]: { quoter?: string; router: string } }; vanilla: { [ version in VanillaVersion]: { router: string; vnl: string } } } = ...

Addresses of deployed Vanilla contracts

Type declaration

  • uniswap: { [ version in UniswapVersion]: { quoter?: string; router: string } }
  • vanilla: { [ version in VanillaVersion]: { router: string; vnl: string } }

epoch

epoch: 12134736 = 12134736

The block number of the first Vanilla v1.0 deployment. Used for calculating HTRS

ethersOverrides

ethersOverrides: { gasLimit: number } = ...

Ethersjs overrides if estimates fail

Type declaration

  • gasLimit: number

hiddenTokens

hiddenTokens: string[] = ...

Vanilla v1.0 hidden tokens. Currently: Ampleforth

network

network: providers.Networkish = ...

A network definition used in ethersjs

usdc

usdc: Token = ...

Equals USDC from getAllTokens if found, defaultUsdc if not

usdcWethPoolAddress

usdcWethPoolAddress: "0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640" = '0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640'

The Uniswap v3 pool address for checking WETH/USDC price

vnl

vnl: Token = ...

Latest $VNL token in Vanilla's token format

vnlDecimals

vnlDecimals: 12 = 12

Decimal points used in $VNL

vnlPools

vnlPools: { ETH: string; USDC: string } = ...

$VNL pools on Uniswap with the most liquidity

Type declaration

  • ETH: string
  • USDC: string

weth

weth: Token = ...

Equals wETH from getAllTokens if found, defaultWeth if not

Functions

calculateGasMargin

  • calculateGasMargin(value: BigNumber): BigNumber
  • Adds a reasonable threshold on top of estimated gas limits to guarantee execution

    Parameters

    • value: BigNumber

      estimated gas limit

    Returns BigNumber

    gas limit with added threshold in wei

convertVanillaTokenToUniswapToken

  • convertVanillaTokenToUniswapToken(input: Token): UniswapToken
  • Converts a token from Vanilla token format into Uniswap token format

    Parameters

    • input: Token

      a Vanilla token

    Returns UniswapToken

    a Uniswap SDK compatible token

Const estimateGas

  • estimateGas(version: VanillaVersion, trade: Trade | V3Trade, signerOrProvider: Signer | Provider, operation: Operation, token0: Token, slippageTolerance: default | Percent): Promise<BigNumber>
  • Estimates gas for given trade

    Parameters

    • version: VanillaVersion

      Vanilla version

    • trade: Trade | V3Trade

      A Vanilla trade object

    • signerOrProvider: Signer | Provider

      an ethersjs signer(read/write) or provider(readonly)

    • operation: Operation

      Buy/Sell

    • token0: Token

      The bought token (Buy) or the sold token (Sell)

    • slippageTolerance: default | Percent

      Allowed slippage for the trade

    Returns Promise<BigNumber>

    Estimated gas limit in wei

Const estimateReward

  • estimateReward(version: VanillaVersion, owner: string, signerOrProvider: Signer | Provider, tokenSold: Token, tokenReceived: Token, amountSold: string, amountReceived: string): Promise<null | RewardResponse>
  • Queries the Vanilla router for eligible rewards if given token was sold now and with given price

    Parameters

    • version: VanillaVersion

      Vanilla version

    • owner: string

      token owner address

    • signerOrProvider: Signer | Provider

      an ethersjs signer(read/write) or provider(readonly)

    • tokenSold: Token

      The sold token in Vanilla's token format

    • tokenReceived: Token

      The received token in Vanilla's token format

    • amountSold: string

      Unparsed amount sold as a decimal string

    • amountReceived: string

      Unparsed amount received as a decimal string

    Returns Promise<null | RewardResponse>

    the amount of rewards ($VNL) the trade would result in

getAllTokens

  • getAllTokens(version?: VanillaVersion): Token[]
  • Returns the list of tokens available in Vanilla's trade UI based on given Vanilla version.

    Parameters

    • Optional version: VanillaVersion

      Vanilla version

    Returns Token[]

    A list of tokens in Vanilla's token format.

getBalance

  • getBalance(address: string, provider: Provider): Promise<BigNumber>
  • Returns the ETH balance of given Ethereum address as a BigNumber (wei)

    Parameters

    • address: string

      Ethereum address

    • provider: Provider

      an ethersjs provider with readonly access

    Returns Promise<BigNumber>

    the ETH balance of given Ethereum address in wei as BigNumber

Const getBasicWalletDetails

  • getBasicWalletDetails(vanillaVersion: VanillaVersion, address: string, provider?: Provider): Promise<PrerenderProps>
  • Fetches the $VNL and $ETH balances for given address

    Parameters

    • vanillaVersion: VanillaVersion

      Vanilla version

    • address: string

      ethereum address

    • Optional provider: Provider

      an ethersjs provider (readonly)

    Returns Promise<PrerenderProps>

    addresses $VNL and $ETH balance

getContract

  • getContract(address: string, ABI: any, signerOrProvider?: Signer | Provider): Contract
  • Helper function for constructing arbitrary ethersjs contract instances

    Parameters

    • address: string

      contract address

    • ABI: any

      The application binary interface of the contract

    • Optional signerOrProvider: Signer | Provider

      an ethersjs signer(read/write) or provider(readonly)

    Returns Contract

    a Contract instance with transactional capabilities

getFeeTier

  • getFeeTier(input: undefined | null | string | number): FeeAmount | undefined
  • Matches a given Uniswap v3 pool fee tier with an enum and returns it

    Parameters

    • input: undefined | null | string | number

      , the default fee tiers of Uniswap v3 pools.

    Returns FeeAmount | undefined

    enum FeeAmount.[LOW, MEDIUM, HIGH] | undefined

Const getPriceData

  • getPriceData(version: VanillaVersion, owner: string, signerOrProvider: Signer | Provider, tokenAddress: string): Promise<null | TokenPriceResponse>
  • Get the pricedata struct that contains the average price and block number of a token, together with the owned amount.

    Parameters

    • version: VanillaVersion

      Vanilla version

    • owner: string

      token owner address

    • signerOrProvider: Signer | Provider

      an ethersjs signer(read/write) or provider(readonly)

    • tokenAddress: string

      token contract address

    Returns Promise<null | TokenPriceResponse>

    Vanilla token data for given owner

getUserPositions

  • getUserPositions(version: VanillaVersion, address: string, tokens?: Token[], provider?: Provider): Promise<Token[]>
  • Gets user positions with embedded price data in Vanilla's token format

    Parameters

    • version: VanillaVersion

      Vanilla version

    • address: string

      user address

    • Optional tokens: Token[]

      list of tokens to query in Vanilla's token format

    • Optional provider: Provider

      an ethersjs provider (readonly)

    Returns Promise<Token[]>

    tokens with price data

Const getUsers

  • getUsers(provider?: Provider): Promise<string[]>
  • Gets all addresses that have purchased tokens via Vanilla

    Parameters

    • Optional provider: Provider

      an ethersjs provider (readonly)

    Returns Promise<string[]>

    list of addresses that have interacted with Vanilla

getVanillaRouter

  • getVanillaRouter(version: VanillaVersion, signerOrProvider?: Signer | Provider): Contract | VanillaV1Router02
  • Returns an instance of a Vanilla trade router contract based on the Vanilla version.

    Parameters

    • version: VanillaVersion

      Version of Vanilla, so that interfacing with legacy tokens is possible.

    • Optional signerOrProvider: Signer | Provider

      ethersjs signer(read/write) or provider(readonly).

    Returns Contract | VanillaV1Router02

    Vanilla router contract instance with transactional capability

getVanillaTokenContract

  • getVanillaTokenContract(version: VanillaVersion, signerOrProvider?: Signer | Provider): ERC20
  • Returns an instance of a $VNL ERC-20 token contract based on the Vanilla version.

    Parameters

    • version: VanillaVersion

      Version of Vanilla, so that interfacing with legacy tokens is possible.

    • Optional signerOrProvider: Signer | Provider

      ethersjs signer(read/write) or provider(readonly).

    Returns ERC20

    ERC-20 token contract instance with transactional capability

Const getVnlHolders

  • getVnlHolders(provider?: Provider): Promise<string[]>
  • Gets a list of $VNL holders

    Parameters

    • Optional provider: Provider

      an ethersjs provider (readonly)

    Returns Promise<string[]>

    list of addresses that hold $VNL

ipfsToHttp

  • ipfsToHttp(src: undefined | null | string, gateway?: string): string
  • Parameters

    • src: undefined | null | string
    • gateway: string = 'ipfs.io/ipfs'

    Returns string

isAddress

  • isAddress(value: string): string | false
  • Returns a checksummed version of the given address if it exists, false if the given address is not correct.

    Parameters

    • value: string

      an Ethereum address

    Returns string | false

    a checksummed address or false

padUniswapTokenToToken

  • padUniswapTokenToToken(input: UniSwapToken): Token
  • Pads Uniswap SDK token format into Vanilla token format

    Parameters

    • input: UniSwapToken

      a UniSwapToken instance with less info than Vanilla's Token format

    Returns Token

    a padded token with all required fields of Vanilla token format

Const snapshot

  • snapshot(token01: VanillaV1Token01, token02: VanillaV1Token02): Promise<{ merkleTree: MerkleTree; root: string; snapshotState: SnapshotState; getProof: any; verify: any }>
  • Parameters

    • token01: VanillaV1Token01
    • token02: VanillaV1Token02

    Returns Promise<{ merkleTree: MerkleTree; root: string; snapshotState: SnapshotState; getProof: any; verify: any }>

Const toKeccak256Leaf

Generated using TypeDoc