@typus/typus-sdk 1.2.50 → 1.2.52

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.
package/lib/mainnet.json CHANGED
@@ -30,12 +30,12 @@
30
30
  "SCALLOP_MARKET": "0xa757975255146dc9686aa823b7838b507f315d704f428cbadad2f4ea061939d9",
31
31
  "SCALLOP_REWARD_POOL_FOR_SUI": "0x162250ef72393a4ad3d46294c4e1bdfcb03f04c869d390e7efbfc995353a7ee9",
32
32
  "SCALLOP_REWARD_POOL_FOR_USDC": "0xf4268cc9b9413b9bfe09e8966b8de650494c9e5784bf0930759cfef4904daff8",
33
- "VERSION": "2.18.13",
33
+ "VERSION": "2.19.3",
34
34
  "EXP_GUESS_PACKAGE": "0x32d670520a10a87b8c042d2259c2d1f7c319329bafcf6f893ad9aaf01a43db8b",
35
35
  "EXP_GUESS_PACKAGE_ORIGIN": "0x32d670520a10a87b8c042d2259c2d1f7c319329bafcf6f893ad9aaf01a43db8b",
36
36
  "EXP_GUESS_REGISTRY": "0x70c6cbe6764b315cee1b24f483a0fc8307f047f1fab2a0d4438624845e6ba3f2",
37
37
  "FRAMEWORK_PACKAGE": "0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274",
38
- "SINGLE_COLLATERAL_PACKAGE": "0xb12e58dee672ad3161e023ac2315e2d39866fbf0960abcb1ce755f24f5578b59",
38
+ "SINGLE_COLLATERAL_PACKAGE": "0x7de806a4277bc31aa12afdce194c38f89cb2f171539a426375dbe730db2d0221",
39
39
  "SINGLE_COLLATERAL_PACKAGE_ORIGIN": "0x321848bf1ae327a9e022ccb3701940191e02fa193ab160d9c0e49cd3c003de3a",
40
40
  "SINGLE_COLLATERAL_REGISTRY": "0x3d70b09359e3ca8301ae0abeda4f2fdf72ce313ba58c919ce568e5f535fd2ea8",
41
41
  "SINGLE_COLLATERAL_PORTFOLIO_VAULT_REGISTRY": "0xa1a186d050e3172ef4701c16048c99b11f785969874fa2642b9cbcf59cde7fc0",
@@ -319,6 +319,11 @@ function getNewBidTx(input) {
319
319
  ],
320
320
  });
321
321
  input.tx.transferObjects([input.tx.object(result[0])], input.user);
322
+ var fud_coin = input.tx.moveCall({
323
+ target: "".concat(input.mfudPackageId, "::mfud::burn"),
324
+ arguments: [input.tx.object(input.mfudRegistry), input.tx.object(result[1])],
325
+ });
326
+ input.tx.transferObjects([input.tx.object(fud_coin)], input.user);
322
327
  return input.tx;
323
328
  }
324
329
  exports.getNewBidTx = getNewBidTx;
