UNPKG

@volare.finance/volare.js

Version:
232 lines 8.59 kB
"use strict"; /** * @file Addressbook.ts * @author astra <astra@volare.finance> * @date 2022 */ Object.defineProperty(exports, "__esModule", { value: true }); exports.Addressbook = void 0; const tslib_1 = require("tslib"); const solidity_1 = require("@ethersproject/solidity"); const utils_js_1 = require("@volare.finance/utils.js"); const ethers_1 = require("ethers"); const Addressbook_json_1 = require("../artifacts/Addressbook.json"); class Addressbook extends utils_js_1.Provider { static ABI() { return Addressbook_json_1.abi; } constructor(contract, endpoint) { super(endpoint); this.contract = new ethers_1.Contract(contract, Addressbook.ABI(), this.provider); } /** * @notice return Oracle address * @return Oracle address */ getOracle() { var _a; return tslib_1.__awaiter(this, void 0, void 0, function* () { return (_a = this.contract) === null || _a === void 0 ? void 0 : _a.getOracle(); }); } /** * @notice return VToken implementation address * @return VToken implementation address */ getVTokenImpl() { var _a; return tslib_1.__awaiter(this, void 0, void 0, function* () { return (_a = this.contract) === null || _a === void 0 ? void 0 : _a.getVTokenImpl(); }); } /** * @notice return vTokenFactory address * @return VTokenFactory address */ getVTokenFactory() { var _a; return tslib_1.__awaiter(this, void 0, void 0, function* () { return (_a = this.contract) === null || _a === void 0 ? void 0 : _a.getVTokenImpl(); }); } /** * @notice return Whitelist address * @return Whitelist address */ getWhitelist() { var _a; return tslib_1.__awaiter(this, void 0, void 0, function* () { return (_a = this.contract) === null || _a === void 0 ? void 0 : _a.getWhitelist(); }); } /** * @notice return MarginPool address * @return MarginPool address */ getMarginPool() { var _a; return tslib_1.__awaiter(this, void 0, void 0, function* () { return (_a = this.contract) === null || _a === void 0 ? void 0 : _a.getMarginPool(); }); } /** * @notice return MarginCalculator address * @return MarginCalculator address */ getMarginCalculator() { var _a; return tslib_1.__awaiter(this, void 0, void 0, function* () { return (_a = this.contract) === null || _a === void 0 ? void 0 : _a.getMarginCalculator(); }); } /** * @notice return LiquidationManager address * @return LiquidationManager address */ getLiquidationManager() { var _a; return tslib_1.__awaiter(this, void 0, void 0, function* () { return (_a = this.contract) === null || _a === void 0 ? void 0 : _a.getLiquidationManager(); }); } /** * @notice return Controller address * @return Controller address */ getController() { var _a; return tslib_1.__awaiter(this, void 0, void 0, function* () { return (_a = this.contract) === null || _a === void 0 ? void 0 : _a.getController(); }); } /** * @notice set Oracle address * @dev can only be called by the addressbook owner * @param owner Owner address * @param oracle Oracle address */ setOracle(owner, oracle) { var _a; return tslib_1.__awaiter(this, void 0, void 0, function* () { return (_a = this.contract) === null || _a === void 0 ? void 0 : _a.connect(owner).setOracle(oracle); }); } /** * @notice set VToken implementation address * @dev can only be called by the addressbook owner * @param owner Owner address * @param vTokenImpl VToken implementation address */ setVTokenImpl(owner, vTokenImpl) { var _a; return tslib_1.__awaiter(this, void 0, void 0, function* () { return (_a = this.contract) === null || _a === void 0 ? void 0 : _a.connect(owner).setVTokenImpl(vTokenImpl); }); } /** * @notice set VTokenFactory address * @dev can only be called by the addressbook owner * @param owner Owner address * @param vTokenFactory VTokenFactory address */ setVTokenFactory(owner, vTokenFactory) { var _a; return tslib_1.__awaiter(this, void 0, void 0, function* () { return (_a = this.contract) === null || _a === void 0 ? void 0 : _a.connect(owner).setVTokenFactory(vTokenFactory); }); } /** * @notice set Whitelist address * @dev can only be called by the addressbook owner * @param owner Owner address * @param whitelist Whitelist address */ setWhitelist(owner, whitelist) { var _a; return tslib_1.__awaiter(this, void 0, void 0, function* () { return (_a = this.contract) === null || _a === void 0 ? void 0 : _a.connect(owner).setWhitelist(whitelist); }); } /** * @notice set MarginPool address * @dev can only be called by the addressbook owner * @param owner Owner address * @param marginPool MarginPool address */ setMarginPool(owner, marginPool) { var _a; return tslib_1.__awaiter(this, void 0, void 0, function* () { return (_a = this.contract) === null || _a === void 0 ? void 0 : _a.connect(owner).setMarginPool(marginPool); }); } /** * @notice set MarginCalculator address * @dev can only be called by the addressbook owner * @param owner Owner address * @param marginCalculator MarginCalculator address */ setMarginCalculator(owner, marginCalculator) { var _a; return tslib_1.__awaiter(this, void 0, void 0, function* () { return (_a = this.contract) === null || _a === void 0 ? void 0 : _a.connect(owner).setMarginCalculator(marginCalculator); }); } /** * @notice set LiquidationManager address * @dev can only be called by the addressbook owner * @param owner Owner address * @param liquidationManager LiquidationManager address */ setLiquidationManager(owner, liquidationManager) { var _a; return tslib_1.__awaiter(this, void 0, void 0, function* () { return (_a = this.contract) === null || _a === void 0 ? void 0 : _a.connect(owner).setLiquidationManager(liquidationManager); }); } /** * @notice set Controller address * @dev can only be called by the addressbook owner * @param owner Owner address * @param controller Controller address */ setController(owner, controller) { var _a; return tslib_1.__awaiter(this, void 0, void 0, function* () { return (_a = this.contract) === null || _a === void 0 ? void 0 : _a.connect(owner).setController(controller); }); } /** * @notice return an address for specific key * @param key key address * @return address */ getAddress(key) { var _a; return tslib_1.__awaiter(this, void 0, void 0, function* () { return (_a = this.contract) === null || _a === void 0 ? void 0 : _a.getAddress(key); }); } /** * @notice set a specific address for a specific key * @dev can only be called by the addressbook owner * @param owner Owner address * @param key key * @param address address */ setAddress(owner, key, address) { var _a; return tslib_1.__awaiter(this, void 0, void 0, function* () { return (_a = this.contract) === null || _a === void 0 ? void 0 : _a.connect(owner).setAddress(key, address); }); } } exports.Addressbook = Addressbook; Addressbook.ORACLE = (0, solidity_1.keccak256)(['string'], ['ORACLE']); Addressbook.VTOKEN_IMPL = (0, solidity_1.keccak256)(['string'], ['VTOKEN_IMPL']); Addressbook.VTOKEN_FACTORY = (0, solidity_1.keccak256)(['string'], ['VTOKEN_FACTORY']); Addressbook.WHITELIST = (0, solidity_1.keccak256)(['string'], ['WHITELIST']); Addressbook.MARGIN_POOL = (0, solidity_1.keccak256)(['string'], ['MARGIN_POOL']); Addressbook.MARGIN_CALCULATOR = (0, solidity_1.keccak256)(['string'], ['MARGIN_CALCULATOR']); Addressbook.LIQUIDATION_MANAGER = (0, solidity_1.keccak256)(['string'], ['LIQUIDATION_MANAGER']); Addressbook.CONTROLLER = (0, solidity_1.keccak256)(['string'], ['CONTROLLER']); //# sourceMappingURL=Addressbook.js.map