@typus/typus-sdk 0.2.3 → 0.2.5

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,14 +1,15 @@
1
- export declare const TOKEN_PACKAGE = "0x97cfaa5d2a79c1be5da410870deb258ed5f42561";
2
- export declare const TOKEN_REGISTRY_BTC = "0xb10e4bf339c2495d793647fa726fd5427ca8c328";
3
- export declare const TOKEN_REGISTRY_ETH = "0x59c42da8bb8a3b98a764985af1d9cef7e6e9f87d";
4
- export declare const TOKEN_REGISTRY_SUI = "0xf4a1954d812748ee08dd4c4c1e21bb136a6c089e";
1
+ export declare const TOKEN_PACKAGE = "0xed553b5e7e8690216566974f843c59711ae2f0b7";
2
+ export declare const TOKEN_REGISTRY_BTC = "0xf936133c49899c482e818cb7aad7a1a245615703";
3
+ export declare const TOKEN_REGISTRY_ETH = "0x9c041d2f4dc68577b9d828ec23d2f64cc2b0426c";
4
+ export declare const TOKEN_REGISTRY_SUI = "0x0a35b52763fda836155f3fab655f1fb0477fd428";
5
5
  export declare const ORACLE_PACKAGE = "0x437d2eb473bd348ad22b37ffb84bd652656026b1";
6
- export declare const COVERED_CALL_PACKAGE = "0x5ece57f5f85a00ad812afd9a4a7b7781d157f7ed";
7
- export declare const COVERED_CALL_REGISTRY = "0x189cf44a4a1daa77df7aab6d5894e2712843c2c9";
8
- export declare const COVERED_CALL_MANAGER = "0x7e39015e03494ebcb976120a0ac2f112c1602dc2";
9
- export declare const USER_SHARE_TABLE = "0x59cd2080bfc2ac8bbf917339372f1c36d44431c5";
10
- export declare const MAKER_SHARE_TABLE = "0x4b3457ee86bd47048006b181738dd5a29263d4b2";
11
- export declare const DOV_PACKAGE = "0x3674cf36f02160cdf3fd983629fed062f2306461";
6
+ export declare const COVERED_CALL_PACKAGE = "0x8e1d90b8f79583a3ca67c9e731039b297c59252a";
7
+ export declare const COVERED_CALL_REGISTRY = "0xd39929844191b67993d84b1bf258ec08a0aa06ba";
8
+ export declare const COVERED_CALL_MANAGER = "0xbfbdae13e30a27d9774a4bc441b71f07dea03710";
9
+ export declare const USER_SHARE_TABLE = "0x6d3e5cc791c7d4a7cfb98955f2afa8b55a729fa8";
10
+ export declare const MAKER_SHARE_TABLE = "0xc42377112a39fb6138e89099912d3888df6444ba";
11
+ export declare const DOV_PACKAGE = "0x1ab7f453176dc6d35fe5e8b6b27a53cb73d1061d";
12
+ export declare const TEST_MINT_TOKEN = "0xd3aeb5597cd4ddea33921fe1155387db28502d13";
12
13
  export declare const DEFAULT_TYPE_ARGUMENT = "0x2::sui::SUI";
13
14
  export declare const FAKE_TOKEN_TYPE_ARGUMENT = "0x27b3674c685046f66cad1d5496d2967894fa5329::token::USDC";
14
15
  export declare const TEST_MNEMONIC = "plug grain matter asthma aware critic can lottery blouse uncover sauce speak";
package/lib/constants.js CHANGED
@@ -1,21 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TOKEN_NAME_TO_MODULE = exports.TOKEN_NAME = exports.TEST_MNEMONIC = exports.FAKE_TOKEN_TYPE_ARGUMENT = exports.DEFAULT_TYPE_ARGUMENT = exports.DOV_PACKAGE = exports.MAKER_SHARE_TABLE = exports.USER_SHARE_TABLE = exports.COVERED_CALL_MANAGER = exports.COVERED_CALL_REGISTRY = exports.COVERED_CALL_PACKAGE = exports.ORACLE_PACKAGE = exports.TOKEN_REGISTRY_SUI = exports.TOKEN_REGISTRY_ETH = exports.TOKEN_REGISTRY_BTC = exports.TOKEN_PACKAGE = void 0;
3
+ exports.TOKEN_NAME_TO_MODULE = exports.TOKEN_NAME = exports.TEST_MNEMONIC = exports.FAKE_TOKEN_TYPE_ARGUMENT = exports.DEFAULT_TYPE_ARGUMENT = exports.TEST_MINT_TOKEN = exports.DOV_PACKAGE = exports.MAKER_SHARE_TABLE = exports.USER_SHARE_TABLE = exports.COVERED_CALL_MANAGER = exports.COVERED_CALL_REGISTRY = exports.COVERED_CALL_PACKAGE = exports.ORACLE_PACKAGE = exports.TOKEN_REGISTRY_SUI = exports.TOKEN_REGISTRY_ETH = exports.TOKEN_REGISTRY_BTC = exports.TOKEN_PACKAGE = void 0;
4
4
  //publish from sui-dev-token
