zo-sdk 0.1.25 → 0.1.26
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/dist/abstract/BaseAPI.cjs.map +1 -1
- package/dist/abstract/BaseAPI.d.cts +2 -2
- package/dist/abstract/BaseAPI.d.cts.map +1 -1
- package/dist/abstract/BaseAPI.d.mts +2 -2
- package/dist/abstract/BaseAPI.d.mts.map +1 -1
- package/dist/abstract/BaseAPI.mjs.map +1 -1
- package/dist/consts/deployments-shared-mainnet.json +50 -0
- package/dist/consts/deployments-shared-testnet.json +45 -0
- package/dist/consts/deployments-usdz-mainnet.json +30 -10
- package/dist/consts/index.cjs +13 -0
- package/dist/consts/index.cjs.map +1 -1
- package/dist/consts/index.d.cts +6 -1
- package/dist/consts/index.d.cts.map +1 -1
- package/dist/consts/index.d.mts +6 -1
- package/dist/consts/index.d.mts.map +1 -1
- package/dist/consts/index.mjs +12 -0
- package/dist/consts/index.mjs.map +1 -1
- package/dist/implementations/SLPAPI.cjs +84 -0
- package/dist/implementations/SLPAPI.cjs.map +1 -1
- package/dist/implementations/SLPAPI.d.cts +12 -0
- package/dist/implementations/SLPAPI.d.cts.map +1 -1
- package/dist/implementations/SLPAPI.d.mts +12 -0
- package/dist/implementations/SLPAPI.d.mts.map +1 -1
- package/dist/implementations/SLPAPI.mjs +84 -0
- package/dist/implementations/SLPAPI.mjs.map +1 -1
- package/dist/implementations/SLPDataAPI.cjs +77 -2
- package/dist/implementations/SLPDataAPI.cjs.map +1 -1
- package/dist/implementations/SLPDataAPI.d.cts +6 -0
- package/dist/implementations/SLPDataAPI.d.cts.map +1 -1
- package/dist/implementations/SLPDataAPI.d.mts +6 -0
- package/dist/implementations/SLPDataAPI.d.mts.map +1 -1
- package/dist/implementations/SLPDataAPI.mjs +77 -2
- package/dist/implementations/SLPDataAPI.mjs.map +1 -1
- package/dist/implementations/USDZAPI.cjs +4 -13
- package/dist/implementations/USDZAPI.cjs.map +1 -1
- package/dist/implementations/USDZAPI.d.cts.map +1 -1
- package/dist/implementations/USDZAPI.d.mts.map +1 -1
- package/dist/implementations/USDZAPI.mjs +4 -13
- package/dist/implementations/USDZAPI.mjs.map +1 -1
- package/dist/implementations/USDZDataAPI.cjs +3 -2
- package/dist/implementations/USDZDataAPI.cjs.map +1 -1
- package/dist/implementations/USDZDataAPI.d.cts.map +1 -1
- package/dist/implementations/USDZDataAPI.d.mts.map +1 -1
- package/dist/implementations/USDZDataAPI.mjs +3 -2
- package/dist/implementations/USDZDataAPI.mjs.map +1 -1
- package/dist/implementations/ZBTCVCAPI.cjs +4 -13
- package/dist/implementations/ZBTCVCAPI.cjs.map +1 -1
- package/dist/implementations/ZBTCVCAPI.d.cts.map +1 -1
- package/dist/implementations/ZBTCVCAPI.d.mts.map +1 -1
- package/dist/implementations/ZBTCVCAPI.mjs +4 -13
- package/dist/implementations/ZBTCVCAPI.mjs.map +1 -1
- package/dist/implementations/ZBTCVCDataAPI.cjs +2 -1
- package/dist/implementations/ZBTCVCDataAPI.cjs.map +1 -1
- package/dist/implementations/ZBTCVCDataAPI.d.cts.map +1 -1
- package/dist/implementations/ZBTCVCDataAPI.d.mts.map +1 -1
- package/dist/implementations/ZBTCVCDataAPI.mjs +2 -1
- package/dist/implementations/ZBTCVCDataAPI.mjs.map +1 -1
- package/dist/implementations/ZLPAPI.cjs +103 -25
- package/dist/implementations/ZLPAPI.cjs.map +1 -1
- package/dist/implementations/ZLPAPI.d.cts +13 -3
- package/dist/implementations/ZLPAPI.d.cts.map +1 -1
- package/dist/implementations/ZLPAPI.d.mts +13 -3
- package/dist/implementations/ZLPAPI.d.mts.map +1 -1
- package/dist/implementations/ZLPAPI.mjs +103 -25
- package/dist/implementations/ZLPAPI.mjs.map +1 -1
- package/dist/implementations/ZLPDataAPI.cjs +86 -4
- package/dist/implementations/ZLPDataAPI.cjs.map +1 -1
- package/dist/implementations/ZLPDataAPI.d.cts +6 -3
- package/dist/implementations/ZLPDataAPI.d.cts.map +1 -1
- package/dist/implementations/ZLPDataAPI.d.mts +6 -3
- package/dist/implementations/ZLPDataAPI.d.mts.map +1 -1
- package/dist/implementations/ZLPDataAPI.mjs +86 -4
- package/dist/implementations/ZLPDataAPI.mjs.map +1 -1
- package/dist/interfaces/base.d.cts +2 -2
- package/dist/interfaces/base.d.cts.map +1 -1
- package/dist/interfaces/base.d.mts +2 -2
- package/dist/interfaces/base.d.mts.map +1 -1
- package/dist/interfaces/slp.d.cts +1 -0
- package/dist/interfaces/slp.d.cts.map +1 -1
- package/dist/interfaces/slp.d.mts +1 -0
- package/dist/interfaces/slp.d.mts.map +1 -1
- package/dist/interfaces/zlp.d.cts +1 -0
- package/dist/interfaces/zlp.d.cts.map +1 -1
- package/dist/interfaces/zlp.d.mts +1 -0
- package/dist/interfaces/zlp.d.mts.map +1 -1
- package/dist/oracle.cjs +1 -0
- package/dist/oracle.cjs.map +1 -1
- package/dist/oracle.d.cts +1 -0
- package/dist/oracle.d.cts.map +1 -1
- package/dist/oracle.d.mts +1 -0
- package/dist/oracle.d.mts.map +1 -1
- package/dist/oracle.mjs +2 -1
- package/dist/oracle.mjs.map +1 -1
- package/package.json +9 -9
- package/src/consts/deployments-shared-mainnet.json +50 -0
- package/src/consts/deployments-shared-testnet.json +45 -0
- package/src/consts/deployments-usdz-mainnet.json +31 -11
- package/src/consts/deployments-zlp-mainnet.json +1 -1
- package/src/consts/index.ts +15 -1
- package/src/implementations/SLPAPI.ts +104 -0
- package/src/implementations/SLPDataAPI.ts +107 -15
- package/src/implementations/USDZAPI.ts +5 -17
- package/src/implementations/USDZDataAPI.ts +3 -2
- package/src/implementations/ZBTCVCAPI.ts +5 -17
- package/src/implementations/ZBTCVCDataAPI.ts +2 -1
- package/src/implementations/ZLPAPI.ts +124 -27
- package/src/implementations/ZLPDataAPI.ts +111 -4
- package/src/interfaces/slp.ts +4 -1
- package/src/interfaces/zlp.ts +1 -0
- package/src/oracle.ts +3 -1
|
@@ -742,10 +742,6 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
|
|
|
742
742
|
pool: string,
|
|
743
743
|
tx?: Transaction,
|
|
744
744
|
): Transaction {
|
|
745
|
-
if (!this.consts.zoStaking) {
|
|
746
|
-
throw new Error('ZO staking configuration not found')
|
|
747
|
-
}
|
|
748
|
-
|
|
749
745
|
if (!tx) {
|
|
750
746
|
tx = new Transaction()
|
|
751
747
|
}
|
|
@@ -754,7 +750,7 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
|
|
|
754
750
|
const [depositObject] = tx.splitCoins(coinObject, [tx.pure.u64(amount)])
|
|
755
751
|
|
|
756
752
|
tx.moveCall({
|
|
757
|
-
target: `${this.
|
|
753
|
+
target: `${this.sharedConfig.zoStaking.package}::pool::deposit`,
|
|
758
754
|
typeArguments: [
|
|
759
755
|
`${this.consts.zoCore.package}::zbtcvc::ZBTCVC`,
|
|
760
756
|
`${this.consts.coins.sui.module}`,
|
|
@@ -776,16 +772,12 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
|
|
|
776
772
|
pool: string,
|
|
777
773
|
tx?: Transaction,
|
|
778
774
|
): Transaction {
|
|
779
|
-
if (!this.consts.zoStaking) {
|
|
780
|
-
throw new Error('ZO staking configuration not found')
|
|
781
|
-
}
|
|
782
|
-
|
|
783
775
|
if (!tx) {
|
|
784
776
|
tx = new Transaction()
|
|
785
777
|
}
|
|
786
778
|
|
|
787
779
|
tx.moveCall({
|
|
788
|
-
target: `${this.
|
|
780
|
+
target: `${this.sharedConfig.zoStaking.package}::pool::deposit`,
|
|
789
781
|
typeArguments: [
|
|
790
782
|
`${this.consts.zoCore.package}::zbtcvc::ZBTCVC`,
|
|
791
783
|
`${this.consts.coins.sui.module}`,
|
|
@@ -808,10 +800,6 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
|
|
|
808
800
|
pool: string,
|
|
809
801
|
tx?: Transaction,
|
|
810
802
|
): Transaction {
|
|
811
|
-
if (!this.consts.zoStaking) {
|
|
812
|
-
throw new Error('ZO staking configuration not found')
|
|
813
|
-
}
|
|
814
|
-
|
|
815
803
|
let unstakeAmount = amount
|
|
816
804
|
if (!tx) {
|
|
817
805
|
tx = new Transaction()
|
|
@@ -823,7 +811,7 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
|
|
|
823
811
|
})()
|
|
824
812
|
unstakeAmount -= withdrawAmount
|
|
825
813
|
tx.moveCall({
|
|
826
|
-
target: `${this.
|
|
814
|
+
target: `${this.sharedConfig.zoStaking.package}::pool::withdraw`,
|
|
827
815
|
typeArguments: [
|
|
828
816
|
`${this.consts.zoCore.package}::zbtcvc::ZBTCVC`,
|
|
829
817
|
`${this.consts.coins.sui.module}`,
|
|
@@ -837,10 +825,10 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
|
|
|
837
825
|
})
|
|
838
826
|
if (credential.amount === BigInt(0)) {
|
|
839
827
|
tx.moveCall({
|
|
840
|
-
target: `${this.
|
|
828
|
+
target: `${this.sharedConfig.zoStaking.package}::pool::clear_empty_credential`,
|
|
841
829
|
typeArguments: [
|
|
842
830
|
`${this.consts.zoCore.package}::zbtcvc::ZBTCVC`,
|
|
843
|
-
|
|
831
|
+
`${this.consts.coins.sui.module}`,
|
|
844
832
|
],
|
|
845
833
|
arguments: [tx.object(credential.id)],
|
|
846
834
|
})
|
|
@@ -93,8 +93,9 @@ export class ZBTCVCDataAPI extends BaseDataAPI implements IZBTCVCDataAPI {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
public async getStakePool(): Promise<IZBTCVCStakePool> {
|
|
96
|
+
const poolId = this.consts.zoStaking.pools.ZBTCVC
|
|
96
97
|
const raw = await this.provider.getObject({
|
|
97
|
-
id:
|
|
98
|
+
id: poolId,
|
|
98
99
|
options: {
|
|
99
100
|
showContent: true,
|
|
100
101
|
},
|
|
@@ -28,6 +28,7 @@ import type {
|
|
|
28
28
|
IBaseSymbolInfo,
|
|
29
29
|
IBaseVaultInfo,
|
|
30
30
|
IZLPAPI,
|
|
31
|
+
IZLPCredential,
|
|
31
32
|
} from '../interfaces'
|
|
32
33
|
import { joinSymbol } from '../utils'
|
|
33
34
|
import { ZLPDataAPI } from './ZLPDataAPI'
|
|
@@ -45,14 +46,6 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
45
46
|
this.dataAPI = new ZLPDataAPI(network, provider, apiEndpoint, connectionURL)
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
public stake(_lpCoinObjects: string[], _amount: bigint, _pool: string, _tx?: Transaction): Transaction {
|
|
49
|
-
throw new Error(`Method not implemented in ${this.constructor.name}.`)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
public unstake(_credentials: IBaseCredential[], _amount: bigint, _pool: string, _tx?: Transaction): Transaction {
|
|
53
|
-
throw new Error(`Method not implemented in ${this.constructor.name}.`)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
49
|
public claimTokenFromSCard(_token: string, _coinObjects: string[], _kioskClient: KioskClient, _kioskCap: KioskOwnerCap, _scard: string): Transaction {
|
|
57
50
|
throw new Error(`Method not implemented in ${this.constructor.name}.`)
|
|
58
51
|
}
|
|
@@ -275,6 +268,110 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
275
268
|
return tx
|
|
276
269
|
}
|
|
277
270
|
|
|
271
|
+
/**
|
|
272
|
+
* Stakes ZLP tokens in ZO staking pools
|
|
273
|
+
*/
|
|
274
|
+
public stake(
|
|
275
|
+
lpCoinObjects: string[],
|
|
276
|
+
amount: bigint,
|
|
277
|
+
pool: string,
|
|
278
|
+
tx?: Transaction,
|
|
279
|
+
): Transaction {
|
|
280
|
+
if (!tx) {
|
|
281
|
+
tx = new Transaction()
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const coinObject = this.processCoins(tx, 'zlp', lpCoinObjects)
|
|
285
|
+
const [depositObject] = tx.splitCoins(coinObject, [tx.pure.u64(amount)])
|
|
286
|
+
|
|
287
|
+
tx.moveCall({
|
|
288
|
+
target: `${this.sharedConfig.zoStaking.package}::pool::deposit`,
|
|
289
|
+
typeArguments: [
|
|
290
|
+
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
291
|
+
`${this.consts.coins.sui.module}`,
|
|
292
|
+
],
|
|
293
|
+
arguments: [
|
|
294
|
+
tx.object(pool),
|
|
295
|
+
tx.object(SUI_CLOCK_OBJECT_ID),
|
|
296
|
+
depositObject,
|
|
297
|
+
],
|
|
298
|
+
})
|
|
299
|
+
return tx
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Stakes ZLP tokens using coin object only (PTB)
|
|
304
|
+
*/
|
|
305
|
+
public stakeCoinObject(
|
|
306
|
+
coinObject: any,
|
|
307
|
+
pool: string,
|
|
308
|
+
tx?: Transaction,
|
|
309
|
+
): Transaction {
|
|
310
|
+
if (!tx) {
|
|
311
|
+
tx = new Transaction()
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
tx.moveCall({
|
|
315
|
+
target: `${this.sharedConfig.zoStaking.package}::pool::deposit`,
|
|
316
|
+
typeArguments: [
|
|
317
|
+
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
318
|
+
`${this.consts.coins.sui.module}`,
|
|
319
|
+
],
|
|
320
|
+
arguments: [
|
|
321
|
+
tx.object(pool),
|
|
322
|
+
tx.object(SUI_CLOCK_OBJECT_ID),
|
|
323
|
+
coinObject,
|
|
324
|
+
],
|
|
325
|
+
})
|
|
326
|
+
return tx
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Unstakes ZLP tokens from ZO staking pools
|
|
331
|
+
*/
|
|
332
|
+
public unstake(
|
|
333
|
+
credentials: IZLPCredential[],
|
|
334
|
+
amount: bigint,
|
|
335
|
+
pool: string,
|
|
336
|
+
tx?: Transaction,
|
|
337
|
+
): Transaction {
|
|
338
|
+
let unstakeAmount = amount
|
|
339
|
+
if (!tx) {
|
|
340
|
+
tx = new Transaction()
|
|
341
|
+
}
|
|
342
|
+
for (const credential of credentials) {
|
|
343
|
+
const withdrawAmount = (() => {
|
|
344
|
+
const min = (a: bigint, b: bigint) => a < b ? a : b
|
|
345
|
+
return min(unstakeAmount, credential.amount)
|
|
346
|
+
})()
|
|
347
|
+
unstakeAmount -= withdrawAmount
|
|
348
|
+
tx.moveCall({
|
|
349
|
+
target: `${this.sharedConfig.zoStaking.package}::pool::withdraw`,
|
|
350
|
+
typeArguments: [
|
|
351
|
+
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
352
|
+
`${this.consts.coins.sui.module}`,
|
|
353
|
+
],
|
|
354
|
+
arguments: [
|
|
355
|
+
tx.object(pool),
|
|
356
|
+
tx.object(SUI_CLOCK_OBJECT_ID),
|
|
357
|
+
tx.object(credential.id),
|
|
358
|
+
tx.pure.u64(withdrawAmount),
|
|
359
|
+
],
|
|
360
|
+
})
|
|
361
|
+
if (credential.amount === BigInt(0)) {
|
|
362
|
+
tx.moveCall({
|
|
363
|
+
target: `${this.sharedConfig.zoStaking.package}::pool::clear_empty_credential`,
|
|
364
|
+
typeArguments: [
|
|
365
|
+
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
366
|
+
`${this.consts.coins.sui.module}`,
|
|
367
|
+
],
|
|
368
|
+
arguments: [tx.object(credential.id)],
|
|
369
|
+
})
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
return tx
|
|
373
|
+
}
|
|
374
|
+
|
|
278
375
|
public async swap(
|
|
279
376
|
fromToken: string,
|
|
280
377
|
toToken: string,
|
|
@@ -1298,15 +1395,15 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1298
1395
|
}
|
|
1299
1396
|
for (const [i, beneficiary] of beneficiaries.entries()) {
|
|
1300
1397
|
tx.moveCall({
|
|
1301
|
-
target: `${this.
|
|
1398
|
+
target: `${this.sharedConfig.zoLootbox.package}::lootbox::admin_issue_lootbox`,
|
|
1302
1399
|
typeArguments: [module],
|
|
1303
1400
|
arguments: [
|
|
1304
|
-
tx.object(this.
|
|
1401
|
+
tx.object(this.sharedConfig.zoLootbox.adminCap),
|
|
1305
1402
|
tx.pure.u8(tiers[i]),
|
|
1306
1403
|
tx.pure.address(beneficiary),
|
|
1307
1404
|
tx.pure.u64(amounts[i]),
|
|
1308
1405
|
tx.pure.bool(amounts[i] > 0),
|
|
1309
|
-
tx.object(`${this.
|
|
1406
|
+
tx.object(`${this.sharedConfig.zoLootbox.lootboxSettings}`),
|
|
1310
1407
|
],
|
|
1311
1408
|
})
|
|
1312
1409
|
}
|
|
@@ -1327,11 +1424,11 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1327
1424
|
}
|
|
1328
1425
|
|
|
1329
1426
|
tx.moveCall({
|
|
1330
|
-
target: `${this.
|
|
1427
|
+
target: `${this.sharedConfig.zoLootbox.package}::lootbox::deposit`,
|
|
1331
1428
|
typeArguments: [module],
|
|
1332
1429
|
arguments: [
|
|
1333
|
-
tx.object(this.
|
|
1334
|
-
tx.object(this.
|
|
1430
|
+
tx.object(this.sharedConfig.zoLootbox.adminCap),
|
|
1431
|
+
tx.object(this.sharedConfig.zoLootbox.lootboxTreasury),
|
|
1335
1432
|
depositObject,
|
|
1336
1433
|
],
|
|
1337
1434
|
})
|
|
@@ -1352,11 +1449,11 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1352
1449
|
}
|
|
1353
1450
|
|
|
1354
1451
|
tx.moveCall({
|
|
1355
|
-
target: `${this.
|
|
1452
|
+
target: `${this.sharedConfig.zoLootbox.package}::lootbox::withdraw`,
|
|
1356
1453
|
typeArguments: [module],
|
|
1357
1454
|
arguments: [
|
|
1358
|
-
tx.object(this.
|
|
1359
|
-
tx.object(this.
|
|
1455
|
+
tx.object(this.sharedConfig.zoLootbox.adminCap),
|
|
1456
|
+
tx.object(this.sharedConfig.zoLootbox.lootboxTreasury),
|
|
1360
1457
|
tx.object(metadata),
|
|
1361
1458
|
tx.pure.u64(amount),
|
|
1362
1459
|
],
|
|
@@ -1378,13 +1475,13 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1378
1475
|
}
|
|
1379
1476
|
|
|
1380
1477
|
tx.moveCall({
|
|
1381
|
-
target: `${this.
|
|
1478
|
+
target: `${this.sharedConfig.zoLootbox.upgradedPackage}::lootbox::open_lootbox`,
|
|
1382
1479
|
typeArguments: [module],
|
|
1383
1480
|
arguments: [
|
|
1384
|
-
tx.object(`${this.
|
|
1481
|
+
tx.object(`${this.sharedConfig.zoLootbox.lootboxTreasury}`),
|
|
1385
1482
|
tx.object(lootbox),
|
|
1386
1483
|
tx.object(metadata),
|
|
1387
|
-
tx.object(`${this.
|
|
1484
|
+
tx.object(`${this.sharedConfig.zoLootbox.lootboxSettings}`),
|
|
1388
1485
|
],
|
|
1389
1486
|
})
|
|
1390
1487
|
|
|
@@ -1408,18 +1505,18 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1408
1505
|
|
|
1409
1506
|
for (const [i, beneficiary] of beneficiaries.entries()) {
|
|
1410
1507
|
const moveCallArgs = {
|
|
1411
|
-
target: `${this.
|
|
1508
|
+
target: `${this.sharedConfig.zoLootboxV2.package}::lootbox::admin_issue_lootbox`,
|
|
1412
1509
|
typeArguments: [module],
|
|
1413
1510
|
arguments: [
|
|
1414
|
-
tx.object(this.
|
|
1415
|
-
tx.object(this.
|
|
1511
|
+
tx.object(this.sharedConfig.zoLootboxV2.adminCap),
|
|
1512
|
+
tx.object(this.sharedConfig.zoLootboxV2.lootboxTreasury),
|
|
1416
1513
|
tx.pure.u8(tiers[i]),
|
|
1417
1514
|
tx.pure.address(beneficiary),
|
|
1418
1515
|
tx.pure.u64(amounts[i]),
|
|
1419
1516
|
tx.pure.bool(amounts[i] > 0),
|
|
1420
1517
|
tx.pure.string(titles[i]),
|
|
1421
1518
|
tx.pure.string(descriptions[i]),
|
|
1422
|
-
tx.object(`${this.
|
|
1519
|
+
tx.object(`${this.sharedConfig.zoLootboxV2.lootboxSettings}`),
|
|
1423
1520
|
],
|
|
1424
1521
|
}
|
|
1425
1522
|
|
|
@@ -1441,13 +1538,13 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1441
1538
|
}
|
|
1442
1539
|
|
|
1443
1540
|
tx.moveCall({
|
|
1444
|
-
target: `${this.
|
|
1541
|
+
target: `${this.sharedConfig.zoLootboxV2.package}::lootbox::open_lootbox`,
|
|
1445
1542
|
typeArguments: [module],
|
|
1446
1543
|
arguments: [
|
|
1447
|
-
tx.object(this.
|
|
1544
|
+
tx.object(this.sharedConfig.zoLootboxV2.lootboxTreasury),
|
|
1448
1545
|
tx.object(lootbox),
|
|
1449
1546
|
tx.object(metadata),
|
|
1450
|
-
tx.object(this.
|
|
1547
|
+
tx.object(this.sharedConfig.zoLootboxV2.lootboxSettings),
|
|
1451
1548
|
],
|
|
1452
1549
|
})
|
|
1453
1550
|
|
|
@@ -15,6 +15,7 @@ import type {
|
|
|
15
15
|
IBaseHistoryResponse,
|
|
16
16
|
IBaseStaked,
|
|
17
17
|
IBaseStakePool,
|
|
18
|
+
IZLPCredential,
|
|
18
19
|
IZLPDataAPI,
|
|
19
20
|
IZLPFundingFeeModel,
|
|
20
21
|
IZLPMarketInfo,
|
|
@@ -26,6 +27,7 @@ import type {
|
|
|
26
27
|
IZLPPositionInfo,
|
|
27
28
|
IZLPRebaseFeeModel,
|
|
28
29
|
IZLPReservingFeeModel,
|
|
30
|
+
IZLPStakePool,
|
|
29
31
|
IZLPSymbolConfig,
|
|
30
32
|
IZLPSymbolInfo,
|
|
31
33
|
IZLPVaultInfo,
|
|
@@ -42,12 +44,64 @@ export class ZLPDataAPI extends BaseDataAPI implements IZLPDataAPI {
|
|
|
42
44
|
super(network, provider, apiEndpoint, connectionURL, LPToken.ZLP)
|
|
43
45
|
}
|
|
44
46
|
|
|
45
|
-
public getStaked(
|
|
46
|
-
|
|
47
|
+
public async getStaked(owner: string): Promise<IBaseStaked> {
|
|
48
|
+
let rawCredentialsData: any[] = []
|
|
49
|
+
let queryNextPage = true
|
|
50
|
+
let queryCursor: string | undefined | null
|
|
51
|
+
|
|
52
|
+
const limit = 50
|
|
53
|
+
|
|
54
|
+
while (queryNextPage) {
|
|
55
|
+
const { data, hasNextPage, nextCursor } = await this.provider.getOwnedObjects({
|
|
56
|
+
owner,
|
|
57
|
+
filter: {
|
|
58
|
+
MoveModule: {
|
|
59
|
+
package: this.consts.zoStaking.package,
|
|
60
|
+
module: 'pool',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
options: {
|
|
64
|
+
showType: true,
|
|
65
|
+
showContent: true,
|
|
66
|
+
},
|
|
67
|
+
cursor: queryCursor,
|
|
68
|
+
limit,
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
queryNextPage = hasNextPage
|
|
72
|
+
queryCursor = nextCursor!
|
|
73
|
+
if (!data)
|
|
74
|
+
break
|
|
75
|
+
rawCredentialsData = [...rawCredentialsData, ...data]
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const pool = await this.getStakePool()
|
|
79
|
+
|
|
80
|
+
const credentials = rawCredentialsData.map((item: any) =>
|
|
81
|
+
ZLPDataAPI.parseCredential(item, pool),
|
|
82
|
+
)
|
|
83
|
+
return {
|
|
84
|
+
credentials,
|
|
85
|
+
amount: credentials.reduce(
|
|
86
|
+
(acc: bigint, cur: IZLPCredential) => acc + cur.amount,
|
|
87
|
+
BigInt(0),
|
|
88
|
+
),
|
|
89
|
+
claimable: credentials.reduce(
|
|
90
|
+
(acc: bigint, cur: IZLPCredential) => acc + cur.claimable,
|
|
91
|
+
BigInt(0),
|
|
92
|
+
),
|
|
93
|
+
}
|
|
47
94
|
}
|
|
48
95
|
|
|
49
|
-
public getStakePool(): Promise<
|
|
50
|
-
|
|
96
|
+
public async getStakePool(): Promise<IZLPStakePool> {
|
|
97
|
+
const poolId = this.consts.zoStaking.pools.ZLP
|
|
98
|
+
const raw = await this.provider.getObject({
|
|
99
|
+
id: poolId,
|
|
100
|
+
options: {
|
|
101
|
+
showContent: true,
|
|
102
|
+
},
|
|
103
|
+
})
|
|
104
|
+
return ZLPDataAPI.parseStakePool(raw)
|
|
51
105
|
}
|
|
52
106
|
|
|
53
107
|
/**
|
|
@@ -907,4 +961,57 @@ export class ZLPDataAPI extends BaseDataAPI implements IZLPDataAPI {
|
|
|
907
961
|
return vaultInfo.unrealisedReservingFeeAmount
|
|
908
962
|
+ (vaultInfo.reservedAmount * reservingFeeModel.multiplier * periods) / 1e18
|
|
909
963
|
}
|
|
964
|
+
|
|
965
|
+
private static parseCredential(raw: any, pool: IZLPStakePool): IZLPCredential {
|
|
966
|
+
const stakedAmount = BigInt(raw.data.content.fields.stake)
|
|
967
|
+
const accRewardPerShare = BigInt(
|
|
968
|
+
raw.data.content.fields.acc_reward_per_share,
|
|
969
|
+
)
|
|
970
|
+
return {
|
|
971
|
+
id: raw.data.objectId,
|
|
972
|
+
lockUntil: parseValue(raw.data.content.fields.lock_until),
|
|
973
|
+
amount: stakedAmount,
|
|
974
|
+
accRewardPerShare,
|
|
975
|
+
claimable:
|
|
976
|
+
((pool.accRewardPerShare - accRewardPerShare) * stakedAmount)
|
|
977
|
+
/ BigInt(1e18),
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
private static parseStakePool(raw: any): IZLPStakePool {
|
|
982
|
+
const content = raw.data.content.fields
|
|
983
|
+
const pool = {
|
|
984
|
+
id: content.id.id,
|
|
985
|
+
enabled: content.enabled,
|
|
986
|
+
lastUpdatedTime: parseValue(content.last_updated_time),
|
|
987
|
+
stakedAmount: BigInt(content.staked_amount),
|
|
988
|
+
reward: BigInt(content.reward_vault),
|
|
989
|
+
startTime: parseValue(content.start_time),
|
|
990
|
+
endTime: parseValue(content.end_time),
|
|
991
|
+
rewardRate: BigInt(content.reward_rate),
|
|
992
|
+
accRewardPerShare: BigInt(content.acc_reward_per_share),
|
|
993
|
+
lockDuration: parseValue(content.lock_duration),
|
|
994
|
+
}
|
|
995
|
+
ZLPDataAPI.refreshPool(pool, Math.floor(Date.now() / 1000))
|
|
996
|
+
return pool
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
private static refreshPool(pool: IZLPStakePool, timestamp: number): void {
|
|
1000
|
+
if (timestamp <= pool.lastUpdatedTime || timestamp < pool.startTime) {
|
|
1001
|
+
return
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
const applicableEndTime = Math.max(pool.endTime, pool.lastUpdatedTime)
|
|
1005
|
+
|
|
1006
|
+
const calculationEndTime = Math.min(timestamp, applicableEndTime)
|
|
1007
|
+
|
|
1008
|
+
if (calculationEndTime > pool.lastUpdatedTime && pool.stakedAmount > BigInt(0) && pool.rewardRate > BigInt(0)) {
|
|
1009
|
+
const timeDiff = BigInt(calculationEndTime - pool.lastUpdatedTime)
|
|
1010
|
+
const rewardAmount = timeDiff * pool.rewardRate
|
|
1011
|
+
const rewardPerShare = (rewardAmount * BigInt(1e18)) / pool.stakedAmount
|
|
1012
|
+
pool.accRewardPerShare += rewardPerShare
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
pool.lastUpdatedTime = calculationEndTime
|
|
1016
|
+
}
|
|
910
1017
|
}
|
package/src/interfaces/slp.ts
CHANGED
|
@@ -56,7 +56,10 @@ export interface ISLPHistory extends IBaseHistory { }
|
|
|
56
56
|
|
|
57
57
|
export interface ISLPStaked extends IBaseStaked { }
|
|
58
58
|
|
|
59
|
-
export interface ISLPStakePool extends IBaseStakePool {
|
|
59
|
+
export interface ISLPStakePool extends IBaseStakePool {
|
|
60
|
+
// SLP-specific stake pool fields to match new staking implementation
|
|
61
|
+
rewardRate?: bigint // Optional for backward compatibility
|
|
62
|
+
}
|
|
60
63
|
|
|
61
64
|
export interface ISLPCredential extends IBaseCredential { }
|
|
62
65
|
|
package/src/interfaces/zlp.ts
CHANGED
package/src/oracle.ts
CHANGED
|
@@ -4,12 +4,13 @@ import type { PriceFeed } from '@pythnetwork/pyth-sui-js'
|
|
|
4
4
|
import { SuiPriceServiceConnection, SuiPythClient } from '@pythnetwork/pyth-sui-js'
|
|
5
5
|
|
|
6
6
|
import type { IConsts, Network } from './consts'
|
|
7
|
-
import { getConsts, getPriceIdToPythFeeder, getPythFeederToId, getPythFeederToPriceId, LPToken } from './consts'
|
|
7
|
+
import { getConsts, getPriceIdToPythFeeder, getPythFeederToId, getPythFeederToPriceId, getSharedConfig, LPToken } from './consts'
|
|
8
8
|
import { createJsonRpcProvider } from './utils'
|
|
9
9
|
|
|
10
10
|
export class OracleAPI {
|
|
11
11
|
network: Network
|
|
12
12
|
consts: IConsts
|
|
13
|
+
sharedConfig: IConsts
|
|
13
14
|
connectionURL: string
|
|
14
15
|
PythFeederToPriceId: Record<string, string>
|
|
15
16
|
PythFeederToId: Record<string, string>
|
|
@@ -27,6 +28,7 @@ export class OracleAPI {
|
|
|
27
28
|
) {
|
|
28
29
|
this.network = network
|
|
29
30
|
this.consts = getConsts(network, lpToken)
|
|
31
|
+
this.sharedConfig = getSharedConfig(network)
|
|
30
32
|
this.connectionURL = connectionURL
|
|
31
33
|
this.PythFeederToPriceId = getPythFeederToPriceId(network)
|
|
32
34
|
this.PythFeederToId = getPythFeederToId(network)
|