@@ -442,7 +442,7 @@ function getNewBidTx(input) {
442
442
  input.typeArguments[1] == "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI")) {
443
443
  var _a = __read(input.tx.splitCoins(input.tx.gas, [input.tx.pure(input.premium_required)]), 1), coin = _a[0];
444
444
  var result = input.tx.moveCall({
445
- target: "".concat(input.typusDovSinglePackageId, "::tails_staking::new_bid"),
445
+ target: "".concat(input.typusDovSinglePackageId, "::tails_staking::new_bid_v2"),
446
446
  typeArguments: input.typeArguments,
447
447
  arguments: [
448
448
  input.tx.object(input.typusDovSingleRegistry),
@@ -453,6 +453,11 @@ function getNewBidTx(input) {
453
453
  ],
454
454
  });
455
455
  input.tx.transferObjects([input.tx.object(result[0])], input.user);
456
+ input.tx.moveCall({
457
+ target: "".concat(input.typusFrameworkPackageId, "::utils::transfer_coins"),
458
+ typeArguments: [input.typeArguments[1]],
459
+ arguments: [input.tx.object(result[1]), input.tx.pure(input.user)],
460
+ });
456
461
  }
457
462
  else {
458
463
  var balance = input.tx.moveCall({
@@ -469,7 +474,7 @@ function getNewBidTx(input) {
469
474
  arguments: [input.tx.object(balance)],
470
475
  });
471
476
  var result = input.tx.moveCall({
472
- target: "".concat(input.typusDovSinglePackageId, "::tails_staking::new_bid"),
477
+ target: "".concat(input.typusDovSinglePackageId, "::tails_staking::new_bid_v2"),
473
478
  typeArguments: input.typeArguments,
474
479
  arguments: [
475
480
  input.tx.object(input.typusDovSingleRegistry),
@@ -480,6 +485,11 @@ function getNewBidTx(input) {
480
485
  ],
481
486
  });
482
487
  input.tx.transferObjects([input.tx.object(result[0])], input.user);
488
+ input.tx.moveCall({
489
+ target: "".concat(input.typusFrameworkPackageId, "::utils::transfer_coins"),
490
+ typeArguments: [input.typeArguments[1]],
491
+ arguments: [input.tx.object(result[1]), input.tx.pure(input.user)],
492
+ });
483
493
  }
484
494
  return input.tx;
485
495
  }
@@ -1,11 +1,13 @@
1
- import { SuiClient } from "@mysten/sui.js/client";
1
+ import { SuiClient, SuiEvent } from "@mysten/sui.js/client";
2
2
  import { Vault } from "./view-function";
3
3
  export declare function getUserHistory(provider: SuiClient, originPackage: string, vaults: {
4
4
  [key: string]: Vault;
5
5
  }, sender: string, startTimeMs: number): Promise<TxHistory[]>;
6
+ export declare function getUserEvents(provider: SuiClient, sender: string, startTimeMs: number): Promise<SuiEvent[]>;
7
+ export declare function getAutoBidEvents(provider: SuiClient, originPackage: string, startTimeMs: number): Promise<SuiEvent[]>;
6
8
  export interface TxHistory {
7
9
  Index: string | undefined;
8
- Action: string;
10
+ Action: string | undefined;
9
11
  Period: string | undefined;
10
12
  Amount: string | undefined;
11
13
  Vault: string | undefined;
@@ -15,3 +17,4 @@ export interface TxHistory {
15
17
  Date: Date;
16
18
  txDigest: string;
17
19
  }
20
+ export declare function getUserBid(startTimestamp: string, userAddress: string): Promise<any[]>;
@@ -39,44 +39,116 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
39
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
40
  };
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.getUserHistory = void 0;
42
+ exports.getUserBid = exports.getAutoBidEvents = exports.getUserEvents = exports.getUserHistory = void 0;
43
43
  var token_1 = require("../token");
44
44
  var bignumber_js_1 = __importDefault(require("bignumber.js"));
45
45
  function getUserHistory(provider, originPackage, vaults, sender, startTimeMs) {
46
46
  return __awaiter(this, void 0, void 0, function () {
47
- var senderFilter, result, txHistory, nextPage;
47
+ var datas1, datas2, datas, txHistory;
48
+ return __generator(this, function (_a) {
49
+ switch (_a.label) {
50
+ case 0: return [4 /*yield*/, getUserEvents(provider, sender, startTimeMs)];
51
+ case 1:
52
+ datas1 = _a.sent();
53
+ return [4 /*yield*/, getAutoBidEvents(provider, originPackage, startTimeMs)];
54
+ case 2:
55
+ datas2 = _a.sent();
56
+ datas = datas1.concat(datas2.filter(function (x) {
57
+ // @ts-ignore
58
+ if (x.parsedJson.signer) {
59
+ // @ts-ignore
60
+ return x.parsedJson.signer == sender;
61
+ }
62
+ else if (x.type.endsWith("ExpUpEvent")) {
63
+ return true;
64
+ }
65
+ else {
66
+ return false;
67
+ }
68
+ }));
69
+ return [4 /*yield*/, parseTxHistory(datas, originPackage, vaults)];
70
+ case 3:
71
+ txHistory = _a.sent();
72
+ return [2 /*return*/, txHistory];
73
+ }
74
+ });
75
+ });
76
+ }
77
+ exports.getUserHistory = getUserHistory;
78
+ function getUserEvents(provider, sender, startTimeMs) {
79
+ return __awaiter(this, void 0, void 0, function () {
80
+ var senderFilter, hasNextPage, cursor, datas, result;
48
81
  return __generator(this, function (_a) {
49
82
  switch (_a.label) {
50
83
  case 0:
51
84
  senderFilter = {
52
85
  Sender: sender,
53
86
  };
54
- return [4 /*yield*/, provider.queryEvents({ query: senderFilter, order: "descending" })];
87
+ hasNextPage = true;
88
+ cursor = undefined;
89
+ datas = [];
90
+ _a.label = 1;
55
91
  case 1:
92
+ if (!hasNextPage) return [3 /*break*/, 3];
93
+ return [4 /*yield*/, provider.queryEvents({
94
+ query: senderFilter,
95
+ order: "descending",
96
+ cursor: cursor,
97
+ })];
98
+ case 2:
56
99
  result = _a.sent();
57
- return [4 /*yield*/, parseTxHistory(result.data, originPackage, vaults)];
100
+ // console.log(result);
101
+ hasNextPage = result.hasNextPage;
102
+ cursor = result.nextCursor;
103
+ // @ts-ignore
104
+ datas = datas.concat(result.data);
105
+ if (hasNextPage && Number(result.data[result.data.length - 1].timestampMs) < startTimeMs) {
106
+ return [3 /*break*/, 3];
107
+ }
108
+ return [3 /*break*/, 1];
109
+ case 3: return [2 /*return*/, datas];
110
+ }
111
+ });
112
+ });
113
+ }
114
+ exports.getUserEvents = getUserEvents;
115
+ function getAutoBidEvents(provider, originPackage, startTimeMs) {
116
+ return __awaiter(this, void 0, void 0, function () {
117
+ var moduleFilter, hasNextPage, cursor, datas, result;
118
+ return __generator(this, function (_a) {
119
+ switch (_a.label) {
120
+ case 0:
121
+ moduleFilter = {
122
+ MoveModule: { package: originPackage, module: "auto_bid" },
123
+ };
124
+ hasNextPage = true;
125
+ cursor = undefined;
126
+ datas = [];
127
+ _a.label = 1;
128
+ case 1:
129
+ if (!hasNextPage) return [3 /*break*/, 3];
130
+ return [4 /*yield*/, provider.queryEvents({
131
+ query: moduleFilter,
132
+ order: "descending",
133
+ cursor: cursor,
134
+ })];
58
135
  case 2:
59
- txHistory = _a.sent();
60
- _a.label = 3;
61
- case 3:
62
- if (!result.hasNextPage) return [3 /*break*/, 6];
63
- return [4 /*yield*/, provider.queryEvents({ query: senderFilter, cursor: result.nextCursor })];
64
- case 4:
65
136
  result = _a.sent();
66
- return [4 /*yield*/, parseTxHistory(result.data, originPackage, vaults)];
67
- case 5:
68
- nextPage = _a.sent();
69
- txHistory = txHistory.concat(nextPage);
70
- if (result.hasNextPage && Number(result.data[24].timestampMs) < startTimeMs) {
71
- return [3 /*break*/, 6];
137
+ // console.log(result);
138
+ hasNextPage = result.hasNextPage;
139
+ cursor = result.nextCursor;
140
+ // @ts-ignore
141
+ datas = datas.concat(result.data);
142
+ if (hasNextPage && Number(result.data[result.data.length - 1].timestampMs) < startTimeMs) {
143
+ return [3 /*break*/, 3];
72
144
  }
73
- return [3 /*break*/, 3];
74
- case 6: return [2 /*return*/, txHistory];
145
+ return [3 /*break*/, 1];
146
+ case 3: return [2 /*return*/, datas];
75
147
  }
76
148
  });
77
149
  });
78
150
  }
79
- exports.getUserHistory = getUserHistory;
151
+ exports.getAutoBidEvents = getAutoBidEvents;
80
152
  function parseTxHistory(datas, originPackage, vaults) {
81
153
  return __awaiter(this, void 0, void 0, function () {
82
154
  var results;
@@ -89,7 +161,7 @@ function parseTxHistory(datas, originPackage, vaults) {
89
161
  return event.packageId == originPackage || type.includes("typus_nft::First") || type.includes("typus_nft::ExpUpEvent");
90
162
  })
91
163
  .reduce(function (promise, event) { return __awaiter(_this, void 0, void 0, function () {
92
- var txHistory, functionType, action, Action, Amount, Index, Period, Vault, RiskLevel, Tails, Exp, o_token, v, period, optionType, i, i, token, amount, token, amount, amount, token, amount, size, token, amount, token, amount, i, b_token, size, bidder_balance;
164
+ var txHistory, functionType, action, Action, Amount, Index, Period, Vault, RiskLevel, Tails, Exp, d_token, b_token, o_token, v, period, optionType, i, i, token, amount, deposit_amount, deposit_amount, balance, balance, profit, token, amount, amount, token, amount, size, token, amount, token, amount, i, size, bidder_balance;
93
165
  var _a;
94
166
  return __generator(this, function (_b) {
95
167
  switch (_b.label) {
@@ -98,9 +170,9 @@ function parseTxHistory(datas, originPackage, vaults) {
98
170
  txHistory = _b.sent();
99
171
  functionType = (_a = new RegExp("^([^::]+)::([^::]+)::([^<]+)").exec(event.type)) === null || _a === void 0 ? void 0 : _a.slice(1, 4);
100
172
  action = functionType[2];
101
- Index = event.parsedJson.index;
102
- if (event.parsedJson.index) {
103
- v = vaults[event.parsedJson.index];
173
+ Index = event.parsedJson.index || event.parsedJson.vault_index;
174
+ if (Index) {
175
+ v = vaults[Index];
104
176
  if (v) {
105
177
  period = void 0;
106
178
  switch (v.info.period) {
@@ -192,6 +264,8 @@ function parseTxHistory(datas, originPackage, vaults) {
192
264
  break;
193
265
  }
194
266
  Vault = "".concat(v.info.settlementBaseName, " ").concat(period, " ").concat(optionType);
267
+ d_token = (0, token_1.typeArgToAsset)("0x" + v.info.depositToken);
268
+ b_token = (0, token_1.typeArgToAsset)("0x" + v.info.bidToken);
195
269
  o_token = (0, token_1.typeArgToAsset)("0x" + v.info.settlementBase);
196
270
  }
197
271
  }
@@ -208,15 +282,23 @@ function parseTxHistory(datas, originPackage, vaults) {
208
282
  case "ExpUpEvent":
209
283
  i = txHistory.findIndex(function (x) { return x.txDigest == event.id.txDigest && x.Action != "First Deposit" && x.Action != "Stake"; });
210
284
  if (i != -1) {
285
+ if (txHistory[i].Tails) {
286
+ return [2 /*return*/, txHistory];
287
+ }
211
288
  txHistory[i].Tails = "#".concat(event.parsedJson.number);
212
289
  txHistory[i].Exp = event.parsedJson.exp_earn;
213
290
  return [2 /*return*/, txHistory];
214
291
  }
215
- else {
292
+ else if (event.id.eventSeq == 0) {
216
293
  Action = "Collect EXP";
217
294
  Tails = "#".concat(event.parsedJson.number);
218
295
  Exp = event.parsedJson.exp_earn;
219
296
  }
297
+ else {
298
+ // Action = undefined;
299
+ Tails = "#".concat(event.parsedJson.number);
300
+ Exp = event.parsedJson.exp_earn;
301
+ }
220
302
  break;
221
303
  case "TransferNftEvent":
222
304
  Action = "Transfer";
@@ -240,8 +322,13 @@ function parseTxHistory(datas, originPackage, vaults) {
240
322
  break;
241
323
  case "LevelUpEvent":
242
324
  Action = "Level Up to Level ".concat(event.parsedJson.level);
243
- Tails = "#".concat(event.parsedJson.number);
244
- break;
325
+ if (event.parsedJson.number) {
326
+ Tails = "#".concat(event.parsedJson.number);
327
+ break;
328
+ }
329
+ else {
330
+ return [2 /*return*/, txHistory];
331
+ }
245
332
  case "DepositEvent":
246
333
  case "WithdrawEvent":
247
334
  case "UnsubscribeEvent":
@@ -252,8 +339,11 @@ function parseTxHistory(datas, originPackage, vaults) {
252
339
  token = (0, token_1.typeArgToAsset)("0x" + event.parsedJson.token.name);
253
340
  amount = Number(event.parsedJson.amount) / Math.pow(10, Number(event.parsedJson.decimal));
254
341
  Action = action.slice(0, action.length - 5);
342
+ if (Action == "Harvest") {
343
+ Action = "Harvest Reward";
344
+ }
255
345
  Amount = "".concat((0, bignumber_js_1.default)(amount).toFixed(), " ").concat(token);
256
- Index = event.parsedJson.index;
346
+ Index = Index;
257
347
  if (i != -1) {
258
348
  txHistory[i].Action = Action;
259
349
  txHistory[i].Amount = Amount;
@@ -263,12 +353,35 @@ function parseTxHistory(datas, originPackage, vaults) {
263
353
  return [2 /*return*/, txHistory];
264
354
  }
265
355
  break;
356
+ case "NewStrategyEventV2":
357
+ Action = "Create Strategy";
358
+ deposit_amount = Number(event.parsedJson.deposit_amount) / Math.pow(10, (0, token_1.assetToDecimal)(b_token));
359
+ Amount = "".concat((0, bignumber_js_1.default)(deposit_amount).toFixed(), " ").concat(b_token);
360
+ break;
361
+ case "UpdateStrategyEvent":
362
+ Action = "Update Strategy";
363
+ deposit_amount = Number(event.parsedJson.deposit_amount) / Math.pow(10, (0, token_1.assetToDecimal)(b_token));
364
+ Amount = "".concat((0, bignumber_js_1.default)(deposit_amount).toFixed(), " ").concat(b_token);
365
+ break;
366
+ case "CloseStrategyEventV2":
367
+ Action = "Close Strategy";
368
+ if (b_token == d_token) {
369
+ balance = (Number(event.parsedJson.u64_padding[0]) + Number(event.parsedJson.u64_padding[1])) /
370
+ Math.pow(10, (0, token_1.assetToDecimal)(b_token));
371
+ Amount = "".concat((0, bignumber_js_1.default)(balance).toFixed(), " ").concat(b_token);
372
+ }
373
+ else {
374
+ balance = Number(event.parsedJson.u64_padding[0]) / Math.pow(10, (0, token_1.assetToDecimal)(b_token));
375
+ profit = Number(event.parsedJson.u64_padding[1]) / Math.pow(10, (0, token_1.assetToDecimal)(d_token));
376
+ Amount = "".concat((0, bignumber_js_1.default)(balance).toFixed(), " ").concat(b_token, "\n").concat((0, bignumber_js_1.default)(profit).toFixed(), " ").concat(d_token);
377
+ }
378
+ break;
266
379
  case "RedeemEvent":
267
380
  token = (0, token_1.typeArgToAsset)("0x" + event.parsedJson.token.name);
268
381
  amount = Number(event.parsedJson.amount) / Math.pow(10, (0, token_1.assetToDecimal)(token));
269
382
  Action = "Harvest";
270
383
  Amount = "".concat((0, bignumber_js_1.default)(amount).toFixed(), " ").concat(token);
271
- Index = event.parsedJson.index;
384
+ Index = Index;
272
385
  break;
273
386
  case "TransferBidReceiptEvent":
274
387
  amount = Number(event.parsedJson.amount) / Math.pow(10, Number(event.parsedJson.decimal));
@@ -284,6 +397,9 @@ function parseTxHistory(datas, originPackage, vaults) {
284
397
  size = Number(event.parsedJson.u64_padding[0]) / Math.pow(10, (0, token_1.assetToDecimal)(o_token));
285
398
  Action = "Exercise ".concat(size, " ").concat(o_token);
286
399
  }
400
+ if (event.sender != event.parsedJson.signer) {
401
+ Action = "Auto " + Action;
402
+ }
287
403
  break;
288
404
  case "RefundEvent":
289
405
  token = (0, token_1.typeArgToAsset)("0x" + event.parsedJson.token.name);
@@ -306,7 +422,12 @@ function parseTxHistory(datas, originPackage, vaults) {
306
422
  bidder_balance = Number(event.parsedJson.bidder_balance) / Math.pow(10, (0, token_1.assetToDecimal)(b_token));
307
423
  Action = action.slice(0, action.length - 5) + " ".concat(size, " ").concat(o_token);
308
424
  Amount = "".concat((0, bignumber_js_1.default)(bidder_balance).toFixed(), " ").concat(b_token);
425
+ if (event.sender != event.parsedJson.signer) {
426
+ Action = "Auto " + Action;
427
+ }
309
428
  if (i != -1) {
429
+ txHistory[i].Index = Index;
430
+ txHistory[i].Period = Period;
310
431
  txHistory[i].Action = Action;
311
432
  txHistory[i].Amount = Amount;
312
433
  txHistory[i].Vault = Vault;
@@ -340,3 +461,37 @@ function parseTxHistory(datas, originPackage, vaults) {
340
461
  });
341
462
  });
342
463
  }
464
+ function getUserBid(startTimestamp, userAddress) {
465
+ return __awaiter(this, void 0, void 0, function () {
466
+ var apiUrl, headers, requestData, jsonData, response, data;
467
+ return __generator(this, function (_a) {
468
+ switch (_a.label) {
469
+ case 0:
470
+ apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_v2/sql/execute";
471
+ headers = {
472
+ "api-key": "tz3JJ6stG7Fux6ueRSRA5mdpC9U0lozI3",
473
+ "Content-Type": "application/json",
474
+ };
475
+ requestData = {
476
+ sqlQuery: {
477
+ sql: "\n SELECT *\n FROM NewBid\n WHERE distinct_id = \"".concat(userAddress, "\" && timestamp >= ").concat(startTimestamp, "\n ORDER BY timestamp DESC;\n "),
478
+ size: 1000,
479
+ },
480
+ };
481
+ jsonData = JSON.stringify(requestData);
482
+ return [4 /*yield*/, fetch(apiUrl, {
483
+ method: "POST",
484
+ headers: headers,
485
+ body: jsonData,
486
+ })];
487
+ case 1:
488
+ response = _a.sent();
489
+ return [4 /*yield*/, response.json()];
490
+ case 2:
491
+ data = _a.sent();
492
+ return [2 /*return*/, data.result.rows];
493
+ }
494
+ });
495
+ });
496
+ }
497
+ exports.getUserBid = getUserBid;
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.2.50",
5
+ "version": "1.2.52",
6
6
  "dependencies": {
7
7
  "@mysten/bcs": "^0.7.3",
8
8
  "@mysten/kiosk": "0.8.4",