@zofai/zo-sdk 0.2.8 → 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 (112) 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.d.cts.map +1 -1
  12. package/dist/api.d.mts.map +1 -1
  13. package/dist/api.mjs +12 -12
  14. package/dist/api.mjs.map +1 -1
  15. package/dist/coins.cjs +74 -0
  16. package/dist/coins.cjs.map +1 -0
  17. package/dist/coins.d.cts +37 -0
  18. package/dist/coins.d.cts.map +1 -0
  19. package/dist/coins.d.mts +37 -0
  20. package/dist/coins.d.mts.map +1 -0
  21. package/dist/coins.mjs +67 -0
  22. package/dist/coins.mjs.map +1 -0
  23. package/dist/consts/deployments-usdz-mainnet.json +1 -1
  24. package/dist/implementations/SLPAPI.cjs +192 -100
  25. package/dist/implementations/SLPAPI.cjs.map +1 -1
  26. package/dist/implementations/SLPAPI.d.cts +23 -23
  27. package/dist/implementations/SLPAPI.d.cts.map +1 -1
  28. package/dist/implementations/SLPAPI.d.mts +23 -23
  29. package/dist/implementations/SLPAPI.d.mts.map +1 -1
  30. package/dist/implementations/SLPAPI.mjs +192 -100
  31. package/dist/implementations/SLPAPI.mjs.map +1 -1
  32. package/dist/implementations/SLPDataAPI.cjs +2 -2
  33. package/dist/implementations/SLPDataAPI.cjs.map +1 -1
  34. package/dist/implementations/SLPDataAPI.mjs +2 -2
  35. package/dist/implementations/SLPDataAPI.mjs.map +1 -1
  36. package/dist/implementations/USDZAPI.cjs +176 -92
  37. package/dist/implementations/USDZAPI.cjs.map +1 -1
  38. package/dist/implementations/USDZAPI.d.cts +21 -21
  39. package/dist/implementations/USDZAPI.d.cts.map +1 -1
  40. package/dist/implementations/USDZAPI.d.mts +21 -21
  41. package/dist/implementations/USDZAPI.d.mts.map +1 -1
  42. package/dist/implementations/USDZAPI.mjs +176 -92
  43. package/dist/implementations/USDZAPI.mjs.map +1 -1
  44. package/dist/implementations/ZBTCVCAPI.cjs +84 -46
  45. package/dist/implementations/ZBTCVCAPI.cjs.map +1 -1
  46. package/dist/implementations/ZBTCVCAPI.d.cts +11 -11
  47. package/dist/implementations/ZBTCVCAPI.d.cts.map +1 -1
  48. package/dist/implementations/ZBTCVCAPI.d.mts +11 -11
  49. package/dist/implementations/ZBTCVCAPI.d.mts.map +1 -1
  50. package/dist/implementations/ZBTCVCAPI.mjs +84 -46
  51. package/dist/implementations/ZBTCVCAPI.mjs.map +1 -1
  52. package/dist/implementations/ZLPAPI.cjs +192 -100
  53. package/dist/implementations/ZLPAPI.cjs.map +1 -1
  54. package/dist/implementations/ZLPAPI.d.cts +23 -23
  55. package/dist/implementations/ZLPAPI.d.cts.map +1 -1
  56. package/dist/implementations/ZLPAPI.d.mts +23 -23
  57. package/dist/implementations/ZLPAPI.d.mts.map +1 -1
  58. package/dist/implementations/ZLPAPI.mjs +192 -100
  59. package/dist/implementations/ZLPAPI.mjs.map +1 -1
  60. package/dist/index.cjs +1 -0
  61. package/dist/index.cjs.map +1 -1
  62. package/dist/index.d.cts +1 -0
  63. package/dist/index.d.cts.map +1 -1
  64. package/dist/index.d.mts +1 -0
  65. package/dist/index.d.mts.map +1 -1
  66. package/dist/index.mjs +1 -0
  67. package/dist/index.mjs.map +1 -1
  68. package/dist/interfaces/base.d.cts +25 -21
  69. package/dist/interfaces/base.d.cts.map +1 -1
  70. package/dist/interfaces/base.d.mts +25 -21
  71. package/dist/interfaces/base.d.mts.map +1 -1
  72. package/dist/interfaces/slp.d.cts +1 -1
  73. package/dist/interfaces/slp.d.cts.map +1 -1
  74. package/dist/interfaces/slp.d.mts +1 -1
  75. package/dist/interfaces/slp.d.mts.map +1 -1
  76. package/dist/interfaces/usdz.d.cts +1 -1
  77. package/dist/interfaces/usdz.d.cts.map +1 -1
  78. package/dist/interfaces/usdz.d.mts +1 -1
  79. package/dist/interfaces/usdz.d.mts.map +1 -1
  80. package/dist/interfaces/zbtcvc.d.cts +1 -1
  81. package/dist/interfaces/zbtcvc.d.cts.map +1 -1
  82. package/dist/interfaces/zbtcvc.d.mts +1 -1
  83. package/dist/interfaces/zbtcvc.d.mts.map +1 -1
  84. package/dist/interfaces/zlp.d.cts +1 -1
  85. package/dist/interfaces/zlp.d.cts.map +1 -1
  86. package/dist/interfaces/zlp.d.mts +1 -1
  87. package/dist/interfaces/zlp.d.mts.map +1 -1
  88. package/dist/oracle.cjs +27 -22
  89. package/dist/oracle.cjs.map +1 -1
  90. package/dist/oracle.d.cts +13 -1
  91. package/dist/oracle.d.cts.map +1 -1
  92. package/dist/oracle.d.mts +13 -1
  93. package/dist/oracle.d.mts.map +1 -1
  94. package/dist/oracle.mjs +27 -22
  95. package/dist/oracle.mjs.map +1 -1
  96. package/package.json +1 -1
  97. package/src/abstract/BaseAPI.ts +10 -8
  98. package/src/api.ts +17 -13
  99. package/src/coins.ts +115 -0
  100. package/src/consts/deployments-usdz-mainnet.json +1 -1
  101. package/src/implementations/SLPAPI.ts +201 -117
  102. package/src/implementations/SLPDataAPI.ts +2 -2
  103. package/src/implementations/USDZAPI.ts +184 -94
  104. package/src/implementations/ZBTCVCAPI.ts +98 -48
  105. package/src/implementations/ZLPAPI.ts +199 -102
  106. package/src/index.ts +1 -0
  107. package/src/interfaces/base.ts +13 -21
  108. package/src/interfaces/slp.ts +0 -1
  109. package/src/interfaces/usdz.ts +0 -1
  110. package/src/interfaces/zbtcvc.ts +0 -1
  111. package/src/interfaces/zlp.ts +0 -1
  112. package/src/oracle.ts +64 -28
