@cetusprotocol/xcetus-sdk 1.0.0 → 1.0.1
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/package.json +1 -1
- package/.turbo/turbo-build.log +0 -10368
- package/src/config/index.ts +0 -2
- package/src/config/mainnet.ts +0 -37
- package/src/config/testnet.ts +0 -37
- package/src/errors/errors.ts +0 -29
- package/src/index.ts +0 -7
- package/src/modules/index.ts +0 -1
- package/src/modules/xcetusModule.ts +0 -1067
- package/src/sdk.ts +0 -59
- package/src/types/index.ts +0 -2
- package/src/types/xcetus_type.ts +0 -166
- package/src/utils/index.ts +0 -1
- package/src/utils/xcetus.ts +0 -175
- package/tests/tsconfig.json +0 -26
- package/tests/xcetus.test.ts +0 -197
- package/tsconfig.json +0 -5
- package/tsup.config.ts +0 -9
package/src/sdk.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { BaseSdkOptions, Package } from '@cetusprotocol/common-sdk'
|
|
2
|
-
import { SdkWrapper } from '@cetusprotocol/common-sdk'
|
|
3
|
-
import { xcetus_mainnet, xcetus_testnet } from './config'
|
|
4
|
-
import { XCetusModule } from './modules/xcetusModule'
|
|
5
|
-
import type { DividendConfig, XcetusConfig } from './types/xcetus_type'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Represents options and configurations for an SDK.
|
|
9
|
-
*/
|
|
10
|
-
export interface SdkOptions extends BaseSdkOptions {
|
|
11
|
-
xcetus: Package<XcetusConfig>
|
|
12
|
-
xcetus_dividends: Package<DividendConfig>
|
|
13
|
-
cetus_faucet: Package
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* The entry class of CetusXcetusSDK, which is almost responsible for all interactions with Xcetus.
|
|
18
|
-
*/
|
|
19
|
-
export class CetusXcetusSDK extends SdkWrapper<SdkOptions> {
|
|
20
|
-
/**
|
|
21
|
-
* Provide interact with Xcetus interface.
|
|
22
|
-
*/
|
|
23
|
-
protected _xcetusModule: XCetusModule
|
|
24
|
-
|
|
25
|
-
constructor(options: SdkOptions) {
|
|
26
|
-
super(options)
|
|
27
|
-
|
|
28
|
-
this._xcetusModule = new XCetusModule(this)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Getter for the Xcetus property.
|
|
33
|
-
* @returns {XCetusModule} The Xcetus property value.
|
|
34
|
-
*/
|
|
35
|
-
get XCetusModule() {
|
|
36
|
-
return this._xcetusModule
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Static factory method to initialize the SDK
|
|
41
|
-
* @param options SDK initialization options
|
|
42
|
-
* @returns An instance of CetusXcetusSDK
|
|
43
|
-
*/
|
|
44
|
-
static createSDK(options: BaseSdkOptions): CetusXcetusSDK {
|
|
45
|
-
const { env = 'mainnet', full_rpc_url } = options
|
|
46
|
-
return env === 'mainnet'
|
|
47
|
-
? CetusXcetusSDK.createCustomSDK({ ...xcetus_mainnet, ...options })
|
|
48
|
-
: CetusXcetusSDK.createCustomSDK({ ...xcetus_testnet, ...options })
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Create a custom SDK instance with the given options
|
|
53
|
-
* @param options The options for the SDK
|
|
54
|
-
* @returns An instance of CetusBurnSDK
|
|
55
|
-
*/
|
|
56
|
-
static createCustomSDK<T extends BaseSdkOptions>(options: T & SdkOptions): CetusXcetusSDK {
|
|
57
|
-
return new CetusXcetusSDK(options)
|
|
58
|
-
}
|
|
59
|
-
}
|
package/src/types/index.ts
DELETED
package/src/types/xcetus_type.ts
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import type { NFT, SuiAddressType, SuiObjectIdType } from '@cetusprotocol/common-sdk'
|
|
2
|
-
|
|
3
|
-
export const XcetusRouterModule = 'router'
|
|
4
|
-
export const DividendsRouterModule = 'router'
|
|
5
|
-
|
|
6
|
-
export const ONE_DAY_SECONDS = 24 * 3600
|
|
7
|
-
export const EXCHANGE_RATE_MULTIPLIER = 1000
|
|
8
|
-
export const REDEEM_NUM_MULTIPLIER = 100000000000
|
|
9
|
-
|
|
10
|
-
export type XcetusConfig = {
|
|
11
|
-
xcetus_manager_id: SuiObjectIdType
|
|
12
|
-
lock_manager_id: SuiObjectIdType
|
|
13
|
-
lock_handle_id: SuiObjectIdType
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export type DividendConfig = {
|
|
17
|
-
dividend_admin_id?: SuiObjectIdType
|
|
18
|
-
dividend_settle_id?: SuiObjectIdType
|
|
19
|
-
dividend_manager_id: SuiObjectIdType
|
|
20
|
-
venft_dividends_id: SuiAddressType
|
|
21
|
-
venft_dividends_id_v2: SuiAddressType
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type LockUpConfig = {
|
|
25
|
-
min_lock_day: number
|
|
26
|
-
max_lock_day: number
|
|
27
|
-
max_percent_numerator: number
|
|
28
|
-
min_percent_numerator: number
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const defaultLockUpConfig: LockUpConfig = {
|
|
32
|
-
min_lock_day: 15,
|
|
33
|
-
max_lock_day: 180,
|
|
34
|
-
max_percent_numerator: 1000,
|
|
35
|
-
min_percent_numerator: 500,
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export type LockUpManager = {
|
|
39
|
-
id: string
|
|
40
|
-
balance: string
|
|
41
|
-
treasury_manager: string
|
|
42
|
-
extra_treasury: string
|
|
43
|
-
lock_infos: {
|
|
44
|
-
lock_handle_id: string
|
|
45
|
-
size: number
|
|
46
|
-
}
|
|
47
|
-
type_name: string
|
|
48
|
-
min_lock_day: number
|
|
49
|
-
max_lock_day: number
|
|
50
|
-
|
|
51
|
-
package_version: number
|
|
52
|
-
max_percent_numerator: number
|
|
53
|
-
min_percent_numerator: number
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export type VeNFT = {
|
|
57
|
-
id: SuiObjectIdType
|
|
58
|
-
type: string
|
|
59
|
-
index: string
|
|
60
|
-
xcetus_balance: string
|
|
61
|
-
} & NFT
|
|
62
|
-
|
|
63
|
-
export type LockCetus = {
|
|
64
|
-
id: SuiObjectIdType
|
|
65
|
-
type: SuiAddressType
|
|
66
|
-
locked_start_time: number
|
|
67
|
-
locked_until_time: number
|
|
68
|
-
lock_day: number
|
|
69
|
-
cetus_amount: string
|
|
70
|
-
xcetus_amount: string
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export type ConvertParams = {
|
|
74
|
-
amount: string
|
|
75
|
-
venft_id?: SuiObjectIdType
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export type RedeemLockParams = {
|
|
79
|
-
amount: string
|
|
80
|
-
venft_id: SuiObjectIdType
|
|
81
|
-
lock_day: number
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export type RedeemXcetusParams = {
|
|
85
|
-
venft_id: SuiObjectIdType
|
|
86
|
-
lock_id: SuiObjectIdType
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export type CancelRedeemParams = {
|
|
90
|
-
venft_id: SuiObjectIdType
|
|
91
|
-
lock_id: SuiObjectIdType
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export type XcetusManager = {
|
|
95
|
-
id: SuiObjectIdType
|
|
96
|
-
index: number
|
|
97
|
-
has_venft: {
|
|
98
|
-
handle: SuiObjectIdType
|
|
99
|
-
size: number
|
|
100
|
-
}
|
|
101
|
-
nfts: {
|
|
102
|
-
handle: SuiObjectIdType
|
|
103
|
-
size: number
|
|
104
|
-
}
|
|
105
|
-
total_locked: string
|
|
106
|
-
treasury: string
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export type VeNFTDividendInfo = {
|
|
110
|
-
id: SuiObjectIdType
|
|
111
|
-
venft_id: SuiObjectIdType
|
|
112
|
-
rewards: DividendReward[]
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export type DividendReward = {
|
|
116
|
-
period: number
|
|
117
|
-
rewards: { coin_type: SuiAddressType; amount: string }[]
|
|
118
|
-
version: string
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export type PhaseDividendInfo = {
|
|
122
|
-
id: string
|
|
123
|
-
phase: string
|
|
124
|
-
settled_num: string
|
|
125
|
-
register_time: string
|
|
126
|
-
redeemed_num: {
|
|
127
|
-
name: string
|
|
128
|
-
value: string
|
|
129
|
-
}[]
|
|
130
|
-
is_settled: boolean
|
|
131
|
-
bonus_types: string[]
|
|
132
|
-
bonus: {
|
|
133
|
-
name: string
|
|
134
|
-
value: string
|
|
135
|
-
}[]
|
|
136
|
-
phase_end_time: string
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export type DividendManager = {
|
|
140
|
-
id: SuiObjectIdType
|
|
141
|
-
/// Dividend info of every phase.
|
|
142
|
-
dividends: {
|
|
143
|
-
id: SuiObjectIdType
|
|
144
|
-
size: number
|
|
145
|
-
}
|
|
146
|
-
/// Dividend info of every venft.
|
|
147
|
-
venft_dividends: {
|
|
148
|
-
id: SuiObjectIdType
|
|
149
|
-
size: number
|
|
150
|
-
}
|
|
151
|
-
/// Current bonus type supported.
|
|
152
|
-
bonus_types: SuiAddressType[]
|
|
153
|
-
/// init time
|
|
154
|
-
start_time: number
|
|
155
|
-
/// interval day between each settlement phase
|
|
156
|
-
interval_day: number
|
|
157
|
-
/// hold the bonus of different types.
|
|
158
|
-
balances: {
|
|
159
|
-
id: SuiObjectIdType
|
|
160
|
-
size: number
|
|
161
|
-
}
|
|
162
|
-
/// status
|
|
163
|
-
is_open: boolean
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
export type BonusTypesV2 = Record<SuiAddressType, number[]>
|
package/src/utils/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './xcetus'
|
package/src/utils/xcetus.ts
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { d, extractStructTagFromType, normalizeCoinType } from '@cetusprotocol/common-sdk'
|
|
2
|
-
import type {
|
|
3
|
-
BonusTypesV2,
|
|
4
|
-
DividendManager,
|
|
5
|
-
DividendReward,
|
|
6
|
-
LockCetus,
|
|
7
|
-
LockUpManager,
|
|
8
|
-
VeNFT,
|
|
9
|
-
VeNFTDividendInfo,
|
|
10
|
-
} from '../types/xcetus_type'
|
|
11
|
-
import { ONE_DAY_SECONDS } from '../types/xcetus_type'
|
|
12
|
-
|
|
13
|
-
export class XCetusUtil {
|
|
14
|
-
static buildVeNFTDividendInfo(fields: any): VeNFTDividendInfo {
|
|
15
|
-
const veNFTDividendInfo: VeNFTDividendInfo = {
|
|
16
|
-
id: fields.id.id,
|
|
17
|
-
venft_id: fields.name,
|
|
18
|
-
rewards: [],
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
fields.value.fields.value.fields.dividends.fields.contents.forEach((item: any) => {
|
|
22
|
-
const periodRewards: any[] = []
|
|
23
|
-
item.fields.value.fields.contents.forEach((reward: any) => {
|
|
24
|
-
const rewardAmount = reward.fields.value
|
|
25
|
-
if (d(rewardAmount).gt(0)) {
|
|
26
|
-
periodRewards.push({
|
|
27
|
-
coin_type: extractStructTagFromType(reward.fields.key.fields.name).source_address,
|
|
28
|
-
amount: rewardAmount,
|
|
29
|
-
})
|
|
30
|
-
}
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
if (periodRewards.length > 0) {
|
|
34
|
-
veNFTDividendInfo.rewards.push({
|
|
35
|
-
period: Number(item.fields.key),
|
|
36
|
-
rewards: periodRewards,
|
|
37
|
-
version: 'v1',
|
|
38
|
-
})
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
return veNFTDividendInfo
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
static buildDividendManager(fields: any): DividendManager {
|
|
46
|
-
const dividendManager: DividendManager = {
|
|
47
|
-
id: fields.id.id,
|
|
48
|
-
dividends: {
|
|
49
|
-
id: fields.dividends.fields.id.id,
|
|
50
|
-
size: fields.dividends.fields.size,
|
|
51
|
-
},
|
|
52
|
-
venft_dividends: {
|
|
53
|
-
id: fields.venft_dividends.fields.id.id,
|
|
54
|
-
size: fields.venft_dividends.fields.size,
|
|
55
|
-
},
|
|
56
|
-
bonus_types: [],
|
|
57
|
-
start_time: Number(fields.start_time),
|
|
58
|
-
interval_day: Number(fields.interval_day),
|
|
59
|
-
balances: {
|
|
60
|
-
id: fields.balances.fields.id.id,
|
|
61
|
-
size: fields.balances.fields.size,
|
|
62
|
-
},
|
|
63
|
-
is_open: fields.is_open,
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
fields.bonus_types.forEach((item: any) => {
|
|
67
|
-
dividendManager.bonus_types.push(extractStructTagFromType(item.fields.name).source_address)
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
return dividendManager
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
static buildLockUpManager(fields: any): LockUpManager {
|
|
74
|
-
const lockUpManager: LockUpManager = {
|
|
75
|
-
id: fields.id.id,
|
|
76
|
-
balance: fields.balance,
|
|
77
|
-
treasury_manager: fields.treasury_manager,
|
|
78
|
-
extra_treasury: fields.extra_treasury,
|
|
79
|
-
lock_infos: {
|
|
80
|
-
lock_handle_id: fields.lock_infos.fields.id.id,
|
|
81
|
-
size: Number(fields.lock_infos.fields.size),
|
|
82
|
-
},
|
|
83
|
-
type_name: normalizeCoinType(fields.type_name.fields.name),
|
|
84
|
-
min_lock_day: Number(fields.min_lock_day),
|
|
85
|
-
max_lock_day: Number(fields.max_lock_day),
|
|
86
|
-
package_version: Number(fields.package_version),
|
|
87
|
-
max_percent_numerator: Number(fields.max_percent_numerator),
|
|
88
|
-
min_percent_numerator: Number(fields.min_percent_numerator),
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return lockUpManager
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
static buildLockCetus(data: any): LockCetus {
|
|
95
|
-
const fields = data.fields as any
|
|
96
|
-
const lockCetus = {
|
|
97
|
-
id: fields.id.id,
|
|
98
|
-
type: extractStructTagFromType(data.type).source_address,
|
|
99
|
-
locked_start_time: Number(fields.locked_start_time),
|
|
100
|
-
locked_until_time: Number(fields.locked_until_time),
|
|
101
|
-
cetus_amount: fields.balance,
|
|
102
|
-
xcetus_amount: '0',
|
|
103
|
-
lock_day: 0,
|
|
104
|
-
}
|
|
105
|
-
lockCetus.lock_day = (lockCetus.locked_until_time - lockCetus.locked_start_time) / ONE_DAY_SECONDS
|
|
106
|
-
return lockCetus
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
static getAvailableXCetus(venft: VeNFT, locks: LockCetus[]): string {
|
|
110
|
-
let lockAmount = d(0)
|
|
111
|
-
locks.forEach((lock) => {
|
|
112
|
-
lockAmount = lockAmount.add(lock.xcetus_amount)
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
return d(venft.xcetus_balance).sub(lockAmount).toString()
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
static getWaitUnLockCetus(locks: LockCetus[]): LockCetus[] {
|
|
119
|
-
return locks.filter((lock) => {
|
|
120
|
-
return !XCetusUtil.isLocked(lock)
|
|
121
|
-
})
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
static getLockingCetus(locks: LockCetus[]): LockCetus[] {
|
|
125
|
-
return locks.filter((lock) => {
|
|
126
|
-
return XCetusUtil.isLocked(lock)
|
|
127
|
-
})
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
static isLocked(lock: LockCetus): boolean {
|
|
131
|
-
return lock.locked_until_time > Date.parse(new Date().toString()) / 1000
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
static buildDividendRewardTypeList(reward_list?: DividendReward[], reward_list_v2?: DividendReward[]): string[] {
|
|
135
|
-
const uniqueItems = new Set<string>()
|
|
136
|
-
reward_list?.forEach((obj) => {
|
|
137
|
-
obj.rewards.forEach((item) => {
|
|
138
|
-
uniqueItems.add(item.coin_type)
|
|
139
|
-
})
|
|
140
|
-
})
|
|
141
|
-
reward_list_v2?.forEach((obj) => {
|
|
142
|
-
obj.rewards.forEach((item) => {
|
|
143
|
-
uniqueItems.add(item.coin_type)
|
|
144
|
-
})
|
|
145
|
-
})
|
|
146
|
-
return Array.from(uniqueItems)
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
static buildDividendRewardTypeListV2(reward_list?: DividendReward[]): BonusTypesV2 {
|
|
150
|
-
const uniqueItems: BonusTypesV2 = {}
|
|
151
|
-
reward_list?.forEach((obj: DividendReward) => {
|
|
152
|
-
if (obj.version === 'v2') {
|
|
153
|
-
obj.rewards.forEach((item) => {
|
|
154
|
-
if (uniqueItems[item.coin_type]) {
|
|
155
|
-
uniqueItems[item.coin_type].push(obj.period)
|
|
156
|
-
} else {
|
|
157
|
-
uniqueItems[item.coin_type] = []
|
|
158
|
-
uniqueItems[item.coin_type].push(obj.period)
|
|
159
|
-
}
|
|
160
|
-
})
|
|
161
|
-
}
|
|
162
|
-
})
|
|
163
|
-
return uniqueItems
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
static getNextStartTime(dividend_manager: DividendManager): number {
|
|
167
|
-
const currentTime = Date.now() / 1000
|
|
168
|
-
const { start_time, interval_day } = dividend_manager
|
|
169
|
-
|
|
170
|
-
const currentPeriod = Math.ceil((currentTime - start_time) / (interval_day * ONE_DAY_SECONDS))
|
|
171
|
-
const nextStartTime = start_time + currentPeriod * interval_day * ONE_DAY_SECONDS
|
|
172
|
-
|
|
173
|
-
return nextStartTime
|
|
174
|
-
}
|
|
175
|
-
}
|
package/tests/tsconfig.json
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"module": "commonjs",
|
|
5
|
-
"allowJs": false,
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"lib": [
|
|
8
|
-
"DOM",
|
|
9
|
-
"ES6",
|
|
10
|
-
"DOM.Iterable",
|
|
11
|
-
"ScriptHost",
|
|
12
|
-
"ES2016.Array.Include"
|
|
13
|
-
],
|
|
14
|
-
"outDir": "./dist",
|
|
15
|
-
"strict": true,
|
|
16
|
-
"esModuleInterop": true,
|
|
17
|
-
"skipLibCheck": true,
|
|
18
|
-
"forceConsistentCasingInFileNames": true,
|
|
19
|
-
"resolveJsonModule": true,
|
|
20
|
-
"experimentalDecorators": true
|
|
21
|
-
},
|
|
22
|
-
"filesGlob": [
|
|
23
|
-
"src/**/*",
|
|
24
|
-
"tests/**/*"
|
|
25
|
-
]
|
|
26
|
-
}
|
package/tests/xcetus.test.ts
DELETED
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import type { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519'
|
|
2
|
-
import { d, getPackagerConfigs, printTransaction } from '@cetusprotocol/common-sdk'
|
|
3
|
-
import { buildTestAccount } from '@cetusprotocol/test-utils'
|
|
4
|
-
import 'isomorphic-fetch'
|
|
5
|
-
import { CetusXcetusSDK } from '../src/sdk'
|
|
6
|
-
import { XCetusUtil } from '../src/utils/xcetus'
|
|
7
|
-
let send_key_pair: Ed25519Keypair
|
|
8
|
-
const account_id = '0x3992ecfe4eca00d482210cddfceb063608f45f3ca41ce7eedea33f27870eb55a'
|
|
9
|
-
const venft_id = '0x653edd0c372ee7b5fc38e7934caab30b8a45b1680d727f127b05140806034067'
|
|
10
|
-
const lock_id = '0x005ba9202a5d9e41c73155a1b4e473a0283191954fb47fe3f927c7026aefec40'
|
|
11
|
-
const redeem_lock_id = '0x6c7cb48929308e7213747c0710ea38db89e3067aa7c80645a0b41dca596fa375'
|
|
12
|
-
describe('xcetus Module', () => {
|
|
13
|
-
const sdk = CetusXcetusSDK.createSDK({ env: 'mainnet' })
|
|
14
|
-
|
|
15
|
-
beforeEach(async () => {
|
|
16
|
-
send_key_pair = buildTestAccount()
|
|
17
|
-
sdk.setSenderAddress(send_key_pair.toSuiAddress())
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
test('getOwnerVeNFT', async () => {
|
|
21
|
-
const ownerVeNFT = await sdk.XCetusModule.getOwnerVeNFT(account_id)
|
|
22
|
-
console.log('ownerVeNFT: ', ownerVeNFT)
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
test('getOwnerRedeemLockList', async () => {
|
|
26
|
-
const lockCetus = await sdk.XCetusModule.getOwnerRedeemLockList(account_id)
|
|
27
|
-
console.log('lockCetus: ', lockCetus)
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
test('getLockCetus', async () => {
|
|
31
|
-
const lockCetus = await sdk.XCetusModule.getLockCetus(lock_id)
|
|
32
|
-
console.log('lockCetus: ', lockCetus)
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
test('getOwnerCetusCoins', async () => {
|
|
36
|
-
const coins = await sdk.XCetusModule.getOwnerCetusCoins(send_key_pair.getPublicKey().toSuiAddress())
|
|
37
|
-
console.log('coins: ', coins)
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
test('mintVeNFTPayload', async () => {
|
|
41
|
-
const payload = sdk.XCetusModule.mintVeNFTPayload()
|
|
42
|
-
const tx = await sdk.FullClient.sendTransaction(send_key_pair, payload)
|
|
43
|
-
console.log('mintVeNFTPayload : ', tx)
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
test(' Convert Cetus to Xcetus', async () => {
|
|
47
|
-
sdk.setSenderAddress(send_key_pair.getPublicKey().toSuiAddress())
|
|
48
|
-
const payload = await sdk.XCetusModule.convertPayload({
|
|
49
|
-
amount: '10000000000',
|
|
50
|
-
venft_id,
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
printTransaction(payload)
|
|
54
|
-
|
|
55
|
-
const tx = await sdk.FullClient.sendTransaction(send_key_pair, payload)
|
|
56
|
-
console.log('convertPayload : ', tx)
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
test('redeemLockPayload', async () => {
|
|
60
|
-
const payload = sdk.XCetusModule.redeemLockPayload({
|
|
61
|
-
venft_id: venft_id,
|
|
62
|
-
amount: '1000',
|
|
63
|
-
lock_day: 30,
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
const tx = await sdk.FullClient.sendTransaction(send_key_pair, payload)
|
|
67
|
-
console.log('redeemLockPayload : ', tx)
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
test('redeemPayload', async () => {
|
|
71
|
-
const lockCetus = await sdk.XCetusModule.getLockCetus(redeem_lock_id)
|
|
72
|
-
console.log('lockCetus: ', lockCetus)
|
|
73
|
-
|
|
74
|
-
if (lockCetus && !XCetusUtil.isLocked(lockCetus)) {
|
|
75
|
-
const payload = sdk.XCetusModule.redeemPayload({
|
|
76
|
-
venft_id: venft_id,
|
|
77
|
-
lock_id: redeem_lock_id,
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
const tx = await sdk.FullClient.sendTransaction(send_key_pair, payload)
|
|
81
|
-
console.log('redeemPayload : ', tx)
|
|
82
|
-
} else {
|
|
83
|
-
console.log(' not reach lock time')
|
|
84
|
-
}
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
test('redeemDividendPayload', async () => {})
|
|
88
|
-
|
|
89
|
-
test('redeemDividendV2Payload', async () => {})
|
|
90
|
-
|
|
91
|
-
test('redeemDividendV3Payload', async () => {
|
|
92
|
-
const dividendManager = await sdk.XCetusModule.getDividendManager()
|
|
93
|
-
const { venft_dividends_id_v2 } = getPackagerConfigs(sdk.sdkOptions.xcetus_dividends)
|
|
94
|
-
|
|
95
|
-
const veNFTDividendInfo = await sdk.XCetusModule.getVeNFTDividendInfo(venft_id)
|
|
96
|
-
|
|
97
|
-
if (veNFTDividendInfo) {
|
|
98
|
-
const payload = await sdk.XCetusModule.redeemDividendV3Payload(venft_id, veNFTDividendInfo.rewards)
|
|
99
|
-
printTransaction(payload)
|
|
100
|
-
try {
|
|
101
|
-
const res = await sdk.FullClient.devInspectTransactionBlock({ transactionBlock: payload, sender: send_key_pair.toSuiAddress() })
|
|
102
|
-
// const result = await sdk.ClmmSDK.fullClient.sendTransaction(send_key_pair, payload)
|
|
103
|
-
// console.log('redeemDividendV3Payload: ', result)
|
|
104
|
-
} catch (error) {
|
|
105
|
-
console.log('🚀🚀🚀 ~ file: xcetus.test.ts:216 ~ test ~ error:', error)
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
test('redeemDividendXTokenPayload', async () => {})
|
|
111
|
-
|
|
112
|
-
test('buildCetusCoinType', async () => {})
|
|
113
|
-
|
|
114
|
-
test('buildXTokenCoinType', async () => {})
|
|
115
|
-
|
|
116
|
-
test('cancelRedeemPayload', async () => {
|
|
117
|
-
const lockCetus = await sdk.XCetusModule.getLockCetus(redeem_lock_id)
|
|
118
|
-
console.log('lockCetus: ', lockCetus)
|
|
119
|
-
|
|
120
|
-
if (lockCetus && XCetusUtil.isLocked(lockCetus)) {
|
|
121
|
-
const payload = sdk.XCetusModule.cancelRedeemPayload({
|
|
122
|
-
venft_id: venft_id,
|
|
123
|
-
lock_id: redeem_lock_id,
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
const tx = await sdk.FullClient.sendTransaction(send_key_pair, payload)
|
|
127
|
-
console.log('cancelRedeemPayload : ', tx)
|
|
128
|
-
}
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
test('getInitConfigs', async () => {})
|
|
132
|
-
|
|
133
|
-
test('getLockUpManager', async () => {
|
|
134
|
-
const lockUpManagerEvent = await sdk.XCetusModule.getLockUpManager()
|
|
135
|
-
console.log(lockUpManagerEvent)
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
test('getDividendConfigs', async () => {})
|
|
139
|
-
|
|
140
|
-
test('getDividendManager', async () => {})
|
|
141
|
-
|
|
142
|
-
test('getXcetusManager', async () => {
|
|
143
|
-
const xcetusManager = await sdk.XCetusModule.getXcetusManager()
|
|
144
|
-
console.log('xcetusManager: ', xcetusManager)
|
|
145
|
-
})
|
|
146
|
-
|
|
147
|
-
test('getVeNFTDividendInfo', async () => {
|
|
148
|
-
const veNFTDividendInfo = await sdk.XCetusModule.getVeNFTDividendInfo(venft_id)
|
|
149
|
-
console.log('🚀🚀🚀 ~ file: xcetus.test.ts:175 ~ test ~ veNFTDividendInfo:', JSON.stringify(veNFTDividendInfo, null, 2))
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
test('redeemNum', async () => {
|
|
153
|
-
const n = 15
|
|
154
|
-
const amountInput = 20000
|
|
155
|
-
const amount = await sdk.XCetusModule.redeemNum(amountInput, n)
|
|
156
|
-
const rate = d(n).sub(15).div(165).mul(0.5).add(0.5)
|
|
157
|
-
const amount1 = rate.mul(amountInput)
|
|
158
|
-
console.log('amount : ', amount, amount1, rate)
|
|
159
|
-
})
|
|
160
|
-
|
|
161
|
-
test('reverseRedeemNum', async () => {})
|
|
162
|
-
|
|
163
|
-
test('getXCetusAmount', async () => {})
|
|
164
|
-
|
|
165
|
-
test('getVeNftAmount', async () => {})
|
|
166
|
-
|
|
167
|
-
test('getPhaseDividendInfo', async () => {
|
|
168
|
-
const phaseDividendInfo = await sdk.XCetusModule.getPhaseDividendInfo('10')
|
|
169
|
-
console.log('phaseDividendInfo: ', phaseDividendInfo)
|
|
170
|
-
})
|
|
171
|
-
|
|
172
|
-
/**-------------------------------------xWHALE Holder Rewards--------------------------------------- */
|
|
173
|
-
test('get my share', async () => {
|
|
174
|
-
const ownerVeNFT = await sdk.XCetusModule.getOwnerVeNFT(send_key_pair.getPublicKey().toSuiAddress())
|
|
175
|
-
console.log('ownerVeNFT: ', ownerVeNFT)
|
|
176
|
-
|
|
177
|
-
if (ownerVeNFT) {
|
|
178
|
-
const xcetusManager = await sdk.XCetusModule.getXcetusManager()
|
|
179
|
-
console.log('xcetusManager: ', xcetusManager)
|
|
180
|
-
|
|
181
|
-
const veNftAmount = await sdk.XCetusModule.getVeNftAmount(xcetusManager.nfts.handle, ownerVeNFT.id)
|
|
182
|
-
console.log('veNftAmount: ', veNftAmount)
|
|
183
|
-
|
|
184
|
-
const rate = d(ownerVeNFT.xcetus_balance).div(xcetusManager.treasury)
|
|
185
|
-
console.log('rate: ', rate)
|
|
186
|
-
}
|
|
187
|
-
})
|
|
188
|
-
|
|
189
|
-
test('getNextStartTime', async () => {
|
|
190
|
-
const dividendManager = await sdk.XCetusModule.getDividendManager()
|
|
191
|
-
console.log('dividendManager: ', dividendManager)
|
|
192
|
-
|
|
193
|
-
const nextTime = XCetusUtil.getNextStartTime(dividendManager)
|
|
194
|
-
|
|
195
|
-
console.log('nextTime: ', nextTime)
|
|
196
|
-
})
|
|
197
|
-
})
|
package/tsconfig.json
DELETED