@typus/typus-sdk 1.4.29 → 1.4.30

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.
@@ -20,7 +20,7 @@
20
20
  "ORACLE": "0x978f65df8570a075298598a9965c18de9087f9e888eb3430fe20334f5c554cfd",
21
21
  "TYPUS": "0xea14501c603e8fcd907087d3aa7cb7adb4d7b3a7ea5e078cc9e8f05c67bc8034",
22
22
  "PERP": "",
23
- "SAFU": "0x3ac130176f586d3eaa763dfbe0b777eac5bd422ef85131fe8752208215157189"
23
+ "SAFU": "0xee11b5672d83f474e1337d10b472dadc45ae827fb53843986a9d8a8b28c9dc77"
24
24
  },
25
25
  "VERSION": {
26
26
  "TYPUS": "0xd2882b992e986250b3304b59530700bc3850939f9a77e9e9dfa9cf1656f84b3d",
@@ -151,7 +151,7 @@ function getHistory(config, input) {
151
151
  break;
152
152
  }
153
153
  eventFilter = {
154
- MoveEventType: "".concat(registry, "::").concat(module, "::Draw"),
154
+ MoveEventType: "".concat(registry, "::").concat(input.module, "::Draw"),
155
155
  };
156
156
  return [4 /*yield*/, provider.queryEvents({ query: eventFilter, order: "descending" })];
157
157
  case 1:
@@ -82,7 +82,7 @@ function newGameTx(config, tx, input) {
82
82
  break;
83
83
  }
84
84
  tx.moveCall({
85
- target: "".concat(config.package.dice, "::").concat(module, "::new_game"),
85
+ target: "".concat(config.package.dice, "::").concat(input.module, "::new_game"),
86
86
  typeArguments: input.typeArguments,
87
87
  arguments: [
88
88
  tx.object(registry),
@@ -123,7 +123,7 @@ function playGuessTx(config, tx, input) {
123
123
  break;
124
124
  }
125
125
  tx.moveCall({
126
- target: "".concat(config.package.dice, "::").concat(module, "::play_guess"),
126
+ target: "".concat(config.package.dice, "::").concat(input.module, "::play_guess"),
127
127
  typeArguments: [],
128
128
  arguments: [
129
129
  tx.object(registry),
@@ -157,7 +157,7 @@ function newGamePlayGuessTx(config, tx, input) {
157
157
  input.typeArguments[0] == "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI") {
158
158
  _a = __read(tx.splitCoins(tx.gas, [tx.pure(input.amount)]), 1), coin = _a[0];
159
159
  tx.moveCall({
160
- target: "".concat(config.package.dice, "::").concat(module, "::new_game"),
160
+ target: "".concat(config.package.dice, "::").concat(input.module, "::new_game"),
161
161
  typeArguments: input.typeArguments,
162
162
  arguments: input.module == "combo_dice"
163
163
  ? [
@@ -172,7 +172,7 @@ function newGamePlayGuessTx(config, tx, input) {
172
172
  }
173
173
  else {
174
174
  tx.moveCall({
175
- target: "".concat(config.package.dice, "::").concat(module, "::new_game"),
175
+ target: "".concat(config.package.dice, "::").concat(input.module, "::new_game"),
176
176
  typeArguments: input.typeArguments,
177
177
  arguments: [
178
178
  tx.object(registry),
@@ -183,7 +183,7 @@ function newGamePlayGuessTx(config, tx, input) {
183
183
  });
184
184
  }
185
185
  tx.moveCall({
186
- target: "".concat(config.package.dice, "::").concat(module, "::play_guess"),
186
+ target: "".concat(config.package.dice, "::").concat(input.module, "::play_guess"),
187
187
  typeArguments: [],
188
188
  arguments: [
189
189
  tx.object(registry),
@@ -196,7 +196,7 @@ function newGamePlayGuessTx(config, tx, input) {
196
196
  });
197
197
  // TODO: waiting for upgrade
198
198
  // tx.moveCall({
199
- // target: `${packageId}::${module}::play_guess_with_random`,
199
+ // target: `${packageId}::${input.module}::play_guess_with_random`,
200
200
  // typeArguments: module == "combo_dice" ? typeArguments : [],
201
201
  // arguments: [
202
202
  // tx.object(registry),
@@ -72,7 +72,7 @@ function simulateGame(config, input) {
72
72
  break;
73
73
  }
74
74
  transactionBlock.moveCall({
75
- target: "".concat(config.package.dice, "::").concat(module, "::simulate_game"),
75
+ target: "".concat(config.package.dice, "::").concat(input.module, "::simulate_game"),
76
76
  typeArguments: [],
77
77
  arguments: [
78
78
  transactionBlock.object(registry),
@@ -4,9 +4,20 @@ export interface TxHistory {
4
4
  Action: string;
5
5
  Index: string;
6
6
  Amount: string;
7
+ Token: string;
7
8
  Exp: string | undefined;
8
9
  Date: Date;
9
10
  txDigest: string;
10
11
  log: string[];
11
12
  }
12
13
  export declare function parseTxHistory(datas: Array<any>, originPackage: string): Promise<Array<TxHistory>>;
14
+ export declare function getDepositorCashFlows(userHistory: TxHistory[]): Map<string, DepositorCashFlow>;
15
+ export interface DepositorCashFlow {
16
+ D_TOKEN: string | undefined;
17
+ totalDeposit: number;
18
+ totalWithdraw: number;
19
+ totalClaim: number;
20
+ totalCompound: number;
21
+ netDeposit: number | undefined;
22
+ totalHarvest: Map<string, number>;
23
+ }
@@ -35,9 +35,39 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
36
  }
37
37
  };
38
+ var __values = (this && this.__values) || function(o) {
39
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
40
+ if (m) return m.call(o);
41
+ if (o && typeof o.length === "number") return {
42
+ next: function () {
43
+ if (o && i >= o.length) o = void 0;
44
+ return { value: o && o[i++], done: !o };
45
+ }
46
+ };
47
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
48
+ };
49
+ var __read = (this && this.__read) || function (o, n) {
50
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
51
+ if (!m) return o;
52
+ var i = m.call(o), r, ar = [], e;
53
+ try {
54
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
55
+ }
56
+ catch (error) { e = { error: error }; }
57
+ finally {
58
+ try {
59
+ if (r && !r.done && (m = i["return"])) m.call(i);
60
+ }
61
+ finally { if (e) throw e.error; }
62
+ }
63
+ return ar;
64
+ };
38
65
  Object.defineProperty(exports, "__esModule", { value: true });
39
66
  exports.getUserEvents = getUserEvents;
40
67
  exports.parseTxHistory = parseTxHistory;
68
+ exports.getDepositorCashFlows = getDepositorCashFlows;
69
+ var bcs_1 = require("@mysten/bcs");
70
+ var constants_1 = require("../../src/constants");
41
71
  function getUserEvents(provider, sender, cursor) {
42
72
  return __awaiter(this, void 0, void 0, function () {
43
73
  var senderFilter, hasNextPage, datas, result;
@@ -91,7 +121,7 @@ function parseTxHistory(datas, originPackage // safu package
91
121
  }
92
122
  })
93
123
  .reduce(function (promise, event) { return __awaiter(_this, void 0, void 0, function () {
94
- var txHistory, action, log;
124
+ var txHistory, action, log, reader, Token, asset, decimal;
95
125
  return __generator(this, function (_a) {
96
126
  switch (_a.label) {
97
127
  case 0: return [4 /*yield*/, promise];
@@ -99,77 +129,91 @@ function parseTxHistory(datas, originPackage // safu package
99
129
  txHistory = _a.sent();
100
130
  action = event.parsedJson.action;
101
131
  log = event.parsedJson.log;
102
- switch (action) {
103
- case "raise_fund":
104
- if (Number(log[2]) + Number(log[3]) + Number(log[4]) + Number(log[5]) > 0) {
105
- txHistory.push({
106
- Action: "Deposit",
107
- Index: log[0],
108
- Amount: (Number(log[2]) + Number(log[3]) + Number(log[4]) + Number(log[5])).toString(),
109
- Exp: log[6],
110
- Date: new Date(Number(event.timestampMs)),
111
- txDigest: event.id.txDigest,
112
- log: log,
113
- });
114
- }
115
- if (Number(log[5]) > 0) {
116
- txHistory.push({
117
- Action: "Compound",
118
- Index: log[0],
119
- Amount: Number(log[5]).toString(),
120
- Exp: log[6],
121
- Date: new Date(Number(event.timestampMs)),
122
- txDigest: event.id.txDigest,
123
- log: log,
124
- });
125
- }
126
- break;
127
- case "reduce_fund":
128
- if (Number(log[2]) > 0) {
129
- txHistory.push({
130
- Action: "Withdraw",
131
- Index: log[0],
132
- Amount: Number(log[2]).toString(),
133
- Exp: log[5],
134
- Date: new Date(Number(event.timestampMs)),
135
- txDigest: event.id.txDigest,
136
- log: log,
137
- });
138
- }
139
- if (Number(log[3]) > 0) {
132
+ // skip the event without tokenType
133
+ if (event.parsedJson.bcs_padding.length > 0) {
134
+ reader = new bcs_1.BcsReader(new Uint8Array(event.parsedJson.bcs_padding[0]));
135
+ Token = String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.read8())));
136
+ asset = (0, constants_1.typeArgToAsset)(Token);
137
+ decimal = (0, constants_1.assetToDecimal)(asset);
138
+ // console.log(asset, decimal);
139
+ switch (action) {
140
+ case "raise_fund":
141
+ if (Number(log[2]) + Number(log[3]) + Number(log[4]) > 0) {
142
+ txHistory.push({
143
+ Action: "Deposit",
144
+ Index: log[0],
145
+ Amount: divByDecimal(Number(log[2]) + Number(log[3]) + Number(log[4]), decimal),
146
+ Token: Token,
147
+ Exp: log[6],
148
+ Date: new Date(Number(event.timestampMs)),
149
+ txDigest: event.id.txDigest,
150
+ log: log,
151
+ });
152
+ }
153
+ if (Number(log[5]) > 0) {
154
+ txHistory.push({
155
+ Action: "Compound",
156
+ Index: log[0],
157
+ Amount: divByDecimal(Number(log[5]), decimal),
158
+ Token: Token,
159
+ Exp: log[6],
160
+ Date: new Date(Number(event.timestampMs)),
161
+ txDigest: event.id.txDigest,
162
+ log: log,
163
+ });
164
+ }
165
+ break;
166
+ case "reduce_fund":
167
+ if (Number(log[2]) > 0) {
168
+ txHistory.push({
169
+ Action: "Withdraw",
170
+ Index: log[0],
171
+ Amount: divByDecimal(Number(log[2]), decimal),
172
+ Token: Token,
173
+ Exp: log[5],
174
+ Date: new Date(Number(event.timestampMs)),
175
+ txDigest: event.id.txDigest,
176
+ log: log,
177
+ });
178
+ }
179
+ if (Number(log[3]) > 0) {
180
+ txHistory.push({
181
+ Action: "Unsubscribe",
182
+ Index: log[0],
183
+ Amount: divByDecimal(Number(log[3]), decimal),
184
+ Token: Token,
185
+ Exp: log[5],
186
+ Date: new Date(Number(event.timestampMs)),
187
+ txDigest: event.id.txDigest,
188
+ log: log,
189
+ });
190
+ }
191
+ if (Number(log[4]) > 0) {
192
+ txHistory.push({
193
+ Action: "Claim",
194
+ Index: log[0],
195
+ Amount: divByDecimal(Number(log[4]), decimal),
196
+ Token: Token,
197
+ Exp: log[5],
198
+ Date: new Date(Number(event.timestampMs)),
199
+ txDigest: event.id.txDigest,
200
+ log: log,
201
+ });
202
+ }
203
+ break;
204
+ case "claim_reward":
140
205
  txHistory.push({
141
- Action: "Unsubscribe",
206
+ Action: "Harvest Options Profit",
142
207
  Index: log[0],
143
- Amount: Number(log[3]).toString(),
144
- Exp: log[5],
208
+ Amount: divByDecimal(Number(log[2]), decimal),
209
+ Token: Token,
210
+ Exp: undefined,
145
211
  Date: new Date(Number(event.timestampMs)),
146
212
  txDigest: event.id.txDigest,
147
213
  log: log,
148
214
  });
149
- }
150
- if (Number(log[4]) > 0) {
151
- txHistory.push({
152
- Action: "Claim",
153
- Index: log[0],
154
- Amount: Number(log[4]).toString(),
155
- Exp: log[5],
156
- Date: new Date(Number(event.timestampMs)),
157
- txDigest: event.id.txDigest,
158
- log: log,
159
- });
160
- }
161
- break;
162
- case "claim_reward":
163
- txHistory.push({
164
- Action: "Harvest Options Profit",
165
- Index: log[0],
166
- Amount: Number(log[2]).toString(),
167
- Exp: undefined,
168
- Date: new Date(Number(event.timestampMs)),
169
- txDigest: event.id.txDigest,
170
- log: log,
171
- });
172
- break;
215
+ break;
216
+ }
173
217
  }
174
218
  return [2 /*return*/, txHistory];
175
219
  }
@@ -182,131 +226,149 @@ function parseTxHistory(datas, originPackage // safu package
182
226
  });
183
227
  });
184
228
  }
185
- // export function getDepositorCashFlows(userHistory: TxHistory[]) {
186
- // let depositorCashFlows = new Map<string, DepositorCashFlow>();
187
- // for (let history of userHistory) {
188
- // const index = history.Index!;
189
- // if (history.Action!.startsWith("Harvest Reward")) {
190
- // let historyAmounts = history.Amount?.split("\n")!;
191
- // for (let historyAmount of historyAmounts) {
192
- // const [amount, token] = historyAmount.split(" ")!;
193
- // if (depositorCashFlows.has(index)) {
194
- // let depositorCashFlow = depositorCashFlows.get(index)!;
195
- // let totalHarvest = depositorCashFlow.totalHarvest;
196
- // if (totalHarvest.has(token)) {
197
- // let sum = totalHarvest.get(token)!;
198
- // totalHarvest.set(token, sum + Number(amount));
199
- // } else {
200
- // totalHarvest.set(token, Number(amount));
201
- // }
202
- // depositorCashFlow.totalHarvest = totalHarvest;
203
- // depositorCashFlows.set(index, depositorCashFlow);
204
- // } else {
205
- // let totalHarvest = new Map();
206
- // totalHarvest.set(token, Number(amount));
207
- // let depositorCashFlow: DepositorCashFlow = {
208
- // D_TOKEN: undefined,
209
- // totalDeposit: 0,
210
- // totalWithdraw: 0,
211
- // totalClaim: 0,
212
- // totalCompound: 0,
213
- // netDeposit: undefined,
214
- // totalHarvest,
215
- // };
216
- // depositorCashFlows.set(index, depositorCashFlow);
217
- // }
218
- // }
219
- // } else if (history.Action!.startsWith("Deposit")) {
220
- // const [amount, token] = history.Amount?.split(" ")!;
221
- // if (depositorCashFlows.has(index)) {
222
- // let depositorCashFlow = depositorCashFlows.get(index)!;
223
- // depositorCashFlow.D_TOKEN = token;
224
- // depositorCashFlow.totalDeposit += Number(amount);
225
- // depositorCashFlows.set(index, depositorCashFlow);
226
- // } else {
227
- // let depositorCashFlow: DepositorCashFlow = {
228
- // D_TOKEN: token,
229
- // totalDeposit: Number(amount),
230
- // totalWithdraw: 0,
231
- // totalClaim: 0,
232
- // totalCompound: 0,
233
- // netDeposit: undefined,
234
- // totalHarvest: new Map(),
235
- // };
236
- // depositorCashFlows.set(index, depositorCashFlow);
237
- // }
238
- // } else if (history.Action!.startsWith("Withdraw")) {
239
- // const [amount, token] = history.Amount?.split(" ")!;
240
- // if (depositorCashFlows.has(index)) {
241
- // let depositorCashFlow = depositorCashFlows.get(index)!;
242
- // depositorCashFlow.D_TOKEN = token;
243
- // depositorCashFlow.totalWithdraw += Number(amount);
244
- // depositorCashFlows.set(index, depositorCashFlow);
245
- // } else {
246
- // let depositorCashFlow: DepositorCashFlow = {
247
- // D_TOKEN: token,
248
- // totalDeposit: 0,
249
- // totalWithdraw: Number(amount),
250
- // totalClaim: 0,
251
- // totalCompound: 0,
252
- // netDeposit: undefined,
253
- // totalHarvest: new Map(),
254
- // };
255
- // depositorCashFlows.set(index, depositorCashFlow);
256
- // }
257
- // } else if (history.Action! == "Claim") {
258
- // const [amount, token] = history.Amount?.split(" ")!;
259
- // if (depositorCashFlows.has(index)) {
260
- // let depositorCashFlow = depositorCashFlows.get(index)!;
261
- // depositorCashFlow.D_TOKEN = token;
262
- // depositorCashFlow.totalClaim += Number(amount);
263
- // depositorCashFlows.set(index, depositorCashFlow);
264
- // } else {
265
- // let depositorCashFlow: DepositorCashFlow = {
266
- // D_TOKEN: token,
267
- // totalDeposit: 0,
268
- // totalWithdraw: 0,
269
- // totalClaim: Number(amount),
270
- // totalCompound: 0,
271
- // netDeposit: undefined,
272
- // totalHarvest: new Map(),
273
- // };
274
- // depositorCashFlows.set(index, depositorCashFlow);
275
- // }
276
- // } else if (history.Action! == "Compound") {
277
- // const [amount, token] = history.Amount?.split(" ")!;
278
- // if (depositorCashFlows.has(index)) {
279
- // let depositorCashFlow = depositorCashFlows.get(index)!;
280
- // depositorCashFlow.D_TOKEN = token;
281
- // depositorCashFlow.totalCompound += Number(amount);
282
- // depositorCashFlows.set(index, depositorCashFlow);
283
- // } else {
284
- // let depositorCashFlow: DepositorCashFlow = {
285
- // D_TOKEN: token,
286
- // totalDeposit: 0,
287
- // totalWithdraw: 0,
288
- // totalClaim: 0,
289
- // totalCompound: Number(amount),
290
- // netDeposit: undefined,
291
- // totalHarvest: new Map(),
292
- // };
293
- // depositorCashFlows.set(index, depositorCashFlow);
294
- // }
295
- // }
296
- // }
297
- // // console.log(depositorCashFlows);
298
- // for (let [index, share] of depositorCashFlows.entries()) {
299
- // share.netDeposit = share.totalDeposit + share.totalCompound - share.totalWithdraw - share.totalClaim;
300
- // depositorCashFlows.set(index, share);
301
- // }
302
- // return depositorCashFlows;
303
- // }
304
- // export interface DepositorCashFlow {
305
- // D_TOKEN: string | undefined;
306
- // totalDeposit: number;
307
- // totalWithdraw: number;
308
- // totalClaim: number;
309
- // totalCompound: number;
310
- // netDeposit: number | undefined;
311
- // totalHarvest: Map<string, number>;
312
- // }
229
+ function divByDecimal(numerator, decimal) {
230
+ return (numerator / Math.pow(10, decimal)).toString();
231
+ }
232
+ function getDepositorCashFlows(userHistory) {
233
+ var e_1, _a, e_2, _b;
234
+ var depositorCashFlows = new Map();
235
+ try {
236
+ for (var userHistory_1 = __values(userHistory), userHistory_1_1 = userHistory_1.next(); !userHistory_1_1.done; userHistory_1_1 = userHistory_1.next()) {
237
+ var history_1 = userHistory_1_1.value;
238
+ var index = history_1.Index;
239
+ var _c = __read([history_1.Amount, history_1.Token], 2), amount = _c[0], token = _c[1];
240
+ if (history_1.Action == "Harvest Options Profit") {
241
+ if (depositorCashFlows.has(index)) {
242
+ var depositorCashFlow = depositorCashFlows.get(index);
243
+ var totalHarvest = depositorCashFlow.totalHarvest;
244
+ if (totalHarvest.has(token)) {
245
+ var sum = totalHarvest.get(token);
246
+ totalHarvest.set(token, sum + Number(amount));
247
+ }
248
+ else {
249
+ totalHarvest.set(token, Number(amount));
250
+ }
251
+ depositorCashFlow.totalHarvest = totalHarvest;
252
+ depositorCashFlows.set(index, depositorCashFlow);
253
+ }
254
+ else {
255
+ var totalHarvest = new Map();
256
+ totalHarvest.set(token, Number(amount));
257
+ var depositorCashFlow = {
258
+ D_TOKEN: undefined,
259
+ totalDeposit: 0,
260
+ totalWithdraw: 0,
261
+ totalClaim: 0,
262
+ totalCompound: 0,
263
+ netDeposit: undefined,
264
+ totalHarvest: totalHarvest,
265
+ };
266
+ depositorCashFlows.set(index, depositorCashFlow);
267
+ }
268
+ }
269
+ else if (history_1.Action == "Deposit") {
270
+ if (depositorCashFlows.has(index)) {
271
+ var depositorCashFlow = depositorCashFlows.get(index);
272
+ depositorCashFlow.D_TOKEN = token;
273
+ depositorCashFlow.totalDeposit += Number(amount);
274
+ depositorCashFlows.set(index, depositorCashFlow);
275
+ }
276
+ else {
277
+ var depositorCashFlow = {
278
+ D_TOKEN: token,
279
+ totalDeposit: Number(amount),
280
+ totalWithdraw: 0,
281
+ totalClaim: 0,
282
+ totalCompound: 0,
283
+ netDeposit: undefined,
284
+ totalHarvest: new Map(),
285
+ };
286
+ depositorCashFlows.set(index, depositorCashFlow);
287
+ }
288
+ }
289
+ else if (history_1.Action == "Withdraw") {
290
+ if (depositorCashFlows.has(index)) {
291
+ var depositorCashFlow = depositorCashFlows.get(index);
292
+ depositorCashFlow.D_TOKEN = token;
293
+ depositorCashFlow.totalWithdraw += Number(amount);
294
+ depositorCashFlows.set(index, depositorCashFlow);
295
+ }
296
+ else {
297
+ var depositorCashFlow = {
298
+ D_TOKEN: token,
299
+ totalDeposit: 0,
300
+ totalWithdraw: Number(amount),
301
+ totalClaim: 0,
302
+ totalCompound: 0,
303
+ netDeposit: undefined,
304
+ totalHarvest: new Map(),
305
+ };
306
+ depositorCashFlows.set(index, depositorCashFlow);
307
+ }
308
+ }
309
+ else if (history_1.Action == "Claim") {
310
+ if (depositorCashFlows.has(index)) {
311
+ var depositorCashFlow = depositorCashFlows.get(index);
312
+ depositorCashFlow.D_TOKEN = token;
313
+ depositorCashFlow.totalClaim += Number(amount);
314
+ depositorCashFlows.set(index, depositorCashFlow);
315
+ }
316
+ else {
317
+ var depositorCashFlow = {
318
+ D_TOKEN: token,
319
+ totalDeposit: 0,
320
+ totalWithdraw: 0,
321
+ totalClaim: Number(amount),
322
+ totalCompound: 0,
323
+ netDeposit: undefined,
324
+ totalHarvest: new Map(),
325
+ };
326
+ depositorCashFlows.set(index, depositorCashFlow);
327
+ }
328
+ }
329
+ else if (history_1.Action == "Compound") {
330
+ if (depositorCashFlows.has(index)) {
331
+ var depositorCashFlow = depositorCashFlows.get(index);
332
+ depositorCashFlow.D_TOKEN = token;
333
+ depositorCashFlow.totalCompound += Number(amount);
334
+ depositorCashFlows.set(index, depositorCashFlow);
335
+ }
336
+ else {
337
+ var depositorCashFlow = {
338
+ D_TOKEN: token,
339
+ totalDeposit: 0,
340
+ totalWithdraw: 0,
341
+ totalClaim: 0,
342
+ totalCompound: Number(amount),
343
+ netDeposit: undefined,
344
+ totalHarvest: new Map(),
345
+ };
346
+ depositorCashFlows.set(index, depositorCashFlow);
347
+ }
348
+ }
349
+ }
350
+ }
351
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
352
+ finally {
353
+ try {
354
+ if (userHistory_1_1 && !userHistory_1_1.done && (_a = userHistory_1.return)) _a.call(userHistory_1);
355
+ }
356
+ finally { if (e_1) throw e_1.error; }
357
+ }
358
+ try {
359
+ // console.log(depositorCashFlows);
360
+ for (var _d = __values(depositorCashFlows.entries()), _e = _d.next(); !_e.done; _e = _d.next()) {
361
+ var _f = __read(_e.value, 2), index = _f[0], share = _f[1];
362
+ share.netDeposit = share.totalDeposit + share.totalCompound - share.totalWithdraw - share.totalClaim;
363
+ depositorCashFlows.set(index, share);
364
+ }
365
+ }
366
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
367
+ finally {
368
+ try {
369
+ if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
370
+ }
371
+ finally { if (e_2) throw e_2.error; }
372
+ }
373
+ return depositorCashFlows;
374
+ }
@@ -1,4 +1,5 @@
1
1
  import { TypusConfig } from "../../src/utils";
2
+ import { TypusBidReceipt } from "../../src/auto-bid/view-function";
2
3
  export interface Vault {
3
4
  id: string;
4
5
  depositToken: string;
@@ -42,7 +43,7 @@ export interface ShareSupply {
42
43
  export declare function getVaultData(config: TypusConfig, input: {
43
44
  indexes: string[];
44
45
  }): Promise<{
45
- [key: string]: Vault;
46
+ [key: string]: [Vault, TypusBidReceipt | null];
46
47
  }>;
47
48
  export interface Share {
48
49
  user: string;
@@ -53,7 +53,9 @@ function getVaultData(config, input) {
53
53
  transactionBlock = new transactions_1.TransactionBlock();
54
54
  transactionBlock.moveCall({
55
55
  target: "".concat(config.package.safu, "::view_function::get_vault_data_bcs"),
56
- typeArguments: [],
56
+ typeArguments: [
57
+ "".concat(config.package.framework, "::vault::TypusBidReceipt")
58
+ ],
57
59
  arguments: [transactionBlock.pure(config.registry.safu.safu), transactionBlock.pure(input.indexes)],
58
60
  });
59
61
  return [4 /*yield*/, provider.devInspectTransactionBlock({ sender: constants_1.SENDER, transactionBlock: transactionBlock })];
@@ -120,16 +122,45 @@ function getVaultData(config, input) {
120
122
  var bcsPadding = reader.readVec(function (reader) {
121
123
  return reader.read8();
122
124
  });
123
- result[info.index] = {
124
- id: id,
125
- depositToken: depositToken,
126
- rewardToken: rewardToken,
127
- info: info,
128
- config: config,
129
- shareSupply: shareSupply,
130
- u64Padding: u64Padding,
131
- bcsPadding: bcsPadding,
132
- };
125
+ var has_bid_receipt = reader.read8() > 0;
126
+ if (has_bid_receipt) {
127
+ result[info.index] = [
128
+ {
129
+ id: id,
130
+ depositToken: depositToken,
131
+ rewardToken: rewardToken,
132
+ info: info,
133
+ config: config,
134
+ shareSupply: shareSupply,
135
+ u64Padding: u64Padding,
136
+ bcsPadding: bcsPadding,
137
+ },
138
+ {
139
+ id: (0, utils_1.AddressFromBytes)(reader.readBytes(32)),
140
+ vid: (0, utils_1.AddressFromBytes)(reader.readBytes(32)),
141
+ index: reader.read64(),
142
+ metadata: String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.read8()))),
143
+ u64_padding: reader.readVec(function (reader) {
144
+ return reader.read64();
145
+ })
146
+ }
147
+ ];
148
+ }
149
+ else {
150
+ result[info.index] = [
151
+ {
152
+ id: id,
153
+ depositToken: depositToken,
154
+ rewardToken: rewardToken,
155
+ info: info,
156
+ config: config,
157
+ shareSupply: shareSupply,
158
+ u64Padding: u64Padding,
159
+ bcsPadding: bcsPadding,
160
+ },
161
+ null
162
+ ];
163
+ }
133
164
  });
134
165
  return [2 /*return*/, result];
135
166
  }
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.4.29",
5
+ "version": "1.4.30",
6
6
  "dependencies": {
7
7
  "@mysten/bcs": "^0.11.1",
8
8
  "@mysten/kiosk": "0.8.10",