zo-sdk 0.1.25 → 0.1.27

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.
Files changed (107) hide show
  1. package/dist/abstract/BaseAPI.cjs.map +1 -1
  2. package/dist/abstract/BaseAPI.d.cts +2 -2
  3. package/dist/abstract/BaseAPI.d.cts.map +1 -1
  4. package/dist/abstract/BaseAPI.d.mts +2 -2
  5. package/dist/abstract/BaseAPI.d.mts.map +1 -1
  6. package/dist/abstract/BaseAPI.mjs.map +1 -1
  7. package/dist/consts/deployments-shared-mainnet.json +50 -0
  8. package/dist/consts/deployments-shared-testnet.json +45 -0
  9. package/dist/consts/index.cjs +13 -0
  10. package/dist/consts/index.cjs.map +1 -1
  11. package/dist/consts/index.d.cts +6 -1
  12. package/dist/consts/index.d.cts.map +1 -1
  13. package/dist/consts/index.d.mts +6 -1
  14. package/dist/consts/index.d.mts.map +1 -1
  15. package/dist/consts/index.mjs +12 -0
  16. package/dist/consts/index.mjs.map +1 -1
  17. package/dist/implementations/SLPAPI.cjs +84 -0
  18. package/dist/implementations/SLPAPI.cjs.map +1 -1
  19. package/dist/implementations/SLPAPI.d.cts +12 -0
  20. package/dist/implementations/SLPAPI.d.cts.map +1 -1
  21. package/dist/implementations/SLPAPI.d.mts +12 -0
  22. package/dist/implementations/SLPAPI.d.mts.map +1 -1
  23. package/dist/implementations/SLPAPI.mjs +84 -0
  24. package/dist/implementations/SLPAPI.mjs.map +1 -1
  25. package/dist/implementations/SLPDataAPI.cjs +79 -2
  26. package/dist/implementations/SLPDataAPI.cjs.map +1 -1
  27. package/dist/implementations/SLPDataAPI.d.cts +6 -0
  28. package/dist/implementations/SLPDataAPI.d.cts.map +1 -1
  29. package/dist/implementations/SLPDataAPI.d.mts +6 -0
  30. package/dist/implementations/SLPDataAPI.d.mts.map +1 -1
  31. package/dist/implementations/SLPDataAPI.mjs +79 -2
  32. package/dist/implementations/SLPDataAPI.mjs.map +1 -1
  33. package/dist/implementations/USDZAPI.cjs +4 -13
  34. package/dist/implementations/USDZAPI.cjs.map +1 -1
  35. package/dist/implementations/USDZAPI.d.cts.map +1 -1
  36. package/dist/implementations/USDZAPI.d.mts.map +1 -1
  37. package/dist/implementations/USDZAPI.mjs +4 -13
  38. package/dist/implementations/USDZAPI.mjs.map +1 -1
  39. package/dist/implementations/USDZDataAPI.cjs +6 -3
  40. package/dist/implementations/USDZDataAPI.cjs.map +1 -1
  41. package/dist/implementations/USDZDataAPI.d.cts.map +1 -1
  42. package/dist/implementations/USDZDataAPI.d.mts.map +1 -1
  43. package/dist/implementations/USDZDataAPI.mjs +6 -3
  44. package/dist/implementations/USDZDataAPI.mjs.map +1 -1
  45. package/dist/implementations/ZBTCVCAPI.cjs +4 -13
  46. package/dist/implementations/ZBTCVCAPI.cjs.map +1 -1
  47. package/dist/implementations/ZBTCVCAPI.d.cts.map +1 -1
  48. package/dist/implementations/ZBTCVCAPI.d.mts.map +1 -1
  49. package/dist/implementations/ZBTCVCAPI.mjs +4 -13
  50. package/dist/implementations/ZBTCVCAPI.mjs.map +1 -1
  51. package/dist/implementations/ZBTCVCDataAPI.cjs +6 -2
  52. package/dist/implementations/ZBTCVCDataAPI.cjs.map +1 -1
  53. package/dist/implementations/ZBTCVCDataAPI.d.cts.map +1 -1
  54. package/dist/implementations/ZBTCVCDataAPI.d.mts.map +1 -1
  55. package/dist/implementations/ZBTCVCDataAPI.mjs +6 -2
  56. package/dist/implementations/ZBTCVCDataAPI.mjs.map +1 -1
  57. package/dist/implementations/ZLPAPI.cjs +103 -25
  58. package/dist/implementations/ZLPAPI.cjs.map +1 -1
  59. package/dist/implementations/ZLPAPI.d.cts +13 -3
  60. package/dist/implementations/ZLPAPI.d.cts.map +1 -1
  61. package/dist/implementations/ZLPAPI.d.mts +13 -3
  62. package/dist/implementations/ZLPAPI.d.mts.map +1 -1
  63. package/dist/implementations/ZLPAPI.mjs +103 -25
  64. package/dist/implementations/ZLPAPI.mjs.map +1 -1
  65. package/dist/implementations/ZLPDataAPI.cjs +89 -4
  66. package/dist/implementations/ZLPDataAPI.cjs.map +1 -1
  67. package/dist/implementations/ZLPDataAPI.d.cts +6 -3
  68. package/dist/implementations/ZLPDataAPI.d.cts.map +1 -1
  69. package/dist/implementations/ZLPDataAPI.d.mts +6 -3
  70. package/dist/implementations/ZLPDataAPI.d.mts.map +1 -1
  71. package/dist/implementations/ZLPDataAPI.mjs +89 -4
  72. package/dist/implementations/ZLPDataAPI.mjs.map +1 -1
  73. package/dist/interfaces/base.d.cts +2 -2
  74. package/dist/interfaces/base.d.cts.map +1 -1
  75. package/dist/interfaces/base.d.mts +2 -2
  76. package/dist/interfaces/base.d.mts.map +1 -1
  77. package/dist/interfaces/slp.d.cts +1 -0
  78. package/dist/interfaces/slp.d.cts.map +1 -1
  79. package/dist/interfaces/slp.d.mts +1 -0
  80. package/dist/interfaces/slp.d.mts.map +1 -1
  81. package/dist/interfaces/zlp.d.cts +1 -0
  82. package/dist/interfaces/zlp.d.cts.map +1 -1
  83. package/dist/interfaces/zlp.d.mts +1 -0
  84. package/dist/interfaces/zlp.d.mts.map +1 -1
  85. package/dist/oracle.cjs +1 -0
  86. package/dist/oracle.cjs.map +1 -1
  87. package/dist/oracle.d.cts +1 -0
  88. package/dist/oracle.d.cts.map +1 -1
  89. package/dist/oracle.d.mts +1 -0
  90. package/dist/oracle.d.mts.map +1 -1
  91. package/dist/oracle.mjs +2 -1
  92. package/dist/oracle.mjs.map +1 -1
  93. package/package.json +9 -9
  94. package/src/consts/deployments-shared-mainnet.json +50 -0
  95. package/src/consts/deployments-shared-testnet.json +45 -0
  96. package/src/consts/index.ts +15 -1
  97. package/src/implementations/SLPAPI.ts +104 -0
  98. package/src/implementations/SLPDataAPI.ts +112 -15
  99. package/src/implementations/USDZAPI.ts +5 -17
  100. package/src/implementations/USDZDataAPI.ts +11 -5
  101. package/src/implementations/ZBTCVCAPI.ts +5 -17
  102. package/src/implementations/ZBTCVCDataAPI.ts +11 -4
  103. package/src/implementations/ZLPAPI.ts +124 -27
  104. package/src/implementations/ZLPDataAPI.ts +117 -4
  105. package/src/interfaces/slp.ts +4 -1
  106. package/src/interfaces/zlp.ts +1 -0
  107. package/src/oracle.ts +3 -1
