@typus/typus-sdk 1.1.9 → 1.1.11

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,11 +1,7 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.assetToDecimal = exports.typeArgToAsset = exports.typeArgsToAssets = void 0;
7
4
  var sui_js_1 = require("@mysten/sui.js");
8
- var config_json_1 = __importDefault(require("../config.json"));
9
5
  function typeArgsToAssets(typeArgs) {
10
6
  var assets = typeArgs.map(function (x) { return typeArgToAsset(x); });
11
7
  return assets;
@@ -19,22 +15,25 @@ function typeArgToAsset(typeArg) {
19
15
  case "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5":
20
16
  return "WETH";
21
17
  case "0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8":
22
- return "SOL";
18
+ return "WSOL";
23
19
  case "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf":
24
20
  return "USDC";
25
21
  case "0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c":
26
22
  return "USDT";
27
23
  case "0x5d1f47ea69bb0de31c313d7acf89b890dbb8991ea8e03c6c355171f84bb1ba4a":
28
24
  return "TURBOS";
29
- case config_json_1.default.TOKEN_PACKAGE:
25
+ case "0x3a5143bb1196e3bcdfab6203d1683ae29edd26294fc8bfeafe4aaa9d2704df37":
26
+ return "APT";
27
+ default:
30
28
  if (typeArgs[2] == "BTC") {
31
29
  return "WBTC";
32
30
  }
33
31
  else if (typeArgs[2] == "ETH") {
34
32
  return "WETH";
35
33
  }
36
- return typeArgs[2];
37
- default:
34
+ else if (typeArgs[2] == "SOL") {
35
+ return "WSOL";
36
+ }
38
37
  return typeArgs[2];
39
38
  }
40
39
  }
@@ -51,6 +50,8 @@ function assetToDecimal(asset) {
51
50
  return 8;
52
51
  case "WETH":
53
52
  return 8;
53
+ case "SOL":
54
+ return 8;
54
55
  case "WSOL":
55
56
  return 8;
56
57
  case "USDC":
@@ -61,6 +62,8 @@ function assetToDecimal(asset) {
61
62
  return 9;
62
63
  case "TURBOS":
63
64
  return 9;
65
+ case "APT":
66
+ return 8;
64
67
  }
65
68
  }
66
69
  exports.assetToDecimal = assetToDecimal;
@@ -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,
@@ -85,7 +85,7 @@ function parseTxHistory(datas, originPackage, vaults) {
85
85
  return type.startsWith(originPackage) || type.includes("typus_nft::First") || type.includes("typus_nft::ExpUpEvent");
86
86
  })
87
87
  .reduce(function (promise, event) { return __awaiter(_this, void 0, void 0, function () {
88
- var txHistory, functionType, action, Action, Amount, Vault, RiskLevel, Tails, Exp, v, period, optionType, i, i, token, amount, i, o_token, b_token, size, bidder_balance, i;
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;
89
89
  var _a;
90
90
  return __generator(this, function (_b) {
91
91
  switch (_b.label) {
@@ -138,6 +138,7 @@ function parseTxHistory(datas, originPackage, vaults) {
138
138
  break;
139
139
  }
140
140
  Vault = "".concat(v.info.settlementBaseName, " ").concat(period, " ").concat(optionType);
141
+ o_token = (0, token_1.typeArgToAsset)("0x" + v.info.settlementBase);
141
142
  }
142
143
  switch (action) {
143
144
  case "StakeNftEvent":
@@ -204,6 +205,23 @@ function parseTxHistory(datas, originPackage, vaults) {
204
205
  return [2 /*return*/, txHistory];
205
206
  }
206
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;
207
225
  case "NewBidEvent":
208
226
  i = txHistory.findIndex(function (x) { return x.txDigest == event.id.txDigest; });
209
227
  o_token = (0, token_1.typeArgToAsset)("0x" + event.parsedJson.o_token.name);
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.9",
5
+ "version": "1.1.11",
6
6
  "dependencies": {
7
7
  "@mysten/bcs": "^0.7.3",
8
8
  "@mysten/kiosk": "^0.3.3",