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.
Files changed (67) hide show
  1. package/dist/abstract/BaseAPI.cjs +10 -0
  2. package/dist/abstract/BaseAPI.cjs.map +1 -1
  3. package/dist/abstract/BaseAPI.d.cts +10 -3
  4. package/dist/abstract/BaseAPI.d.cts.map +1 -1
  5. package/dist/abstract/BaseAPI.d.mts +10 -3
  6. package/dist/abstract/BaseAPI.d.mts.map +1 -1
  7. package/dist/abstract/BaseAPI.mjs +10 -0
  8. package/dist/abstract/BaseAPI.mjs.map +1 -1
  9. package/dist/consts/deployments-slp-mainnet.json +9 -9
  10. package/dist/consts/deployments-zlp-mainnet.json +4 -4
  11. package/dist/implementations/SLPAPI.cjs +110 -38
  12. package/dist/implementations/SLPAPI.cjs.map +1 -1
  13. package/dist/implementations/SLPAPI.d.cts +9 -9
  14. package/dist/implementations/SLPAPI.d.cts.map +1 -1
  15. package/dist/implementations/SLPAPI.d.mts +9 -9
  16. package/dist/implementations/SLPAPI.d.mts.map +1 -1
  17. package/dist/implementations/SLPAPI.mjs +110 -38
  18. package/dist/implementations/SLPAPI.mjs.map +1 -1
  19. package/dist/implementations/SLPDataAPI.cjs +2 -0
  20. package/dist/implementations/SLPDataAPI.cjs.map +1 -1
  21. package/dist/implementations/SLPDataAPI.d.cts.map +1 -1
  22. package/dist/implementations/SLPDataAPI.d.mts.map +1 -1
  23. package/dist/implementations/SLPDataAPI.mjs +2 -0
  24. package/dist/implementations/SLPDataAPI.mjs.map +1 -1
  25. package/dist/implementations/USDZAPI.cjs +102 -40
  26. package/dist/implementations/USDZAPI.cjs.map +1 -1
  27. package/dist/implementations/USDZAPI.d.cts +9 -9
  28. package/dist/implementations/USDZAPI.d.cts.map +1 -1
  29. package/dist/implementations/USDZAPI.d.mts +9 -9
  30. package/dist/implementations/USDZAPI.d.mts.map +1 -1
  31. package/dist/implementations/USDZAPI.mjs +102 -40
  32. package/dist/implementations/USDZAPI.mjs.map +1 -1
  33. package/dist/implementations/USDZDataAPI.cjs +2 -0
  34. package/dist/implementations/USDZDataAPI.cjs.map +1 -1
  35. package/dist/implementations/USDZDataAPI.d.cts.map +1 -1
  36. package/dist/implementations/USDZDataAPI.d.mts.map +1 -1
  37. package/dist/implementations/USDZDataAPI.mjs +2 -0
  38. package/dist/implementations/USDZDataAPI.mjs.map +1 -1
  39. package/dist/implementations/ZLPAPI.cjs +100 -38
  40. package/dist/implementations/ZLPAPI.cjs.map +1 -1
  41. package/dist/implementations/ZLPAPI.d.cts +9 -9
  42. package/dist/implementations/ZLPAPI.d.cts.map +1 -1
  43. package/dist/implementations/ZLPAPI.d.mts +9 -9
  44. package/dist/implementations/ZLPAPI.d.mts.map +1 -1
  45. package/dist/implementations/ZLPAPI.mjs +100 -38
  46. package/dist/implementations/ZLPAPI.mjs.map +1 -1
  47. package/dist/implementations/ZLPDataAPI.cjs +2 -0
  48. package/dist/implementations/ZLPDataAPI.cjs.map +1 -1
  49. package/dist/implementations/ZLPDataAPI.d.cts.map +1 -1
  50. package/dist/implementations/ZLPDataAPI.d.mts.map +1 -1
  51. package/dist/implementations/ZLPDataAPI.mjs +2 -0
  52. package/dist/implementations/ZLPDataAPI.mjs.map +1 -1
  53. package/dist/interfaces/base.d.cts +5 -4
  54. package/dist/interfaces/base.d.cts.map +1 -1
  55. package/dist/interfaces/base.d.mts +5 -4
  56. package/dist/interfaces/base.d.mts.map +1 -1
  57. package/package.json +8 -8
  58. package/src/abstract/BaseAPI.ts +17 -3
  59. package/src/consts/deployments-slp-mainnet.json +9 -9
  60. package/src/consts/deployments-zlp-mainnet.json +4 -4
  61. package/src/implementations/SLPAPI.ts +169 -33
  62. package/src/implementations/SLPDataAPI.ts +2 -0
  63. package/src/implementations/USDZAPI.ts +174 -36
  64. package/src/implementations/USDZDataAPI.ts +2 -0
  65. package/src/implementations/ZLPAPI.ts +172 -31
  66. package/src/implementations/ZLPDataAPI.ts +2 -0
  67. package/src/interfaces/base.ts +9 -3
