@volare.finance/volare.js
Version:
The SDK for Volare Protocol
78 lines (77 loc) • 3.96 kB
TypeScript
/**
* @file MarginCalculator.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 declare class MarginCalculator extends Provider {
static ABI(): ContractInterface;
constructor(address: Address, endpoint: string);
/**
* @notice set spot shock value, scaled to 1e27
* @dev can only be called by owner
* @param owner
* @param vToken
* @param shockValue spot shock value
*/
setSpotShock(owner: Wallet, vToken: Pick<INativeVToken, 'underlyingAsset' | 'strikeAsset' | 'collateralAsset' | 'isPut'>, shockValue: BigNumber): Promise<TransactionResponse>;
/***
* @description calculate required collateral margin for a vault
* @param vToken
* @return shockValue spot shock value (1e27)
*/
getSpotShock(vToken: Pick<INativeVToken, 'underlyingAsset' | 'strikeAsset' | 'collateralAsset' | 'isPut'>): Promise<BigNumber>;
/**
* @notice set product upper bound values
* @dev can only be called by owner
* @param owner
* @param vToken
* @param timesToExpiry array of times to expiry timestamp
* @param values upper bound values array
*
*/
setUpperBoundValues(owner: Wallet, vToken: Pick<INativeVToken, 'underlyingAsset' | 'strikeAsset' | 'collateralAsset' | 'isPut'>, timesToExpiry: Array<number>, values: Array<BigNumber>): Promise<TransactionResponse>;
/**
* @notice set option upper bound value for specific time to expiry (1e27)
* @dev can only be called by owner
* @param owner
* @param vToken
* @param timeToExpiry option time to expiry timestamp
* @param value upper bound value
*/
updateUpperBoundValue(owner: Wallet, vToken: Pick<INativeVToken, 'underlyingAsset' | 'strikeAsset' | 'collateralAsset' | 'isPut'>, timeToExpiry: number, value: BigNumber): Promise<TransactionResponse>;
/**
* @notice get times to expiry for a specific product
* @param vToken
* @return array of times to expiry
*/
getTimesToExpiry(vToken: Pick<INativeVToken, 'underlyingAsset' | 'strikeAsset' | 'collateralAsset' | 'isPut'>): Promise<Array<number>>;
/**
* @notice get option upper bound value for specific time to expiry
* @param vToken
* @param timeToExpiry option time to expiry timestamp
* @return option upper bound value (1e27)
*/
getMaxPrice(vToken: Pick<INativeVToken, 'underlyingAsset' | 'strikeAsset' | 'collateralAsset' | 'isPut'>, timeToExpiry: number): Promise<BigNumber>;
/***
* @description calculate required collateral margin for a vault
* @param vault
* @param vaultType
* @return the vault collateral amount,
* and marginRequired the minimal amount of collateral needed in a vault, scaled to 1e27
*/
getMarginRequired(vault: INativeVault, 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 vault 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(vault: INativeVault, vaultType: VaultType): Promise<[BigNumber, boolean]>;
}