@@ -53,7 +53,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
53
53
  referralAddress?: string,
54
54
  sender?: string,
55
55
  sponsoredTx?: boolean,
56
- suiCoinObjectsForPythUpdate?: string[],
57
56
  ): Promise<Transaction> {
58
57
  let tx = new Transaction()
59
58
 
@@ -67,12 +66,16 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
67
66
 
68
67
  // Handle sponsored transaction case
69
68
  if (sponsoredTx) {
70
- const suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
71
- tx = await this.initOracleTxb(pythFeederKeys, tx, true, suiCoinObject)
69
+ const oracle = await this.initOracleTxb(pythFeederKeys, tx, true, {
70
+ sender: this.requireSenderForSponsored(sender),
71
+ additionalSuiAmount: coin === 'sui' ? BigInt(amount) : 0n,
72
+ })
73
+ tx = oracle.tx
74
+ const { suiCoinObject } = oracle
72
75
 
73
76
  // Process deposit coins
74
77
  const depositObject = coin === 'sui'
75
- ? tx.splitCoins(suiCoinObject, [tx.pure.u64(amount)])[0]
78
+ ? tx.splitCoins(suiCoinObject!, [tx.pure.u64(amount)])[0]
76
79
  : tx.splitCoins(this.processCoins(tx, coin, coinObjects, true), [tx.pure.u64(amount)])[0]
77
80
 
78
81
  const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
@@ -96,7 +99,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
96
99
  }
97
100
 
98
101
  // Handle non-sponsored transaction case
99
- tx = await this.initOracleTxb(pythFeederKeys, tx)
102
+ tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx
100
103
  const depositObject = tx.splitCoins(
101
104
  this.processCoins(tx, coin, coinObjects, false),
102
105
  [tx.pure.u64(amount)],
@@ -134,7 +137,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
134
137
  sender?: string,
135
138
  tx?: Transaction,
136
139
  sponsoredTx?: boolean,
137
- suiCoinObjectsForPythUpdate?: string[],
138
140
  ): Promise<TransactionObjectArgument> {
139
141
  if (!tx) {
140
142
  tx = new Transaction()
@@ -150,12 +152,16 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
150
152
 
151
153
  // Handle sponsored transaction case
152
154
  if (sponsoredTx) {
153
- const suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
154
- tx = await this.initOracleTxb(pythFeederKeys, tx, true, suiCoinObject)
155
+ const oracle = await this.initOracleTxb(pythFeederKeys, tx, true, {
156
+ sender: this.requireSenderForSponsored(sender),
157
+ additionalSuiAmount: coin === 'sui' ? BigInt(amount) : 0n,
158
+ })
159
+ tx = oracle.tx
160
+ const { suiCoinObject } = oracle
155
161
 
156
162
  // Process deposit coins
157
163
  const depositObject = coin === 'sui'
158
- ? tx.splitCoins(suiCoinObject, [tx.pure.u64(amount)])[0]
164
+ ? tx.splitCoins(suiCoinObject!, [tx.pure.u64(amount)])[0]
159
165
  : tx.splitCoins(this.processCoins(tx, coin, coinObjects, true), [tx.pure.u64(amount)])[0]
160
166
 
161
167
  const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
@@ -176,7 +182,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
176
182
  }
177
183
 
178
184
  // Handle non-sponsored transaction case
179
- tx = await this.initOracleTxb(pythFeederKeys, tx)
185
+ tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx
180
186
  const depositObject = tx.splitCoins(
181
187
  this.processCoins(tx, coin, coinObjects, false),
182
188
  [tx.pure.u64(amount)],
@@ -214,7 +220,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
214
220
  sender?: string,
215
221
  tx?: Transaction,
216
222
  sponsoredTx?: boolean,
217
- suiCoinObjectsForPythUpdate?: string[],
218
223
  ): Promise<Transaction> {
219
224
  if (!tx) {
220
225
  tx = new Transaction()
@@ -230,8 +235,12 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
230
235
 
231
236
  // Handle sponsored transaction case
232
237
  if (sponsoredTx) {
233
- const suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
234
- tx = await this.initOracleTxb(pythFeederKeys, tx, true, suiCoinObject)
238
+ const oracle = await this.initOracleTxb(pythFeederKeys, tx, true, {
239
+ sender: this.requireSenderForSponsored(sender),
240
+ additionalSuiAmount: 0n,
241
+ })
242
+ tx = oracle.tx
243
+ const { suiCoinObject } = oracle
235
244
 
236
245
  const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
237
246
 
@@ -254,7 +263,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
254
263
  }
255
264
 
256
265
  // Handle non-sponsored transaction case
257
- tx = await this.initOracleTxb(pythFeederKeys, tx)
266
+ tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx
258
267
 
259
268
  const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
260
269
 
@@ -285,7 +294,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
285
294
  amount: number,
286
295
  minAmountOut = 0,
287
296
  sponsoredTx?: boolean,
288
- suiCoinObjectsForPythUpdate?: string[],
297
+ sender?: string,
289
298
  ): Promise<Transaction> {
290
299
  let tx = new Transaction()
291
300
 
@@ -293,11 +302,15 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
293
302
  const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder)
294
303
 
295
304
  if (sponsoredTx) {
296
- const suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
297
- tx = await this.initOracleTxb(pythFeederKeys, tx, true, suiCoinObject)
305
+ const oracle = await this.initOracleTxb(pythFeederKeys, tx, true, {
306
+ sender: this.requireSenderForSponsored(sender),
307
+ additionalSuiAmount: 0n,
308
+ })
309
+ tx = oracle.tx
310
+ const { suiCoinObject } = oracle
298
311
  }
299
312
  else {
300
- tx = await this.initOracleTxb(pythFeederKeys, tx)
313
+ tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx
301
314
  }
302
315
 
303
316
  const slpCoinObject = this.processCoins(tx, 'slp', lpCoinObjects, false)
@@ -338,7 +351,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
338
351
  // Initialize oracle transaction
339
352
  const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder)
340
353
 
341
- tx = await this.initOracleTxb(pythFeederKeys, tx)
354
+ tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx
342
355
  const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
343
356
 
344
357
  tx.moveCall({
@@ -366,7 +379,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
366
379
  minAmountOut = 0,
367
380
  tx?: Transaction,
368
381
  sponsoredTx?: boolean,
369
- suiCoinObjectsForPythUpdate?: string[],
382
+ sender?: string,
370
383
  ): Promise<TransactionObjectArgument> {
371
384
  if (!tx) {
372
385
  tx = new Transaction()
@@ -376,11 +389,15 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
376
389
  const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder)
377
390
 
378
391
  if (sponsoredTx) {
379
- const suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
380
- tx = await this.initOracleTxb(pythFeederKeys, tx, true, suiCoinObject)
392
+ const oracle = await this.initOracleTxb(pythFeederKeys, tx, true, {
393
+ sender: this.requireSenderForSponsored(sender),
394
+ additionalSuiAmount: 0n,
395
+ })
396
+ tx = oracle.tx
397
+ const { suiCoinObject } = oracle
381
398
  }
382
399
  else {
383
- tx = await this.initOracleTxb(pythFeederKeys, tx)
400
+ tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx
384
401
  }
385
402
 
386
403
  const slpCoinObject = this.processCoins(tx, 'slp', lpCoinObjects, false)
@@ -412,9 +429,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
412
429
  fromCoinObjects: string[],
413
430
  minAmountOut?: number,
414
431
  ): Promise<Transaction> {
415
- const tx = await this.initOracleTxb(
416
- Object.keys(this.consts.sudoCore.vaults),
417
- )
432
+ const { tx } = await this.initOracleTxb(Object.keys(this.consts.sudoCore.vaults))
418
433
  const fromCoinObject = this.processCoins(tx, fromToken, fromCoinObjects)
419
434
  const [fromDepositObject] = tx.splitCoins(fromCoinObject, [
420
435
  tx.pure.u64(fromAmount),
@@ -457,10 +472,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
457
472
  if (!tx) {
458
473
  tx = new Transaction()
459
474
  }
460
- tx = await this.initOracleTxb(
461
- Object.keys(this.consts.sudoCore.vaults),
462
- tx,
463
- )
475
+ tx = (await this.initOracleTxb(Object.keys(this.consts.sudoCore.vaults), tx)).tx
464
476
  const fromCoinObject = this.processCoins(tx, fromToken, fromCoinObjects)
465
477
  const [fromDepositObject] = tx.splitCoins(fromCoinObject, [
466
478
  tx.pure.u64(fromAmount),
@@ -707,7 +719,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
707
719
  referralAddress?: string,
708
720
  sender?: string,
709
721
  sponsoredTx?: boolean,
710
- suiCoinObjectsForPythUpdate?: string[],
711
722
  ): Promise<Transaction> {
712
723
  let tx = new Transaction()
713
724
  if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
@@ -725,11 +736,15 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
725
736
  // Handle oracle initialization and coin processing
726
737
  let suiCoinObject
727
738
  if (sponsoredTx) {
728
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
729
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
739
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
740
+ sender: this.requireSenderForSponsored(sender),
741
+ additionalSuiAmount: collateralToken === 'sui' ? collateralAmount + relayerFee : 0n,
742
+ })
743
+ tx = oracle.tx
744
+ suiCoinObject = oracle.suiCoinObject
730
745
  }
731
746
  else {
732
- tx = await this.initOracleTxb([collateralToken, indexToken], tx)
747
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
733
748
  }
734
749
 
735
750
  // Process coin splitting
@@ -794,7 +809,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
794
809
  sender?: string,
795
810
  tx?: Transaction,
796
811
  sponsoredTx?: boolean,
797
- suiCoinObjectsForPythUpdate?: string[],
798
812
  ): Promise<Transaction> {
799
813
  if (!tx) {
800
814
  tx = new Transaction()
@@ -814,11 +828,15 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
814
828
  // Handle oracle initialization and coin processing
815
829
  let suiCoinObject
816
830
  if (sponsoredTx) {
817
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
818
- 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
819
837
  }
820
838
  else {
821
- tx = await this.initOracleTxb([collateralToken, indexToken], tx)
839
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
822
840
  }
823
841
 
824
842
  // Process coin splitting
@@ -876,7 +894,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
876
894
  referralAddress?: string,
877
895
  sender?: string,
878
896
  sponsoredTx?: boolean,
879
- suiCoinObjectsForPythUpdate?: string[],
880
897
  ): Promise<Transaction> {
881
898
  let tx = new Transaction()
882
899
  if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
@@ -896,11 +913,15 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
896
913
  // Handle oracle initialization and coin processing
897
914
  let suiCoinObject
898
915
  if (sponsoredTx) {
899
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
900
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
916
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
917
+ sender: this.requireSenderForSponsored(sender),
918
+ additionalSuiAmount: collateralToken === 'sui' ? collateralAmount + relayerFee : 0n,
919
+ })
920
+ tx = oracle.tx
921
+ suiCoinObject = oracle.suiCoinObject
901
922
  }
902
923
  else {
903
- tx = await this.initOracleTxb([collateralToken, indexToken], tx)
924
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
904
925
  }
905
926
 
906
927
  // Process coin splitting
@@ -963,7 +984,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
963
984
  sender?: string,
964
985
  tx?: Transaction,
965
986
  sponsoredTx?: boolean,
966
- suiCoinObjectsForPythUpdate?: string[],
967
987
  ): Promise<Transaction> {
968
988
  if (!tx) {
969
989
  tx = new Transaction()
@@ -985,11 +1005,15 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
985
1005
  // Handle oracle initialization and coin processing
986
1006
  let suiCoinObject
987
1007
  if (sponsoredTx) {
988
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
989
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
1008
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
1009
+ sender: this.requireSenderForSponsored(sender),
1010
+ additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
1011
+ })
1012
+ tx = oracle.tx
1013
+ suiCoinObject = oracle.suiCoinObject
990
1014
  }
991
1015
  else {
992
- tx = await this.initOracleTxb([collateralToken, indexToken], tx)
1016
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
993
1017
  }
994
1018
 
995
1019
  // Process coin splitting
@@ -1043,7 +1067,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
1043
1067
  relayerFee = BigInt(0.5),
1044
1068
  coinObjects?: string[],
1045
1069
  sponsoredTx?: boolean,
1046
- suiCoinObjectsForPythUpdate?: string[],
1070
+ sender?: string,
1047
1071
  ): Promise<Transaction> {
1048
1072
  if (!coinObjects) {
1049
1073
  throw new Error(`${this.constructor.name}: coinObjects is required`)
@@ -1052,11 +1076,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
1052
1076
  let tx = new Transaction()
1053
1077
  const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
1054
1078
 
1055
- const adjustPrice = this.processSlippage(
1056
- indexPrice,
1057
- !long,
1058
- isTriggerOrder ? 0 : pricesSlippage,
1059
- )
1079
+ const adjustPrice = this.processSlippage(indexPrice, !long, isTriggerOrder ? 0 : pricesSlippage)
1060
1080
  const adjustCollateralPrice = this.processSlippage(
1061
1081
  collateralPrice,
1062
1082
  false,
@@ -1073,11 +1093,15 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
1073
1093
 
1074
1094
  let suiCoinObject
1075
1095
  if (sponsoredTx) {
1076
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
1077
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
1096
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
1097
+ sender: this.requireSenderForSponsored(sender),
1098
+ additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
1099
+ })
1100
+ tx = oracle.tx
1101
+ suiCoinObject = oracle.suiCoinObject
1078
1102
  }
1079
1103
  else {
1080
- tx = await this.initOracleTxb([collateralToken, indexToken], tx)
1104
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
1081
1105
  }
1082
1106
 
1083
1107
  // Handle oracle initialization and coin processing
@@ -1140,7 +1164,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
1140
1164
  relayerFee = BigInt(0.5),
1141
1165
  coinObjects?: string[],
1142
1166
  sponsoredTx?: boolean,
1143
- suiCoinObjectsForPythUpdate?: string[],
1167
+ sender?: string,
1144
1168
  ): Promise<Transaction> {
1145
1169
  if (!coinObjects) {
1146
1170
  throw new Error(`${this.constructor.name}: coinObjects is required`)
@@ -1163,11 +1187,15 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
1163
1187
  // Handle oracle initialization and coin processing
1164
1188
  let suiCoinObject
1165
1189
  if (sponsoredTx) {
1166
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
1167
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
1190
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
1191
+ sender: this.requireSenderForSponsored(sender),
1192
+ additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
1193
+ })
1194
+ tx = oracle.tx
1195
+ suiCoinObject = oracle.suiCoinObject
1168
1196
  }
1169
1197
  else {
1170
- tx = await this.initOracleTxb([collateralToken, indexToken], tx)
1198
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
1171
1199
  }
1172
1200
 
1173
1201
  // Process coin splitting
@@ -1227,7 +1255,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
1227
1255
  }>,
1228
1256
  tx?: Transaction,
1229
1257
  sponsoredTx?: boolean,
1230
- suiCoinObjectsForPythUpdate?: string[],
1258
+ sender?: string,
1231
1259
  ): Promise<Transaction> {
1232
1260
  if (!tx) {
1233
1261
  tx = new Transaction()
@@ -1236,11 +1264,20 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
1236
1264
  // Handle oracle initialization and coin processing
1237
1265
  let suiCoinObject
1238
1266
  if (sponsoredTx) {
1239
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
1240
- tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx, true, suiCoinObject)
1267
+ const oracle = await this.initOracleTxb(
1268
+ positions.flatMap(position => [position.collateralToken, position.indexToken]),
1269
+ tx,
1270
+ true,
1271
+ { sender: this.requireSenderForSponsored(sender) },
1272
+ )
1273
+ tx = oracle.tx
1274
+ suiCoinObject = oracle.suiCoinObject
1241
1275
  }
1242
1276
  else {
1243
- tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx)
1277
+ tx = (await this.initOracleTxb(
1278
+ positions.flatMap(position => [position.collateralToken, position.indexToken]),
1279
+ tx,
1280
+ )).tx
1244
1281
  }
1245
1282
 
1246
1283
  for (const position of positions) {
@@ -1330,15 +1367,22 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
1330
1367
  collateralSlippage?: number
1331
1368
  relayerFee?: bigint
1332
1369
  coinObjects?: string[]
1333
- }>, tx?: Transaction, sponsoredTx?: boolean, suiCoinObjectsForPythUpdate?: string[], feeObjects?: TransactionObjectArgument[]): Promise<Transaction> {
1334
- const transaction = tx ?? new Transaction()
1370
+ }>, tx?: Transaction, sponsoredTx?: boolean, sender?: string, feeObjects?: TransactionObjectArgument[]): Promise<Transaction> {
1371
+ let transaction = tx ?? new Transaction()
1335
1372
 
1336
1373
  // Handle oracle initialization and coin processing
1337
1374
  const tokens = positions.flatMap(position => [position.collateralToken, position.indexToken])
1338
- const suiCoinObject = sponsoredTx
1339
- ? this.processCoins(transaction, 'sui', suiCoinObjectsForPythUpdate || [], true)
1340
- : undefined
1341
- await this.initOracleTxb(tokens, transaction, !!sponsoredTx, suiCoinObject)
1375
+ let suiCoinObject
1376
+ if (sponsoredTx) {
1377
+ const oracle = await this.initOracleTxb(tokens, transaction, true, {
1378
+ sender: this.requireSenderForSponsored(sender),
1379
+ })
1380
+ transaction = oracle.tx
1381
+ suiCoinObject = oracle.suiCoinObject
1382
+ }
1383
+ else {
1384
+ transaction = (await this.initOracleTxb(tokens, transaction, false)).tx
1385
+ }
1342
1386
 
1343
1387
  if (!feeObjects || feeObjects.length !== positions.length) {
1344
1388
  throw new Error('feeObjects must be provided (pre-processed via buildFeeCoinObjects) and match positions length')
@@ -1410,18 +1454,22 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
1410
1454
  coinObjects: string[],
1411
1455
  long: boolean,
1412
1456
  sponsoredTx?: boolean,
1413
- suiCoinObjectsForPythUpdate?: string[],
1457
+ sender?: string,
1414
1458
  ): Promise<Transaction> {
1415
1459
  let tx = new Transaction()
1416
1460
 
1417
1461
  // Handle oracle initialization and coin processing
1418
1462
  let suiCoinObject
1419
1463
  if (sponsoredTx) {
1420
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
1421
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
1464
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
1465
+ sender: this.requireSenderForSponsored(sender),
1466
+ additionalSuiAmount: collateralToken === 'sui' ? BigInt(amount) : 0n,
1467
+ })
1468
+ tx = oracle.tx
1469
+ suiCoinObject = oracle.suiCoinObject
1422
1470
  }
