import { BigNumberish, ContractTransaction, ContractTransactionResponse, Provider } from 'ethers'; import { FillableQuote, PoolKey, PoolMinimal, TransactionData, Vault, VaultExtended, VaultPosition, VaultPositionExtended } from '../entities'; import { BaseAPI } from './baseAPI'; import { TokenOrAddress } from './tokenAPI'; export declare class VaultAPI extends BaseAPI { /** * Converts a boolean into the corresponding `bigint` for the trade side. * * @param {boolean} isBuy - Whether the trade is a buy or a sell. * @returns {bigint} The corresponding `bigint` for the trade side */ tradeSide(isBuy: boolean): bigint; /** * Converts a boolean into the corresponding `bigint` for the option type. * * @param {boolean} isCall - Whether the trade is a call or a put. * @returns {bigint} The corresponding `bigint` for the trade side */ optionType(isCall: boolean): bigint; /** * Returns the total amount of assets in a vault. * @param vaultAddress {string} The contract address of the vault. * @param provider {Provider} The custom provider to use for this call. * @returns {Promise} Promise containing the total assets in the vault. */ totalAssets(vaultAddress: string, provider?: Provider): Promise; /** * Returns the utilization percent of total assets in a vault. * @param vaultAddress {string} The contract address of the vault. * @param provider {Provider} The custom provider to use for this call. * @returns {Promise} Promise containing the utilization percent of the assets in the vault. */ getUtilizationPercent(vaultAddress: string, provider?: Provider): Promise; /** * Returns the best vault quote for a given pool. * * @param {string} poolAddress - The address of the pool to stream quotes for. * @param {string} size - The size of the quote to stream. * @param {string} isBuy - Whether the quote is a buy quote. * @param {string} minimumSize - The minimum size of the quote to stream. Only quotes with a size greater than or equal to this will be emitted. * @param {string} referrer - The referrer address to use for the quote. * @param {string} taker - The taker address to use for the quote. * @param {number} maxSlippagePercent - The maximum slippage percent to use for the quote. * @param {boolean} showErrors - Whether to show errors in the console. * @param {Provider} provider - The custom provider to use for this call. * * @returns {Promise} A promise that resolves to the best quote for the given pool. */ quote(poolAddress: string, size: BigNumberish, isBuy: boolean, minimumSize?: BigNumberish, referrer?: string, taker?: string, maxSlippagePercent?: number, showErrors?: boolean, provider?: Provider, _vaults?: string[], poolKey?: PoolKey, pool?: PoolMinimal): Promise; /** * Opens a stream, which will emit a quote every time the best vault quote changes. * * @param {string} options.poolAddress - The address of the pool to stream quotes for. * @param {Object} options - The options object. * @param {BigNumberish} options.size - The size of the quote to stream. * @param {boolean} options.isBuy - Whether the quote is a buy quote. * @param {BigNumberish} options.minimumSize - The minimum size of the quote to stream. Only quotes with a size greater than or equal to this will be emitted. * @param {string} options.referrer - The referrer address to use for the quote. * @param {string} options.taker - The taker address to use for the quote. * @param {number} options.maxSlippagePercent - The maximum slippage percent to use for the quote. * @param {boolean} options.showErrors - Whether to show errors in the console. * @param {Provider} options.provider - The custom provider to use for this call. * @param {string} callback - The callback to call when a new quote is emitted. * * @returns {Promise} A promise that resolves when the quote stream has been started. */ streamQuotes(options: { poolAddress: string; size: BigNumberish; isBuy: boolean; minimumSize?: BigNumberish; referrer?: string; taker?: string; maxSlippagePercent?: number; showErrors?: boolean; provider?: Provider; poolKey?: PoolKey; pool?: PoolMinimal; }, callback: (quote: FillableQuote | null) => void): Promise; /** * Cancels a quote stream for a given parameter set. * * @param {string} assets - The vault assets for which to cancel quote streams on. * @param {string} isCall - Whether the vault is a call vault. * @param {string} isBuy - Whether the quote is a buy quote. * @param {Provider} provider - The custom provider to use for this call. * * @returns {Promise} A promise that resolves when the quote stream has been cancelled. */ cancelQuoteStream(assets: string[], isCall: boolean, isBuy: boolean, provider?: Provider): Promise; /** * Retrieves information for a specific vault using its address. * * @param {string} address - The address of the vault for which information should be retrieved. * * @returns {Promise} A promise that resolves to a VaultExtended object, containing information about * the vault at the specified address. */ getVault(address: string): Promise; /** * Retrieves extended information for a specific vault using its address. * * @param {string} address - The address of the vault for which extended information should be retrieved. * * @returns {Promise} A promise that resolves to a VaultExtended object, containing * detailed information about the vault at the specified address. */ getVaultExtended(address: string): Promise; /** * Retrieves information for all vaults. * * @returns {Promise} A promise that resolves to an array of VaultExtended objects, each containing information * about a vault. */ getAllVaultsExtended(): Promise; /** * Retrieves extended information for all vaults associated with a given token address. * * @param {string} tokenAddress - The base token address for which vaults should be retrieved. * * @returns {Promise} A promise that resolves to an array of Vault objects, each containing information * about a vault associated with the given base address. */ getVaults(tokenAddress: string): Promise; /** * Retrieves information for all vaults associated with a given token address. * * @param {string} tokenAddress - The base token address for which vaults should be retrieved. * * @returns {Promise} A promise that resolves to an array of VaultExtended objects, each containing * detailed information about a vault associated with the given base address. */ getVaultsExtended(tokenAddress: string): Promise; /** * Retrieves information for all vaults associated with a given token. * * @param {TokenOrAddress} token - The token or token address for which vaults should be retrieved. * @param {boolean} isQuote - Optional parameter that indicates whether the token is a quote token. Default is false. * * @returns {Promise} A promise that resolves to an array of Vault objects, each containing information * about a vault associated with the given token. */ getVaultsForToken(token: TokenOrAddress, isQuote?: boolean): Promise; /** * Retrieves extended information for all vaults associated with a given token. * * @param {TokenOrAddress} token - The token or token address for which vaults should be retrieved. * @param {boolean} isQuote - Optional parameter that indicates whether the token is a quote token. Default is false. * * @returns {Promise} A promise that resolves to an array of VaultExtended objects, each containing * detailed information about a vault associated with the given token. */ getVaultsExtendedForToken(token: TokenOrAddress, isQuote?: boolean): Promise; /** * Retrieves the vault position for a specific owner and pool. * * @param {string} owner - The address of an owner with shares in the vault. * @param {string} vaultAddress - The address of the vault. * @returns {Promise} A promise that resolves to a VaultPosition object containing details about the owner's position in the specified vault. */ getVaultPosition(owner: string, vaultAddress: string): Promise; /** * Retrieves the extended vault position for a specific owner and pool. * * @param {string} owner - The address of an owner with shares in the vault. * @param {string} vaultAddress - The address of the vault. * @returns {Promise} A promise that resolves to a VaultPositionExtended object containing extended details about the owner's position in the specified vault. */ getVaultPositionExtended(owner: string, vaultAddress: string): Promise; /** * Retrieves the vault positions for a specific owner. * * @param {string} owner - The address of an owner with shares in the vault. * @returns {Promise} A promise that resolves to an array of VaultPositionExtended objects, each containing * detailed information about a vault position associated with the given owner. */ getVaultPositionsExtendedForUser(owner: string): Promise; /** * Gets the balance of shares for a specific owner in a vault. * * @param {string} vaultAddress - The address of the vault. * @param {string} owner - The address of the owner. * @param {Provider} provider - The custom provider to use for this call. * @returns {Promise} A promise that resolves to a bigint representing the balance of shares for the specified owner in the specified vault. */ balanceOfShares(vaultAddress: string, owner: string, provider?: Provider): Promise; /** * Gets the balance of assets for a specific owner in a vault. * * @param {string} vaultAddress - The address of the vault. * @param {string} owner - The address of the owner. * @param {Provider} provider - The custom provider to use for this call. * @returns {Promise} A promise that resolves to a bigint representing the balance of assets for the specified owner in the specified vault. */ balanceOfAssets(vaultAddress: string, owner: string, provider?: Provider): Promise; /** * Converts a given amount of assets to shares for a specific vault. * * @param {string} vaultAddress - The address of the vault. * @param {BigNumberish} assets - The amount of assets to be converted. * @param {Provider} provider - The custom provider to use for this call. * @returns {Promise} A promise that resolves to a bigint representing the equivalent shares for the specified amount of assets in the specified vault. */ convertToShares(vaultAddress: string, assets: BigNumberish, provider?: Provider): Promise; /** * Converts a given amount of shares to assets for a specific vault. * * @param {string} vaultAddress - The address of the vault. * @param {BigNumberish} shares - The amount of shares to be converted. * @param {Provider} provider - The custom provider to use for this call. * @returns {Promise} A promise that resolves to a bigint representing the equivalent assets for the specified amount of shares in the specified vault. */ convertToAssets(vaultAddress: string, shares: BigNumberish, provider?: Provider): Promise; /** * Encodes the deposit parameters into a transaction that can be broadcasted to the provider network. * * @param {string} vaultAddress - The address of the vault where assets will be deposited. * @param {Object} options - An object containing the parameters for the deposit operation. * @param {BigNumberish} options.assets - The amount of assets to be deposited. * @param {string} options.receiver - The address of the receiver whose assets will be deposited and shares will be received. * @param {Provider} provider - The custom provider to use for this call. * * @returns {Promise} A promise that resolves to a contract transaction for the deposit operation. * * @throws Will throw an error if the ERC4626 contract is not found for the provided vault address. */ encodeDeposit(vaultAddress: string, { assets, receiver, }: { assets: BigNumberish; receiver: string; }, provider?: Provider): Promise; /** * Encodes the deposit parameters into a transaction that can be broadcasted to the provider network. * * @param {string} vaultAddress - The address of the vault where assets will be deposited. * @param {Object} options - An object containing the parameters for the deposit operation. * @param {BigNumberish} options.assets - The amount of assets to be deposited. * @param {string} options.receiver - The address of the receiver whose assets will be deposited and shares will be received. * @param {Provider} provider - The custom provider to use for this call. * * @returns {TransactionData} The encoded transaction data. * * @throws Will throw an error if the ERC4626 contract is not found for the provided vault address. */ encodeDepositSync(vaultAddress: string, { assets, receiver, }: { assets: BigNumberish; receiver: string; }, provider?: Provider): TransactionData; /** * Deposits specified assets into a vault from the receiver's address. * * @param {string} vaultAddress - The address of the vault into which the assets are to be deposited. * @param {Object} options - An object containing deposit parameters. * @param {BigNumberish} options.assets - The amount of assets to be deposited into the vault. * @param {string} options.receiver - The address of the receiver whose assets will be deposited and shares will be received. * @param {Provider} provider - The custom provider to use for this call. * * @returns {Promise} A promise that resolves to a transaction response. This contains details of the transaction such as block number, transaction hash, etc. * * @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. */ deposit(vaultAddress: string, options: { assets: BigNumberish; receiver: string; }, provider?: Provider): Promise; /** * Gets the maximum amount that can be withdrawn from a specified vault by a particular owner. * * @param {string} vaultAddress - The address of the vault. * @param {string} owner - The address of the owner. * @param {Provider} provider - The custom provider to use for this call. * @returns {Promise} A promise that resolves to a bigint representing the maximum amount that can be withdrawn by the owner from the vault. */ maxWithdraw(vaultAddress: string, owner: string, provider?: Provider): Promise; /** * Previews the amount of shares that would be withdrawn for a given amount of assets from a specific vault. * * @method previewWithdraw * @param {string} vaultAddress - The address of the vault. * @param {BigNumberish} assets - The amount of assets for which to preview the withdrawal. * @param {Provider} provider - The custom provider to use for this call. * @returns {Promise} A promise that resolves to a bigint representing the amount of shares that would be withdrawn for the given assets amount. */ previewWithdraw(vaultAddress: string, assets: BigNumberish, provider?: Provider): Promise; /** * Encodes the withdrawal parameters into a transaction that can be broadcasted to the provider network. * * @param {string} vaultAddress - The address of the vault from which assets will be withdrawn. * @param {Object} options - An object containing the parameters for the withdrawal operation. * @param {BigNumberish} options.assets - The amount of assets to be withdrawn. * @param {string} options.receiver - The address of the receiver who will get the withdrawn assets. * @param {string} options.owner - The address of the current owner of the assets. * @param {Provider} provider - The custom provider to use for this call. * * @returns {Promise} A promise that resolves to a contract transaction for the withdrawal operation. * * @throws Will throw an error if the ERC4626 contract is not found for the provided vault address. */ encodeWithdraw(vaultAddress: string, { assets, receiver, owner, }: { assets: BigNumberish; receiver: string; owner: string; }, provider?: Provider): Promise; /** * Encodes the withdrawal parameters into a transaction that can be broadcasted to the provider network. * * @param {string} vaultAddress - The address of the vault from which assets will be withdrawn. * @param {Object} options - An object containing the parameters for the withdrawal operation. * @param {BigNumberish} options.assets - The amount of assets to be withdrawn. * @param {string} options.receiver - The address of the receiver who will get the withdrawn assets. * @param {string} options.owner - The address of the current owner of the assets. * @param {Provider} provider - The custom provider to use for this call. * * @returns {TransactionData} The encoded transaction data. * * @throws Will throw an error if the ERC4626 contract is not found for the provided vault address. */ encodeWithdrawSync(vaultAddress: string, { assets, receiver, owner, }: { assets: BigNumberish; receiver: string; owner: string; }, provider?: Provider): TransactionData; /** * Withdraws specified assets from a vault and sends them to a receiver's address. * * @param {string} vaultAddress - The address of the vault from which the assets are to be withdrawn. * @param {Object} options - An object containing withdrawal parameters. * @param {BigNumberish} options.assets - The amount of assets to be withdrawn from the vault. * @param {string} options.receiver - The address of the receiver to which the withdrawn assets will be sent. * @param {string} options.owner - The address of the owner initiating the withdrawal. This should be the signer of the transaction. * @param {Provider} provider - The custom provider to use for this call. * * @returns {Promise} A promise that resolves to a transaction response. This contains details of the transaction such as block number, transaction hash etc. * * @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. */ withdraw(vaultAddress: string, options: { assets: BigNumberish; receiver: string; owner: string; }, provider?: Provider): Promise; /** * Gets the maximum amount of shares that can be redeemed by a particular owner from a specified vault. * * @param {string} vaultAddress - The address of the vault. * @param {string} owner - The address of the owner. * @param {Provider} provider - The custom provider to use for this call. * @returns {Promise} A promise that resolves to a bigint representing the maximum amount of shares that can be redeemed by the owner from the vault. */ maxRedeem(vaultAddress: string, owner: string, provider?: Provider): Promise; /** * Previews the amount of assets that would be received for a given amount of shares from a specific vault. * * @method previewRedeem * @param {string} vaultAddress - The address of the vault. * @param {BigNumberish} shares - The amount of shares for which to preview the redemption. * @param {Provider} provider - The custom provider to use for this call. * @returns {Promise} A promise that resolves to a bigint representing the amount of assets that would be received for the given shares amount. */ previewRedeem(vaultAddress: string, shares: BigNumberish, provider?: Provider): Promise; /** * Encodes a transaction for redeeming shares from a vault. * * @method encodeRedeem * @param {string} vaultAddress - The address of the vault. * @param {object} options - An object containing the parameters for redeeming shares. * @param {BigNumberish} options.shares - The number of shares to redeem. * @param {string} options.receiver - The address to receive the redeemed assets. * @param {string} options.owner - The address of the owner of the shares. * @param {Provider} provider - The custom provider to use for this call. * @returns {Promise} A promise that resolves to a ContractTransaction that represents the encoded transaction for redeeming the shares. */ encodeRedeem(vaultAddress: string, { shares, receiver, owner, }: { shares: BigNumberish; receiver: string; owner: string; }, provider?: Provider): Promise; /** * Encodes a transaction for redeeming shares from a vault. * * @method encodeRedeem * @param {string} vaultAddress - The address of the vault. * @param {object} options - An object containing the parameters for redeeming shares. * @param {BigNumberish} options.shares - The number of shares to redeem. * @param {string} options.receiver - The address to receive the redeemed assets. * @param {string} options.owner - The address of the owner of the shares. * @param {Provider} provider - The custom provider to use for this call. * @returns {TransactionData} The encoded transaction data. */ encodeRedeemSync(vaultAddress: string, { shares, receiver, owner, }: { shares: BigNumberish; receiver: string; owner: string; }, provider?: Provider): TransactionData; /** * Redeems shares from a vault and sends the resulting assets to the specified receiver. * * @method redeem * @param {string} vaultAddress - The address of the vault. * @param {object} options - An object containing the parameters for redeeming shares. * @param {BigNumberish} options.shares - The number of shares to redeem. * @param {string} options.receiver - The address to receive the redeemed assets. * @param {string} options.owner - The address of the owner of the shares. * @param {Provider} provider - The custom provider to use for this call. * @returns {Promise} A promise that resolves to a ContractTransactionResponse which contains information about the transaction that redeemed the shares. */ redeem(vaultAddress: string, options: { shares: BigNumberish; receiver: string; owner: string; }, provider?: Provider): Promise; /** * Retrieves the quote for a specified trade operation in a specific vault. * * @param {string} vaultAddress - The address of the vault where the quote will be retrieved from. * @param {PoolKey} poolKey - The identifier for the pool from which the contracts are to be bought or sold. * @param {BigNumberish} size - The number of contracts to be bought or sold. * @param {boolean} isBuy - A boolean indicating whether this operation is a buy (true) or sell (false). * @param {string} taker - The address of the user who would perform the trade. * @param {Provider} provider - The custom provider to use for this call. * * @returns {Promise} A promise that resolves to a quote for the proposed trade operation. * * @throws Will throw an error if the vault contract is not found for the provided vault address. */ getQuote(vaultAddress: string, poolKey: PoolKey, size: BigNumberish, isBuy: boolean, taker: string, provider?: Provider): Promise; /** * Encodes the trade parameters into a contract transaction that can be broadcasted to the provider network. * * @param {string} vaultAddress - The address of the vault. * @param {Object} options - An object containing key trade options. * @param {PoolKey} options.poolKey - The unique identifier for the liquidity pool involved in the trade. * @param {BigNumberish} options.size - The number of contracts to be bought or sold. * @param {boolean} options.isBuy - A boolean flag indicating whether the trade is a buy (true) or sell (false). * @param {BigNumberish} options.premiumLimit - The maximum premium that the trader is willing to pay for the trade. * @param {string} [options.referrer] - (Optional) The address of the referrer. If not provided, the referrer will default to a zero address. * @param {Provider} provider - The custom provider to use for this call. * * @returns {Promise} A promise that resolves to an encoded contract transaction. This transaction can be signed and broadcasted to the provider network. * * @throws Will throw an error if the vault contract is not found for the provided vault address. */ encodeTrade(vaultAddress: string, { poolKey, size, isBuy, premiumLimit, referrer, }: { poolKey: PoolKey; size: BigNumberish; isBuy: boolean; premiumLimit: BigNumberish; referrer?: string; }, provider?: Provider): Promise; /** * Encodes the trade parameters into a contract transaction that can be broadcasted to the provider network. * * @param {string} vaultAddress - The address of the vault. * @param {Object} options - An object containing key trade options. * @param {PoolKey} options.poolKey - The unique identifier for the liquidity pool involved in the trade. * @param {BigNumberish} options.size - The number of contracts to be bought or sold. * @param {boolean} options.isBuy - A boolean flag indicating whether the trade is a buy (true) or sell (false). * @param {BigNumberish} options.premiumLimit - The maximum premium that the trader is willing to pay for the trade. * @param {string} [options.referrer] - (Optional) The address of the referrer. If not provided, the referrer will default to a zero address. * @param {Provider} provider - The custom provider to use for this call. * * @returns {TransactionData} The encoded transaction data. * * @throws Will throw an error if the vault contract is not found for the provided vault address. */ encodeTradeSync(vaultAddress: string, { poolKey, size, isBuy, premiumLimit, referrer, }: { poolKey: PoolKey; size: BigNumberish; isBuy: boolean; premiumLimit: BigNumberish; referrer?: string; }, provider?: Provider): TransactionData; /** * Performs a trade operation in a specific vault on behalf of a user. * * @param {string} vaultAddress - The address of the vault where the trade operation will occur. * @param {Object} options - An object containing trade parameters. * @param {PoolKey} options.poolKey - The unique identifier for the liquidity pool involved in the trade. * @param {BigNumberish} options.size - The number of contracts to be bought or sold. * @param {boolean} options.isBuy - A boolean indicating whether this operation is a buy (true) or sell (false). * @param {BigNumberish} options.premiumLimit - The maximum premium that the trader is willing to pay for the trade. * @param {string} [options.referrer] - (Optional) The address of the user who referred this trade. * @param {Provider} provider - The custom provider to use for this call. * * @returns {Promise} A promise that resolves to a transaction response. This contains details of the transaction such as block number, transaction hash, etc. * * @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. */ trade(vaultAddress: string, options: { poolKey: PoolKey; size: BigNumberish; isBuy: boolean; premiumLimit: BigNumberish; referrer?: string; }, provider?: Provider): Promise; } export default VaultAPI;