UNPKG

@volare.finance/volare.js

Version:
152 lines (151 loc) 6.65 kB
/** * @file Controller.ts * @author astra <astra@volare.finance> * @date 2022 */ import { TransactionResponse } from '@ethersproject/providers'; import { Address, BigNumber, Provider } from '@volare.finance/utils.js'; import { ContractInterface, Wallet } from 'ethers'; import { INativeVault, INativeVToken, VaultType } from './protocols'; export interface IControllerConfiguration { whitelist: Address; oracle: Address; calculator: Address; pool: Address; } export declare class Controller extends Provider { static OwnershipTransferred_t0: string; static ABI(): ContractInterface; configuration?: IControllerConfiguration; constructor(address: Address, endpoint: string); /** * @notice returns the current controller configuration * @return whitelist, the address of the whitelist module * @return oracle, the address of the oracle module * @return calculator, the address of the calculator module * @return pool, the address of the pool module */ getConfiguration(): Promise<IControllerConfiguration>; /** * @notice get cap amount for collateral asset * @param assetAddress collateral asset address * @return cap amount */ getNakedCap(assetAddress: Address): Promise<BigNumber>; /** * @notice get amount of collateral deposited in all naked margin vaults * @param assetAddress collateral asset address * @return naked pool balance */ getNakedPoolBalance(assetAddress: Address): Promise<BigNumber>; /** * @notice get an vToken's payout/cash value after expiry, in the collateral asset * @param vTokenAddress vToken address * @param vTokenAmount amount of the vToken to calculate the payout for, always represented in 1e8 * @return amount of collateral to pay out */ getPayout(vTokenAddress: Address, vTokenAmount: BigNumber): Promise<BigNumber>; /** * @notice get the number of vaults for a specified account owner * @param ownerAddress account owner address * @return number of vaults */ getAccountVaultCounter(ownerAddress: Address): Promise<number>; /** * @notice return a specific vault * @param ownerAddress account owner * @param vaultId vault id of vault to return * @return INativeVault struct that corresponds to the _vaultId of _owner */ getVault(ownerAddress: Address, vaultId: number): Promise<INativeVault>; /** * @notice return a specific vault * @param ownerAddress account owner * @param vaultId vault id of vault to return * @return INativeVault struct that corresponds to the vaultId of ownerAddress, vault type and the latest timestamp when the vault was updated */ getVaultWithDetails(ownerAddress: Address, vaultId: number): Promise<[INativeVault, VaultType, number]>; /** * @notice mint short vTokens from a vault which creates an obligation that is recorded in the vault * @dev only the account owner or operator can mint an vToken, cannot be called when system is partiallyPaused or fullyPaused * @param wallet * @param vaultId * @param index * @param vToken * @param vTokenAmount * @param vaultType */ short(wallet: Wallet, vaultId: number, index: number, vToken: INativeVToken, vTokenAmount: BigNumber, vaultType?: VaultType): Promise<TransactionResponse>; /** * @notice redeem an vToken after expiry, receiving the payout of the vToken in the collateral asset * @dev cannot be called when system is fullyPaused * @param wallet * @param vToken * @param vTokenAmount */ redeem(wallet: Wallet, vToken: Pick<INativeVToken, 'address'>, vTokenAmount: BigNumber): Promise<TransactionResponse>; /** * @notice settle a vault after expiry, removing the net proceeds/collateral after both long and short vToken payouts have settled * @dev deletes a vault of vaultId after net proceeds/collateral is removed, cannot be called when system is fullyPaused * @param wallet * @param vaultId * @param vault */ settle(wallet: Wallet, vaultId: number, vault?: Partial<INativeVault>): Promise<TransactionResponse>; /** * @notice liquidate naked margin vault * @dev can liquidate different vaults id in the same operate() call * @param wallet * @param ownerAddress * @param vaultId * @param vTokenAmount */ liquidate(wallet: Wallet, ownerAddress: Address, vaultId: number, vTokenAmount: BigNumber): Promise<TransactionResponse>; /** * @notice deposit a collateral asset into a vault * @dev only the account owner or operator can deposit collateral, cannot be called when system is partiallyPaused or fullyPaused * @param owner * @param vaultId * @param index * @param collateralAddress * @param collateralAmount */ depositCollateral(owner: Wallet, vaultId: number, index: number, collateralAddress: Address, collateralAmount: BigNumber): Promise<TransactionResponse>; /** * @notice withdraw a collateral asset from a vault * @dev only the account owner or operator can withdraw collateral, cannot be called when system is partiallyPaused or fullyPaused * @param owner * @param vaultId * @param index * @param collateralAddress * @param collateralAmount */ withdrawCollateral(owner: Wallet, vaultId: number, index: number, collateralAddress: Address, collateralAmount: BigNumber): Promise<TransactionResponse>; /** * @notice deposit a long vToken into a vault * @dev only the account owner or operator can deposit a long vToken, cannot be called when system is partiallyPaused or fullyPaused * @param owner * @param vaultId * @param index * @param vToken * @param vTokenAmount */ depositLong(owner: Wallet, vaultId: number, index: number, vToken: Pick<INativeVToken, 'address'>, vTokenAmount: BigNumber): Promise<TransactionResponse>; /** * @notice withdraw a long vToken from a vault * @dev only the account owner or operator can withdraw a long vToken, cannot be called when system is partiallyPaused or fullyPaused * @param owner * @param vaultId * @param index * @param vToken * @param vTokenAmount */ withdrawLong(owner: Wallet, vaultId: number, index: number, vToken: Pick<INativeVToken, 'address'>, vTokenAmount: BigNumber): Promise<TransactionResponse>; private v; private shortOptionOp; private settleVaultOp; private redeemOp; private liquidateOp; private depositOp; private withdrawOp; }