@zofai/zo-sdk 0.2.9 → 0.2.10

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 (108) hide show
  1. package/dist/abstract/BaseAPI.cjs +7 -1
  2. package/dist/abstract/BaseAPI.cjs.map +1 -1
  3. package/dist/abstract/BaseAPI.d.cts +8 -7
  4. package/dist/abstract/BaseAPI.d.cts.map +1 -1
  5. package/dist/abstract/BaseAPI.d.mts +8 -7
  6. package/dist/abstract/BaseAPI.d.mts.map +1 -1
  7. package/dist/abstract/BaseAPI.mjs +7 -1
  8. package/dist/abstract/BaseAPI.mjs.map +1 -1
  9. package/dist/api.cjs +12 -12
  10. package/dist/api.cjs.map +1 -1
  11. package/dist/api.mjs +12 -12
  12. package/dist/api.mjs.map +1 -1
  13. package/dist/coins.cjs +74 -0
  14. package/dist/coins.cjs.map +1 -0
  15. package/dist/coins.d.cts +37 -0
  16. package/dist/coins.d.cts.map +1 -0
  17. package/dist/coins.d.mts +37 -0
  18. package/dist/coins.d.mts.map +1 -0
  19. package/dist/coins.mjs +67 -0
  20. package/dist/coins.mjs.map +1 -0
  21. package/dist/implementations/SLPAPI.cjs +192 -100
  22. package/dist/implementations/SLPAPI.cjs.map +1 -1
  23. package/dist/implementations/SLPAPI.d.cts +23 -23
  24. package/dist/implementations/SLPAPI.d.cts.map +1 -1
  25. package/dist/implementations/SLPAPI.d.mts +23 -23
  26. package/dist/implementations/SLPAPI.d.mts.map +1 -1
  27. package/dist/implementations/SLPAPI.mjs +192 -100
  28. package/dist/implementations/SLPAPI.mjs.map +1 -1
  29. package/dist/implementations/SLPDataAPI.cjs +2 -2
  30. package/dist/implementations/SLPDataAPI.cjs.map +1 -1
  31. package/dist/implementations/SLPDataAPI.mjs +2 -2
  32. package/dist/implementations/SLPDataAPI.mjs.map +1 -1
  33. package/dist/implementations/USDZAPI.cjs +176 -92
  34. package/dist/implementations/USDZAPI.cjs.map +1 -1
  35. package/dist/implementations/USDZAPI.d.cts +21 -21
  36. package/dist/implementations/USDZAPI.d.cts.map +1 -1
  37. package/dist/implementations/USDZAPI.d.mts +21 -21
  38. package/dist/implementations/USDZAPI.d.mts.map +1 -1
  39. package/dist/implementations/USDZAPI.mjs +176 -92
  40. package/dist/implementations/USDZAPI.mjs.map +1 -1
  41. package/dist/implementations/ZBTCVCAPI.cjs +84 -46
  42. package/dist/implementations/ZBTCVCAPI.cjs.map +1 -1
  43. package/dist/implementations/ZBTCVCAPI.d.cts +11 -11
  44. package/dist/implementations/ZBTCVCAPI.d.cts.map +1 -1
  45. package/dist/implementations/ZBTCVCAPI.d.mts +11 -11
  46. package/dist/implementations/ZBTCVCAPI.d.mts.map +1 -1
  47. package/dist/implementations/ZBTCVCAPI.mjs +84 -46
  48. package/dist/implementations/ZBTCVCAPI.mjs.map +1 -1
  49. package/dist/implementations/ZLPAPI.cjs +192 -100
  50. package/dist/implementations/ZLPAPI.cjs.map +1 -1
  51. package/dist/implementations/ZLPAPI.d.cts +23 -23
  52. package/dist/implementations/ZLPAPI.d.cts.map +1 -1
  53. package/dist/implementations/ZLPAPI.d.mts +23 -23
  54. package/dist/implementations/ZLPAPI.d.mts.map +1 -1
  55. package/dist/implementations/ZLPAPI.mjs +192 -100
  56. package/dist/implementations/ZLPAPI.mjs.map +1 -1
  57. package/dist/index.cjs +1 -0
  58. package/dist/index.cjs.map +1 -1
  59. package/dist/index.d.cts +1 -0
  60. package/dist/index.d.cts.map +1 -1
  61. package/dist/index.d.mts +1 -0
  62. package/dist/index.d.mts.map +1 -1
  63. package/dist/index.mjs +1 -0
  64. package/dist/index.mjs.map +1 -1
  65. package/dist/interfaces/base.d.cts +25 -21
  66. package/dist/interfaces/base.d.cts.map +1 -1
  67. package/dist/interfaces/base.d.mts +25 -21
  68. package/dist/interfaces/base.d.mts.map +1 -1
  69. package/dist/interfaces/slp.d.cts +1 -1
  70. package/dist/interfaces/slp.d.cts.map +1 -1
  71. package/dist/interfaces/slp.d.mts +1 -1
  72. package/dist/interfaces/slp.d.mts.map +1 -1
  73. package/dist/interfaces/usdz.d.cts +1 -1
  74. package/dist/interfaces/usdz.d.cts.map +1 -1
  75. package/dist/interfaces/usdz.d.mts +1 -1
  76. package/dist/interfaces/usdz.d.mts.map +1 -1
  77. package/dist/interfaces/zbtcvc.d.cts +1 -1
  78. package/dist/interfaces/zbtcvc.d.cts.map +1 -1
  79. package/dist/interfaces/zbtcvc.d.mts +1 -1
  80. package/dist/interfaces/zbtcvc.d.mts.map +1 -1
  81. package/dist/interfaces/zlp.d.cts +1 -1
  82. package/dist/interfaces/zlp.d.cts.map +1 -1
  83. package/dist/interfaces/zlp.d.mts +1 -1
  84. package/dist/interfaces/zlp.d.mts.map +1 -1
  85. package/dist/oracle.cjs +27 -22
  86. package/dist/oracle.cjs.map +1 -1
  87. package/dist/oracle.d.cts +13 -1
  88. package/dist/oracle.d.cts.map +1 -1
  89. package/dist/oracle.d.mts +13 -1
  90. package/dist/oracle.d.mts.map +1 -1
  91. package/dist/oracle.mjs +27 -22
  92. package/dist/oracle.mjs.map +1 -1
  93. package/package.json +1 -1
  94. package/src/abstract/BaseAPI.ts +10 -8
  95. package/src/api.ts +12 -12
  96. package/src/coins.ts +115 -0
  97. package/src/implementations/SLPAPI.ts +199 -115
  98. package/src/implementations/SLPDataAPI.ts +2 -2
  99. package/src/implementations/USDZAPI.ts +184 -94
  100. package/src/implementations/ZBTCVCAPI.ts +98 -52
  101. package/src/implementations/ZLPAPI.ts +199 -110
  102. package/src/index.ts +1 -0
  103. package/src/interfaces/base.ts +13 -21
  104. package/src/interfaces/slp.ts +0 -1
  105. package/src/interfaces/usdz.ts +0 -1
  106. package/src/interfaces/zbtcvc.ts +0 -1
  107. package/src/interfaces/zlp.ts +0 -1
  108. package/src/oracle.ts +64 -28
