zumokit
Version:
ZumoKit is a Wallet as a Service SDK
39 lines (38 loc) • 1.56 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Exchange = void 0;
var decimal_js_1 = require("decimal.js");
var Quote_1 = require("./Quote");
/** Exchange details. */
var Exchange = /** @class */ (function () {
/** @internal */
function Exchange(json) {
var _this = this;
this.json = json;
this.id = json.id;
this.status = json.status;
this.pair = json.pair;
this.side = json.side;
this.price = new decimal_js_1.Decimal(json.price);
this.amount = new decimal_js_1.Decimal(json.amount);
this.debitAccountId = json.debitAccountId;
this.debitTransactionId = json.debitTransactionId;
this.creditAccountId = json.creditAccountId;
this.creditTransactionId = json.creditTransactionId;
this.quote = new Quote_1.Quote(json.quote);
this.nonce = json.nonce;
this.createdAt = Math.round(new Date(json.createdAt).getTime() / 1000);
this.updatedAt = Math.round(new Date(json.updatedAt).getTime() / 1000);
// convert rates from strings to decimals
this.rates = {};
Object.keys(json.rates).forEach(function (fromCurrency) {
var innerMap = {};
Object.keys(json.rates[fromCurrency]).forEach(function (toCurrency) {
innerMap[toCurrency] = new decimal_js_1.Decimal(json.rates[fromCurrency][toCurrency]);
});
_this.rates[fromCurrency] = innerMap;
});
}
return Exchange;
}());
exports.Exchange = Exchange;