@@ -41,6 +41,17 @@ export abstract class BaseAPI extends BaseDataAPI implements IBaseAPI {
41
41
  return tx.object(coinObjects[0])
42
42
  }
43
43
 
44
+ protected processCoinSplitting(tx: Transaction, token: string, coinObjects: string[], amounts: any[], sponsoredTx?: boolean, suiCoinObject?: any) {
45
+ if (sponsoredTx) {
46
+ const sourceObject = token === 'sui'
47
+ ? suiCoinObject
48
+ : this.processCoins(tx, token, coinObjects, true)
49
+ return tx.splitCoins(sourceObject, amounts)
50
+ }
51
+ const coinObject = this.processCoins(tx, token, coinObjects)
52
+ return tx.splitCoins(coinObject, amounts)
53
+ }
54
+
44
55
  /**
45
56
  * Processes slippage for price calculations
46
57
  */
@@ -71,7 +82,6 @@ export abstract class BaseAPI extends BaseDataAPI implements IBaseAPI {
71
82
  sender?: string,
72
83
  sponsoredTx?: boolean,
73
84
  suiCoinObjectsForPythUpdate?: string[],
74
- isDepositingSui?: boolean,
75
85
  ): Promise<Transaction>
76
86
 
77
87
  public abstract withdraw(
@@ -122,7 +132,9 @@ export abstract class BaseAPI extends BaseDataAPI implements IBaseAPI {
122
132
  collateralSlippage?: number,
123
133
  relayerFee?: bigint,
124
134
  referralAddress?: string,
125
- sender?: string
135
+ sender?: string,
136
+ sponsoredTx?: boolean,
137
+ suiCoinObjectsForPythUpdate?: string[],
126
138
  ): Promise<Transaction>
127
139
 
128
140
  public abstract decreasePosition(
@@ -139,7 +151,9 @@ export abstract class BaseAPI extends BaseDataAPI implements IBaseAPI {
139
151
  pricesSlippage?: number,
140
152
  collateralSlippage?: number,
141
153
  relayerFee?: bigint,
142
- coinObjects?: string[]
154
+ coinObjects?: string[],
155
+ sponsoredTx?: boolean,
156
+ suiCoinObjectsForPythUpdate?: string[],
143
157
  ): Promise<Transaction>
144
158
 
145
159
  public abstract decreaseMultiPositions(
@@ -14,39 +14,39 @@
14
14
  "orders_parent": "0x6084377e6a7eb77c6bcc18e8f2af8a46708af87e98aff448a44e46d7c5afd31a",
15
15
  "vaults": {
16
16
  "sui": {
17
- "weight": "70000000000000000",
17
+ "weight": "200000000000000000",
18
18
  "reserving_fee_model": "0x06420378d3b4bdba8d5afc2f88d33b7c7640aa14330c35f14c9874289147f15b"
19
19
  },
20
20
  "usdc": {
21
- "weight": "0",
21
+ "weight": "50000000000000000",
22
22
  "reserving_fee_model": "0x75183cd63566bf3ef9c5d1ec790a28e5b0a75a0901a33b48e1e8423a62a6eb9d"
23
23
  },
24
24
  "usdt": {
25
- "weight": "0",
25
+ "weight": "50000000000000000",
26
26
  "reserving_fee_model": "0xbb09fbc5c2103ffcde3c589463c700b7c6cd2c2a462429c6b5fd147c7b1aba4f"
27
27
  },
28
28
  "afSui": {
29
- "weight": "12500000000000000",
29
+ "weight": "200000000000000000",
30
30
  "reserving_fee_model": "0x94243eff61204c6afb510639de396217dbbc0cc838626ce7ae8ab7aa9b30a020"
31
31
  },
32
32
  "vSui": {
33
- "weight": "12500000000000000",
33
+ "weight": "200000000000000000",
34
34
  "reserving_fee_model": "0xc02335751b486792862e2d04402f64296442e104e2ee79e1ef9a56f038a2cd2e"
35
35
  },
36
36
  "buck": {
37
- "weight": "2000000000000000",
37
+ "weight": "50000000000000000",
38
38
  "reserving_fee_model": "0xb5bfc5231b21059123fd4c0bdb39af025ec3025683d43fe23e05cf792bcbc8b8"
39
39
  },
40
40
  "nusdc": {
41
- "weight": "2000000000000000",
41
+ "weight": "100000000000000000",
42
42
  "reserving_fee_model": "0xc9f2c56c85589ce19d58a55097234df845fca075a902c4b912d36ba5d21b32de"
43
43
  },
44
44
  "suiEth": {
45
- "weight": "0",
45
+ "weight": "50000000000000000",
46
46
  "reserving_fee_model": "0xd0d0b5076dd61ff70205a2f38d3abc6d18974b0ef524bb2dc7631371b5090b8c"
47
47
  },
48
48
  "ausd": {
49
- "weight": "1000000000000000",
49
+ "weight": "50000000000000000",
50
50
  "reserving_fee_model": "0xcf5fcdd8fc9d295f1d44ba68a0b74350fe8191ee6b367dfa8c103c5ebc6f80c0"
51
51
  }
52
52
  },
@@ -18,19 +18,19 @@
18
18
  "reserving_fee_model": "0x4d19ffb376fb4c0dcfc85f434b100372f55a67eae44078b4516b61f28a82ceb4"
19
19
  },
20
20
  "deep": {
21
- "weight": "12500000000000000",
21
+ "weight": "25000000000000000",
22
22
  "reserving_fee_model": "0x229d034eba80fc3473a691e945923c57bb369ee6823a69824d68e20c462e0577"
23
23
  },
24
24
  "nusdc": {
25
- "weight": "10000000000000000",
25
+ "weight": "50000000000000000",
26
26
  "reserving_fee_model": "0x7536eaafa9851c86ca771eff21b915d787d57e0939bb353ba6a5839b0bcc472f"
27
27
  },
28
28
  "wal": {
29
- "weight": "12500000000000000",
29
+ "weight": "25000000000000000",
30
30
  "reserving_fee_model": "0x86ee98bdf815a46d4eff6a622f4e95eb0cf630e48a51ab2c340abb57883442b1"
31
31
  },
32
32
  "cetus": {
33
- "weight": "10000000000000000",
33
+ "weight": "12500000000000000",
34
34
  "reserving_fee_model": "0x21c5f1cc0596ac9fc2b2cc6c4c748dc5ccc66f116fcf25900822c683d6a38972"
35
35
  }
36
36
  },
@@ -153,7 +153,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
153
153
  sender?: string,
154
154
  sponsoredTx?: boolean,
155
155
  suiCoinObjectsForPythUpdate?: string[],
156
- isDepositingSui?: boolean,
157
156
  ): Promise<Transaction> {
158
157
  let tx = new Transaction()
159
158
 
@@ -171,7 +170,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
171
170
  tx = await this.initOracleTxb(pythFeederKeys, tx, true, suiCoinObject)
172
171
 
173
172
  // Process deposit coins
174
- const depositObject = isDepositingSui
173
+ const depositObject = coin === 'sui'
175
174
  ? tx.splitCoins(suiCoinObject, [tx.pure.u64(amount)])[0]
176
175
  : tx.splitCoins(this.processCoins(tx, coin, coinObjects, true), [tx.pure.u64(amount)])[0]
177
176
 
@@ -400,27 +399,46 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
400
399
  relayerFee = BigInt(0.5),
401
400
  referralAddress?: string,
402
401
  sender?: string,
402
+ sponsoredTx?: boolean,
403
+ suiCoinObjectsForPythUpdate?: string[],
403
404
  ): Promise<Transaction> {
404
405
  let tx = new Transaction()
405
406
  if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
406
407
  tx = await this.addReferral(referralAddress, tx)
407
408
  }