1423
1471
  else {
1424
- tx = await this.initOracleTxb([collateralToken, indexToken], tx)
1472
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
1425
1473
  }
1426
1474
 
1427
1475
  // Process coin splitting
@@ -1458,17 +1506,21 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
1458
1506
  amount: number,
1459
1507
  long: boolean,
1460
1508
  sponsoredTx?: boolean,
1461
- suiCoinObjectsForPythUpdate?: string[],
1509
+ sender?: string,
1462
1510
  ): Promise<Transaction> {
1463
1511
  let tx = new Transaction()
1464
1512
  // Handle oracle initialization and coin processing
1465
1513
  let suiCoinObject
1466
1514
  if (sponsoredTx) {
1467
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
1468
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
1515
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
1516
+ sender: this.requireSenderForSponsored(sender),
1517
+ additionalSuiAmount: 0n,
1518
+ })
1519
+ tx = oracle.tx
1520
+ suiCoinObject = oracle.suiCoinObject
1469
1521
  }
1470
1522
  else {
1471
- tx = await this.initOracleTxb([collateralToken, indexToken], tx)
1523
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
1472
1524
  }
1473
1525
  const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
1474
1526
 
@@ -1732,7 +1784,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
1732
1784
  referralAddress?: string,
1733
1785
  sender?: string,
