@typus/typus-sdk 0.2.0 → 0.2.1

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.
@@ -3,10 +3,10 @@ export declare const TOKEN_REGISTRY_BTC = "0x1d41542c9bcbb3427e80afb6cd7f05b304f
3
3
  export declare const TOKEN_REGISTRY_ETH = "0x97da9ec6f9842025480b73a2249e8670491c37d6";
4
4
  export declare const TOKEN_REGISTRY_SUI = "0xa0b7b5fc89ee0fa8a1f3355f9370c9651f7611b6";
5
5
  export declare const ORACLE_PACKAGE = "0xe450380f9abda5ef5a7d8674f36d60caeb5a5b22";
6
- export declare const COVERED_CALL_PACKAGE = "0xaf49c3190359bdce1ef2947ef9e10dcc9227cec2";
7
- export declare const COVERED_CALL_REGISTRY = "0x92c1ef1b38b36541d43502954d9e6529aa9cf4d9";
8
- export declare const COVERED_CALL_MANAGER = "0x868bf971423bf0c0b443e23dc6d21bcc4169a79b";
9
- export declare const DOV_PACKAGE = "0x0c5b45ef284e97b8564223232cdd291649c0f0b7";
6
+ export declare const COVERED_CALL_PACKAGE = "0xf98dbb57fde46c6c42fd199404037c9f5cfb6cbd";
7
+ export declare const COVERED_CALL_REGISTRY = "0x060ef5e7d31e578eece3b69fb7f933ad1f34cbf9";
8
+ export declare const COVERED_CALL_MANAGER = "0xcee379cd9be9e99baf441039d8d874126615ccdd";
9
+ export declare const DOV_PACKAGE = "0xfaadf1d975ed3dec39cbe93a1f44c034966f6747";
10
10
  export declare const DEFAULT_TYPE_ARGUMENT = "0x2::sui::SUI";
11
11
  export declare const FAKE_TOKEN_TYPE_ARGUMENT = "0x27b3674c685046f66cad1d5496d2967894fa5329::token::USDC";
12
12
  export declare const TEST_MNEMONIC = "plug grain matter asthma aware critic can lottery blouse uncover sauce speak";
package/lib/constants.js CHANGED
@@ -9,11 +9,11 @@ exports.TOKEN_REGISTRY_SUI = "0xa0b7b5fc89ee0fa8a1f3355f9370c9651f7611b6"; //fak
9
9
  //publish from typus-oracle
10
10
  exports.ORACLE_PACKAGE = "0xe450380f9abda5ef5a7d8674f36d60caeb5a5b22";
11
11
  //publish from typus-dov/cover_call
12
- exports.COVERED_CALL_PACKAGE = "0xaf49c3190359bdce1ef2947ef9e10dcc9227cec2";
13
- exports.COVERED_CALL_REGISTRY = "0x92c1ef1b38b36541d43502954d9e6529aa9cf4d9";
14
- exports.COVERED_CALL_MANAGER = "0x868bf971423bf0c0b443e23dc6d21bcc4169a79b";
12
+ exports.COVERED_CALL_PACKAGE = "0xf98dbb57fde46c6c42fd199404037c9f5cfb6cbd";
13
+ exports.COVERED_CALL_REGISTRY = "0x060ef5e7d31e578eece3b69fb7f933ad1f34cbf9";
14
+ exports.COVERED_CALL_MANAGER = "0xcee379cd9be9e99baf441039d8d874126615ccdd";
15
15
  //publish from typus-dov/typus-dov
16
- exports.DOV_PACKAGE = "0x0c5b45ef284e97b8564223232cdd291649c0f0b7";
16
+ exports.DOV_PACKAGE = "0xfaadf1d975ed3dec39cbe93a1f44c034966f6747";
17
17
  exports.DEFAULT_TYPE_ARGUMENT = "0x2::sui::SUI";
18
18
  exports.FAKE_TOKEN_TYPE_ARGUMENT = "0x27b3674c685046f66cad1d5496d2967894fa5329::token::USDC";
19
19
  exports.TEST_MNEMONIC = "plug grain matter asthma aware critic can lottery blouse uncover sauce speak";
@@ -121,7 +121,7 @@ var expirationTsMs2 = 2000000;
121
121
  // await updateTimeOracle(timeOracle, timeOracleManager, ts)
122
122
  //create new vault
123
123
  //DONE