408
- tx = await this.initOracleTxb([collateralToken, indexToken], tx)
409
- const coinObject = this.processCoins(tx, collateralToken, coinObjects)
410
- const [depositObject] = tx.splitCoins(coinObject, [
411
- tx.pure.u64(collateralAmount),
412
- ])
413
- const feeObject = tx.splitCoins(tx.gas, [tx.pure.u64(relayerFee || BigInt(0.5))]) // Sudo contract requires SUI as fee
414
409
 
415
410
  const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
416
- const adjustPrice = this.processSlippage(indexPrice, long, isLimitOrder ? 0 : pricesSlippage || 0.003)
417
- const adjustCollateralPrice = this.processSlippage(collateralPrice, false, collateralSlippage || 0.5)
411
+ const adjustPrice = this.processSlippage(indexPrice, long, isLimitOrder ? 0 : pricesSlippage)
412
+ const adjustCollateralPrice = this.processSlippage(collateralPrice, false, collateralSlippage)
418
413
 
419
414
  let allowTrade = ALLOW_TRADE_MUST_TRADE
420
415
  if (isLimitOrder) {
421
416
  allowTrade = isIocOrder ? ALLOW_TRADE_NO_TRADE : ALLOW_TRADE_CAN_TRADE
422
417
  }
423
418
 
