Class VaultAPI

Hierarchy

  • BaseAPI
    • VaultAPI

Constructors

Properties

premia: Premia

Methods

  • Gets the balance of assets for a specific owner in a vault.

    Parameters

    • vaultAddress: string

      The address of the vault.

    • owner: string

      The address of the owner.

    Returns Promise<bigint>

    A promise that resolves to a bigint representing the balance of assets for the specified owner in the specified vault.

  • Gets the balance of shares for a specific owner in a vault.

    Parameters

    • vaultAddress: string

      The address of the vault.

    • owner: string

      The address of the owner.

    Returns Promise<bigint>

    A promise that resolves to a bigint representing the balance of shares for the specified owner in the specified vault.

  • Cancels a quote stream for a given parameter set.

    Parameters

    • assets: string[]

      The vault assets for which to cancel quote streams on.

    • isCall: boolean

      Whether the vault is a call vault.

    • isBuy: boolean

      Whether the quote is a buy quote.

    Returns Promise<void>

    A promise that resolves when the quote stream has been cancelled.

  • Converts a given amount of shares to assets for a specific vault.

    Parameters

    • vaultAddress: string

      The address of the vault.

    • shares: BigNumberish

      The amount of shares to be converted.

    Returns Promise<bigint>

    A promise that resolves to a bigint representing the equivalent assets for the specified amount of shares in the specified vault.

  • Converts a given amount of assets to shares for a specific vault.

    Parameters

    • vaultAddress: string

      The address of the vault.

    • assets: BigNumberish

      The amount of assets to be converted.

    Returns Promise<bigint>

    A promise that resolves to a bigint representing the equivalent shares for the specified amount of assets in the specified vault.

  • Deposits specified assets into a vault from the receiver's address.

    Throws

    Will throw an error if the ERC4626 contract is not found for the provided vault address, or if the transaction fails to be sent.

    Parameters

    • vaultAddress: string

      The address of the vault into which the assets are to be deposited.

    • options: {
          assets: BigNumberish;
          receiver: string;
      }

      An object containing deposit parameters.

      • assets: BigNumberish

        The amount of assets to be deposited into the vault.

      • receiver: string

        The address of the receiver whose assets will be deposited and shares will be received.

    Returns Promise<ContractTransactionResponse>

    A promise that resolves to a transaction response. This contains details of the transaction such as block number, transaction hash, etc.

  • Encodes the deposit parameters into a transaction that can be broadcasted to the provider network.

    Throws

    Will throw an error if the ERC4626 contract is not found for the provided vault address.

    Parameters

    • vaultAddress: string

      The address of the vault where assets will be deposited.

    • options: {
          assets: BigNumberish;
          receiver: string;
      }

      An object containing the parameters for the deposit operation.

      • assets: BigNumberish

        The amount of assets to be deposited.

      • receiver: string

        The address of the receiver whose assets will be deposited and shares will be received.

    Returns Promise<ContractTransaction>

    A promise that resolves to a contract transaction for the deposit operation.

  • Encodes a transaction for redeeming shares from a vault.

    Method

    encodeRedeem

    Parameters

    • vaultAddress: string

      The address of the vault.

    • options: {
          owner: string;
          receiver: string;
          shares: BigNumberish;
      }

      An object containing the parameters for redeeming shares.

      • owner: string

        The address of the owner of the shares.

      • receiver: string

        The address to receive the redeemed assets.

      • shares: BigNumberish

        The number of shares to redeem.

    Returns Promise<ContractTransaction>

    A promise that resolves to a ContractTransaction that represents the encoded transaction for redeeming the shares.

  • Encodes the trade parameters into a contract transaction that can be broadcasted to the provider network.

    Throws

    Will throw an error if the vault contract is not found for the provided vault address.

    Parameters

    • vaultAddress: string

      The address of the vault.

    • options: {
          isBuy: boolean;
          poolKey: PoolKey;
          premiumLimit: BigNumberish;
          referrer?: string;
          size: BigNumberish;
      }

      An object containing key trade options.

      • isBuy: boolean

        A boolean flag indicating whether the trade is a buy (true) or sell (false).

      • poolKey: PoolKey

        The unique identifier for the liquidity pool involved in the trade.

      • premiumLimit: BigNumberish

        The maximum premium that the trader is willing to pay for the trade.

      • Optional referrer?: string

        (Optional) The address of the referrer. If not provided, the referrer will default to a zero address.

      • size: BigNumberish

        The number of contracts to be bought or sold.

    Returns Promise<ContractTransaction>

    A promise that resolves to an encoded contract transaction. This transaction can be signed and broadcasted to the provider network.

  • Encodes the withdrawal parameters into a transaction that can be broadcasted to the provider network.

    Throws

    Will throw an error if the ERC4626 contract is not found for the provided vault address.

    Parameters

    • vaultAddress: string

      The address of the vault from which assets will be withdrawn.

    • options: {
          assets: BigNumberish;
          owner: string;
          receiver: string;
      }

      An object containing the parameters for the withdrawal operation.

      • assets: BigNumberish

        The amount of assets to be withdrawn.

      • owner: string

        The address of the current owner of the assets.

      • receiver: string

        The address of the receiver who will get the withdrawn assets.

    Returns Promise<ContractTransaction>

    A promise that resolves to a contract transaction for the withdrawal operation.

  • Retrieves information for all vaults.

    This function is cached, meaning that if it is called multiple times within a daily period, it will only perform the operation once and then return the cached result for subsequent calls.

    Returns Promise<VaultExtended[]>

    A promise that resolves to an array of VaultExtended objects, each containing information about a vault.

  • Retrieves the quote for a specified trade operation in a specific vault.

    Throws

    Will throw an error if the vault contract is not found for the provided vault address.

    Parameters

    • vaultAddress: string

      The address of the vault where the quote will be retrieved from.

    • poolKey: PoolKey

      The identifier for the pool from which the contracts are to be bought or sold.

    • size: BigNumberish

      The number of contracts to be bought or sold.

    • isBuy: boolean

      A boolean indicating whether this operation is a buy (true) or sell (false).

    • taker: string

      The address of the user who would perform the trade.

    Returns Promise<bigint>

    A promise that resolves to a quote for the proposed trade operation.

  • Returns the utilization percent of total assets in a vault.

    Parameters

    • vaultAddress: string

      {string} The contract address of the vault.

    Returns Promise<number>

    Promise containing the utilization percent of the assets in the vault.

  • Retrieves information for a specific vault using its address.

    This function is cached, meaning that if it is called multiple times within a daily period, it will only perform the operation once and then return the cached result for subsequent calls.

    Parameters

    • address: string

      The address of the vault for which information should be retrieved.

    Returns Promise<Vault>

    A promise that resolves to a VaultExtended object, containing information about the vault at the specified address.

  • Retrieves extended information for a specific vault using its address.

    This function is cached, meaning that if it is called multiple times within a one minute period, it will only perform the operation once and then return the cached result for subsequent calls.

    Parameters

    • address: string

      The address of the vault for which extended information should be retrieved.

    Returns Promise<VaultExtended>

    A promise that resolves to a VaultExtended object, containing detailed information about the vault at the specified address.

  • Retrieves the vault position for a specific owner and pool.

    This function is cached, meaning that if it is called multiple times within a one-minute period, it will only perform the operation once and then return the cached result for subsequent calls.

    Parameters

    • owner: string

      The address of an owner with shares in the vault.

    • vaultAddress: string

      The address of the vault.

    Returns Promise<VaultPosition>

    A promise that resolves to a VaultPosition object containing details about the owner's position in the specified vault.

  • Retrieves the extended vault position for a specific owner and pool.

    This function is cached, meaning that if it is called multiple times within a one-minute period, it will only perform the operation once and then return the cached result for subsequent calls.

    Parameters

    • owner: string

      The address of an owner with shares in the vault.

    • vaultAddress: string

      The address of the vault.

    Returns Promise<VaultPositionExtended>

    A promise that resolves to a VaultPositionExtended object containing extended details about the owner's position in the specified vault.

  • Retrieves the vault positions for a specific owner.

    This function is cached, meaning that if it is called multiple times within a one-minute period, it will only perform the operation once and then return the cached result for subsequent calls.

    Parameters

    • owner: string

      The address of an owner with shares in the vault.

    Returns Promise<VaultPositionExtended[]>

    A promise that resolves to an array of VaultPositionExtended objects, each containing detailed information about a vault position associated with the given owner.

  • Retrieves extended information for all vaults associated with a given token address.

    This function is cached, meaning that if it is called multiple times within a daily period, it will only perform the operation once and then return the cached result for subsequent calls.

    Parameters

    • tokenAddress: string

      The base token address for which vaults should be retrieved.

    Returns Promise<Vault[]>

    A promise that resolves to an array of Vault objects, each containing information about a vault associated with the given base address.

  • Retrieves information for all vaults associated with a given token address.

    This function is cached, meaning that if it is called multiple times within a one minute period, it will only perform the operation once and then return the cached result for subsequent calls.

    Parameters

    • tokenAddress: string

      The base token address for which vaults should be retrieved.

    Returns Promise<VaultExtended[]>

    A promise that resolves to an array of VaultExtended objects, each containing detailed information about a vault associated with the given base address.

  • Retrieves extended information for all vaults associated with a given token.

    This function is cached, meaning that if it is called multiple times within a one minute period, it will only perform the operation once and then return the cached result for subsequent calls.

    Parameters

    • token: Token

      The token for which vaults should be retrieved.

    • isQuote: boolean = false

      Optional parameter that indicates whether the token is a quote token. Default is false.

    Returns Promise<VaultExtended[]>

    A promise that resolves to an array of VaultExtended objects, each containing detailed information about a vault associated with the given token.

  • Retrieves information for all vaults associated with a given token.

    This function is cached, meaning that if it is called multiple times within a daily period, it will only perform the operation once and then return the cached result for subsequent calls.

    Parameters

    • token: Token

      The token for which vaults should be retrieved.

    • isQuote: boolean = false

      Optional parameter that indicates whether the token is a quote token. Default is false.

    Returns Promise<Vault[]>

    A promise that resolves to an array of Vault objects, each containing information about a vault associated with the given token.

  • Gets the maximum amount of shares that can be redeemed by a particular owner from a specified vault.

    Parameters

    • vaultAddress: string

      The address of the vault.

    • owner: string

      The address of the owner.

    Returns Promise<bigint>

    A promise that resolves to a bigint representing the maximum amount of shares that can be redeemed by the owner from the vault.

  • Gets the maximum amount that can be withdrawn from a specified vault by a particular owner.

    Parameters

    • vaultAddress: string

      The address of the vault.

    • owner: string

      The address of the owner.

    Returns Promise<bigint>

    A promise that resolves to a bigint representing the maximum amount that can be withdrawn by the owner from the vault.

  • Converts a boolean into the corresponding bigint for the option type.

    Parameters

    • isCall: boolean

      Whether the trade is a call or a put.

    Returns bigint

    The corresponding bigint for the trade side

  • Previews the amount of assets that would be received for a given amount of shares from a specific vault.

    Method

    previewRedeem

    Parameters

    • vaultAddress: string

      The address of the vault.

    • shares: BigNumberish

      The amount of shares for which to preview the redemption.

    Returns Promise<bigint>

    A promise that resolves to a bigint representing the amount of assets that would be received for the given shares amount.

  • Previews the amount of shares that would be withdrawn for a given amount of assets from a specific vault.

    Method

    previewWithdraw

    Parameters

    • vaultAddress: string

      The address of the vault.

    • assets: BigNumberish

      The amount of assets for which to preview the withdrawal.

    Returns Promise<bigint>

    A promise that resolves to a bigint representing the amount of shares that would be withdrawn for the given assets amount.

  • Returns the best vault quote for a given pool.

    Parameters

    • poolAddress: string

      The address of the pool to stream quotes for.

    • size: BigNumberish

      The size of the quote to stream.

    • isBuy: boolean

      Whether the quote is a buy quote.

    • Optional minimumSize: BigNumberish

      The minimum size of the quote to stream. Only quotes with a size greater than or equal to this will be emitted.

    • Optional referrer: string

      The referrer address to use for the quote.

    • Optional maxSlippagePercent: BigNumberish

      The maximum slippage percent to use for the quote.

    Returns Promise<null | FillableQuote>

    A promise that resolves to the best quote for the given pool.

  • Redeems shares from a vault and sends the resulting assets to the specified receiver.

    Method

    redeem

    Parameters

    • vaultAddress: string

      The address of the vault.

    • options: {
          owner: string;
          receiver: string;
          shares: BigNumberish;
      }

      An object containing the parameters for redeeming shares.

      • owner: string

        The address of the owner of the shares.

      • receiver: string

        The address to receive the redeemed assets.

      • shares: BigNumberish

        The number of shares to redeem.

    Returns Promise<ContractTransactionResponse>

    A promise that resolves to a ContractTransactionResponse which contains information about the transaction that redeemed the shares.

  • Opens a stream, which will emit a quote every time the best vault quote changes.

    Parameters

    • options: {
          isBuy: boolean;
          minimumSize?: BigNumberish;
          poolAddress: string;
          size: BigNumberish;
      }

      The options object.

      • isBuy: boolean

        Whether the quote is a buy quote.

      • Optional minimumSize?: BigNumberish

        The minimum size of the quote to stream. Only quotes with a size greater than or equal to this will be emitted.

      • poolAddress: string

        The address of the pool to stream quotes for.

      • size: BigNumberish

        The size of the quote to stream.

    • callback: ((quote) => void)

      The callback to call when a new quote is emitted.

        • (quote): void
        • Parameters

          Returns void

    Returns Promise<void>

    A promise that resolves when the quote stream has been started.

  • Returns the total amount of assets in a vault.

    Parameters

    • vaultAddress: string

      {string} The contract address of the vault.

    Returns Promise<bigint>

    Promise containing the total assets in the vault.

  • Performs a trade operation in a specific vault on behalf of a user.

    Throws

    Will throw an error if the vault contract is not found for the provided vault address, or if the transaction fails to be sent.

    Parameters

    • vaultAddress: string

      The address of the vault where the trade operation will occur.

    • options: {
          isBuy: boolean;
          poolKey: PoolKey;
          premiumLimit: BigNumberish;
          referrer?: string;
          size: BigNumberish;
      }

      An object containing trade parameters.

      • isBuy: boolean

        A boolean indicating whether this operation is a buy (true) or sell (false).

      • poolKey: PoolKey

        The unique identifier for the liquidity pool involved in the trade.

      • premiumLimit: BigNumberish

        The maximum premium that the trader is willing to pay for the trade.

      • Optional referrer?: string

        (Optional) The address of the user who referred this trade.

      • size: BigNumberish

        The number of contracts to be bought or sold.

    Returns Promise<ContractTransactionResponse>

    A promise that resolves to a transaction response. This contains details of the transaction such as block number, transaction hash, etc.

  • Converts a boolean into the corresponding bigint for the trade side.

    Parameters

    • isBuy: boolean

      Whether the trade is a buy or a sell.

    Returns bigint

    The corresponding bigint for the trade side

  • Withdraws specified assets from a vault and sends them to a receiver's address.

    Throws

    Will throw an error if the ERC4626 contract is not found for the provided vault address, or if the transaction fails to be sent.

    Parameters

    • vaultAddress: string

      The address of the vault from which the assets are to be withdrawn.

    • options: {
          assets: BigNumberish;
          owner: string;
          receiver: string;
      }

      An object containing withdrawal parameters.

      • assets: BigNumberish

        The amount of assets to be withdrawn from the vault.

      • owner: string

        The address of the owner initiating the withdrawal. This should be the signer of the transaction.

      • receiver: string

        The address of the receiver to which the withdrawn assets will be sent.

    Returns Promise<ContractTransactionResponse>

    A promise that resolves to a transaction response. This contains details of the transaction such as block number, transaction hash etc.

Generated using TypeDoc