@@ -105,7 +105,6 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
105
105
  referralAddress?: string,
106
106
  sender?: string,
107
107
  sponsoredTx?: boolean,
108
- suiCoinObjectsForPythUpdate?: string[],
109
108
  ): Promise<Transaction> {
110
109
  let tx = new Transaction()
111
110
  if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
@@ -135,11 +134,15 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
135
134
  // Handle oracle initialization and coin processing
136
135
  let suiCoinObject
137
136
  if (sponsoredTx) {
138
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
139
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
137
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
138
+ sender: this.requireSenderForSponsored(sender),
139
+ additionalSuiAmount: collateralToken === 'sui' ? collateralAmount + relayerFee : 0n,
140
+ })
141
+ tx = oracle.tx
142
+ suiCoinObject = oracle.suiCoinObject
140
143
  }
141
144
  else {
142
- tx = await this.initOracleTxb([collateralToken, indexToken], tx)
145
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
143
146
  }
144
147
 
145
148
  // Process coin splitting
@@ -209,7 +212,7 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
209
212
  relayerFee = BigInt(0.5),
210
213
  coinObjects?: string[],
211
214
  sponsoredTx?: boolean,
212
- suiCoinObjectsForPythUpdate?: string[],
215
+ sender?: string,
213
216
  ): Promise<Transaction> {
214
217
  if (!coinObjects) {
215
218
  throw new Error(`${this.constructor.name}: coinObjects is required`)
@@ -244,11 +247,15 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
244
247
  // Handle oracle initialization and coin processing
245
248
  let suiCoinObject
246
249
  if (sponsoredTx) {
247
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
248
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
250
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
251
+ sender: this.requireSenderForSponsored(sender),
252
+ additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
253
+ })
254
+ tx = oracle.tx
255
+ suiCoinObject = oracle.suiCoinObject
249
256
  }
250
257
  else {
251
- tx = await this.initOracleTxb([collateralToken, indexToken], tx)
258
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
252
259
  }
