zo-sdk 0.1.28 → 0.1.30
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/implementations/SLPAPI.cjs +85 -0
- package/dist/implementations/SLPAPI.cjs.map +1 -1
- package/dist/implementations/SLPAPI.d.cts +3 -1
- package/dist/implementations/SLPAPI.d.cts.map +1 -1
- package/dist/implementations/SLPAPI.d.mts +3 -1
- package/dist/implementations/SLPAPI.d.mts.map +1 -1
- package/dist/implementations/SLPAPI.mjs +85 -0
- package/dist/implementations/SLPAPI.mjs.map +1 -1
- package/dist/implementations/ZLPAPI.cjs +82 -0
- package/dist/implementations/ZLPAPI.cjs.map +1 -1
- package/dist/implementations/ZLPAPI.d.cts +3 -1
- package/dist/implementations/ZLPAPI.d.cts.map +1 -1
- package/dist/implementations/ZLPAPI.d.mts +3 -1
- package/dist/implementations/ZLPAPI.d.mts.map +1 -1
- package/dist/implementations/ZLPAPI.mjs +82 -0
- package/dist/implementations/ZLPAPI.mjs.map +1 -1
- package/package.json +1 -1
- package/src/consts/deployments-slp-mainnet.json +1 -1
- package/src/implementations/SLPAPI.ts +117 -1
- package/src/implementations/ZLPAPI.ts +113 -1
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import type { KioskClient, KioskOwnerCap } from '@mysten/kiosk'
|
|
7
7
|
import { KioskTransaction } from '@mysten/kiosk'
|
|
8
8
|
import type { SuiClient } from '@mysten/sui/client'
|
|
9
|
-
import { Transaction } from '@mysten/sui/transactions'
|
|
9
|
+
import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions'
|
|
10
10
|
import { SUI_CLOCK_OBJECT_ID } from '@mysten/sui/utils'
|
|
11
11
|
|
|
12
12
|
import { BaseAPI } from '../abstract'
|
|
@@ -223,6 +223,73 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
223
223
|
return tx
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
+
public async depositWithPtb(
|
|
227
|
+
coin: string,
|
|
228
|
+
depositObject: TransactionObjectArgument,
|
|
229
|
+
minAmountOut = 0,
|
|
230
|
+
referralAddress?: string,
|
|
231
|
+
sender?: string,
|
|
232
|
+
tx?: Transaction,
|
|
233
|
+
sponsoredTx?: boolean,
|
|
234
|
+
suiCoinObjectsForPythUpdate?: string[],
|
|
235
|
+
): Promise<Transaction> {
|
|
236
|
+
if (!tx) {
|
|
237
|
+
tx = new Transaction()
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// Add referral if needed
|
|
241
|
+
if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
|
|
242
|
+
tx = await this.addReferral(referralAddress, tx)
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// Initialize oracle transaction
|
|
246
|
+
const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder)
|
|
247
|
+
|
|
248
|
+
// Handle sponsored transaction case
|
|
249
|
+
if (sponsoredTx) {
|
|
250
|
+
const suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
|
|
251
|
+
tx = await this.initOracleTxb(pythFeederKeys, tx, true, suiCoinObject)
|
|
252
|
+
|
|
253
|
+
const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
|
|
254
|
+
|
|
255
|
+
tx.moveCall({
|
|
256
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::deposit`,
|
|
257
|
+
typeArguments: [`${this.consts.zoCore.package}::zlp::ZLP`, this.consts.coins[coin].module],
|
|
258
|
+
arguments: [
|
|
259
|
+
tx.object(this.consts.zoCore.market),
|
|
260
|
+
tx.object(this.consts.zoCore.rebaseFeeModel),
|
|
261
|
+
depositObject,
|
|
262
|
+
tx.pure.u64(minAmountOut),
|
|
263
|
+
vaultsValuation,
|
|
264
|
+
symbolsValuation,
|
|
265
|
+
],
|
|
266
|
+
})
|
|
267
|
+
return tx
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Handle non-sponsored transaction case
|
|
271
|
+
tx = await this.initOracleTxb(pythFeederKeys, tx)
|
|
272
|
+
|
|
273
|
+
const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
|
|
274
|
+
|
|
275
|
+
tx.moveCall({
|
|
276
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::deposit`,
|
|
277
|
+
typeArguments: [
|
|
278
|
+
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
279
|
+
this.consts.coins[coin].module,
|
|
280
|
+
],
|
|
281
|
+
arguments: [
|
|
282
|
+
tx.object(this.consts.zoCore.market),
|
|
283
|
+
tx.object(this.consts.zoCore.rebaseFeeModel),
|
|
284
|
+
depositObject,
|
|
285
|
+
tx.pure.u64(minAmountOut),
|
|
286
|
+
vaultsValuation,
|
|
287
|
+
symbolsValuation,
|
|
288
|
+
],
|
|
289
|
+
})
|
|
290
|
+
return tx
|
|
291
|
+
}
|
|
292
|
+
|
|
226
293
|
/**
|
|
227
294
|
* Withdraws collateral from ZLP vault
|
|
228
295
|
*/
|
|
@@ -268,6 +335,51 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
268
335
|
return tx
|
|
269
336
|
}
|
|
270
337
|
|
|
338
|
+
public async withdrawPtb(
|
|
339
|
+
coin: string,
|
|
340
|
+
lpCoinObjects: string[],
|
|
341
|
+
amount: number,
|
|
342
|
+
minAmountOut = 0,
|
|
343
|
+
tx?: Transaction,
|
|
344
|
+
sponsoredTx?: boolean,
|
|
345
|
+
suiCoinObjectsForPythUpdate?: string[],
|
|
346
|
+
): Promise<TransactionObjectArgument> {
|
|
347
|
+
if (!tx) {
|
|
348
|
+
tx = new Transaction()
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// Initialize oracle transaction
|
|
352
|
+
const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder)
|
|
353
|
+
|
|
354
|
+
if (sponsoredTx) {
|
|
355
|
+
const suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
|
|
356
|
+
tx = await this.initOracleTxb(pythFeederKeys, tx, true, suiCoinObject)
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
tx = await this.initOracleTxb(pythFeederKeys, tx)
|
|
360
|
+
}
|
|
361
|
+
const zlpCoinObject = this.processCoins(tx, 'zlp', lpCoinObjects, false)
|
|
362
|
+
const [withdrawObject] = tx.splitCoins(zlpCoinObject, [tx.pure.u64(amount)])
|
|
363
|
+
const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
|
|
364
|
+
|
|
365
|
+
const [withdrawCoin] = tx.moveCall({
|
|
366
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::withdraw_ptb`,
|
|
367
|
+
typeArguments: [
|
|
368
|
+
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
369
|
+
this.consts.coins[coin].module,
|
|
370
|
+
],
|
|
371
|
+
arguments: [
|
|
372
|
+
tx.object(this.consts.zoCore.market),
|
|
373
|
+
tx.object(this.consts.zoCore.rebaseFeeModel),
|
|
374
|
+
withdrawObject,
|
|
375
|
+
tx.pure.u64(minAmountOut),
|
|
376
|
+
vaultsValuation,
|
|
377
|
+
symbolsValuation,
|
|
378
|
+
],
|
|
379
|
+
})
|
|
380
|
+
return withdrawCoin
|
|
381
|
+
}
|
|
382
|
+
|
|
271
383
|
/**
|
|
272
384
|
* Stakes ZLP tokens in ZO staking pools
|
|
273
385
|
*/
|