1734
1786
  sponsoredTx?: boolean,
1735
- suiCoinObjectsForPythUpdate?: string[],
1736
1787
  ): Promise<Transaction> {
1737
1788
  let tx = new Transaction()
1738
1789
  if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
@@ -1762,11 +1813,15 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
1762
1813
  // Handle oracle initialization and coin processing
1763
1814
  let suiCoinObject
1764
1815
  if (sponsoredTx) {
1765
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
1766
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
1816
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
1817
+ sender: this.requireSenderForSponsored(sender),
1818
+ additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
1819
+ })
1820
+ tx = oracle.tx
1821
+ suiCoinObject = oracle.suiCoinObject
1767
1822
  }
1768
1823
  else {
1769
- tx = await this.initOracleTxb([collateralToken, indexToken], tx)
1824
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
1770
1825
  }
1771
1826
 
1772
1827
  // Process coin splitting
@@ -1840,7 +1895,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
1840
1895
  sender?: string,
1841
1896
  tx?: Transaction,
1842
1897
  sponsoredTx?: boolean,
1843
- suiCoinObjectsForPythUpdate?: string[],
1844
1898
  ): Promise<Transaction> {
1845
1899
  if (!tx) {
1846
1900
  tx = new Transaction()
@@ -1872,11 +1926,15 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
1872
1926
  // Handle oracle initialization and coin processing
1873
1927
  let suiCoinObject
1874
1928
  if (sponsoredTx) {
1875
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
1876
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
1929
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
1930
+ sender: this.requireSenderForSponsored(sender),
1931
+ additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
1932
+ })
1933
+ tx = oracle.tx
1934
+ suiCoinObject = oracle.suiCoinObject
1877
1935
  }
