zo-sdk 0.1.31 → 0.1.33

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 (55) hide show
  1. package/dist/consts/deployments-shared-mainnet.json +1 -0
  2. package/dist/implementations/SLPAPI.cjs +107 -72
  3. package/dist/implementations/SLPAPI.cjs.map +1 -1
  4. package/dist/implementations/SLPAPI.d.cts +19 -10
  5. package/dist/implementations/SLPAPI.d.cts.map +1 -1
  6. package/dist/implementations/SLPAPI.d.mts +19 -10
  7. package/dist/implementations/SLPAPI.d.mts.map +1 -1
  8. package/dist/implementations/SLPAPI.mjs +107 -72
  9. package/dist/implementations/SLPAPI.mjs.map +1 -1
  10. package/dist/implementations/USDZAPI.cjs +43 -4
  11. package/dist/implementations/USDZAPI.cjs.map +1 -1
  12. package/dist/implementations/USDZAPI.d.cts +13 -2
  13. package/dist/implementations/USDZAPI.d.cts.map +1 -1
  14. package/dist/implementations/USDZAPI.d.mts +13 -2
  15. package/dist/implementations/USDZAPI.d.mts.map +1 -1
  16. package/dist/implementations/USDZAPI.mjs +43 -4
  17. package/dist/implementations/USDZAPI.mjs.map +1 -1
  18. package/dist/implementations/ZBTCVCAPI.cjs +4 -4
  19. package/dist/implementations/ZBTCVCAPI.cjs.map +1 -1
  20. package/dist/implementations/ZBTCVCAPI.mjs +4 -4
  21. package/dist/implementations/ZBTCVCAPI.mjs.map +1 -1
  22. package/dist/implementations/ZLPAPI.cjs +100 -4
  23. package/dist/implementations/ZLPAPI.cjs.map +1 -1
  24. package/dist/implementations/ZLPAPI.d.cts +14 -0
  25. package/dist/implementations/ZLPAPI.d.cts.map +1 -1
  26. package/dist/implementations/ZLPAPI.d.mts +14 -0
  27. package/dist/implementations/ZLPAPI.d.mts.map +1 -1
  28. package/dist/implementations/ZLPAPI.mjs +100 -4
  29. package/dist/implementations/ZLPAPI.mjs.map +1 -1
  30. package/dist/interfaces/slp.d.cts +5 -1
  31. package/dist/interfaces/slp.d.cts.map +1 -1
  32. package/dist/interfaces/slp.d.mts +5 -1
  33. package/dist/interfaces/slp.d.mts.map +1 -1
  34. package/dist/interfaces/usdz.d.cts +5 -3
  35. package/dist/interfaces/usdz.d.cts.map +1 -1
  36. package/dist/interfaces/usdz.d.mts +5 -3
  37. package/dist/interfaces/usdz.d.mts.map +1 -1
  38. package/dist/interfaces/zbtcvc.d.cts +3 -3
  39. package/dist/interfaces/zbtcvc.d.cts.map +1 -1
  40. package/dist/interfaces/zbtcvc.d.mts +3 -3
  41. package/dist/interfaces/zbtcvc.d.mts.map +1 -1
  42. package/dist/interfaces/zlp.d.cts +5 -1
  43. package/dist/interfaces/zlp.d.cts.map +1 -1
  44. package/dist/interfaces/zlp.d.mts +5 -1
  45. package/dist/interfaces/zlp.d.mts.map +1 -1
  46. package/package.json +1 -1
  47. package/src/consts/deployments-shared-mainnet.json +1 -0
  48. package/src/implementations/SLPAPI.ts +142 -86
  49. package/src/implementations/USDZAPI.ts +57 -6
  50. package/src/implementations/ZBTCVCAPI.ts +4 -4
  51. package/src/implementations/ZLPAPI.ts +135 -4
  52. package/src/interfaces/slp.ts +31 -1
  53. package/src/interfaces/usdz.ts +18 -4
  54. package/src/interfaces/zbtcvc.ts +5 -4
  55. package/src/interfaces/zlp.ts +32 -1
@@ -223,6 +223,87 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
223
223
  return tx
224
224
  }
225
225
 
