Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • default

Index

Constructors

  • Creates a new APWine SDK instance.

    Parameters

    Returns default

Properties

AMMRegistry: AMMRegistry

The AMM Registry contract instance. Keeps track of all AMMs.

Controller: null | Controller = null

The Controller contract instance. Provides some basic flows, like withdraw/deposit.

async
FutureVault: (address: string) => FutureVault

Type declaration

    • Get a target FutureVault contract instance.

      Parameters

      • address: string

        address of the desired Future.

      Returns FutureVault

      • FutureVault instance on the given address
Registry: Registry

The Registry contract instance. Keeps track of all utility contracts.

Router: AMMRouterV1

The AMM Router contract instance. Simplifies some processes through AMMs.

defaultSlippage: number

The slippage tolerance being used by default on swaps.

defaultUser: string = ''

The default user which will be used in case no user is passed to certain functions. The initial value will be the result of signer.getAddress()

network: Network

The network the SDK instance is connected to.

provider: Provider

The provider, necessary for fetching data.

ready: boolean | Promise<[Controller, undefined | string]> = false

Await this propery to use asynchronous props, like Controller.

async
signer: null | Signer

The signer, necessary for executing transactions.

signerOrProvider: Signer | Provider

Keep track of whether the signer or the provider is being used, when creating contract instances.