124
- return [4 /*yield*/, createNewVault(typeArgument, priceOracle)
124
+ return [4 /*yield*/, createNewVault(typeArgument, expirationTsMs1, priceOracle)
125
125
  //deposit to new vault
126
126
  //DONE
127
127
  ];
@@ -216,11 +216,28 @@ var expirationTsMs2 = 2000000;
216
216
  premiumRoi = 100000;
217
217
  return [4 /*yield*/, updatePayoffConfig(vaultIndex, price, premiumRoi)
218
218
  //update price oracle and time oracle
219
- //TODO
219
+ //DONE
220
+ ];
221
+ case 17:
222
+ _c.sent();
223
+ //update price oracle and time oracle
224
+ //DONE
225
+ price = 9800000000;
226
+ return [4 /*yield*/, updatePriceOracle(priceOracle, priceOracleManager, typeArgument, price, expirationTsMs1)];
227
+ case 18:
228
+ _c.sent();
229
+ return [4 /*yield*/, updateTimeOracle(timeOracle, timeOracleManager, expirationTsMs1)
220
230
  //settle
221
231
  //TODO
222
232
  ];
223
- case 17:
233
+ case 19:
234
+ _c.sent();
235
+ //settle
236
+ //TODO
237
+ return [4 /*yield*/, settle(vaultIndex, priceOracle, timeOracle)];
238
+ case 20:
239
+ //settle
240
+ //TODO
224
241
  _c.sent();
225
242
  return [2 /*return*/];
226
243
  }
@@ -374,7 +391,7 @@ function updateTimeOracle(timeOracle, managerCap, ts) {
374
391
  });
375
392
  });
376
393
  }
377
- function createNewVault(typeArgument, priceOracle) {
394
+ function createNewVault(typeArgument, expirationTsMs1, priceOracle) {
378
395
  return __awaiter(this, void 0, void 0, function () {
379
396
  var _this = this;
380
397
  return __generator(this, function (_a) {
@@ -491,65 +508,124 @@ function depositToVault(typeArgument, vaultIndex, depositAmount) {
491
508
  }
492
509
  function createNewAuctionWithNextCoveredCallVault(typeArgument, vaultIndex, startAuctionTsMs, endAuctionTsMs, decaySpeed, initialPrice, finalPrice, expirationTsMs2, strike) {
493
510
  return __awaiter(this, void 0, void 0, function () {
494
- var txn;
511
+ var _this = this;
495
512
  return __generator(this, function (_a) {
496
- switch (_a.label) {
497
- case 0: return [4 /*yield*/, (0, getNewAuctionWithNextCoveredCallVaultTx_1.getNewAuctionWithNextCoveredCallVaultTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_MANAGER, constants_1.COVERED_CALL_REGISTRY, typeArgument, vaultIndex, startAuctionTsMs, endAuctionTsMs, decaySpeed, initialPrice, finalPrice, expirationTsMs2, strike)];
498
- case 1:
499
- txn = _a.sent();
500
- return [4 /*yield*/, signer.executeMoveCall(txn)];
501
- case 2:
502
- _a.sent();
503
- return [2 /*return*/];
504
- }
513
+ return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
514
+ var txn, e_9;
515
+ return __generator(this, function (_a) {
516
+ switch (_a.label) {
517
+ case 0:
518
+ _a.trys.push([0, 3, , 4]);
519
+ return [4 /*yield*/, (0, getNewAuctionWithNextCoveredCallVaultTx_1.getNewAuctionWithNextCoveredCallVaultTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_MANAGER, constants_1.COVERED_CALL_REGISTRY, typeArgument, vaultIndex, startAuctionTsMs, endAuctionTsMs, decaySpeed, initialPrice, finalPrice, expirationTsMs2, strike)];
520
+ case 1:
521
+ txn = _a.sent();
522
+ return [4 /*yield*/, signer.executeMoveCall(txn)];
523
+ case 2:
524
+ _a.sent();
525
+ return [3 /*break*/, 4];
526
+ case 3:
527
+ e_9 = _a.sent();
528
+ console.error("err in createNewAuctionWithNextCoveredCallVault");
529
+ reject();
530
+ return [3 /*break*/, 4];
531
+ case 4: return [2 /*return*/];
532
+ }
533
+ });
534
+ }); })];
505
535
  });
506
536
  });
507
537
  }
508
538
  function newBid(vaultIndex, size, token, timeOracle) {
509
539
  return __awaiter(this, void 0, void 0, function () {
510
- var newBidTx;
540
+ var _this = this;
511
541
  return __generator(this, function (_a) {
512
- switch (_a.label) {
513
- case 0: return [4 /*yield*/, (0, getNewBidTx_1.getNewBidTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, constants_1.DEFAULT_TYPE_ARGUMENT, vaultIndex, size, token, timeOracle)];
514
- case 1:
515
- newBidTx = _a.sent();
516
- return [4 /*yield*/, signer.executeMoveCall(newBidTx)];
517
- case 2:
518
- _a.sent();
519
- return [2 /*return*/];
520
- }
542
+ return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
543
+ var newBidTx, e_10;
544
+ return __generator(this, function (_a) {
545
+ switch (_a.label) {
546
+ case 0:
547
+ _a.trys.push([0, 3, , 4]);
548
+ return [4 /*yield*/, (0, getNewBidTx_1.getNewBidTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, constants_1.DEFAULT_TYPE_ARGUMENT, vaultIndex, size, token, timeOracle)];
549
+ case 1:
550
+ newBidTx = _a.sent();
551
+ return [4 /*yield*/, signer.executeMoveCall(newBidTx)];
552
+ case 2:
553
+ _a.sent();
554
+ return [3 /*break*/, 4];
555
+ case 3:
556
+ e_10 = _a.sent();
557
+ console.error("err in newBid");
558
+ reject();
559
+ return [3 /*break*/, 4];
560
+ case 4: return [2 /*return*/];
561
+ }
562
+ });
563
+ }); })];
521
564
  });
