@typus/typus-sdk 1.2.85-tails-exp → 1.2.85

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.
package/lib/config.json CHANGED
@@ -5,6 +5,7 @@
5
5
  "TGLD_COIN_METADATA": "0x3a070c729606334a2be7c51ab28da9a1101b0de01452dd62c10cda0f7a5795d2",
6
6
  "TGLD_TOKEN_POLICY": "0xd9461bd329f1df24be9698131b6e2c2b9eaac7c9cf6d76689112f2e57be12009",
7
7
  "NFT_TRANSFER_POLICY": "0x55475b9e16d9a0176dcef37f83a1921b15f2cbd2711a5f30b9d952c0c8f5f957",
8
+ "STRATEGY_POOL": "0x2c60ddd50d76beb00faa025962d566359a6ea05b1f7f19ac6bd050f4db8c885c",
8
9
  "PACKAGE_ORIGIN": {
9
10
  "DOV_SINGLE": "0x321848bf1ae327a9e022ccb3701940191e02fa193ab160d9c0e49cd3c003de3a",
10
11
  "FRAMEWORK": "0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274",
@@ -14,7 +15,7 @@
14
15
  "TYPUS": "0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a"
15
16
  },
16
17
  "PACKAGE": {
17
- "DOV_SINGLE": "0x5395c48f9bd7ee96586fa1e10f22fc1cb2455f83994ca919aaef51ae4db40242",
18
+ "DOV_SINGLE": "0x8b65b817e7d819ab810bf50eaaa521ceea39d85cd46ab58180cfe287ce6f8ef0",
18
19
  "FRAMEWORK": "0x946d188d91cabd4fe15ef763e463a6738db1965814d3fd790085b4720cf90e28",
19
20
  "MFUD": "0xd8f04cd2a16c19c17428c3b4c22b01dd06740423b93fb7ee88fbe2676a82849d",
20
21
  "NFT": "0xba06aae31d9b7c9f651e783272c7e4f776fb5ae17e89d525b75a17b099f58202",
@@ -54,6 +55,7 @@
54
55
  "TGLD_COIN_METADATA": "0xf77f8aabe64dccef0e568f2ef58a6ca74bdfb31786507cc35b7626a4df0d0ebc",
55
56
  "TGLD_TOKEN_POLICY": "0x17875c2f772053cd148bd2b8b8a40160db3f841825d8963192f8394d5c18974c",
56
57
  "NFT_TRANSFER_POLICY": "0x1c62271ecc443c3d92a8fe8f5662e877856d26b971d967f66937a65f55160831",
58
+ "STRATEGY_POOL": "0x50b01081469d032e04bfcbd057614b1359376920f55c7bebd076e0e2af07a57f",
57
59
  "PACKAGE_ORIGIN": {
58
60
  "DOV_SINGLE": "0x6c9a394a43844fc09d9617bc8a8e775a4521f0e28e83de1da780d043a498671f",
59
61
  "FRAMEWORK": "0x908a10789a1a6953e0b73a997c10e3552f7ce4e2907afd00a334ed74bd973ded",
@@ -165,7 +165,7 @@ function getAccumulatedRewardGeneratedUSD() {
165
165
  queries: [
166
166
  {
167
167
  metricsQuery: {
168
- query: "premiumUSD",
168
+ query: "AccumulatedPremiumUSD",
169
169
  alias: "",
170
170
  id: "a",
171
171
  labelSelector: {},
@@ -173,34 +173,14 @@ function getAccumulatedRewardGeneratedUSD() {
173
173
  op: "SUM",
174
174
  grouping: [],
175
175
  },
176
- functions: [
177
- {
178
- name: "sum_over_time",
179
- arguments: [
180
- {
181
- durationValue: {
182
- value: 100,
183
- unit: "w",
184
- },
185
- },
186
- ],
187
- },
188
- ],
189
- disabled: true,
176
+ functions: [],
177
+ disabled: false,
190
178
  },
191
179
  dataSource: "METRICS",
192
180
  sourceName: "",
193
181
  },
194
182
  ],
195
- formulas: [
196
- {
197
- expression: "a/2",
198
- alias: "",
199
- id: "A",
200
- disabled: false,
201
- functions: [],
202
- },
203
- ],
183
+ formulas: [],
204
184
  };
205
185
  jsonDataV1 = JSON.stringify(requestDataV1);
206
186
  return [4 /*yield*/, fetch(apiUrlV1, {
@@ -1,6 +1,6 @@
1
+ import { TransactionBlock } from "@mysten/sui.js/transactions";
1
2
  import { KioskClient } from "@mysten/kiosk";
2
3
  import { TailsId, kioskOwnerCap } from "../typus-nft/fetch";
3
- import { TransactionBlock } from "@mysten/sui.js/transactions";
4
4
  /**
5
5
  entry fun transfer_nft(
6
6
  registry: &mut Registry,
@@ -51,7 +51,7 @@ export declare function getDailyAttendTx(gasBudget: number, nftPackageId: string
51
51
  ctx: &mut TxContext
52
52
  )
53
53
  */
54
- export declare function getSnapshotTx(gasBudget: number, typusEcosystemVersion: string, typusUserRegistry: string, nftPackageId: string, registry: string, amount: string): Promise<TransactionBlock>;
54
+ export declare function getSnapshotTx(gasBudget: number, nftPackageId: string, registry: string): Promise<TransactionBlock>;
55
55
  export declare function getNewBidTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, additional_config_registry: string, index: string, priceOracle: string, coins: string[], size: string, premium_required: string, // fe float * b_token_decimal
56
56
  usingSponsoredGasCoin?: boolean): Promise<TransactionBlock>;
57
57
  export declare function getDepositTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, additional_config_registry: string, index: string, coins: string[], amount: string, usingSponsoredGasCoin?: boolean): Promise<TransactionBlock>;
@@ -53,9 +53,9 @@ var __read = (this && this.__read) || function (o, n) {
53
53
  };
54
54
  Object.defineProperty(exports, "__esModule", { value: true });
55
55
  exports.getClaimProfitSharingTx = exports.consumeExpCoinStakedTx = exports.consumeExpCoinUnstakedTx = exports.getLevelUpTx = exports.getUnsubscribeTx = exports.getWithdrawTx = exports.getCompoundTx = exports.getDepositTx = exports.getNewBidTx = exports.getSnapshotTx = exports.getDailyAttendTx = exports.getUnstakeNftTx = exports.getCreateKioskAndLockNftTx = exports.getSwitchNftTx = exports.getStakeNftTx = exports.getTransferNftsTx = exports.getTransferNftTx = void 0;
56
+ var transactions_1 = require("@mysten/sui.js/transactions");
56
57
  var constants_1 = require("../../constants");
57
58
  var kiosk_1 = require("@mysten/kiosk");
58
- var transactions_1 = require("@mysten/sui.js/transactions");
59
59
  /**
60
60
  entry fun transfer_nft(
61
61
  registry: &mut Registry,
@@ -216,11 +216,11 @@ function getSwitchNftTx(gasBudget, nftPackageId, registry, personalKioskPackageI
216
216
  return __generator(this, function (_c) {
217
217
  tx = new transactions_1.TransactionBlock();
218
218
  _a = __read(tx.splitCoins(tx.gas, [tx.pure(50000000)]), 1), coin = _a[0];
219
- // tx.moveCall({
220
- // target: `${nftPackageId}::tails_staking::snapshot`,
221
- // typeArguments: [],
222
- // arguments: [tx.object(registry), tx.object(CLOCK)],
223
- // });
219
+ tx.moveCall({
220
+ target: "".concat(nftPackageId, "::tails_staking::snapshot"),
221
+ typeArguments: [],
222
+ arguments: [tx.object(registry), tx.object(constants_1.CLOCK)],
223
+ });
224
224
  tx.moveCall({
225
225
  target: "".concat(nftPackageId, "::tails_staking::claim_profit_sharing"),
226
226
  typeArguments: typeArguments,
@@ -307,11 +307,11 @@ function getUnstakeNftTx(gasBudget, nftPackageId, registry, typeArguments, kiosk
307
307
  var tx, _a, personalKioskCap, borrow;
308
308
  return __generator(this, function (_b) {
309
309
  tx = new transactions_1.TransactionBlock();
310
- // tx.moveCall({
311
- // target: `${nftPackageId}::tails_staking::snapshot`,
312
- // typeArguments: [],
313
- // arguments: [tx.object(registry), tx.object(CLOCK)],
314
- // });
310
+ tx.moveCall({
311
+ target: "".concat(nftPackageId, "::tails_staking::snapshot"),
312
+ typeArguments: [],
313
+ arguments: [tx.object(registry), tx.object(constants_1.CLOCK)],
314
+ });
315
315
  tx.moveCall({
316
316
  target: "".concat(nftPackageId, "::tails_staking::claim_profit_sharing"),
317
317
  typeArguments: typeArguments,
@@ -380,7 +380,7 @@ exports.getDailyAttendTx = getDailyAttendTx;
380
380
  ctx: &mut TxContext
381
381
  )
382
382
  */
383
- function getSnapshotTx(gasBudget, typusEcosystemVersion, typusUserRegistry, nftPackageId, registry, amount) {
383
+ function getSnapshotTx(gasBudget, nftPackageId, registry) {
384
384
  return __awaiter(this, void 0, void 0, function () {
385
385
  var tx;
386
386
  return __generator(this, function (_a) {
@@ -388,7 +388,7 @@ function getSnapshotTx(gasBudget, typusEcosystemVersion, typusUserRegistry, nftP
388
388
  tx.moveCall({
389
389
  target: "".concat(nftPackageId, "::tails_staking::snapshot"),
390
390
  typeArguments: [],
391
- arguments: [tx.object(typusEcosystemVersion), tx.object(typusUserRegistry), tx.object(registry), tx.pure(amount)],
391
+ arguments: [tx.object(registry), tx.object(constants_1.CLOCK)],
392
392
  });
393
393
  tx.setGasBudget(gasBudget);
394
394
  return [2 /*return*/, tx];
@@ -10,6 +10,8 @@ exports.typeArgsToAssets = typeArgsToAssets;
10
10
  function typeArgToAsset(typeArg) {
11
11
  var typeArgs = typeArg.split("::");
12
12
  switch ((0, utils_1.normalizeSuiAddress)(typeArgs[0])) {
13
+ case "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55":
14
+ return "VSUI";
13
15
  case "0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881":
14
16
  return "WBTC";
15
17
  case "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5":
@@ -1,2 +1,6 @@
1
+ import BigNumber from "bignumber.js";
1
2
  export declare function U64FromBytes(x: any): bigint;
2
3
  export declare function AddressFromBytes(x: any): string;
4
+ export declare const insertAt: (str: string, sub: string, pos: number) => string;
5
+ export declare const checkNumber: (str: any) => boolean;
6
+ export declare const countFloating: (value: number | BigNumber) => number;
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AddressFromBytes = exports.U64FromBytes = void 0;
6
+ exports.countFloating = exports.checkNumber = exports.insertAt = exports.AddressFromBytes = exports.U64FromBytes = void 0;
7
+ var bignumber_js_1 = __importDefault(require("bignumber.js"));
4
8
  function U64FromBytes(x) {
5
9
  var u64 = BigInt(0);
6
10
  for (var i = 0; i < x.length; i++) {
@@ -18,3 +22,24 @@ function AddressFromBytes(x) {
18
22
  return address;
19
23
  }
20
24
  exports.AddressFromBytes = AddressFromBytes;
25
+ var insertAt = function (str, sub, pos) { return "".concat(str.slice(0, pos)).concat(sub).concat(str.slice(pos)); };
26
+ exports.insertAt = insertAt;
27
+ var checkNumber = function (str) {
28
+ if (typeof str != "string")
29
+ return false; // we only process strings!
30
+ return (
31
+ // @ts-ignore
32
+ !isNaN(str) && // use type coercion to parse the _entirety_ of the string (`parseFloat` alone does not do this)...
33
+ !isNaN(parseFloat(str))); // ...and ensure strings of whitespace fail
34
+ };
35
+ exports.checkNumber = checkNumber;
36
+ var countFloating = function (value) {
37
+ var num = (0, bignumber_js_1.default)(value).toFixed().replace(/,/g, "");
38
+ if (value instanceof bignumber_js_1.default) {
39
+ num = value.toFixed().replace(/,/g, "");
40
+ }
41
+ if (!num.includes("."))
42
+ return 0;
43
+ return num.split(".")[1].length;
44
+ };
45
+ exports.countFloating = countFloating;
@@ -0,0 +1,143 @@
1
+ import BigNumber from "bignumber.js";
2
+ import { PublicKey } from "@solana/web3.js";
3
+ import { PriceData } from "@pythnetwork/client";
4
+ import { SuiClient } from "@mysten/sui.js/dist/cjs/client";
5
+ import { Auction, BidShare, Vault } from "../view-function";
6
+ export declare const ASSET_INFO: {
7
+ BTC: {
8
+ product: PublicKey;
9
+ price: PublicKey;
10
+ };
11
+ ETH: {
12
+ product: PublicKey;
13
+ price: PublicKey;
14
+ };
15
+ SUI: {
16
+ product: PublicKey;
17
+ price: PublicKey;
18
+ };
19
+ CETUS: {
20
+ product: PublicKey;
21
+ price: PublicKey;
22
+ };
23
+ SEI: {
24
+ product: PublicKey;
25
+ price: PublicKey;
26
+ };
27
+ USDC: {
28
+ product: PublicKey;
29
+ price: PublicKey;
30
+ };
31
+ USDT: {
32
+ product: PublicKey;
33
+ price: PublicKey;
34
+ };
35
+ TURBOS: {
36
+ product: PublicKey;
37
+ price: PublicKey;
38
+ };
39
+ APT: {
40
+ product: PublicKey;
41
+ price: PublicKey;
42
+ };
43
+ SOL: {
44
+ product: PublicKey;
45
+ price: PublicKey;
46
+ };
47
+ INJ: {
48
+ product: PublicKey;
49
+ price: PublicKey;
50
+ };
51
+ JUP: {
52
+ product: PublicKey;
53
+ price: PublicKey;
54
+ };
55
+ };
56
+ export declare const tokenOrder: {
57
+ [key: string]: number;
58
+ };
59
+ export declare const optionTypeOrder: {
60
+ [key: string]: number;
61
+ };
62
+ export declare const periodOrder: {
63
+ [key: string]: number;
64
+ };
65
+ export type Receipt = {
66
+ id: string;
67
+ index: string;
68
+ name: string;
69
+ description: string;
70
+ vid: string;
71
+ };
72
+ export type TokenAmount = {
73
+ value: string;
74
+ token: string;
75
+ };
76
+ export type BidVaultInfo = {
77
+ vaultInfo: Vault;
78
+ receipt: Receipt;
79
+ };
80
+ export interface Bid {
81
+ vaultIndex: string;
82
+ expiry: string;
83
+ auctionName: string;
84
+ strikes: string[];
85
+ bidSize: TokenAmount;
86
+ breakEvenPrice: string;
87
+ estPnls: TokenAmount[];
88
+ receiptsId: string[];
89
+ receiptsVid: string[];
90
+ settlePrice: string;
91
+ isAutoBid: boolean;
92
+ }
93
+ export interface OrderBy {
94
+ tokenOrder: number;
95
+ optionTypeOrder: number;
96
+ periodOrder: number;
97
+ }
98
+ export interface CoinInfo {
99
+ price: string;
100
+ decimal: string;
101
+ quote: string;
102
+ }
103
+ export declare const IncentiveRateBp = 4;
104
+ export declare const parsePythOracleData: (data: PriceData[], decimals: {
105
+ [key: string]: string;
106
+ }) => {
107
+ [key: string]: CoinInfo;
108
+ };
109
+ export declare const fetchPrices: (provider: SuiClient, network: string) => Promise<{
110
+ [key: string]: CoinInfo;
111
+ }>;
112
+ export declare const calcIncentiveRate: (incentiveBp: any) => number;
113
+ export declare const calcDeliveryPrice: (bidShare: BidShare, vaultInfo: Vault) => BigNumber;
114
+ export declare const calcBreakEvenPrice: (optionType: string, period: string, strikes: string[], bToken: string, price: string, incentive: number) => number;
115
+ export declare const calcEstPnl: (live: boolean, incentive: number, bidSize: string, optionType: string, assets: string[], strikes: string[], bidShare: BidShare, deliveryPrice: string, oTokenPrice: string) => TokenAmount[];
116
+ export declare const parseStrikes: (period: string, optionType: string, metadata: string) => string[];
117
+ export declare const parseBidReceipt: (vaults: Vault[], bidReceipts: {
118
+ [key: string]: Receipt[];
119
+ }) => {
120
+ sortedBidReceipts: string[];
121
+ bidVaultsInfo: BidVaultInfo[];
122
+ };
123
+ export declare const parseBid: (bidVaultInfo: BidVaultInfo, bidShare: BidShare, auction: Auction | null, oTokenPrice: string, isAutoBid: boolean) => Bid & OrderBy;
124
+ export declare const getUserBidReceipts: (provider: SuiClient, network: string, originFramworkAddress: string, userAddress: string) => Promise<{
125
+ [key: string]: Receipt[];
126
+ }>;
127
+ /**
128
+ * Fetch user's bids info
129
+ *
130
+ * @param provider - Sui Client instance.
131
+ * @param network - network type in lowercase.
132
+ * @param packageAddress - Typus main package address.
133
+ * @param framworkAddress - Typus framwork package address.
134
+ * @param originFramworkAddress - Typus intial framwork package address.
135
+ * @param registryAddress - Typus registry package address.
136
+ * @param strategyPoolAddress - strategy pool package address.
137
+ * @param userAddress - user's wallet address.
138
+ * @param prices - tokens prices (usd pair on Pyth)
139
+ * @return User Bids.
140
+ */
141
+ export declare const fetchUserBids: (provider: SuiClient, network: string, packageAddress: string, framworkAddress: string, originFramworkAddress: string, registryAddress: string, strategyPoolAddress: string, userAddress: string, prices?: {
142
+ [key: string]: CoinInfo;
143
+ } | undefined) => Promise<any>;