226
+ /**
227
+ * Deposits collateral into ZLP vault and returns a coin
228
+ */
229
+ public async depositPtb(
230
+ coin: string,
231
+ coinObjects: string[],
232
+ amount: number,
233
+ minAmountOut = 0,
234
+ referralAddress?: string,
235
+ sender?: string,
236
+ tx?: Transaction,
237
+ sponsoredTx?: boolean,
238
+ suiCoinObjectsForPythUpdate?: string[],
239
+ ): Promise<TransactionObjectArgument> {
240
+ if (!tx) {
241
+ tx = new Transaction()
242
+ }
243
+
244
+ // Add referral if needed
245
+ if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
246
+ tx = await this.addReferral(referralAddress, tx)
247
+ }
248
+
249
+ // Initialize oracle transaction
250
+ const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder)
251
+
252
+ // Handle sponsored transaction case
253
+ if (sponsoredTx) {
254
+ const suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
255
+ tx = await this.initOracleTxb(pythFeederKeys, tx, true, suiCoinObject)
256
+
257
+ // Process deposit coins
258
+ const depositObject = coin === 'sui'
259
+ ? tx.splitCoins(suiCoinObject, [tx.pure.u64(amount)])[0]
260
+ : tx.splitCoins(this.processCoins(tx, coin, coinObjects, true), [tx.pure.u64(amount)])[0]
261
+
262
+ const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
263
+
264
+ const [mintedCoin] = tx.moveCall({
265
+ target: `${this.consts.zoCore.upgradedPackage}::market::deposit_ptb`,
266
+ typeArguments: [`${this.consts.zoCore.package}::zlp::ZLP`, this.consts.coins[coin].module],
267
+ arguments: [
268
+ tx.object(this.consts.zoCore.market),
269
+ tx.object(this.consts.zoCore.rebaseFeeModel),
270
+ depositObject,
271
+ tx.pure.u64(minAmountOut),
272
+ vaultsValuation,
273
+ symbolsValuation,
274
+ ],
275
+ })
276
+ return mintedCoin
277
+ }
278
+
279
+ // Handle non-sponsored transaction case
280
+ tx = await this.initOracleTxb(pythFeederKeys, tx)
281
+ const depositObject = tx.splitCoins(
282
+ this.processCoins(tx, coin, coinObjects, false),
283
+ [tx.pure.u64(amount)],
284
+ )[0]
285
+
286
+ const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
287
+
288
+ const [mintedCoin] = tx.moveCall({
289
+ target: `${this.consts.zoCore.upgradedPackage}::market::deposit_ptb`,
290
+ typeArguments: [
291
+ `${this.consts.zoCore.package}::zlp::ZLP`,
292
+ this.consts.coins[coin].module,
293
+ ],
294
+ arguments: [
295
+ tx.object(this.consts.zoCore.market),
296
+ tx.object(this.consts.zoCore.rebaseFeeModel),
297
+ depositObject,
298
+ tx.pure.u64(minAmountOut),
299
+ vaultsValuation,
300
+ symbolsValuation,
301
+ ],
302
+ })
303
+
304
+ return mintedCoin
305
+ }
306
+
226
307
  public async depositWithPtb(
227
308
  coin: string,
228
309
  depositObject: TransactionObjectArgument,
@@ -397,7 +478,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
397
478
  const [depositObject] = tx.splitCoins(coinObject, [tx.pure.u64(amount)])
398
479
 
399
480
  tx.moveCall({
400
- target: `${this.sharedConfig.zoStaking.package}::pool::deposit`,
481
+ target: `${this.sharedConfig.zoStaking.upgradedPackage}::pool::deposit`,
401
482
  typeArguments: [
402
483
  `${this.consts.zoCore.package}::zlp::ZLP`,
403
484
  `${this.consts.coins.sui.module}`,
@@ -424,7 +505,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
424
505
  }
425
506
 
426
507
  tx.moveCall({
427
- target: `${this.sharedConfig.zoStaking.package}::pool::deposit`,
508
+ target: `${this.sharedConfig.zoStaking.upgradedPackage}::pool::deposit`,
428
509
  typeArguments: [
429
510
  `${this.consts.zoCore.package}::zlp::ZLP`,
430
511
  `${this.consts.coins.sui.module}`,
@@ -458,7 +539,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
458
539
  })()
459
540
  unstakeAmount -= withdrawAmount
460
541
  tx.moveCall({
461
- target: `${this.sharedConfig.zoStaking.package}::pool::withdraw`,
542
+ target: `${this.sharedConfig.zoStaking.upgradedPackage}::pool::withdraw`,
462
543
  typeArguments: [
463
544
  `${this.consts.zoCore.package}::zlp::ZLP`,
464
545
  `${this.consts.coins.sui.module}`,
@@ -472,7 +553,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
472
553
  })
473
554
  if (credential.amount === BigInt(0)) {
474
555
  tx.moveCall({
475
- target: `${this.sharedConfig.zoStaking.package}::pool::clear_empty_credential`,
556
+ target: `${this.sharedConfig.zoStaking.upgradedPackage}::pool::clear_empty_credential`,
476
557
  typeArguments: [
477
558
  `${this.consts.zoCore.package}::zlp::ZLP`,
478
559
  `${this.consts.coins.sui.module}`,
@@ -484,6 +565,56 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
484
565
  return tx
485
566
  }
486
567
 
568
+ /**
569
+ * Withdraws ZLP tokens from a staking pool credential (PTB)
570
+ * Returns the withdrawn coin object for use in programmable transaction blocks
571
+ */
572
+ public withdrawFromVaultPtb(
573
+ pool: string,
574
+ credential: string,
575
+ withdrawAmount: bigint,
576
+ tx: Transaction,
577
+ ): TransactionObjectArgument {
578
+ const [withdrawnCoin] = tx.moveCall({
579
+ target: `${this.sharedConfig.zoStaking.upgradedPackage}::pool::withdraw_ptb`,
580
+ typeArguments: [
581
+ `${this.consts.zoCore.package}::zlp::ZLP`,
582
+ `${this.consts.coins.sui.module}`,
583
+ ],
584
+ arguments: [
585
+ tx.object(pool),
586
+ tx.object(SUI_CLOCK_OBJECT_ID),
587
+ tx.object(credential),
588
+ tx.pure.u64(withdrawAmount),
589
+ ],
590
+ })
591
+ return withdrawnCoin
592
+ }
593
+
594
+ /**
595
+ * Claims rewards from a staking pool credential (PTB)
596
+ * Returns the reward coin object for use in programmable transaction blocks
597
+ */
598
+ public claimRewardsPtb(
599
+ pool: string,
600
+ credential: string,
601
+ tx: Transaction,
602
+ ): TransactionObjectArgument {
603
+ const [rewardCoin] = tx.moveCall({
604
+ target: `${this.sharedConfig.zoStaking.upgradedPackage}::pool::claim_rewards_ptb`,
605
+ typeArguments: [
606
+ `${this.consts.zoCore.package}::zlp::ZLP`,
607
+ `${this.consts.coins.sui.module}`,
608
+ ],
609
+ arguments: [
610
+ tx.object(pool),
611
+ tx.object(SUI_CLOCK_OBJECT_ID),
612
+ tx.object(credential),
613
+ ],
614
+ })
615
+ return rewardCoin
616
+ }
617
+
487
618
  public async swap(
488
619
  fromToken: string,
489
620
  toToken: string,
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import type { KioskClient, KioskOwnerCap } from '@mysten/kiosk'
7
- import type { Transaction } from '@mysten/sui/transactions'
7
+ import type { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions'
8
8
 
9
9
  import type {
10
10
  IBaseAPI,
@@ -182,4 +182,34 @@ export interface ISLPAPI extends IBaseAPI {
182
182
  kioskCap: KioskOwnerCap,
183
183
  scard: string
184
184
  ) => Transaction
185
+ depositPtb: (
186
+ coin: string,
187
+ coinObjects: string[],
188
+ amount: number,
189
+ minAmountOut?: number,
190
+ referralAddress?: string,
191
+ sender?: string,
192
+ tx?: Transaction,
193
+ sponsoredTx?: boolean,
194
+ suiCoinObjectsForPythUpdate?: string[],
195
+ ) => Promise<TransactionObjectArgument>
196
+
197
+ stakeCoinObject: (
198
+ coinObject: TransactionObjectArgument,
199
+ pool: string,
200
+ tx?: Transaction,
201
+ ) => Transaction
202
+
203
+ withdrawFromVaultPtb: (
204
+ pool: string,
205
+ credential: string,
206
+ withdrawAmount: bigint,
207
+ tx: Transaction,
208
+ ) => TransactionObjectArgument
209
+
210
+ claimRewardsPtb: (
211
+ pool: string,
212
+ credential: string,
213
+ tx: Transaction,
214
+ ) => TransactionObjectArgument
185
215
  }
@@ -3,7 +3,7 @@
3
3
  * Extends base interfaces with USDZ-specific implementations
4
4
  */
5
5
 
6
- import type { Transaction } from '@mysten/sui/transactions'
6
+ import type { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions'
7
7
 
8
8
  import type {
9
9
  IBaseAPI,
@@ -106,10 +106,24 @@ export interface IUSDZAPI extends IBaseAPI {
106
106
  tx?: Transaction,
107
107
  sponsoredTx?: boolean,
108
108
  suiCoinObjectsForPythUpdate?: string[],
109
- ) => Promise<any>
109
+ ) => Promise<TransactionObjectArgument>
110
+
110
111
  stakeCoinObject: (
111
- coinObject: any,
112
+ coinObject: TransactionObjectArgument,
112
113
  pool: string,
113
114
  tx?: Transaction,
114
- ) => any
115
+ ) => Transaction
116
+
117
+ withdrawFromVaultPtb: (
118
+ pool: string,
119
+ credential: string,
120
+ withdrawAmount: bigint,
121
+ tx: Transaction,
122
+ ) => TransactionObjectArgument
123
+
124
+ claimRewardsPtb: (
125
+ pool: string,
126
+ credential: string,
127
+ tx: Transaction,
128
+ ) => TransactionObjectArgument
115
129
  }
@@ -3,7 +3,7 @@
3
3
  * Extends base interfaces with USDZ-specific implementations
4
4
  */
5
5
 
6
- import type { Transaction } from '@mysten/sui/transactions'
6
+ import type { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions'
7
7
 
8
8
  import type {
9
9
  IBaseAPI,
@@ -106,10 +106,11 @@ export interface IZBTCVCAPI extends IBaseAPI {
106
106
  tx?: Transaction,
107
107
  sponsoredTx?: boolean,
108
108
  suiCoinObjectsForPythUpdate?: string[],
109
- ) => Promise<any>
109
+ ) => Promise<TransactionObjectArgument>
110
+
110
111
  stakeCoinObject: (
111
- coinObject: any,
112
+ coinObject: TransactionObjectArgument,
112
113
  pool: string,
113
114
  tx?: Transaction,
114
- ) => any
115
+ ) => Transaction
115
116
  }
@@ -3,7 +3,7 @@
3
3
  * Extends base interfaces with ZLP-specific implementations
4
4
  */
5
5
 
6
- import type { Transaction } from '@mysten/sui/transactions'
6
+ import type { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions'
7
7
 
8
8
  import type {
9
9
  IBaseAPI,
@@ -134,4 +134,35 @@ export interface IZLPAPI extends IBaseAPI {
134
134
  coin: string,
135
135
  lootbox: string
136
136
  ) => Transaction
137
+
138
+ depositPtb: (
139
+ coin: string,
140
+ coinObjects: string[],
141
+ amount: number,
142
+ minAmountOut?: number,
143
+ referralAddress?: string,
144
+ sender?: string,
145
+ tx?: Transaction,
146
+ sponsoredTx?: boolean,
147
+ suiCoinObjectsForPythUpdate?: string[],
148
+ ) => Promise<TransactionObjectArgument>
149
+
150
+ stakeCoinObject: (
151
+ coinObject: TransactionObjectArgument,
152
+ pool: string,
153
+ tx?: Transaction,
154
+ ) => Transaction
155
+
156
+ withdrawFromVaultPtb: (
157
+ pool: string,
158
+ credential: string,
159
+ withdrawAmount: bigint,
160
+ tx: Transaction,
161
+ ) => TransactionObjectArgument
162
+
163
+ claimRewardsPtb: (
164
+ pool: string,
165
+ credential: string,
166
+ tx: Transaction,
167
+ ) => TransactionObjectArgument
137
168
  }