1878
1936
  else {
1879
- tx = await this.initOracleTxb([collateralToken, indexToken], tx)
1937
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
1880
1938
  }
1881
1939
 
1882
1940
  // Process coin splitting
@@ -1943,7 +2001,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
1943
2001
  referralAddress?: string,
1944
2002
  sender?: string,
1945
2003
  sponsoredTx?: boolean,
1946
- suiCoinObjectsForPythUpdate?: string[],
1947
2004
  ): Promise<Transaction> {
1948
2005
  let tx = new Transaction()
1949
2006
  if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
@@ -1974,11 +2031,15 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
1974
2031
  // Handle oracle initialization and coin processing
1975
2032
  let suiCoinObject
1976
2033
  if (sponsoredTx) {
1977
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
1978
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
2034
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
2035
+ sender: this.requireSenderForSponsored(sender),
2036
+ additionalSuiAmount: collateralToken === 'sui' ? collateralAmount + relayerFee : 0n,
2037
+ })
2038
+ tx = oracle.tx
2039
+ suiCoinObject = oracle.suiCoinObject
1979
2040
  }
1980
2041
  else {
1981
- tx = await this.initOracleTxb([collateralToken, indexToken], tx)
2042
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
1982
2043
  }
1983
2044
 
1984
2045
  // Process coin splitting