5
- exports.TOKEN_PACKAGE = "0x97cfaa5d2a79c1be5da410870deb258ed5f42561";
6
- exports.TOKEN_REGISTRY_BTC = "0xb10e4bf339c2495d793647fa726fd5427ca8c328"; //fake btc registry
7
- exports.TOKEN_REGISTRY_ETH = "0x59c42da8bb8a3b98a764985af1d9cef7e6e9f87d"; //fake eth registry
8
- exports.TOKEN_REGISTRY_SUI = "0xf4a1954d812748ee08dd4c4c1e21bb136a6c089e"; //fake usdc registry
5
+ exports.TOKEN_PACKAGE = "0xed553b5e7e8690216566974f843c59711ae2f0b7";
6
+ exports.TOKEN_REGISTRY_BTC = "0xf936133c49899c482e818cb7aad7a1a245615703"; //fake btc registry
7
+ exports.TOKEN_REGISTRY_ETH = "0x9c041d2f4dc68577b9d828ec23d2f64cc2b0426c"; //fake eth registry
8
+ exports.TOKEN_REGISTRY_SUI = "0x0a35b52763fda836155f3fab655f1fb0477fd428"; //fake usdc registry
9
9
  //publish from typus-oracle
10
10
  exports.ORACLE_PACKAGE = "0x437d2eb473bd348ad22b37ffb84bd652656026b1";
11
11
  //publish from typus-dov/cover_call
12
- exports.COVERED_CALL_PACKAGE = "0x5ece57f5f85a00ad812afd9a4a7b7781d157f7ed";
13
- exports.COVERED_CALL_REGISTRY = "0x189cf44a4a1daa77df7aab6d5894e2712843c2c9";
14
- exports.COVERED_CALL_MANAGER = "0x7e39015e03494ebcb976120a0ac2f112c1602dc2";
15
- exports.USER_SHARE_TABLE = "0x59cd2080bfc2ac8bbf917339372f1c36d44431c5";
16
- exports.MAKER_SHARE_TABLE = "0x4b3457ee86bd47048006b181738dd5a29263d4b2";
12
+ exports.COVERED_CALL_PACKAGE = "0x8e1d90b8f79583a3ca67c9e731039b297c59252a";
13
+ exports.COVERED_CALL_REGISTRY = "0xd39929844191b67993d84b1bf258ec08a0aa06ba";
14
+ exports.COVERED_CALL_MANAGER = "0xbfbdae13e30a27d9774a4bc441b71f07dea03710";
15
+ exports.USER_SHARE_TABLE = "0x6d3e5cc791c7d4a7cfb98955f2afa8b55a729fa8";
16
+ exports.MAKER_SHARE_TABLE = "0xc42377112a39fb6138e89099912d3888df6444ba";
17
17
  //publish from typus-dov/typus-dov
18
- exports.DOV_PACKAGE = "0x3674cf36f02160cdf3fd983629fed062f2306461";
18
+ exports.DOV_PACKAGE = "0x1ab7f453176dc6d35fe5e8b6b27a53cb73d1061d";
19
+ exports.TEST_MINT_TOKEN = "0xd3aeb5597cd4ddea33921fe1155387db28502d13";
19
20
  exports.DEFAULT_TYPE_ARGUMENT = "0x2::sui::SUI";
20
21
  exports.FAKE_TOKEN_TYPE_ARGUMENT = "0x27b3674c685046f66cad1d5496d2967894fa5329::token::USDC";
21
22
  exports.TEST_MNEMONIC = "plug grain matter asthma aware critic can lottery blouse uncover sauce speak";
@@ -46,7 +46,7 @@ var constants_1 = require("../../constants");
46
46
  console.log("test for getClaimAllTx()");
47
47
  index = 0;
48
48
  isRolling = true;
49
- return [4 /*yield*/, (0, getClaimAllTx_1.getClaimAllTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, constants_1.DEFAULT_TYPE_ARGUMENT, index, isRolling)];
49
+ return [4 /*yield*/, (0, getClaimAllTx_1.getClaimAllTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, constants_1.DEFAULT_TYPE_ARGUMENT, index)];
50
50
  case 1:
51
51
  claimAllTx = _a.sent();
52
52
  console.log(claimAllTx);
@@ -39,15 +39,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  var getClaimTx_1 = require("../../utils/coveredCall/getClaimTx");
40
40
  var constants_1 = require("../../constants");
