@zofai/zo-sdk 0.2.9 → 0.2.11

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 (173) 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 +11 -10
  4. package/dist/abstract/BaseAPI.d.cts.map +1 -1
  5. package/dist/abstract/BaseAPI.d.mts +11 -10
  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/abstract/BaseDataAPI.d.cts +1 -1
  10. package/dist/abstract/BaseDataAPI.d.cts.map +1 -1
  11. package/dist/abstract/BaseDataAPI.d.mts +1 -1
  12. package/dist/abstract/BaseDataAPI.d.mts.map +1 -1
  13. package/dist/api.cjs +12 -12
  14. package/dist/api.cjs.map +1 -1
  15. package/dist/api.d.cts +1 -1
  16. package/dist/api.d.cts.map +1 -1
  17. package/dist/api.d.mts +1 -1
  18. package/dist/api.d.mts.map +1 -1
  19. package/dist/api.mjs +12 -12
  20. package/dist/api.mjs.map +1 -1
  21. package/dist/bcs.d.cts +41 -71
  22. package/dist/bcs.d.cts.map +1 -1
  23. package/dist/bcs.d.mts +41 -71
  24. package/dist/bcs.d.mts.map +1 -1
  25. package/dist/coins.cjs +74 -0
  26. package/dist/coins.cjs.map +1 -0
  27. package/dist/coins.d.cts +37 -0
  28. package/dist/coins.d.cts.map +1 -0
  29. package/dist/coins.d.mts +37 -0
  30. package/dist/coins.d.mts.map +1 -0
  31. package/dist/coins.mjs +67 -0
  32. package/dist/coins.mjs.map +1 -0
  33. package/dist/data.d.cts +6 -6
  34. package/dist/data.d.cts.map +1 -1
  35. package/dist/data.d.mts +6 -6
  36. package/dist/data.d.mts.map +1 -1
  37. package/dist/factory/SDKFactory.d.cts +1 -1
  38. package/dist/factory/SDKFactory.d.cts.map +1 -1
  39. package/dist/factory/SDKFactory.d.mts +1 -1
  40. package/dist/factory/SDKFactory.d.mts.map +1 -1
  41. package/dist/implementations/SLPAPI.cjs +192 -100
  42. package/dist/implementations/SLPAPI.cjs.map +1 -1
  43. package/dist/implementations/SLPAPI.d.cts +24 -24
  44. package/dist/implementations/SLPAPI.d.cts.map +1 -1
  45. package/dist/implementations/SLPAPI.d.mts +24 -24
  46. package/dist/implementations/SLPAPI.d.mts.map +1 -1
  47. package/dist/implementations/SLPAPI.mjs +192 -100
  48. package/dist/implementations/SLPAPI.mjs.map +1 -1
  49. package/dist/implementations/SLPDataAPI.cjs +2 -2
  50. package/dist/implementations/SLPDataAPI.cjs.map +1 -1
  51. package/dist/implementations/SLPDataAPI.d.cts +5 -5
  52. package/dist/implementations/SLPDataAPI.d.cts.map +1 -1
  53. package/dist/implementations/SLPDataAPI.d.mts +5 -5
  54. package/dist/implementations/SLPDataAPI.d.mts.map +1 -1
  55. package/dist/implementations/SLPDataAPI.mjs +2 -2
  56. package/dist/implementations/SLPDataAPI.mjs.map +1 -1
  57. package/dist/implementations/USDZAPI.cjs +176 -92
  58. package/dist/implementations/USDZAPI.cjs.map +1 -1
  59. package/dist/implementations/USDZAPI.d.cts +22 -22
  60. package/dist/implementations/USDZAPI.d.cts.map +1 -1
  61. package/dist/implementations/USDZAPI.d.mts +22 -22
  62. package/dist/implementations/USDZAPI.d.mts.map +1 -1
  63. package/dist/implementations/USDZAPI.mjs +176 -92
  64. package/dist/implementations/USDZAPI.mjs.map +1 -1
  65. package/dist/implementations/USDZDataAPI.d.cts +5 -5
  66. package/dist/implementations/USDZDataAPI.d.cts.map +1 -1
  67. package/dist/implementations/USDZDataAPI.d.mts +5 -5
  68. package/dist/implementations/USDZDataAPI.d.mts.map +1 -1
  69. package/dist/implementations/ZBTCVCAPI.cjs +84 -46
  70. package/dist/implementations/ZBTCVCAPI.cjs.map +1 -1
  71. package/dist/implementations/ZBTCVCAPI.d.cts +12 -12
  72. package/dist/implementations/ZBTCVCAPI.d.cts.map +1 -1
  73. package/dist/implementations/ZBTCVCAPI.d.mts +12 -12
  74. package/dist/implementations/ZBTCVCAPI.d.mts.map +1 -1
  75. package/dist/implementations/ZBTCVCAPI.mjs +84 -46
  76. package/dist/implementations/ZBTCVCAPI.mjs.map +1 -1
  77. package/dist/implementations/ZBTCVCDataAPI.cjs.map +1 -1
  78. package/dist/implementations/ZBTCVCDataAPI.d.cts +5 -5
  79. package/dist/implementations/ZBTCVCDataAPI.d.cts.map +1 -1
  80. package/dist/implementations/ZBTCVCDataAPI.d.mts +5 -5
  81. package/dist/implementations/ZBTCVCDataAPI.d.mts.map +1 -1
  82. package/dist/implementations/ZBTCVCDataAPI.mjs.map +1 -1
  83. package/dist/implementations/ZLPAPI.cjs +192 -100
  84. package/dist/implementations/ZLPAPI.cjs.map +1 -1
  85. package/dist/implementations/ZLPAPI.d.cts +24 -24
  86. package/dist/implementations/ZLPAPI.d.cts.map +1 -1
  87. package/dist/implementations/ZLPAPI.d.mts +24 -24
  88. package/dist/implementations/ZLPAPI.d.mts.map +1 -1
  89. package/dist/implementations/ZLPAPI.mjs +192 -100
  90. package/dist/implementations/ZLPAPI.mjs.map +1 -1
  91. package/dist/implementations/ZLPDataAPI.cjs.map +1 -1
  92. package/dist/implementations/ZLPDataAPI.d.cts +5 -5
  93. package/dist/implementations/ZLPDataAPI.d.cts.map +1 -1
  94. package/dist/implementations/ZLPDataAPI.d.mts +5 -5
  95. package/dist/implementations/ZLPDataAPI.d.mts.map +1 -1
  96. package/dist/implementations/ZLPDataAPI.mjs.map +1 -1
  97. package/dist/index.cjs +2 -0
  98. package/dist/index.cjs.map +1 -1
  99. package/dist/index.d.cts +3 -1
  100. package/dist/index.d.cts.map +1 -1
  101. package/dist/index.d.mts +3 -1
  102. package/dist/index.d.mts.map +1 -1
  103. package/dist/index.mjs +2 -0
  104. package/dist/index.mjs.map +1 -1
  105. package/dist/interfaces/base.d.cts +26 -22
  106. package/dist/interfaces/base.d.cts.map +1 -1
  107. package/dist/interfaces/base.d.mts +26 -22
  108. package/dist/interfaces/base.d.mts.map +1 -1
  109. package/dist/interfaces/slp.d.cts +1 -1
  110. package/dist/interfaces/slp.d.cts.map +1 -1
  111. package/dist/interfaces/slp.d.mts +1 -1
  112. package/dist/interfaces/slp.d.mts.map +1 -1
  113. package/dist/interfaces/usdz.d.cts +1 -1
  114. package/dist/interfaces/usdz.d.cts.map +1 -1
  115. package/dist/interfaces/usdz.d.mts +1 -1
  116. package/dist/interfaces/usdz.d.mts.map +1 -1
  117. package/dist/interfaces/zbtcvc.d.cts +1 -1
  118. package/dist/interfaces/zbtcvc.d.cts.map +1 -1
  119. package/dist/interfaces/zbtcvc.d.mts +1 -1
  120. package/dist/interfaces/zbtcvc.d.mts.map +1 -1
  121. package/dist/interfaces/zlp.d.cts +1 -1
  122. package/dist/interfaces/zlp.d.cts.map +1 -1
  123. package/dist/interfaces/zlp.d.mts +1 -1
  124. package/dist/interfaces/zlp.d.mts.map +1 -1
  125. package/dist/oracle.cjs +27 -22
  126. package/dist/oracle.cjs.map +1 -1
  127. package/dist/oracle.d.cts +14 -2
  128. package/dist/oracle.d.cts.map +1 -1
  129. package/dist/oracle.d.mts +14 -2
  130. package/dist/oracle.d.mts.map +1 -1
  131. package/dist/oracle.mjs +27 -22
  132. package/dist/oracle.mjs.map +1 -1
  133. package/dist/suiClient.cjs +8 -0
  134. package/dist/suiClient.cjs.map +1 -0
  135. package/dist/suiClient.d.cts +8 -0
  136. package/dist/suiClient.d.cts.map +1 -0
  137. package/dist/suiClient.d.mts +8 -0
  138. package/dist/suiClient.d.mts.map +1 -0
  139. package/dist/suiClient.mjs +2 -0
  140. package/dist/suiClient.mjs.map +1 -0
  141. package/dist/utils.cjs +7 -3
  142. package/dist/utils.cjs.map +1 -1
  143. package/dist/utils.d.cts +2 -2
  144. package/dist/utils.d.cts.map +1 -1
  145. package/dist/utils.d.mts +2 -2
  146. package/dist/utils.d.mts.map +1 -1
  147. package/dist/utils.mjs +7 -3
  148. package/dist/utils.mjs.map +1 -1
  149. package/package.json +4 -4
  150. package/src/abstract/BaseAPI.ts +11 -9
  151. package/src/abstract/BaseDataAPI.ts +1 -1
  152. package/src/api.ts +13 -17
  153. package/src/coins.ts +116 -0
  154. package/src/data.ts +1 -1
  155. package/src/factory/SDKFactory.ts +1 -1
  156. package/src/implementations/SLPAPI.ts +200 -116
  157. package/src/implementations/SLPDataAPI.ts +3 -3
  158. package/src/implementations/USDZAPI.ts +185 -95
  159. package/src/implementations/USDZDataAPI.ts +1 -1
  160. package/src/implementations/ZBTCVCAPI.ts +99 -53
  161. package/src/implementations/ZBTCVCDataAPI.ts +1 -1
  162. package/src/implementations/ZLPAPI.ts +200 -111
  163. package/src/implementations/ZLPDataAPI.ts +1 -1
  164. package/src/index.ts +3 -1
  165. package/src/interfaces/base.ts +14 -22
  166. package/src/interfaces/slp.ts +0 -1
  167. package/src/interfaces/usdz.ts +0 -1
  168. package/src/interfaces/zbtcvc.ts +0 -1
  169. package/src/interfaces/zlp.ts +0 -1
  170. package/src/oracle.ts +70 -30
  171. package/src/suiClient.ts +11 -0
  172. package/src/utils.ts +9 -3
  173. package/tsconfig.json +8 -1