@@ -379,6 +379,110 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
379
379
  return tx
380
380
  }
381
381
 
382
+ /**
383
+ * Stakes SLP tokens in ZO staking pools
384
+ */
385
+ public stakeV2(
386
+ lpCoinObjects: string[],
387
+ amount: bigint,
388
+ pool: string,
389
+ tx?: Transaction,
390
+ ): Transaction {
391
+ if (!tx) {
392
+ tx = new Transaction()
393
+ }
394
+
395
+ const coinObject = this.processCoins(tx, 'slp', lpCoinObjects)
396
+ const [depositObject] = tx.splitCoins(coinObject, [tx.pure.u64(amount)])
397
+
398
+ tx.moveCall({
399
+ target: `${this.sharedConfig.zoStaking.package}::pool::deposit`,
400
+ typeArguments: [
401
+ `${this.consts.sudoCore.package}::slp::SLP`,
402
+ `${this.consts.sudoCore.package}::slp::SLP`,
403
+ ],
404
+ arguments: [
405
+ tx.object(pool),
406
+ tx.object(SUI_CLOCK_OBJECT_ID),
407
+ depositObject,
408
+ ],
409
+ })
410
+ return tx
411
+ }
412
+
413
+ /**
414
+ * Stakes SLP tokens using coin object only (PTB)
415
+ */
416
+ public stakeCoinObjectV2(
417
+ coinObject: any,
418
+ pool: string,
419
+ tx?: Transaction,
420
+ ): Transaction {
421
+ if (!tx) {
422
+ tx = new Transaction()
423
+ }
424
+
425
+ tx.moveCall({
426
+ target: `${this.sharedConfig.zoStaking.package}::pool::deposit`,
427
+ typeArguments: [
428
+ `${this.consts.sudoCore.package}::slp::SLP`,
429
+ `${this.consts.sudoCore.package}::slp::SLP`,
430
+ ],
431
+ arguments: [
432
+ tx.object(pool),
433
+ tx.object(SUI_CLOCK_OBJECT_ID),
434
+ coinObject,
435
+ ],
436
+ })
437
+ return tx
438
+ }
439
+
440
+ /**
441
+ * Unstakes SLP tokens from ZO staking pools
442
+ */
443
+ public unstakeV2(
444
+ credentials: ISLPCredential[],
445
+ amount: bigint,
446
+ pool: string,
447
+ tx?: Transaction,
448
+ ): Transaction {
449
+ let unstakeAmount = amount
450
+ if (!tx) {
451
+ tx = new Transaction()
452
+ }
453
+ for (const credential of credentials) {
454
+ const withdrawAmount = (() => {
455
+ const min = (a: bigint, b: bigint) => a < b ? a : b
456
+ return min(unstakeAmount, credential.amount)
457
+ })()
458
+ unstakeAmount -= withdrawAmount
459
+ tx.moveCall({
460
+ target: `${this.sharedConfig.zoStaking.package}::pool::withdraw`,
461
+ typeArguments: [
462
+ `${this.consts.sudoCore.package}::slp::SLP`,
463
+ `${this.consts.sudoCore.package}::slp::SLP`,
464
+ ],
465
+ arguments: [
466
+ tx.object(pool),
467
+ tx.object(SUI_CLOCK_OBJECT_ID),
468
+ tx.object(credential.id),
469
+ tx.pure.u64(withdrawAmount),
470
+ ],
471
+ })
472
+ if (credential.amount === BigInt(0)) {
473
+ tx.moveCall({
474
+ target: `${this.sharedConfig.zoStaking.package}::pool::clear_empty_credential`,
475
+ typeArguments: [
476
+ `${this.consts.sudoCore.package}::slp::SLP`,
477
+ `${this.consts.sudoCore.package}::slp::SLP`,
478
+ ],
479
+ arguments: [tx.object(credential.id)],
480
+ })
481
+ }
482
+ }
483
+ return tx
484
+ }
485
+
382
486
  /**
383
487
  * Opens a position using Sudo SDK approach
384
488
  */
