UNPKG

@dolomite-exchange/dolomite-margin

Version:

Ethereum Smart Contracts and TypeScript library used for the DolomiteMargin trading protocol

49 lines 2.46 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Expiry = void 0; const bignumber_js_1 = __importDefault(require("bignumber.js")); class Expiry { // ============ Constructor ============ constructor(contracts) { this.contracts = contracts; } // ============ Getters ============ get address() { return this.contracts.expiry.options.address; } async getExpiry(accountOwner, accountNumber, marketId, options) { const result = await this.contracts.callConstantContractFunction(this.contracts.expiry.methods.getExpiry({ owner: accountOwner, number: accountNumber.toFixed(0), }, marketId.toFixed(0)), options); return new bignumber_js_1.default(result); } async getApproval(approver, sender, options) { const result = await this.contracts.callConstantContractFunction(this.contracts.expiry.methods.g_approvedSender(approver, sender), options); return new bignumber_js_1.default(result); } async getPrices(liquidAccount, heldMarketId, owedMarketId, expiryTimestamp, options) { const result = await this.contracts.callConstantContractFunction(this.contracts.expiry.methods.getLiquidationSpreadAdjustedPrices(liquidAccount, heldMarketId.toFixed(0), owedMarketId.toFixed(0), expiryTimestamp.toFixed(0)), options); return { heldPrice: new bignumber_js_1.default(result[0].value), owedPrice: new bignumber_js_1.default(result[1].value), }; } async getRampTime(options) { const result = await this.contracts.callConstantContractFunction(this.contracts.expiry.methods.g_expiryRampTime(), options); return new bignumber_js_1.default(result); } // ============ Setters ============ async setApproval(sender, minTimeDelta, options) { return this.contracts.callContractFunction(this.contracts.expiry.methods.approveSender(sender, minTimeDelta.toFixed(0)), options); } // ============ Admin ============ async setExpiryRampTime(newExpiryRampTime, options) { return this.contracts.callContractFunction(this.contracts.expiry.methods.ownerSetExpiryRampTime(newExpiryRampTime.toFixed(0)), options); } } exports.Expiry = Expiry; //# sourceMappingURL=Expiry.js.map