@typus/typus-sdk 1.2.79 → 1.2.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -84,6 +84,7 @@ var vault_1 = require("./vault");
|
|
|
84
84
|
var token_1 = require("./token");
|
|
85
85
|
var tools_1 = require("../../tools");
|
|
86
86
|
var view_function_2 = require("../../auto-bid/view-function");
|
|
87
|
+
var token_2 = require("../../token");
|
|
87
88
|
var PriceDecimal = (0, bignumber_js_1.default)(10).pow(8);
|
|
88
89
|
exports.tokenOrder = {
|
|
89
90
|
// Basically it's a to z but put SUI at first
|
|
@@ -210,7 +211,7 @@ exports.calcBreakEvenPrice = calcBreakEvenPrice;
|
|
|
210
211
|
var calcEstPnl = function (live, incentive, bidSize, optionType, assets, strikes, bidShare, deliveryPrice, oTokenPrice) {
|
|
211
212
|
var profit = "0";
|
|
212
213
|
var cost = "0";
|
|
213
|
-
var _a = __read(assets, 3), dToken = _a[0], bToken = _a[1], oToken = _a[2];
|
|
214
|
+
var _a = __read((0, token_2.typeArgsToAssets)(assets), 3), dToken = _a[0], bToken = _a[1], oToken = _a[2];
|
|
214
215
|
var dTokenWrappedName = (0, token_1.getTokenName)({ token: dToken, wrapped: true });
|
|
215
216
|
var bTokenWrappedName = (0, token_1.getTokenName)({ token: bToken, wrapped: true });
|
|
216
217
|
var estPnls = [];
|
|
@@ -249,7 +250,7 @@ var calcEstPnl = function (live, incentive, bidSize, optionType, assets, strikes
|
|
|
249
250
|
if (!live) {
|
|
250
251
|
estPnls.push({
|
|
251
252
|
value: profit,
|
|
252
|
-
token:
|
|
253
|
+
token: assets[1],
|
|
253
254
|
});
|
|
254
255
|
if (dToken !== bToken) {
|
|
255
256
|
estPnls.push({ value: "-" + cost, token: bTokenWrappedName });
|
|
@@ -270,6 +271,9 @@ var parseStrikes = function (period, optionType, metadata) {
|
|
|
270
271
|
break;
|
|
271
272
|
case "4":
|
|
272
273
|
strikes = [metadata.split("-")[2], metadata.split("-")[3]];
|
|
274
|
+
if (period == "3") {
|
|
275
|
+
strikes = [metadata.split("-")[3], metadata.split("-")[4]];
|
|
276
|
+
}
|
|
273
277
|
strikes = strikes.sort(function (a, b) { return Number(a) - Number(b); });
|
|
274
278
|
break;
|
|
275
279
|
case "5":
|
|
@@ -327,7 +331,7 @@ var parseBidReceipt = function (vaults, bidReceipts) {
|
|
|
327
331
|
exports.parseBidReceipt = parseBidReceipt;
|
|
328
332
|
var parseBid = function (bidVaultInfo, bidShare, auction, oTokenPrice, isAutoBid) {
|
|
329
333
|
var _a, _b;
|
|
330
|
-
var vaultInfo = bidVaultInfo.vaultInfo, _c = bidVaultInfo.vaultInfo, info = _c.info, _d = _c.info, index = _d.index, bTokenDecimal = _d.bTokenDecimal, oTokenDecimal = _d.oTokenDecimal, optionType = _d.optionType, period = _d.period, _e = _c.config, lotSize = _e.bidLotSize, bidIncentiveBp = _e.bidIncentiveBp, u64Padding = _e.u64Padding, receipt = bidVaultInfo.receipt;
|
|
334
|
+
var vaultInfo = bidVaultInfo.vaultInfo, _c = bidVaultInfo.vaultInfo, info = _c.info, _d = _c.info, index = _d.index, bTokenDecimal = _d.bTokenDecimal, oTokenDecimal = _d.oTokenDecimal, optionType = _d.optionType, period = _d.period, depositToken = _d.depositToken, bidToken = _d.bidToken, settlementBase = _d.settlementBase, _e = _c.config, lotSize = _e.bidLotSize, bidIncentiveBp = _e.bidIncentiveBp, u64Padding = _e.u64Padding, receipt = bidVaultInfo.receipt;
|
|
331
335
|
var incentiveRate = (0, exports.calcIncentiveRate)(bidIncentiveBp);
|
|
332
336
|
var _f = __read((0, vault_1.parseAssets)(info), 3), dToken = _f[0], bToken = _f[1], oToken = _f[2];
|
|
333
337
|
var oTokenName = (0, token_1.getTokenName)({ token: oToken });
|
|
@@ -357,7 +361,7 @@ var parseBid = function (bidVaultInfo, bidShare, auction, oTokenPrice, isAutoBid
|
|
|
357
361
|
var defaultMinBidSize = (0, bignumber_js_1.default)(lotSize).div((0, bignumber_js_1.default)(10).pow(oTokenDecimal));
|
|
358
362
|
var bidSize = bidsSize.toFixed((0, tools_1.countFloating)(defaultMinBidSize.toNumber()));
|
|
359
363
|
var settlePrice = (0, bignumber_js_1.default)((_b = bidShare.bidVault.u64Padding[0]) !== null && _b !== void 0 ? _b : "0").div(PriceDecimal);
|
|
360
|
-
var estPnls = (0, exports.calcEstPnl)(live, incentiveRate, bidSize, optionType, [
|
|
364
|
+
var estPnls = (0, exports.calcEstPnl)(live, incentiveRate, bidSize, optionType, [depositToken, bidToken, settlementBase], strikes, bidShare, deliveryPrice.toString(), oTokenPrice);
|
|
361
365
|
return {
|
|
362
366
|
vaultIndex: index,
|
|
363
367
|
auctionName: "".concat(tokenLabel, " ").concat(periodLabel, " ").concat(optionTypeLabel),
|
|
@@ -372,7 +376,7 @@ var parseBid = function (bidVaultInfo, bidShare, auction, oTokenPrice, isAutoBid
|
|
|
372
376
|
value: (0, bignumber_js_1.default)(bidSize)
|
|
373
377
|
.div((0, bignumber_js_1.default)(10).pow(oToken === "MFUD" ? 6 : 0))
|
|
374
378
|
.toString(),
|
|
375
|
-
token:
|
|
379
|
+
token: settlementBase,
|
|
376
380
|
},
|
|
377
381
|
breakEvenPrice: (0, bignumber_js_1.default)(breakEvenPrice)
|
|
378
382
|
.div((0, bignumber_js_1.default)(10).pow(oToken === "MFUD" ? 6 : 0))
|