@@ -91,7 +91,7 @@ class USDZAPI extends abstract_1.BaseAPI {
91
91
  arguments: [tx.object(this.consts.zoCore.market), tx.object(orderCapId)],
92
92
  });
93
93
  }
94
- async openPositionWithSCard(collateralToken, indexToken, size, collateralAmount, coinObjects, long, reserveAmount, indexPrice, collateralPrice, kioskClient, kioskCap, scard, isLimitOrder, isIocOrder, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), referralAddress, sender, sponsoredTx, suiCoinObjectsForPythUpdate) {
94
+ async openPositionWithSCard(collateralToken, indexToken, size, collateralAmount, coinObjects, long, reserveAmount, indexPrice, collateralPrice, kioskClient, kioskCap, scard, isLimitOrder, isIocOrder, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), referralAddress, sender, sponsoredTx) {
95
95
  let tx = new transactions_1.Transaction();
96
96
  if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
97
97
  tx = await this.addReferral(referralAddress, tx);
@@ -115,11 +115,15 @@ class USDZAPI extends abstract_1.BaseAPI {
115
115
  // Handle oracle initialization and coin processing
116
116
  let suiCoinObject;
117
117
  if (sponsoredTx) {
118
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
119
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
118
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
119
+ sender: this.requireSenderForSponsored(sender),
120
+ additionalSuiAmount: collateralToken === 'sui' ? collateralAmount + relayerFee : 0n,
121
+ });
122
+ tx = oracle.tx;
123
+ suiCoinObject = oracle.suiCoinObject;
120
124
  }