@@ -2051,7 +2112,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
2051
2112
  sender?: string,
2052
2113
  tx?: Transaction,
2053
2114
  sponsoredTx?: boolean,
2054
- suiCoinObjectsForPythUpdate?: string[],
2055
2115
  ): Promise<Transaction> {
2056
2116
  if (!tx) {
2057
2117
  tx = new Transaction()
@@ -2084,11 +2144,15 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
2084
2144
  // Handle oracle initialization and coin processing
2085
2145
  let suiCoinObject
2086
2146
  if (sponsoredTx) {
2087
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
2088
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
2147
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
2148
+ sender: this.requireSenderForSponsored(sender),
2149
+ additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
2150
+ })
2151
+ tx = oracle.tx
2152
+ suiCoinObject = oracle.suiCoinObject
2089
2153
  }
2090
2154
  else {
2091
- tx = await this.initOracleTxb([collateralToken, indexToken], tx)
2155
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
2092
2156
  }
2093
2157
 
2094
2158
  // Process coin splitting
@@ -2151,7 +2215,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
2151
2215
  relayerFee = BigInt(0.5),
2152
2216
  coinObjects?: string[],
2153
2217
  sponsoredTx?: boolean,
2154
- suiCoinObjectsForPythUpdate?: string[],
2218
+ sender?: string,
2155
2219
  ): Promise<Transaction> {
2156
2220
  if (!coinObjects) {
2157
2221
  throw new Error(`${this.constructor.name}: coinObjects is required`)
@@ -2160,11 +2224,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
2160
2224
  let tx = new Transaction()
2161
2225
  const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
2162
2226
 
2163
- const adjustPrice = this.processSlippage(
2164
- indexPrice,
2165
- !long,
2166
- isTriggerOrder ? 0 : pricesSlippage,
2167
- )
2227
+ const adjustPrice = this.processSlippage(indexPrice, !long, isTriggerOrder ? 0 : pricesSlippage)
2168
2228
  const adjustCollateralPrice = this.processSlippage(
2169
2229
  collateralPrice,
2170
2230
  false,
@@ -2193,11 +2253,15 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
2193
2253
  // Handle oracle initialization and coin processing
2194
2254
  let suiCoinObject
2195
2255
  if (sponsoredTx) {
2196
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
2197
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
2256
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
2257
+ sender: this.requireSenderForSponsored(sender),
2258
+ additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
2259
+ })
2260
+ tx = oracle.tx
2261
+ suiCoinObject = oracle.suiCoinObject
2198
2262
  }
2199
2263
  else {
2200
- tx = await this.initOracleTxb([collateralToken, indexToken], tx)
2264
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
2201
2265
  }
2202
2266
 
2203
2267
  // Process coin splitting
@@ -2268,7 +2332,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
2268
2332
  relayerFee = BigInt(0.5),
2269
2333
  coinObjects?: string[],
2270
2334
  sponsoredTx?: boolean,
2271
- suiCoinObjectsForPythUpdate?: string[],
2335
+ sender?: string,
2272
2336
  ): Promise<Transaction> {
2273
2337
  if (!coinObjects) {
2274
2338
  throw new Error(`${this.constructor.name}: coinObjects is required`)
@@ -2302,11 +2366,15 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
2302
2366
  // Handle oracle initialization and coin processing
2303
2367
  let suiCoinObject
2304
2368
  if (sponsoredTx) {
2305
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
2306
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject)
2369
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
2370
+ sender: this.requireSenderForSponsored(sender),
2371
+ additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
2372
+ })
2373
+ tx = oracle.tx
2374
+ suiCoinObject = oracle.suiCoinObject
2307
2375
  }