419
+ // Handle oracle initialization and coin processing
420
+ let suiCoinObject
421
+ let feeObject
422
+ if (sponsoredTx) {
423
+ suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
424
+ feeObject = tx.splitCoins(suiCoinObject, [tx.pure.u64(relayerFee)]) // Sudo contract requires SUI as fee
425
+ tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
426
+ }
427
+ else {
428
+ feeObject = tx.splitCoins(tx.gas, [tx.pure.u64(relayerFee)]) // Sudo contract requires SUI as fee
429
+ tx = await this.initOracleTxb([collateralToken, indexToken], tx)
430
+ }
431
+
432
+ // Process coin splitting
433
+ const [depositObject] = this.processCoinSplitting(
434
+ tx,
435
+ collateralToken,
436
+ coinObjects,
437
+ [tx.pure.u64(collateralAmount)],
438
+ sponsoredTx,
439
+ suiCoinObject,
440
+ )
441
+
424
442
  tx.moveCall({
425
443
  target: `${this.consts.sudoCore.upgradedPackage}::market::open_position_v1_2`,
426
444
  typeArguments: [
@@ -470,10 +488,12 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
470
488
  pricesSlippage = 0.003,
471
489
  collateralSlippage = 0.5,
472
490
  relayerFee = BigInt(0.5),
491
+ coinObjects?: string[],
492
+ sponsoredTx?: boolean,
493
+ suiCoinObjectsForPythUpdate?: string[],
473
494
  ): Promise<Transaction> {
474
- const tx = await this.initOracleTxb([collateralToken, indexToken])
495
+ let tx = new Transaction()
475
496
  const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
476
- const feeObject = tx.splitCoins(tx.gas, [tx.pure.u64(relayerFee)]) // Sudo contract requires SUI as fee
477
497
 
478
498
  const adjustPrice = this.processSlippage(
479
499
  indexPrice,
@@ -494,6 +514,19 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
494
514
  isTakeProfitOrder = true
495
515
  }
496
516
 
517
+ // Handle oracle initialization and coin processing
518
+ let suiCoinObject
519
+ let feeObject
520
+ if (sponsoredTx) {
521
+ suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
522
+ feeObject = tx.splitCoins(suiCoinObject, [tx.pure.u64(relayerFee)]) // Sudo contract requires SUI as fee
523
+ tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
524
+ }
525
+ else {
526
+ feeObject = tx.splitCoins(tx.gas, [tx.pure.u64(relayerFee)]) // Sudo contract requires SUI as fee
527
+ tx = await this.initOracleTxb([collateralToken, indexToken], tx)
528
+ }
529
+
497
530
  tx.moveCall({
498
531
  target: `${this.consts.sudoCore.upgradedPackage}::market::decrease_position_v1_2`,
499
532
  typeArguments: [
@@ -544,11 +577,22 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
544
577
  coinObjects?: string[]
545
578
  }>,
546
579
  tx?: Transaction,
580
+ sponsoredTx?: boolean,
581
+ suiCoinObjectsForPythUpdate?: string[],
547
582
  ): Promise<Transaction> {
548
583
  if (!tx) {
549
584
  tx = new Transaction()
550
585
  }
551
- tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx)
586
+
587
+ // Handle oracle initialization and coin processing
588
+ let suiCoinObject
589
+ if (sponsoredTx) {
590
+ suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
591
+ tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx, true, suiCoinObject)
592
+ }
593
+ else {
594
+ tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx)
595
+ }
552
596
 
553
597
  for (const position of positions) {
554
598
  const {
@@ -569,8 +613,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
569
613
  } = position
570
614
  let innerIsTakeProfitOrder = isTakeProfitOrder
571
615
  const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
572
- const coinObject = this.processCoins(tx, collateralToken, coinObjects)
573
- const feeObject = tx.splitCoins(coinObject, [tx.pure.u64(relayerFee)])
574
616
 
575
617
  const adjustPrice = this.processSlippage(indexPrice, !long, isTriggerOrder ? 0 : pricesSlippage)
576
618
  const adjustCollateralPrice = this.processSlippage(collateralPrice, false, collateralSlippage)
@@ -583,6 +625,16 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
583
625
  innerIsTakeProfitOrder = true
584
626
  }
585
627
 
628
+ // Process coin splitting
629
+ const [feeObject] = this.processCoinSplitting(
630
+ tx,
631
+ collateralToken,
632
+ coinObjects,
633
+ [tx.pure.u64(relayerFee)],
634
+ sponsoredTx,
635
+ suiCoinObject,
636
+ )
637
+
586
638
  tx.moveCall({
587
639
  target: `${this.consts.sudoCore.upgradedPackage}::market::decrease_position_v1_2`,
588
640
  typeArguments: [
@@ -622,10 +674,30 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
622
674
  amount: number,
623
675
  coinObjects: string[],
624
676
  long: boolean,
677
+ sponsoredTx?: boolean,
678
+ suiCoinObjectsForPythUpdate?: string[],
625
679
  ): Promise<Transaction> {
626
- const tx = await this.initOracleTxb([collateralToken, indexToken])
627
- const coinObject = this.processCoins(tx, collateralToken, coinObjects)
628
- const [depositObject] = tx.splitCoins(coinObject, [tx.pure.u64(amount)])
680
+ let tx = new Transaction()
681
+
682
+ // Handle oracle initialization and coin processing
683
+ let suiCoinObject
684
+ if (sponsoredTx) {
685
+ suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
686
+ tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
687
+ }
688
+ else {
689
+ tx = await this.initOracleTxb([collateralToken, indexToken], tx)
690
+ }
691
+
692
+ // Process coin splitting
693
+ const [depositObject] = this.processCoinSplitting(
694
+ tx,
695
+ collateralToken,
696
+ coinObjects,
697
+ [tx.pure.u64(amount)],
698
+ sponsoredTx,
699
+ suiCoinObject,
700
+ )
629
701
 
630
702
  tx.moveCall({
631
703
  target: `${this.consts.sudoCore.upgradedPackage}::market::pledge_in_position`,
@@ -650,8 +722,19 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
650
722
  indexToken: string,
651
723
  amount: number,
652
724
  long: boolean,
725
+ sponsoredTx?: boolean,
726
+ suiCoinObjectsForPythUpdate?: string[],
653
727
  ): Promise<Transaction> {
654
- const tx = await this.initOracleTxb([collateralToken, indexToken])
728
+ let tx = new Transaction()
729
+ // Handle oracle initialization and coin processing
730
+ let suiCoinObject
731
+ if (sponsoredTx) {
732
+ suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
733
+ tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
734
+ }
735
+ else {
736
+ tx = await this.initOracleTxb([collateralToken, indexToken], tx)
737
+ }
655
738
  const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
656
739
 
657
740
  tx.moveCall({
@@ -847,22 +930,18 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
847
930
  scard: string,
848
931
  isLimitOrder = false,
849
932
  isIocOrder = false,
850
- pricesSlippage?: number,
851
- collateralSlippage?: number,
852
- relayerFee?: bigint,
933
+ pricesSlippage = 0.003,
934
+ collateralSlippage = 0.5,
935
+ relayerFee = BigInt(0.5),
853
936
  referralAddress?: string,
854
937
  sender?: string,
938
+ sponsoredTx?: boolean,
939
+ suiCoinObjectsForPythUpdate?: string[],
855
940
  ): Promise<Transaction> {
856
941
  let tx = new Transaction()
857
942
  if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
858
943
  tx = await this.addReferral(referralAddress, tx)
859
944
  }
860
- tx = await this.initOracleTxb([collateralToken, indexToken], tx)
861
- const coinObject = this.processCoins(tx, collateralToken, coinObjects)
862
- const [depositObject] = tx.splitCoins(coinObject, [
863
- tx.pure.u64(collateralAmount),
864
- ])
865
- const feeObject = tx.splitCoins(tx.gas, [tx.pure.u64(relayerFee || BigInt(0.5))]) // Sudo contract requires SUI as fee
866
945
 
867
946
  const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
868
947
  const adjustPrice = this.processSlippage(indexPrice, long, isLimitOrder ? 0 : pricesSlippage || 0.003)
@@ -884,6 +963,29 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
884
963
  itemId: scard,
885
964
  })
886
965
 
966
+ // Handle oracle initialization and coin processing
967
+ let suiCoinObject
968
+ let feeObject
969
+ if (sponsoredTx) {
970
+ suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
971
+ feeObject = tx.splitCoins(suiCoinObject, [tx.pure.u64(relayerFee)]) // Sudo contract requires SUI as fee
972
+ tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
973
+ }
974
+ else {
975
+ feeObject = tx.splitCoins(tx.gas, [tx.pure.u64(relayerFee)]) // Sudo contract requires SUI as fee
976
+ tx = await this.initOracleTxb([collateralToken, indexToken], tx)
977
+ }
978
+
979
+ // Process coin splitting
980
+ const [depositObject] = this.processCoinSplitting(
981
+ tx,
982
+ collateralToken,
983
+ coinObjects,
984
+ [tx.pure.u64(collateralAmount)],
985
+ sponsoredTx,
986
+ suiCoinObject,
987
+ )
988
+
887
989
  tx.moveCall({
888
990
  target: `${this.consts.sudoCore.upgradedPackage}::market::open_position_v1_3`,
889
991
  typeArguments: [
@@ -942,10 +1044,12 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
942
1044
  pricesSlippage = 0.003,
943
1045
  collateralSlippage = 0.5,
944
1046
  relayerFee = BigInt(0.5),
1047
+ coinObjects?: string[],
1048
+ sponsoredTx?: boolean,
1049
+ suiCoinObjectsForPythUpdate?: string[],
945
1050
  ): Promise<Transaction> {
946
- const tx = await this.initOracleTxb([collateralToken, indexToken])
1051
+ let tx = new Transaction()
947
1052
  const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
948
- const feeObject = tx.splitCoins(tx.gas, [tx.pure.u64(relayerFee)]) // Sudo contract requires SUI as fee
949
1053
 
950
1054
  const adjustPrice = this.processSlippage(
951
1055
  indexPrice,
@@ -977,6 +1081,19 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
977
1081
  itemId: scard,
978
1082
  })
979
1083
 
1084
+ // Handle oracle initialization and coin processing
1085
+ let suiCoinObject
1086
+ let feeObject
1087
+ if (sponsoredTx) {
1088
+ suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
1089
+ feeObject = tx.splitCoins(suiCoinObject, [tx.pure.u64(relayerFee)]) // Sudo contract requires SUI as fee
1090
+ tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
1091
+ }
1092
+ else {
1093
+ feeObject = tx.splitCoins(tx.gas, [tx.pure.u64(relayerFee)]) // Sudo contract requires SUI as fee
1094
+ tx = await this.initOracleTxb([collateralToken, indexToken], tx)
1095
+ }
1096
+
980
1097
  tx.moveCall({
981
1098
  target: `${this.consts.sudoCore.upgradedPackage}::market::decrease_position_v1_3`,
982
1099
  typeArguments: [
@@ -1038,11 +1155,22 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
1038
1155
  kioskCap: KioskOwnerCap,
1039
1156
  scard: string,
1040
1157
  tx?: Transaction,
1158
+ sponsoredTx?: boolean,
1159
+ suiCoinObjectsForPythUpdate?: string[],
1041
1160
  ): Promise<Transaction> {
1042
1161
  if (!tx) {
1043
1162
  tx = new Transaction()
1044
1163
  }
1045
- tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx)
1164
+
1165
+ // Handle oracle initialization and coin processing
1166
+ let suiCoinObject
1167
+ if (sponsoredTx) {
1168
+ suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
1169
+ tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx, true, suiCoinObject)
1170
+ }
1171
+ else {
1172
+ tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx)
1173
+ }
1046
1174
 
1047
1175
  const kioskTx = new KioskTransaction({
1048
1176
  transaction: tx,
@@ -1074,8 +1202,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
1074
1202
  } = position
1075
1203
  let innerIsTakeProfitOrder = isTakeProfitOrder
1076
1204
  const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
1077
- const coinObject = this.processCoins(tx, collateralToken, coinObjects)
1078
- const feeObject = tx.splitCoins(coinObject, [tx.pure.u64(relayerFee)])
1079
1205
 
1080
1206
  const adjustPrice = this.processSlippage(indexPrice, !long, isTriggerOrder ? 0 : pricesSlippage)
1081
1207
  const adjustCollateralPrice = this.processSlippage(collateralPrice, false, collateralSlippage)
@@ -1088,6 +1214,16 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
1088
1214
  innerIsTakeProfitOrder = true
1089
1215
  }
1090
1216
 
1217
+ // Process coin splitting
1218
+ const [feeObject] = this.processCoinSplitting(
1219
+ tx,
1220
+ collateralToken,
1221
+ coinObjects,
1222
+ [tx.pure.u64(relayerFee)],
1223
+ sponsoredTx,
1224
+ suiCoinObject,
1225
+ )
1226
+
1091
1227
  tx.moveCall({
1092
1228
  target: `${this.consts.sudoCore.upgradedPackage}::market::decrease_position_v1_3`,
1093
1229
  typeArguments: [
@@ -1008,6 +1008,7 @@ export class SLPDataAPI extends BaseDataAPI implements ISLPDataAPI {
1008
1008
  }
1009
1009
 
1010
1010
  private async parseSymbolInfo(raw: any, long: boolean): Promise<ISLPSymbolInfo> {
1011
+ const { objectId } = raw.data
1011
1012
  const { fields } = raw.data.content.fields.value
1012
1013
  const fundingFeeModelAddr = fields.funding_fee_model
1013
1014
  const fundingFeeModelRaw = await this.provider.getObject({
@@ -1019,6 +1020,7 @@ export class SLPDataAPI extends BaseDataAPI implements ISLPDataAPI {
1019
1020
  const fundingFeeModel = SLPDataAPI.parseFundingFeeModel(fundingFeeModelRaw)
1020
1021
 
1021
1022
  return {
1023
+ objectId,
1022
1024
  openingSize: parseValue(fields.opening_size),
1023
1025
  openingAmount: parseValue(fields.opening_amount),
1024
1026
  accFundingRate: parseValue(fields.acc_funding_rate),