522
565
  });
523
566
  }
524
567
  function delivery(vaultIndex, sellSize, timeOracle) {
525
568
  return __awaiter(this, void 0, void 0, function () {
526
- var deliveryTx;
569
+ var _this = this;
527
570
  return __generator(this, function (_a) {
528
- switch (_a.label) {
529
- case 0: return [4 /*yield*/, (0, getDeliveryTx_1.getDeliveryTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_MANAGER, constants_1.COVERED_CALL_REGISTRY, constants_1.DEFAULT_TYPE_ARGUMENT, vaultIndex, sellSize, timeOracle)];
530
- case 1:
531
- deliveryTx = _a.sent();
532
- return [4 /*yield*/, signer.executeMoveCall(deliveryTx)];
533
- case 2:
534
- _a.sent();
535
- return [2 /*return*/];
536
- }
571
+ return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
572
+ var deliveryTx, e_11;
573
+ return __generator(this, function (_a) {
574
+ switch (_a.label) {
575
+ case 0:
576
+ _a.trys.push([0, 3, , 4]);
577
+ return [4 /*yield*/, (0, getDeliveryTx_1.getDeliveryTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_MANAGER, constants_1.COVERED_CALL_REGISTRY, constants_1.DEFAULT_TYPE_ARGUMENT, vaultIndex, sellSize, timeOracle)];
578
+ case 1:
579
+ deliveryTx = _a.sent();
580
+ return [4 /*yield*/, signer.executeMoveCall(deliveryTx)];
581
+ case 2:
582
+ _a.sent();
583
+ return [3 /*break*/, 4];
584
+ case 3:
585
+ e_11 = _a.sent();
586
+ console.error("err in delivery");
587
+ reject();
588
+ return [3 /*break*/, 4];
589
+ case 4: return [2 /*return*/];
590
+ }
591
+ });
592
+ }); })];
537
593
  });
538
594
  });
539
595
  }
540
596
  function updatePayoffConfig(vaultIndex, price, premiumRoi) {
541
597
  return __awaiter(this, void 0, void 0, function () {
542
- var updatePayoffConfigTx;
598
+ var _this = this;
543
599
  return __generator(this, function (_a) {
544
- switch (_a.label) {
545
- case 0: return [4 /*yield*/, (0, getUpdatePayoffConfigTx_1.getUpdatePayoffConfigTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, constants_1.DEFAULT_TYPE_ARGUMENT, constants_1.COVERED_CALL_MANAGER, vaultIndex, price, premiumRoi)];
546
- case 1:
547
- updatePayoffConfigTx = _a.sent();
548
- return [4 /*yield*/, signer.executeMoveCall(updatePayoffConfigTx)];
549
- case 2:
550
- _a.sent();
551
- return [2 /*return*/];
552
- }
600
+ return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
601
+ var updatePayoffConfigTx, e_12;
602
+ return __generator(this, function (_a) {
603
+ switch (_a.label) {
604
+ case 0:
605
+ _a.trys.push([0, 3, , 4]);
606
+ return [4 /*yield*/, (0, getUpdatePayoffConfigTx_1.getUpdatePayoffConfigTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, constants_1.DEFAULT_TYPE_ARGUMENT, constants_1.COVERED_CALL_MANAGER, vaultIndex, price, premiumRoi)];
607
+ case 1:
608
+ updatePayoffConfigTx = _a.sent();
609
+ return [4 /*yield*/, signer.executeMoveCall(updatePayoffConfigTx)];
610
+ case 2:
611
+ _a.sent();
612
+ return [3 /*break*/, 4];
613
+ case 3:
614
+ e_12 = _a.sent();
615
+ console.error("err in updatePayoffConfig");
616
+ reject();
617
+ return [3 /*break*/, 4];
618
+ case 4: return [2 /*return*/];
619
+ }
620
+ });
621
+ }); })];
622
+ });
623
+ });
624
+ }
625
+ function settle(vaultIndex, priceOracle, timeOracle) {
626
+ return __awaiter(this, void 0, void 0, function () {
627
+ return __generator(this, function (_a) {
628
+ return [2 /*return*/];
553
629
  });
554
630
  });
555
631
  }
@@ -112,7 +112,7 @@ function loadUsersDepositData(registry) {
112
112
  subVault: subVaults[subVaultType],
113
113
  subVaultType: subVaultType,
114
114
  linkedListNode: linkedListNode.objectId,
115
- balance: userData.value.fields.value
115
+ balance: (userData.value) ? userData.value.fields.value : 0
116
116
  };
117
117
  userDepositDatas = (usersDepositData.get(userData.name) == undefined) ? [] : usersDepositData.get(userData.name);
118
118
  userDepositDatas.push(userDepositData);
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": "0.2.0",
5
+ "version": "0.2.1",
6
6
  "dependencies": {
7
7
  "@mysten/sui.js": "^0.17.1",
8
8
  "@types/node": "^17.0.0",