2308
2376
  else {
2309
- tx = await this.initOracleTxb([collateralToken, indexToken], tx)
2377
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
2310
2378
  }
2311
2379
 
2312
2380
  // Process coin splitting
@@ -2377,7 +2445,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
2377
2445
  scard: string,
2378
2446
  tx?: Transaction,
2379
2447
  sponsoredTx?: boolean,
2380
- suiCoinObjectsForPythUpdate?: string[],
2448
+ sender?: string,
2381
2449
  ): Promise<Transaction> {
2382
2450
  if (!tx) {
2383
2451
  tx = new Transaction()
@@ -2386,11 +2454,20 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
2386
2454
  // Handle oracle initialization and coin processing
2387
2455
  let suiCoinObject
2388
2456
  if (sponsoredTx) {
2389
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true)
2390
- tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx, true, suiCoinObject)
2457
+ const oracle = await this.initOracleTxb(
2458
+ positions.flatMap(position => [position.collateralToken, position.indexToken]),
2459
+ tx,
2460
+ true,
2461
+ { sender: this.requireSenderForSponsored(sender) },
2462
+ )
2463
+ tx = oracle.tx
2464
+ suiCoinObject = oracle.suiCoinObject
2391
2465
  }
2392
2466
  else {
2393
- tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx)
2467
+ tx = (await this.initOracleTxb(
2468
+ positions.flatMap(position => [position.collateralToken, position.indexToken]),
2469
+ tx,
2470
+ )).tx
2394
2471
  }
