UNPKG

@dolomite-exchange/dolomite-margin

Version:

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

45 lines 2.39 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.IsolationModeWrapper = void 0; const BytesHelper_1 = require("../lib/BytesHelper"); const bignumber_js_1 = __importDefault(require("bignumber.js")); class IsolationModeWrapper { constructor(contracts, unwrapperContract) { this.contracts = contracts; this.wrapperContract = unwrapperContract; } get address() { return this.wrapperContract.options.address; } async token() { return this.contracts.callConstantContractFunction(this.wrapperContract.methods.token()); } async actionsLength() { const result = await this.contracts.callConstantContractFunction(this.wrapperContract.methods.actionsLength()); return new bignumber_js_1.default(result); } async createActionsForWrapping(solidAccountId, liquidAccountId, solidAccountOwner, solidAccountNumber, liquidAccountOwner, liquidAccountNumber, outputMarket, inputMarket, minOutputAmount, inputAmount, orderDataHexString) { return this.contracts.callConstantContractFunction(this.wrapperContract.methods.createActionsForWrapping({ primaryAccountId: solidAccountId.toFixed(), otherAccountId: liquidAccountId.toFixed(), primaryAccountOwner: solidAccountOwner, primaryAccountNumber: solidAccountNumber.toFixed(), otherAccountOwner: liquidAccountOwner, otherAccountNumber: liquidAccountNumber.toFixed(), outputMarket: outputMarket.toFixed(), inputMarket: inputMarket.toFixed(), minOutputAmount: minOutputAmount.toFixed(), inputAmount: inputAmount.toFixed(), orderData: BytesHelper_1.toBytesNoPadding(orderDataHexString), })); } async getExchangeCost(makerToken, takerToken, desiredMakerToken, orderData) { const result = await this.contracts.callConstantContractFunction(this.wrapperContract.methods.getExchangeCost(makerToken, takerToken, desiredMakerToken.toFixed(), BytesHelper_1.hexStringToBytes(orderData))); return new bignumber_js_1.default(result); } } exports.IsolationModeWrapper = IsolationModeWrapper; //# sourceMappingURL=IsolationModeWrapper.js.map