@typus/typus-sdk 1.1.8 → 1.1.10

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,2 +1,3 @@
1
1
  export declare function typeArgsToAssets(typeArgs: string[]): string[];
2
+ export declare function typeArgToAsset(typeArg: string): string;
2
3
  export declare function assetToDecimal(asset: string): number | undefined;
@@ -3,40 +3,42 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.assetToDecimal = exports.typeArgsToAssets = void 0;
6
+ exports.assetToDecimal = exports.typeArgToAsset = exports.typeArgsToAssets = void 0;
7
7
  var sui_js_1 = require("@mysten/sui.js");
8
8
  var config_json_1 = __importDefault(require("../config.json"));
9
9
  function typeArgsToAssets(typeArgs) {
10
- var assets = typeArgs.map(function (x) {
11
- var typeArgs = x.split("::");
12
- switch ((0, sui_js_1.normalizeSuiAddress)(typeArgs[0])) {
13
- case "0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881":
14
- return "WBTC";
15
- case "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5":
16
- return "WETH";
17
- case "0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8":
18
- return "SOL";
19
- case "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf":
20
- return "USDC";
21
- case "0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c":
22
- return "USDT";
23
- case "0x5d1f47ea69bb0de31c313d7acf89b890dbb8991ea8e03c6c355171f84bb1ba4a":
24
- return "TURBOS";
25
- case config_json_1.default.TOKEN_PACKAGE:
26
- if (typeArgs[2] == "BTC") {
27
- return "WBTC";
28
- }
29
- else if (typeArgs[2] == "ETH") {
30
- return "WETH";
31
- }
32
- return typeArgs[2];
33
- default:
34
- return typeArgs[2];
35
- }
36
- });
10
+ var assets = typeArgs.map(function (x) { return typeArgToAsset(x); });
37
11
  return assets;
38
12
  }
39
13
  exports.typeArgsToAssets = typeArgsToAssets;