121
125
  else {
122
- tx = await this.initOracleTxb([collateralToken, indexToken], tx);
126
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx;
123
127
  }
124
128
  // Process coin splitting
125
129
  const [depositObject, feeObject] = this.processCoinSplitting(tx, collateralToken, coinObjects, [tx.pure.u64(collateralAmount), tx.pure.u64(relayerFee)], sponsoredTx, suiCoinObject);
@@ -159,7 +163,7 @@ class USDZAPI extends abstract_1.BaseAPI {
159
163
  .finalize();
160
164
  return tx;
161
165
  }
162
- async openPositionWithCoinAndSCard(collateralToken, indexToken, size, coinObj, long, reserveAmount, indexPrice, collateralPrice, kioskClient, kioskCap, scard, isLimitOrder, isIocOrder, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), referralAddress, sender, tx, sponsoredTx, suiCoinObjectsForPythUpdate) {
166
+ async openPositionWithCoinAndSCard(collateralToken, indexToken, size, coinObj, long, reserveAmount, indexPrice, collateralPrice, kioskClient, kioskCap, scard, isLimitOrder, isIocOrder, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), referralAddress, sender, tx, sponsoredTx) {
163
167
  if (!tx) {
164
168
  tx = new transactions_1.Transaction();
165
169
  }
@@ -185,11 +189,15 @@ class USDZAPI extends abstract_1.BaseAPI {
185
189
  // Handle oracle initialization and coin processing
186
190
  let suiCoinObject;
187
191
  if (sponsoredTx) {
188
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
189
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
192
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
193
+ sender: this.requireSenderForSponsored(sender),
194
+ additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
195
+ });
196
+ tx = oracle.tx;
197
+ suiCoinObject = oracle.suiCoinObject;
190
198
  }
191
199
  else {
192
- tx = await this.initOracleTxb([collateralToken, indexToken], tx);
200
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx;
193
201
  }
194
202
  // Process coin splitting
195
203
  const [feeObject] = tx.splitCoins(coinObj, [tx.pure.u64(relayerFee)]);
@@ -229,7 +237,7 @@ class USDZAPI extends abstract_1.BaseAPI {
229
237
  .finalize();
230
238
  return tx;
231
239
  }
232
- async decreasePositionWithSCard(pcpId, collateralToken, indexToken, amount, long, indexPrice, collateralPrice, kioskClient, kioskCap, scard, isTriggerOrder = false, isTakeProfitOrder = true, isIocOrder = false, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), coinObjects, sponsoredTx, suiCoinObjectsForPythUpdate) {
240
+ async decreasePositionWithSCard(pcpId, collateralToken, indexToken, amount, long, indexPrice, collateralPrice, kioskClient, kioskCap, scard, isTriggerOrder = false, isTakeProfitOrder = true, isIocOrder = false, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), coinObjects, sponsoredTx, sender) {
233
241
  if (!coinObjects) {
234
242
  throw new Error(`${this.constructor.name}: coinObjects is required`);
235
243
  }
@@ -256,11 +264,15 @@ class USDZAPI extends abstract_1.BaseAPI {
256
264
  // Handle oracle initialization and coin processing
257
265
  let suiCoinObject;
258
266
  if (sponsoredTx) {
259
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
260
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
267
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
268
+ sender: this.requireSenderForSponsored(sender),
269
+ additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
270
+ });
271
+ tx = oracle.tx;
272
+ suiCoinObject = oracle.suiCoinObject;
261
273
  }
262
274
  else {
263
- tx = await this.initOracleTxb([collateralToken, indexToken], tx);
275
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx;
264
276
  }
265
277
  // Process coin splitting
266
278
  const [feeObject] = this.processCoinSplitting(tx, collateralToken, coinObjects, [tx.pure.u64(relayerFee)], sponsoredTx, suiCoinObject);
@@ -299,18 +311,19 @@ class USDZAPI extends abstract_1.BaseAPI {
299
311
  .finalize();
300
312
  return tx;
301
313
  }
302
- async decreaseMultiPositionsWithSCard(positions, kioskClient, kioskCap, scard, tx, sponsoredTx, suiCoinObjectsForPythUpdate) {
314
+ async decreaseMultiPositionsWithSCard(positions, kioskClient, kioskCap, scard, tx, sponsoredTx, sender) {
303
315
  if (!tx) {
304
316
  tx = new transactions_1.Transaction();
305
317
  }
306
318
  // Handle oracle initialization and coin processing
307
319
  let suiCoinObject;
308
320
  if (sponsoredTx) {
309
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
310
- tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx, true, suiCoinObject);
321
+ const oracle = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx, true, { sender: this.requireSenderForSponsored(sender) });
322
+ tx = oracle.tx;
323
+ suiCoinObject = oracle.suiCoinObject;
311
324
  }
312
325
  else {
313
- tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx);
326
+ tx = (await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx)).tx;
314
327
  }
