@typus/typus-sdk 1.4.75 → 1.4.77

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.
@@ -1,7 +1,7 @@
1
1
  import { Auction, BidShare, Vault } from "../../../src/typus-dov-single-v2";
2
2
  import { PublicKey } from "@solana/web3.js";
3
3
  import { PriceData } from "@pythnetwork/client";
4
- import { SuiClient } from "@mysten/sui.js/client";
4
+ import { SuiClient, SuiObjectResponse } from "@mysten/sui.js/client";
5
5
  import BigNumber from "bignumber.js";
6
6
  import { TypusConfig } from "../../../src/utils";
7
7
  export declare const ASSET_INFO: {
@@ -142,9 +142,8 @@ export declare const parseBidReceipt: (vaults: Vault[], bidReceipts: {
142
142
  bidVaultsInfo: BidVaultInfo[];
143
143
  };
144
144
  export declare const parseBid: (bidVaultInfo: BidVaultInfo, bidShare: BidShare, auction: Auction | null, oTokenPrice: string, isAutoBid: boolean) => Bid & OrderBy;
145
- export declare const getUserBidReceipts: (config: TypusConfig, input: {
146
- user: string;
147
- }) => Promise<{
145
+ export declare function getUserOwnedObjects(config: TypusConfig, user: string): Promise<SuiObjectResponse[]>;
146
+ export declare const getUserBidReceipts: (config: TypusConfig, data: SuiObjectResponse[]) => Promise<{
148
147
  [key: string]: Receipt[];
149
148
  }>;
150
149
  /**
@@ -161,6 +160,10 @@ export declare const getUserBidReceipts: (config: TypusConfig, input: {
161
160
  * @param prices - tokens prices (usd pair on Pyth)
162
161
  * @return User Bids.
163
162
  */
164
- export declare const fetchUserBids: (config: TypusConfig, user: string, prices?: {
163
+ export declare function fetchUserBids(config: TypusConfig, user: string, vaultsInfo: {
164
+ [key: string]: Vault;
165
+ }, userReceipts: {
166
+ [key: string]: Receipt[];
167
+ }, prices?: {
165
168
  [key: string]: CoinInfo;
166
- }) => Promise<any>;
169
+ }): Promise<any>;
@@ -86,7 +86,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
86
86
  return (mod && mod.__esModule) ? mod : { "default": mod };
87
87
  };
88
88
  Object.defineProperty(exports, "__esModule", { value: true });
89
- exports.fetchUserBids = exports.getUserBidReceipts = exports.parseBid = exports.parseBidReceipt = exports.parseStrikes = exports.calcEstPnl = exports.calcBreakEvenPrice = exports.calcDeliveryPrice = exports.calcIncentiveRate = exports.fetchPrices = exports.parsePythOracleData = exports.IncentiveRateBp = exports.periodOrder = exports.optionTypeOrder = exports.tokenOrder = exports.ASSET_INFO = void 0;
89
+ exports.getUserBidReceipts = exports.parseBid = exports.parseBidReceipt = exports.parseStrikes = exports.calcEstPnl = exports.calcBreakEvenPrice = exports.calcDeliveryPrice = exports.calcIncentiveRate = exports.fetchPrices = exports.parsePythOracleData = exports.IncentiveRateBp = exports.periodOrder = exports.optionTypeOrder = exports.tokenOrder = exports.ASSET_INFO = void 0;
90
+ exports.getUserOwnedObjects = getUserOwnedObjects;
91
+ exports.fetchUserBids = fetchUserBids;
90
92
  var vault_1 = require("./vault");
91
93
  var typus_dov_single_v2_1 = require("../../../src/typus-dov-single-v2");
92
94
  var utils_1 = require("../../../src/utils");
@@ -270,7 +272,7 @@ var parsePythOracleData = function (data, decimals) {
270
272
  };
271
273
  exports.parsePythOracleData = parsePythOracleData;
272
274
  var fetchPrices = function (provider, config) { return __awaiter(void 0, void 0, void 0, function () {
273
- var oracleDecimal, PYTHNET_CLUSTER_NAME, connection, pythPublicKey, pythClient, priceData, prices, mblub;
275
+ var oracleDecimal, PYTHNET_CLUSTER_NAME, connection, pythPublicKey, pythClient, priceData, prices, mblub, typus;
274
276
  return __generator(this, function (_a) {
275
277
  switch (_a.label) {
276
278
  case 0:
@@ -286,7 +288,10 @@ var fetchPrices = function (provider, config) { return __awaiter(void 0, void 0,
286
288
  return [4 /*yield*/, (0, utils_1.getLatestPrice)("MBLUBUSDC")];
287
289
  case 2:
288
290
  mblub = _a.sent();
289
- return [2 /*return*/, __assign({ mblub: { price: mblub.toString(), decimal: "8", quote: "usd" } }, prices)];
291
+ return [4 /*yield*/, (0, utils_1.getLatestPrice)("TYPUSUSDC")];
292
+ case 3:
293
+ typus = _a.sent();
294
+ return [2 /*return*/, __assign({ mblub: { price: mblub.toString(), decimal: "8", quote: "usd" }, typus: { price: typus.toString(), decimal: "8", quote: "usd" } }, prices)];
290
295
  }
291
296
  });
292
297
  }); };
@@ -560,80 +565,91 @@ var parseBid = function (bidVaultInfo, bidShare, auction, oTokenPrice, isAutoBid
560
565
  };
561
566
  };
562
567
  exports.parseBid = parseBid;
563
- var getUserBidReceipts = function (config, input) { return __awaiter(void 0, void 0, void 0, function () {
564
- var provider, bidReceipts, result, hasNextPage, data, nextCursor, data_1, data_1_1, object, content, typeStringComponents, subtype, typeComponents, type, typePackage, vaultIndex, receipt;
568
+ function getUserOwnedObjects(config, user) {
569
+ return __awaiter(this, void 0, void 0, function () {
570
+ var provider, result, hasNextPage, data, nextCursor;
571
+ return __generator(this, function (_a) {
572
+ switch (_a.label) {
573
+ case 0:
574
+ provider = new client_2.SuiClient({ url: config.rpcEndpoint });
575
+ return [4 /*yield*/, provider.getOwnedObjects({ owner: user, options: { showType: true, showContent: true } })];
576
+ case 1:
577
+ result = _a.sent();
578
+ hasNextPage = result.hasNextPage;
579
+ data = result.data;
580
+ nextCursor = result.nextCursor;
581
+ _a.label = 2;
582
+ case 2:
583
+ if (!hasNextPage) return [3 /*break*/, 4];
584
+ return [4 /*yield*/, provider.getOwnedObjects({
585
+ owner: user,
586
+ cursor: nextCursor,
587
+ options: { showType: true, showContent: true },
588
+ })];
589
+ case 3:
590
+ result = _a.sent();
591
+ data = __spreadArray(__spreadArray([], __read(data), false), __read(result.data), false);
592
+ hasNextPage = result.hasNextPage;
593
+ nextCursor = result.nextCursor;
594
+ return [3 /*break*/, 2];
595
+ case 4: return [2 /*return*/, data];
596
+ }
597
+ });
598
+ });
599
+ }
600
+ var getUserBidReceipts = function (config, data) { return __awaiter(void 0, void 0, void 0, function () {
601
+ var bidReceipts, data_1, data_1_1, object, content, typeStringComponents, subtype, typeComponents, type, typePackage, vaultIndex, receipt;
565
602
  var e_1, _a;
566
603
  return __generator(this, function (_b) {
567
- switch (_b.label) {
568
- case 0:
569
- provider = new client_2.SuiClient({ url: config.rpcEndpoint });
570
- bidReceipts = {};
571
- return [4 /*yield*/, provider.getOwnedObjects({ owner: input.user, options: { showType: true, showContent: true } })];
572
- case 1:
573
- result = _b.sent();
574
- hasNextPage = result.hasNextPage;
575
- data = result.data;
576
- nextCursor = result.nextCursor;
577
- _b.label = 2;
578
- case 2:
579
- if (!hasNextPage) return [3 /*break*/, 4];
580
- return [4 /*yield*/, provider.getOwnedObjects({ owner: input.user, cursor: nextCursor, options: { showType: true, showContent: true } })];
581
- case 3:
582
- result = _b.sent();
583
- data = __spreadArray(__spreadArray([], __read(data), false), __read(result.data), false);
584
- hasNextPage = result.hasNextPage;
585
- nextCursor = result.nextCursor;
586
- return [3 /*break*/, 2];
587
- case 4:
588
- if (data.length === 0) {
589
- return [2 /*return*/, bidReceipts];
590
- }
604
+ bidReceipts = {};
605
+ if (data.length === 0) {
606
+ return [2 /*return*/, bidReceipts];
607
+ }
608
+ try {
609
+ for (data_1 = __values(data), data_1_1 = data_1.next(); !data_1_1.done; data_1_1 = data_1.next()) {
610
+ object = data_1_1.value;
591
611
  try {
592
- for (data_1 = __values(data), data_1_1 = data_1.next(); !data_1_1.done; data_1_1 = data_1.next()) {
593
- object = data_1_1.value;
594
- try {
595
- content = (object.data || {}).content;
596
- if (!content)
597
- continue;
598
- typeStringComponents = (content.type || "").split("<");
599
- subtype = (typeStringComponents[1] || "").replace(/>/, "");
600
- typeComponents = typeStringComponents[0].split("::");
601
- type = typeComponents[typeComponents.length - 1];
602
- typePackage = typeComponents[0];
603
- if (type === "TypusBidReceipt" && config.packageOrigin.framework == typePackage) {
604
- vaultIndex = content.fields.index;
605
- receipt = {
606
- // @ts-ignore
607
- id: content.fields.id.id,
608
- // @ts-ignore
609
- index: vaultIndex,
610
- // @ts-ignore
611
- name: content.fields.name,
612
- // @ts-ignore
613
- description: content.fields.description,
614
- // @ts-ignore
615
- vid: content.fields.vid,
616
- // @ts-ignore
617
- metadata: content.fields.metadata,
618
- };
619
- bidReceipts[vaultIndex] || (bidReceipts[vaultIndex] = []);
620
- bidReceipts[vaultIndex].push(receipt);
621
- }
622
- }
623
- catch (e) {
624
- console.log("Error retrieving object", object, e);
625
- }
612
+ content = (object.data || {}).content;
613
+ if (!content)
614
+ continue;
615
+ typeStringComponents = (content.type || "").split("<");
616
+ subtype = (typeStringComponents[1] || "").replace(/>/, "");
617
+ typeComponents = typeStringComponents[0].split("::");
618
+ type = typeComponents[typeComponents.length - 1];
619
+ typePackage = typeComponents[0];
620
+ if (type === "TypusBidReceipt" && config.packageOrigin.framework == typePackage) {
621
+ vaultIndex = content.fields.index;
622
+ receipt = {
623
+ // @ts-ignore
624
+ id: content.fields.id.id,
625
+ // @ts-ignore
626
+ index: vaultIndex,
627
+ // @ts-ignore
628
+ name: content.fields.name,
629
+ // @ts-ignore
630
+ description: content.fields.description,
631
+ // @ts-ignore
632
+ vid: content.fields.vid,
633
+ // @ts-ignore
634
+ metadata: content.fields.metadata,
635
+ };
636
+ bidReceipts[vaultIndex] || (bidReceipts[vaultIndex] = []);
637
+ bidReceipts[vaultIndex].push(receipt);
626
638
  }
627
639
  }
628
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
629
- finally {
630
- try {
631
- if (data_1_1 && !data_1_1.done && (_a = data_1.return)) _a.call(data_1);
632
- }
633
- finally { if (e_1) throw e_1.error; }
640
+ catch (e) {
641
+ console.log("Error retrieving object", object, e);
634
642
  }
635
- return [2 /*return*/, bidReceipts];
643
+ }
636
644
  }
645
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
646
+ finally {
647
+ try {
648
+ if (data_1_1 && !data_1_1.done && (_a = data_1.return)) _a.call(data_1);
649
+ }
650
+ finally { if (e_1) throw e_1.error; }
651
+ }
652
+ return [2 /*return*/, bidReceipts];
637
653
  });
638
654
  }); };
639
655
  exports.getUserBidReceipts = getUserBidReceipts;
@@ -651,165 +667,160 @@ exports.getUserBidReceipts = getUserBidReceipts;
651
667
  * @param prices - tokens prices (usd pair on Pyth)
652
668
  * @return User Bids.
653
669
  */
654
- var fetchUserBids = function (config, user, prices) { return __awaiter(void 0, void 0, void 0, function () {
655
- var provider, vaultsInfo, userReceipts, userStrategies, auctions, _a, sortedBidReceipts, bidVaultsInfo, bidShares, bidsFromBidShares, _loop_1, bidVaultsInfo_1, bidVaultsInfo_1_1, bidVaultInfo, autoBidsShares, vaultAutoBidReceipts, userStrategies_1, userStrategies_1_1, strategy, receipts, receipts_1, receipts_1_1, receiptItem, vaultIndex, receipt, autoBidVaultInfos, bidsFromStrategies, _loop_2, autoBidVaultInfos_1, autoBidVaultInfos_1_1, autoBidVaultInfo, byOrdered;
656
- var e_2, _b, e_3, _c, e_4, _d, e_5, _e;
657
- return __generator(this, function (_f) {
658
- switch (_f.label) {
659
- case 0:
660
- provider = new client_2.SuiClient({ url: config.rpcEndpoint });
661
- return [4 /*yield*/, (0, typus_dov_single_v2_1.getVaults)(config, { indexes: [] })];
662
- case 1:
663
- vaultsInfo = _f.sent();
664
- return [4 /*yield*/, (0, exports.getUserBidReceipts)(config, { user: user })];
665
- case 2:
666
- userReceipts = _f.sent();
667
- return [4 /*yield*/, (0, auto_bid_1.getUserStrategies)(config, { user: user })];
668
- case 3:
669
- userStrategies = _f.sent();
670
- return [4 /*yield*/, (0, typus_dov_single_v2_1.getAuctions)(config, { indexes: [] })];
671
- case 4:
672
- auctions = _f.sent();
673
- if (!(typeof prices === "undefined")) return [3 /*break*/, 6];
674
- return [4 /*yield*/, (0, exports.fetchPrices)(provider, config)];
675
- case 5:
676
- prices = _f.sent();
677
- _f.label = 6;
678
- case 6:
679
- _a = (0, exports.parseBidReceipt)(Object.values(vaultsInfo), userReceipts), sortedBidReceipts = _a.sortedBidReceipts, bidVaultsInfo = _a.bidVaultsInfo;
680
- return [4 /*yield*/, (0, typus_dov_single_v2_1.getMyBids)(config, { receipts: sortedBidReceipts })];
681
- case 7:
682
- bidShares = _f.sent();
683
- bidsFromBidShares = [];
684
- _loop_1 = function (bidVaultInfo) {
685
- var bidShare = bidShares["".concat(bidVaultInfo.receipt.index, "-").concat(bidVaultInfo.receipt.vid)];
686
- var auction = auctions ? auctions[bidVaultInfo.vaultInfo.info.index] : null;
687
- var _g = __read((0, vault_1.parseAssets)(bidVaultInfo.vaultInfo.info), 3), dToken = _g[0], bToken = _g[1], oToken = _g[2];
688
- if (bidShare) {
689
- var price = (0, bignumber_js_1.default)(prices[oToken.toLowerCase()].price)
690
- .div((0, bignumber_js_1.default)(10).pow(prices[oToken.toLowerCase()].decimal))
691
- .toString();
692
- var data = (0, exports.parseBid)(bidVaultInfo, bidShare, auction, price, false);
693
- var checkExistVault = bidsFromBidShares.find(function (p) { return p.vaultIndex === bidVaultInfo.vaultInfo.info.index && p.receiptsVid.includes(bidVaultInfo.receipt.vid); });
694
- if (checkExistVault) {
695
- // Merge the bid receipts into the same vault
696
- checkExistVault.receiptsId = __spreadArray(__spreadArray([], __read(checkExistVault.receiptsId), false), __read(data.receiptsId), false);
670
+ function fetchUserBids(config, user, vaultsInfo, userReceipts, prices) {
671
+ return __awaiter(this, void 0, void 0, function () {
672
+ var provider, userStrategies, auctions, _a, sortedBidReceipts, bidVaultsInfo, bidShares, bidsFromBidShares, _loop_1, bidVaultsInfo_1, bidVaultsInfo_1_1, bidVaultInfo, autoBidsShares, vaultAutoBidReceipts, userStrategies_1, userStrategies_1_1, strategy, receipts, receipts_1, receipts_1_1, receiptItem, vaultIndex, receipt, autoBidVaultInfos, bidsFromStrategies, _loop_2, autoBidVaultInfos_1, autoBidVaultInfos_1_1, autoBidVaultInfo, byOrdered;
673
+ var e_2, _b, e_3, _c, e_4, _d, e_5, _e;
674
+ return __generator(this, function (_f) {
675
+ switch (_f.label) {
676
+ case 0:
677
+ provider = new client_2.SuiClient({ url: config.rpcEndpoint });
678
+ return [4 /*yield*/, (0, auto_bid_1.getUserStrategies)(config, { user: user })];
679
+ case 1:
680
+ userStrategies = _f.sent();
681
+ return [4 /*yield*/, (0, typus_dov_single_v2_1.getAuctions)(config, { indexes: [] })];
682
+ case 2:
683
+ auctions = _f.sent();
684
+ if (!(typeof prices === "undefined")) return [3 /*break*/, 4];
685
+ return [4 /*yield*/, (0, exports.fetchPrices)(provider, config)];
686
+ case 3:
687
+ prices = _f.sent();
688
+ _f.label = 4;
689
+ case 4:
690
+ _a = (0, exports.parseBidReceipt)(Object.values(vaultsInfo), userReceipts), sortedBidReceipts = _a.sortedBidReceipts, bidVaultsInfo = _a.bidVaultsInfo;
691
+ return [4 /*yield*/, (0, typus_dov_single_v2_1.getMyBids)(config, { receipts: sortedBidReceipts })];
692
+ case 5:
693
+ bidShares = _f.sent();
694
+ bidsFromBidShares = [];
695
+ _loop_1 = function (bidVaultInfo) {
696
+ var bidShare = bidShares["".concat(bidVaultInfo.receipt.index, "-").concat(bidVaultInfo.receipt.vid)];
697
+ var auction = auctions ? auctions[bidVaultInfo.vaultInfo.info.index] : null;
698
+ var _g = __read((0, vault_1.parseAssets)(bidVaultInfo.vaultInfo.info), 3), dToken = _g[0], bToken = _g[1], oToken = _g[2];
699
+ if (bidShare) {
700
+ var price = (0, bignumber_js_1.default)(prices[oToken.toLowerCase()].price)
701
+ .div((0, bignumber_js_1.default)(10).pow(prices[oToken.toLowerCase()].decimal))
702
+ .toString();
703
+ var data = (0, exports.parseBid)(bidVaultInfo, bidShare, auction, price, false);
704
+ var checkExistVault = bidsFromBidShares.find(function (p) { return p.vaultIndex === bidVaultInfo.vaultInfo.info.index && p.receiptsVid.includes(bidVaultInfo.receipt.vid); });
705
+ if (checkExistVault) {
706
+ // Merge the bid receipts into the same vault
707
+ checkExistVault.receiptsId = __spreadArray(__spreadArray([], __read(checkExistVault.receiptsId), false), __read(data.receiptsId), false);
708
+ }
709
+ else {
710
+ bidsFromBidShares.push(data);
711
+ }
697
712
  }
698
- else {
699
- bidsFromBidShares.push(data);
713
+ };
714
+ try {
715
+ for (bidVaultsInfo_1 = __values(bidVaultsInfo), bidVaultsInfo_1_1 = bidVaultsInfo_1.next(); !bidVaultsInfo_1_1.done; bidVaultsInfo_1_1 = bidVaultsInfo_1.next()) {
716
+ bidVaultInfo = bidVaultsInfo_1_1.value;
717
+ _loop_1(bidVaultInfo);
700
718
  }
701
719
  }
702
- };
703
- try {
704
- for (bidVaultsInfo_1 = __values(bidVaultsInfo), bidVaultsInfo_1_1 = bidVaultsInfo_1.next(); !bidVaultsInfo_1_1.done; bidVaultsInfo_1_1 = bidVaultsInfo_1.next()) {
705
- bidVaultInfo = bidVaultsInfo_1_1.value;
706
- _loop_1(bidVaultInfo);
720
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
721
+ finally {
722
+ try {
723
+ if (bidVaultsInfo_1_1 && !bidVaultsInfo_1_1.done && (_b = bidVaultsInfo_1.return)) _b.call(bidVaultsInfo_1);
724
+ }
725
+ finally { if (e_2) throw e_2.error; }
707
726
  }
708
- }
709
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
710
- finally {
727
+ autoBidsShares = {};
728
+ vaultAutoBidReceipts = {};
711
729
  try {
712
- if (bidVaultsInfo_1_1 && !bidVaultsInfo_1_1.done && (_b = bidVaultsInfo_1.return)) _b.call(bidVaultsInfo_1);
713
- }
714
- finally { if (e_2) throw e_2.error; }
715
- }
716
- autoBidsShares = {};
717
- vaultAutoBidReceipts = {};
718
- try {
719
- for (userStrategies_1 = __values(userStrategies), userStrategies_1_1 = userStrategies_1.next(); !userStrategies_1_1.done; userStrategies_1_1 = userStrategies_1.next()) {
720
- strategy = userStrategies_1_1.value;
721
- receipts = strategy.receipts;
722
- try {
723
- for (receipts_1 = (e_4 = void 0, __values(receipts)), receipts_1_1 = receipts_1.next(); !receipts_1_1.done; receipts_1_1 = receipts_1.next()) {
724
- receiptItem = receipts_1_1.value;
725
- vaultIndex = receiptItem.index;
726
- receipt = {
727
- id: receiptItem.id,
728
- index: vaultIndex,
729
- name: "",
730
- description: "",
731
- vid: receiptItem.vid,
732
- metadata: receiptItem.metadata,
733
- };
734
- if (vaultAutoBidReceipts[vaultIndex]) {
735
- vaultAutoBidReceipts[vaultIndex] = __spreadArray(__spreadArray([], __read(vaultAutoBidReceipts[vaultIndex]), false), [receipt], false);
736
- }
737
- else {
738
- vaultAutoBidReceipts[vaultIndex] = [receipt];
739
- }
740
- if (autoBidsShares["".concat(vaultIndex, "-").concat(receiptItem.vid)]) {
741
- autoBidsShares["".concat(vaultIndex, "-").concat(receiptItem.vid)].share = (Number(autoBidsShares["".concat(vaultIndex, "-").concat(receiptItem.vid)].share) +
742
- Number(strategy.my_bids["".concat(vaultIndex, "-").concat(receiptItem.vid)].share)).toString();
743
- }
744
- else {
745
- autoBidsShares["".concat(vaultIndex, "-").concat(receiptItem.vid)] = {
746
- bidVault: strategy.my_bids["".concat(vaultIndex, "-").concat(receiptItem.vid)].bidVault,
747
- share: strategy.my_bids["".concat(vaultIndex, "-").concat(receiptItem.vid)].share,
730
+ for (userStrategies_1 = __values(userStrategies), userStrategies_1_1 = userStrategies_1.next(); !userStrategies_1_1.done; userStrategies_1_1 = userStrategies_1.next()) {
731
+ strategy = userStrategies_1_1.value;
732
+ receipts = strategy.receipts;
733
+ try {
734
+ for (receipts_1 = (e_4 = void 0, __values(receipts)), receipts_1_1 = receipts_1.next(); !receipts_1_1.done; receipts_1_1 = receipts_1.next()) {
735
+ receiptItem = receipts_1_1.value;
736
+ vaultIndex = receiptItem.index;
737
+ receipt = {
738
+ id: receiptItem.id,
739
+ index: vaultIndex,
740
+ name: "",
741
+ description: "",
742
+ vid: receiptItem.vid,
743
+ metadata: receiptItem.metadata,
748
744
  };
745
+ if (vaultAutoBidReceipts[vaultIndex]) {
746
+ vaultAutoBidReceipts[vaultIndex] = __spreadArray(__spreadArray([], __read(vaultAutoBidReceipts[vaultIndex]), false), [receipt], false);
747
+ }
748
+ else {
749
+ vaultAutoBidReceipts[vaultIndex] = [receipt];
750
+ }
751
+ if (autoBidsShares["".concat(vaultIndex, "-").concat(receiptItem.vid)]) {
752
+ autoBidsShares["".concat(vaultIndex, "-").concat(receiptItem.vid)].share = (Number(autoBidsShares["".concat(vaultIndex, "-").concat(receiptItem.vid)].share) +
753
+ Number(strategy.my_bids["".concat(vaultIndex, "-").concat(receiptItem.vid)].share)).toString();
754
+ }
755
+ else {
756
+ autoBidsShares["".concat(vaultIndex, "-").concat(receiptItem.vid)] = {
757
+ bidVault: strategy.my_bids["".concat(vaultIndex, "-").concat(receiptItem.vid)].bidVault,
758
+ share: strategy.my_bids["".concat(vaultIndex, "-").concat(receiptItem.vid)].share,
759
+ };
760
+ }
749
761
  }
750
762
  }
751
- }
752
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
753
- finally {
754
- try {
755
- if (receipts_1_1 && !receipts_1_1.done && (_d = receipts_1.return)) _d.call(receipts_1);
763
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
764
+ finally {
765
+ try {
766
+ if (receipts_1_1 && !receipts_1_1.done && (_d = receipts_1.return)) _d.call(receipts_1);
767
+ }
768
+ finally { if (e_4) throw e_4.error; }
756
769
  }
757
- finally { if (e_4) throw e_4.error; }
758
770
  }
759
771
  }
760
- }
761
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
762
- finally {
763
- try {
764
- if (userStrategies_1_1 && !userStrategies_1_1.done && (_c = userStrategies_1.return)) _c.call(userStrategies_1);
765
- }
766
- finally { if (e_3) throw e_3.error; }
767
- }
768
- autoBidVaultInfos = [];
769
- Object.values(vaultsInfo).forEach(function (v) {
770
- var curReceipts = vaultAutoBidReceipts[v.info.index];
771
- if (curReceipts) {
772
- curReceipts.map(function (item) {
773
- autoBidVaultInfos.push({ vaultInfo: v, receipt: item });
774
- });
772
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
773
+ finally {
774
+ try {
775
+ if (userStrategies_1_1 && !userStrategies_1_1.done && (_c = userStrategies_1.return)) _c.call(userStrategies_1);
776
+ }
777
+ finally { if (e_3) throw e_3.error; }
775
778
  }
776
- });
777
- bidsFromStrategies = [];
778
- _loop_2 = function (autoBidVaultInfo) {
779
- var bidShare = autoBidsShares["".concat(autoBidVaultInfo.receipt.index, "-").concat(autoBidVaultInfo.receipt.vid)];
780
- var auction = auctions ? auctions[autoBidVaultInfo.vaultInfo.info.index] : null;
781
- var _h = __read((0, vault_1.parseAssets)(autoBidVaultInfo.vaultInfo.info), 3), dToken = _h[0], bToken = _h[1], oToken = _h[2];
782
- if (bidShare) {
783
- var price = (0, bignumber_js_1.default)(prices[oToken.toLowerCase()].price)
784
- .div((0, bignumber_js_1.default)(10).pow(prices[oToken.toLowerCase()].decimal))
785
- .toString();
786
- var data = (0, exports.parseBid)(autoBidVaultInfo, bidShare, auction, price, false);
787
- var checkExistVault = bidsFromStrategies.find(function (p) { return p.vaultIndex === autoBidVaultInfo.vaultInfo.info.index && p.receiptsVid.includes(autoBidVaultInfo.receipt.vid); });
788
- if (checkExistVault) {
789
- // Merge the bid receipts into the same vault
790
- checkExistVault.receiptsId = __spreadArray(__spreadArray([], __read(checkExistVault.receiptsId), false), __read(data.receiptsId), false);
779
+ autoBidVaultInfos = [];
780
+ Object.values(vaultsInfo).forEach(function (v) {
781
+ var curReceipts = vaultAutoBidReceipts[v.info.index];
782
+ if (curReceipts) {
783
+ curReceipts.map(function (item) {
784
+ autoBidVaultInfos.push({ vaultInfo: v, receipt: item });
785
+ });
791
786
  }
792
- else {
793
- bidsFromStrategies.push(data);
787
+ });
788
+ bidsFromStrategies = [];
789
+ _loop_2 = function (autoBidVaultInfo) {
790
+ var bidShare = autoBidsShares["".concat(autoBidVaultInfo.receipt.index, "-").concat(autoBidVaultInfo.receipt.vid)];
791
+ var auction = auctions ? auctions[autoBidVaultInfo.vaultInfo.info.index] : null;
792
+ var _h = __read((0, vault_1.parseAssets)(autoBidVaultInfo.vaultInfo.info), 3), dToken = _h[0], bToken = _h[1], oToken = _h[2];
793
+ if (bidShare) {
794
+ var price = (0, bignumber_js_1.default)(prices[oToken.toLowerCase()].price)
795
+ .div((0, bignumber_js_1.default)(10).pow(prices[oToken.toLowerCase()].decimal))
796
+ .toString();
797
+ var data = (0, exports.parseBid)(autoBidVaultInfo, bidShare, auction, price, false);
798
+ var checkExistVault = bidsFromStrategies.find(function (p) { return p.vaultIndex === autoBidVaultInfo.vaultInfo.info.index && p.receiptsVid.includes(autoBidVaultInfo.receipt.vid); });
799
+ if (checkExistVault) {
800
+ // Merge the bid receipts into the same vault
801
+ checkExistVault.receiptsId = __spreadArray(__spreadArray([], __read(checkExistVault.receiptsId), false), __read(data.receiptsId), false);
802
+ }
803
+ else {
804
+ bidsFromStrategies.push(data);
805
+ }
794
806
  }
795
- }
796
- };
797
- try {
798
- for (autoBidVaultInfos_1 = __values(autoBidVaultInfos), autoBidVaultInfos_1_1 = autoBidVaultInfos_1.next(); !autoBidVaultInfos_1_1.done; autoBidVaultInfos_1_1 = autoBidVaultInfos_1.next()) {
799
- autoBidVaultInfo = autoBidVaultInfos_1_1.value;
800
- _loop_2(autoBidVaultInfo);
801
- }
802
- }
803
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
804
- finally {
807
+ };
805
808
  try {
806
- if (autoBidVaultInfos_1_1 && !autoBidVaultInfos_1_1.done && (_e = autoBidVaultInfos_1.return)) _e.call(autoBidVaultInfos_1);
809
+ for (autoBidVaultInfos_1 = __values(autoBidVaultInfos), autoBidVaultInfos_1_1 = autoBidVaultInfos_1.next(); !autoBidVaultInfos_1_1.done; autoBidVaultInfos_1_1 = autoBidVaultInfos_1.next()) {
810
+ autoBidVaultInfo = autoBidVaultInfos_1_1.value;
811
+ _loop_2(autoBidVaultInfo);
812
+ }
807
813
  }
808
- finally { if (e_5) throw e_5.error; }
809
- }
810
- byOrdered = (0, lodash_1.orderBy)(__spreadArray(__spreadArray([], __read(bidsFromBidShares), false), __read(bidsFromStrategies), false), ["expiry", "tokenOrder", "periodOrder", "optionTypeOrder"], ["asc", "asc", "asc", "asc"]);
811
- return [2 /*return*/, byOrdered];
812
- }
814
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
815
+ finally {
816
+ try {
817
+ if (autoBidVaultInfos_1_1 && !autoBidVaultInfos_1_1.done && (_e = autoBidVaultInfos_1.return)) _e.call(autoBidVaultInfos_1);
818
+ }
819
+ finally { if (e_5) throw e_5.error; }
820
+ }
821
+ byOrdered = (0, lodash_1.orderBy)(__spreadArray(__spreadArray([], __read(bidsFromBidShares), false), __read(bidsFromStrategies), false), ["expiry", "tokenOrder", "periodOrder", "optionTypeOrder"], ["asc", "asc", "asc", "asc"]);
822
+ return [2 /*return*/, byOrdered];
823
+ }
824
+ });
813
825
  });
814
- }); };
815
- exports.fetchUserBids = fetchUserBids;
826
+ }
@@ -20,13 +20,13 @@ export declare function getFund(config: TypusConfig, input: {
20
20
  indexes: string[];
21
21
  user: string;
22
22
  }): Promise<{
23
- [key: string]: [Fund[]];
23
+ [key: string]: Fund[];
24
24
  }>;
25
25
  export declare function getRefund(config: TypusConfig, input: {
26
26
  indexes: string[];
27
27
  user: string;
28
28
  }): Promise<{
29
- [key: string]: [Fund[]];
29
+ [key: string]: Fund[];
30
30
  }>;
31
31
  export declare function getAllFunds(config: TypusConfig, input: {
32
32
  index: string;
@@ -129,7 +129,7 @@ function getFund(config, input) {
129
129
  tsMs: reader.read64(),
130
130
  };
131
131
  });
132
- funds[input.indexes[i]] = [fund];
132
+ funds[input.indexes[i]] = fund;
133
133
  });
134
134
  return [2 /*return*/, funds];
135
135
  }
@@ -169,7 +169,7 @@ function getRefund(config, input) {
169
169
  tsMs: reader.read64(),
170
170
  };
171
171
  });
172
- funds[input.indexes[i]] = [fund];
172
+ funds[input.indexes[i]] = fund;
173
173
  });
174
174
  return [2 /*return*/, funds];
175
175
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@typus/typus-sdk",
3
3
  "author": "Typus",
4
4
  "description": "typus sdk",
5
- "version": "1.4.75",
5
+ "version": "1.4.77",
6
6
  "dependencies": {
7
7
  "@mysten/bcs": "^0.11.1",
8
8
  "@mysten/kiosk": "0.8.10",