14
+ function typeArgToAsset(typeArg) {
15
+ var typeArgs = typeArg.split("::");
16
+ switch ((0, sui_js_1.normalizeSuiAddress)(typeArgs[0])) {
17
+ case "0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881":
18
+ return "WBTC";
19
+ case "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5":
20
+ return "WETH";
21
+ case "0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8":
22
+ return "SOL";
23
+ case "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf":
24
+ return "USDC";
25
+ case "0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c":
26
+ return "USDT";
27
+ case "0x5d1f47ea69bb0de31c313d7acf89b890dbb8991ea8e03c6c355171f84bb1ba4a":
28
+ return "TURBOS";
29
+ case config_json_1.default.TOKEN_PACKAGE:
30
+ if (typeArgs[2] == "BTC") {
31
+ return "WBTC";
32
+ }
33
+ else if (typeArgs[2] == "ETH") {
34
+ return "WETH";
35
+ }
36
+ return typeArgs[2];
37
+ default:
38
+ return typeArgs[2];
39
+ }
40
+ }
41
+ exports.typeArgToAsset = typeArgToAsset;
40
42
  function assetToDecimal(asset) {
41
43
  switch (asset) {
42
44
  case "SUI":
@@ -42,24 +42,28 @@ export declare function getOtcTx(gasBudget: number, packageId: string, typeArgum
42
42
  ctx: &TxContext,
43
43
  ) {
44
44
  */
45
- export declare function getUpdateConfigTx(gasBudget: number, packageId: string, registry: string, index: string, config: {
46
- oracleId?: string;
47
- depositLotSize?: string;
48
- bidLotSize?: string;
49
- minDepositSize?: string;
50
- minBidSize?: string;
51
- maxDepositEntry?: string;
52
- maxBidEntry?: string;
53
- depositFeeBp?: string;
54
- depositFeeShareBp?: string;
55
- depositSharedFeePool?: string;
56
- bidFeeBp?: string;
57
- depositIncentiveBp?: string;
58
- bidIncentiveBp?: string;
59
- auctionDelayTsMs?: string;
60
- auctionDurationTsMs?: string;
61
- recoupDelayTsMs?: string;
62
- capacity?: string;
63
- leverage?: string;
64
- riskLevel?: string;
65
- }): Promise<TransactionBlock>;
45
+ export interface UpdateConfigRequests {
46
+ index: string;
47
+ config: {
48
+ oracleId?: string;
49
+ depositLotSize?: string;
50
+ bidLotSize?: string;
51
+ minDepositSize?: string;
52
+ minBidSize?: string;
53
+ maxDepositEntry?: string;
54
+ maxBidEntry?: string;
55
+ depositFeeBp?: string;
56
+ depositFeeShareBp?: string;
57
+ depositSharedFeePool?: string;
58
+ bidFeeBp?: string;
59
+ depositIncentiveBp?: string;
60
+ bidIncentiveBp?: string;
61
+ auctionDelayTsMs?: string;
62
+ auctionDurationTsMs?: string;
63
+ recoupDelayTsMs?: string;
64
+ capacity?: string;
65
+ leverage?: string;
66
+ riskLevel?: string;
67
+ };
68
+ }
69
+ export declare function getUpdateConfigTx(gasBudget: number, packageId: string, registry: string, requests: UpdateConfigRequests[]): Promise<TransactionBlock>;
@@ -125,63 +125,39 @@ function getOtcTx(gasBudget, packageId, typeArguments, registry, index, coins, d
125
125
  });
126
126
  }
127
127
  exports.getOtcTx = getOtcTx;
128
- /**
129
- public(friend) entry fun update_config(
130
- registry: &mut Registry,
131
- index: u64,
132
- oracle_id: Option<address>,
133
- deposit_lot_size: Option<u64>,
134
- bid_lot_size: Option<u64>,
135
- min_deposit_size: Option<u64>,
136
- min_bid_size: Option<u64>,
137
- max_deposit_entry: Option<u64>,
138
- max_bid_entry: Option<u64>,
139
- deposit_fee_bp: Option<u64>,
140
- deposit_fee_share_bp: Option<u64>,
141
- deposit_shared_fee_pool: Option<Option<vector<u8>>>,
142
- bid_fee_bp: Option<u64>,
143
- deposit_incentive_bp: Option<u64>,
144
- bid_incentive_bp: Option<u64>,
145
- auction_delay_ts_ms: Option<u64>,
146
- auction_duration_ts_ms: Option<u64>,
147
- recoup_delay_ts_ms: Option<u64>,
148
- capacity: Option<u64>,
149
- leverage: Option<u64>,
150
- risk_level: Option<u64>,
151
- ctx: &TxContext,
152
- ) {
153
- */
154
- function getUpdateConfigTx(gasBudget, packageId, registry, index, config) {
128
+ function getUpdateConfigTx(gasBudget, packageId, registry, requests) {
155
129
  return __awaiter(this, void 0, void 0, function () {
156
130
  var tx;
157
131
  return __generator(this, function (_a) {
158
132
  tx = new sui_js_1.TransactionBlock();
159
- tx.moveCall({
160
- target: "".concat(packageId, "::tds_authorized_entry::update_config"),
161
- typeArguments: [],
162
- arguments: [
163
- tx.object(registry),
164
- tx.pure(index),
165
- tx.pure(config.oracleId ? [config.oracleId] : []),
166
- tx.pure(config.depositLotSize ? [config.depositLotSize] : []),
167
- tx.pure(config.bidLotSize ? [config.bidLotSize] : []),
168
- tx.pure(config.minDepositSize ? [config.minDepositSize] : []),
169
- tx.pure(config.minBidSize ? [config.minBidSize] : []),
170
- tx.pure(config.maxDepositEntry ? [config.maxDepositEntry] : []),
171
- tx.pure(config.maxBidEntry ? [config.maxBidEntry] : []),
172
- tx.pure(config.depositFeeBp ? [config.depositFeeBp] : []),
173
- tx.pure(config.depositFeeShareBp ? [config.depositFeeShareBp] : []),
174
- tx.pure(config.depositSharedFeePool ? [config.depositSharedFeePool] : []),
175
- tx.pure(config.bidFeeBp ? [config.bidFeeBp] : []),
176
- tx.pure(config.depositIncentiveBp ? [config.depositIncentiveBp] : []),
177
- tx.pure(config.bidIncentiveBp ? [config.bidIncentiveBp] : []),
178
- tx.pure(config.auctionDelayTsMs ? [config.auctionDelayTsMs] : []),
179
- tx.pure(config.auctionDurationTsMs ? [config.auctionDurationTsMs] : []),
180
- tx.pure(config.recoupDelayTsMs ? [config.recoupDelayTsMs] : []),
181
- tx.pure(config.capacity ? [config.capacity] : []),
182
- tx.pure(config.leverage ? [config.leverage] : []),
183
- tx.pure(config.riskLevel ? [config.riskLevel] : []),
184
- ],
133
+ requests.forEach(function (request) {
134
+ tx.moveCall({
135
+ target: "".concat(packageId, "::tds_authorized_entry::update_config"),
136
+ typeArguments: [],
137
+ arguments: [
138
+ tx.object(registry),
139
+ tx.pure(request.index),
140
+ tx.pure(request.config.oracleId ? [request.config.oracleId] : []),
141
+ tx.pure(request.config.depositLotSize ? [request.config.depositLotSize] : []),
142
+ tx.pure(request.config.bidLotSize ? [request.config.bidLotSize] : []),
143
+ tx.pure(request.config.minDepositSize ? [request.config.minDepositSize] : []),
144
+ tx.pure(request.config.minBidSize ? [request.config.minBidSize] : []),
145
+ tx.pure(request.config.maxDepositEntry ? [request.config.maxDepositEntry] : []),
146
+ tx.pure(request.config.maxBidEntry ? [request.config.maxBidEntry] : []),
147
+ tx.pure(request.config.depositFeeBp ? [request.config.depositFeeBp] : []),
148
+ tx.pure(request.config.depositFeeShareBp ? [request.config.depositFeeShareBp] : []),
149
+ tx.pure(request.config.depositSharedFeePool ? [request.config.depositSharedFeePool] : []),
150
+ tx.pure(request.config.bidFeeBp ? [request.config.bidFeeBp] : []),
151
+ tx.pure(request.config.depositIncentiveBp ? [request.config.depositIncentiveBp] : []),
152
+ tx.pure(request.config.bidIncentiveBp ? [request.config.bidIncentiveBp] : []),
153
+ tx.pure(request.config.auctionDelayTsMs ? [request.config.auctionDelayTsMs] : []),
154
+ tx.pure(request.config.auctionDurationTsMs ? [request.config.auctionDurationTsMs] : []),
155
+ tx.pure(request.config.recoupDelayTsMs ? [request.config.recoupDelayTsMs] : []),
156
+ tx.pure(request.config.capacity ? [request.config.capacity] : []),
157
+ tx.pure(request.config.leverage ? [request.config.leverage] : []),
158
+ tx.pure(request.config.riskLevel ? [request.config.riskLevel] : []),
159
+ ],
160
+ });
185
161
  });
186
162
  tx.setGasBudget(gasBudget);
187
163
  return [2 /*return*/, tx];
@@ -81,6 +81,27 @@ export declare function getCompoundTx(gasBudget: number, typusFrameworkPackageId
81
81
  */
82
82
  export declare function getNewBidTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, index: string, coins: string[], size: string, premium_required: string, // fe float * b_token_decimal
83
83
  usingSponsoredGasCoin?: boolean): Promise<TransactionBlock>;
84
+ /**
85
+ public(friend) entry fun transfer_bid_receipt<D_TOKEN, B_TOKEN>(
86
+ registry: &mut Registry,
87
+ index: u64,
88
+ receipts: vector<TypusBidReceipt>,
89
+ share: Option<u64>,
90
+ recipient: address,
91
+ ctx: &mut TxContext,
92
+ ) {
93
+ */
94
+ export declare function getTransferBidReceiptTx(input: {
95
+ gasBudget: number;
96
+ typusFrameworkPackageId: string;
97
+ packageId: string;
98
+ typeArguments: string[];
99
+ registry: string;
100
+ index: string;
101
+ receipts: string[];
102
+ share?: string;
103
+ recipient: string;
104
+ }): Promise<TransactionBlock>;
84
105
  /**
85
106
  public(friend) entry fun exercise<D_TOKEN, B_TOKEN>(
86
107
  registry: &mut Registry,
@@ -52,7 +52,7 @@ var __read = (this && this.__read) || function (o, n) {
52
52
  return ar;
53
53
  };
54
54
  Object.defineProperty(exports, "__esModule", { value: true });
55
- exports.getRefundTx = exports.getExerciseTx = exports.getNewBidTx = exports.getCompoundTx = exports.getHarvestTx = exports.getClaimTx = exports.getUnsubscribeTx = exports.getWithdrawTx = exports.getDepositTx = void 0;
55
+ exports.getRefundTx = exports.getExerciseTx = exports.getTransferBidReceiptTx = exports.getNewBidTx = exports.getCompoundTx = exports.getHarvestTx = exports.getClaimTx = exports.getUnsubscribeTx = exports.getWithdrawTx = exports.getDepositTx = void 0;
56
56
  var sui_js_1 = require("@mysten/sui.js");
57
57
  var constants_1 = require("../../constants");
58
58
  /**
@@ -328,6 +328,41 @@ usingSponsoredGasCoin) {
328
328
  });
329
329
  }
330
330
  exports.getNewBidTx = getNewBidTx;
331
+ /**
332
+ public(friend) entry fun transfer_bid_receipt<D_TOKEN, B_TOKEN>(
333
+ registry: &mut Registry,
334
+ index: u64,
335
+ receipts: vector<TypusBidReceipt>,
336
+ share: Option<u64>,
337
+ recipient: address,
338
+ ctx: &mut TxContext,
339
+ ) {
340
+ */
341
+ function getTransferBidReceiptTx(input) {
342
+ return __awaiter(this, void 0, void 0, function () {
343
+ var tx;
344
+ return __generator(this, function (_a) {
345
+ tx = new sui_js_1.TransactionBlock();
346
+ tx.moveCall({
347
+ target: "".concat(input.packageId, "::tds_user_entry::transfer_bid_receipt"),
348
+ typeArguments: input.typeArguments,
349
+ arguments: [
350
+ tx.object(input.registry),
351
+ tx.pure(input.index),
352
+ tx.makeMoveVec({
353
+ type: "".concat(input.typusFrameworkPackageId, "::vault::TypusBidReceipt"),
354
+ objects: input.receipts.map(function (id) { return tx.object(id); }),
355
+ }),
356
+ tx.pure(input.share ? [input.share] : []),
357
+ tx.pure(input.recipient),
358
+ ],
359
+ });
360
+ tx.setGasBudget(input.gasBudget);
361
+ return [2 /*return*/, tx];
362
+ });
363
+ });
364
+ }
365
+ exports.getTransferBidReceiptTx = getTransferBidReceiptTx;
331
366
  /**
332
367
  public(friend) entry fun exercise<D_TOKEN, B_TOKEN>(
333
368
  registry: &mut Registry,
@@ -75,16 +75,17 @@ function getUserHistory(provider, originPackage, vaults, sender, startTimeMs) {
75
75
  exports.getUserHistory = getUserHistory;
76
76
  function parseTxHistory(datas, originPackage, vaults) {
77
77
  return __awaiter(this, void 0, void 0, function () {
78
+ var results;
78
79
  var _this = this;
79
80
  return __generator(this, function (_a) {
80
81
  switch (_a.label) {
81
82
  case 0: return [4 /*yield*/, datas
82
83
  .filter(function (event) {
83
84
  var type = event.type;
84
- return type.startsWith(originPackage) || type.includes("typus_nft::First");
85
+ return type.startsWith(originPackage) || type.includes("typus_nft::First") || type.includes("typus_nft::ExpUpEvent");
85
86
  })
86
87
  .reduce(function (promise, event) { return __awaiter(_this, void 0, void 0, function () {
87
- var txHistory, functionType, action, Action, Amount, Vault, RiskLevel, Tails, Exp, v, period, optionType, i, i, token, amount;
88
+ var txHistory, functionType, action, Action, Amount, Vault, RiskLevel, Tails, Exp, o_token, v, period, optionType, i, i, token, amount, i, token, amount, size, token, amount, i, b_token, size, bidder_balance, i;
88
89
  var _a;
89
90
  return __generator(this, function (_b) {
90
91
  switch (_b.label) {
@@ -137,6 +138,7 @@ function parseTxHistory(datas, originPackage, vaults) {
137
138
  break;
138
139
  }
139
140
  Vault = "".concat(v.info.settlementBaseName, " ").concat(period, " ").concat(optionType);
141
+ o_token = (0, token_1.typeArgToAsset)("0x" + v.info.settlementBase);
140
142
  }
141
143
  switch (action) {
142
144
  case "StakeNftEvent":
@@ -156,8 +158,8 @@ function parseTxHistory(datas, originPackage, vaults) {
156
158
  Exp = event.parsedJson.exp_earn;
157
159
  }
158
160
  else {
159
- txHistory[i].Exp = event.parsedJson.exp_earn;
160
161
  txHistory[i].Tails = "#".concat(event.parsedJson.number);
162
+ txHistory[i].Exp = event.parsedJson.exp_earn;
161
163
  return [2 /*return*/, txHistory];
162
164
  }
163
165
  break;
@@ -191,7 +193,7 @@ function parseTxHistory(datas, originPackage, vaults) {
191
193
  case "ClaimEvent":
192
194
  case "HarvestEvent":
193
195
  i = txHistory.findIndex(function (x) { return x.txDigest == event.id.txDigest; });
194
- token = (0, token_1.typeArgsToAssets)(["0x" + event.parsedJson.token.name])[0];
196
+ token = (0, token_1.typeArgToAsset)("0x" + event.parsedJson.token.name);
195
197
  amount = Number(event.parsedJson.amount) / Math.pow(10, Number(event.parsedJson.decimal));
196
198
  Action = action.slice(0, action.length - 5);
197
199
  Amount = "".concat(amount, " ").concat(token);
@@ -203,6 +205,51 @@ function parseTxHistory(datas, originPackage, vaults) {
203
205
  return [2 /*return*/, txHistory];
204
206
  }
205
207
  break;
208
+ case "ExerciseEvent":
209
+ i = txHistory.findIndex(function (x) { return x.txDigest == event.id.txDigest; });
210
+ token = (0, token_1.typeArgToAsset)("0x" + event.parsedJson.token.name);
211
+ amount = Number(event.parsedJson.amount) / Math.pow(10, Number(event.parsedJson.decimal));
212
+ Action = "Exercise";
213
+ Amount = "".concat(amount, " ").concat(token);
214
+ if (event.parsedJson.u64_padding[0]) {
215
+ size = Number(event.parsedJson.u64_padding[0]) / Math.pow(10, (0, token_1.assetToDecimal)(o_token));
216
+ Action = "Exercise ".concat(size, " ").concat(o_token);
217
+ }
218
+ break;
219
+ case "RefundEvent":
220
+ token = (0, token_1.typeArgToAsset)("0x" + event.parsedJson.token.name);
221
+ amount = Number(event.parsedJson.amount) / Math.pow(10, (0, token_1.assetToDecimal)(token));
222
+ Action = "Rebate";
223
+ Amount = "".concat(amount, " ").concat(token);
224
+ break;
225
+ case "NewBidEvent":
226
+ i = txHistory.findIndex(function (x) { return x.txDigest == event.id.txDigest; });
227
+ o_token = (0, token_1.typeArgToAsset)("0x" + event.parsedJson.o_token.name);
228
+ b_token = (0, token_1.typeArgToAsset)("0x" + event.parsedJson.b_token.name);
229
+ size = Number(event.parsedJson.size) / Math.pow(10, (0, token_1.assetToDecimal)(o_token));
230
+ bidder_balance = Number(event.parsedJson.bidder_balance) / Math.pow(10, (0, token_1.assetToDecimal)(b_token));
231
+ Action = action.slice(0, action.length - 5) + " ".concat(size, " ").concat(o_token);
232
+ Amount = "".concat(bidder_balance, " ").concat(b_token);
233
+ if (i != -1) {
234
+ txHistory[i].Action = Action;
235
+ txHistory[i].Amount = Amount;
236
+ txHistory[i].Vault = Vault;
237
+ txHistory[i].RiskLevel = RiskLevel;
238
+ return [2 /*return*/, txHistory];
239
+ }
240
+ break;
241
+ case "ExpUpEvent":
242
+ i = txHistory.findIndex(function (x) { return x.txDigest == event.id.txDigest; });
243
+ if (i != -1) {
244
+ txHistory[i].Tails = "#".concat(event.parsedJson.number);
245
+ txHistory[i].Exp = event.parsedJson.exp_earn;
246
+ return [2 /*return*/, txHistory];
247
+ }
248
+ else {
249
+ Tails = "#".concat(event.parsedJson.number);
250
+ Exp = event.parsedJson.exp_earn;
251
+ }
252
+ break;
206
253
  default:
207
254
  return [2 /*return*/, txHistory];
208
255
  }
@@ -220,7 +267,9 @@ function parseTxHistory(datas, originPackage, vaults) {
220
267
  }
221
268
  });
222
269
  }); }, Promise.resolve(new Array()))];
223
- case 1: return [2 /*return*/, _a.sent()];
270
+ case 1:
271
+ results = _a.sent();
272
+ return [2 /*return*/, results.filter(function (result) { return result.Action; })];
224
273
  }
225
274
  });
226
275
  });
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.1.8",
5
+ "version": "1.1.10",
6
6
  "dependencies": {
7
7
  "@mysten/bcs": "^0.7.3",
8
8
  "@mysten/kiosk": "^0.3.3",