@cetusprotocol/xcetus-sdk 1.0.0
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/.turbo/turbo-build.log +10368 -0
- package/README.md +276 -0
- package/dist/index.d.mts +356 -0
- package/dist/index.d.ts +356 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +13 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +36 -0
- package/src/config/index.ts +2 -0
- package/src/config/mainnet.ts +37 -0
- package/src/config/testnet.ts +37 -0
- package/src/errors/errors.ts +29 -0
- package/src/index.ts +7 -0
- package/src/modules/index.ts +1 -0
- package/src/modules/xcetusModule.ts +1067 -0
- package/src/sdk.ts +59 -0
- package/src/types/index.ts +2 -0
- package/src/types/xcetus_type.ts +166 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/xcetus.ts +175 -0
- package/tests/tsconfig.json +26 -0
- package/tests/xcetus.test.ts +197 -0
- package/tsconfig.json +5 -0
- package/tsup.config.ts +9 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import { SuiObjectIdType, SuiAddressType, NFT, IModule, CoinAsset, SdkWrapper, BaseSdkOptions, Package } from '@cetusprotocol/common-sdk';
|
|
2
|
+
import { Transaction } from '@mysten/sui/transactions';
|
|
3
|
+
|
|
4
|
+
declare const XcetusRouterModule = "router";
|
|
5
|
+
declare const DividendsRouterModule = "router";
|
|
6
|
+
declare const ONE_DAY_SECONDS: number;
|
|
7
|
+
declare const EXCHANGE_RATE_MULTIPLIER = 1000;
|
|
8
|
+
declare const REDEEM_NUM_MULTIPLIER = 100000000000;
|
|
9
|
+
type XcetusConfig = {
|
|
10
|
+
xcetus_manager_id: SuiObjectIdType;
|
|
11
|
+
lock_manager_id: SuiObjectIdType;
|
|
12
|
+
lock_handle_id: SuiObjectIdType;
|
|
13
|
+
};
|
|
14
|
+
type DividendConfig = {
|
|
15
|
+
dividend_admin_id?: SuiObjectIdType;
|
|
16
|
+
dividend_settle_id?: SuiObjectIdType;
|
|
17
|
+
dividend_manager_id: SuiObjectIdType;
|
|
18
|
+
venft_dividends_id: SuiAddressType;
|
|
19
|
+
venft_dividends_id_v2: SuiAddressType;
|
|
20
|
+
};
|
|
21
|
+
type LockUpConfig = {
|
|
22
|
+
min_lock_day: number;
|
|
23
|
+
max_lock_day: number;
|
|
24
|
+
max_percent_numerator: number;
|
|
25
|
+
min_percent_numerator: number;
|
|
26
|
+
};
|
|
27
|
+
declare const defaultLockUpConfig: LockUpConfig;
|
|
28
|
+
type LockUpManager = {
|
|
29
|
+
id: string;
|
|
30
|
+
balance: string;
|
|
31
|
+
treasury_manager: string;
|
|
32
|
+
extra_treasury: string;
|
|
33
|
+
lock_infos: {
|
|
34
|
+
lock_handle_id: string;
|
|
35
|
+
size: number;
|
|
36
|
+
};
|
|
37
|
+
type_name: string;
|
|
38
|
+
min_lock_day: number;
|
|
39
|
+
max_lock_day: number;
|
|
40
|
+
package_version: number;
|
|
41
|
+
max_percent_numerator: number;
|
|
42
|
+
min_percent_numerator: number;
|
|
43
|
+
};
|
|
44
|
+
type VeNFT = {
|
|
45
|
+
id: SuiObjectIdType;
|
|
46
|
+
type: string;
|
|
47
|
+
index: string;
|
|
48
|
+
xcetus_balance: string;
|
|
49
|
+
} & NFT;
|
|
50
|
+
type LockCetus = {
|
|
51
|
+
id: SuiObjectIdType;
|
|
52
|
+
type: SuiAddressType;
|
|
53
|
+
locked_start_time: number;
|
|
54
|
+
locked_until_time: number;
|
|
55
|
+
lock_day: number;
|
|
56
|
+
cetus_amount: string;
|
|
57
|
+
xcetus_amount: string;
|
|
58
|
+
};
|
|
59
|
+
type ConvertParams = {
|
|
60
|
+
amount: string;
|
|
61
|
+
venft_id?: SuiObjectIdType;
|
|
62
|
+
};
|
|
63
|
+
type RedeemLockParams = {
|
|
64
|
+
amount: string;
|
|
65
|
+
venft_id: SuiObjectIdType;
|
|
66
|
+
lock_day: number;
|
|
67
|
+
};
|
|
68
|
+
type RedeemXcetusParams = {
|
|
69
|
+
venft_id: SuiObjectIdType;
|
|
70
|
+
lock_id: SuiObjectIdType;
|
|
71
|
+
};
|
|
72
|
+
type CancelRedeemParams = {
|
|
73
|
+
venft_id: SuiObjectIdType;
|
|
74
|
+
lock_id: SuiObjectIdType;
|
|
75
|
+
};
|
|
76
|
+
type XcetusManager = {
|
|
77
|
+
id: SuiObjectIdType;
|
|
78
|
+
index: number;
|
|
79
|
+
has_venft: {
|
|
80
|
+
handle: SuiObjectIdType;
|
|
81
|
+
size: number;
|
|
82
|
+
};
|
|
83
|
+
nfts: {
|
|
84
|
+
handle: SuiObjectIdType;
|
|
85
|
+
size: number;
|
|
86
|
+
};
|
|
87
|
+
total_locked: string;
|
|
88
|
+
treasury: string;
|
|
89
|
+
};
|
|
90
|
+
type VeNFTDividendInfo = {
|
|
91
|
+
id: SuiObjectIdType;
|
|
92
|
+
venft_id: SuiObjectIdType;
|
|
93
|
+
rewards: DividendReward[];
|
|
94
|
+
};
|
|
95
|
+
type DividendReward = {
|
|
96
|
+
period: number;
|
|
97
|
+
rewards: {
|
|
98
|
+
coin_type: SuiAddressType;
|
|
99
|
+
amount: string;
|
|
100
|
+
}[];
|
|
101
|
+
version: string;
|
|
102
|
+
};
|
|
103
|
+
type PhaseDividendInfo = {
|
|
104
|
+
id: string;
|
|
105
|
+
phase: string;
|
|
106
|
+
settled_num: string;
|
|
107
|
+
register_time: string;
|
|
108
|
+
redeemed_num: {
|
|
109
|
+
name: string;
|
|
110
|
+
value: string;
|
|
111
|
+
}[];
|
|
112
|
+
is_settled: boolean;
|
|
113
|
+
bonus_types: string[];
|
|
114
|
+
bonus: {
|
|
115
|
+
name: string;
|
|
116
|
+
value: string;
|
|
117
|
+
}[];
|
|
118
|
+
phase_end_time: string;
|
|
119
|
+
};
|
|
120
|
+
type DividendManager = {
|
|
121
|
+
id: SuiObjectIdType;
|
|
122
|
+
dividends: {
|
|
123
|
+
id: SuiObjectIdType;
|
|
124
|
+
size: number;
|
|
125
|
+
};
|
|
126
|
+
venft_dividends: {
|
|
127
|
+
id: SuiObjectIdType;
|
|
128
|
+
size: number;
|
|
129
|
+
};
|
|
130
|
+
bonus_types: SuiAddressType[];
|
|
131
|
+
start_time: number;
|
|
132
|
+
interval_day: number;
|
|
133
|
+
balances: {
|
|
134
|
+
id: SuiObjectIdType;
|
|
135
|
+
size: number;
|
|
136
|
+
};
|
|
137
|
+
is_open: boolean;
|
|
138
|
+
};
|
|
139
|
+
type BonusTypesV2 = Record<SuiAddressType, number[]>;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Helper class to help interact with xcetus with a router interface.
|
|
143
|
+
*/
|
|
144
|
+
declare class XCetusModule implements IModule<CetusXcetusSDK> {
|
|
145
|
+
protected _sdk: CetusXcetusSDK;
|
|
146
|
+
private readonly _cache;
|
|
147
|
+
constructor(sdk: CetusXcetusSDK);
|
|
148
|
+
get sdk(): CetusXcetusSDK;
|
|
149
|
+
/**
|
|
150
|
+
* Gets the VeNFT object for the specified account address.
|
|
151
|
+
*
|
|
152
|
+
* @param account_address The address of the account that owns the VeNFT object.
|
|
153
|
+
* @param force_refresh Indicates whether to refresh the cache of the VeNFT object.
|
|
154
|
+
* @returns A Promise that resolves to the VeNFT object or `undefined` if the object is not found.
|
|
155
|
+
*/
|
|
156
|
+
getOwnerVeNFT(account_address: SuiAddressType, force_refresh?: boolean): Promise<VeNFT | void>;
|
|
157
|
+
/**
|
|
158
|
+
* Gets the list of LockCetus objects owned by the specified account address.
|
|
159
|
+
*
|
|
160
|
+
* @param account_address The address of the account that owns the LockCetus objects.
|
|
161
|
+
* @returns A Promise that resolves to a list of LockCetus objects.
|
|
162
|
+
*/
|
|
163
|
+
getOwnerRedeemLockList(account_address: SuiAddressType): Promise<LockCetus[]>;
|
|
164
|
+
/**
|
|
165
|
+
* Gets the LockCetus object with the specified ID.
|
|
166
|
+
*
|
|
167
|
+
* @param lock_id The ID of the LockCetus object.
|
|
168
|
+
* @returns A Promise that resolves to the LockCetus object or `undefined` if the object is not found.
|
|
169
|
+
*/
|
|
170
|
+
getLockCetus(lock_id: SuiObjectIdType): Promise<LockCetus | undefined>;
|
|
171
|
+
/**
|
|
172
|
+
* Gets the list of Cetus coins owned by the specified account address.
|
|
173
|
+
*
|
|
174
|
+
* @param account_address The address of the account that owns the Cetus coins.
|
|
175
|
+
* @returns A Promise that resolves to a list of CoinAsset objects.
|
|
176
|
+
*/
|
|
177
|
+
getOwnerCetusCoins(account_address: SuiAddressType): Promise<CoinAsset[]>;
|
|
178
|
+
/**
|
|
179
|
+
* mint venft
|
|
180
|
+
* @returns
|
|
181
|
+
*/
|
|
182
|
+
mintVeNFTPayload(): Transaction;
|
|
183
|
+
/**
|
|
184
|
+
* Convert Cetus to Xcetus.
|
|
185
|
+
* @param params
|
|
186
|
+
* @returns
|
|
187
|
+
*/
|
|
188
|
+
convertPayload(params: ConvertParams, tx?: Transaction): Transaction;
|
|
189
|
+
/**
|
|
190
|
+
* Convert Xcetus to Cetus, first step is to lock the Cetus for a period.
|
|
191
|
+
* When the time is reach, cetus can be redeem and xcetus will be burned.
|
|
192
|
+
* @param params
|
|
193
|
+
* @returns
|
|
194
|
+
*/
|
|
195
|
+
redeemLockPayload(params: RedeemLockParams): Transaction;
|
|
196
|
+
/**
|
|
197
|
+
* lock time is reach and the cetus can be redeemed, the xcetus will be burned.
|
|
198
|
+
* @param params
|
|
199
|
+
* @returns
|
|
200
|
+
*/
|
|
201
|
+
redeemPayload(params: RedeemXcetusParams): Transaction;
|
|
202
|
+
redeemDividendPayload(venft_id: SuiObjectIdType, bonus_types: SuiAddressType[]): Transaction;
|
|
203
|
+
redeemDividendV2Payload(venft_id: SuiObjectIdType, bonus_types: SuiAddressType[], x_token_type: SuiAddressType[]): Transaction;
|
|
204
|
+
redeemDividendV3Payload(venft_id: string, reward_list: DividendReward[]): Transaction;
|
|
205
|
+
redeemDividendXTokenPayload(venft_id: SuiObjectIdType, tx?: Transaction): Transaction;
|
|
206
|
+
buildCetusCoinType(): SuiAddressType;
|
|
207
|
+
buildXTokenCoinType(package_id?: string, module?: string, name?: string): SuiAddressType;
|
|
208
|
+
/**
|
|
209
|
+
* Cancel the redeem lock, the cetus locked will be return back to the manager and the xcetus will be available again.
|
|
210
|
+
* @param params
|
|
211
|
+
* @returns
|
|
212
|
+
*/
|
|
213
|
+
cancelRedeemPayload(params: CancelRedeemParams): Transaction;
|
|
214
|
+
/**
|
|
215
|
+
* Gets the init factory event.
|
|
216
|
+
*
|
|
217
|
+
* @returns A Promise that resolves to the init factory event.
|
|
218
|
+
*/
|
|
219
|
+
getInitConfigs(): Promise<XcetusConfig>;
|
|
220
|
+
/**
|
|
221
|
+
* Gets the lock up manager event.
|
|
222
|
+
*
|
|
223
|
+
* @returns A Promise that resolves to the lock up manager event.
|
|
224
|
+
*/
|
|
225
|
+
getLockUpManager(lock_manager_id?: string, force_refresh?: boolean): Promise<LockUpManager>;
|
|
226
|
+
/**
|
|
227
|
+
* Gets the dividend manager event.
|
|
228
|
+
*
|
|
229
|
+
* @returns A Promise that resolves to the dividend manager event.
|
|
230
|
+
*/
|
|
231
|
+
getDividendConfigs(): Promise<DividendConfig>;
|
|
232
|
+
/**
|
|
233
|
+
* Gets the dividend manager object.
|
|
234
|
+
*
|
|
235
|
+
* @param force_refresh Whether to force a refresh of the cache.
|
|
236
|
+
* @returns A Promise that resolves to the dividend manager object.
|
|
237
|
+
*/
|
|
238
|
+
getDividendManager(force_refresh?: boolean): Promise<DividendManager>;
|
|
239
|
+
/**
|
|
240
|
+
* Gets the Xcetus manager object.
|
|
241
|
+
*
|
|
242
|
+
* @returns A Promise that resolves to the Xcetus manager object.
|
|
243
|
+
*/
|
|
244
|
+
getXcetusManager(force_refresh?: boolean): Promise<XcetusManager>;
|
|
245
|
+
private fetchDividendInfo;
|
|
246
|
+
/**
|
|
247
|
+
* Gets the VeNFT dividend information for the specified VeNFT dividend handle and VeNFT ID.
|
|
248
|
+
*
|
|
249
|
+
* @param venft_id The VeNFT ID.
|
|
250
|
+
* @returns A Promise that resolves to the VeNFT dividend information or undefined if an error occurs.
|
|
251
|
+
*/
|
|
252
|
+
getVeNFTDividendInfo(venft_id: string): Promise<VeNFTDividendInfo | void>;
|
|
253
|
+
private getVeNFTDividendInfoV2;
|
|
254
|
+
private getVeNFTDividendInfoV1;
|
|
255
|
+
/**
|
|
256
|
+
* Calculates the redeem number for the specified amount and lock day.
|
|
257
|
+
*
|
|
258
|
+
* @param redeem_amount The amount to redeem.
|
|
259
|
+
* @param lock_day The number of days to lock the amount for.
|
|
260
|
+
* @returns A Promise that resolves to an object with the amount out and percent.
|
|
261
|
+
*/
|
|
262
|
+
redeemNum(redeem_amount: string | number, lock_day: number): {
|
|
263
|
+
amount_out: string;
|
|
264
|
+
percent: string;
|
|
265
|
+
};
|
|
266
|
+
/**
|
|
267
|
+
* Reverses the redeem number for the specified amount and lock day.
|
|
268
|
+
*
|
|
269
|
+
* @param amount The amount to redeem.
|
|
270
|
+
* @param lock_day The number of days to lock the amount for.
|
|
271
|
+
* @returns A Promise that resolves to an object with the reversed amount and percent.
|
|
272
|
+
*/
|
|
273
|
+
reverseRedeemNum(amount: string | number, lock_day: number): {
|
|
274
|
+
amount_out: string;
|
|
275
|
+
percent: string;
|
|
276
|
+
};
|
|
277
|
+
/**
|
|
278
|
+
* Gets the XCetus amount for the specified lock ID.
|
|
279
|
+
*
|
|
280
|
+
* @param lock_id The ID of the lock.
|
|
281
|
+
* @returns A Promise that resolves to the XCetus amount.
|
|
282
|
+
*/
|
|
283
|
+
getXCetusAmount(lock_id: string): Promise<string>;
|
|
284
|
+
/**
|
|
285
|
+
* Gets the amount of XCetus and lock for the specified VENFT.
|
|
286
|
+
*
|
|
287
|
+
* @param nft_handle_id The ID of the NFT handle.
|
|
288
|
+
* @param venft_id The ID of the VENFT.
|
|
289
|
+
* @returns A Promise that resolves to an object with the XCetus amount and lock amount.
|
|
290
|
+
*/
|
|
291
|
+
getVeNftAmount(nft_handle_id: string, venft_id: string): Promise<{
|
|
292
|
+
xcetus_amount: string;
|
|
293
|
+
lock_amount: string;
|
|
294
|
+
}>;
|
|
295
|
+
/**
|
|
296
|
+
* @param phase_handle
|
|
297
|
+
* @param phase
|
|
298
|
+
* @param force_refresh
|
|
299
|
+
* @returns
|
|
300
|
+
*/
|
|
301
|
+
getPhaseDividendInfo(phase: string, force_refresh?: boolean): Promise<PhaseDividendInfo | undefined>;
|
|
302
|
+
private updateCache;
|
|
303
|
+
private getCache;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Represents options and configurations for an SDK.
|
|
308
|
+
*/
|
|
309
|
+
interface SdkOptions extends BaseSdkOptions {
|
|
310
|
+
xcetus: Package<XcetusConfig>;
|
|
311
|
+
xcetus_dividends: Package<DividendConfig>;
|
|
312
|
+
cetus_faucet: Package;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* The entry class of CetusXcetusSDK, which is almost responsible for all interactions with Xcetus.
|
|
316
|
+
*/
|
|
317
|
+
declare class CetusXcetusSDK extends SdkWrapper<SdkOptions> {
|
|
318
|
+
/**
|
|
319
|
+
* Provide interact with Xcetus interface.
|
|
320
|
+
*/
|
|
321
|
+
protected _xcetusModule: XCetusModule;
|
|
322
|
+
constructor(options: SdkOptions);
|
|
323
|
+
/**
|
|
324
|
+
* Getter for the Xcetus property.
|
|
325
|
+
* @returns {XCetusModule} The Xcetus property value.
|
|
326
|
+
*/
|
|
327
|
+
get XCetusModule(): XCetusModule;
|
|
328
|
+
/**
|
|
329
|
+
* Static factory method to initialize the SDK
|
|
330
|
+
* @param options SDK initialization options
|
|
331
|
+
* @returns An instance of CetusXcetusSDK
|
|
332
|
+
*/
|
|
333
|
+
static createSDK(options: BaseSdkOptions): CetusXcetusSDK;
|
|
334
|
+
/**
|
|
335
|
+
* Create a custom SDK instance with the given options
|
|
336
|
+
* @param options The options for the SDK
|
|
337
|
+
* @returns An instance of CetusBurnSDK
|
|
338
|
+
*/
|
|
339
|
+
static createCustomSDK<T extends BaseSdkOptions>(options: T & SdkOptions): CetusXcetusSDK;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
declare class XCetusUtil {
|
|
343
|
+
static buildVeNFTDividendInfo(fields: any): VeNFTDividendInfo;
|
|
344
|
+
static buildDividendManager(fields: any): DividendManager;
|
|
345
|
+
static buildLockUpManager(fields: any): LockUpManager;
|
|
346
|
+
static buildLockCetus(data: any): LockCetus;
|
|
347
|
+
static getAvailableXCetus(venft: VeNFT, locks: LockCetus[]): string;
|
|
348
|
+
static getWaitUnLockCetus(locks: LockCetus[]): LockCetus[];
|
|
349
|
+
static getLockingCetus(locks: LockCetus[]): LockCetus[];
|
|
350
|
+
static isLocked(lock: LockCetus): boolean;
|
|
351
|
+
static buildDividendRewardTypeList(reward_list?: DividendReward[], reward_list_v2?: DividendReward[]): string[];
|
|
352
|
+
static buildDividendRewardTypeListV2(reward_list?: DividendReward[]): BonusTypesV2;
|
|
353
|
+
static getNextStartTime(dividend_manager: DividendManager): number;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export { type BonusTypesV2, type CancelRedeemParams, CetusXcetusSDK, type ConvertParams, type DividendConfig, type DividendManager, type DividendReward, DividendsRouterModule, EXCHANGE_RATE_MULTIPLIER, type LockCetus, type LockUpConfig, type LockUpManager, ONE_DAY_SECONDS, type PhaseDividendInfo, REDEEM_NUM_MULTIPLIER, type RedeemLockParams, type RedeemXcetusParams, type SdkOptions, type VeNFT, type VeNFTDividendInfo, XCetusModule, XCetusUtil, type XcetusConfig, type XcetusManager, XcetusRouterModule, CetusXcetusSDK as default, defaultLockUpConfig };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";var ye=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var Je=Object.getOwnPropertyNames;var Ye=Object.prototype.hasOwnProperty;var et=(t,e)=>{for(var n in e)ye(t,n,{get:e[n],enumerable:!0})},tt=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Je(e))!Ye.call(t,r)&&r!==n&&ye(t,r,{get:()=>e[r],enumerable:!(i=We(e,r))||i.enumerable});return t};var nt=t=>tt(ye({},"__esModule",{value:!0}),t);var Wt={};et(Wt,{CetusXcetusSDK:()=>re,DividendsRouterModule:()=>J,EXCHANGE_RATE_MULTIPLIER:()=>ve,ONE_DAY_SECONDS:()=>ne,REDEEM_NUM_MULTIPLIER:()=>Q,XCetusModule:()=>ie,XCetusUtil:()=>R,XcetusRouterModule:()=>z,default:()=>Gt,defaultLockUpConfig:()=>A});module.exports=nt(Wt);var Ge=require("@cetusprotocol/common-sdk");var Me=require("@cetusprotocol/common-sdk"),Ie={xcetusConfig:{xcetus_manager_id:"0x838b3dbade12b1e602efcaf8c8b818fae643e43176462bf14fd196afa59d1d9d",lock_manager_id:"0x288b59d9dedb51d0bb6cb5e13bfb30885ecf44f8c9076b6f5221c5ef6644fd28",lock_handle_id:"0x7c534bb7b8a2cc21538d0dbedd2437cc64f47106cb4c259b9ff921b5c3cb1a49"},xcetusDividendsConfig:{dividend_manager_id:"0x721c990bfc031d074341c6059a113a59c1febfbd2faeb62d49dcead8408fa6b5",dividend_admin_id:"0x682ba823134f156eac2bcfb27d85a284954a0e61998dc628c40b9bcb4a46ff30",dividend_settle_id:"0xade40abe9f6dd10b83b11085be18f07b63b681cf1c169b041fa16854403388c5",venft_dividends_id:"0x9dcdb97b4307684bedaeaf803d381b12321a31ecbb9dad7df2cd5f64384f9456",venft_dividends_id_v2:"0xaa21fbc1707786d56302952f8327362f4eb9a431a5bc574834e6d46125390de3"}},Se={full_rpc_url:Me.FullRpcUrlMainnet,xcetus:{package_id:"0x9e69acc50ca03bc943c4f7c5304c2a6002d507b51c11913b247159c60422c606",published_at:"0x9e69acc50ca03bc943c4f7c5304c2a6002d507b51c11913b247159c60422c606",config:Ie.xcetusConfig},xcetus_dividends:{package_id:"0x785248249ac457dfd378bdc6d2fbbfec9d1daf65e9d728b820eb4888c8da2c10",published_at:"0x5aa58e1623885bd93de2331d05c29bf4930e54e56beeabcab8fe5385de2d31dc",version:4,config:Ie.xcetusDividendsConfig},cetus_faucet:{package_id:"0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b",published_at:"0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b"},env:"mainnet"};var xe=require("@cetusprotocol/common-sdk"),Oe={xcetusConfig:{xcetus_manager_id:"0x3be34cbad122c8b100ed7157d762b9610e68b3c65734e08bc3c3baf857da807d",lock_manager_id:"0x7c67e805182e3fecd098bd68a6b06c317f28f8c6249bd771e07904a10b424e60",lock_handle_id:"0xc5f3bbfefe9a45c13da7a34bc72cac122ee45d633690476a8ac56bd2c4e78c86"},xcetusDividendsConfig:{dividend_manager_id:"0x9d1be1a6b1146b30448a266bc87127466c0bae1585750c42adffce3e25e1ab6d",dividend_admin_id:"0x36d63c1a588bd93775aff8f47538a0063960564f0a171d100a9f49526a872b92",dividend_settle_id:"0x9eb78595419560b1dcaa9fb0ca307921ab1664a5f63c877c6887ab696344b400",venft_dividends_id:"0xc31a85fa5a77fc1def0dc5b2aadc5317a9d744ffda24b472e56a646711770676",venft_dividends_id_v2:"0x53b24031120730f6e4a733526147917650b1ecd3c56b43164b69eaa74f9b9ff7"}},Ae={full_rpc_url:xe.FullRpcUrlTestnet,xcetus:{package_id:"0xdebaab6b851fd3414c0a62dbdf8eb752d6b0d31f5cfce5e38541bc6c6daa8966",published_at:"0xdebaab6b851fd3414c0a62dbdf8eb752d6b0d31f5cfce5e38541bc6c6daa8966",version:1,config:Oe.xcetusConfig},xcetus_dividends:{package_id:"0x4061e279415a3c45cfd31554d38c5b3bb0e06c65833811a98a66f469e04c69c3",published_at:"0xfeda040996e722ba532ab2203d13333484024456ca38bf4adeb526ce1457332d",version:1,config:Oe.xcetusDividendsConfig},cetus_faucet:{package_id:"0x1a69aee6be709054750949959a67aedbb4200583b39586d5e3eabe57f40012c7",published_at:"0x1a69aee6be709054750949959a67aedbb4200583b39586d5e3eabe57f40012c7"},env:"testnet"};var j=require("@mysten/sui/transactions"),l=require("@cetusprotocol/common-sdk");var G=9e15,Z=1e9,Ee="0123456789abcdef",fe="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",le="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Te={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-G,maxE:G,crypto:!1},Re,q,v=!0,he="[DecimalError] ",K=he+"Invalid argument: ",je=he+"Precision limit exceeded",Ve=he+"crypto unavailable",Ue="[object Decimal]",S=Math.floor,C=Math.pow,it=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,rt=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,st=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Xe=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,L=1e7,_=7,ot=9007199254740991,dt=fe.length-1,Ce=le.length-1,h={toStringTag:Ue};h.absoluteValue=h.abs=function(){var t=new this.constructor(this);return t.s<0&&(t.s=1),m(t)};h.ceil=function(){return m(new this.constructor(this),this.e+1,2)};h.clampedTo=h.clamp=function(t,e){var n,i=this,r=i.constructor;if(t=new r(t),e=new r(e),!t.s||!e.s)return new r(NaN);if(t.gt(e))throw Error(K+e);return n=i.cmp(t),n<0?t:i.cmp(e)>0?e:new r(i)};h.comparedTo=h.cmp=function(t){var e,n,i,r,s=this,o=s.d,d=(t=new s.constructor(t)).d,c=s.s,a=t.s;if(!o||!d)return!c||!a?NaN:c!==a?c:o===d?0:!o^c<0?1:-1;if(!o[0]||!d[0])return o[0]?c:d[0]?-a:0;if(c!==a)return c;if(s.e!==t.e)return s.e>t.e^c<0?1:-1;for(i=o.length,r=d.length,e=0,n=i<r?i:r;e<n;++e)if(o[e]!==d[e])return o[e]>d[e]^c<0?1:-1;return i===r?0:i>r^c<0?1:-1};h.cosine=h.cos=function(){var t,e,n=this,i=n.constructor;return n.d?n.d[0]?(t=i.precision,e=i.rounding,i.precision=t+Math.max(n.e,n.sd())+_,i.rounding=1,n=at(i,Ke(i,n)),i.precision=t,i.rounding=e,m(q==2||q==3?n.neg():n,t,e,!0)):new i(1):new i(NaN)};h.cubeRoot=h.cbrt=function(){var t,e,n,i,r,s,o,d,c,a,u=this,f=u.constructor;if(!u.isFinite()||u.isZero())return new f(u);for(v=!1,s=u.s*C(u.s*u,1/3),!s||Math.abs(s)==1/0?(n=N(u.d),t=u.e,(s=(t-n.length+1)%3)&&(n+=s==1||s==-2?"0":"00"),s=C(n,1/3),t=S((t+1)/3)-(t%3==(t<0?-1:2)),s==1/0?n="5e"+t:(n=s.toExponential(),n=n.slice(0,n.indexOf("e")+1)+t),i=new f(n),i.s=u.s):i=new f(s.toString()),o=(t=f.precision)+3;;)if(d=i,c=d.times(d).times(d),a=c.plus(u),i=y(a.plus(u).times(d),a.plus(c),o+2,1),N(d.d).slice(0,o)===(n=N(i.d)).slice(0,o))if(n=n.slice(o-3,o+1),n=="9999"||!r&&n=="4999"){if(!r&&(m(d,t+1,0),d.times(d).times(d).eq(u))){i=d;break}o+=4,r=1}else{(!+n||!+n.slice(1)&&n.charAt(0)=="5")&&(m(i,t+1,1),e=!i.times(i).times(i).eq(u));break}return v=!0,m(i,t,f.rounding,e)};h.decimalPlaces=h.dp=function(){var t,e=this.d,n=NaN;if(e){if(t=e.length-1,n=(t-S(this.e/_))*_,t=e[t],t)for(;t%10==0;t/=10)n--;n<0&&(n=0)}return n};h.dividedBy=h.div=function(t){return y(this,new this.constructor(t))};h.dividedToIntegerBy=h.divToInt=function(t){var e=this,n=e.constructor;return m(y(e,new n(t),0,1,1),n.precision,n.rounding)};h.equals=h.eq=function(t){return this.cmp(t)===0};h.floor=function(){return m(new this.constructor(this),this.e+1,3)};h.greaterThan=h.gt=function(t){return this.cmp(t)>0};h.greaterThanOrEqualTo=h.gte=function(t){var e=this.cmp(t);return e==1||e===0};h.hyperbolicCosine=h.cosh=function(){var t,e,n,i,r,s=this,o=s.constructor,d=new o(1);if(!s.isFinite())return new o(s.s?1/0:NaN);if(s.isZero())return d;n=o.precision,i=o.rounding,o.precision=n+Math.max(s.e,s.sd())+4,o.rounding=1,r=s.d.length,r<32?(t=Math.ceil(r/3),e=(1/me(4,t)).toString()):(t=16,e="2.3283064365386962890625e-10"),s=W(o,1,s.times(e),new o(1),!0);for(var c,a=t,u=new o(8);a--;)c=s.times(s),s=d.minus(c.times(u.minus(c.times(u))));return m(s,o.precision=n,o.rounding=i,!0)};h.hyperbolicSine=h.sinh=function(){var t,e,n,i,r=this,s=r.constructor;if(!r.isFinite()||r.isZero())return new s(r);if(e=s.precision,n=s.rounding,s.precision=e+Math.max(r.e,r.sd())+4,s.rounding=1,i=r.d.length,i<3)r=W(s,2,r,r,!0);else{t=1.4*Math.sqrt(i),t=t>16?16:t|0,r=r.times(1/me(5,t)),r=W(s,2,r,r,!0);for(var o,d=new s(5),c=new s(16),a=new s(20);t--;)o=r.times(r),r=r.times(d.plus(o.times(c.times(o).plus(a))))}return s.precision=e,s.rounding=n,m(r,e,n,!0)};h.hyperbolicTangent=h.tanh=function(){var t,e,n=this,i=n.constructor;return n.isFinite()?n.isZero()?new i(n):(t=i.precision,e=i.rounding,i.precision=t+7,i.rounding=1,y(n.sinh(),n.cosh(),i.precision=t,i.rounding=e)):new i(n.s)};h.inverseCosine=h.acos=function(){var t=this,e=t.constructor,n=t.abs().cmp(1),i=e.precision,r=e.rounding;return n!==-1?n===0?t.isNeg()?V(e,i,r):new e(0):new e(NaN):t.isZero()?V(e,i+4,r).times(.5):(e.precision=i+6,e.rounding=1,t=new e(1).minus(t).div(t.plus(1)).sqrt().atan(),e.precision=i,e.rounding=r,t.times(2))};h.inverseHyperbolicCosine=h.acosh=function(){var t,e,n=this,i=n.constructor;return n.lte(1)?new i(n.eq(1)?0:NaN):n.isFinite()?(t=i.precision,e=i.rounding,i.precision=t+Math.max(Math.abs(n.e),n.sd())+4,i.rounding=1,v=!1,n=n.times(n).minus(1).sqrt().plus(n),v=!0,i.precision=t,i.rounding=e,n.ln()):new i(n)};h.inverseHyperbolicSine=h.asinh=function(){var t,e,n=this,i=n.constructor;return!n.isFinite()||n.isZero()?new i(n):(t=i.precision,e=i.rounding,i.precision=t+2*Math.max(Math.abs(n.e),n.sd())+6,i.rounding=1,v=!1,n=n.times(n).plus(1).sqrt().plus(n),v=!0,i.precision=t,i.rounding=e,n.ln())};h.inverseHyperbolicTangent=h.atanh=function(){var t,e,n,i,r=this,s=r.constructor;return r.isFinite()?r.e>=0?new s(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(t=s.precision,e=s.rounding,i=r.sd(),Math.max(i,t)<2*-r.e-1?m(new s(r),t,e,!0):(s.precision=n=i-r.e,r=y(r.plus(1),new s(1).minus(r),n+t,1),s.precision=t+4,s.rounding=1,r=r.ln(),s.precision=t,s.rounding=e,r.times(.5))):new s(NaN)};h.inverseSine=h.asin=function(){var t,e,n,i,r=this,s=r.constructor;return r.isZero()?new s(r):(e=r.abs().cmp(1),n=s.precision,i=s.rounding,e!==-1?e===0?(t=V(s,n+4,i).times(.5),t.s=r.s,t):new s(NaN):(s.precision=n+6,s.rounding=1,r=r.div(new s(1).minus(r.times(r)).sqrt().plus(1)).atan(),s.precision=n,s.rounding=i,r.times(2)))};h.inverseTangent=h.atan=function(){var t,e,n,i,r,s,o,d,c,a=this,u=a.constructor,f=u.precision,p=u.rounding;if(a.isFinite()){if(a.isZero())return new u(a);if(a.abs().eq(1)&&f+4<=Ce)return o=V(u,f+4,p).times(.25),o.s=a.s,o}else{if(!a.s)return new u(NaN);if(f+4<=Ce)return o=V(u,f+4,p).times(.5),o.s=a.s,o}for(u.precision=d=f+10,u.rounding=1,n=Math.min(28,d/_+2|0),t=n;t;--t)a=a.div(a.times(a).plus(1).sqrt().plus(1));for(v=!1,e=Math.ceil(d/_),i=1,c=a.times(a),o=new u(a),r=a;t!==-1;)if(r=r.times(c),s=o.minus(r.div(i+=2)),r=r.times(c),o=s.plus(r.div(i+=2)),o.d[e]!==void 0)for(t=e;o.d[t]===s.d[t]&&t--;);return n&&(o=o.times(2<<n-1)),v=!0,m(o,u.precision=f,u.rounding=p,!0)};h.isFinite=function(){return!!this.d};h.isInteger=h.isInt=function(){return!!this.d&&S(this.e/_)>this.d.length-2};h.isNaN=function(){return!this.s};h.isNegative=h.isNeg=function(){return this.s<0};h.isPositive=h.isPos=function(){return this.s>0};h.isZero=function(){return!!this.d&&this.d[0]===0};h.lessThan=h.lt=function(t){return this.cmp(t)<0};h.lessThanOrEqualTo=h.lte=function(t){return this.cmp(t)<1};h.logarithm=h.log=function(t){var e,n,i,r,s,o,d,c,a=this,u=a.constructor,f=u.precision,p=u.rounding,g=5;if(t==null)t=new u(10),e=!0;else{if(t=new u(t),n=t.d,t.s<0||!n||!n[0]||t.eq(1))return new u(NaN);e=t.eq(10)}if(n=a.d,a.s<0||!n||!n[0]||a.eq(1))return new u(n&&!n[0]?-1/0:a.s!=1?NaN:n?0:1/0);if(e)if(n.length>1)s=!0;else{for(r=n[0];r%10===0;)r/=10;s=r!==1}if(v=!1,d=f+g,o=H(a,d),i=e?pe(u,d+10):H(t,d),c=y(o,i,d,1),ee(c.d,r=f,p))do if(d+=10,o=H(a,d),i=e?pe(u,d+10):H(t,d),c=y(o,i,d,1),!s){+N(c.d).slice(r+1,r+15)+1==1e14&&(c=m(c,f+1,0));break}while(ee(c.d,r+=10,p));return v=!0,m(c,f,p)};h.minus=h.sub=function(t){var e,n,i,r,s,o,d,c,a,u,f,p,g=this,w=g.constructor;if(t=new w(t),!g.d||!t.d)return!g.s||!t.s?t=new w(NaN):g.d?t.s=-t.s:t=new w(t.d||g.s!==t.s?g:NaN),t;if(g.s!=t.s)return t.s=-t.s,g.plus(t);if(a=g.d,p=t.d,d=w.precision,c=w.rounding,!a[0]||!p[0]){if(p[0])t.s=-t.s;else if(a[0])t=new w(g);else return new w(c===3?-0:0);return v?m(t,d,c):t}if(n=S(t.e/_),u=S(g.e/_),a=a.slice(),s=u-n,s){for(f=s<0,f?(e=a,s=-s,o=p.length):(e=p,n=u,o=a.length),i=Math.max(Math.ceil(d/_),o)+2,s>i&&(s=i,e.length=1),e.reverse(),i=s;i--;)e.push(0);e.reverse()}else{for(i=a.length,o=p.length,f=i<o,f&&(o=i),i=0;i<o;i++)if(a[i]!=p[i]){f=a[i]<p[i];break}s=0}for(f&&(e=a,a=p,p=e,t.s=-t.s),o=a.length,i=p.length-o;i>0;--i)a[o++]=0;for(i=p.length;i>s;){if(a[--i]<p[i]){for(r=i;r&&a[--r]===0;)a[r]=L-1;--a[r],a[i]+=L}a[i]-=p[i]}for(;a[--o]===0;)a.pop();for(;a[0]===0;a.shift())--n;return a[0]?(t.d=a,t.e=ge(a,n),v?m(t,d,c):t):new w(c===3?-0:0)};h.modulo=h.mod=function(t){var e,n=this,i=n.constructor;return t=new i(t),!n.d||!t.s||t.d&&!t.d[0]?new i(NaN):!t.d||n.d&&!n.d[0]?m(new i(n),i.precision,i.rounding):(v=!1,i.modulo==9?(e=y(n,t.abs(),0,3,1),e.s*=t.s):e=y(n,t,0,i.modulo,1),e=e.times(t),v=!0,n.minus(e))};h.naturalExponential=h.exp=function(){return Ne(this)};h.naturalLogarithm=h.ln=function(){return H(this)};h.negated=h.neg=function(){var t=new this.constructor(this);return t.s=-t.s,m(t)};h.plus=h.add=function(t){var e,n,i,r,s,o,d,c,a,u,f=this,p=f.constructor;if(t=new p(t),!f.d||!t.d)return!f.s||!t.s?t=new p(NaN):f.d||(t=new p(t.d||f.s===t.s?f:NaN)),t;if(f.s!=t.s)return t.s=-t.s,f.minus(t);if(a=f.d,u=t.d,d=p.precision,c=p.rounding,!a[0]||!u[0])return u[0]||(t=new p(f)),v?m(t,d,c):t;if(s=S(f.e/_),i=S(t.e/_),a=a.slice(),r=s-i,r){for(r<0?(n=a,r=-r,o=u.length):(n=u,i=s,o=a.length),s=Math.ceil(d/_),o=s>o?s+1:o+1,r>o&&(r=o,n.length=1),n.reverse();r--;)n.push(0);n.reverse()}for(o=a.length,r=u.length,o-r<0&&(r=o,n=u,u=a,a=n),e=0;r;)e=(a[--r]=a[r]+u[r]+e)/L|0,a[r]%=L;for(e&&(a.unshift(e),++i),o=a.length;a[--o]==0;)a.pop();return t.d=a,t.e=ge(a,i),v?m(t,d,c):t};h.precision=h.sd=function(t){var e,n=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(K+t);return n.d?(e=$e(n.d),t&&n.e+1>e&&(e=n.e+1)):e=NaN,e};h.round=function(){var t=this,e=t.constructor;return m(new e(t),t.e+1,e.rounding)};h.sine=h.sin=function(){var t,e,n=this,i=n.constructor;return n.isFinite()?n.isZero()?new i(n):(t=i.precision,e=i.rounding,i.precision=t+Math.max(n.e,n.sd())+_,i.rounding=1,n=ut(i,Ke(i,n)),i.precision=t,i.rounding=e,m(q>2?n.neg():n,t,e,!0)):new i(NaN)};h.squareRoot=h.sqrt=function(){var t,e,n,i,r,s,o=this,d=o.d,c=o.e,a=o.s,u=o.constructor;if(a!==1||!d||!d[0])return new u(!a||a<0&&(!d||d[0])?NaN:d?o:1/0);for(v=!1,a=Math.sqrt(+o),a==0||a==1/0?(e=N(d),(e.length+c)%2==0&&(e+="0"),a=Math.sqrt(e),c=S((c+1)/2)-(c<0||c%2),a==1/0?e="5e"+c:(e=a.toExponential(),e=e.slice(0,e.indexOf("e")+1)+c),i=new u(e)):i=new u(a.toString()),n=(c=u.precision)+3;;)if(s=i,i=s.plus(y(o,s,n+2,1)).times(.5),N(s.d).slice(0,n)===(e=N(i.d)).slice(0,n))if(e=e.slice(n-3,n+1),e=="9999"||!r&&e=="4999"){if(!r&&(m(s,c+1,0),s.times(s).eq(o))){i=s;break}n+=4,r=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(m(i,c+1,1),t=!i.times(i).eq(o));break}return v=!0,m(i,c,u.rounding,t)};h.tangent=h.tan=function(){var t,e,n=this,i=n.constructor;return n.isFinite()?n.isZero()?new i(n):(t=i.precision,e=i.rounding,i.precision=t+10,i.rounding=1,n=n.sin(),n.s=1,n=y(n,new i(1).minus(n.times(n)).sqrt(),t+10,0),i.precision=t,i.rounding=e,m(q==2||q==4?n.neg():n,t,e,!0)):new i(NaN)};h.times=h.mul=function(t){var e,n,i,r,s,o,d,c,a,u=this,f=u.constructor,p=u.d,g=(t=new f(t)).d;if(t.s*=u.s,!p||!p[0]||!g||!g[0])return new f(!t.s||p&&!p[0]&&!g||g&&!g[0]&&!p?NaN:!p||!g?t.s/0:t.s*0);for(n=S(u.e/_)+S(t.e/_),c=p.length,a=g.length,c<a&&(s=p,p=g,g=s,o=c,c=a,a=o),s=[],o=c+a,i=o;i--;)s.push(0);for(i=a;--i>=0;){for(e=0,r=c+i;r>i;)d=s[r]+g[i]*p[r-i-1]+e,s[r--]=d%L|0,e=d/L|0;s[r]=(s[r]+e)%L|0}for(;!s[--o];)s.pop();return e?++n:s.shift(),t.d=s,t.e=ge(s,n),v?m(t,f.precision,f.rounding):t};h.toBinary=function(t,e){return De(this,2,t,e)};h.toDecimalPlaces=h.toDP=function(t,e){var n=this,i=n.constructor;return n=new i(n),t===void 0?n:(x(t,0,Z),e===void 0?e=i.rounding:x(e,0,8),m(n,t+n.e+1,e))};h.toExponential=function(t,e){var n,i=this,r=i.constructor;return t===void 0?n=U(i,!0):(x(t,0,Z),e===void 0?e=r.rounding:x(e,0,8),i=m(new r(i),t+1,e),n=U(i,!0,t+1)),i.isNeg()&&!i.isZero()?"-"+n:n};h.toFixed=function(t,e){var n,i,r=this,s=r.constructor;return t===void 0?n=U(r):(x(t,0,Z),e===void 0?e=s.rounding:x(e,0,8),i=m(new s(r),t+r.e+1,e),n=U(i,!1,t+i.e+1)),r.isNeg()&&!r.isZero()?"-"+n:n};h.toFraction=function(t){var e,n,i,r,s,o,d,c,a,u,f,p,g=this,w=g.d,b=g.constructor;if(!w)return new b(g);if(a=n=new b(1),i=c=new b(0),e=new b(i),s=e.e=$e(w)-g.e-1,o=s%_,e.d[0]=C(10,o<0?_+o:o),t==null)t=s>0?e:a;else{if(d=new b(t),!d.isInt()||d.lt(a))throw Error(K+d);t=d.gt(e)?s>0?e:a:d}for(v=!1,d=new b(N(w)),u=b.precision,b.precision=s=w.length*_*2;f=y(d,e,0,1,1),r=n.plus(f.times(i)),r.cmp(t)!=1;)n=i,i=r,r=a,a=c.plus(f.times(r)),c=r,r=e,e=d.minus(f.times(r)),d=r;return r=y(t.minus(n),i,0,1,1),c=c.plus(r.times(a)),n=n.plus(r.times(i)),c.s=a.s=g.s,p=y(a,i,s,1).minus(g).abs().cmp(y(c,n,s,1).minus(g).abs())<1?[a,i]:[c,n],b.precision=u,v=!0,p};h.toHexadecimal=h.toHex=function(t,e){return De(this,16,t,e)};h.toNearest=function(t,e){var n=this,i=n.constructor;if(n=new i(n),t==null){if(!n.d)return n;t=new i(1),e=i.rounding}else{if(t=new i(t),e===void 0?e=i.rounding:x(e,0,8),!n.d)return t.s?n:t;if(!t.d)return t.s&&(t.s=n.s),t}return t.d[0]?(v=!1,n=y(n,t,0,e,1).times(t),v=!0,m(n)):(t.s=n.s,n=t),n};h.toNumber=function(){return+this};h.toOctal=function(t,e){return De(this,8,t,e)};h.toPower=h.pow=function(t){var e,n,i,r,s,o,d=this,c=d.constructor,a=+(t=new c(t));if(!d.d||!t.d||!d.d[0]||!t.d[0])return new c(C(+d,a));if(d=new c(d),d.eq(1))return d;if(i=c.precision,s=c.rounding,t.eq(1))return m(d,i,s);if(e=S(t.e/_),e>=t.d.length-1&&(n=a<0?-a:a)<=ot)return r=qe(c,d,n,i),t.s<0?new c(1).div(r):m(r,i,s);if(o=d.s,o<0){if(e<t.d.length-1)return new c(NaN);if((t.d[e]&1)==0&&(o=1),d.e==0&&d.d[0]==1&&d.d.length==1)return d.s=o,d}return n=C(+d,a),e=n==0||!isFinite(n)?S(a*(Math.log("0."+N(d.d))/Math.LN10+d.e+1)):new c(n+"").e,e>c.maxE+1||e<c.minE-1?new c(e>0?o/0:0):(v=!1,c.rounding=d.s=1,n=Math.min(12,(e+"").length),r=Ne(t.times(H(d,i+n)),i),r.d&&(r=m(r,i+5,1),ee(r.d,i,s)&&(e=i+10,r=m(Ne(t.times(H(d,e+n)),e),e+5,1),+N(r.d).slice(i+1,i+15)+1==1e14&&(r=m(r,i+1,0)))),r.s=o,v=!0,c.rounding=s,m(r,i,s))};h.toPrecision=function(t,e){var n,i=this,r=i.constructor;return t===void 0?n=U(i,i.e<=r.toExpNeg||i.e>=r.toExpPos):(x(t,1,Z),e===void 0?e=r.rounding:x(e,0,8),i=m(new r(i),t,e),n=U(i,t<=i.e||i.e<=r.toExpNeg,t)),i.isNeg()&&!i.isZero()?"-"+n:n};h.toSignificantDigits=h.toSD=function(t,e){var n=this,i=n.constructor;return t===void 0?(t=i.precision,e=i.rounding):(x(t,1,Z),e===void 0?e=i.rounding:x(e,0,8)),m(new i(n),t,e)};h.toString=function(){var t=this,e=t.constructor,n=U(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()&&!t.isZero()?"-"+n:n};h.truncated=h.trunc=function(){return m(new this.constructor(this),this.e+1,1)};h.valueOf=h.toJSON=function(){var t=this,e=t.constructor,n=U(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()?"-"+n:n};function N(t){var e,n,i,r=t.length-1,s="",o=t[0];if(r>0){for(s+=o,e=1;e<r;e++)i=t[e]+"",n=_-i.length,n&&(s+=B(n)),s+=i;o=t[e],i=o+"",n=_-i.length,n&&(s+=B(n))}else if(o===0)return"0";for(;o%10===0;)o/=10;return s+o}function x(t,e,n){if(t!==~~t||t<e||t>n)throw Error(K+t)}function ee(t,e,n,i){var r,s,o,d;for(s=t[0];s>=10;s/=10)--e;return--e<0?(e+=_,r=0):(r=Math.ceil((e+1)/_),e%=_),s=C(10,_-e),d=t[r]%s|0,i==null?e<3?(e==0?d=d/100|0:e==1&&(d=d/10|0),o=n<4&&d==99999||n>3&&d==49999||d==5e4||d==0):o=(n<4&&d+1==s||n>3&&d+1==s/2)&&(t[r+1]/s/100|0)==C(10,e-2)-1||(d==s/2||d==0)&&(t[r+1]/s/100|0)==0:e<4?(e==0?d=d/1e3|0:e==1?d=d/100|0:e==2&&(d=d/10|0),o=(i||n<4)&&d==9999||!i&&n>3&&d==4999):o=((i||n<4)&&d+1==s||!i&&n>3&&d+1==s/2)&&(t[r+1]/s/1e3|0)==C(10,e-3)-1,o}function ce(t,e,n){for(var i,r=[0],s,o=0,d=t.length;o<d;){for(s=r.length;s--;)r[s]*=e;for(r[0]+=Ee.indexOf(t.charAt(o++)),i=0;i<r.length;i++)r[i]>n-1&&(r[i+1]===void 0&&(r[i+1]=0),r[i+1]+=r[i]/n|0,r[i]%=n)}return r.reverse()}function at(t,e){var n,i,r;if(e.isZero())return e;i=e.d.length,i<32?(n=Math.ceil(i/3),r=(1/me(4,n)).toString()):(n=16,r="2.3283064365386962890625e-10"),t.precision+=n,e=W(t,1,e.times(r),new t(1));for(var s=n;s--;){var o=e.times(e);e=o.times(o).minus(o).times(8).plus(1)}return t.precision-=n,e}var y=function(){function t(i,r,s){var o,d=0,c=i.length;for(i=i.slice();c--;)o=i[c]*r+d,i[c]=o%s|0,d=o/s|0;return d&&i.unshift(d),i}function e(i,r,s,o){var d,c;if(s!=o)c=s>o?1:-1;else for(d=c=0;d<s;d++)if(i[d]!=r[d]){c=i[d]>r[d]?1:-1;break}return c}function n(i,r,s,o){for(var d=0;s--;)i[s]-=d,d=i[s]<r[s]?1:0,i[s]=d*o+i[s]-r[s];for(;!i[0]&&i.length>1;)i.shift()}return function(i,r,s,o,d,c){var a,u,f,p,g,w,b,O,T,F,k,I,se,$,be,oe,Y,we,P,de,ae=i.constructor,ke=i.s==r.s?1:-1,M=i.d,E=r.d;if(!M||!M[0]||!E||!E[0])return new ae(!i.s||!r.s||(M?E&&M[0]==E[0]:!E)?NaN:M&&M[0]==0||!E?ke*0:ke/0);for(c?(g=1,u=i.e-r.e):(c=L,g=_,u=S(i.e/g)-S(r.e/g)),P=E.length,Y=M.length,T=new ae(ke),F=T.d=[],f=0;E[f]==(M[f]||0);f++);if(E[f]>(M[f]||0)&&u--,s==null?($=s=ae.precision,o=ae.rounding):d?$=s+(i.e-r.e)+1:$=s,$<0)F.push(1),w=!0;else{if($=$/g+2|0,f=0,P==1){for(p=0,E=E[0],$++;(f<Y||p)&&$--;f++)be=p*c+(M[f]||0),F[f]=be/E|0,p=be%E|0;w=p||f<Y}else{for(p=c/(E[0]+1)|0,p>1&&(E=t(E,p,c),M=t(M,p,c),P=E.length,Y=M.length),oe=P,k=M.slice(0,P),I=k.length;I<P;)k[I++]=0;de=E.slice(),de.unshift(0),we=E[0],E[1]>=c/2&&++we;do p=0,a=e(E,k,P,I),a<0?(se=k[0],P!=I&&(se=se*c+(k[1]||0)),p=se/we|0,p>1?(p>=c&&(p=c-1),b=t(E,p,c),O=b.length,I=k.length,a=e(b,k,O,I),a==1&&(p--,n(b,P<O?de:E,O,c))):(p==0&&(a=p=1),b=E.slice()),O=b.length,O<I&&b.unshift(0),n(k,b,I,c),a==-1&&(I=k.length,a=e(E,k,P,I),a<1&&(p++,n(k,P<I?de:E,I,c))),I=k.length):a===0&&(p++,k=[0]),F[f++]=p,a&&k[0]?k[I++]=M[oe]||0:(k=[M[oe]],I=1);while((oe++<Y||k[0]!==void 0)&&$--);w=k[0]!==void 0}F[0]||F.shift()}if(g==1)T.e=u,Re=w;else{for(f=1,p=F[0];p>=10;p/=10)f++;T.e=f+u*g-1,m(T,d?s+T.e+1:s,o,w)}return T}}();function m(t,e,n,i){var r,s,o,d,c,a,u,f,p,g=t.constructor;e:if(e!=null){if(f=t.d,!f)return t;for(r=1,d=f[0];d>=10;d/=10)r++;if(s=e-r,s<0)s+=_,o=e,u=f[p=0],c=u/C(10,r-o-1)%10|0;else if(p=Math.ceil((s+1)/_),d=f.length,p>=d)if(i){for(;d++<=p;)f.push(0);u=c=0,r=1,s%=_,o=s-_+1}else break e;else{for(u=d=f[p],r=1;d>=10;d/=10)r++;s%=_,o=s-_+r,c=o<0?0:u/C(10,r-o-1)%10|0}if(i=i||e<0||f[p+1]!==void 0||(o<0?u:u%C(10,r-o-1)),a=n<4?(c||i)&&(n==0||n==(t.s<0?3:2)):c>5||c==5&&(n==4||i||n==6&&(s>0?o>0?u/C(10,r-o):0:f[p-1])%10&1||n==(t.s<0?8:7)),e<1||!f[0])return f.length=0,a?(e-=t.e+1,f[0]=C(10,(_-e%_)%_),t.e=-e||0):f[0]=t.e=0,t;if(s==0?(f.length=p,d=1,p--):(f.length=p+1,d=C(10,_-s),f[p]=o>0?(u/C(10,r-o)%C(10,o)|0)*d:0),a)for(;;)if(p==0){for(s=1,o=f[0];o>=10;o/=10)s++;for(o=f[0]+=d,d=1;o>=10;o/=10)d++;s!=d&&(t.e++,f[0]==L&&(f[0]=1));break}else{if(f[p]+=d,f[p]!=L)break;f[p--]=0,d=1}for(s=f.length;f[--s]===0;)f.pop()}return v&&(t.e>g.maxE?(t.d=null,t.e=NaN):t.e<g.minE&&(t.e=0,t.d=[0])),t}function U(t,e,n){if(!t.isFinite())return He(t);var i,r=t.e,s=N(t.d),o=s.length;return e?(n&&(i=n-o)>0?s=s.charAt(0)+"."+s.slice(1)+B(i):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(t.e<0?"e":"e+")+t.e):r<0?(s="0."+B(-r-1)+s,n&&(i=n-o)>0&&(s+=B(i))):r>=o?(s+=B(r+1-o),n&&(i=n-r-1)>0&&(s=s+"."+B(i))):((i=r+1)<o&&(s=s.slice(0,i)+"."+s.slice(i)),n&&(i=n-o)>0&&(r+1===o&&(s+="."),s+=B(i))),s}function ge(t,e){var n=t[0];for(e*=_;n>=10;n/=10)e++;return e}function pe(t,e,n){if(e>dt)throw v=!0,n&&(t.precision=n),Error(je);return m(new t(fe),e,1,!0)}function V(t,e,n){if(e>Ce)throw Error(je);return m(new t(le),e,n,!0)}function $e(t){var e=t.length-1,n=e*_+1;if(e=t[e],e){for(;e%10==0;e/=10)n--;for(e=t[0];e>=10;e/=10)n++}return n}function B(t){for(var e="";t--;)e+="0";return e}function qe(t,e,n,i){var r,s=new t(1),o=Math.ceil(i/_+4);for(v=!1;;){if(n%2&&(s=s.times(e),Pe(s.d,o)&&(r=!0)),n=S(n/2),n===0){n=s.d.length-1,r&&s.d[n]===0&&++s.d[n];break}e=e.times(e),Pe(e.d,o)}return v=!0,s}function Fe(t){return t.d[t.d.length-1]&1}function Be(t,e,n){for(var i,r,s=new t(e[0]),o=0;++o<e.length;){if(r=new t(e[o]),!r.s){s=r;break}i=s.cmp(r),(i===n||i===0&&s.s===n)&&(s=r)}return s}function Ne(t,e){var n,i,r,s,o,d,c,a=0,u=0,f=0,p=t.constructor,g=p.rounding,w=p.precision;if(!t.d||!t.d[0]||t.e>17)return new p(t.d?t.d[0]?t.s<0?0:1/0:1:t.s?t.s<0?0:t:NaN);for(e==null?(v=!1,c=w):c=e,d=new p(.03125);t.e>-2;)t=t.times(d),f+=5;for(i=Math.log(C(2,f))/Math.LN10*2+5|0,c+=i,n=s=o=new p(1),p.precision=c;;){if(s=m(s.times(t),c,1),n=n.times(++u),d=o.plus(y(s,n,c,1)),N(d.d).slice(0,c)===N(o.d).slice(0,c)){for(r=f;r--;)o=m(o.times(o),c,1);if(e==null)if(a<3&&ee(o.d,c-i,g,a))p.precision=c+=10,n=s=d=new p(1),u=0,a++;else return m(o,p.precision=w,g,v=!0);else return p.precision=w,o}o=d}}function H(t,e){var n,i,r,s,o,d,c,a,u,f,p,g=1,w=10,b=t,O=b.d,T=b.constructor,F=T.rounding,k=T.precision;if(b.s<0||!O||!O[0]||!b.e&&O[0]==1&&O.length==1)return new T(O&&!O[0]?-1/0:b.s!=1?NaN:O?0:b);if(e==null?(v=!1,u=k):u=e,T.precision=u+=w,n=N(O),i=n.charAt(0),Math.abs(s=b.e)<15e14){for(;i<7&&i!=1||i==1&&n.charAt(1)>3;)b=b.times(t),n=N(b.d),i=n.charAt(0),g++;s=b.e,i>1?(b=new T("0."+n),s++):b=new T(i+"."+n.slice(1))}else return a=pe(T,u+2,k).times(s+""),b=H(new T(i+"."+n.slice(1)),u-w).plus(a),T.precision=k,e==null?m(b,k,F,v=!0):b;for(f=b,c=o=b=y(b.minus(1),b.plus(1),u,1),p=m(b.times(b),u,1),r=3;;){if(o=m(o.times(p),u,1),a=c.plus(y(o,new T(r),u,1)),N(a.d).slice(0,u)===N(c.d).slice(0,u))if(c=c.times(2),s!==0&&(c=c.plus(pe(T,u+2,k).times(s+""))),c=y(c,new T(g),u,1),e==null)if(ee(c.d,u-w,F,d))T.precision=u+=w,a=o=b=y(f.minus(1),f.plus(1),u,1),p=m(b.times(b),u,1),r=d=1;else return m(c,T.precision=k,F,v=!0);else return T.precision=k,c;c=a,r+=2}}function He(t){return String(t.s*t.s/0)}function ue(t,e){var n,i,r;for((n=e.indexOf("."))>-1&&(e=e.replace(".","")),(i=e.search(/e/i))>0?(n<0&&(n=i),n+=+e.slice(i+1),e=e.substring(0,i)):n<0&&(n=e.length),i=0;e.charCodeAt(i)===48;i++);for(r=e.length;e.charCodeAt(r-1)===48;--r);if(e=e.slice(i,r),e){if(r-=i,t.e=n=n-i-1,t.d=[],i=(n+1)%_,n<0&&(i+=_),i<r){for(i&&t.d.push(+e.slice(0,i)),r-=_;i<r;)t.d.push(+e.slice(i,i+=_));e=e.slice(i),i=_-e.length}else i-=r;for(;i--;)e+="0";t.d.push(+e),v&&(t.e>t.constructor.maxE?(t.d=null,t.e=NaN):t.e<t.constructor.minE&&(t.e=0,t.d=[0]))}else t.e=0,t.d=[0];return t}function ct(t,e){var n,i,r,s,o,d,c,a,u;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),Xe.test(e))return ue(t,e)}else if(e==="Infinity"||e==="NaN")return+e||(t.s=NaN),t.e=NaN,t.d=null,t;if(rt.test(e))n=16,e=e.toLowerCase();else if(it.test(e))n=2;else if(st.test(e))n=8;else throw Error(K+e);for(s=e.search(/p/i),s>0?(c=+e.slice(s+1),e=e.substring(2,s)):e=e.slice(2),s=e.indexOf("."),o=s>=0,i=t.constructor,o&&(e=e.replace(".",""),d=e.length,s=d-s,r=qe(i,new i(n),s,s*2)),a=ce(e,n,L),u=a.length-1,s=u;a[s]===0;--s)a.pop();return s<0?new i(t.s*0):(t.e=ge(a,u),t.d=a,v=!1,o&&(t=y(t,r,d*4)),c&&(t=t.times(Math.abs(c)<54?C(2,c):te.pow(2,c))),v=!0,t)}function ut(t,e){var n,i=e.d.length;if(i<3)return e.isZero()?e:W(t,2,e,e);n=1.4*Math.sqrt(i),n=n>16?16:n|0,e=e.times(1/me(5,n)),e=W(t,2,e,e);for(var r,s=new t(5),o=new t(16),d=new t(20);n--;)r=e.times(e),e=e.times(s.plus(r.times(o.times(r).minus(d))));return e}function W(t,e,n,i,r){var s,o,d,c,a=1,u=t.precision,f=Math.ceil(u/_);for(v=!1,c=n.times(n),d=new t(i);;){if(o=y(d.times(c),new t(e++*e++),u,1),d=r?i.plus(o):i.minus(o),i=y(o.times(c),new t(e++*e++),u,1),o=d.plus(i),o.d[f]!==void 0){for(s=f;o.d[s]===d.d[s]&&s--;);if(s==-1)break}s=d,d=i,i=o,o=s,a++}return v=!0,o.d.length=f+1,o}function me(t,e){for(var n=t;--e;)n*=t;return n}function Ke(t,e){var n,i=e.s<0,r=V(t,t.precision,1),s=r.times(.5);if(e=e.abs(),e.lte(s))return q=i?4:1,e;if(n=e.divToInt(r),n.isZero())q=i?3:2;else{if(e=e.minus(n.times(r)),e.lte(s))return q=Fe(n)?i?2:3:i?4:1,e;q=Fe(n)?i?1:4:i?3:2}return e.minus(r).abs()}function De(t,e,n,i){var r,s,o,d,c,a,u,f,p,g=t.constructor,w=n!==void 0;if(w?(x(n,1,Z),i===void 0?i=g.rounding:x(i,0,8)):(n=g.precision,i=g.rounding),!t.isFinite())u=He(t);else{for(u=U(t),o=u.indexOf("."),w?(r=2,e==16?n=n*4-3:e==8&&(n=n*3-2)):r=e,o>=0&&(u=u.replace(".",""),p=new g(1),p.e=u.length-o,p.d=ce(U(p),10,r),p.e=p.d.length),f=ce(u,10,r),s=c=f.length;f[--c]==0;)f.pop();if(!f[0])u=w?"0p+0":"0";else{if(o<0?s--:(t=new g(t),t.d=f,t.e=s,t=y(t,p,n,i,0,r),f=t.d,s=t.e,a=Re),o=f[n],d=r/2,a=a||f[n+1]!==void 0,a=i<4?(o!==void 0||a)&&(i===0||i===(t.s<0?3:2)):o>d||o===d&&(i===4||a||i===6&&f[n-1]&1||i===(t.s<0?8:7)),f.length=n,a)for(;++f[--n]>r-1;)f[n]=0,n||(++s,f.unshift(1));for(c=f.length;!f[c-1];--c);for(o=0,u="";o<c;o++)u+=Ee.charAt(f[o]);if(w){if(c>1)if(e==16||e==8){for(o=e==16?4:3,--c;c%o;c++)u+="0";for(f=ce(u,r,e),c=f.length;!f[c-1];--c);for(o=1,u="1.";o<c;o++)u+=Ee.charAt(f[o])}else u=u.charAt(0)+"."+u.slice(1);u=u+(s<0?"p":"p+")+s}else if(s<0){for(;++s;)u="0"+u;u="0."+u}else if(++s>c)for(s-=c;s--;)u+="0";else s<c&&(u=u.slice(0,s)+"."+u.slice(s))}u=(e==16?"0x":e==2?"0b":e==8?"0o":"")+u}return t.s<0?"-"+u:u}function Pe(t,e){if(t.length>e)return t.length=e,!0}function ft(t){return new this(t).abs()}function lt(t){return new this(t).acos()}function pt(t){return new this(t).acosh()}function ht(t,e){return new this(t).plus(e)}function gt(t){return new this(t).asin()}function mt(t){return new this(t).asinh()}function _t(t){return new this(t).atan()}function vt(t){return new this(t).atanh()}function bt(t,e){t=new this(t),e=new this(e);var n,i=this.precision,r=this.rounding,s=i+4;return!t.s||!e.s?n=new this(NaN):!t.d&&!e.d?(n=V(this,s,1).times(e.s>0?.25:.75),n.s=t.s):!e.d||t.isZero()?(n=e.s<0?V(this,i,r):new this(0),n.s=t.s):!t.d||e.isZero()?(n=V(this,s,1).times(.5),n.s=t.s):e.s<0?(this.precision=s,this.rounding=1,n=this.atan(y(t,e,s,1)),e=V(this,s,1),this.precision=i,this.rounding=r,n=t.s<0?n.minus(e):n.plus(e)):n=this.atan(y(t,e,s,1)),n}function wt(t){return new this(t).cbrt()}function kt(t){return m(t=new this(t),t.e+1,2)}function yt(t,e,n){return new this(t).clamp(e,n)}function Et(t){if(!t||typeof t!="object")throw Error(he+"Object expected");var e,n,i,r=t.defaults===!0,s=["precision",1,Z,"rounding",0,8,"toExpNeg",-G,0,"toExpPos",0,G,"maxE",0,G,"minE",-G,0,"modulo",0,9];for(e=0;e<s.length;e+=3)if(n=s[e],r&&(this[n]=Te[n]),(i=t[n])!==void 0)if(S(i)===i&&i>=s[e+1]&&i<=s[e+2])this[n]=i;else throw Error(K+n+": "+i);if(n="crypto",r&&(this[n]=Te[n]),(i=t[n])!==void 0)if(i===!0||i===!1||i===0||i===1)if(i)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[n]=!0;else throw Error(Ve);else this[n]=!1;else throw Error(K+n+": "+i);return this}function Tt(t){return new this(t).cos()}function Ct(t){return new this(t).cosh()}function Ze(t){var e,n,i;function r(s){var o,d,c,a=this;if(!(a instanceof r))return new r(s);if(a.constructor=r,Le(s)){a.s=s.s,v?!s.d||s.e>r.maxE?(a.e=NaN,a.d=null):s.e<r.minE?(a.e=0,a.d=[0]):(a.e=s.e,a.d=s.d.slice()):(a.e=s.e,a.d=s.d?s.d.slice():s.d);return}if(c=typeof s,c==="number"){if(s===0){a.s=1/s<0?-1:1,a.e=0,a.d=[0];return}if(s<0?(s=-s,a.s=-1):a.s=1,s===~~s&&s<1e7){for(o=0,d=s;d>=10;d/=10)o++;v?o>r.maxE?(a.e=NaN,a.d=null):o<r.minE?(a.e=0,a.d=[0]):(a.e=o,a.d=[s]):(a.e=o,a.d=[s]);return}if(s*0!==0){s||(a.s=NaN),a.e=NaN,a.d=null;return}return ue(a,s.toString())}if(c==="string")return(d=s.charCodeAt(0))===45?(s=s.slice(1),a.s=-1):(d===43&&(s=s.slice(1)),a.s=1),Xe.test(s)?ue(a,s):ct(a,s);if(c==="bigint")return s<0?(s=-s,a.s=-1):a.s=1,ue(a,s.toString());throw Error(K+s)}if(r.prototype=h,r.ROUND_UP=0,r.ROUND_DOWN=1,r.ROUND_CEIL=2,r.ROUND_FLOOR=3,r.ROUND_HALF_UP=4,r.ROUND_HALF_DOWN=5,r.ROUND_HALF_EVEN=6,r.ROUND_HALF_CEIL=7,r.ROUND_HALF_FLOOR=8,r.EUCLID=9,r.config=r.set=Et,r.clone=Ze,r.isDecimal=Le,r.abs=ft,r.acos=lt,r.acosh=pt,r.add=ht,r.asin=gt,r.asinh=mt,r.atan=_t,r.atanh=vt,r.atan2=bt,r.cbrt=wt,r.ceil=kt,r.clamp=yt,r.cos=Tt,r.cosh=Ct,r.div=Nt,r.exp=Dt,r.floor=It,r.hypot=Mt,r.ln=St,r.log=Ot,r.log10=At,r.log2=xt,r.max=Ft,r.min=Pt,r.mod=Lt,r.mul=Rt,r.pow=jt,r.random=Vt,r.round=Ut,r.sign=Xt,r.sin=$t,r.sinh=qt,r.sqrt=Bt,r.sub=Ht,r.sum=Kt,r.tan=Zt,r.tanh=zt,r.trunc=Qt,t===void 0&&(t={}),t&&t.defaults!==!0)for(i=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<i.length;)t.hasOwnProperty(n=i[e++])||(t[n]=this[n]);return r.config(t),r}function Nt(t,e){return new this(t).div(e)}function Dt(t){return new this(t).exp()}function It(t){return m(t=new this(t),t.e+1,3)}function Mt(){var t,e,n=new this(0);for(v=!1,t=0;t<arguments.length;)if(e=new this(arguments[t++]),e.d)n.d&&(n=n.plus(e.times(e)));else{if(e.s)return v=!0,new this(1/0);n=e}return v=!0,n.sqrt()}function Le(t){return t instanceof te||t&&t.toStringTag===Ue||!1}function St(t){return new this(t).ln()}function Ot(t,e){return new this(t).log(e)}function xt(t){return new this(t).log(2)}function At(t){return new this(t).log(10)}function Ft(){return Be(this,arguments,-1)}function Pt(){return Be(this,arguments,1)}function Lt(t,e){return new this(t).mod(e)}function Rt(t,e){return new this(t).mul(e)}function jt(t,e){return new this(t).pow(e)}function Vt(t){var e,n,i,r,s=0,o=new this(1),d=[];if(t===void 0?t=this.precision:x(t,1,Z),i=Math.ceil(t/_),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(i));s<i;)r=e[s],r>=429e7?e[s]=crypto.getRandomValues(new Uint32Array(1))[0]:d[s++]=r%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(i*=4);s<i;)r=e[s]+(e[s+1]<<8)+(e[s+2]<<16)+((e[s+3]&127)<<24),r>=214e7?crypto.randomBytes(4).copy(e,s):(d.push(r%1e7),s+=4);s=i/4}else throw Error(Ve);else for(;s<i;)d[s++]=Math.random()*1e7|0;for(i=d[--s],t%=_,i&&t&&(r=C(10,_-t),d[s]=(i/r|0)*r);d[s]===0;s--)d.pop();if(s<0)n=0,d=[0];else{for(n=-1;d[0]===0;n-=_)d.shift();for(i=1,r=d[0];r>=10;r/=10)i++;i<_&&(n-=_-i)}return o.e=n,o.d=d,o}function Ut(t){return m(t=new this(t),t.e+1,this.rounding)}function Xt(t){return t=new this(t),t.d?t.d[0]?t.s:0*t.s:t.s||NaN}function $t(t){return new this(t).sin()}function qt(t){return new this(t).sinh()}function Bt(t){return new this(t).sqrt()}function Ht(t,e){return new this(t).sub(e)}function Kt(){var t=0,e=arguments,n=new this(e[t]);for(v=!1;n.s&&++t<e.length;)n=n.plus(e[t]);return v=!0,m(n,this.precision,this.rounding)}function Zt(t){return new this(t).tan()}function zt(t){return new this(t).tanh()}function Qt(t){return m(t=new this(t),t.e+1,1)}h[Symbol.for("nodejs.util.inspect.custom")]=h.toString;h[Symbol.toStringTag]="Decimal";var te=h.constructor=Ze(Te);fe=new te(fe);le=new te(le);var ze=te;var Qe=require("@cetusprotocol/common-sdk");var _e=class extends Qe.BaseError{constructor(e,n,i){super(e,n||"UnknownError",i)}static isXCetusErrorCode(e,n){return this.isErrorCode(e,n)}},D=(t,e,n)=>{throw e instanceof Error?new _e(e.message,t,n):new _e(e,t,n)};var z="router",J="router",ne=86400,ve=1e3,Q=1e11,A={min_lock_day:15,max_lock_day:180,max_percent_numerator:1e3,min_percent_numerator:500};var X=require("@cetusprotocol/common-sdk");var R=class t{static buildVeNFTDividendInfo(e){let n={id:e.id.id,venft_id:e.name,rewards:[]};return e.value.fields.value.fields.dividends.fields.contents.forEach(i=>{let r=[];i.fields.value.fields.contents.forEach(s=>{let o=s.fields.value;(0,X.d)(o).gt(0)&&r.push({coin_type:(0,X.extractStructTagFromType)(s.fields.key.fields.name).source_address,amount:o})}),r.length>0&&n.rewards.push({period:Number(i.fields.key),rewards:r,version:"v1"})}),n}static buildDividendManager(e){let n={id:e.id.id,dividends:{id:e.dividends.fields.id.id,size:e.dividends.fields.size},venft_dividends:{id:e.venft_dividends.fields.id.id,size:e.venft_dividends.fields.size},bonus_types:[],start_time:Number(e.start_time),interval_day:Number(e.interval_day),balances:{id:e.balances.fields.id.id,size:e.balances.fields.size},is_open:e.is_open};return e.bonus_types.forEach(i=>{n.bonus_types.push((0,X.extractStructTagFromType)(i.fields.name).source_address)}),n}static buildLockUpManager(e){return{id:e.id.id,balance:e.balance,treasury_manager:e.treasury_manager,extra_treasury:e.extra_treasury,lock_infos:{lock_handle_id:e.lock_infos.fields.id.id,size:Number(e.lock_infos.fields.size)},type_name:(0,X.normalizeCoinType)(e.type_name.fields.name),min_lock_day:Number(e.min_lock_day),max_lock_day:Number(e.max_lock_day),package_version:Number(e.package_version),max_percent_numerator:Number(e.max_percent_numerator),min_percent_numerator:Number(e.min_percent_numerator)}}static buildLockCetus(e){let n=e.fields,i={id:n.id.id,type:(0,X.extractStructTagFromType)(e.type).source_address,locked_start_time:Number(n.locked_start_time),locked_until_time:Number(n.locked_until_time),cetus_amount:n.balance,xcetus_amount:"0",lock_day:0};return i.lock_day=(i.locked_until_time-i.locked_start_time)/86400,i}static getAvailableXCetus(e,n){let i=(0,X.d)(0);return n.forEach(r=>{i=i.add(r.xcetus_amount)}),(0,X.d)(e.xcetus_balance).sub(i).toString()}static getWaitUnLockCetus(e){return e.filter(n=>!t.isLocked(n))}static getLockingCetus(e){return e.filter(n=>t.isLocked(n))}static isLocked(e){return e.locked_until_time>Date.parse(new Date().toString())/1e3}static buildDividendRewardTypeList(e,n){let i=new Set;return e?.forEach(r=>{r.rewards.forEach(s=>{i.add(s.coin_type)})}),n?.forEach(r=>{r.rewards.forEach(s=>{i.add(s.coin_type)})}),Array.from(i)}static buildDividendRewardTypeListV2(e){let n={};return e?.forEach(i=>{i.version==="v2"&&i.rewards.forEach(r=>{n[r.coin_type]||(n[r.coin_type]=[]),n[r.coin_type].push(i.period)})}),n}static getNextStartTime(e){let n=Date.now()/1e3,{start_time:i,interval_day:r}=e,s=Math.ceil((n-i)/(r*86400));return i+s*r*86400}};var ie=class{constructor(e){this._cache={};this._sdk=e}get sdk(){return this._sdk}async getOwnerVeNFT(e,n=!0){let{xcetus:i}=this.sdk.sdkOptions,r=`${e}_getLockUpManagerEvent`,s=this.getCache(r,n);if(s!==void 0)return s;let o,d=`${i.package_id}::xcetus::VeNFT`;try{return(await this._sdk.FullClient.getOwnedObjectsByPage(e,{options:{showType:!0,showContent:!0,showDisplay:!0},filter:{StructType:d}})).data.forEach(a=>{let u=(0,l.extractStructTagFromType)((0,l.getMoveObjectType)(a)).source_address;if(u===d&&a.data&&a.data.content){let{fields:f}=a.data.content;o={...(0,l.buildNFT)(a),id:f.id.id,index:f.index,type:u,xcetus_balance:f.xcetus_balance},this.updateCache(r,o,l.CACHE_TIME_24H)}}),o}catch(c){return D("InvalidAccountAddress",c,{[l.DETAILS_KEYS.METHOD_NAME]:"getOwnerVeNFT",[l.DETAILS_KEYS.REQUEST_PARAMS]:{account_address:e}})}}async getOwnerRedeemLockList(e){let{xcetus:n}=this.sdk.sdkOptions,i=[],r=(0,l.extractStructTagFromType)(this.buildCetusCoinType()).full_address,s=`${n.package_id}::lock_coin::LockedCoin<${r}>`;try{let o=await this._sdk.FullClient.getOwnedObjectsByPage(e,{options:{showType:!0,showContent:!0},filter:{StructType:s}});for(let d of o.data)if((0,l.extractStructTagFromType)((0,l.getMoveObjectType)(d)).source_address===s&&d.data){let a=R.buildLockCetus(d.data.content);a.xcetus_amount=await this.getXCetusAmount(a.id),i.push(a)}return i}catch(o){return D("InvalidAccountAddress",o,{[l.DETAILS_KEYS.METHOD_NAME]:"getOwnerRedeemLockList",[l.DETAILS_KEYS.REQUEST_PARAMS]:{account_address:e}})}}async getLockCetus(e){try{let n=await this._sdk.FullClient.getObject({id:e,options:{showType:!0,showContent:!0}});if(n.data?.content){let i=R.buildLockCetus(n.data.content);return i.xcetus_amount=await this.getXCetusAmount(i.id),i}return}catch(n){return D("InvalidLockId",n,{[l.DETAILS_KEYS.METHOD_NAME]:"getLockCetus",[l.DETAILS_KEYS.REQUEST_PARAMS]:{lock_id:e}})}}async getOwnerCetusCoins(e){try{return await this._sdk.FullClient.getOwnerCoinAssets(e,this.buildCetusCoinType())}catch(n){return D("InvalidAccountAddress",n,{[l.DETAILS_KEYS.METHOD_NAME]:"getOwnerCetusCoins",[l.DETAILS_KEYS.REQUEST_PARAMS]:{account_address:e}})}}mintVeNFTPayload(){let{xcetus:e}=this.sdk.sdkOptions,n=new j.Transaction;return n.moveCall({target:`${e.published_at}::${z}::mint_venft`,typeArguments:[],arguments:[n.object((0,l.getPackagerConfigs)(e)?.xcetus_manager_id)]}),n}convertPayload(e,n){let{xcetus:i}=this.sdk.sdkOptions;n=n||new j.Transaction;let r=this.buildCetusCoinType();n.setSender(this._sdk.getSenderAddress());let s=l.CoinAssist.buildCoinWithBalance(BigInt(e.amount),r,n);return e.venft_id===void 0?n.moveCall({target:`${i.published_at}::${z}::mint_and_convert`,typeArguments:[],arguments:[n.object((0,l.getPackagerConfigs)(i)?.lock_manager_id),n.object((0,l.getPackagerConfigs)(i)?.xcetus_manager_id),n.makeMoveVec({elements:[s]}),n.pure.u64(e.amount)]}):n.moveCall({target:`${i.published_at}::${z}::convert`,typeArguments:[],arguments:[n.object((0,l.getPackagerConfigs)(i)?.lock_manager_id),n.object((0,l.getPackagerConfigs)(i)?.xcetus_manager_id),n.makeMoveVec({elements:[s]}),n.pure.u64(e.amount),n.object(e.venft_id)]}),n}redeemLockPayload(e){let{xcetus:n}=this.sdk.sdkOptions,i=new j.Transaction;return i.moveCall({target:`${n.published_at}::${z}::redeem_lock`,typeArguments:[],arguments:[i.object((0,l.getPackagerConfigs)(n)?.lock_manager_id),i.object((0,l.getPackagerConfigs)(n)?.xcetus_manager_id),i.object(e.venft_id),i.pure.u64(e.amount),i.pure.u64(e.lock_day),i.object(l.CLOCK_ADDRESS)]}),i}redeemPayload(e){let{xcetus:n}=this.sdk.sdkOptions,i=new j.Transaction;return i.moveCall({target:`${n.published_at}::${z}::redeem`,typeArguments:[],arguments:[i.object((0,l.getPackagerConfigs)(n)?.lock_manager_id),i.object((0,l.getPackagerConfigs)(n)?.xcetus_manager_id),i.object(e.venft_id),i.object(e.lock_id),i.object(l.CLOCK_ADDRESS)]}),i}redeemDividendPayload(e,n){let{xcetus:i,xcetus_dividends:r}=this.sdk.sdkOptions,s=new j.Transaction;return n.forEach(o=>{s.moveCall({target:`${i.published_at}::${J}::redeem`,typeArguments:[o],arguments:[s.object((0,l.getPackagerConfigs)(r)?.dividend_manager_id),s.object(e)]})}),s}redeemDividendV2Payload(e,n,i){let{xcetus_dividends:r}=this.sdk.sdkOptions,s=new j.Transaction;return n.filter(d=>i.includes(d)).length>0&&(s=this.redeemDividendXTokenPayload(e,s)),n.forEach(d=>{i.includes(d)||s.moveCall({target:`${r.published_at}::${J}::redeem_v2`,typeArguments:[d],arguments:[s.object((0,l.getPackagerConfigs)(r)?.dividend_manager_id),s.object(e),s.object(l.CLOCK_ADDRESS)]})}),s}redeemDividendV3Payload(e,n){let{xcetus_dividends:i}=this.sdk.sdkOptions,r=new j.Transaction,s=R.buildDividendRewardTypeList(n),o=R.buildDividendRewardTypeListV2(n),d=(0,l.extractStructTagFromType)(this.buildXTokenCoinType()).full_address;return s.find(a=>(0,l.extractStructTagFromType)(a).full_address===d)!==void 0&&this.redeemDividendXTokenPayload(e,r),s.forEach(a=>{r.moveCall({target:`${i.published_at}::${J}::redeem_v3`,typeArguments:[a],arguments:[r.object((0,l.getPackagerConfigs)(i)?.dividend_manager_id),r.object((0,l.getPackagerConfigs)(i)?.venft_dividends_id),r.makeMoveVec({elements:o[a].map(u=>r.pure.u64(u)),type:"u64"}),r.object(e),r.object(l.CLOCK_ADDRESS)]})}),r}redeemDividendXTokenPayload(e,n){let{xcetus_dividends:i,xcetus:r}=this.sdk.sdkOptions,{xcetus_manager_id:s,lock_manager_id:o}=(0,l.getPackagerConfigs)(r),{dividend_manager_id:d}=(0,l.getPackagerConfigs)(i);return n=n===void 0?new j.Transaction:n,n.moveCall({target:`${i.published_at}::${J}::redeem_xtoken`,typeArguments:[],arguments:[n.object(o),n.object(s),n.object(d),n.object(e),n.object(l.CLOCK_ADDRESS)]}),n}buildCetusCoinType(){return`${this.sdk.sdkOptions.cetus_faucet.package_id}::cetus::CETUS`}buildXTokenCoinType(e=this._sdk.sdkOptions.xcetus.package_id,n="xcetus",i="XCETUS"){return`${e}::${n}::${i}`}cancelRedeemPayload(e){let{xcetus:n}=this.sdk.sdkOptions,i=new j.Transaction;return i.moveCall({target:`${n.published_at}::${z}::cancel_redeem_lock`,typeArguments:[],arguments:[i.object((0,l.getPackagerConfigs)(n).lock_manager_id),i.object((0,l.getPackagerConfigs)(n).xcetus_manager_id),i.object(e.venft_id),i.object(e.lock_id),i.object(l.CLOCK_ADDRESS)]}),i}async getInitConfigs(){let{package_id:e}=this.sdk.sdkOptions.xcetus,n=`${e}_getInitFactoryEvent`,i=this.getCache(n);if(i!==void 0)return i;let r=(await this._sdk.FullClient.queryEventsByPage({MoveEventType:`${e}::xcetus::InitEvent`}))?.data,s={xcetus_manager_id:"",lock_manager_id:"",lock_handle_id:""};r.length>0&&r.forEach(d=>{let c=d.parsedJson;c&&(s.xcetus_manager_id=c.xcetus_manager)});let o=(await this._sdk.FullClient.queryEventsByPage({MoveEventType:`${e}::locking::InitializeEvent`}))?.data;o.length>0&&o.forEach(d=>{let c=d.parsedJson;c&&(s.lock_manager_id=c.lock_manager)});try{if(s.lock_manager_id.length>0){let d=await this.getLockUpManager(s.lock_manager_id);d&&d?.lock_infos.lock_handle_id&&(s.lock_handle_id=d?.lock_infos.lock_handle_id)}return this.updateCache(n,s,l.CACHE_TIME_24H),s}catch(d){return D("FetchError",d,{[l.DETAILS_KEYS.METHOD_NAME]:"getInitConfigs"})}}async getLockUpManager(e=(0,l.getPackagerConfigs)(this.sdk.sdkOptions.xcetus).lock_manager_id,n=!1){let i=`${e}_getLockUpManager`,r=this.getCache(i,n);if(r!==void 0)return r;try{let s=await this.sdk.FullClient.getObject({id:e,options:{showContent:!0}}),o=R.buildLockUpManager((0,l.getObjectFields)(s));return this.updateCache(i,o,l.CACHE_TIME_24H),o}catch(s){return D("InvalidLockManagerId",s,{[l.DETAILS_KEYS.METHOD_NAME]:"getLockUpManager",[l.DETAILS_KEYS.REQUEST_PARAMS]:{lock_manager_id:e}})}}async getDividendConfigs(){let{package_id:e}=this.sdk.sdkOptions.xcetus_dividends,{dividend_manager_id:n,venft_dividends_id:i}=(0,l.getPackagerConfigs)(this._sdk.sdkOptions.xcetus_dividends),r=`${e}_getDividendManagerEvent`,s=this.getCache(r);if(s!==void 0)return s;try{let o=(await this._sdk.FullClient.queryEventsByPage({MoveEventType:`${e}::dividend::InitEvent`}))?.data,d=await this._sdk.FullClient.getDynamicFieldObject({parentId:n,name:{type:"0x1::string::String",value:"VeNFTDividends"}}),c={dividend_manager_id:"",dividend_admin_id:"",dividend_settle_id:"",venft_dividends_id:"",venft_dividends_id_v2:""};o.length>0&&o.forEach(u=>{let f=u.parsedJson;f&&(c.dividend_manager_id=f.manager_id,c.dividend_admin_id=f.admin_id,c.dividend_settle_id=f.settle_id,this.updateCache(r,c,l.CACHE_TIME_24H))}),d&&d.data&&d.data.content&&(c.venft_dividends_id=d.data.content?.fields?.value,this.updateCache(r,c,l.CACHE_TIME_24H));let a=await this._sdk.FullClient.getObject({id:i,options:{showContent:!0}});return c.venft_dividends_id_v2=a.data.content.fields.venft_dividends.fields.id.id,c}catch(o){return D("FetchError",o,{[l.DETAILS_KEYS.METHOD_NAME]:"getDividendConfigs"})}}async getDividendManager(e=!1){let{dividend_manager_id:n}=(0,l.getPackagerConfigs)(this._sdk.sdkOptions.xcetus_dividends),i=`${n}_getDividendManager`,r=this.getCache(i,e);if(r!==void 0)return r;try{let s=await this._sdk.FullClient.getObject({id:n,options:{showContent:!0}}),o=(0,l.getObjectFields)(s),d=R.buildDividendManager(o);return this.updateCache(i,d,l.CACHE_TIME_24H),d}catch(s){return D("FetchError",s,{[l.DETAILS_KEYS.METHOD_NAME]:"getDividendManager"})}}async getXcetusManager(e=!0){let{xcetus_manager_id:n}=(0,l.getPackagerConfigs)(this._sdk.sdkOptions.xcetus),i=`${n}_getXcetusManager`,r=this.getCache(i,e);if(r)return r;try{let s=await this._sdk.FullClient.getObject({id:n,options:{showContent:!0}}),o=(0,l.getObjectFields)(s),d={id:o.id.id,index:Number(o.index),has_venft:{handle:o.has_venft.fields.id.id,size:o.has_venft.fields.size},nfts:{handle:o.nfts.fields.id.id,size:o.nfts.fields.size},total_locked:o.total_locked,treasury:o.treasury.fields.total_supply.fields.value};return this.updateCache(i,d),d}catch(s){return D("FetchError",s,{[l.DETAILS_KEYS.METHOD_NAME]:"getXcetusManager"})}}async fetchDividendInfo(e){let{xcetus_dividends:n}=this._sdk.sdkOptions,{dividend_manager_id:i,venft_dividends_id:r}=(0,l.getPackagerConfigs)(n),s=new j.Transaction;s.moveCall({target:`${n.published_at}::dividend::fetch_dividend_info_v2`,typeArguments:[],arguments:[s.object(i),s.object(r),s.object(e)]});try{let o=await this._sdk.FullClient.devInspectTransactionBlock({transactionBlock:s,sender:this._sdk.getSenderAddress()}),{contents:d}=o.events[0].parsedJson.info,c={id:"",venft_id:e,rewards:[]};return d.forEach(a=>{let u=[],f=a.key,{contents:p}=a.value;p.forEach(g=>{(0,l.d)(g.value).gt(0)&&u.push({coin_type:(0,l.extractStructTagFromType)(g.key.name).source_address,amount:g.value})}),u.length>0&&c.rewards.push({period:Number(f),rewards:u,version:Number(f)>66?"v2":"v1"})}),c}catch(o){D("InvalidVeNftId",o,{[l.DETAILS_KEYS.METHOD_NAME]:"fetchDividendInfo",[l.DETAILS_KEYS.REQUEST_PARAMS]:{venft_id:e}})}}async getVeNFTDividendInfo(e){try{return await this.fetchDividendInfo(e)}catch{try{return await this.getVeNFTDividendInfoV2(e)}catch(i){return console.log("getVeNFTDividendInfo",i),D("InvalidVeNftId",i,{[l.DETAILS_KEYS.METHOD_NAME]:"getVeNFTDividendInfo",[l.DETAILS_KEYS.REQUEST_PARAMS]:{venft_id:e}})}}}async getVeNFTDividendInfoV2(e){let{xcetus_dividends:n}=this._sdk.sdkOptions,{venft_dividends_id_v2:i}=(0,l.getPackagerConfigs)(n),r={id:"",venft_id:e,rewards:[]},s=[];try{let o=await this._sdk.FullClient.getDynamicFieldObject({parentId:i,name:{type:"0x2::object::ID",value:e}}),d=(0,l.getObjectFields)(o).value.fields.value.fields.dividends.fields.id.id,c=null,a=50,u=[];for(;;){let p=await this._sdk.FullClient.getDynamicFields({parentId:d,cursor:c,limit:a});if(p.data.forEach(g=>{u.push(g.objectId)}),c=p.nextCursor,c===null||p.data.length<a)break}(await this._sdk.FullClient.batchGetObjects(u,{showType:!0,showContent:!0})).forEach(p=>{s.push({period:Number(p.data.content.fields.name),version:"v2",rewards:p.data.content.fields.value.fields.contents.map(g=>({coin_type:(0,l.extractStructTagFromType)(g.fields.key.fields.name).source_address,amount:g.fields.value}))})})}catch(o){return console.log("getVeNFTDividendInfoV2",o),D("InvalidVeNftId",o,{[l.DETAILS_KEYS.METHOD_NAME]:"getVeNFTDividendInfoV2",[l.DETAILS_KEYS.REQUEST_PARAMS]:{venft_id:e}})}return{...r,rewards:[...s]}}async getVeNFTDividendInfoV1(e){let{xcetus_dividends:n}=this._sdk.sdkOptions,{venft_dividends_id:i}=(0,l.getPackagerConfigs)(n),r={id:"",venft_id:e,rewards:[]};try{let s=await this._sdk.FullClient.getDynamicFieldObject({parentId:i,name:{type:"0x2::object::ID",value:e}}),o=(0,l.getObjectFields)(s);r=R.buildVeNFTDividendInfo(o)}catch(s){return console.log("getVeNFTDividendInfoV1 ~ error:",s),D("InvalidVeNftId",s,{[l.DETAILS_KEYS.METHOD_NAME]:"getVeNFTDividendInfoV1",[l.DETAILS_KEYS.REQUEST_PARAMS]:{venft_id:e}})}return r}redeemNum(e,n){if(BigInt(e)===BigInt(0))return{amount_out:"0",percent:"0"};let i=(0,l.d)(1e11).mul((0,l.d)(A.max_lock_day).sub((0,l.d)(n))).mul((0,l.d)(A.max_percent_numerator).sub((0,l.d)(A.min_percent_numerator))).div((0,l.d)(A.max_lock_day).sub((0,l.d)(A.min_lock_day))),r=(0,l.d)(1e11).mul((0,l.d)(A.max_percent_numerator)).sub(i).div((0,l.d)(1e3)).div(1e11);return{amount_out:(0,l.d)(r).mul((0,l.d)(e)).round().toString(),percent:r.toString()}}reverseRedeemNum(e,n){if(BigInt(e)===BigInt(0))return{amount_out:"0",percent:"0"};let i=(0,l.d)(1e11).mul((0,l.d)(A.max_lock_day).sub((0,l.d)(n))).mul((0,l.d)(A.max_percent_numerator).sub((0,l.d)(A.min_percent_numerator))).div((0,l.d)(A.max_lock_day).sub((0,l.d)(A.min_lock_day))),r=(0,l.d)(1e11).mul((0,l.d)(A.max_percent_numerator)).sub(i).div((0,l.d)(1e3)).div(1e11);return{amount_out:(0,l.d)(e).div(r).toFixed(0,ze.ROUND_UP),percent:r.toString()}}async getXCetusAmount(e){let{lock_handle_id:n}=(0,l.getPackagerConfigs)(this._sdk.sdkOptions.xcetus),i=`${e}_getXCetusAmount`,r=this.getCache(i);if(r!==void 0)return r;try{let s=await this.sdk.FullClient.getDynamicFieldObject({parentId:n,name:{type:"0x2::object::ID",value:e}}),o=(0,l.getObjectFields)(s);if(o){let{xcetus_amount:d}=o.value.fields.value.fields;return this.updateCache(i,d,l.CACHE_TIME_24H),d}}catch(s){console.log("getXCetusAmount",s),D("InvalidLockId",s,{[l.DETAILS_KEYS.METHOD_NAME]:"getXCetusAmount",[l.DETAILS_KEYS.REQUEST_PARAMS]:{lock_id:e}})}return"0"}async getVeNftAmount(e,n){try{let i=await this.sdk.FullClient.getDynamicFieldObject({parentId:e,name:{type:"0x2::object::ID",value:n}}),r=(0,l.getObjectFields)(i);if(r){let{lock_amount:s,xcetus_amount:o}=r.value.fields.value.fields;return{lock_amount:s,xcetus_amount:o}}}catch(i){console.log("getVeNftAmount",i),D("FetchError",i,{[l.DETAILS_KEYS.METHOD_NAME]:"getVeNftAmount",[l.DETAILS_KEYS.REQUEST_PARAMS]:{nft_handle_id:e,venft_id:n}})}return{lock_amount:"0",xcetus_amount:"0"}}async getPhaseDividendInfo(e,n=!1){try{let i=await this.getDividendManager();if(i){let r=i.dividends.id,s=`${r}_${e}_getPhaseDividendInfo`,o=this._sdk.getCache(s,n);if(o)return o;let d=await this._sdk.FullClient.getDynamicFieldObject({parentId:r,name:{type:"u64",value:e}}),c=(0,l.getObjectFields)(d),a=c.value.fields.value.fields,u=a.redeemed_num.fields.contents.map(w=>({name:w.fields.key.fields.name,value:w.fields.value})),f=a.bonus_types.map(w=>w.fields.name),p=a.bonus.fields.contents.map(w=>({name:w.fields.key.fields.name,value:w.fields.value})),g={id:(0,l.getObjectId)(d),phase:c.name,settled_num:a.settled_num,register_time:a.register_time,redeemed_num:u,is_settled:a.is_settled,bonus_types:f,bonus:p,phase_end_time:""};return this.updateCache(s,g),g}}catch(i){console.log("getPhaseDividendInfo",i),D("InvalidPhase",i,{[l.DETAILS_KEYS.METHOD_NAME]:"getPhaseDividendInfo",[l.DETAILS_KEYS.REQUEST_PARAMS]:{phase:e}})}}updateCache(e,n,i=l.CACHE_TIME_5MIN){let r=this._cache[e];r?(r.overdue_time=(0,l.getFutureTime)(i),r.value=n):r=new l.CachedContent(n,(0,l.getFutureTime)(i)),this._cache[e]=r}getCache(e,n=!1){let i=this._cache[e];if(!n&&i?.isValid())return i.value;delete this._cache[e]}};var re=class t extends Ge.SdkWrapper{constructor(e){super(e),this._xcetusModule=new ie(this)}get XCetusModule(){return this._xcetusModule}static createSDK(e){let{env:n="mainnet",full_rpc_url:i}=e;return n==="mainnet"?t.createCustomSDK({...Se,...e}):t.createCustomSDK({...Ae,...e})}static createCustomSDK(e){return new t(e)}};var Gt=re;0&&(module.exports={CetusXcetusSDK,DividendsRouterModule,EXCHANGE_RATE_MULTIPLIER,ONE_DAY_SECONDS,REDEEM_NUM_MULTIPLIER,XCetusModule,XCetusUtil,XcetusRouterModule,defaultLockUpConfig});
|
|
2
|
+
/*! Bundled license information:
|
|
3
|
+
|
|
4
|
+
decimal.js/decimal.mjs:
|
|
5
|
+
(*!
|
|
6
|
+
* decimal.js v10.5.0
|
|
7
|
+
* An arbitrary-precision Decimal type for JavaScript.
|
|
8
|
+
* https://github.com/MikeMcl/decimal.js
|
|
9
|
+
* Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
|
|
10
|
+
* MIT Licence
|
|
11
|
+
*)
|
|
12
|
+
*/
|
|
13
|
+
//# sourceMappingURL=index.js.map
|