@typus/typus-sdk 1.4.49 → 1.4.51

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.
@@ -122,6 +122,43 @@ export declare function getExpUpWithoutStakingTx(config: TypusConfig, tx: Transa
122
122
  amount: string;
123
123
  personalKioskPackageId: string | undefined;
124
124
  }): TransactionBlock;
125
+ /**
126
+ entry fun exp_down_with_fee(
127
+ version: &Version,
128
+ tails_staking_registry: &mut TailsStakingRegistry,
129
+ typus_user_registry: &mut TypusUserRegistry,
130
+ tails: address,
131
+ amount: u64,
132
+ coin: Coin<SUI>,
133
+ ctx: &TxContext,
134
+ ) {
135
+ */
136
+ export declare function getExpDownWithFeeTx(config: TypusConfig, tx: TransactionBlock, input: {
137
+ fee: string;
138
+ tails: string;
139
+ amount: string;
140
+ }): TransactionBlock;
141
+ /**
142
+ entry fun exp_down_without_staking_with_fee(
143
+ version: &Version,
144
+ tails_staking_registry: &TailsStakingRegistry,
145
+ typus_user_registry: &mut TypusUserRegistry,
146
+ kiosk: &mut Kiosk,
147
+ kiosk_owner_cap: &KioskOwnerCap,
148
+ tails: address,
149
+ amount: u64,
150
+ coin: Coin<SUI>,
151
+ ctx: &TxContext,
152
+ ) {
153
+ */
154
+ export declare function getExpDownWithoutStakingWithFeeTx(config: TypusConfig, tx: TransactionBlock, input: {
155
+ fee: string;
156
+ kiosk: string;
157
+ kioskCap: string;
158
+ tails: string;
159
+ amount: string;
160
+ personalKioskPackageId: string | undefined;
161
+ }): TransactionBlock;
125
162
  export declare function getCreateKioskAndLockNftTx(config: TypusConfig, tx: TransactionBlock, kioskClient: KioskClient, input: {
126
163
  nft_policy: string;
127
164
  nft_id: string;
@@ -24,6 +24,8 @@ exports.getClaimProfitSharingTx = getClaimProfitSharingTx;
24
24
  exports.getLevelUpTx = getLevelUpTx;
25
25
  exports.getExpUpTx = getExpUpTx;
26
26
  exports.getExpUpWithoutStakingTx = getExpUpWithoutStakingTx;
27
+ exports.getExpDownWithFeeTx = getExpDownWithFeeTx;
28
+ exports.getExpDownWithoutStakingWithFeeTx = getExpDownWithoutStakingWithFeeTx;
27
29
  exports.getCreateKioskAndLockNftTx = getCreateKioskAndLockNftTx;
28
30
  var constants_1 = require("../../../src/constants");
29
31
  var kiosk_1 = require("@mysten/kiosk");
@@ -314,6 +316,90 @@ function getExpUpWithoutStakingTx(config, tx, input) {
314
316
  }
315
317
  return tx;
316
318
  }
319
+ /**
320
+ entry fun exp_down_with_fee(
321
+ version: &Version,
322
+ tails_staking_registry: &mut TailsStakingRegistry,
323
+ typus_user_registry: &mut TypusUserRegistry,
324
+ tails: address,
325
+ amount: u64,
326
+ coin: Coin<SUI>,
327
+ ctx: &TxContext,
328
+ ) {
329
+ */
330
+ function getExpDownWithFeeTx(config, tx, input) {
331
+ var _a = __read(tx.splitCoins(tx.gas, [tx.pure(input.fee)]), 1), coin = _a[0];
332
+ tx.moveCall({
333
+ target: "".concat(config.package.typus, "::tails_staking::exp_down_with_fee"),
334
+ typeArguments: [],
335
+ arguments: [
336
+ tx.object(config.version.typus),
337
+ tx.object(config.registry.typus.tailsStaking),
338
+ tx.object(config.registry.typus.user),
339
+ tx.pure(input.tails),
340
+ tx.pure(input.amount),
341
+ coin,
342
+ ],
343
+ });
344
+ return tx;
345
+ }
346
+ /**
347
+ entry fun exp_down_without_staking_with_fee(
348
+ version: &Version,
349
+ tails_staking_registry: &TailsStakingRegistry,
350
+ typus_user_registry: &mut TypusUserRegistry,
351
+ kiosk: &mut Kiosk,
352
+ kiosk_owner_cap: &KioskOwnerCap,
353
+ tails: address,
354
+ amount: u64,
355
+ coin: Coin<SUI>,
356
+ ctx: &TxContext,
357
+ ) {
358
+ */
359
+ function getExpDownWithoutStakingWithFeeTx(config, tx, input) {
360
+ var _a = __read(tx.splitCoins(tx.gas, [tx.pure(input.fee)]), 1), coin = _a[0];
361
+ if (input.personalKioskPackageId) {
362
+ var _b = __read(tx.moveCall({
363
+ target: "".concat(input.personalKioskPackageId, "::personal_kiosk::borrow_val"),
364
+ arguments: [tx.object(input.kioskCap)],
365
+ }), 2), personalKioskCap = _b[0], borrow = _b[1];
366
+ tx.moveCall({
367
+ target: "".concat(config.package.typus, "::tails_staking::exp_down_without_staking_with_fee"),
368
+ typeArguments: [],
369
+ arguments: [
370
+ tx.object(config.version.typus),
371
+ tx.object(config.registry.typus.tailsStaking),
372
+ tx.object(config.registry.typus.user),
373
+ tx.object(input.kiosk),
374
+ personalKioskCap,
375
+ tx.pure(input.tails),
376
+ tx.pure(input.amount),
377
+ coin,
378
+ ],
379
+ });
380
+ tx.moveCall({
381
+ target: "".concat(input.personalKioskPackageId, "::personal_kiosk::return_val"),
382
+ arguments: [tx.object(input.kioskCap), personalKioskCap, borrow],
383
+ });
384
+ }
385
+ else {
386
+ tx.moveCall({
387
+ target: "".concat(config.package.typus, "::tails_staking::exp_down_without_staking_with_fee"),
388
+ typeArguments: [],
389
+ arguments: [
390
+ tx.object(config.version.typus),
391
+ tx.object(config.registry.typus.tailsStaking),
392
+ tx.object(config.registry.typus.user),
393
+ tx.object(input.kiosk),
394
+ tx.object(input.kioskCap),
395
+ tx.pure(input.tails),
396
+ tx.pure(input.amount),
397
+ coin,
398
+ ],
399
+ });
400
+ }
401
+ return tx;
402
+ }
317
403
  function getCreateKioskAndLockNftTx(config, tx, kioskClient, input) {
318
404
  var kioskTx = new kiosk_1.KioskTransaction({ transactionBlock: tx, kioskClient: kioskClient });
319
405
  kioskTx.create();
@@ -61,6 +61,18 @@ export declare const ASSET_INFO: {
61
61
  product: PublicKey;
62
62
  price: PublicKey;
63
63
  };
64
+ AUSD: {
65
+ product: PublicKey;
66
+ price: PublicKey;
67
+ };
68
+ FUD: {
69
+ product: PublicKey;
70
+ price: PublicKey;
71
+ };
72
+ USDY: {
73
+ product: PublicKey;
74
+ price: PublicKey;
75
+ };
64
76
  };
65
77
  export declare const tokenOrder: {
66
78
  [key: string]: number;
@@ -157,6 +157,18 @@ exports.ASSET_INFO = {
157
157
  product: new web3_js_1.PublicKey("9L4zWUnRWEqHT9fvH5WkmQgXf7qrr97SGV4pofTSdK5k"),
158
158
  price: new web3_js_1.PublicKey("6vWPEigSDaAi6m6HuX24aK4fJGJxvQZ8TLQKADC65S2S"),
159
159
  },
160
+ AUSD: {
161
+ product: new web3_js_1.PublicKey("GHXtvZLRq3WGm7DWUke5UdB8P6Jb4MuSwWjd72gGFPc8"),
162
+ price: new web3_js_1.PublicKey("FeHsLbpPsJ7JTBPGKqhBTzvNuX5bjrm4Q6HdgXWgKW8Z"),
163
+ },
164
+ FUD: {
165
+ product: new web3_js_1.PublicKey("2fcvX3is1N5vy17xeqi2x5t7ShFKPaBx91UTH73DvTH3"),
166
+ price: new web3_js_1.PublicKey("89mKNz2WRvoPXy1mbRdaptLPYHsaYBpqmh5oxk2xD4Da"),
167
+ },
168
+ USDY: {
169
+ product: new web3_js_1.PublicKey("555ugWQAae89KU9t9SBWAZTHZtQNkQ18XumbzgxDXQmZ"),
170
+ price: new web3_js_1.PublicKey("GKMnwKMJS97DZHQS9mBquF15cEbgNKHvoayz8uamBp1T"),
171
+ },
160
172
  };
161
173
  exports.tokenOrder = {
162
174
  // Basically it's a to z but put SUI at first
@@ -256,58 +268,23 @@ var parsePythOracleData = function (data, decimals) {
256
268
  };
257
269
  exports.parsePythOracleData = parsePythOracleData;
258
270
  var fetchPrices = function (provider, config) { return __awaiter(void 0, void 0, void 0, function () {
259
- var coinObjects, oracleDecimal, PYTHNET_CLUSTER_NAME, connection, pythPublicKey, pythClient, priceData, prices, suiusd, suifud, fudusd, suiafsui, afsuiusd, suinavx, navxusd, suibuck, buckusd, usdyusdc, usdyusdcWithDecimal, scasui, scausd;
260
- var _a, _b;
261
- return __generator(this, function (_c) {
262
- switch (_c.label) {
263
- case 0: return [4 /*yield*/, provider.multiGetObjects({
264
- ids: Object.values(config.oracle),
265
- options: { showContent: true },
266
- })];
267
- case 1:
268
- coinObjects = _c.sent();
271
+ var oracleDecimal, PYTHNET_CLUSTER_NAME, connection, pythPublicKey, pythClient, priceData, prices, mblub;
272
+ return __generator(this, function (_a) {
273
+ switch (_a.label) {
274
+ case 0:
269
275
  oracleDecimal = __assign({}, DefaultOracleDecimal);
270
- coinObjects.forEach(function (c) {
271
- var _a, _b;
272
- // @ts-ignore
273
- oracleDecimal[(_a = c.data) === null || _a === void 0 ? void 0 : _a.content.fields.base_token] =
274
- // @ts-ignore
275
- (_b = c.data) === null || _b === void 0 ? void 0 : _b.content.fields.decimal;
276
- });
277
276
  PYTHNET_CLUSTER_NAME = "pythnet";
278
277
  connection = new web3_js_1.Connection((0, client_1.getPythClusterApiUrl)(PYTHNET_CLUSTER_NAME));
279
278
  pythPublicKey = (0, client_1.getPythProgramKeyForCluster)(PYTHNET_CLUSTER_NAME);
280
279
  pythClient = new client_1.PythHttpClient(connection, pythPublicKey);
281
280
  return [4 /*yield*/, pythClient.getAssetPricesFromAccounts(Object.values(exports.ASSET_INFO).map(function (a) { return a.price; }))];
282
- case 2:
283
- priceData = _c.sent();
281
+ case 1:
282
+ priceData = _a.sent();
284
283
  prices = (0, exports.parsePythOracleData)(priceData, oracleDecimal);
285
- suiusd = (0, bignumber_js_1.default)((_b = (_a = prices["sui"]) === null || _a === void 0 ? void 0 : _a.price) !== null && _b !== void 0 ? _b : 0);
286
- return [4 /*yield*/, (0, utils_1.getLatestPrice)("SUIFUD")];
287
- case 3:
288
- suifud = _c.sent();
289
- fudusd = suifud == "0" ? (0, bignumber_js_1.default)(0) : suiusd.div(suifud);
290
- return [4 /*yield*/, (0, utils_1.getLatestPrice)("SUIAFSUI")];
291
- case 4:
292
- suiafsui = _c.sent();
293
- afsuiusd = suiafsui == "0" ? (0, bignumber_js_1.default)(0) : suiusd.div(suiafsui);
294
- return [4 /*yield*/, (0, utils_1.getLatestPrice)("SUINAVX")];
295
- case 5:
296
- suinavx = _c.sent();
297
- navxusd = suiusd.div(suinavx);
298
- return [4 /*yield*/, (0, utils_1.getLatestPrice)("SUIBUCK")];
299
- case 6:
300
- suibuck = _c.sent();
301
- buckusd = (0, bignumber_js_1.default)(suibuck).lte(0) ? "0" : suiusd.div(suibuck);
302
- return [4 /*yield*/, (0, utils_1.getLatestPrice)("USDYUSDC")];
303
- case 7:
304
- usdyusdc = _c.sent();
305
- usdyusdcWithDecimal = (0, bignumber_js_1.default)(usdyusdc).multipliedBy((0, bignumber_js_1.default)(10).pow(8));
306
- return [4 /*yield*/, (0, utils_1.getLatestPrice)("SCASUI")];
307
- case 8:
308
- scasui = _c.sent();
309
- scausd = suiusd.eq(0) ? (0, bignumber_js_1.default)(0) : (0, bignumber_js_1.default)(scasui).multipliedBy(suiusd);
310
- return [2 /*return*/, __assign({ fud: { price: fudusd.toString(), decimal: "8", quote: "usd" }, mfud: { price: fudusd.multipliedBy(1000000).toString(), decimal: "8", quote: "usd" }, afsui: { price: afsuiusd.toString(), decimal: "8", quote: "usd" }, navx: { price: navxusd.toString(), decimal: "8", quote: "usd" }, buck: { price: buckusd.toString(), decimal: "8", quote: "usd" }, usdy: { price: usdyusdcWithDecimal.toString(), decimal: "8", quote: "usd" }, sca: { price: scausd.toString(), decimal: "8", quote: "usd" } }, prices)];
284
+ return [4 /*yield*/, (0, utils_1.getLatestPrice)("MBLUBUSDC")];
285
+ case 2:
286
+ mblub = _a.sent();
287
+ return [2 /*return*/, __assign({ mblub: { price: mblub.toString(), decimal: "8", quote: "usd" } }, prices)];
311
288
  }
312
289
  });
313
290
  }); };
@@ -13,4 +13,6 @@ interface TokenAmount {
13
13
  export declare function getAccumulatedUser(): Promise<number[]>;
14
14
  /** Returns Accumulated Notional Volume in USD [v1, v2] */
15
15
  export declare function getAccumulatedNotionalVolumeUSD(): Promise<number[]>;
16
+ /** Returns Safu Accumulated Rewards im USD */
17
+ export declare function getSafuAccumulatedRewardGeneratedUSD(): Promise<number>;
16
18
  export {};
@@ -54,6 +54,7 @@ exports.getTotalProfitSharingClaimed = getTotalProfitSharingClaimed;
54
54
  exports.getTotalProfitSharing = getTotalProfitSharing;
55
55
  exports.getAccumulatedUser = getAccumulatedUser;
56
56
  exports.getAccumulatedNotionalVolumeUSD = getAccumulatedNotionalVolumeUSD;
57
+ exports.getSafuAccumulatedRewardGeneratedUSD = getSafuAccumulatedRewardGeneratedUSD;
57
58
  var constants_1 = require("../../../../src/constants");
58
59
  var headers = {
59
60
  "api-key": "tz3JJ6stG7Fux6ueRSRA5mdpC9U0lozI3",
@@ -504,3 +505,56 @@ function getAccumulatedNotionalVolumeUSD() {
504
505
  });
505
506
  });
506
507
  }
508
+ /** Returns Safu Accumulated Rewards im USD */
509
+ function getSafuAccumulatedRewardGeneratedUSD() {
510
+ return __awaiter(this, void 0, void 0, function () {
511
+ var apiUrl, requestData, jsonData, response, data;
512
+ return __generator(this, function (_a) {
513
+ switch (_a.label) {
514
+ case 0:
515
+ apiUrl = "https://app.sentio.xyz/api/v1/insights/typus/typus_v2/query";
516
+ requestData = {
517
+ timeRange: {
518
+ start: "now",
519
+ end: "now",
520
+ step: 3600,
521
+ timezone: "Asia/Taipei",
522
+ },
523
+ limit: 1,
524
+ queries: [
525
+ {
526
+ metricsQuery: {
527
+ query: "SafuAccumulatedRewardGeneratedUSD",
528
+ alias: "",
529
+ id: "a",
530
+ labelSelector: {},
531
+ aggregate: {
532
+ op: "SUM",
533
+ grouping: [],
534
+ },
535
+ functions: [],
536
+ disabled: false,
537
+ },
538
+ dataSource: "METRICS",
539
+ sourceName: "",
540
+ },
541
+ ],
542
+ formulas: [],
543
+ };
544
+ jsonData = JSON.stringify(requestData);
545
+ return [4 /*yield*/, fetch(apiUrl, {
546
+ method: "POST",
547
+ headers: headers,
548
+ body: jsonData,
549
+ })];
550
+ case 1:
551
+ response = _a.sent();
552
+ return [4 /*yield*/, response.json()];
553
+ case 2:
554
+ data = _a.sent();
555
+ // console.log(data.results[0].matrix.samples[0].values[0].value);
556
+ return [2 /*return*/, data.results[0].matrix.samples[0].values[0].value];
557
+ }
558
+ });
559
+ });
560
+ }
@@ -18,7 +18,6 @@ export interface Package {
18
18
  oracle: string;
19
19
  perp: string;
20
20
  safu: string;
21
- token: string;
22
21
  typus: string;
23
22
  }
24
23
  export interface Version {
@@ -86,6 +85,8 @@ export interface Oracle {
86
85
  export interface Token {
87
86
  afsui: string;
88
87
  apt: string;
88
+ ausd: string;
89
+ blub: string;
89
90
  btc: string;
90
91
  buck: string;
91
92
  cetus: string;
@@ -94,6 +95,7 @@ export interface Token {
94
95
  hasui: string;
95
96
  inj: string;
96
97
  jup: string;
98
+ mblub: string;
97
99
  mfud: string;
98
100
  navx: string;
99
101
  sca: string;
@@ -109,7 +111,5 @@ export interface Token {
109
111
  usdt: string;
110
112
  usdy: string;
111
113
  vsui: string;
112
- blub: string;
113
- mblub: string;
114
- ausd: string;
114
+ wusdc: string;
115
115
  }
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.49",
5
+ "version": "1.4.51",
6
6
  "dependencies": {
7
7
  "@mysten/bcs": "^0.11.1",
8
8
  "@mysten/kiosk": "0.8.10",