@typus/typus-sdk 1.2.1 → 1.2.3

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.
@@ -0,0 +1,67 @@
1
+ {
2
+ "RPC_ENDPOINT": "https://fullnode.mainnet.sui.io:443",
3
+ "PYTH_EVM_SUI": "0x23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
4
+ "PYTH_EVM_CETUS": "0xe5b274b2611143df055d6e7cd8d93fe1961716bcd4dca1cad87a83bc1e78c1ef",
5
+ "PYTH_EVM_USDC": "0xeaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a",
6
+ "PYTH_EVM_BTC": "0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43",
7
+ "PYTH_EVM_ETH": "0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace",
8
+ "PYTH_EVM_SOL": "0xef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d",
9
+ "PYTH_EVM_TURBOS": "0xf9c2e890443dd995d0baafc08eea3358be1ffb874f93f99c30b3816c460bbac3",
10
+ "PYTH_EVM_APT": "0x03ae4db29ed4ae33d323568895aa00337e658e348b37509f5372ae51f0af00d5",
11
+ "PYTH_EVM_USDT": "0x2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b",
12
+ "PYTH_EVM_DOGE": "0xdcef50dd0a4cd2dcc17e45df1676dcb336a11a61c69df7a0299b0150c672d25c",
13
+ "PYTH_EVM_BUCK": "0x2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b",
14
+ "ORACLE_PACKAGE": "0x32db67540e8be0c078604a0018e4008b936c2a72d6f1fc7a9130bca120784c0f",
15
+ "SUI_USDC_ORACLE": "0xeb6b3e3300ff884604ead6172b0aeadee3854980cab65a7feb57300b04b74cc1",
16
+ "SUI_BUCK_ORACLE": "0x9e7ed446b4899fcb713ac03a204070070cdd246695d7b6b2ab0812cb2206ead8",
17
+ "CETUS_USDC_ORACLE": "0xaedaa2e76661471924c1ca7edae069317cbe082798dd3bfa31694dc873102532",
18
+ "BTC_USDC_ORACLE": "0x61813dc2e46dba41b14507857827f0ed7e99b0be242548828769728b81c8fab5",
19
+ "ETH_USDC_ORACLE": "0x253bbaaa35275240cf6df03258489707ea059762831e4102ebaabafd442bc935",
20
+ "TURBOS_USDC_ORACLE": "0x819ff07b5768d7b9b428b69b123140f6a74b04eaa978a4cbab9055025bd1536d",
21
+ "SOL_USDC_ORACLE": "0x9712ad1cba00a437fb669e4df1a59568e4267bd8a8ce989452fb63c9f00b59ab",
22
+ "APT_USDC_ORACLE": "0x401ed2a4de92950351c54edaa9a8dce5e38bdb6b06e248935c6f6f7d361a99d6",
23
+ "SWITCHBOARD_SUIUSDC": "0xbca474133638352ba83ccf7b5c931d50f764b09550e16612c9f70f1e21f3f594",
24
+ "PYTH_STATE": "0xf9ff3ef935ef6cdfb659a203bf2754cebeb63346e29114a535ea6f41315e5a3f",
25
+ "PYTH_SUIUSDC": "0x168aa44fa92b27358beb17643834078b1320be6adf1b3bb0c7f018ac3591db1a",
26
+ "CETUS_PACKAGE": "0xbd6d0f475ccdfd81ed148d70a2f84883d8c63f332d046215bd0ccf528290358e",
27
+ "SCALLOP_VERSION": "0x07871c4b3c847a0f674510d4978d5cf6f960452795e8ff6f189fd2088a3f6ac7",
28
+ "SCALLOP_SPOOL_SUI": "0x4f0ba970d3c11db05c8f40c64a15b6a33322db3702d634ced6536960ab6f3ee4",
29
+ "SCALLOP_SPOOL_USDC": "0x4ace6648ddc64e646ba47a957c562c32c9599b3bba8f5ac1aadb2ae23a2f8ca0",
30
+ "SCALLOP_MARKET": "0xa757975255146dc9686aa823b7838b507f315d704f428cbadad2f4ea061939d9",
31
+ "SCALLOP_REWARD_POOL_FOR_SUI": "0x162250ef72393a4ad3d46294c4e1bdfcb03f04c869d390e7efbfc995353a7ee9",
32
+ "SCALLOP_REWARD_POOL_FOR_USDC": "0xf4268cc9b9413b9bfe09e8966b8de650494c9e5784bf0930759cfef4904daff8",
33
+ "VERSION": "2.11.1",
34
+ "EXP_GUESS_PACKAGE": "0x32d670520a10a87b8c042d2259c2d1f7c319329bafcf6f893ad9aaf01a43db8b",
35
+ "EXP_GUESS_PACKAGE_ORIGIN": "0x32d670520a10a87b8c042d2259c2d1f7c319329bafcf6f893ad9aaf01a43db8b",
36
+ "EXP_GUESS_REGISTRY": "0x70c6cbe6764b315cee1b24f483a0fc8307f047f1fab2a0d4438624845e6ba3f2",
37
+ "FRAMEWORK_PACKAGE": "0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274",
38
+ "SINGLE_COLLATERAL_PACKAGE": "0x936e250c06624db833f4118b6cf3166859dee868d1305fbf6c4ed064c939d9e6",
39
+ "SINGLE_COLLATERAL_PACKAGE_ORIGIN": "0x321848bf1ae327a9e022ccb3701940191e02fa193ab160d9c0e49cd3c003de3a",
40
+ "SINGLE_COLLATERAL_REGISTRY": "0x3d70b09359e3ca8301ae0abeda4f2fdf72ce313ba58c919ce568e5f535fd2ea8",
41
+ "SINGLE_COLLATERAL_PORTFOLIO_VAULT_REGISTRY": "0xa1a186d050e3172ef4701c16048c99b11f785969874fa2642b9cbcf59cde7fc0",
42
+ "SINGLE_COLLATERAL_AUCTION_REGISTRY": "0x2b95e45e87b26453073819fc3e41cf599027da3bb0318534bc9d37a57bc9246c",
43
+ "SINGLE_COLLATERAL_DEPOSIT_VAULT_REGISTRY": "0xd67cf93a0df61b4b3bbf6170511e0b28b21578d9b87a8f4adafec96322dd284d",
44
+ "METADATA": "/home/metadata",
45
+ "NFT_PACKAGE": "0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196",
46
+ "NFT_PACKAGE_UPGRADE": "0xe227fb985a005a4e6e87856f59862ba0e0337b7fe6d587cab588c8436ba05743",
47
+ "NFT_MANAGER_CAP": "0xd1c387021a99a8177d996ab59c5866f69d0f8c9951b538e0688a55357846fe9e",
48
+ "NFT_TRANSFER_POLICY": "0x55475b9e16d9a0176dcef37f83a1921b15f2cbd2711a5f30b9d952c0c8f5f957",
49
+ "NFT_ROYALTY": "0x342222a33cebf88f8e01a7e5eecdf69cc89e7129fed6caf0b505916bb298afd8",
50
+ "NFT_TABLE": "0xa537a287cf99264b905cb0a5400df6ed2612ba82db6c536548ad9f3fd9843c1f",
51
+ "bucket_protocol": "0xf1301e045a310c4aa45c0e462e382458a426d3effdb8c457581708ae202e8740",
52
+ "kriya_dex": "0x84b95b3f412bdf47d36d60d3bafed5cd86e65fad9044e0e28234661548f445e8",
53
+ "cetus_protocol": "0xd68df013fdc58cb7777d90bfe88d97f9467660c67bfb6570530907a28977c30b",
54
+ "ethos_wallet": "0x1343b7d9f34ba09686c83f6a6b80ba9cdac879426cbb4c4be2753188d9bf030b",
55
+ "typus": "0x4200f77d82b4a0ba5069459179f7d19b3ef522c67759af66fcf7fcd96d566fe4",
56
+ "navi_protocol": "0xa2819d1eae5985cfbc91183e247e798ac6715174e15d6f0fc3c1a5df23ac7cf4",
57
+ "scallop_sui": "0xb4d33b5469f96740bb1421fe158fa32d952c20068bb9cad8bb326c3ec2c2deb1",
58
+ "shinami_corp": "0xe7c5ba89ffd9b1403593d2697ee1803e098cb72644908edea8966c909a4c2be3",
59
+ "studio_mirai": "0xf79f0ea0dab65a35ed7535cf328e480d59e4e6f5893537cd4f1a02216e993230",
60
+ "blockvision": "0xfebfb558e24a572213edc67b27b7d2e39d7a0eecf4b30b1bc7ce87a36881902b",
61
+ "team": "0x16eb99443a5bce89f0e4b10eba15624ff1f19d05fda2fb76d7854a3accee6dc5",
62
+ "nft_vault": "0x9a5bca0fb698734481d6cd51ad1a186d0620ada11163ff7ab55e3fc0ca5f71a5",
63
+ "sui_network": "0xed5f3eebda1be7cd74ebb883852738996ea4b7d651eb1b5a77bb5d7f221b5b2a",
64
+ "mysten_labs": "0x985a37095c597ecfa072b0f389df689ee4d9c99bcf4b175aa53be52e2e5f25b8",
65
+ "none": "0x88dba869e789d0725ae55fbb446f6e38065b67e1f26b10ec57322b18f4de9892",
66
+ "diceProfitSharing": "0x42ba35a057e38baf19e916b0f9ad5d98bb23b7fc246b4d659fc21c608790e872"
67
+ }
@@ -1,2 +1,4 @@
1
1
  export declare function getPairPrices(pair: string, startTs: string, endTs: string): Promise<any>;
