@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/README.md
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
# @cetusprotocol/xcetus-sdk
|
|
2
|
+
|
|
3
|
+
## xCETUS Overview
|
|
4
|
+
|
|
5
|
+
**Platform equity tokens** are non-circulating currencies and cannot be transferred by default. These tokens are recorded in the user's **veNFT** account as points.
|
|
6
|
+
|
|
7
|
+
### How to Obtain xCETUS:
|
|
8
|
+
|
|
9
|
+
1. **Convert 1 CETUS to 1 xCETUS Mint**
|
|
10
|
+
2. **LP NFT lock-up mining rewards** released.
|
|
11
|
+
|
|
12
|
+
### Transfer of xCETUS:
|
|
13
|
+
|
|
14
|
+
- xCETUS can be transferred under certain conditions.
|
|
15
|
+
- To prevent special circumstances, only the platform has the permission to transfer xCETUS.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## veNFT Overview
|
|
20
|
+
|
|
21
|
+
**veNFT** stores xCETUS in a **non-transferable** form under the user account.
|
|
22
|
+
|
|
23
|
+
### Benefits of Holding xCETUS:
|
|
24
|
+
|
|
25
|
+
- Holding xCETUS allows participation in **Cetus reward dividends**.
|
|
26
|
+
- Dividends are distributed based on the proportion of xCETUS in the wallet's veNFT account relative to the total xCETUS in the market.
|
|
27
|
+
|
|
28
|
+
## Getting Started
|
|
29
|
+
|
|
30
|
+
## How to Use the Burn SDK ?
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
To start using the `xcetus SDK`, you first need to install it in your TypeScript project:
|
|
35
|
+
|
|
36
|
+
Github Link: https://github.com/CetusProtocol/xcetus-sdk
|
|
37
|
+
|
|
38
|
+
NPM Link: [@cetusprotocol/xcetus-sdk](https://www.npmjs.com/package/@cetusprotocol/xcetus-sdk)
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install @cetusprotocol/xcetus-sdk
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Setup
|
|
45
|
+
|
|
46
|
+
Import the SDK into the TypeScript file where you intend to use it:
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import { CetusXcetusSDK } from '@cetusprotocol/xcetus-sdk'
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Initializing the SDK
|
|
53
|
+
|
|
54
|
+
Initialize the SDK with the required configuration parameters. This typically includes setting up the network and API keys, if needed.
|
|
55
|
+
|
|
56
|
+
If you would like to use the mainnet network and the official Sui rpc url, you can do so as follows:
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
const sdk = CetusXcetusSDK.createSDK()
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
If you wish to set your own full node URL or network (You have the option to select either 'mainnet' or 'testnet' for the network), you can do so as follows:
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
const env = 'mainnet'
|
|
66
|
+
const full_rpc_url = 'YOUR_FULL_NODE_URL'
|
|
67
|
+
const wallet = 'YOUR_WALLET_ADDRESS'
|
|
68
|
+
|
|
69
|
+
const sdk = CetusXcetusSDK.createSDK({ env })
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
If you wish to set your own full node URL or SuiClient, you can do so as follows:
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
const sdk = CetusXcetusSDK.createSDK({ env, sui_client })
|
|
76
|
+
// or
|
|
77
|
+
const sdk = CetusXcetusSDK.createSDK({ env, full_rpc_url })
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Usage
|
|
81
|
+
|
|
82
|
+
After linking your wallet, if you need use your wallet address to do something, you should set it by `sdk.setSenderAddress`.
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
const wallet = 'YOUR_WALLET_ADDRESS'
|
|
86
|
+
sdk.setSenderAddress(wallet)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 1. getOwnerVeNFT
|
|
90
|
+
|
|
91
|
+
Gets the VeNFT object for the specified account address.
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
const owner_venft = await sdk.XCetusModule.getOwnerVeNFT(wallet)
|
|
95
|
+
// ownerVeNFT
|
|
96
|
+
{
|
|
97
|
+
creator: 'Cetus',
|
|
98
|
+
description: "A non-transferrable NFT storing Cetus Escrowed Token xCETUS that represents a user's governance power on Cetus Protocol.",
|
|
99
|
+
image_url: 'https://x77unmxbojk6nincdlzd57hhk5qgp5223rrrxrsplqqcs23vu5ja.arweave.net/v_9GsuFyVeahohryPvznV2Bn91rcYxvGT1wgKWt1p1I',
|
|
100
|
+
link: 'https://app.cetus.zone',
|
|
101
|
+
name: 'Cetus veNFT #14562',
|
|
102
|
+
project_url: 'https://www.cetus.zone',
|
|
103
|
+
id: '0x12adbc7e726cf2a5a9d4c4f0bdd08b6a49c876be99b2e650778a68d3891584bc',
|
|
104
|
+
index: '14562',
|
|
105
|
+
type: '0x9e69acc50ca03bc943c4f7c5304c2a6002d507b51c11913b247159c60422c606::xcetus::VeNFT',
|
|
106
|
+
xcetus_balance: '1000000000'
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### 2. getOwnerRedeemLockList.
|
|
112
|
+
|
|
113
|
+
Gets the list of LockCetus objects owned by the specified account address.
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
const redeem_lock_list = await sdk.XCetusModule.getOwnerRedeemLockList(wallet)
|
|
117
|
+
|
|
118
|
+
redeem_lock_list: [
|
|
119
|
+
{
|
|
120
|
+
id: '0x005ba9202a5d9e41c73155a1b4e47...',
|
|
121
|
+
type: '0x9e69acc50ca03bc943c4f7c5304c2a6002d507b51c11913b247159c60422c606::lock_coin::LockedCoin<0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b::cetus::CETUS>',
|
|
122
|
+
locked_start_time: 1730442744,
|
|
123
|
+
locked_until_time: 1745994744,
|
|
124
|
+
cetus_amount: '500000000',
|
|
125
|
+
xcetus_amount: '500000000',
|
|
126
|
+
lock_day: 180,
|
|
127
|
+
},
|
|
128
|
+
]
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### 3. Convert Cetus to Xcetus
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
const venft_id = 'YOUR_VENFT_ID'
|
|
135
|
+
const payload = await sdk.XCetusModule.convertPayload({
|
|
136
|
+
amount: '10000000000',
|
|
137
|
+
venft_id,
|
|
138
|
+
})
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### 4. redeemLock
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
const lock_day = 15
|
|
145
|
+
const amount_input = 20000
|
|
146
|
+
const amount = await sdk.XCetusModule.redeemNum(amount_input, lock_day)
|
|
147
|
+
sdk.XCetusModule.redeemLockPayload({
|
|
148
|
+
venft_id,
|
|
149
|
+
amount,
|
|
150
|
+
lock_day,
|
|
151
|
+
})
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### 5. redeem
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
const lock_id = '0x005ba9202a5d9e41c73155a1b4e47...'
|
|
158
|
+
const lock_cetus = await sdk.XCetusModule.getLockCetus(lock_id)
|
|
159
|
+
|
|
160
|
+
if (lock_cetus && !XCetusUtil.isLocked(lock_cetus)) {
|
|
161
|
+
const payload = sdk.XCetusModule.redeemPayload({
|
|
162
|
+
venft_id,
|
|
163
|
+
lock_id,
|
|
164
|
+
})
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### 6.redeemDividendV3Payload
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
const venft_dividend_info = await sdk.XCetusModule.getVeNFTDividendInfo(venft_id)
|
|
172
|
+
|
|
173
|
+
if (venft_dividend_info) {
|
|
174
|
+
const payload = await sdk.XCetusModule.redeemDividendV3Payload(venft_id, venft_dividend_info.rewards)
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### 7. cancelRedeemPayload
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
const lock_id = '0x005ba9202a5d9e41c73155a1...'
|
|
182
|
+
const lock_cetus = await sdk.XCetusModule.getLockCetus(lock_id)
|
|
183
|
+
|
|
184
|
+
if (lock_cetus && XCetusUtil.isLocked(lock_cetus)) {
|
|
185
|
+
const payload = sdk.XCetusModule.cancelRedeemPayload({
|
|
186
|
+
venft_id,
|
|
187
|
+
lock_id,
|
|
188
|
+
})
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### 7. getVeNFTDividendInfo
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
const dividend_manager = await sdk.XCetusModule.getDividendManager()
|
|
196
|
+
const venft_dividend_info = await sdk.XCetusModule.getVeNFTDividendInfo(dividend_manager.venft_dividends.id)
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### 8. redeemNum
|
|
200
|
+
|
|
201
|
+
```typescript
|
|
202
|
+
const lock_day = 15
|
|
203
|
+
const amount_input = 20000
|
|
204
|
+
const amount = await sdk.XCetusModule.redeemNum(amount_input, lock_day)
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### 9. reverseRedeemNum
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
const lock_day = 15
|
|
211
|
+
const amount_input = 20000
|
|
212
|
+
const amount = await sdk.XCetusModule.reverseRedeemNum(amount_input, lock_day)
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### 10. getXCetusAmount
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
const lock_id = '0x005ba9202a5d9e41c73155a1b...'
|
|
219
|
+
const amount = await sdk.XCetusModule.getXCetusAmount(lock_id)
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### 11. getPhaseDividendInfo
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
const phase_dividend_info = await sdk.XCetusModule.getPhaseDividendInfo('10')
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### 12. getXcetusManager & getVeNftAmount
|
|
229
|
+
|
|
230
|
+
```typescript
|
|
231
|
+
const owner_venft = await sdk.XCetusModule.getOwnerVeNFT(wallet)
|
|
232
|
+
|
|
233
|
+
if (owner_venft) {
|
|
234
|
+
const xcetus_manager = await sdk.XCetusModule.getXcetusManager()
|
|
235
|
+
|
|
236
|
+
const venft_amount = await sdk.XCetusModule.getVeNftAmount(xcetus_manager.nfts.handle, owner_venft.id)
|
|
237
|
+
|
|
238
|
+
const rate = d(owner_venft.xcetus_balance).div(xcetus_manager.treasury)
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
# Contract Error Codes
|
|
243
|
+
|
|
244
|
+
the Cetus smart contract may return the following error codes:
|
|
245
|
+
|
|
246
|
+
| Module | Error Code | Description | Contract Methods |
|
|
247
|
+
| --------- | ---------- | ---------------------------------------------------------------------------- | ------------------------------------------------------------------- |
|
|
248
|
+
| lock_coin | 0 | The lock time must be greater than the current time | lock_coin |
|
|
249
|
+
| lock_coin | 1 | The lock period has not ended | unlock_coin |
|
|
250
|
+
| locking | 1 | Insufficient XCetus balance | redeem_lock |
|
|
251
|
+
| locking | 2 | Locking period for XCetus is out of allowed range | redeem_lock |
|
|
252
|
+
| locking | 3 | Invalid redeemable XCetus amount | redeem_lock |
|
|
253
|
+
| locking | 4 | veNFT does not match the associated LockedCoin | cancel_redeem_lock, redeem |
|
|
254
|
+
| locking | 5 | LockCoin has expired; locking has ended | cancel_redeem_lock |
|
|
255
|
+
| locking | 7 | Unauthorized treasury manager | redeem_treasury |
|
|
256
|
+
| locking | 8 | The version of the contract has been deprecated | The vast majority of methods |
|
|
257
|
+
| xcetus | 1 | XCetus balance is not zero | burn_venft |
|
|
258
|
+
| xcetus | 5 | The address already has a VeNFT | burn_lp |
|
|
259
|
+
| xcetus | 6 | XCetus in unlocking process is not zero | request_transfer_venft_by_admin, approve_transfer_venft, mint_venft |
|
|
260
|
+
| xcetus | 7 | VeNFT does not exist | approve_transfer_venft |
|
|
261
|
+
| xcetus | 8 | Transfer request already exists | request_transfer_venft_by_admin |
|
|
262
|
+
| xcetus | 9 | Transfer request does not exist | approve_transfer_venft, cancel_transfer_venft_request_by_admin |
|
|
263
|
+
| xcetus | 10 | TransferVeNFTRequest does not match the VeNFT | approve_transfer_venft |
|
|
264
|
+
| xcetus | 11 | The destination address is inconsistent with the one in TransferVeNFTRequest | approve_transfer_venft |
|
|
265
|
+
|
|
266
|
+
# More About Cetus
|
|
267
|
+
|
|
268
|
+
Use the following links to learn more about Cetus:
|
|
269
|
+
|
|
270
|
+
Learn more about working with Cetus in the [Cetus Documentation](https://cetus-1.gitbook.io/cetus-docs).
|
|
271
|
+
|
|
272
|
+
Join the Cetus community on [Cetus Discord](https://discord.com/channels/1009749448022315008/1009751382783447072).
|
|
273
|
+
|
|
274
|
+
## License
|
|
275
|
+
|
|
276
|
+
MIT
|
package/dist/index.d.mts
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 };
|