Methods

  • Add liqidity for the target AMM for a user.

    transaction
    • requires a signer.

    Parameters

    Returns Promise<undefined | SDKFunctionReturnType<Transaction>>

    • an SDK returnType which contains a transaction and/or an error.
  • allowance(spender: string, tokenAddress: string, account?: string): Promise<TokenAmount>
  • Fetch the spendable amount by another party(spender) from the owner's tokens on a future vault

    Parameters

    • spender: string

      The contract/entity to which the allowance is set.

    • tokenAddress: string

      The address of the token contract.

    • Optional account: string

      The token owner's wallet address

    Returns Promise<TokenAmount>

    • The allowance in TokenAmount.
  • Approve transactions for a token amount for the target token.

    transaction
    • requires a signer.

    Parameters

    • spender: string

      The contract/entity receiving approval for spend.

    • tokenAddress: string

      The address of the token contract.

    • amount: BigNumberish

      The amount of tokens to be approved.

    Returns Promise<undefined | SDKFunctionReturnType<Transaction>>

    • an SDK returnType which contains a transaction and/or an error.
  • Set LPToken approval status for an account.

    transaction
    • requires a signer.

    Parameters

    • amm: AMM

      The AMM on which the approval will happen.

    • approval: boolean = true

      Boolean value of the approval.

    Returns Promise<undefined | SDKFunctionReturnType<Transaction>>

    • an SDK returnType which contains a transaction and/or an error.
  • Deposit amount to a future vault.

    transaction
    • requires a signer.

    Parameters

    • future: FutureVault

      The future to be withdrawn from.

    • amount: BigNumberish

      The amount to be withdrawn.

    • options: { autoApprove: boolean } = ...
      • autoApprove: boolean

    Returns Promise<undefined | SDKFunctionReturnType<Transaction>>

    • an SDK returnType which contains a transaction and/or an error.
  • Fetch the AMM of the provided FutureVault instance.

    Parameters

    Returns Promise<AMM>

    • AMM contract instance.
  • fetchAllAMMs(): Promise<AMM[]>
  • Fetch all AMMs

    Returns Promise<AMM[]>

    • Promise of an AMM collection.
  • Fetch all FYT contract instances.

    Returns Promise<FutureYieldToken[]>

    • a collection of FYT token contract instances.
  • Fetch all aggregated Future constructs on an AMM.

    Parameters

    Returns Promise<FutureAggregate[]>

    • A collection of aggregated objects with future related data
  • Fetch all future vaults.

    Returns Promise<FutureVault[]>

    • All FutureVault instances.
  • fetchAllLPTokenPools(amm: AMM): Promise<{ address: string; id: BigNumber; pairId: 0 | 1; periodIndex: undefined | BigNumberish; token: LPToken }[]>
  • Fetch an aggregated construct collection of all LPTokenPools.

    Parameters

    • amm: AMM

      Fetch all liquidity pools of an AMM.

    Returns Promise<{ address: string; id: BigNumber; pairId: 0 | 1; periodIndex: undefined | BigNumberish; token: LPToken }[]>

    • A collection of aggregated constructs with LPTokenPool related data.
  • fetchFutureAggregateFromAddress(futureAddress: string): Promise<FutureAggregate>
  • Fetch an aggregated Future construct by future vault address.

    Parameters

    • futureAddress: string

      The address of the future to be fetched.

    Returns Promise<FutureAggregate>

    • An aggregated object with future related data.
  • Fetch an aggregated Future construct by future vault index.

    Parameters

    • index: number

      The index of the future to be fetched.

    Returns Promise<FutureAggregate>

    • An aggregated object with future related data.
  • fetchLPTokenPool(amm: AMM, pairId: 0 | 1, periodIndex?: number): Promise<{ address: string; id: BigNumber; pairId: 0 | 1; periodIndex: undefined | BigNumberish; token: LPToken }>
  • Fetch an aggregated construct of an LPTokenPool

    Parameters

    • amm: AMM

      The target AMM on which the tokenPool exists.

    • pairId: 0 | 1

      The pair id of the token pair, 0 or 1.

    • Optional periodIndex: number

      anything from 0 to the current period index. Default is the current period.

    Returns Promise<{ address: string; id: BigNumber; pairId: 0 | 1; periodIndex: undefined | BigNumberish; token: LPToken }>

    • An aggregated construct with LPTokenPool related data.
  • fetchPT(amm: AMM): Promise<PT>
  • Fetch PT token contract instance of an AMM.

    Parameters

    • amm: AMM

      The target AMM.

    Returns Promise<PT>

    • PT token contract instance.
  • fetchSpotPrice(future: FutureVault, from: "PT" | "Underlying" | "FYT", to: "PT" | "Underlying" | "FYT"): Promise<BigNumber | Error>
  • Fetch spot price of a swap route.

    Parameters

    • future: FutureVault

      The target future on which the spot price is being queried.

    • from: "PT" | "Underlying" | "FYT"

      APWToken: PT, Underlying or FYT.

    • to: "PT" | "Underlying" | "FYT"

      APWToken: PT, Underlying or FYT.

    Returns Promise<BigNumber | Error>

    • spot price in BigNumber format.
  • initialize(): Promise<[Controller, undefined | string]>
  • Initializes all asynchronous properties, and sets the resulting promise in sdkInstance.ready

    Returns Promise<[Controller, undefined | string]>

    • A Promise of a collection of asynchronous props wrapped into Promise.all
  • isApprovalNecessary(tokenAddress: string, amount: BigNumberish, spender: string, account?: string): Promise<boolean>
  • Check if the user needs to give approval to an entity, for an amount of a token.

    Parameters

    • tokenAddress: string

      The address of the token.

    • amount: BigNumberish

      The amount in question.

    • spender: string

      The entity of which the approval is being queried.

    • Optional account: string

      The owner of the tokens.

    Returns Promise<boolean>

    • a boolean value.
  • isLPApprovedForAll(amm: AMM, account?: string): Promise<boolean>
  • Inspect LPToken approval status of an account.

    Parameters

    • amm: AMM

      The amm on which to check LPToken approval status.

    • Optional account: string

      The user whose approval status is queried.

    Returns Promise<boolean>

    • a boolean value of the approval of this account for all LPs.
  • Remove liquidity from the target AMM for a user.

    transaction
    • requires a signer.

    Parameters

    Returns Promise<undefined | SDKFunctionReturnType<Transaction>>

    • an SDK returnType which contains a transaction and/or an error.
  • Swap by controlling the exact amount of tokens passed in.

    transaction
    • requires a signer.

    Parameters

    Returns Promise<undefined | SDKFunctionReturnType<Transaction>>

    • either an error object, or a ContractTransaction
  • Swap by controlling the exact amount of tokens coming out.

    transaction
    • requires a signer.

    Parameters

    Returns Promise<undefined | SDKFunctionReturnType<Transaction>>

    • either an error object, or a ContractTransaction
  • updateAllowance(spender: string, tokenAddress: string, amount: BigNumberish, options?: { autoApprove: boolean }): Promise<undefined | SDKFunctionReturnType<Transaction>>
  • Update the spendable amount by another party(spender) from the owner's tokens on a future vault.

    transaction
    • requires a signer.

    Parameters

    • spender: string

      The contract/entity for which the allowance will be updated.

    • tokenAddress: string

      The address of the token contract.

    • amount: BigNumberish

      The amount of the allowance.

    • options: { autoApprove: boolean } = ...
      • autoApprove: boolean

    Returns Promise<undefined | SDKFunctionReturnType<Transaction>>

    • an SDK returnType which contains a transaction and/or an error.
  • updateDefaultUser(address: string): void
  • Update default user on an existing APWineSDK instance.

    Parameters

    • address: string

      The address of the new user.

    Returns void

  • updateNetwork(network: Network): void
  • Updates the network on an existing APWineSDK instance.

    Parameters

    • network: Network

      The network on which the SDK instance operates

    Returns void

  • updateProvider(provider: Provider, useWithContracts?: boolean): void
  • Updates the provider on an existing APWineSDK instance.

    Parameters

    • provider: Provider

      A provider to connect to the ethereum blockchain.

    • useWithContracts: boolean = false

      'Set this provider to sdk.signerOrProvider, and re-instantiate contract instances with it.'

    Returns void

  • updateSigner(signer: Signer, useWithContracts?: boolean): void
  • Updates the signer on an existing APWineSDK instance.

    Parameters

    • signer: Signer

      A transaction signer.

    • useWithContracts: boolean = true

      'Set this signer to sdk.signerOrProvider, and re-instantiate contract instances with it.'

    Returns void

  • updateSlippageTolerance(slippage: number): void
  • Set default slippage tolerance for the SDK instance.

    Parameters

    • slippage: number

      Default slippage to be set.

    Returns void

  • useProvider(): void
  • Switch to provider usage on the sdk instance. This is useful, when the priority is fetching. (utilizing MulticallProvider)

    Returns void

  • useSigner(): void
  • Switch to signer usage on the sdk instance. This is necessary if transactions are to be executed.

    Returns void

  • Withdraw amount from a future vault.

    transaction
    • requires a signer.

    Parameters

    • future: FutureVault

      The future to be withdrawn from.

    • amount: BigNumberish

      The amount to be withdrawn.

    Returns Promise<undefined | SDKFunctionReturnType<Transaction>>

    • an SDK returnType which contains a transaction and/or an error.

Generated using TypeDoc, the 4/22/2022