@zofai/zo-sdk 0.2.29 → 0.2.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.
Files changed (41) hide show
  1. package/dist/consts/deployments-zlp-mainnet.json +1 -1
  2. package/dist/consts/deployments-zo-oracle-mainnet.json +18 -1
  3. package/dist/implementations/ZLPAPI.cjs +456 -123
  4. package/dist/implementations/ZLPAPI.cjs.map +1 -1
  5. package/dist/implementations/ZLPAPI.d.cts +46 -1
  6. package/dist/implementations/ZLPAPI.d.cts.map +1 -1
  7. package/dist/implementations/ZLPAPI.d.mts +46 -1
  8. package/dist/implementations/ZLPAPI.d.mts.map +1 -1
  9. package/dist/implementations/ZLPAPI.mjs +457 -124
  10. package/dist/implementations/ZLPAPI.mjs.map +1 -1
  11. package/dist/implementations/ZLPDataAPI.cjs +38 -0
  12. package/dist/implementations/ZLPDataAPI.cjs.map +1 -1
  13. package/dist/implementations/ZLPDataAPI.d.cts +16 -0
  14. package/dist/implementations/ZLPDataAPI.d.cts.map +1 -1
  15. package/dist/implementations/ZLPDataAPI.d.mts +16 -0
  16. package/dist/implementations/ZLPDataAPI.d.mts.map +1 -1
  17. package/dist/implementations/ZLPDataAPI.mjs +38 -0
  18. package/dist/implementations/ZLPDataAPI.mjs.map +1 -1
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +1 -0
  21. package/dist/index.d.cts.map +1 -1
  22. package/dist/index.d.mts +1 -0
  23. package/dist/index.d.mts.map +1 -1
  24. package/dist/index.mjs.map +1 -1
  25. package/dist/interfaces/zlp.d.cts +19 -0
  26. package/dist/interfaces/zlp.d.cts.map +1 -1
  27. package/dist/interfaces/zlp.d.mts +19 -0
  28. package/dist/interfaces/zlp.d.mts.map +1 -1
  29. package/docs/api-reference.md +45 -0
  30. package/docs/architecture.md +21 -3
  31. package/docs/common-operations.md +56 -8
  32. package/docs/getting-started.md +8 -3
  33. package/docs/lp-specific-features.md +89 -12
  34. package/docs/swap-integration.md +52 -20
  35. package/package.json +1 -1
  36. package/src/consts/deployments-zlp-mainnet.json +1 -1
  37. package/src/consts/deployments-zo-oracle-mainnet.json +18 -1
  38. package/src/implementations/ZLPAPI.ts +760 -151
  39. package/src/implementations/ZLPDataAPI.ts +42 -0
  40. package/src/index.ts +1 -0
  41. package/src/interfaces/zlp.ts +170 -0
@@ -35,6 +35,8 @@ import type {
35
35
  IZLPSymbolInfo,
36
36
  IZLPVaultInfo,
37
37
  } from '../interfaces'
38
+ import type { OracleInputs } from '../oraclePro'
39
+ import { valuateSymbolsV2, valuateVaultsV2 } from '../oraclePro'
38
40
  import type { DynamicFieldInfo, SuiClient } from '../suiClient'
39
41
  import { joinSymbol, parseSymbolKey, parseValue, suiSymbolToSymbol } from '../utils'
40
42
 
@@ -204,6 +206,46 @@ export class ZLPDataAPI extends BaseDataAPI implements IZLPDataAPI {
204
206
  return { vaultsValuation, symbolsValuation }
205
207
  }
206
208
 
209
+ /**
210
+ * Creates vaults valuation using valuate_vault_v2 (Pyth Pro + Stork).
211
+ */
212
+ public valuateVaultsV2(tx: Transaction, oracle: OracleInputs) {
213
+ return valuateVaultsV2({
214
+ tx,
215
+ upgradedPackage: this.consts.zoCore.upgradedPackage,
216
+ lpType: `${this.consts.zoCore.package}::zlp::ZLP`,
217
+ market: this.consts.zoCore.market,
218
+ vaults: this.consts.zoCore.vaults,
219
+ coinModules: this.consts.coins,
220
+ oracle,
221
+ })
222
+ }
223
+
224
+ /**
225
+ * Creates symbols valuation using valuate_symbol_v2 (Pyth Pro + Stork).
226
+ */
227
+ public valuateSymbolsV2(tx: Transaction, oracle: OracleInputs) {
228
+ return valuateSymbolsV2({
229
+ tx,
230
+ upgradedPackage: this.consts.zoCore.upgradedPackage,
231
+ marketPackage: this.consts.zoCore.package,
232
+ lpType: `${this.consts.zoCore.package}::zlp::ZLP`,
233
+ market: this.consts.zoCore.market,
234
+ symbols: this.consts.zoCore.symbols,
235
+ coinModules: this.consts.coins,
236
+ oracle,
237
+ })
238
+ }
239
+
240
+ /**
241
+ * Creates both vaults and symbols valuation (Pyth Pro + Stork).
242
+ */
243
+ public valuateV2(tx: Transaction, oracle: OracleInputs) {
244
+ const vaultsValuation = this.valuateVaultsV2(tx, oracle)
245
+ const symbolsValuation = this.valuateSymbolsV2(tx, oracle)
246
+ return { vaultsValuation, symbolsValuation }
247
+ }
248
+
207
249
  /**
208
250
  * Valuates the ZLP market
209
251
  */