@@ -339,11 +339,9 @@ export class SLPDataAPI extends BaseDataAPI implements ISLPDataAPI {
339
339
  const positionRaw = await this.provider.getDynamicFieldObject({
340
340
  parentId: this.consts.sudoCore.positionsParent,
341
341
  name: {
342
- type: `${this.consts.sudoCore.package}::market::PositionName<${
343
- positionCapInfo.symbol0
344
- }, ${positionCapInfo.symbol1}, ${
345
- this.consts.sudoCore.package
346
- }::market::${positionCapInfo.long ? 'LONG' : 'SHORT'}>`,
342
+ type: `${this.consts.sudoCore.package}::market::PositionName<${positionCapInfo.symbol0
343
+ }, ${positionCapInfo.symbol1}, ${this.consts.sudoCore.package
344
+ }::market::${positionCapInfo.long ? 'LONG' : 'SHORT'}>`,
347
345
  value: {
348
346
  owner,
349
347
  id: positionCapInfo.positionCapId,
@@ -463,6 +461,9 @@ export class SLPDataAPI extends BaseDataAPI implements ISLPDataAPI {
463
461
  }
464
462
  }
465
463
 
464
+ /**
465
+ * Legacy method: Get stake pool from sudo_staking
466
+ */
466
467
  public async getStakePool(): Promise<ISLPStakePool> {
467
468
  const raw = await this.provider.getObject({
468
469
  id: this.consts.sudoStaking.pool,
@@ -473,6 +474,70 @@ export class SLPDataAPI extends BaseDataAPI implements ISLPDataAPI {
473
474
  return SLPDataAPI.parseStakePool(raw)
474
475
  }
475
476
 
477
+ public async getStakePoolV2(): Promise<ISLPStakePool> {
478
+ const poolId = this.sharedConfig.zoStaking.pools.SLP
479
+ const raw = await this.provider.getObject({
480
+ id: poolId,
481
+ options: {
482
+ showContent: true,
483
+ },
484
+ })
485
+ return SLPDataAPI.parseStakePool(raw)
486
+ }
487
+
488
+ public async getStakedV2(owner: string): Promise<ISLPStaked> {
489
+ let rawCredentialsData: any[] = []
490
+ let queryNextPage = true
491
+ let queryCursor
492
+ const limit = 50
493
+
494
+ while (queryNextPage) {
495
+ const { data, hasNextPage, nextCursor } = await this.provider.getOwnedObjects({
496
+ owner,
497
+ filter: {
498
+ MoveModule: {
499
+ package: this.sharedConfig.zoStaking.package,
500
+ module: 'pool',
501
+ },
502
+ },
503
+ options: {
504
+ showType: true,
505
+ showContent: true,
506
+ },
507
+ cursor: queryCursor,
508
+ limit,
509
+ })
510
+
511
+ queryNextPage = hasNextPage
512
+ queryCursor = nextCursor!
513
+ if (!data)
514
+ break
515
+ rawCredentialsData = [...rawCredentialsData, ...data]
516
+ }
517
+
518
+ const pool = await this.getStakePoolV2()
519
+
520
+ const credentials = rawCredentialsData
521
+ .filter(
522
+ (item: any) =>
523
+ item.data.type ===
524
+ `${this.sharedConfig.zoStaking.package}::pool::Credential<${this.consts.sudoCore.package}::slp::SLP, ${this.consts.sudoCore.package}::slp::SLP>`
525
+ ).map((item: any) =>
526
+ SLPDataAPI.parseCredential(item, pool),
527
+ )
528
+ return {
529
+ credentials,
530
+ amount: credentials.reduce(
531
+ (acc: bigint, cur: ISLPCredential) => acc + cur.amount,
532
+ BigInt(0),
533
+ ),
534
+ claimable: credentials.reduce(
535
+ (acc: bigint, cur: ISLPCredential) => acc + cur.claimable,
536
+ BigInt(0),
537
+ ),
538
+ }
539
+ }
540
+
476
541
  public async fundingFeeRate(indexToken: string, long: boolean, sender?: string): Promise<number> {
477
542
  if (!sender) {
478
543
  throw new Error('Sender address is required for fundingFeeRate calculation')
@@ -835,13 +900,10 @@ export class SLPDataAPI extends BaseDataAPI implements ISLPDataAPI {
835
900
  const orderRaw = await this.provider.getDynamicFieldObject({
836
901
  parentId: this.consts.sudoCore.ordersParent,
837
902
  name: {
838
- type: `${this.consts.sudoCore.package}::market::OrderName<${
839
- orderCapInfo.symbol0
840
- }, ${orderCapInfo.symbol1}, ${
841
- this.consts.sudoCore.package
842
- }::market::${orderCapInfo.long ? 'LONG' : 'SHORT'}, ${
843
- this.consts.coins.sui.module
844
- }>`,
903
+ type: `${this.consts.sudoCore.package}::market::OrderName<${orderCapInfo.symbol0
904
+ }, ${orderCapInfo.symbol1}, ${this.consts.sudoCore.package
905
+ }::market::${orderCapInfo.long ? 'LONG' : 'SHORT'}, ${this.consts.coins.sui.module
906
+ }>`,
845
907
  value: {
846
908
  owner,
847
909
  id: orderCapInfo.orderCapId,
@@ -1197,21 +1259,36 @@ export class SLPDataAPI extends BaseDataAPI implements ISLPDataAPI {
1197
1259
 
1198
1260
  private static parseStakePool(raw: any): ISLPStakePool {
1199
1261
  const content = raw.data.content.fields
1200
- const pool = {
1262
+
1263
+ // Check if this is the new version with reward_vault and reward_rate
1264
+ const isNewVersion = content.reward_vault !== undefined && content.reward_rate !== undefined
1265
+
1266
+ const pool: ISLPStakePool = {
1201
1267
  id: content.id.id,
1202
1268
  enabled: content.enabled,
1203
1269
  lastUpdatedTime: parseValue(content.last_updated_time),
1204
1270
  stakedAmount: BigInt(content.staked_amount),
1205
- reward: BigInt(content.reward),
1271
+ // Support both old 'reward' and new 'reward_vault' field names
1272
+ reward: BigInt(content.reward_vault || content.reward),
1206
1273
  startTime: parseValue(content.start_time),
1207
1274
  endTime: parseValue(content.end_time),
1208
1275
  accRewardPerShare: BigInt(content.acc_reward_per_share),
1209
1276
  lockDuration: parseValue(content.lock_duration),
1277
+ // Add rewardRate if available (new version)
1278
+ ...(isNewVersion && { rewardRate: BigInt(content.reward_rate) }),
1210
1279
  }
1211
- SLPDataAPI.refreshPool(pool, Math.floor(Date.now() / 1000))
1280
+
1281
+ // Use appropriate refresh method based on version
1282
+ if (isNewVersion) {
1283
+ SLPDataAPI.refreshPoolV2(pool, Math.floor(Date.now() / 1000))
1284
+ } else {
1285
+ SLPDataAPI.refreshPool(pool, Math.floor(Date.now() / 1000))
1286
+ }
1287
+
1212
1288
  return pool
1213
1289
  }
1214
1290
 
1291
+ // Legacy refresh method for backward compatibility
1215
1292
  private static refreshPool(pool: ISLPStakePool, timestamp: number): void {
1216
1293
  if (timestamp === pool.lastUpdatedTime || timestamp < pool.startTime) {
1217
1294
  return
@@ -1234,4 +1311,24 @@ export class SLPDataAPI extends BaseDataAPI implements ISLPDataAPI {
1234
1311
  const rewardPerShare = (rewardAmount * BigInt(1e18)) / pool.stakedAmount
1235
1312
  pool.accRewardPerShare += rewardPerShare
1236
1313
  }
1314
+
1315
+ // New refresh method matching SLP implementation
1316
+ private static refreshPoolV2(pool: ISLPStakePool, timestamp: number): void {
1317
+ if (timestamp <= pool.lastUpdatedTime || timestamp < pool.startTime) {
1318
+ return
1319
+ }
1320
+
1321
+ const applicableEndTime = Math.max(pool.endTime, pool.lastUpdatedTime)
1322
+
1323
+ const calculationEndTime = Math.min(timestamp, applicableEndTime)
1324
+
1325
+ if (calculationEndTime > pool.lastUpdatedTime && pool.stakedAmount > BigInt(0) && pool.rewardRate && pool.rewardRate > BigInt(0)) {
1326
+ const timeDiff = BigInt(calculationEndTime - pool.lastUpdatedTime)
1327
+ const rewardAmount = timeDiff * pool.rewardRate
1328
+ const rewardPerShare = (rewardAmount * BigInt(1e18)) / pool.stakedAmount
1329
+ pool.accRewardPerShare += rewardPerShare
1330
+ }
1331
+
1332
+ pool.lastUpdatedTime = calculationEndTime
1333
+ }
1237
1334
  }
@@ -742,10 +742,6 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
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 USDZAPI extends BaseAPI implements IUSDZAPI {
754
750
  const [depositObject] = tx.splitCoins(coinObject, [tx.pure.u64(amount)])
755
751
 
756
752
  tx.moveCall({
757
- target: `${this.consts.zoStaking.package}::pool::deposit`,
753
+ target: `${this.sharedConfig.zoStaking.package}::pool::deposit`,
758
754
  typeArguments: [
759
755
  `${this.consts.zoCore.package}::usdz::USDZ`,
760
756
  `${this.consts.coins.sui.module}`,
@@ -776,16 +772,12 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
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.consts.zoStaking.package}::pool::deposit`,
780
+ target: `${this.sharedConfig.zoStaking.package}::pool::deposit`,
789
781
  typeArguments: [
790
782
  `${this.consts.zoCore.package}::usdz::USDZ`,
791
783
  `${this.consts.coins.sui.module}`,
@@ -808,10 +800,6 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
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 USDZAPI extends BaseAPI implements IUSDZAPI {
823
811
  })()
824
812
  unstakeAmount -= withdrawAmount
825
813
  tx.moveCall({
826
- target: `${this.consts.zoStaking.package}::pool::withdraw`,
814
+ target: `${this.sharedConfig.zoStaking.package}::pool::withdraw`,
827
815
  typeArguments: [
828
816
  `${this.consts.zoCore.package}::usdz::USDZ`,
829
817
  `${this.consts.coins.sui.module}`,
@@ -837,10 +825,10 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
837
825
  })
838
826
  if (credential.amount === BigInt(0)) {
839
827
  tx.moveCall({
840
- target: `${this.consts.zoStaking.package}::pool::clear_empty_credential`,
828
+ target: `${this.sharedConfig.zoStaking.package}::pool::clear_empty_credential`,
841
829
  typeArguments: [
842
830
  `${this.consts.zoCore.package}::usdz::USDZ`,
843
- `${this.consts.coins.sui.module}`,
831
+ `${this.consts.coins.sui.module}`,
844
832
  ],
845
833
  arguments: [tx.object(credential.id)],
846
834
  })
@@ -55,7 +55,7 @@ export class USDZDataAPI extends BaseDataAPI implements IUSDZDataAPI {
55
55
  owner,
56
56
  filter: {
57
57
  MoveModule: {
58
- package: this.consts.zoStaking.package,
58
+ package: this.sharedConfig.zoStaking.package,
59
59
  module: 'pool',
60
60
  },
61
61
  },
@@ -76,9 +76,14 @@ export class USDZDataAPI extends BaseDataAPI implements IUSDZDataAPI {
76
76
 
77
77
  const pool = await this.getStakePool()
78
78
 
79
- const credentials = rawCredentialsData.map((item: any) =>
80
- USDZDataAPI.parseCredential(item, pool),
81
- )
79
+ const credentials = rawCredentialsData
80
+ .filter(
81
+ (item: any) =>
82
+ item.data.type ===
83
+ `${this.sharedConfig.zoStaking.package}::pool::Credential<${this.consts.zoCore.package}::usdz::USDZ, 0x2::sui::SUI>`
84
+ ).map((item: any) =>
85
+ USDZDataAPI.parseCredential(item, pool),
86
+ )
82
87
  return {
83
88
  credentials,
84
89
  amount: credentials.reduce(
@@ -93,8 +98,9 @@ export class USDZDataAPI extends BaseDataAPI implements IUSDZDataAPI {
93
98
  }
94
99
 
95
100
  public async getStakePool(): Promise<IUSDZStakePool> {
101
+ const poolId = this.sharedConfig.zoStaking.pools.USDZ
96
102
  const raw = await this.provider.getObject({
97
- id: this.consts.zoStaking.pools[0],
103
+ id: poolId,
98
104
  options: {
99
105
  showContent: true,
100
106
  },
@@ -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.consts.zoStaking.package}::pool::deposit`,
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.consts.zoStaking.package}::pool::deposit`,
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.consts.zoStaking.package}::pool::withdraw`,
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.consts.zoStaking.package}::pool::clear_empty_credential`,
828
+ target: `${this.sharedConfig.zoStaking.package}::pool::clear_empty_credential`,
841
829
  typeArguments: [
842
830
  `${this.consts.zoCore.package}::zbtcvc::ZBTCVC`,
843
- `${this.consts.coins.sui.module}`,
831
+ `${this.consts.coins.sui.module}`,
844
832
  ],
845
833
  arguments: [tx.object(credential.id)],
846
834
  })
@@ -76,9 +76,15 @@ export class ZBTCVCDataAPI extends BaseDataAPI implements IZBTCVCDataAPI {
76
76
 
77
77
  const pool = await this.getStakePool()
78
78
 
79
- const credentials = rawCredentialsData.map((item: any) =>
80
- ZBTCVCDataAPI.parseCredential(item, pool),
81
- )
79
+ // TODO: Update reward coin type once available
80
+ const credentials = rawCredentialsData
81
+ .filter(
82
+ (item: any) =>
83
+ item.data.type ===
84
+ `${this.sharedConfig.zoStaking.package}::pool::Credential<${this.consts.zoCore.package}::zbtcvc::ZBTCVC, 0x2::sui::SUI>`
85
+ ).map((item: any) =>
86
+ ZBTCVCDataAPI.parseCredential(item, pool),
87
+ )
82
88
  return {
83
89
  credentials,
84
90
  amount: credentials.reduce(
@@ -93,8 +99,9 @@ export class ZBTCVCDataAPI extends BaseDataAPI implements IZBTCVCDataAPI {
93
99
  }
94
100
 
95
101
  public async getStakePool(): Promise<IZBTCVCStakePool> {
102
+ const poolId = this.consts.zoStaking.pools.ZBTCVC
96
103
  const raw = await this.provider.getObject({
97
- id: this.consts.zoStaking.pools[0],
104
+ id: poolId,
98
105
  options: {
99
106
  showContent: true,
100
107
  },