41
41
  (function () { return __awaiter(void 0, void 0, void 0, function () {
42
- var index, amount, isRolling, claimTx;
42
+ var index, claimTx;
43
43
  return __generator(this, function (_a) {
44
44
  switch (_a.label) {
45
45
  case 0:
46
46
  console.log("test for getClaimTx()");
47
47
  index = 0;
48
- amount = 1000;
49
- isRolling = true;
50
- return [4 /*yield*/, (0, getClaimTx_1.getClaimTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, constants_1.DEFAULT_TYPE_ARGUMENT, index, amount, isRolling)];
48
+ return [4 /*yield*/, (0, getClaimTx_1.getClaimTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, constants_1.DEFAULT_TYPE_ARGUMENT, index)];
51
49
  case 1:
52
50
  claimTx = _a.sent();
53
51
  console.log(claimTx);
@@ -39,19 +39,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  var getNewAuctionTx_1 = require("../../utils/coveredCall/getNewAuctionTx");
40
40
  var constants_1 = require("../../constants");
41
41
  (function () { return __awaiter(void 0, void 0, void 0, function () {
42
- var typeArgument, vaultIndex, start, end, decay, initialPrice, finalPrice, newAuctionTx;
42
+ var typeArgument, vaultIndex, newAuctionTx;
43
43
  return __generator(this, function (_a) {
44
44
  switch (_a.label) {
45
45
  case 0:
46
46
  console.log("test for getNewAuctionTx()");
47
47
  typeArgument = "0x27b3674c685046f66cad1d5496d2967894fa5329::token::USDC";
48
48
  vaultIndex = 1;
49
- start = 1;
50
- end = 100;
51
- decay = 0;
52
- initialPrice = 1;
53
- finalPrice = 100;
54
- return [4 /*yield*/, (0, getNewAuctionTx_1.getNewAuctionTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, constants_1.COVERED_CALL_MANAGER, vaultIndex, start, end, decay, initialPrice, finalPrice)];
49
+ return [4 /*yield*/, (0, getNewAuctionTx_1.getNewAuctionTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, constants_1.COVERED_CALL_MANAGER, vaultIndex)];
55
50
  case 1:
56
51
  newAuctionTx = _a.sent();
57
52
  console.log(newAuctionTx);
@@ -39,21 +39,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  var getNewAuctionWithNextCoveredCallVaultTx_1 = require("../../utils/coveredCall/getNewAuctionWithNextCoveredCallVaultTx");
40
40
  var constants_1 = require("../../constants");
41
41
  (function () { return __awaiter(void 0, void 0, void 0, function () {
42
- var index, start, end, decay, initialPrice, finalPrice, expiration, assetName, strikeOtmPct, newAuctionWithNextCoveredCallVaultTx;
42
+ var index, timeOracle, activationTsMs, expirationTsMs, newAuctionWithNextCoveredCallVaultTx;
43
43
  return __generator(this, function (_a) {
44
44
  switch (_a.label) {
45
45
  case 0:
46
46
  console.log("test for getNewAuctionWithNextCoveredCallVaultTx()");
47
47
  index = 1;
48
- start = 10;
49
- end = 20;
50
- decay = 2;
51
- initialPrice = 5;
52
- finalPrice = 1;
53
- expiration = 2000;
54
- assetName = "BTC";
55
- strikeOtmPct = 2000;
56
- return [4 /*yield*/, (0, getNewAuctionWithNextCoveredCallVaultTx_1.getNewAuctionWithNextCoveredCallVaultTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_MANAGER, constants_1.COVERED_CALL_REGISTRY, constants_1.DEFAULT_TYPE_ARGUMENT, index, start, end, decay, initialPrice, finalPrice, expiration, strikeOtmPct)];
48
+ timeOracle = "";
49
+ activationTsMs = 1672992000000;
50
+ expirationTsMs = 1672992000000 + 604800000;
51
+ return [4 /*yield*/, (0, getNewAuctionWithNextCoveredCallVaultTx_1.getNewAuctionWithNextCoveredCallVaultTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_MANAGER, constants_1.COVERED_CALL_REGISTRY, constants_1.DEFAULT_TYPE_ARGUMENT, index, timeOracle, activationTsMs, expirationTsMs)];
57
52
  case 1:
58
53
  newAuctionWithNextCoveredCallVaultTx = _a.sent();
59
54
  console.log(newAuctionWithNextCoveredCallVaultTx);
@@ -39,19 +39,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  var getNewCoveredCallVaultTx_1 = require("../../utils/coveredCall/getNewCoveredCallVaultTx");
40
40
  var constants_1 = require("../../constants");
41
41
  (function () { return __awaiter(void 0, void 0, void 0, function () {
42
- var expiration, strike, tokenDecimal, shareDecimal, timeOracle, period, start, newCoveredCallVaultTx;
42
+ var tokenDecimal, shareDecimal, timeOracle, period, activationTsMs, expirationTsMs, capacity, strikeOtmPct, strikeIncrement, decaySpeed, initialPrice, finalPrice, auctionDurationInMs, prevBalance, newCoveredCallVaultTx;
43
43
  return __generator(this, function (_a) {
44
44
  switch (_a.label) {
45
45
  case 0:
46
46
  console.log("test for getNewCoveredCallVaultTx()");
47
- expiration = 123;
48
- strike = 456;
49
47
  tokenDecimal = 9;
50
48
  shareDecimal = 4;
51
49
  timeOracle = "";
52
- period = 0;
53
- start = 0;
54
- return [4 /*yield*/, (0, getNewCoveredCallVaultTx_1.getNewCoveredCallVaultTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, constants_1.DEFAULT_TYPE_ARGUMENT, constants_1.COVERED_CALL_MANAGER, tokenDecimal, shareDecimal, timeOracle, period, start, expiration, strike)];
50
+ period = 1;
51
+ activationTsMs = 1671782400000;
52
+ expirationTsMs = 1671782400000 + 604800000;
53
+ capacity = 1000000000;
54
+ strikeOtmPct = 500;
55
+ strikeIncrement = 10000;
56
+ decaySpeed = 1;
57
+ initialPrice = 5000;
58
+ finalPrice = 1000;
59
+ auctionDurationInMs = 3600000;
60
+ prevBalance = 0;
61
+ return [4 /*yield*/, (0, getNewCoveredCallVaultTx_1.getNewCoveredCallVaultTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, constants_1.DEFAULT_TYPE_ARGUMENT, constants_1.COVERED_CALL_MANAGER, timeOracle, period, activationTsMs, expirationTsMs, tokenDecimal, shareDecimal, capacity, strikeOtmPct, strikeIncrement, decaySpeed, initialPrice, finalPrice, auctionDurationInMs, prevBalance)];
55
62
  case 1:
56
63
  newCoveredCallVaultTx = _a.sent();
57
64
  console.log(newCoveredCallVaultTx);
@@ -61,14 +61,14 @@ var signer = new sui_js_1.RawSigner(keypair, provider);
61
61
  case 1:
62
62
  typeArgument = _a.sent();
63
63
  console.log("test for claim, try to claim " + token + " for " + claimAmount + " ...");
64
- return [4 /*yield*/, (0, getClaimTx_1.getClaimTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, vaultIndex, claimAmount, isRolling)];
64
+ return [4 /*yield*/, (0, getClaimTx_1.getClaimTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, vaultIndex)];
65
65
  case 2:
66
66
  claimTx = _a.sent();
67
67
  return [4 /*yield*/, signer.executeMoveCall(claimTx)];
68
68
  case 3:
69
69
  _a.sent();
70
70
  console.log("claim successfully");
71
- return [4 /*yield*/, (0, getClaimAllTx_1.getClaimAllTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, vaultIndex, isRolling)];
71
+ return [4 /*yield*/, (0, getClaimAllTx_1.getClaimAllTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, vaultIndex)];
72
72
  case 4:
73
73
  claimAllTx = _a.sent();
74
74
  return [4 /*yield*/, signer.executeMoveCall(claimAllTx)];
@@ -45,8 +45,7 @@ var keypair = sui_js_1.Ed25519Keypair.deriveKeypair(constants_1.TEST_MNEMONIC);
45
45
  var signer = new sui_js_1.RawSigner(keypair, provider);
46
46
  /*
47
47
  after deposit, token object (minted token) balance will decrease,
48
- and subVault "balance" in fields will increase,
49
- and a new rolling linked list node will be created if not exist, and the value will increase the same value
48
+ and subVault "rolling_sub_vault" will increase
50
49
  */
51
50
  (function () { return __awaiter(void 0, void 0, void 0, function () {
52
51
  var depositAmount, isRolling, token, vaultIndex, typeArgument, depositTx;
@@ -55,8 +54,7 @@ var signer = new sui_js_1.RawSigner(keypair, provider);
55
54
  case 0:
56
55
  depositAmount = 100000000;
57
56
  isRolling = true;
58
- token = "0x07f6ef13aa444a793b11675494a8c7fb3b1acab7" // minted token
59
- ;
57
+ token = constants_1.TEST_MINT_TOKEN;
60
58
  vaultIndex = 0;
61
59
  return [4 /*yield*/, (0, getTypeArgumentFromToken_1.getTypeArgumentFromToken)(token)];
62
60
  case 1:
@@ -71,13 +71,20 @@ var getTypeArgumentFromToken_1 = require("../utils/getTypeArgumentFromToken");
71
71
  var provider = new sui_js_1.JsonRpcProvider(sui_js_1.Network.DEVNET); //for read only operations
72
72
  var keypair = sui_js_1.Ed25519Keypair.deriveKeypair(constants_1.TEST_MNEMONIC);
73
73
  var signer = new sui_js_1.RawSigner(keypair, provider);
74
- var token = "0x07f6ef13aa444a793b11675494a8c7fb3b1acab7"; // minted token
75
- var expiration = 1;
76
- var strike = 105;
74
+ var token = constants_1.TEST_MINT_TOKEN; // minted token
77
75
  var tokenDecimal = 9;
78
76
  var shareDecimal = 4;
79
- var period = 1; //weekly
80
- var start = 1671782400000; // 2022/12/23 Friday 08:00:00
77
+ var period = 1;
78
+ var activationTsMs = 1671782400000;
79
+ var expirationTsMs = 1671782400000 + 604800000;
80
+ var capacity = 1000000000;
81
+ var strikeOtmPct = 500;
82
+ var strikeIncrement = 10000;
83
+ var decaySpeed = 1;
84
+ var initialPrice = 5000;
85
+ var finalPrice = 1000;
86
+ var auctionDurationInMs = 3600000;
87
+ var prevBalance = 0;
81
88
  (function () { return __awaiter(void 0, void 0, void 0, function () {
82
89
  var typeArgument, _a, timeOracle, _, newCoveredCallVaultTx, moveCallTxn;
83
90
  return __generator(this, function (_b) {
@@ -90,7 +97,8 @@ var start = 1671782400000; // 2022/12/23 Friday 08:00:00
90
97
  return [4 /*yield*/, (0, createTimeOracle_1.createTimeOracle)()];
91
98
  case 2:
92
99
  _a = __read.apply(void 0, [_b.sent(), 2]), timeOracle = _a[0], _ = _a[1];
93
- return [4 /*yield*/, (0, getNewCoveredCallVaultTx_1.getNewCoveredCallVaultTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, constants_1.COVERED_CALL_MANAGER, tokenDecimal, shareDecimal, timeOracle, period, start, expiration, strike)];
100
+ console.log(typeArgument, timeOracle);
101
+ return [4 /*yield*/, (0, getNewCoveredCallVaultTx_1.getNewCoveredCallVaultTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, constants_1.COVERED_CALL_MANAGER, timeOracle, period, activationTsMs, expirationTsMs, tokenDecimal, shareDecimal, capacity, strikeOtmPct, strikeIncrement, decaySpeed, initialPrice, finalPrice, auctionDurationInMs, prevBalance)];
94
102
  case 3:
95
103
  newCoveredCallVaultTx = _b.sent();
96
104
  return [4 /*yield*/, signer.executeMoveCall(newCoveredCallVaultTx)];
@@ -92,7 +92,7 @@ var expirationTsMs2 = 2000000;
92
92
  // let timeOracle = '0x2b06a0f8109e394258c288b1d90c8c5a9c3832db';
93
93
  // let timeOracleManager = '0xcad2723ff9c95ce423d3614375e2fa73ce9a7c04';
94
94
  (function () { return __awaiter(void 0, void 0, void 0, function () {
95
- var typeArgument, _a, priceOracle, priceOracleManager, _b, timeOracle, timeOracleManager, price, ts, tokenDecimal, shareDecimal, period, start, vaultIndex, depositAmount, startAuctionTsMs, endAuctionTsMs, decaySpeed, initialPrice, finalPrice, currentTime, bidSize, sellSize, premiumRoi, exposureRatio;
95
+ var typeArgument, _a, priceOracle, priceOracleManager, _b, timeOracle, timeOracleManager, price, ts, tokenDecimal, shareDecimal, period, activationTsMs, expirationTsMs, capacity, strikeOtmPct, strikeIncrement, decaySpeed, initialPrice, finalPrice, auctionDurationInMs, prevBalance, vaultIndex, depositAmount, startAuctionTsMs, endAuctionTsMs, currentTime, bidSize, sellSize, premiumRoi, exposureRatio;
96
96
  return __generator(this, function (_c) {
97
97
  switch (_c.label) {
98
98
  case 0: return [4 /*yield*/, (0, getTypeArgumentFromToken_1.getTypeArgumentFromToken)(token)
@@ -122,11 +122,17 @@ var expirationTsMs2 = 2000000;
122
122
  tokenDecimal = 9;
123
123
  shareDecimal = 4;
124
124
  period = 1;
125
- start = 0 //???
126
- ;
127
- return [4 /*yield*/, createNewVault(typeArgument, expirationTsMs1, tokenDecimal, shareDecimal, timeOracle, period, start)
128
- //deposit to new vault
129
- ];
125
+ activationTsMs = 1671782400000;
126
+ expirationTsMs = 1671782400000 + 604800000;
127
+ capacity = 1000000000;
128
+ strikeOtmPct = 500;
129
+ strikeIncrement = 10000;
130
+ decaySpeed = 1;
131
+ initialPrice = 5000;
132
+ finalPrice = 1000;
133
+ auctionDurationInMs = 3600000;
134
+ prevBalance = 0;
135
+ return [4 /*yield*/, createNewVault(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, constants_1.COVERED_CALL_MANAGER, timeOracle, period, activationTsMs, expirationTsMs, tokenDecimal, shareDecimal, capacity, strikeOtmPct, strikeIncrement, decaySpeed, initialPrice, finalPrice, auctionDurationInMs, prevBalance)];
130
136
  case 5:
131
137
  _c.sent();
132
138
  return [4 /*yield*/, getNewestVaultIndex(constants_1.COVERED_CALL_REGISTRY)];
@@ -152,9 +158,9 @@ var expirationTsMs2 = 2000000;
152
158
  decaySpeed = 2;
153
159
  initialPrice = 500000000;
154
160
  finalPrice = 100000000;
155
- return [4 /*yield*/, createNewAuctionWithNextCoveredCallVault(typeArgument, vaultIndex, startAuctionTsMs, endAuctionTsMs, decaySpeed, initialPrice, finalPrice, expirationTsMs2, strike)
156
- //update time oracle
157
- ];
161
+ activationTsMs = 1672992000000;
162
+ expirationTsMs = 1672992000000 + 604800000;
163
+ return [4 /*yield*/, createNewAuctionWithNextCoveredCallVault(typeArgument, vaultIndex, timeOracle, activationTsMs, expirationTsMs)];
158
164
  case 10:
159
165
  _c.sent();
160
166
  currentTime = startAuctionTsMs + 300;
@@ -338,7 +344,7 @@ function updateTimeOracle(timeOracle, managerCap, ts) {
338
344
  });
339
345
  });
340
346
  }
341
- function createNewVault(typeArgument, expirationTsMs1, tokenDecimal, shareDecimal, timeOracle, period, start) {
347
+ function createNewVault(packageId, registry, typeArgument, managerCap, timeOracle, period, activationTsMs, expirationTsMs, tokenDecimal, shareDecimal, capacity, strikeOtmPct, strikeIncrement, decaySpeed, initialPrice, finalPrice, auctionDurationInMs, prevBalance) {
342
348
  return __awaiter(this, void 0, void 0, function () {
343
349
  var _this = this;
344
350
  return __generator(this, function (_a) {
@@ -348,7 +354,7 @@ function createNewVault(typeArgument, expirationTsMs1, tokenDecimal, shareDecima
348
354
  switch (_a.label) {
349
355
  case 0:
350
356
  _a.trys.push([0, 4, , 5]);
351
- return [4 /*yield*/, (0, getNewCoveredCallVaultTx_1.getNewCoveredCallVaultTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, constants_1.COVERED_CALL_MANAGER, tokenDecimal, shareDecimal, timeOracle, period, start, expirationTsMs1, strike)];
357
+ return [4 /*yield*/, (0, getNewCoveredCallVaultTx_1.getNewCoveredCallVaultTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, constants_1.COVERED_CALL_MANAGER, timeOracle, period, activationTsMs, expirationTsMs, tokenDecimal, shareDecimal, capacity, strikeOtmPct, strikeIncrement, decaySpeed, initialPrice, finalPrice, auctionDurationInMs, prevBalance)];
352
358
  case 1:
353
359
  newCoveredCallVaultTx = _a.sent();
354
360
  return [4 /*yield*/, signer.executeMoveCall(newCoveredCallVaultTx)];
@@ -463,7 +469,7 @@ function depositToVault(typeArgument, vaultIndex, depositAmount) {
463
469
  });
464
470
  });
465
471
  }
466
- function createNewAuctionWithNextCoveredCallVault(typeArgument, vaultIndex, startAuctionTsMs, endAuctionTsMs, decaySpeed, initialPrice, finalPrice, expirationTsMs2, strike) {
472
+ function createNewAuctionWithNextCoveredCallVault(typeArgument, vaultIndex, timeOracle, activationTsMs, expirationTsMs) {
467
473
  return __awaiter(this, void 0, void 0, function () {
468
474
  var _this = this;
469
475
  return __generator(this, function (_a) {
@@ -473,7 +479,7 @@ function createNewAuctionWithNextCoveredCallVault(typeArgument, vaultIndex, star
473
479
  switch (_a.label) {
474
480
  case 0:
475
481
  _a.trys.push([0, 3, , 4]);
476
- 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)];
482
+ return [4 /*yield*/, (0, getNewAuctionWithNextCoveredCallVaultTx_1.getNewAuctionWithNextCoveredCallVaultTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_MANAGER, constants_1.COVERED_CALL_REGISTRY, typeArgument, vaultIndex, timeOracle, activationTsMs, expirationTsMs)];
477
483
  case 1:
478
484
  txn = _a.sent();
479
485
  return [4 /*yield*/, signer.executeMoveCall(txn)];
@@ -1 +1 @@
1
- export declare function getClaimAllTx(packageId: string, registry: string, typeArgument: string, index: number, isRolling: boolean): Promise<any>;
1
+ export declare function getClaimAllTx(packageId: string, registry: string, typeArgument: string, index: number): Promise<any>;
@@ -37,7 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.getClaimAllTx = void 0;
40
- function getClaimAllTx(packageId, registry, typeArgument, index, isRolling) {
40
+ function getClaimAllTx(packageId, registry, typeArgument, index) {
41
41
  return __awaiter(this, void 0, void 0, function () {
42
42
  var tx;
43
43
  return __generator(this, function (_a) {
@@ -49,7 +49,6 @@ function getClaimAllTx(packageId, registry, typeArgument, index, isRolling) {
49
49
  arguments: [
50
50
  registry,
51
51
  [index],
52
- [isRolling],
53
52
  ],
54
53
  gasBudget: 10000,
55
54
  };
@@ -1 +1 @@
1
- export declare function getClaimTx(packageId: string, registry: string, typeArgument: string, index: number, amount: number, isRolling: boolean): Promise<any>;
1
+ export declare function getClaimTx(packageId: string, registry: string, typeArgument: string, index: number): Promise<any>;
@@ -37,7 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.getClaimTx = void 0;
40
- function getClaimTx(packageId, registry, typeArgument, index, amount, isRolling) {
40
+ function getClaimTx(packageId, registry, typeArgument, index) {
41
41
  return __awaiter(this, void 0, void 0, function () {
42
42
  var tx;
43
43
  return __generator(this, function (_a) {
@@ -49,8 +49,6 @@ function getClaimTx(packageId, registry, typeArgument, index, amount, isRolling)
49
49
  arguments: [
50
50
  registry,
51
51
  index,
52
- amount,
53
- isRolling,
54
52
  ],
55
53
  gasBudget: 10000,
56
54
  };
@@ -50,8 +50,8 @@ function getDeliveryTx(packageId, managerCap, registry, typeArgument, index, siz
50
50
  managerCap,
51
51
  registry,
52
52
  index,
53
- size,
54
53
  timeOracle,
54
+ size,
55
55
  ],
56
56
  gasBudget: 10000,
57
57
  };
@@ -1 +1 @@
1
- export declare function getNewAuctionTx(packageId: string, registry: string, typeArgument: string, managerCap: string, index: number, start: number, end: number, decay: number, initialPrice: number, finalPrice: number): Promise<any>;
1
+ export declare function getNewAuctionTx(packageId: string, registry: string, typeArgument: string, managerCap: string, index: number): Promise<any>;
@@ -37,7 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.getNewAuctionTx = void 0;
40
- function getNewAuctionTx(packageId, registry, typeArgument, managerCap, index, start, end, decay, initialPrice, finalPrice) {
40
+ function getNewAuctionTx(packageId, registry, typeArgument, managerCap, index) {
41
41
  return __awaiter(this, void 0, void 0, function () {
42
42
  var tx;
43
43
  return __generator(this, function (_a) {
@@ -50,11 +50,6 @@ function getNewAuctionTx(packageId, registry, typeArgument, managerCap, index, s
50
50
  managerCap,
51
51
  registry,
52
52
  index,
53
- start,
54
- end,
55
- decay,
56
- initialPrice,
57
- finalPrice,
58
53
  ],
59
54
  gasBudget: 1000,
60
55
  };
@@ -1 +1 @@
1
- export declare function getNewAuctionWithNextCoveredCallVaultTx(packageId: string, managerCap: string, registry: string, typeArgument: string, index: number, start: number, end: number, decay: number, initialPrice: number, finalPrice: number, expiration: number, strikeOtmPct: number): Promise<any>;
1
+ export declare function getNewAuctionWithNextCoveredCallVaultTx(packageId: string, managerCap: string, registry: string, typeArgument: string, index: number, timeOracle: string, activationTsMs: number, expirationTsMs: number): Promise<any>;
@@ -37,7 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.getNewAuctionWithNextCoveredCallVaultTx = void 0;
40
- function getNewAuctionWithNextCoveredCallVaultTx(packageId, managerCap, registry, typeArgument, index, start, end, decay, initialPrice, finalPrice, expiration, strikeOtmPct) {
40
+ function getNewAuctionWithNextCoveredCallVaultTx(packageId, managerCap, registry, typeArgument, index, timeOracle, activationTsMs, expirationTsMs) {
41
41
  return __awaiter(this, void 0, void 0, function () {
42
42
  var tx;
43
43
  return __generator(this, function (_a) {
@@ -50,13 +50,9 @@ function getNewAuctionWithNextCoveredCallVaultTx(packageId, managerCap, registry
50
50
  managerCap,
51
51
  registry,
52
52
  index,
53
- start,
54
- end,
55
- decay,
56
- initialPrice,
57
- finalPrice,
58
- expiration,
59
- strikeOtmPct,
53
+ timeOracle,
54
+ activationTsMs,
55
+ expirationTsMs,
60
56
  ],
61
57
  gasBudget: 10000,
62
58
  };
@@ -49,9 +49,9 @@ function getNewBidTx(packageId, registry, typeArgument, vaultIndex, size, coin,
49
49
  arguments: [
50
50
  registry,
51
51
  vaultIndex,
52
- size,
53
- coin,
54
52
  time,
53
+ coin,
54
+ size,
55
55
  ],
56
56
  gasBudget: 1000,
57
57
  };
@@ -1 +1 @@
1
- export declare function getNewCoveredCallVaultTx(packageId: string, registry: string, typeArgument: string, managerCap: string, tokenDecimal: number, shareDecimal: number, timeOracle: string, period: number, start: number, expiration: number, strike: number): Promise<any>;
1
+ export declare function getNewCoveredCallVaultTx(packageId: string, registry: string, typeArgument: string, managerCap: string, timeOracle: string, period: number, activationTsMs: number, expirationTsMs: number, tokenDecimal: number, shareDecimal: number, capacity: number, strikeOtmPct: number, strikeIncrement: number, decaySpeed: number, initialPrice: number, finalPrice: number, auctionDurationInMs: number, prevBalance: number): Promise<any>;
@@ -37,7 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.getNewCoveredCallVaultTx = void 0;
40
- function getNewCoveredCallVaultTx(packageId, registry, typeArgument, managerCap, tokenDecimal, shareDecimal, timeOracle, period, start, expiration, strike) {
40
+ function getNewCoveredCallVaultTx(packageId, registry, typeArgument, managerCap, timeOracle, period, activationTsMs, expirationTsMs, tokenDecimal, shareDecimal, capacity, strikeOtmPct, strikeIncrement, decaySpeed, initialPrice, finalPrice, auctionDurationInMs, prevBalance) {
41
41
  return __awaiter(this, void 0, void 0, function () {
42
42
  var tx;
43
43
  return __generator(this, function (_a) {
@@ -49,13 +49,20 @@ function getNewCoveredCallVaultTx(packageId, registry, typeArgument, managerCap,
49
49
  arguments: [
50
50
  managerCap,
51
51
  registry,
52
- tokenDecimal,
53
- shareDecimal,
54
52
  timeOracle,
55
53
  period,
56
- start,
57
- expiration,
58
- strike,
54
+ activationTsMs,
55
+ expirationTsMs,
56
+ tokenDecimal,
57
+ shareDecimal,
58
+ capacity,
59
+ strikeOtmPct,
60
+ strikeIncrement,
61
+ decaySpeed,
62
+ initialPrice,
63
+ finalPrice,
64
+ auctionDurationInMs,
65
+ prevBalance,
59
66
  ],
60
67
  gasBudget: 10000,
61
68
  };
@@ -3,24 +3,42 @@ export interface SubVaults {
3
3
  maker: string;
4
4
  regular: string;
5
5
  }
6
+ export interface VaultConfig {
7
+ strikeOtmPct: number;
8
+ strikeIncrement: number;
9
+ decaySpeed: number;
10
+ initialPrice: number;
11
+ finalPrice: number;
12
+ auctionDurationInMs: number;
13
+ }
14
+ export interface Config {
15
+ period: number;
16
+ activationTsMs: number;
17
+ expirationTsMs: number;
18
+ tokenDecimal: number;
19
+ shareDecimal: number;
20
+ capacity: number;
21
+ vaultConfig: VaultConfig;
22
+ nextVaultConfig: VaultConfig;
23
+ payoffConfig: PayoffConfig;
24
+ }
6
25
  export interface Vault {
26
+ ableToDeposit: boolean;
27
+ ableToWithdraw: boolean;
28
+ }
29
+ export interface CoveredCallVault {
7
30
  vaultId: string;
8
31
  vaultIdx: number;
9
32
  asset: string;
10
- ableToDeposit: boolean;
11
- ableToWithdraw: boolean;
12
- expirationTsMs: number;
13
- payoffConfig: PayoffConfig;
14
- period: number;
15
- shareDecimal: number;
16
- startTsMs: number;
17
- tokenDecimal: number;
33
+ config: Config;
34
+ vault: Vault;
35
+ prevBalance: number;
36
+ tvl: number;
18
37
  }
19
38
  export interface PayoffConfig {
20
39
  exposureRatio: number;
21
40
  premiumRoi: number;
22
41
  strike: number;
23
- strikeOtmPct: number;
24
42
  }
25
43
  export declare function getCoveredCallVaultsFromRegistry(registry: string): Promise<any>;
26
44
  export declare function getTableFromCoveredCallVault(coveredCallVault: string): Promise<any>;
@@ -1,2 +1,2 @@
1
- import { Vault } from "../utils/fetchData";
2
- export declare function getVaultDataFromRegistry(registry: string): Promise<Vault[]>;
1
+ import { CoveredCallVault } from "../utils/fetchData";
2
+ export declare function getVaultDataFromRegistry(registry: string): Promise<CoveredCallVault[]>;
@@ -72,12 +72,11 @@ function getVaultDataFromRegistry(registry) {
72
72
  console.log("obj not exist");
73
73
  return "continue";
74
74
  }
75
- //vault
76
75
  //@ts-ignore
77
- var vault = objInfo.details.data.fields.value.fields.vault.fields;
78
- //config
76
+ // console.log(objInfo.details.data.fields.value.fields.config.fields)
77
+ //vaultId
79
78
  //@ts-ignore
80
- var config = objInfo.details.data.fields.value.fields.config.fields;
79
+ var vaultId = objInfo.details.data.fields.id.id;
81
80
  //vaultIdx
82
81
  //@ts-ignore
83
82
  var vaultIdx = objInfo.details.data.fields.name;
@@ -89,28 +88,63 @@ function getVaultDataFromRegistry(registry) {
89
88
  console.log("can't find token");
90
89
  asset = "";
91
90
  }
92
- //vaultId
91
+ //config
93
92
  //@ts-ignore
94
- var vaultId = objInfo.details.data.fields.id.id;
95
- //payoff config
96
- var payoffConfig = {
97
- exposureRatio: Number(config.payoff_config.fields.exposure_ratio),
98
- premiumRoi: Number(config.payoff_config.fields.premium_roi),
99
- strike: Number(config.payoff_config.fields.strike),
100
- strikeOtmPct: Number(config.payoff_config.fields.strike_otm_pct)
93
+ var config = objInfo.details.data.fields.value.fields.config.fields;
94
+ //vault
95
+ //@ts-ignore
96
+ var vault = objInfo.details.data.fields.value.fields.vault.fields;
97
+ //prevBalance
98
+ //@ts-ignore
99
+ var prevBalance = objInfo.details.data.fields.value.fields.prev_balance;
100
+ var vaultConfig = config.vault_config.fields;
101
+ var vaultConfigRes = {
102
+ strikeOtmPct: vaultConfig.strike_otm_pct,
103
+ strikeIncrement: vaultConfig.strike_increment,
104
+ decaySpeed: vaultConfig.decay_speed,
105
+ initialPrice: vaultConfig.initial_price,
106
+ finalPrice: vaultConfig.final_price,
107
+ auctionDurationInMs: vaultConfig.auction_duration_in_ms,
101
108
  };
109
+ var nextVaultConfig = config.next_vault_config.fields;
110
+ var nextVaultConfigRes = {
111
+ strikeOtmPct: nextVaultConfig.strike_otm_pct,
112
+ strikeIncrement: nextVaultConfig.strike_increment,
113
+ decaySpeed: nextVaultConfig.decay_speed,
114
+ initialPrice: nextVaultConfig.initial_price,
115
+ finalPrice: nextVaultConfig.final_price,
116
+ auctionDurationInMs: nextVaultConfig.auction_duration_in_ms,
117
+ };
118
+ var payoffConfig = config.payoff_config.fields;
119
+ var payoffConfigRes = {
120
+ exposureRatio: Number(payoffConfig.exposure_ratio),
121
+ premiumRoi: Number(payoffConfig.premium_roi),
122
+ strike: Number(payoffConfig.strike),
123
+ };
124
+ var configRes = {
125
+ period: config.period,
126
+ activationTsMs: config.activation_ts_ms,
127
+ expirationTsMs: config.expiration_ts_ms,
128
+ tokenDecimal: config.token_decimal,
129
+ shareDecimal: config.share_decimal,
130
+ capacity: config.capacity,
131
+ vaultConfig: vaultConfigRes,
132
+ nextVaultConfig: nextVaultConfigRes,
133
+ payoffConfig: payoffConfigRes,
134
+ };
135
+ var vaultRes = {
136
+ ableToDeposit: vault.able_to_deposit,
137
+ ableToWithdraw: vault.able_to_withdraw,
138
+ };
139
+ var tvl = Number(vault.regular_sub_vault.fields.balance) + Number(vault.rolling_sub_vault.fields.balance);
102
140
  var res = {
103
141
  vaultId: vaultId,
104
142
  vaultIdx: vaultIdx,
105
143
  asset: asset,
106
- ableToDeposit: vault.able_to_deposit,
107
- ableToWithdraw: vault.able_to_withdraw,
108
- expirationTsMs: config.expiration_ts_ms,
109
- payoffConfig: payoffConfig,
110
- period: Number(config.period),
111
- shareDecimal: config.share_decimal,
112
- startTsMs: config.start_ts_ms,
113
- tokenDecimal: config.token_decimal,
144
+ config: configRes,
145
+ vault: vaultRes,
146
+ prevBalance: prevBalance,
147
+ tvl: tvl,
114
148
  };
115
149
  vaults.push(res);
116
150
  };
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.3",
5
+ "version": "0.2.5",
6
6
  "dependencies": {
7
7
  "@mysten/bcs": "^0.5.0",
8
8
  "@mysten/sui.js": "^0.20.0",