2
2
  export declare function getLatestPrice(pair: string): Promise<string>;
3
+ export declare function getPythLatestPrice(): Promise<Map<string, number> | undefined>;
4
+ export declare function getLatestPriceUSD(): Promise<Map<string, number>>;
@@ -35,8 +35,19 @@ 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
+ };
38
49
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.getLatestPrice = exports.getPairPrices = void 0;
50
+ exports.getLatestPriceUSD = exports.getPythLatestPrice = exports.getLatestPrice = exports.getPairPrices = void 0;
40
51
  var apiUrl = "https://us-central1-aqueous-freedom-378103.cloudfunctions.net/db-price";
41
52
  function getPairPrices(pair, startTs, endTs) {
42
53
  return __awaiter(this, void 0, void 0, function () {
@@ -84,3 +95,92 @@ function getLatestPrice(pair) {
84
95
  });
85
96
  }
86
97
  exports.getLatestPrice = getLatestPrice;
98
+ function getPythLatestPrice() {
99
+ return __awaiter(this, void 0, void 0, function () {
100
+ var apiUrlWithParams, response, map, data;
101
+ return __generator(this, function (_a) {
102
+ switch (_a.label) {
103
+ case 0:
104
+ apiUrlWithParams = "https://hermes.pyth.network/api/latest_price_feeds?ids[]=0x23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744&ids[]=0xe5b274b2611143df055d6e7cd8d93fe1961716bcd4dca1cad87a83bc1e78c1ef&ids[]=0xeaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a&ids[]=0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43&ids[]=0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace&ids[]=0xef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d&ids[]=0xf9c2e890443dd995d0baafc08eea3358be1ffb874f93f99c30b3816c460bbac3&ids[]=0x03ae4db29ed4ae33d323568895aa00337e658e348b37509f5372ae51f0af00d5&ids[]=0x2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b&ids[]=0xdcef50dd0a4cd2dcc17e45df1676dcb336a11a61c69df7a0299b0150c672d25c&ids[]=0x7a5bc1d2b56ad029048cd63964b3ad2776eadf812edc1a43a31406cb54bff592&ids[]=0x53614f1cb0c031d4af66c04cb9c756234adad0e1cee85303795091499a4084eb";
105
+ return [4 /*yield*/, fetch(apiUrlWithParams, {
106
+ method: "GET",
107
+ headers: { "Content-Type": "application/json" },
108
+ })];
109
+ case 1:
110
+ response = _a.sent();
111
+ map = new Map();
112
+ if (!response.ok) return [3 /*break*/, 3];
113
+ return [4 /*yield*/, response.json()];
114
+ case 2:
115
+ data = _a.sent();
116
+ data.forEach(function (p) {
117
+ var token = pythId[p.id];
118
+ var price = p.price.price / Math.pow(10, -p.price.expo);
119
+ map.set(token, price);
120
+ });
121
+ return [2 /*return*/, map];
122
+ case 3: return [2 /*return*/];
123
+ }
124
+ });
125
+ });
126
+ }
127
+ exports.getPythLatestPrice = getPythLatestPrice;
128
+ function getLatestPriceUSD() {
129
+ return __awaiter(this, void 0, void 0, function () {
130
+ var prices, _a, _b, pair, currentTimestampInSeconds, minuteAgo, res, price, e_1_1;
131
+ var e_1, _c;
132
+ return __generator(this, function (_d) {
133
+ switch (_d.label) {
134
+ case 0: return [4 /*yield*/, getPythLatestPrice()];
135
+ case 1:
136
+ prices = (_d.sent());
137
+ _d.label = 2;
138
+ case 2:
139
+ _d.trys.push([2, 7, 8, 9]);
140
+ _a = __values(["SUIFUD", "SUIBUCK", "SUIAFSUI"]), _b = _a.next();
141
+ _d.label = 3;
142
+ case 3:
143
+ if (!!_b.done) return [3 /*break*/, 6];
144
+ pair = _b.value;
145
+ currentTimestampInSeconds = Math.floor(new Date().getTime() / 1000);
146
+ minuteAgo = currentTimestampInSeconds - 300;
147
+ return [4 /*yield*/, getPairPrices(pair, minuteAgo.toString(), currentTimestampInSeconds.toString())];
148
+ case 4:
149
+ res = _d.sent();
150
+ price = res.at(-1).price;
151
+ prices.set(pair.replace("SUI", ""), prices.get("SUI") / Number(price));
152
+ _d.label = 5;
153
+ case 5:
154
+ _b = _a.next();
155
+ return [3 /*break*/, 3];
156
+ case 6: return [3 /*break*/, 9];
157
+ case 7:
158
+ e_1_1 = _d.sent();
159
+ e_1 = { error: e_1_1 };
160
+ return [3 /*break*/, 9];
161
+ case 8:
162
+ try {
163
+ if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
164
+ }
165
+ finally { if (e_1) throw e_1.error; }
166
+ return [7 /*endfinally*/];
167
+ case 9: return [2 /*return*/, prices];
168
+ }
169
+ });
170
+ });
171
+ }
172
+ exports.getLatestPriceUSD = getLatestPriceUSD;
173
+ var pythId = {
174
+ "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744": "SUI",
175
+ e5b274b2611143df055d6e7cd8d93fe1961716bcd4dca1cad87a83bc1e78c1ef: "CETUS",
176
+ eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a: "USDC",
177
+ e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43: "BTC",
178
+ ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace: "ETH",
179
+ ef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d: "SOL",
180
+ f9c2e890443dd995d0baafc08eea3358be1ffb874f93f99c30b3816c460bbac3: "TURBOS",
181
+ "03ae4db29ed4ae33d323568895aa00337e658e348b37509f5372ae51f0af00d5": "APT",
182
+ "2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b": "USDT",
183
+ dcef50dd0a4cd2dcc17e45df1676dcb336a11a61c69df7a0299b0150c672d25c: "DOGE",
184
+ "7a5bc1d2b56ad029048cd63964b3ad2776eadf812edc1a43a31406cb54bff592": "INJ",
185
+ "53614f1cb0c031d4af66c04cb9c756234adad0e1cee85303795091499a4084eb": "SEI",
186
+ };
@@ -0,0 +1 @@
1
+ export declare function recap2023(user: string): Promise<(string | number | undefined)[]>;
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
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
+ };
65
+ var __importDefault = (this && this.__importDefault) || function (mod) {
66
+ return (mod && mod.__esModule) ? mod : { "default": mod };
67
+ };
68
+ Object.defineProperty(exports, "__esModule", { value: true });
69
+ exports.recap2023 = void 0;
70
+ var mainnet_json_1 = __importDefault(require("../mainnet.json"));
71
+ var user_history_1 = require("../utils/typus-dov-single-v2/user-history");
72
+ var view_function_1 = require("../utils/typus-dov-single-v2/view-function");
73
+ var client_1 = require("@mysten/sui.js/client");
74
+ var price_1 = require("../utils/price");
75
+ var fetch_1 = require("../utils/nft-staking/fetch");
76
+ // (async () => {
77
+ // const user = "0xdc72506f269feb89822c13e66b282bc52c5724c27e575a04cbec949a13671d13";
78
+ // const res = await recap2023(user);
79
+ // console.log(res);
80
+ // })();
81
+ function recap2023(user) {
82
+ var _a, _b, _c, _d;
83
+ return __awaiter(this, void 0, void 0, function () {
84
+ var provider, vaults, userHistory, earn, userHistory_1, userHistory_1_1, history_1, token, amount, sum_1, prices, sum, _e, _f, _g, token, amount, price, res_1;
85
+ var e_1, _h, _j, _k, _l, _m, e_2, _o;
86
+ return __generator(this, function (_p) {
87
+ switch (_p.label) {
88
+ case 0:
89
+ provider = new client_1.SuiClient({
90
+ url: mainnet_json_1.default.RPC_ENDPOINT,
91
+ });
92
+ return [4 /*yield*/, (0, view_function_1.getVaults)(provider, mainnet_json_1.default.SINGLE_COLLATERAL_PACKAGE, mainnet_json_1.default.SINGLE_COLLATERAL_REGISTRY, [])];
93
+ case 1:
94
+ vaults = _p.sent();
95
+ return [4 /*yield*/, (0, user_history_1.getUserHistory)(provider, mainnet_json_1.default.SINGLE_COLLATERAL_PACKAGE_ORIGIN, vaults, user, 0)];
96
+ case 2:
97
+ userHistory = _p.sent();
98
+ console.log(userHistory);
99
+ earn = new Map();
100
+ try {
101
+ for (userHistory_1 = __values(userHistory), userHistory_1_1 = userHistory_1.next(); !userHistory_1_1.done; userHistory_1_1 = userHistory_1.next()) {
102
+ history_1 = userHistory_1_1.value;
103
+ token = "";
104
+ amount = "";
105
+ if (history_1.Action.startsWith("Harvest")) {
106
+ _j = __read((_a = history_1.Amount) === null || _a === void 0 ? void 0 : _a.split(" "), 2), amount = _j[0], token = _j[1];
107
+ // console.log(`Harvest ${amount} ${token}`);
108
+ }
109
+ else if (history_1.Action.startsWith("Compound")) {
110
+ _k = __read((_b = history_1.Amount) === null || _b === void 0 ? void 0 : _b.split(" "), 2), amount = _k[0], token = _k[1];
111
+ // console.log(`Compound ${amount} ${token}`);
112
+ }
113
+ else if (history_1.Action.startsWith("Exercise")) {
114
+ _l = __read((_c = history_1.Amount) === null || _c === void 0 ? void 0 : _c.split(" "), 2), amount = _l[0], token = _l[1];
115
+ // console.log(`Exercise ${amount} ${token}`);
116
+ }
117
+ else if (history_1.Action.startsWith("Claim Profit Sharing")) {
118
+ _m = __read((_d = history_1.Amount) === null || _d === void 0 ? void 0 : _d.split(" "), 2), amount = _m[0], token = _m[1];
119
+ // console.log(`Claim Profit Sharing ${amount} ${token}`);
120
+ }
121
+ if (earn.has(token)) {
122
+ sum_1 = earn.get(token);
123
+ earn.set(token, sum_1 + Number(amount));
124
+ }
125
+ else {
126
+ earn.set(token, Number(amount));
127
+ }
128
+ }
129
+ }
130
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
131
+ finally {
132
+ try {
133
+ if (userHistory_1_1 && !userHistory_1_1.done && (_h = userHistory_1.return)) _h.call(userHistory_1);
134
+ }
135
+ finally { if (e_1) throw e_1.error; }
136
+ }
137
+ // console.log(earn);
138
+ earn.delete("");
139
+ return [4 /*yield*/, (0, price_1.getLatestPriceUSD)()];
140
+ case 3:
141
+ prices = _p.sent();
142
+ sum = 0;
143
+ try {
144
+ for (_e = __values(earn.entries()), _f = _e.next(); !_f.done; _f = _e.next()) {
145
+ _g = __read(_f.value, 2), token = _g[0], amount = _g[1];
146
+ price = prices.get(token.replace("W", ""));
147
+ // console.log(`${token} ${price * amount}`);
148
+ sum += price * amount;
149
+ }
150
+ }
151
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
152
+ finally {
153
+ try {
154
+ if (_f && !_f.done && (_o = _e.return)) _o.call(_e);
155
+ }
156
+ finally { if (e_2) throw e_2.error; }
157
+ }
158
+ return [4 /*yield*/, (0, fetch_1.getUserStake)(provider, mainnet_json_1.default.NFT_TABLE, user)];
159
+ case 4:
160
+ res_1 = _p.sent();
161
+ // console.log(res_1!.number); // null
162
+ return [2 /*return*/, [sum, res_1 === null || res_1 === void 0 ? void 0 : res_1.url]];
163
+ }
164
+ });
165
+ });
166
+ }
167
+ exports.recap2023 = recap2023;
@@ -89,7 +89,7 @@ function parseTxHistory(datas, originPackage, vaults) {
89
89
  return type.startsWith(originPackage) || type.includes("typus_nft::First") || type.includes("typus_nft::ExpUpEvent");
90
90
  })
