zo-sdk 0.1.31 → 0.1.32
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/consts/deployments-shared-mainnet.json +1 -0
- package/dist/implementations/SLPAPI.cjs +106 -71
- package/dist/implementations/SLPAPI.cjs.map +1 -1
- package/dist/implementations/SLPAPI.d.cts +19 -10
- package/dist/implementations/SLPAPI.d.cts.map +1 -1
- package/dist/implementations/SLPAPI.d.mts +19 -10
- package/dist/implementations/SLPAPI.d.mts.map +1 -1
- package/dist/implementations/SLPAPI.mjs +106 -71
- package/dist/implementations/SLPAPI.mjs.map +1 -1
- package/dist/implementations/USDZAPI.cjs +43 -4
- package/dist/implementations/USDZAPI.cjs.map +1 -1
- package/dist/implementations/USDZAPI.d.cts +13 -2
- package/dist/implementations/USDZAPI.d.cts.map +1 -1
- package/dist/implementations/USDZAPI.d.mts +13 -2
- package/dist/implementations/USDZAPI.d.mts.map +1 -1
- package/dist/implementations/USDZAPI.mjs +43 -4
- package/dist/implementations/USDZAPI.mjs.map +1 -1
- package/dist/implementations/ZBTCVCAPI.cjs +4 -4
- package/dist/implementations/ZBTCVCAPI.cjs.map +1 -1
- package/dist/implementations/ZBTCVCAPI.mjs +4 -4
- package/dist/implementations/ZBTCVCAPI.mjs.map +1 -1
- package/dist/implementations/ZLPAPI.cjs +100 -4
- package/dist/implementations/ZLPAPI.cjs.map +1 -1
- package/dist/implementations/ZLPAPI.d.cts +14 -0
- package/dist/implementations/ZLPAPI.d.cts.map +1 -1
- package/dist/implementations/ZLPAPI.d.mts +14 -0
- package/dist/implementations/ZLPAPI.d.mts.map +1 -1
- package/dist/implementations/ZLPAPI.mjs +100 -4
- package/dist/implementations/ZLPAPI.mjs.map +1 -1
- package/dist/interfaces/slp.d.cts +5 -1
- package/dist/interfaces/slp.d.cts.map +1 -1
- package/dist/interfaces/slp.d.mts +5 -1
- package/dist/interfaces/slp.d.mts.map +1 -1
- package/dist/interfaces/usdz.d.cts +5 -3
- package/dist/interfaces/usdz.d.cts.map +1 -1
- package/dist/interfaces/usdz.d.mts +5 -3
- package/dist/interfaces/usdz.d.mts.map +1 -1
- package/dist/interfaces/zbtcvc.d.cts +3 -3
- package/dist/interfaces/zbtcvc.d.cts.map +1 -1
- package/dist/interfaces/zbtcvc.d.mts +3 -3
- package/dist/interfaces/zbtcvc.d.mts.map +1 -1
- package/dist/interfaces/zlp.d.cts +5 -1
- package/dist/interfaces/zlp.d.cts.map +1 -1
- package/dist/interfaces/zlp.d.mts +5 -1
- package/dist/interfaces/zlp.d.mts.map +1 -1
- package/package.json +1 -1
- package/src/consts/deployments-shared-mainnet.json +1 -0
- package/src/implementations/SLPAPI.ts +141 -85
- package/src/implementations/USDZAPI.ts +57 -6
- package/src/implementations/ZBTCVCAPI.ts +4 -4
- package/src/implementations/ZLPAPI.ts +135 -4
- package/src/interfaces/slp.ts +31 -1
- package/src/interfaces/usdz.ts +18 -4
- package/src/interfaces/zbtcvc.ts +5 -4
- 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.
|
|
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.
|
|
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.
|
|
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.
|
|
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,
|
package/src/interfaces/slp.ts
CHANGED
|
@@ -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
|
}
|
package/src/interfaces/usdz.ts
CHANGED
|
@@ -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<
|
|
109
|
+
) => Promise<TransactionObjectArgument>
|
|
110
|
+
|
|
110
111
|
stakeCoinObject: (
|
|
111
|
-
coinObject:
|
|
112
|
+
coinObject: TransactionObjectArgument,
|
|
112
113
|
pool: string,
|
|
113
114
|
tx?: Transaction,
|
|
114
|
-
) =>
|
|
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
|
}
|
package/src/interfaces/zbtcvc.ts
CHANGED
|
@@ -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<
|
|
109
|
+
) => Promise<TransactionObjectArgument>
|
|
110
|
+
|
|
110
111
|
stakeCoinObject: (
|
|
111
|
-
coinObject:
|
|
112
|
+
coinObject: TransactionObjectArgument,
|
|
112
113
|
pool: string,
|
|
113
114
|
tx?: Transaction,
|
|
114
|
-
) =>
|
|
115
|
+
) => Transaction
|
|
115
116
|
}
|
package/src/interfaces/zlp.ts
CHANGED
|
@@ -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
|
}
|