@volare.finance/volare.js
Version:
The SDK for Volare Protocol
63 lines (62 loc) • 3.93 kB
TypeScript
/**
* @file vanilla.ts
* @author astra <astra@volare.finance>
* @date 2022
*/
import { TransactionResponse } from '@ethersproject/providers';
import { Address, BigNumber, Provider } from '@volare.finance/utils.js';
import { Wallet } from 'ethers';
import { IVolareAddress } from './contracts';
import { Controller } from './Controller';
import { MarginCalculator } from './MarginCalculator';
import { OracleV2 } from './OracleV2';
import { INativeVault, INativeVToken, VaultType } from './protocols';
import { Whitelist } from './Whitelist';
export interface VanillaOptions {
endpoint: string;
contracts: IVolareAddress;
}
export declare class Vanilla extends Provider {
oracle: OracleV2;
whitelist: Whitelist;
marginCalculator: MarginCalculator;
controller: Controller;
constructor(options: VanillaOptions);
isWhitelistedVToken(vTokenAddress: Address): Promise<boolean>;
getPrice(assetAddress: Address): Promise<BigNumber>;
getExpiryPrice(assetAddress: Address, expiryTimestamp: number): Promise<BigNumber>;
/***
* @description calculate required collateral margin for a vault
* @param ownerAddress
* @param vaultId
* @param vaultType
* @return the vault collateral amount,
* and marginRequired the minimal amount of collateral needed in a vault, scaled to 1e27
*/
getMarginRequired(ownerAddress: Address, vaultId: number, vaultType: VaultType): Promise<[BigNumber, BigNumber]>;
/**
* @notice returns the amount of collateral that can be removed from an actual or a theoretical vault
* @dev return amount is denominated in the collateral asset for the vToken in the vault, or the collateral asset in the vault
* @param ownerAddress
* @param vaultId theoretical vault that needs to be checked
* @param vaultType vault type (0 for spread/max loss, 1 for naked margin)
* @return excessCollateral the amount by which the margin is above or below the required amount
* @return isExcess True if there is excess margin in the vault, False if there is a deficit of margin in the vault
* if True, collateral can be taken out from the vault, if False, additional collateral needs to be added to vault
*/
getExcessCollateral(ownerAddress: Address, vaultId: number, vaultType: VaultType): Promise<[BigNumber, boolean]>;
getNakedCap(assetAddress: Address): Promise<BigNumber>;
getNakedPoolBalance(assetAddress: Address): Promise<BigNumber>;
getPayout(vTokenAddress: Address, vTokenAmount: BigNumber): Promise<BigNumber>;
getAccountVaultCounter(ownerAddress: Address): Promise<number>;
getVault(ownerAddress: Address, vaultId: number): Promise<INativeVault>;
getVaultWithDetails(ownerAddress: Address, vaultId: number): Promise<[INativeVault, VaultType, number]>;
short(writer: Wallet, vaultId: number, index: number, vToken: INativeVToken, vTokenAmount: BigNumber, vaultType?: VaultType): Promise<TransactionResponse>;
redeem(owner: Wallet, vToken: Pick<INativeVToken, 'address'>, vTokenAmount: BigNumber): Promise<TransactionResponse>;
settle(writer: Wallet, vaultId: number): Promise<TransactionResponse>;
liquidate(wallet: Wallet, ownerAddress: Address, vaultId: number, vTokenAmount: BigNumber): Promise<TransactionResponse>;
depositCollateral(owner: Wallet, vaultId: number, index: number, collateralAddress: Address, collateralAmount: BigNumber): Promise<TransactionResponse>;
withdrawCollateral(owner: Wallet, vaultId: number, index: number, collateralAddress: Address, collateralAmount: BigNumber): Promise<TransactionResponse>;
depositLong(owner: Wallet, vaultId: number, index: number, vToken: Pick<INativeVToken, 'address'>, vTokenAmount: BigNumber): Promise<TransactionResponse>;
withdrawLong(owner: Wallet, vaultId: number, index: number, vToken: Pick<INativeVToken, 'address'>, vTokenAmount: BigNumber): Promise<TransactionResponse>;
}