315
328
  const kioskTx = new kiosk_1.KioskTransaction({
316
329
  transaction: tx,
@@ -372,7 +385,7 @@ class USDZAPI extends abstract_1.BaseAPI {
372
385
  .finalize();
373
386
  return tx;
374
387
  }
375
- async openPositionWithSCardV2(collateralToken, indexToken, size, collateralAmount, coinObjects, long, reserveAmount, indexPrice, collateralPrice, kioskClient, kioskCap, scard, isLimitOrder, isIocOrder, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), referralAddress, sender, sponsoredTx, suiCoinObjectsForPythUpdate) {
388
+ async openPositionWithSCardV2(collateralToken, indexToken, size, collateralAmount, coinObjects, long, reserveAmount, indexPrice, collateralPrice, kioskClient, kioskCap, scard, isLimitOrder, isIocOrder, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), referralAddress, sender, sponsoredTx) {
376
389
  let tx = new transactions_1.Transaction();
377
390
  if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
378
391
  tx = await this.addReferral(referralAddress, tx);
@@ -397,11 +410,15 @@ class USDZAPI extends abstract_1.BaseAPI {
397
410
  // Handle oracle initialization and coin processing
398
411
  let suiCoinObject;
399
412
  if (sponsoredTx) {
400
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
401
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
413
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
414
+ sender: this.requireSenderForSponsored(sender),
415
+ additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
416
+ });
417
+ tx = oracle.tx;
418
+ suiCoinObject = oracle.suiCoinObject;
402
419
  }
403
420
  else {
404
- tx = await this.initOracleTxb([collateralToken, indexToken], tx);
421
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx;
405
422
  }
406
423
  // Process coin splitting
407
424
  const [depositObject, feeObject] = this.processCoinSplitting(tx, collateralToken, coinObjects, [tx.pure.u64(collateralAmount), tx.pure.u64(relayerFee)], sponsoredTx, suiCoinObject);
@@ -441,7 +458,7 @@ class USDZAPI extends abstract_1.BaseAPI {
441
458
  return tx;
442
459
  }
443
460
  // S Card operations
444
- async openPositionWithCoinAndSCardV2(collateralToken, indexToken, size, coinObj, long, reserveAmount, indexPrice, collateralPrice, kioskClient, kioskCap, scard, isLimitOrder, isIocOrder, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), referralAddress, sender, tx, sponsoredTx, suiCoinObjectsForPythUpdate) {
461
+ async openPositionWithCoinAndSCardV2(collateralToken, indexToken, size, coinObj, long, reserveAmount, indexPrice, collateralPrice, kioskClient, kioskCap, scard, isLimitOrder, isIocOrder, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), referralAddress, sender, tx, sponsoredTx) {
445
462
  if (!tx) {
446
463
  tx = new transactions_1.Transaction();
447
464
  }
@@ -468,11 +485,15 @@ class USDZAPI extends abstract_1.BaseAPI {
468
485
  // Handle oracle initialization and coin processing
469
486
  let suiCoinObject;
470
487
  if (sponsoredTx) {
471
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
472
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
488
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
489
+ sender: this.requireSenderForSponsored(sender),
490
+ additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
491
+ });
492
+ tx = oracle.tx;
493
+ suiCoinObject = oracle.suiCoinObject;
473
494
  }
474
495
  else {
475
- tx = await this.initOracleTxb([collateralToken, indexToken], tx);
496
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx;
476
497
  }
477
498
  // Process coin splitting
478
499
  const [feeObject] = tx.splitCoins(coinObj, [tx.pure.u64(relayerFee)]);
@@ -511,7 +532,7 @@ class USDZAPI extends abstract_1.BaseAPI {
511
532
  .finalize();
512
533
  return tx;
513
534
  }
514
- async decreasePositionWithSCardV2(pcpId, collateralToken, indexToken, amount, long, indexPrice, collateralPrice, kioskClient, kioskCap, scard, isTriggerOrder = false, isTakeProfitOrder = true, isIocOrder = false, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), coinObjects, sponsoredTx, suiCoinObjectsForPythUpdate) {
535
+ async decreasePositionWithSCardV2(pcpId, collateralToken, indexToken, amount, long, indexPrice, collateralPrice, kioskClient, kioskCap, scard, isTriggerOrder = false, isTakeProfitOrder = true, isIocOrder = false, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), coinObjects, sponsoredTx, sender) {
515
536
  if (!coinObjects) {
516
537
  throw new Error(`${this.constructor.name}: coinObjects is required`);
517
538
  }
@@ -538,11 +559,15 @@ class USDZAPI extends abstract_1.BaseAPI {
538
559
  // Handle oracle initialization and coin processing
539
560
  let suiCoinObject;
540
561
  if (sponsoredTx) {
541
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
542
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
562
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
563
+ sender: this.requireSenderForSponsored(sender),
564
+ additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
565
+ });
566
+ tx = oracle.tx;
567
+ suiCoinObject = oracle.suiCoinObject;
543
568
  }
544
569
  else {
545
- tx = await this.initOracleTxb([collateralToken, indexToken], tx);
570
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx;
546
571
  }
547
572
  // Process coin splitting
548
573
  const [feeObject] = this.processCoinSplitting(tx, collateralToken, coinObjects, [tx.pure.u64(relayerFee)], sponsoredTx, suiCoinObject);
@@ -580,14 +605,21 @@ class USDZAPI extends abstract_1.BaseAPI {
580
605
  .finalize();
581
606
  return tx;
582
607
  }