package/src/index.ts CHANGED
@@ -30,6 +30,7 @@ export * from './consts'
30
30
  export * from './data'
31
31
  export * from './oracle'
32
32
  export * from './oraclePro'
33
+ export type { PythProChannel } from './pythProClient'
33
34
  export * from './storkClient'
34
35
  export * from './storkOracle'
35
36
  export * from './utils'
@@ -5,6 +5,7 @@
5
5
 
6
6
  import type { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions'
7
7
 
8
+ import type { OracleInputs } from '../oraclePro'
8
9
  import type {
9
10
  IBaseAPI,
10
11
  IBaseCredential,
@@ -139,6 +140,9 @@ export interface IZLPDataAPI extends IBaseDataAPI {
139
140
  getSymbolConfig: (indexToken: string, long: boolean) => Promise<IZLPSymbolConfig | null>
140
141
  getPriceImpactConfig: (indexToken: string) => Promise<IZLPPriceImpactConfig | null>
141
142
  calculateSwapFeeBreakdown: (fromToken: string, toToken: string, fromAmount: number) => Promise<ISwapFeeBreakdown>
143
+ valuateVaultsV2: (tx: Transaction, oracle: OracleInputs) => TransactionObjectArgument
144
+ valuateSymbolsV2: (tx: Transaction, oracle: OracleInputs) => TransactionObjectArgument
145
+ valuateV2: (tx: Transaction, oracle: OracleInputs) => { vaultsValuation: TransactionObjectArgument, symbolsValuation: TransactionObjectArgument }
142
146
  }
143
147
 
144
148
  // ZLP-specific API interface
@@ -262,4 +266,170 @@ export interface IZLPAPI extends IBaseAPI {
262
266
  minAmountOut?: number,
263
267
  tx?: Transaction,
264
268
  ) => Promise<TransactionObjectArgument>
269
+
270
+ /** Pyth Pro + Stork swap (transfers output). */
271
+ swapV3: (
272
+ fromToken: string,
273
+ toToken: string,
274
+ fromAmount: bigint,
275
+ fromCoinObjects: string[],
276
+ pythProUpdateBytes: Uint8Array | number[],
277
+ minAmountOut?: number,
278
+ tx?: Transaction,
279
+ ) => Promise<Transaction>
280
+
281
+ /** Pyth Pro + Stork swap PTB (returns output coin). */
282
+ swapV3Ptb: (
283
+ fromToken: string,
284
+ toToken: string,
285
+ fromAmount: bigint,
286
+ fromCoinObjects: string[],
287
+ pythProUpdateBytes: Uint8Array | number[],
288
+ minAmountOut?: number,
289
+ tx?: Transaction,
290
+ ) => Promise<TransactionObjectArgument>
291
+
292
+ openPositionV3: (
293
+ collateralToken: string,
294
+ indexToken: string,
295
+ size: bigint,
296
+ collateralAmount: bigint,
297
+ coinObjects: string[],
298
+ long: boolean,
299
+ reserveAmount: bigint,
300
+ indexPrice: number,
301
+ collateralPrice: number,
302
+ pythProUpdateBytes: Uint8Array | number[],
303
+ isLimitOrder?: boolean,
304
+ isIocOrder?: boolean,
305
+ pricesSlippage?: number,
306
+ collateralSlippage?: number,
307
+ relayerFee?: bigint,
308
+ referralAddress?: string,
309
+ sender?: string,
310
+ sponsoredTx?: boolean,
311
+ ) => Promise<Transaction>
312
+
313
+ openPositionWithSCardV3: (
314
+ collateralToken: string,
315
+ indexToken: string,
316
+ size: bigint,
317
+ collateralAmount: bigint,
318
+ coinObjects: string[],
319
+ long: boolean,
320
+ reserveAmount: bigint,
321
+ indexPrice: number,
322
+ collateralPrice: number,
323
+ kioskClient: import('@mysten/kiosk').KioskClient,
324
+ kioskCap: import('@mysten/kiosk').KioskOwnerCap,
325
+ scard: string,
326
+ pythProUpdateBytes: Uint8Array | number[],
327
+ isLimitOrder?: boolean,
328
+ isIocOrder?: boolean,
329
+ pricesSlippage?: number,
330
+ collateralSlippage?: number,
331
+ relayerFee?: bigint,
332
+ referralAddress?: string,
333
+ sender?: string,
334
+ sponsoredTx?: boolean,
335
+ ) => Promise<Transaction>
336
+
337
+ openPositionWithCoinV3: (
338
+ collateralToken: string,
339
+ indexToken: string,
340
+ size: bigint,
341
+ coinObj: TransactionObjectArgument,
342
+ long: boolean,
343
+ reserveAmount: bigint,
344
+ indexPrice: number,
345
+ collateralPrice: number,
346
+ pythProUpdateBytes: Uint8Array | number[],
347
+ isLimitOrder?: boolean,
348
+ isIocOrder?: boolean,
349
+ pricesSlippage?: number,
350
+ collateralSlippage?: number,
351
+ relayerFee?: bigint,
352
+ referralAddress?: string,
353
+ sender?: string,
354
+ tx?: Transaction,
355
+ sponsoredTx?: boolean,
356
+ ) => Promise<Transaction>
357
+
358
+ openPositionWithCoinAndSCardV3: (
359
+ collateralToken: string,
360
+ indexToken: string,
361
+ size: bigint,
362
+ coinObj: TransactionObjectArgument,
363
+ long: boolean,
364
+ reserveAmount: bigint,
365
+ indexPrice: number,
366
+ collateralPrice: number,
367
+ kioskClient: import('@mysten/kiosk').KioskClient,
368
+ kioskCap: import('@mysten/kiosk').KioskOwnerCap,
369
+ scard: string,
370
+ pythProUpdateBytes: Uint8Array | number[],
371
+ isLimitOrder?: boolean,
372
+ isIocOrder?: boolean,
373
+ pricesSlippage?: number,
374
+ collateralSlippage?: number,
375
+ relayerFee?: bigint,
376
+ referralAddress?: string,
377
+ sender?: string,
378
+ tx?: Transaction,
379
+ sponsoredTx?: boolean,
380
+ ) => Promise<Transaction>
381
+
382
+ decreasePositionV3: (
383
+ pcpId: string,
384
+ collateralToken: string,
385
+ indexToken: string,
386
+ amount: bigint,
387
+ long: boolean,
388
+ indexPrice: number,
389
+ collateralPrice: number,
390
+ pythProUpdateBytes: Uint8Array | number[],
391
+ isTriggerOrder?: boolean,
392
+ isTakeProfitOrder?: boolean,
393
+ isIocOrder?: boolean,
394
+ pricesSlippage?: number,
395
+ collateralSlippage?: number,
396
+ relayerFee?: bigint,
397
+ coinObjects?: string[],
398
+ sponsoredTx?: boolean,
399
+ sender?: string,
400
+ ) => Promise<Transaction>
401
+
402
+ decreasePositionWithSCardV3: (
403
+ pcpId: string,
404
+ collateralToken: string,
405
+ indexToken: string,
406
+ amount: bigint,
407
+ long: boolean,
408
+ indexPrice: number,
409
+ collateralPrice: number,
410
+ kioskClient: import('@mysten/kiosk').KioskClient,
411
+ kioskCap: import('@mysten/kiosk').KioskOwnerCap,
412
+ scard: string,
413
+ pythProUpdateBytes: Uint8Array | number[],
414
+ isTriggerOrder?: boolean,
415
+ isTakeProfitOrder?: boolean,
416
+ isIocOrder?: boolean,
417
+ pricesSlippage?: number,
418
+ collateralSlippage?: number,
419
+ relayerFee?: bigint,
420
+ coinObjects?: string[],
421
+ sponsoredTx?: boolean,
422
+ sender?: string,
423
+ ) => Promise<Transaction>
424
+
425
+ /** Pyth Pro path (not legacy feeder v2). */
426
+ redeemFromPositionV2: (
427
+ pcpId: string,
428
+ collateralToken: string,
429
+ indexToken: string,
430
+ amount: number,
431
+ long: boolean,
432
+ pythProUpdateBytes: Uint8Array | number[],
433
+ tx?: Transaction,
434
+ ) => Promise<Transaction>
265
435
  }