253
260
 
254
261
  // Process coin splitting
@@ -261,7 +268,6 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
261
268
  suiCoinObject,
262
269
  )
263
270
 
264
-
265
271
  tx.moveCall({
266
272
  target: `${this.consts.zoCore.upgradedPackage}::market::decrease_position_with_scard`,
267
273
  typeArguments: [
@@ -321,7 +327,7 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
321
327
  scard: string,
322
328
  tx?: Transaction,
323
329
  sponsoredTx?: boolean,
324
- suiCoinObjectsForPythUpdate?: string[],
330
+ sender?: string,
325
331
  ): Promise<Transaction> {
326
332
  if (!tx) {
327
333
  tx = new Transaction()
@@ -330,11 +336,20 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
330
336
  // Handle oracle initialization and coin processing
331
337
  let suiCoinObject
332
338
  if (sponsoredTx) {
333
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
334
- tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx, true, suiCoinObject)
339
+ const oracle = await this.initOracleTxb(
340
+ positions.flatMap(position => [position.collateralToken, position.indexToken]),
341
+ tx,
342
+ true,
343
+ { sender: this.requireSenderForSponsored(sender) },
344
+ )
345
+ tx = oracle.tx
346
+ suiCoinObject = oracle.suiCoinObject
335
347
  }
336
348
  else {
337
- tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx)
349
+ tx = (await this.initOracleTxb(
350
+ positions.flatMap(position => [position.collateralToken, position.indexToken]),
351
+ tx,
352
+ )).tx
338
353
  }
339
354
 
340
355
  const kioskTx = new KioskTransaction({
@@ -389,7 +404,6 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
389
404
  suiCoinObject,
390
405
  )
391
406
 
392
-
393
407
  tx.moveCall({
394
408
  target: `${this.consts.zoCore.upgradedPackage}::market::decrease_position_with_scard`,
395
409
  typeArguments: [
@@ -439,7 +453,6 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
439
453
  referralAddress?: string,
440
454
  sender?: string,
441
455
  sponsoredTx?: boolean,
442
- suiCoinObjectsForPythUpdate?: string[],
443
456
  ): Promise<Transaction> {
444
457
  let tx = new Transaction()
445
458
 
@@ -453,12 +466,16 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
453
466
 
454
467
  // Handle sponsored transaction case
455
468
  if (sponsoredTx) {
456
- const suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
457
- tx = await this.initOracleTxb(pythFeederKeys, tx, true, suiCoinObject)
469
+ const oracle = await this.initOracleTxb(pythFeederKeys, tx, true, {
470
+ sender: this.requireSenderForSponsored(sender),
471
+ additionalSuiAmount: coin === 'sui' ? BigInt(amount) : 0n,
472
+ })
473
+ tx = oracle.tx
474
+ const { suiCoinObject } = oracle
458
475
 
459
476
  // Process deposit coins
460
477
  const depositObject = coin === 'sui'
461
- ? tx.splitCoins(suiCoinObject, [tx.pure.u64(amount)])[0]
478
+ ? tx.splitCoins(suiCoinObject!, [tx.pure.u64(amount)])[0]
462
479
  : tx.splitCoins(this.processCoins(tx, coin, coinObjects, true), [tx.pure.u64(amount)])[0]
463
480
 
464
481
  const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
@@ -479,7 +496,7 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
479
496
  }
480
497
 
481
498
  // Handle non-sponsored transaction case
482
- tx = await this.initOracleTxb(pythFeederKeys, tx)
499
+ tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx
483
500
  const depositObject = tx.splitCoins(
484
501
  this.processCoins(tx, coin, coinObjects, false),
485
502
  [tx.pure.u64(amount)],
@@ -517,7 +534,6 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
517
534
  sender?: string,
518
535
  tx?: Transaction,
519
536
  sponsoredTx?: boolean,
520
- suiCoinObjectsForPythUpdate?: string[],
521
537
  ): Promise<any> {
522
538
  if (!tx) {
523
539
  tx = new Transaction()
@@ -533,12 +549,16 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
533
549
 
534
550
  // Handle sponsored transaction case
535
551
  if (sponsoredTx) {
536
- const suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
537
- tx = await this.initOracleTxb(pythFeederKeys, tx, true, suiCoinObject)
552
+ const oracle = await this.initOracleTxb(pythFeederKeys, tx, true, {
553
+ sender: this.requireSenderForSponsored(sender),
554
+ additionalSuiAmount: coin === 'sui' ? BigInt(amount) : 0n,
555
+ })
556
+ tx = oracle.tx
557
+ const { suiCoinObject } = oracle
538
558
 
539
559
  // Process deposit coins
540
560
  const depositObject = coin === 'sui'
541
- ? tx.splitCoins(suiCoinObject, [tx.pure.u64(amount)])[0]
561
+ ? tx.splitCoins(suiCoinObject!, [tx.pure.u64(amount)])[0]
542
562
  : tx.splitCoins(this.processCoins(tx, coin, coinObjects, true), [tx.pure.u64(amount)])[0]
543
563
 
544
564
  const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
@@ -559,7 +579,7 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
559
579
  }
560
580
 
561
581
  // Handle non-sponsored transaction case
562
- tx = await this.initOracleTxb(pythFeederKeys, tx)
582
+ tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx
563
583
  const depositObject = tx.splitCoins(
564
584
  this.processCoins(tx, coin, coinObjects, false),
565
585
  [tx.pure.u64(amount)],
@@ -595,7 +615,7 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
595
615
  amount: number,
596
616
  minAmountOut = 0,
597
617
  sponsoredTx?: boolean,
598
- suiCoinObjectsForPythUpdate?: string[],
618
+ sender?: string,
599
619
  ): Promise<Transaction> {
600
620
  let tx = new Transaction()
601
621
 
@@ -603,11 +623,15 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
603
623
  const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder)
604
624
 
605
625
  if (sponsoredTx) {
606
- const suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
607
- tx = await this.initOracleTxb(pythFeederKeys, tx, true, suiCoinObject)
626
+ const oracle = await this.initOracleTxb(pythFeederKeys, tx, true, {
627
+ sender: this.requireSenderForSponsored(sender),
628
+ additionalSuiAmount: 0n,
629
+ })
630
+ tx = oracle.tx
631
+ const { suiCoinObject } = oracle
608
632
  }
609
633
  else {
610
- tx = await this.initOracleTxb(pythFeederKeys, tx)
634
+ tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx
611
635
  }
612
636
  const zbtcvcCoinObject = this.processCoins(tx, 'zbtcvc', lpCoinObjects, false)
613
637
  const [withdrawObject] = tx.splitCoins(zbtcvcCoinObject, [tx.pure.u64(amount)])
@@ -742,7 +766,7 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
742
766
  fromCoinObjects: string[],
743
767
  minAmountOut?: number,
744
768
  ): Promise<Transaction> {
745
- const tx = await this.initOracleTxb(Object.keys(this.consts.zoCore.vaults))
769
+ const { tx } = await this.initOracleTxb(Object.keys(this.consts.zoCore.vaults))
746
770
  const fromCoinObject = this.processCoins(tx, fromToken, fromCoinObjects)
747
771
  const [fromDepositObject] = tx.splitCoins(fromCoinObject, [tx.pure.u64(fromAmount)])
748
772
  const vaultsValuation = this.dataAPI.valuateVaults(tx)
@@ -786,7 +810,6 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
786
810
  referralAddress?: string,
787
811
  sender?: string,
788
812
  sponsoredTx?: boolean,
789
- suiCoinObjectsForPythUpdate?: string[],
790
813
  ): Promise<Transaction> {
791
814
  let tx = new Transaction()
792
815
  if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
@@ -805,11 +828,15 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
805
828
  // Handle oracle initialization and coin processing
806
829
  let suiCoinObject
807
830
  if (sponsoredTx) {
808
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
809
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
831
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
832
+ sender: this.requireSenderForSponsored(sender),
833
+ additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
834
+ })
835
+ tx = oracle.tx
836
+ suiCoinObject = oracle.suiCoinObject
810
837
  }
811
838
  else {
812
- tx = await this.initOracleTxb([collateralToken, indexToken], tx)
839
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
813
840
  }
814
841
 
815
842
  // Process coin splitting
@@ -870,7 +897,7 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
870
897
  relayerFee = BigInt(0.5),
871
898
  coinObjects?: string[],
872
899
  sponsoredTx?: boolean,
873
- suiCoinObjectsForPythUpdate?: string[],
900
+ sender?: string,
874
901
  ): Promise<Transaction> {
875
902
  if (!coinObjects) {
876
903
  throw new Error(`${this.constructor.name}: coinObjects is required`)
@@ -892,11 +919,15 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
892
919
  // Handle oracle initialization and coin processing
893
920
  let suiCoinObject
894
921
  if (sponsoredTx) {
895
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
896
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
922
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
923
+ sender: this.requireSenderForSponsored(sender),
924
+ additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
925
+ })
926
+ tx = oracle.tx
927
+ suiCoinObject = oracle.suiCoinObject
897
928
  }
898
929
  else {
899
- tx = await this.initOracleTxb([collateralToken, indexToken], tx)
930
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
900
931
  }
901
932
 
902
933
  // Process coin splitting
@@ -909,7 +940,6 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
909
940
  suiCoinObject,
910
941
  )
911
942
 
912
-
913
943
  tx.moveCall({
914
944
  target: `${this.consts.zoCore.upgradedPackage}::market::decrease_position`,
915
945
  typeArguments: [
@@ -954,7 +984,7 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
954
984
  collateralSlippage?: number
955
985
  relayerFee?: bigint
956
986
  coinObjects?: string[]
957
- }>, tx?: Transaction, sponsoredTx?: boolean, suiCoinObjectsForPythUpdate?: string[]): Promise<Transaction> {
987
+ }>, tx?: Transaction, sponsoredTx?: boolean, sender?: string): Promise<Transaction> {
958
988
  if (!tx) {
959
989
  tx = new Transaction()
960
990
  }
@@ -962,11 +992,20 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
962
992
  // Handle oracle initialization and coin processing
963
993
  let suiCoinObject
964
994
  if (sponsoredTx) {
965
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
966
- tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx, true, suiCoinObject)
995
+ const oracle = await this.initOracleTxb(
996
+ positions.flatMap(position => [position.collateralToken, position.indexToken]),
997
+ tx,
998
+ true,
999
+ { sender: this.requireSenderForSponsored(sender) },
1000
+ )
1001
+ tx = oracle.tx
1002
+ suiCoinObject = oracle.suiCoinObject
967
1003
  }
968
1004
  else {
969
- tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx)
1005
+ tx = (await this.initOracleTxb(
1006
+ positions.flatMap(position => [position.collateralToken, position.indexToken]),
1007
+ tx,
1008
+ )).tx
970
1009
  }
971
1010
 
972
1011
  for (const position of positions) {
@@ -1010,7 +1049,6 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
1010
1049
  suiCoinObject,
1011
1050
  )
1012
1051
 
1013
-
1014
1052
  tx.moveCall({
1015
1053
  target: `${this.consts.zoCore.upgradedPackage}::market::decrease_position`,
1016
1054
  typeArguments: [
@@ -1051,17 +1089,21 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
1051
1089
  coinObjects: string[],
1052
1090
  long: boolean,
1053
1091
  sponsoredTx?: boolean,
1054
- suiCoinObjectsForPythUpdate?: string[],
1092
+ sender?: string,
1055
1093
  ): Promise<Transaction> {
1056
1094
  let tx = new Transaction()
1057
1095
  // Handle oracle initialization and coin processing
1058
1096
  let suiCoinObject
1059
1097
  if (sponsoredTx) {
1060
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
1061
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
1098
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
1099
+ sender: this.requireSenderForSponsored(sender),
1100
+ additionalSuiAmount: collateralToken === 'sui' ? BigInt(amount) : 0n,
1101
+ })
1102
+ tx = oracle.tx
1103
+ suiCoinObject = oracle.suiCoinObject
1062
1104
  }
1063
1105
  else {
1064
- tx = await this.initOracleTxb([collateralToken, indexToken], tx)
1106
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
1065
1107
  }
1066
1108
 
1067
1109
  // Process coin splitting
@@ -1094,17 +1136,21 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
1094
1136
  amount: number,
1095
1137
  long: boolean,
1096
1138
  sponsoredTx?: boolean,
1097
- suiCoinObjectsForPythUpdate?: string[],
1139
+ sender?: string,
1098
1140
  ): Promise<Transaction> {
1099
1141
  let tx = new Transaction()
1100
1142
  // Handle oracle initialization and coin processing
1101
1143
  let suiCoinObject
1102
1144
  if (sponsoredTx) {
1103
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
1104
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
1145
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
1146
+ sender: this.requireSenderForSponsored(sender),
1147
+ additionalSuiAmount: 0n,
1148
+ })
1149
+ tx = oracle.tx
1150
+ suiCoinObject = oracle.suiCoinObject
1105
1151
  }
1106
1152
  else {
1107
- tx = await this.initOracleTxb([collateralToken, indexToken], tx)
1153
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
1108
1154
  }
1109
1155
  const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
1110
1156
 
@@ -1239,7 +1285,7 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
1239
1285
  collateralToken: string,
1240
1286
  indexToken: string,
1241
1287
  ): Promise<Transaction> {
1242
- const tx = await this.initOracleTxb([collateralToken, indexToken])
1288
+ const { tx } = await this.initOracleTxb([collateralToken, indexToken])
1243
1289
  return tx
1244
1290
  }
1245
1291