91
91
  .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, amount, token, amount, size, token, amount, i, b_token, size, bidder_balance;
92
+ var txHistory, functionType, action, Action, Amount, Index, Period, Vault, RiskLevel, Tails, Exp, o_token, v, period, optionType, i, i, token, amount, amount, token, amount, size, token, amount, token, amount, i, b_token, size, bidder_balance;
93
93
  var _a;
94
94
  return __generator(this, function (_b) {
95
95
  switch (_b.label) {
@@ -282,6 +282,13 @@ function parseTxHistory(datas, originPackage, vaults) {
282
282
  Action = "Rebate";
283
283
  Amount = "".concat((0, bignumber_js_1.default)(amount).toFixed(), " ").concat(token);
284
284
  break;
285
+ case "ClaimProfitSharingEvent":
286
+ token = (0, token_1.typeArgToAsset)("0x" + event.parsedJson.token.name);
287
+ amount = Number(event.parsedJson.value) / Math.pow(10, (0, token_1.assetToDecimal)(token));
288
+ Action = "Claim Profit Sharing";
289
+ Amount = "".concat((0, bignumber_js_1.default)(amount).toFixed(), " ").concat(token);
290
+ Tails = "#".concat(event.parsedJson.number);
291
+ break;
285
292
  case "NewBidEvent":
286
293
  i = txHistory.findIndex(function (x) { return x.txDigest == event.id.txDigest; });
287
294
  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.2.1",
5
+ "version": "1.2.3",
6
6
  "dependencies": {
7
7
  "@mysten/bcs": "^0.7.3",
8
8
  "@mysten/kiosk": "0.7.12",