@dolomite-exchange/dolomite-margin
Version:
Ethereum Smart Contracts and TypeScript library used for the DolomiteMargin trading protocol
40 lines • 1.72 kB
JavaScript
;
// noinspection JSUnusedGlobalSymbols
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MultiCall = void 0;
const BytesHelper_1 = require("../lib/BytesHelper");
const bignumber_js_1 = __importDefault(require("bignumber.js"));
class MultiCall {
constructor(contracts) {
this.contracts = contracts;
}
async getCurrentBlockTimestamp() {
const transaction = !this.contracts.multiCall.options.address
? this.contracts.arbitrumMultiCall.methods.getCurrentBlockTimestamp()
: this.contracts.multiCall.methods.getCurrentBlockTimestamp();
const result = await this.contracts.callConstantContractFunction(transaction);
return new bignumber_js_1.default(result);
}
async aggregate(calls, options) {
const rawCalls = calls.map(({ target, callData }) => {
return {
target,
callData: BytesHelper_1.hexStringToBytes(callData),
};
});
const transaction = !this.contracts.multiCall.options.address
? this.contracts.arbitrumMultiCall.methods.aggregate(rawCalls)
: this.contracts.multiCall.methods.aggregate(rawCalls);
const result = await this.contracts.callConstantContractFunction(transaction, options);
// result.returnData is actually string[], not string[][]
return {
blockNumber: parseInt(result.blockNumber, 10),
results: result.returnData,
};
}
}
exports.MultiCall = MultiCall;
//# sourceMappingURL=MultiCall.js.map