UNPKG

@volare.finance/volare.js

Version:
42 lines 1.96 kB
"use strict"; /** * @file margin.calculator.ts * @author astra <astra@volare.finance> * @date 2022 */ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const utils_js_1 = require("@volare.finance/utils.js"); const dotenv_1 = require("dotenv"); const ethers_1 = require("ethers"); const src_1 = require("../../src"); (0, dotenv_1.config)({ path: '.env', encoding: 'utf8', }); const CHAIN_ID = Number(process.env.CHAIN_ID); const ENDPOINT = String(process.env.ENDPOINT); const DEPLOYER_PRIVATE_KEY = String(process.env.DEPLOYER_PRIVATE_KEY); const VTOKEN_ADDRESS = String(process.env.VTOKEN_ADDRESS); const Addresses = (0, src_1.getContractsForChain)(CHAIN_ID); const Provider = new ethers_1.providers.JsonRpcProvider(ENDPOINT); const Deployer = new ethers_1.Wallet(DEPLOYER_PRIVATE_KEY, Provider); const calculator = new src_1.MarginCalculator(Addresses.MarginCalculator, ENDPOINT); (() => tslib_1.__awaiter(void 0, void 0, void 0, function* () { const vToken = yield (0, src_1.cVTokenDetails)(VTOKEN_ADDRESS); let tx; // SpotShock tx = yield calculator.setSpotShock(Deployer, vToken, new utils_js_1.BigNumber(1)); yield tx.wait(); const spotShock = yield calculator.getSpotShock(vToken); console.log(`calculator.getSpotShock(vToken): ${spotShock}`); // UpperBoundValue const timesToExpiryForProduct = yield calculator.getTimesToExpiry(vToken); for (let i = 0; i < timesToExpiryForProduct.length; i++) { tx = yield calculator.updateUpperBoundValue(Deployer, vToken, timesToExpiryForProduct[i], new utils_js_1.BigNumber(0.2)); yield tx.wait(); const maxPriceAtTimeToExpiry = yield calculator.getMaxPrice(vToken, timesToExpiryForProduct[i]); console.log(`calculator.getMaxPrice(vToken, timesToExpiryForProduct[i]): ${timesToExpiryForProduct} ${maxPriceAtTimeToExpiry}`); } }))(); //# sourceMappingURL=margin.calculator.js.map