@cetusprotocol/burn-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 +10682 -0
- package/README.md +275 -0
- package/dist/index.d.mts +154 -0
- package/dist/index.d.ts +154 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2 -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 +18 -0
- package/src/config/testnet.ts +18 -0
- package/src/errors/errors.ts +27 -0
- package/src/index.ts +8 -0
- package/src/modules/burnModule.ts +365 -0
- package/src/modules/index.ts +1 -0
- package/src/sdk.ts +50 -0
- package/src/types/burn.ts +38 -0
- package/src/types/index.ts +1 -0
- package/src/utils/burn.ts +26 -0
- package/src/utils/index.ts +1 -0
- package/tests/burn.test.ts +90 -0
- package/tests/tsconfig.json +26 -0
- package/tsconfig.json +5 -0
- package/tsup.config.ts +9 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { asIntN, extractStructTagFromType } from '@cetusprotocol/common-sdk'
|
|
2
|
+
import { BurnPositionNFT } from '../types/burn'
|
|
3
|
+
|
|
4
|
+
export class BurnUtils {
|
|
5
|
+
static buildBurnPositionNFT(fields: any): BurnPositionNFT {
|
|
6
|
+
const burnFields = fields.position.fields
|
|
7
|
+
const name = `Cetus Burned LP | Pool${burnFields.name.split('Pool')?.[1]}`
|
|
8
|
+
const burnPositionNft: BurnPositionNFT = {
|
|
9
|
+
id: fields.id.id,
|
|
10
|
+
url: burnFields.url,
|
|
11
|
+
pool_id: burnFields.pool,
|
|
12
|
+
coin_type_a: extractStructTagFromType(burnFields.coin_type_a.fields.name).full_address,
|
|
13
|
+
coin_type_b: extractStructTagFromType(burnFields.coin_type_b.fields.name).full_address,
|
|
14
|
+
description: burnFields.description,
|
|
15
|
+
name,
|
|
16
|
+
liquidity: burnFields.liquidity,
|
|
17
|
+
clmm_position_id: burnFields.id.id,
|
|
18
|
+
clmm_pool_id: burnFields.pool,
|
|
19
|
+
tick_lower_index: asIntN(BigInt(burnFields.tick_lower_index.fields.bits)),
|
|
20
|
+
tick_upper_index: asIntN(BigInt(burnFields.tick_upper_index.fields.bits)),
|
|
21
|
+
index: burnFields.index,
|
|
22
|
+
is_lp_burn: true,
|
|
23
|
+
}
|
|
24
|
+
return burnPositionNft
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './burn'
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// buildTestAccount
|
|
2
|
+
import type { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519'
|
|
3
|
+
import { buildTestAccount } from '@cetusprotocol/test-utils'
|
|
4
|
+
import { CetusBurnSDK } from '../src/sdk'
|
|
5
|
+
|
|
6
|
+
describe('burn', () => {
|
|
7
|
+
const sdk = CetusBurnSDK.createSDK({ env: 'mainnet' })
|
|
8
|
+
console.log('🚀 ~ describe ~ sdk:', sdk)
|
|
9
|
+
let send_key_pair: Ed25519Keypair
|
|
10
|
+
let account: string
|
|
11
|
+
|
|
12
|
+
beforeEach(async () => {
|
|
13
|
+
send_key_pair = buildTestAccount()
|
|
14
|
+
account = send_key_pair.getPublicKey().toSuiAddress()
|
|
15
|
+
sdk.setSenderAddress(account)
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
test('getBurnPoolList', async () => {
|
|
19
|
+
const res = await sdk.Burn.getBurnPoolList()
|
|
20
|
+
console.log('getBurnPoolList res:', res)
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
test('getPoolBurnPositionList', async () => {
|
|
24
|
+
const res = await sdk.Burn.getPoolBurnPositionList('0xcf994611fd4c48e277ce3ffd4d4364c914af2c3cbb05f7bf6facd371de688630')
|
|
25
|
+
console.log('getBurnPositionList res:', res)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
test('getBurnPositionList', async () => {
|
|
29
|
+
const res = await sdk.Burn.getBurnPositionList(account)
|
|
30
|
+
console.log('getBurnPositionList res:', res)
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
test('getBurnPosition', async () => {
|
|
34
|
+
const posId = '0x88678e4cd2681bf41b7f2afdd49c1583a1ca0ae8d6c8f5581bf1db1e021a1e48'
|
|
35
|
+
const res = await sdk.Burn.getBurnPosition(posId)
|
|
36
|
+
console.log('getBurnPosition res:', res)
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
test('burn lock', async () => {
|
|
40
|
+
const poolId = '0xc41621d02d5ee00a7a993b912a8550df50524c9b2494339691e5896936ff269b'
|
|
41
|
+
const posId = '0x4e1970683fc49de834478339724509a051764e7f34d55b4dc4d2a37b7034669c' // is burn success
|
|
42
|
+
const coinTypeA = '26b3bc67befc214058ca78ea9a2690298d731a2d4309485ec3d40198063c4abc::usdc::USDC'
|
|
43
|
+
const coinTypeB = '26b3bc67befc214058ca78ea9a2690298d731a2d4309485ec3d40198063c4abc::cetus::CETUS'
|
|
44
|
+
const txb = await sdk.Burn.createBurnPayload({
|
|
45
|
+
pool_id: poolId,
|
|
46
|
+
pos_id: posId,
|
|
47
|
+
coin_type_a: coinTypeA,
|
|
48
|
+
coin_type_b: coinTypeB,
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
const simulateRes = await sdk.FullClient.devInspectTransactionBlock({
|
|
52
|
+
transactionBlock: txb,
|
|
53
|
+
sender: account,
|
|
54
|
+
})
|
|
55
|
+
console.log('burn lock simulateRes:', simulateRes)
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
test('createBurnLPV2Payload', async () => {})
|
|
59
|
+
|
|
60
|
+
test('claim', async () => {
|
|
61
|
+
const poolId = '0xc41621d02d5ee00a7a993b912a8550df50524c9b2494339691e5896936ff269b'
|
|
62
|
+
const posId = '0x2f10a5816747fd02218dd7a3a7d0417d287da55ccee5943eb5c94f5a6b552299' // is wrap pos id
|
|
63
|
+
const coinTypeA = '26b3bc67befc214058ca78ea9a2690298d731a2d4309485ec3d40198063c4abc::usdc::USDC'
|
|
64
|
+
const coinTypeB = '26b3bc67befc214058ca78ea9a2690298d731a2d4309485ec3d40198063c4abc::cetus::CETUS'
|
|
65
|
+
|
|
66
|
+
const rewarderCoinTypes = ['0x26b3bc67befc214058ca78ea9a2690298d731a2d4309485ec3d40198063c4abc::cetus::CETUS']
|
|
67
|
+
let txb = sdk.Burn.createCollectFeePayload({
|
|
68
|
+
pool_id: poolId,
|
|
69
|
+
pos_id: posId,
|
|
70
|
+
coin_type_a: coinTypeA,
|
|
71
|
+
coin_type_b: coinTypeB,
|
|
72
|
+
account,
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
txb = sdk.Burn.crateCollectRewardPayload({
|
|
76
|
+
pool_id: poolId,
|
|
77
|
+
pos_id: posId,
|
|
78
|
+
coin_type_a: coinTypeA,
|
|
79
|
+
coin_type_b: coinTypeB,
|
|
80
|
+
rewarder_coin_types: rewarderCoinTypes,
|
|
81
|
+
account,
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
const simulateRes = await sdk.FullClient.devInspectTransactionBlock({
|
|
85
|
+
transactionBlock: txb,
|
|
86
|
+
sender: account,
|
|
87
|
+
})
|
|
88
|
+
console.log('claim simulateRes:', simulateRes)
|
|
89
|
+
})
|
|
90
|
+
})
|
|
@@ -0,0 +1,26 @@
|
|
|
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/tsconfig.json
ADDED