@nexex/api
Version:
support trade on nexex network
52 lines • 2.02 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var ethers_1 = require("ethers");
var formatUnits = ethers_1.utils.formatUnits, parseUnits = ethers_1.utils.parseUnits;
var AmountUnit;
(function (AmountUnit) {
AmountUnit["WEI"] = "wei";
AmountUnit["DISPLAY"] = "display";
})(AmountUnit = exports.AmountUnit || (exports.AmountUnit = {}));
var Amount = /** @class */ (function (_super) {
__extends(Amount, _super);
function Amount(value, decimals, unit) {
if (decimals === void 0) { decimals = 18; }
if (unit === void 0) { unit = AmountUnit.WEI; }
var _this = this;
if (unit === AmountUnit.DISPLAY) {
_this = _super.call(this, parseUnits(String(value), decimals)) || this;
}
else {
_this = _super.call(this, value) || this;
}
_this.decimals = decimals;
return _this;
}
Amount.prototype.toDisplay = function () {
return formatUnits(this, this.decimals);
};
Amount.prototype.add = function (other) {
var ret = _super.prototype.add.call(this, other);
return new Amount(ret, this.decimals);
};
Amount.prototype.sub = function (other) {
var ret = _super.prototype.sub.call(this, other);
return new Amount(ret, this.decimals);
};
return Amount;
}(ethers_1.utils.BigNumber));
exports.Amount = Amount;
//# sourceMappingURL=Amount.js.map