2395
2472
 
2396
2473
  const kioskTx = new KioskTransaction({
@@ -2507,17 +2584,24 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
2507
2584
  scard: string,
2508
2585
  tx?: Transaction,
2509
2586
  sponsoredTx?: boolean,
2510
- suiCoinObjectsForPythUpdate?: string[],
2587
+ sender?: string,
2511
2588
  feeObjects?: TransactionObjectArgument[],
2512
2589
  ): Promise<Transaction> {
2513
- const transaction = tx ?? new Transaction()
2590
+ let transaction = tx ?? new Transaction()
2514
2591
 
2515
2592
  // Handle oracle initialization and coin processing
2516
2593
  const tokens = positions.flatMap(position => [position.collateralToken, position.indexToken])
2517
- const suiCoinObject = sponsoredTx
2518
- ? this.processCoins(transaction, 'sui', suiCoinObjectsForPythUpdate || [], true)
2519
- : undefined
2520
- await this.initOracleTxb(tokens, transaction, !!sponsoredTx, suiCoinObject)
2594
+ let suiCoinObject
2595
+ if (sponsoredTx) {
2596
+ const oracle = await this.initOracleTxb(tokens, transaction, true, {
2597
+ sender: this.requireSenderForSponsored(sender),
2598
+ })
2599
+ transaction = oracle.tx
2600
+ suiCoinObject = oracle.suiCoinObject
2601
+ }
2602
+ else {
2603
+ transaction = (await this.initOracleTxb(tokens, transaction, false)).tx
2604
+ }
2521
2605
 
2522
2606
  if (!feeObjects || feeObjects.length !== positions.length) {
2523
2607
  throw new Error('feeObjects must be provided (pre-processed via buildFeeCoinObjects) and match positions length')
@@ -2621,7 +2705,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
2621
2705
  collateralToken: string,
2622
2706
  indexToken: string,
2623
2707
  ): Promise<Transaction> {
2624
- const tx = await this.initOracleTxb([collateralToken, indexToken])
2708
+ const { tx } = await this.initOracleTxb([collateralToken, indexToken])
2625
2709
  return tx
2626
2710
  }
2627
2711