583
- async decreaseMultiPositionsWithSCardV2(positions, kioskClient, kioskCap, scard, tx, sponsoredTx, suiCoinObjectsForPythUpdate, feeObjects) {
584
- const transaction = tx ?? new transactions_1.Transaction();
608
+ async decreaseMultiPositionsWithSCardV2(positions, kioskClient, kioskCap, scard, tx, sponsoredTx, sender, feeObjects) {
609
+ let transaction = tx ?? new transactions_1.Transaction();
585
610
  // Handle oracle initialization and coin processing
586
611
  const tokens = positions.flatMap(position => [position.collateralToken, position.indexToken]);
587
- const suiCoinObject = sponsoredTx
588
- ? this.processCoins(transaction, 'sui', suiCoinObjectsForPythUpdate || [], true)
589
- : undefined;
590
- await this.initOracleTxb(tokens, transaction, !!sponsoredTx, suiCoinObject);
612
+ let suiCoinObject;
613
+ if (sponsoredTx) {
614
+ const oracle = await this.initOracleTxb(tokens, transaction, true, {
615
+ sender: this.requireSenderForSponsored(sender),
616
+ });
617
+ transaction = oracle.tx;
618
+ suiCoinObject = oracle.suiCoinObject;
619
+ }
620
+ else {
621
+ transaction = (await this.initOracleTxb(tokens, transaction, false)).tx;
622
+ }
591
623
  if (!feeObjects || feeObjects.length !== positions.length) {
592
624
  throw new Error('feeObjects must be provided (pre-processed via buildFeeCoinObjects) and match positions length');
593
625
  }
@@ -652,7 +684,7 @@ class USDZAPI extends abstract_1.BaseAPI {
652
684
  /**
653
685
  * Deposits collateral into USDZ vault
654
686
  */
655
- async deposit(coin, coinObjects, amount, minAmountOut = 0, referralAddress, sender, sponsoredTx, suiCoinObjectsForPythUpdate) {
687
+ async deposit(coin, coinObjects, amount, minAmountOut = 0, referralAddress, sender, sponsoredTx) {
656
688
  let tx = new transactions_1.Transaction();
657
689
  // Add referral if needed
658
690
  if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
@@ -662,8 +694,12 @@ class USDZAPI extends abstract_1.BaseAPI {
662
694
  const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder);
663
695
  // Handle sponsored transaction case
664
696
  if (sponsoredTx) {
665
- const suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
666
- tx = await this.initOracleTxb(pythFeederKeys, tx, true, suiCoinObject);
697
+ const oracle = await this.initOracleTxb(pythFeederKeys, tx, true, {
698
+ sender: this.requireSenderForSponsored(sender),
699
+ additionalSuiAmount: coin === 'sui' ? BigInt(amount) : 0n,
700
+ });
701
+ tx = oracle.tx;
702
+ const { suiCoinObject } = oracle;
667
703
  // Process deposit coins
668
704
  const depositObject = coin === 'sui'
669
705
  ? tx.splitCoins(suiCoinObject, [tx.pure.u64(amount)])[0]
@@ -684,7 +720,7 @@ class USDZAPI extends abstract_1.BaseAPI {
684
720
  return tx;
685
721
  }
686
722
  // Handle non-sponsored transaction case
687
- tx = await this.initOracleTxb(pythFeederKeys, tx);
723
+ tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx;
688
724
  const depositObject = tx.splitCoins(this.processCoins(tx, coin, coinObjects, false), [tx.pure.u64(amount)])[0];
689
725
  const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx);
690
726
  tx.moveCall({
@@ -707,7 +743,7 @@ class USDZAPI extends abstract_1.BaseAPI {
707
743
  /**
708
744
  * Deposits collateral into USDZ vault
709
745
  */
710
- async depositPtb(coin, coinObjects, amount, minAmountOut = 0, referralAddress, sender, tx, sponsoredTx, suiCoinObjectsForPythUpdate) {
746
+ async depositPtb(coin, coinObjects, amount, minAmountOut = 0, referralAddress, sender, tx, sponsoredTx) {
711
747
  if (!tx) {
712
748
  tx = new transactions_1.Transaction();
713
749
  }
@@ -719,8 +755,12 @@ class USDZAPI extends abstract_1.BaseAPI {
719
755
  const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder);
720
756
  // Handle sponsored transaction case
721
757
  if (sponsoredTx) {
722
- const suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
723
- tx = await this.initOracleTxb(pythFeederKeys, tx, true, suiCoinObject);
758
+ const oracle = await this.initOracleTxb(pythFeederKeys, tx, true, {
759
+ sender: this.requireSenderForSponsored(sender),
760
+ additionalSuiAmount: coin === 'sui' ? BigInt(amount) : 0n,
761
+ });
762
+ tx = oracle.tx;
763
+ const { suiCoinObject } = oracle;
724
764
  // Process deposit coins
725
765
  const depositObject = coin === 'sui'
726
766
  ? tx.splitCoins(suiCoinObject, [tx.pure.u64(amount)])[0]
@@ -741,7 +781,7 @@ class USDZAPI extends abstract_1.BaseAPI {
741
781
  return mintedCoin;
742
782
  }
743
783
  // Handle non-sponsored transaction case
744
- tx = await this.initOracleTxb(pythFeederKeys, tx);
784
+ tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx;
745
785
  const depositObject = tx.splitCoins(this.processCoins(tx, coin, coinObjects, false), [tx.pure.u64(amount)])[0];
746
786
  const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx);
747
787
  const [mintedCoin] = tx.moveCall({
@@ -764,16 +804,20 @@ class USDZAPI extends abstract_1.BaseAPI {
764
804
  /**
765
805
  * Withdraws collateral from USDZ vault
766
806
  */
767
- async withdraw(coin, lpCoinObjects, amount, minAmountOut = 0, sponsoredTx, suiCoinObjectsForPythUpdate) {
807
+ async withdraw(coin, lpCoinObjects, amount, minAmountOut = 0, sponsoredTx, sender) {
768
808
  let tx = new transactions_1.Transaction();
769
809
  // Initialize oracle transaction
770
810
  const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder);
771
811
  if (sponsoredTx) {
772
- const suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
773
- tx = await this.initOracleTxb(pythFeederKeys, tx, true, suiCoinObject);
812
+ const oracle = await this.initOracleTxb(pythFeederKeys, tx, true, {
813
+ sender: this.requireSenderForSponsored(sender),
814
+ additionalSuiAmount: 0n,
815
+ });
816
+ tx = oracle.tx;
817
+ const { suiCoinObject } = oracle;
774
818
  }
775
819
  else {
776
- tx = await this.initOracleTxb(pythFeederKeys, tx);
820
+ tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx;
777
821
  }
778
822
  const usdzCoinObject = this.processCoins(tx, 'usdz', lpCoinObjects, false);
779
823
  const [withdrawObject] = tx.splitCoins(usdzCoinObject, [tx.pure.u64(amount)]);
@@ -804,7 +848,7 @@ class USDZAPI extends abstract_1.BaseAPI {
804
848
  }
805
849
  // Initialize oracle transaction
806
850
  const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder);
807
- tx = await this.initOracleTxb(pythFeederKeys, tx);
851
+ tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx;
808
852
  const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx);
809
853
  tx.moveCall({
810
854
  target: `${this.consts.zoCore.upgradedPackage}::market::withdraw`,
@@ -986,7 +1030,7 @@ class USDZAPI extends abstract_1.BaseAPI {
986
1030
  return rewardCoin;
987
1031
  }
988
1032
  async swap(fromToken, toToken, fromAmount, fromCoinObjects, minAmountOut) {
989
- const tx = await this.initOracleTxb(Object.keys(this.consts.zoCore.vaults));
1033
+ const { tx } = await this.initOracleTxb(Object.keys(this.consts.zoCore.vaults));
990
1034
  const fromCoinObject = this.processCoins(tx, fromToken, fromCoinObjects);
991
1035
  const [fromDepositObject] = tx.splitCoins(fromCoinObject, [tx.pure.u64(fromAmount)]);
992
1036
  const vaultsValuation = this.dataAPI.valuateVaults(tx);
@@ -1018,7 +1062,7 @@ class USDZAPI extends abstract_1.BaseAPI {
1018
1062
  if (!tx) {
1019
1063
  tx = new transactions_1.Transaction();
1020
1064
  }
1021
- tx = await this.initOracleTxb(Object.keys(this.consts.zoCore.vaults), tx);
1065
+ tx = (await this.initOracleTxb(Object.keys(this.consts.zoCore.vaults), tx)).tx;
1022
1066
  const fromCoinObject = this.processCoins(tx, fromToken, fromCoinObjects);
1023
1067
  const [fromDepositObject] = tx.splitCoins(fromCoinObject, [
1024
1068
  tx.pure.u64(fromAmount),
@@ -1044,7 +1088,7 @@ class USDZAPI extends abstract_1.BaseAPI {
1044
1088
  /**
1045
1089
  * Opens a new position in USDZ
1046
1090
  */
1047
- async openPosition(collateralToken, indexToken, size, collateralAmount, coinObjects, long, reserveAmount, indexPrice, collateralPrice, isLimitOrder, isIocOrder, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), referralAddress, sender, sponsoredTx, suiCoinObjectsForPythUpdate) {
1091
+ async openPosition(collateralToken, indexToken, size, collateralAmount, coinObjects, long, reserveAmount, indexPrice, collateralPrice, isLimitOrder, isIocOrder, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), referralAddress, sender, sponsoredTx) {
1048
1092
  let tx = new transactions_1.Transaction();
1049
1093
  if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
1050
1094
  tx = await this.addReferral(referralAddress, tx);
@@ -1059,11 +1103,15 @@ class USDZAPI extends abstract_1.BaseAPI {
1059
1103
  // Handle oracle initialization and coin processing
1060
1104
  let suiCoinObject;
1061
1105
  if (sponsoredTx) {
1062
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
1063
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
1106
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
1107
+ sender: this.requireSenderForSponsored(sender),
1108
+ additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
1109
+ });
1110
+ tx = oracle.tx;
1111
+ suiCoinObject = oracle.suiCoinObject;
1064
1112
  }
1065
1113
  else {
1066
- tx = await this.initOracleTxb([collateralToken, indexToken], tx);
1114
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx;
1067
1115
  }
1068
1116
  // Process coin splitting
1069
1117
  const [depositObject, feeObject] = this.processCoinSplitting(tx, collateralToken, coinObjects, [tx.pure.u64(collateralAmount), tx.pure.u64(relayerFee)], sponsoredTx, suiCoinObject);
@@ -1098,7 +1146,7 @@ class USDZAPI extends abstract_1.BaseAPI {
1098
1146
  /**
1099
1147
  * Opens a new position in USDZ (V2)
1100
1148
  */
1101
- async openPositionV2(collateralToken, indexToken, size, collateralAmount, coinObjects, long, reserveAmount, indexPrice, collateralPrice, isLimitOrder, isIocOrder, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), referralAddress, sender, sponsoredTx, suiCoinObjectsForPythUpdate) {
1149
+ async openPositionV2(collateralToken, indexToken, size, collateralAmount, coinObjects, long, reserveAmount, indexPrice, collateralPrice, isLimitOrder, isIocOrder, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), referralAddress, sender, sponsoredTx) {
1102
1150
  let tx = new transactions_1.Transaction();
1103
1151
  if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
1104
1152
  tx = await this.addReferral(referralAddress, tx);
@@ -1114,11 +1162,15 @@ class USDZAPI extends abstract_1.BaseAPI {
1114
1162
  // Handle oracle initialization and coin processing
1115
1163
  let suiCoinObject;
1116
1164
  if (sponsoredTx) {
1117
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
1118
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
1165
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
1166
+ sender: this.requireSenderForSponsored(sender),
1167
+ additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
1168
+ });
1169
+ tx = oracle.tx;
1170
+ suiCoinObject = oracle.suiCoinObject;
1119
1171
  }
1120
1172
  else {
1121
- tx = await this.initOracleTxb([collateralToken, indexToken], tx);
1173
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx;
1122
1174
  }
1123
1175
  // Process coin splitting
1124
1176
  const [depositObject, feeObject] = this.processCoinSplitting(tx, collateralToken, coinObjects, [tx.pure.u64(collateralAmount), tx.pure.u64(relayerFee)], sponsoredTx, suiCoinObject);
@@ -1152,7 +1204,7 @@ class USDZAPI extends abstract_1.BaseAPI {
1152
1204
  /**
1153
1205
  * Opens a new position in USDZ
1154
1206
  */
1155
- async openPositionWithCoin(collateralToken, indexToken, size, coinObj, long, reserveAmount, indexPrice, collateralPrice, isLimitOrder, isIocOrder, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), referralAddress, sender, tx, sponsoredTx, suiCoinObjectsForPythUpdate) {
1207
+ async openPositionWithCoin(collateralToken, indexToken, size, coinObj, long, reserveAmount, indexPrice, collateralPrice, isLimitOrder, isIocOrder, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), referralAddress, sender, tx, sponsoredTx) {
1156
1208
  if (!tx) {
1157
1209
  tx = new transactions_1.Transaction();
1158
1210
  }
@@ -1169,11 +1221,15 @@ class USDZAPI extends abstract_1.BaseAPI {
1169
1221
  // Handle oracle initialization and coin processing
1170
1222
  let suiCoinObject;
1171
1223
  if (sponsoredTx) {
1172
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
1173
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
1224
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
1225
+ sender: this.requireSenderForSponsored(sender),
1226
+ additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
1227
+ });
1228
+ tx = oracle.tx;
1229
+ suiCoinObject = oracle.suiCoinObject;
1174
1230
  }
1175
1231
  else {
1176
- tx = await this.initOracleTxb([collateralToken, indexToken], tx);
1232
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx;
1177
1233
  }
1178
1234
  // Process coin splitting
1179
1235
  const [feeObject] = tx.splitCoins(coinObj, [tx.pure.u64(relayerFee)]);
@@ -1208,7 +1264,7 @@ class USDZAPI extends abstract_1.BaseAPI {
1208
1264
  /**
1209
1265
  * Opens a new position with Coin in USDZ (V2)
1210
1266
  */
1211
- async openPositionWithCoinV2(collateralToken, indexToken, size, coinObj, long, reserveAmount, indexPrice, collateralPrice, isLimitOrder, isIocOrder, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), referralAddress, sender, tx, sponsoredTx, suiCoinObjectsForPythUpdate) {
1267
+ async openPositionWithCoinV2(collateralToken, indexToken, size, coinObj, long, reserveAmount, indexPrice, collateralPrice, isLimitOrder, isIocOrder, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), referralAddress, sender, tx, sponsoredTx) {
1212
1268
  if (!tx) {
1213
1269
  tx = new transactions_1.Transaction();
1214
1270
  }
@@ -1226,11 +1282,15 @@ class USDZAPI extends abstract_1.BaseAPI {
1226
1282
  // Handle oracle initialization and coin processing
1227
1283
  let suiCoinObject;
1228
1284
  if (sponsoredTx) {
1229
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
1230
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
1285
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
1286
+ sender: this.requireSenderForSponsored(sender),
1287
+ additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
1288
+ });
1289
+ tx = oracle.tx;
1290
+ suiCoinObject = oracle.suiCoinObject;
1231
1291
  }
1232
1292
  else {
1233
- tx = await this.initOracleTxb([collateralToken, indexToken], tx);
1293
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx;
1234
1294
  }
1235
1295
  // Process coin splitting
1236
1296
  const [feeObject] = tx.splitCoins(coinObj, [tx.pure.u64(relayerFee)]);
@@ -1264,7 +1324,7 @@ class USDZAPI extends abstract_1.BaseAPI {
1264
1324
  /**
1265
1325
  * Decreases an existing position in USDZ
1266
1326
  */
1267
- async decreasePosition(pcpId, collateralToken, indexToken, amount, long, indexPrice, collateralPrice, isTriggerOrder = false, isTakeProfitOrder = true, isIocOrder = false, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), coinObjects, sponsoredTx, suiCoinObjectsForPythUpdate) {
1327
+ async decreasePosition(pcpId, collateralToken, indexToken, amount, long, indexPrice, collateralPrice, isTriggerOrder = false, isTakeProfitOrder = true, isIocOrder = false, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), coinObjects, sponsoredTx, sender) {
1268
1328
  if (!coinObjects) {
1269
1329
  throw new Error(`${this.constructor.name}: coinObjects is required`);
1270
1330
  }
@@ -1282,11 +1342,15 @@ class USDZAPI extends abstract_1.BaseAPI {
1282
1342
  // Handle oracle initialization and coin processing
1283
1343
  let suiCoinObject;
1284
1344
  if (sponsoredTx) {
1285
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
1286
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
1345
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
1346
+ sender: this.requireSenderForSponsored(sender),
1347
+ additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
1348
+ });
1349
+ tx = oracle.tx;
1350
+ suiCoinObject = oracle.suiCoinObject;
1287
1351
  }
1288
1352
  else {
1289
- tx = await this.initOracleTxb([collateralToken, indexToken], tx);
1353
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx;
1290
1354
  }
1291
1355
  // Process coin splitting
1292
1356
  const [feeObject] = this.processCoinSplitting(tx, collateralToken, coinObjects, [tx.pure.u64(relayerFee)], sponsoredTx, suiCoinObject);
@@ -1320,7 +1384,7 @@ class USDZAPI extends abstract_1.BaseAPI {
1320
1384
  /**
1321
1385
  * Decreases an existing position in USDZ (V2)
1322
1386
  */
1323
- async decreasePositionV2(pcpId, collateralToken, indexToken, amount, long, indexPrice, collateralPrice, isTriggerOrder = false, isTakeProfitOrder = true, isIocOrder = false, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), coinObjects, sponsoredTx, suiCoinObjectsForPythUpdate) {
1387
+ async decreasePositionV2(pcpId, collateralToken, indexToken, amount, long, indexPrice, collateralPrice, isTriggerOrder = false, isTakeProfitOrder = true, isIocOrder = false, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), coinObjects, sponsoredTx, sender) {
1324
1388
  if (!coinObjects) {
1325
1389
  throw new Error(`${this.constructor.name}: coinObjects is required`);
1326
1390
  }
@@ -1338,11 +1402,15 @@ class USDZAPI extends abstract_1.BaseAPI {
1338
1402
  // Handle oracle initialization and coin processing
1339
1403
  let suiCoinObject;
1340
1404
  if (sponsoredTx) {
1341
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
1342
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
1405
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
1406
+ sender: this.requireSenderForSponsored(sender),
1407
+ additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
1408
+ });
1409
+ tx = oracle.tx;
1410
+ suiCoinObject = oracle.suiCoinObject;
1343
1411
  }
1344
1412
  else {
1345
- tx = await this.initOracleTxb([collateralToken, indexToken], tx);
1413
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx;
1346
1414
  }
1347
1415
  // Process coin splitting
1348
1416
  const [feeObject] = this.processCoinSplitting(tx, collateralToken, coinObjects, [tx.pure.u64(relayerFee)], sponsoredTx, suiCoinObject);
@@ -1372,18 +1440,19 @@ class USDZAPI extends abstract_1.BaseAPI {
1372
1440
  });
1373
1441
  return tx;
1374
1442
  }
1375
- async decreaseMultiPositions(positions, tx, sponsoredTx, suiCoinObjectsForPythUpdate) {
1443
+ async decreaseMultiPositions(positions, tx, sponsoredTx, sender) {
1376
1444
  if (!tx) {
1377
1445
  tx = new transactions_1.Transaction();
1378
1446
  }
1379
1447
  // Handle oracle initialization and coin processing
1380
1448
  let suiCoinObject;
1381
1449
  if (sponsoredTx) {
1382
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
1383
- tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx, true, suiCoinObject);
1450
+ const oracle = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx, true, { sender: this.requireSenderForSponsored(sender) });
1451
+ tx = oracle.tx;
1452
+ suiCoinObject = oracle.suiCoinObject;
1384
1453
  }
1385
1454
  else {
1386
- tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx);
1455
+ tx = (await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx)).tx;
1387
1456
  }
1388
1457
  for (const position of positions) {
1389
1458
  const { pcpId, collateralToken, coinObjects = [], indexToken, amount, long, indexPrice, collateralPrice, isTriggerOrder = false, isTakeProfitOrder = true, isIocOrder = false, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), } = position;
@@ -1428,14 +1497,21 @@ class USDZAPI extends abstract_1.BaseAPI {
1428
1497
  }
1429
1498
  return tx;
1430
1499
  }
1431
- async decreaseMultiPositionsV2(positions, tx, sponsoredTx, suiCoinObjectsForPythUpdate, feeObjects) {
1432
- const transaction = tx ?? new transactions_1.Transaction();
1500
+ async decreaseMultiPositionsV2(positions, tx, sponsoredTx, sender, feeObjects) {
1501
+ let transaction = tx ?? new transactions_1.Transaction();
1433
1502
  // Handle oracle initialization and coin processing
1434
1503
  const tokens = positions.flatMap(position => [position.collateralToken, position.indexToken]);
1435
- const suiCoinObject = sponsoredTx
1436
- ? this.processCoins(transaction, 'sui', suiCoinObjectsForPythUpdate || [], true)
1437
- : undefined;
1438
- await this.initOracleTxb(tokens, transaction, !!sponsoredTx, suiCoinObject);
1504
+ let suiCoinObject;
1505
+ if (sponsoredTx) {
1506
+ const oracle = await this.initOracleTxb(tokens, transaction, true, {
1507
+ sender: this.requireSenderForSponsored(sender),
1508
+ });
1509
+ transaction = oracle.tx;
1510
+ suiCoinObject = oracle.suiCoinObject;
1511
+ }
1512
+ else {
1513
+ transaction = (await this.initOracleTxb(tokens, transaction, false)).tx;
1514
+ }
1439
1515
  if (!feeObjects || feeObjects.length !== positions.length) {
1440
1516
  throw new Error('feeObjects must be provided (pre-processed via buildFeeCoinObjects) and match positions length');
1441
1517
  }
@@ -1483,16 +1559,20 @@ class USDZAPI extends abstract_1.BaseAPI {
1483
1559
  /**
1484
1560
  * Pledges in position (USDZ-specific functionality)
1485
1561
  */
1486
- async pledgeInPosition(pcpId, collateralToken, indexToken, amount, coinObjects, long, sponsoredTx, suiCoinObjectsForPythUpdate) {
1562
+ async pledgeInPosition(pcpId, collateralToken, indexToken, amount, coinObjects, long, sponsoredTx, sender) {
1487
1563
  let tx = new transactions_1.Transaction();
1488
1564
  // Handle oracle initialization and coin processing
1489
1565
  let suiCoinObject;
1490
1566
  if (sponsoredTx) {
1491
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
1492
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
1567
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
1568
+ sender: this.requireSenderForSponsored(sender),
1569
+ additionalSuiAmount: collateralToken === 'sui' ? BigInt(amount) : 0n,
1570
+ });
1571
+ tx = oracle.tx;
1572
+ suiCoinObject = oracle.suiCoinObject;
1493
1573
  }
1494
1574
  else {
1495
- tx = await this.initOracleTxb([collateralToken, indexToken], tx);
1575
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx;
1496
1576
  }
1497
1577
  // Process coin splitting
1498
1578
  const [depositObject] = this.processCoinSplitting(tx, collateralToken, coinObjects, [tx.pure.u64(amount)], sponsoredTx, suiCoinObject);
@@ -1508,16 +1588,20 @@ class USDZAPI extends abstract_1.BaseAPI {
1508
1588
  });
1509
1589
  return tx;
1510
1590
  }
1511
- async redeemFromPosition(pcpId, collateralToken, indexToken, amount, long, sponsoredTx, suiCoinObjectsForPythUpdate) {
1591
+ async redeemFromPosition(pcpId, collateralToken, indexToken, amount, long, sponsoredTx, sender) {
1512
1592
  let tx = new transactions_1.Transaction();
1513
1593
  // Handle oracle initialization and coin processing
1514
1594
  let suiCoinObject;
1515
1595
  if (sponsoredTx) {
1516
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
1517
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
1596
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
1597
+ sender: this.requireSenderForSponsored(sender),
1598
+ additionalSuiAmount: 0n,
1599
+ });
1600
+ tx = oracle.tx;
1601
+ suiCoinObject = oracle.suiCoinObject;
1518
1602
  }
1519
1603
  else {
1520
- tx = await this.initOracleTxb([collateralToken, indexToken], tx);
1604
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx;
1521
1605
  }
1522
1606
  const symbol = (0, utils_2.joinSymbol)(long ? 'long' : 'short', indexToken);
1523
1607
  tx.moveCall({
@@ -1636,7 +1720,7 @@ class USDZAPI extends abstract_1.BaseAPI {
1636
1720
  return tx;
1637
1721
  }
1638
1722
  async adminUpdatePriceFeed(collateralToken, indexToken) {
1639
- const tx = await this.initOracleTxb([collateralToken, indexToken]);
1723
+ const { tx } = await this.initOracleTxb([collateralToken, indexToken]);
1640
1724
  return tx;
1641
1725
  }
1642
1726
  adminSettlePosition(positionId, owner, collateralToken, indexToken, long) {