zo-sdk 0.1.7 → 0.1.9
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/abstract/BaseAPI.cjs +10 -0
- package/dist/abstract/BaseAPI.cjs.map +1 -1
- package/dist/abstract/BaseAPI.d.cts +10 -3
- package/dist/abstract/BaseAPI.d.cts.map +1 -1
- package/dist/abstract/BaseAPI.d.mts +10 -3
- package/dist/abstract/BaseAPI.d.mts.map +1 -1
- package/dist/abstract/BaseAPI.mjs +10 -0
- package/dist/abstract/BaseAPI.mjs.map +1 -1
- package/dist/consts/deployments-slp-mainnet.json +9 -9
- package/dist/consts/deployments-zlp-mainnet.json +4 -4
- package/dist/implementations/SLPAPI.cjs +110 -38
- package/dist/implementations/SLPAPI.cjs.map +1 -1
- package/dist/implementations/SLPAPI.d.cts +9 -9
- package/dist/implementations/SLPAPI.d.cts.map +1 -1
- package/dist/implementations/SLPAPI.d.mts +9 -9
- package/dist/implementations/SLPAPI.d.mts.map +1 -1
- package/dist/implementations/SLPAPI.mjs +110 -38
- package/dist/implementations/SLPAPI.mjs.map +1 -1
- package/dist/implementations/SLPDataAPI.cjs +2 -0
- package/dist/implementations/SLPDataAPI.cjs.map +1 -1
- package/dist/implementations/SLPDataAPI.d.cts.map +1 -1
- package/dist/implementations/SLPDataAPI.d.mts.map +1 -1
- package/dist/implementations/SLPDataAPI.mjs +2 -0
- package/dist/implementations/SLPDataAPI.mjs.map +1 -1
- package/dist/implementations/USDZAPI.cjs +102 -40
- package/dist/implementations/USDZAPI.cjs.map +1 -1
- package/dist/implementations/USDZAPI.d.cts +9 -9
- package/dist/implementations/USDZAPI.d.cts.map +1 -1
- package/dist/implementations/USDZAPI.d.mts +9 -9
- package/dist/implementations/USDZAPI.d.mts.map +1 -1
- package/dist/implementations/USDZAPI.mjs +102 -40
- package/dist/implementations/USDZAPI.mjs.map +1 -1
- package/dist/implementations/USDZDataAPI.cjs +2 -0
- package/dist/implementations/USDZDataAPI.cjs.map +1 -1
- package/dist/implementations/USDZDataAPI.d.cts.map +1 -1
- package/dist/implementations/USDZDataAPI.d.mts.map +1 -1
- package/dist/implementations/USDZDataAPI.mjs +2 -0
- package/dist/implementations/USDZDataAPI.mjs.map +1 -1
- package/dist/implementations/ZLPAPI.cjs +100 -38
- package/dist/implementations/ZLPAPI.cjs.map +1 -1
- package/dist/implementations/ZLPAPI.d.cts +9 -9
- package/dist/implementations/ZLPAPI.d.cts.map +1 -1
- package/dist/implementations/ZLPAPI.d.mts +9 -9
- package/dist/implementations/ZLPAPI.d.mts.map +1 -1
- package/dist/implementations/ZLPAPI.mjs +100 -38
- package/dist/implementations/ZLPAPI.mjs.map +1 -1
- package/dist/implementations/ZLPDataAPI.cjs +2 -0
- package/dist/implementations/ZLPDataAPI.cjs.map +1 -1
- package/dist/implementations/ZLPDataAPI.d.cts.map +1 -1
- package/dist/implementations/ZLPDataAPI.d.mts.map +1 -1
- package/dist/implementations/ZLPDataAPI.mjs +2 -0
- package/dist/implementations/ZLPDataAPI.mjs.map +1 -1
- package/dist/interfaces/base.d.cts +5 -4
- package/dist/interfaces/base.d.cts.map +1 -1
- package/dist/interfaces/base.d.mts +5 -4
- package/dist/interfaces/base.d.mts.map +1 -1
- package/package.json +8 -8
- package/src/abstract/BaseAPI.ts +17 -3
- package/src/consts/deployments-slp-mainnet.json +9 -9
- package/src/consts/deployments-zlp-mainnet.json +4 -4
- package/src/implementations/SLPAPI.ts +169 -33
- package/src/implementations/SLPDataAPI.ts +2 -0
- package/src/implementations/USDZAPI.ts +174 -36
- package/src/implementations/USDZDataAPI.ts +2 -0
- package/src/implementations/ZLPAPI.ts +172 -31
- package/src/implementations/ZLPDataAPI.ts +2 -0
- package/src/interfaces/base.ts +9 -3
|
@@ -165,7 +165,6 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
165
165
|
sender?: string,
|
|
166
166
|
sponsoredTx?: boolean,
|
|
167
167
|
suiCoinObjectsForPythUpdate?: string[],
|
|
168
|
-
isDepositingSui?: boolean,
|
|
169
168
|
): Promise<Transaction> {
|
|
170
169
|
let tx = new Transaction()
|
|
171
170
|
|
|
@@ -183,7 +182,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
183
182
|
tx = await this.initOracleTxb(pythFeederKeys, tx, true, suiCoinObject)
|
|
184
183
|
|
|
185
184
|
// Process deposit coins
|
|
186
|
-
const depositObject =
|
|
185
|
+
const depositObject = coin === 'sui'
|
|
187
186
|
? tx.splitCoins(suiCoinObject, [tx.pure.u64(amount)])[0]
|
|
188
187
|
: tx.splitCoins(this.processCoins(tx, coin, coinObjects, true), [tx.pure.u64(amount)])[0]
|
|
189
188
|
|
|
@@ -326,17 +325,13 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
326
325
|
relayerFee = BigInt(0.5),
|
|
327
326
|
referralAddress?: string,
|
|
328
327
|
sender?: string,
|
|
328
|
+
sponsoredTx?: boolean,
|
|
329
|
+
suiCoinObjectsForPythUpdate?: string[],
|
|
329
330
|
): Promise<Transaction> {
|
|
330
331
|
let tx = new Transaction()
|
|
331
332
|
if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
|
|
332
333
|
tx = await this.addReferral(referralAddress, tx)
|
|
333
334
|
}
|
|
334
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
335
|
-
const coinObject = this.processCoins(tx, collateralToken, coinObjects)
|
|
336
|
-
const [depositObject, feeObject] = tx.splitCoins(coinObject, [
|
|
337
|
-
tx.pure.u64(collateralAmount),
|
|
338
|
-
tx.pure.u64(relayerFee),
|
|
339
|
-
])
|
|
340
335
|
|
|
341
336
|
const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
|
|
342
337
|
const adjustPrice = this.processSlippage(indexPrice, long, isLimitOrder ? 0 : pricesSlippage)
|
|
@@ -347,6 +342,26 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
347
342
|
allowTrade = isIocOrder ? ALLOW_TRADE_NO_TRADE : ALLOW_TRADE_CAN_TRADE
|
|
348
343
|
}
|
|
349
344
|
|
|
345
|
+
// Handle oracle initialization and coin processing
|
|
346
|
+
let suiCoinObject
|
|
347
|
+
if (sponsoredTx) {
|
|
348
|
+
suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
|
|
349
|
+
tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
|
|
350
|
+
}
|
|
351
|
+
else {
|
|
352
|
+
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// Process coin splitting
|
|
356
|
+
const [depositObject, feeObject] = this.processCoinSplitting(
|
|
357
|
+
tx,
|
|
358
|
+
collateralToken,
|
|
359
|
+
coinObjects,
|
|
360
|
+
[tx.pure.u64(collateralAmount), tx.pure.u64(relayerFee)],
|
|
361
|
+
sponsoredTx,
|
|
362
|
+
suiCoinObject,
|
|
363
|
+
)
|
|
364
|
+
|
|
350
365
|
tx.moveCall({
|
|
351
366
|
target: `${this.consts.zoCore.package}::market::open_position`,
|
|
352
367
|
typeArguments: [
|
|
@@ -373,6 +388,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
373
388
|
tx.pure.u256(adjustPrice),
|
|
374
389
|
],
|
|
375
390
|
})
|
|
391
|
+
|
|
376
392
|
return tx
|
|
377
393
|
}
|
|
378
394
|
|
|
@@ -394,14 +410,15 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
394
410
|
collateralSlippage = 0.5,
|
|
395
411
|
relayerFee = BigInt(0.5),
|
|
396
412
|
coinObjects?: string[],
|
|
413
|
+
sponsoredTx?: boolean,
|
|
414
|
+
suiCoinObjectsForPythUpdate?: string[],
|
|
397
415
|
): Promise<Transaction> {
|
|
398
416
|
if (!coinObjects) {
|
|
399
417
|
throw new Error(`${this.constructor.name}: coinObjects is required`)
|
|
400
418
|
}
|
|
401
|
-
|
|
419
|
+
|
|
420
|
+
let tx = new Transaction()
|
|
402
421
|
const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
|
|
403
|
-
const coinObject = this.processCoins(tx, collateralToken, coinObjects || [])
|
|
404
|
-
const feeObject = tx.splitCoins(coinObject, [tx.pure.u64(relayerFee)])
|
|
405
422
|
|
|
406
423
|
const adjustPrice = this.processSlippage(indexPrice, !long, isTriggerOrder ? 0 : pricesSlippage)
|
|
407
424
|
const adjustCollateralPrice = this.processSlippage(collateralPrice, false, collateralSlippage)
|
|
@@ -414,6 +431,26 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
414
431
|
isTakeProfitOrder = true
|
|
415
432
|
}
|
|
416
433
|
|
|
434
|
+
// Handle oracle initialization and coin processing
|
|
435
|
+
let suiCoinObject
|
|
436
|
+
if (sponsoredTx) {
|
|
437
|
+
suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
|
|
438
|
+
tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// Process coin splitting
|
|
445
|
+
const [feeObject] = this.processCoinSplitting(
|
|
446
|
+
tx,
|
|
447
|
+
collateralToken,
|
|
448
|
+
coinObjects,
|
|
449
|
+
[tx.pure.u64(relayerFee)],
|
|
450
|
+
sponsoredTx,
|
|
451
|
+
suiCoinObject,
|
|
452
|
+
)
|
|
453
|
+
|
|
417
454
|
tx.moveCall({
|
|
418
455
|
target: `${this.consts.zoCore.package}::market::decrease_position`,
|
|
419
456
|
typeArguments: [
|
|
@@ -458,11 +495,20 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
458
495
|
collateralSlippage?: number
|
|
459
496
|
relayerFee?: bigint
|
|
460
497
|
coinObjects?: string[]
|
|
461
|
-
}>, tx?: Transaction): Promise<Transaction> {
|
|
498
|
+
}>, tx?: Transaction, sponsoredTx?: boolean, suiCoinObjectsForPythUpdate?: string[]): Promise<Transaction> {
|
|
462
499
|
if (!tx) {
|
|
463
500
|
tx = new Transaction()
|
|
464
501
|
}
|
|
465
|
-
|
|
502
|
+
|
|
503
|
+
// Handle oracle initialization and coin processing
|
|
504
|
+
let suiCoinObject
|
|
505
|
+
if (sponsoredTx) {
|
|
506
|
+
suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
|
|
507
|
+
tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx, true, suiCoinObject)
|
|
508
|
+
}
|
|
509
|
+
else {
|
|
510
|
+
tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx)
|
|
511
|
+
}
|
|
466
512
|
|
|
467
513
|
for (const position of positions) {
|
|
468
514
|
const {
|
|
@@ -483,8 +529,6 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
483
529
|
} = position
|
|
484
530
|
let innerIsTakeProfitOrder = isTakeProfitOrder
|
|
485
531
|
const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
|
|
486
|
-
const coinObject = this.processCoins(tx, collateralToken, coinObjects)
|
|
487
|
-
const feeObject = tx.splitCoins(coinObject, [tx.pure.u64(relayerFee)])
|
|
488
532
|
|
|
489
533
|
const adjustPrice = this.processSlippage(indexPrice, !long, isTriggerOrder ? 0 : pricesSlippage)
|
|
490
534
|
const adjustCollateralPrice = this.processSlippage(collateralPrice, false, collateralSlippage)
|
|
@@ -497,6 +541,16 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
497
541
|
innerIsTakeProfitOrder = true
|
|
498
542
|
}
|
|
499
543
|
|
|
544
|
+
// Process coin splitting
|
|
545
|
+
const [feeObject] = this.processCoinSplitting(
|
|
546
|
+
tx,
|
|
547
|
+
collateralToken,
|
|
548
|
+
coinObjects,
|
|
549
|
+
[tx.pure.u64(relayerFee)],
|
|
550
|
+
sponsoredTx,
|
|
551
|
+
suiCoinObject,
|
|
552
|
+
)
|
|
553
|
+
|
|
500
554
|
tx.moveCall({
|
|
501
555
|
target: `${this.consts.zoCore.package}::market::decrease_position`,
|
|
502
556
|
typeArguments: [
|
|
@@ -546,17 +600,13 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
546
600
|
relayerFee = BigInt(0.5),
|
|
547
601
|
referralAddress?: string,
|
|
548
602
|
sender?: string,
|
|
603
|
+
sponsoredTx?: boolean,
|
|
604
|
+
suiCoinObjectsForPythUpdate?: string[],
|
|
549
605
|
): Promise<Transaction> {
|
|
550
606
|
let tx = new Transaction()
|
|
551
607
|
if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
|
|
552
608
|
tx = await this.addReferral(referralAddress, tx)
|
|
553
609
|
}
|
|
554
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
555
|
-
const coinObject = this.processCoins(tx, collateralToken, coinObjects)
|
|
556
|
-
const [depositObject, feeObject] = tx.splitCoins(coinObject, [
|
|
557
|
-
tx.pure.u64(collateralAmount),
|
|
558
|
-
tx.pure.u64(relayerFee),
|
|
559
|
-
])
|
|
560
610
|
|
|
561
611
|
const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
|
|
562
612
|
const adjustPrice = this.processSlippage(indexPrice, long, isLimitOrder ? 0 : pricesSlippage)
|
|
@@ -578,6 +628,26 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
578
628
|
itemId: scard,
|
|
579
629
|
})
|
|
580
630
|
|
|
631
|
+
// Handle oracle initialization and coin processing
|
|
632
|
+
let suiCoinObject
|
|
633
|
+
if (sponsoredTx) {
|
|
634
|
+
suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
|
|
635
|
+
tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
|
|
636
|
+
}
|
|
637
|
+
else {
|
|
638
|
+
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
// Process coin splitting
|
|
642
|
+
const [depositObject, feeObject] = this.processCoinSplitting(
|
|
643
|
+
tx,
|
|
644
|
+
collateralToken,
|
|
645
|
+
coinObjects,
|
|
646
|
+
[tx.pure.u64(collateralAmount), tx.pure.u64(relayerFee)],
|
|
647
|
+
sponsoredTx,
|
|
648
|
+
suiCoinObject,
|
|
649
|
+
)
|
|
650
|
+
|
|
581
651
|
tx.moveCall({
|
|
582
652
|
target: `${this.consts.zoCore.package}::market::open_position_with_scard`,
|
|
583
653
|
typeArguments: [
|
|
@@ -613,6 +683,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
613
683
|
promise,
|
|
614
684
|
})
|
|
615
685
|
.finalize()
|
|
686
|
+
|
|
616
687
|
return tx
|
|
617
688
|
}
|
|
618
689
|
|
|
@@ -634,11 +705,14 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
634
705
|
collateralSlippage = 0.5,
|
|
635
706
|
relayerFee = BigInt(0.5),
|
|
636
707
|
coinObjects?: string[],
|
|
708
|
+
sponsoredTx?: boolean,
|
|
709
|
+
suiCoinObjectsForPythUpdate?: string[],
|
|
637
710
|
): Promise<Transaction> {
|
|
638
711
|
if (!coinObjects) {
|
|
639
712
|
throw new Error(`${this.constructor.name}: coinObjects is required`)
|
|
640
713
|
}
|
|
641
|
-
|
|
714
|
+
|
|
715
|
+
let tx = new Transaction()
|
|
642
716
|
|
|
643
717
|
const kioskTx = new KioskTransaction({
|
|
644
718
|
transaction: tx,
|
|
@@ -652,8 +726,6 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
652
726
|
})
|
|
653
727
|
|
|
654
728
|
const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
|
|
655
|
-
const coinObject = this.processCoins(tx, collateralToken, coinObjects || [])
|
|
656
|
-
const feeObject = tx.splitCoins(coinObject, [tx.pure.u64(relayerFee)])
|
|
657
729
|
|
|
658
730
|
const adjustPrice = this.processSlippage(indexPrice, !long, isTriggerOrder ? 0 : pricesSlippage)
|
|
659
731
|
const adjustCollateralPrice = this.processSlippage(collateralPrice, false, collateralSlippage)
|
|
@@ -666,6 +738,26 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
666
738
|
isTakeProfitOrder = true
|
|
667
739
|
}
|
|
668
740
|
|
|
741
|
+
// Handle oracle initialization and coin processing
|
|
742
|
+
let suiCoinObject
|
|
743
|
+
if (sponsoredTx) {
|
|
744
|
+
suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
|
|
745
|
+
tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
|
|
746
|
+
}
|
|
747
|
+
else {
|
|
748
|
+
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
// Process coin splitting
|
|
752
|
+
const [feeObject] = this.processCoinSplitting(
|
|
753
|
+
tx,
|
|
754
|
+
collateralToken,
|
|
755
|
+
coinObjects,
|
|
756
|
+
[tx.pure.u64(relayerFee)],
|
|
757
|
+
sponsoredTx,
|
|
758
|
+
suiCoinObject,
|
|
759
|
+
)
|
|
760
|
+
|
|
669
761
|
tx.moveCall({
|
|
670
762
|
target: `${this.consts.zoCore.package}::market::decrease_position_with_scard`,
|
|
671
763
|
typeArguments: [
|
|
@@ -724,11 +816,22 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
724
816
|
kioskCap: KioskOwnerCap,
|
|
725
817
|
scard: string,
|
|
726
818
|
tx?: Transaction,
|
|
819
|
+
sponsoredTx?: boolean,
|
|
820
|
+
suiCoinObjectsForPythUpdate?: string[],
|
|
727
821
|
): Promise<Transaction> {
|
|
728
822
|
if (!tx) {
|
|
729
823
|
tx = new Transaction()
|
|
730
824
|
}
|
|
731
|
-
|
|
825
|
+
|
|
826
|
+
// Handle oracle initialization and coin processing
|
|
827
|
+
let suiCoinObject
|
|
828
|
+
if (sponsoredTx) {
|
|
829
|
+
suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
|
|
830
|
+
tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx, true, suiCoinObject)
|
|
831
|
+
}
|
|
832
|
+
else {
|
|
833
|
+
tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx)
|
|
834
|
+
}
|
|
732
835
|
|
|
733
836
|
const kioskTx = new KioskTransaction({
|
|
734
837
|
transaction: tx,
|
|
@@ -760,8 +863,6 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
760
863
|
} = position
|
|
761
864
|
let innerIsTakeProfitOrder = isTakeProfitOrder
|
|
762
865
|
const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
|
|
763
|
-
const coinObject = this.processCoins(tx, collateralToken, coinObjects || [])
|
|
764
|
-
const feeObject = tx.splitCoins(coinObject, [tx.pure.u64(relayerFee || BigInt(0.5))])
|
|
765
866
|
|
|
766
867
|
const adjustPrice = this.processSlippage(indexPrice, !long, isTriggerOrder ? 0 : pricesSlippage)
|
|
767
868
|
const adjustCollateralPrice = this.processSlippage(collateralPrice, false, collateralSlippage)
|
|
@@ -774,6 +875,16 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
774
875
|
innerIsTakeProfitOrder = true
|
|
775
876
|
}
|
|
776
877
|
|
|
878
|
+
// Process coin splitting
|
|
879
|
+
const [feeObject] = this.processCoinSplitting(
|
|
880
|
+
tx,
|
|
881
|
+
collateralToken,
|
|
882
|
+
coinObjects,
|
|
883
|
+
[tx.pure.u64(relayerFee)],
|
|
884
|
+
sponsoredTx,
|
|
885
|
+
suiCoinObject,
|
|
886
|
+
)
|
|
887
|
+
|
|
777
888
|
tx.moveCall({
|
|
778
889
|
target: `${this.consts.zoCore.package}::market::decrease_position_with_scard`,
|
|
779
890
|
typeArguments: [
|
|
@@ -822,10 +933,29 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
822
933
|
amount: number,
|
|
823
934
|
coinObjects: string[],
|
|
824
935
|
long: boolean,
|
|
936
|
+
sponsoredTx?: boolean,
|
|
937
|
+
suiCoinObjectsForPythUpdate?: string[],
|
|
825
938
|
): Promise<Transaction> {
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
939
|
+
let tx = new Transaction()
|
|
940
|
+
// Handle oracle initialization and coin processing
|
|
941
|
+
let suiCoinObject
|
|
942
|
+
if (sponsoredTx) {
|
|
943
|
+
suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
|
|
944
|
+
tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
|
|
945
|
+
}
|
|
946
|
+
else {
|
|
947
|
+
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
// Process coin splitting
|
|
951
|
+
const [depositObject] = this.processCoinSplitting(
|
|
952
|
+
tx,
|
|
953
|
+
collateralToken,
|
|
954
|
+
coinObjects,
|
|
955
|
+
[tx.pure.u64(amount)],
|
|
956
|
+
sponsoredTx,
|
|
957
|
+
suiCoinObject,
|
|
958
|
+
)
|
|
829
959
|
|
|
830
960
|
tx.moveCall({
|
|
831
961
|
target: `${this.consts.zoCore.package}::market::pledge_in_position`,
|
|
@@ -846,8 +976,19 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
846
976
|
indexToken: string,
|
|
847
977
|
amount: number,
|
|
848
978
|
long: boolean,
|
|
979
|
+
sponsoredTx?: boolean,
|
|
980
|
+
suiCoinObjectsForPythUpdate?: string[],
|
|
849
981
|
): Promise<Transaction> {
|
|
850
|
-
|
|
982
|
+
let tx = new Transaction()
|
|
983
|
+
// Handle oracle initialization and coin processing
|
|
984
|
+
let suiCoinObject
|
|
985
|
+
if (sponsoredTx) {
|
|
986
|
+
suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
|
|
987
|
+
tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
|
|
988
|
+
}
|
|
989
|
+
else {
|
|
990
|
+
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
991
|
+
}
|
|
851
992
|
const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
|
|
852
993
|
|
|
853
994
|
tx.moveCall({
|
|
@@ -688,6 +688,7 @@ export class ZLPDataAPI extends BaseDataAPI implements IZLPDataAPI {
|
|
|
688
688
|
}
|
|
689
689
|
|
|
690
690
|
private async parseSymbolInfo(raw: any, long: boolean): Promise<IZLPSymbolInfo> {
|
|
691
|
+
const { objectId } = raw.data
|
|
691
692
|
const { fields } = raw.data.content.fields.value
|
|
692
693
|
const fundingFeeModelAddr = fields.funding_fee_model
|
|
693
694
|
const fundingFeeModelRaw = await this.provider.getObject({
|
|
@@ -699,6 +700,7 @@ export class ZLPDataAPI extends BaseDataAPI implements IZLPDataAPI {
|
|
|
699
700
|
const fundingFeeModel = ZLPDataAPI.parseFundingFeeModel(fundingFeeModelRaw)
|
|
700
701
|
|
|
701
702
|
return {
|
|
703
|
+
objectId,
|
|
702
704
|
openingSize: parseValue(fields.opening_size),
|
|
703
705
|
openingAmount: parseValue(fields.opening_amount),
|
|
704
706
|
accFundingRate: parseValue(fields.acc_funding_rate),
|
package/src/interfaces/base.ts
CHANGED
|
@@ -62,6 +62,7 @@ export interface IBaseRebaseFeeModel {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
export interface IBaseSymbolInfo {
|
|
65
|
+
objectId: string
|
|
65
66
|
openingSize: number
|
|
66
67
|
openingAmount: number
|
|
67
68
|
accFundingRate: number
|
|
@@ -271,7 +272,6 @@ export interface IBaseAPI {
|
|
|
271
272
|
sender?: string,
|
|
272
273
|
sponsoredTx?: boolean,
|
|
273
274
|
suiCoinObjectsForPythUpdate?: string[],
|
|
274
|
-
isDepositingSui?: boolean,
|
|
275
275
|
) => Promise<Transaction>
|
|
276
276
|
|
|
277
277
|
withdraw: (
|
|
@@ -322,7 +322,9 @@ export interface IBaseAPI {
|
|
|
322
322
|
collateralSlippage?: number,
|
|
323
323
|
relayerFee?: bigint,
|
|
324
324
|
referralAddress?: string,
|
|
325
|
-
sender?: string
|
|
325
|
+
sender?: string,
|
|
326
|
+
sponsoredTx?: boolean,
|
|
327
|
+
suiCoinObjectsForPythUpdate?: string[],
|
|
326
328
|
) => Promise<Transaction>
|
|
327
329
|
|
|
328
330
|
decreasePosition: (
|
|
@@ -339,7 +341,9 @@ export interface IBaseAPI {
|
|
|
339
341
|
pricesSlippage?: number,
|
|
340
342
|
collateralSlippage?: number,
|
|
341
343
|
relayerFee?: bigint,
|
|
342
|
-
coinObjects?: string[]
|
|
344
|
+
coinObjects?: string[],
|
|
345
|
+
sponsoredTx?: boolean,
|
|
346
|
+
suiCoinObjectsForPythUpdate?: string[],
|
|
343
347
|
) => Promise<Transaction>
|
|
344
348
|
|
|
345
349
|
decreaseMultiPositions: (
|
|
@@ -447,6 +451,8 @@ export interface IBaseAPI {
|
|
|
447
451
|
relayerFee?: bigint,
|
|
448
452
|
referralAddress?: string,
|
|
449
453
|
sender?: string,
|
|
454
|
+
sponsoredTx?: boolean,
|
|
455
|
+
suiCoinObjectsForPythUpdate?: string[],
|
|
450
456
|
) => Promise<Transaction>
|
|
451
457
|
|
|
452
458
|
decreasePositionWithSCard: (
|