@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
@@ -26,7 +26,7 @@ class SLPAPI extends abstract_1.BaseAPI {
26
26
  /**
27
27
  * Deposits collateral into SLP vault using Sudo SDK approach
28
28
  */
29
- async deposit(coin, coinObjects, amount, minAmountOut = 0, referralAddress, sender, sponsoredTx, suiCoinObjectsForPythUpdate) {
29
+ async deposit(coin, coinObjects, amount, minAmountOut = 0, referralAddress, sender, sponsoredTx) {
30
30
  let tx = new transactions_1.Transaction();
31
31
  // Add referral if needed
32
32
  if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
@@ -36,8 +36,12 @@ class SLPAPI extends abstract_1.BaseAPI {
36
36
  const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder);
37
37
  // Handle sponsored transaction case
38
38
  if (sponsoredTx) {
39
- const suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
40
- tx = await this.initOracleTxb(pythFeederKeys, tx, true, suiCoinObject);
39
+ const oracle = await this.initOracleTxb(pythFeederKeys, tx, true, {
40
+ sender: this.requireSenderForSponsored(sender),
41
+ additionalSuiAmount: coin === 'sui' ? BigInt(amount) : 0n,
42
+ });
43
+ tx = oracle.tx;
44
+ const { suiCoinObject } = oracle;
41
45
  // Process deposit coins
42
46
  const depositObject = coin === 'sui'
43
47
  ? tx.splitCoins(suiCoinObject, [tx.pure.u64(amount)])[0]
@@ -61,7 +65,7 @@ class SLPAPI extends abstract_1.BaseAPI {
61
65
  return tx;
62
66
  }
63
67
  // Handle non-sponsored transaction case
64
- tx = await this.initOracleTxb(pythFeederKeys, tx);
68
+ tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx;
65
69
  const depositObject = tx.splitCoins(this.processCoins(tx, coin, coinObjects, false), [tx.pure.u64(amount)])[0];
66
70
  const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx);
67
71
  tx.moveCall({
@@ -84,7 +88,7 @@ class SLPAPI extends abstract_1.BaseAPI {
84
88
  /**
85
89
  * Deposits collateral into SLP vault and returns a coin
86
90
  */
87
- async depositPtb(coin, coinObjects, amount, minAmountOut = 0, referralAddress, sender, tx, sponsoredTx, suiCoinObjectsForPythUpdate) {
91
+ async depositPtb(coin, coinObjects, amount, minAmountOut = 0, referralAddress, sender, tx, sponsoredTx) {
88
92
  if (!tx) {
89
93
  tx = new transactions_1.Transaction();
90
94
  }
@@ -96,8 +100,12 @@ class SLPAPI extends abstract_1.BaseAPI {
96
100
  const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder);
97
101
  // Handle sponsored transaction case
98
102
  if (sponsoredTx) {
99
- const suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
100
- tx = await this.initOracleTxb(pythFeederKeys, tx, true, suiCoinObject);
103
+ const oracle = await this.initOracleTxb(pythFeederKeys, tx, true, {
104
+ sender: this.requireSenderForSponsored(sender),
105
+ additionalSuiAmount: coin === 'sui' ? BigInt(amount) : 0n,
106
+ });
107
+ tx = oracle.tx;
108
+ const { suiCoinObject } = oracle;
101
109
  // Process deposit coins
102
110
  const depositObject = coin === 'sui'
103
111
  ? tx.splitCoins(suiCoinObject, [tx.pure.u64(amount)])[0]
@@ -118,7 +126,7 @@ class SLPAPI extends abstract_1.BaseAPI {
118
126
  return mintedCoin;
119
127
  }
120
128
  // Handle non-sponsored transaction case
121
- tx = await this.initOracleTxb(pythFeederKeys, tx);
129
+ tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx;
122
130
  const depositObject = tx.splitCoins(this.processCoins(tx, coin, coinObjects, false), [tx.pure.u64(amount)])[0];
123
131
  const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx);
124
132
  const [mintedCoin] = tx.moveCall({
@@ -141,7 +149,7 @@ class SLPAPI extends abstract_1.BaseAPI {
141
149
  /**
142
150
  * Deposits collateral pool with PTB deposit object
143
151
  */
144
- async depositWithPtb(coin, depositObject, minAmountOut = 0, referralAddress, sender, tx, sponsoredTx, suiCoinObjectsForPythUpdate) {
152
+ async depositWithPtb(coin, depositObject, minAmountOut = 0, referralAddress, sender, tx, sponsoredTx) {
145
153
  if (!tx) {
146
154
  tx = new transactions_1.Transaction();
147
155
  }
@@ -153,8 +161,12 @@ class SLPAPI extends abstract_1.BaseAPI {
153
161
  const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder);
154
162
  // Handle sponsored transaction case
155
163
  if (sponsoredTx) {
156
- const suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
157
- tx = await this.initOracleTxb(pythFeederKeys, tx, true, suiCoinObject);
164
+ const oracle = await this.initOracleTxb(pythFeederKeys, tx, true, {
165
+ sender: this.requireSenderForSponsored(sender),
166
+ additionalSuiAmount: 0n,
167
+ });
168
+ tx = oracle.tx;
169
+ const { suiCoinObject } = oracle;
158
170
  const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx);
159
171
  tx.moveCall({
160
172
  target: `${this.consts.sudoCore.upgradedPackage}::market::deposit`,
@@ -174,7 +186,7 @@ class SLPAPI extends abstract_1.BaseAPI {
174
186
  return tx;
175
187
  }
176
188
  // Handle non-sponsored transaction case
177
- tx = await this.initOracleTxb(pythFeederKeys, tx);
189
+ tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx;
178
190
  const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx);
179
191
  tx.moveCall({
180
192
  target: `${this.consts.sudoCore.upgradedPackage}::market::deposit`,
@@ -196,16 +208,20 @@ class SLPAPI extends abstract_1.BaseAPI {
196
208
  /**
197
209
  * Withdraws collateral from SLP vault using Sudo SDK approach
198
210
  */
199
- async withdraw(coin, lpCoinObjects, amount, minAmountOut = 0, sponsoredTx, suiCoinObjectsForPythUpdate) {
211
+ async withdraw(coin, lpCoinObjects, amount, minAmountOut = 0, sponsoredTx, sender) {
200
212
  let tx = new transactions_1.Transaction();
201
213
  // Initialize oracle transaction
202
214
  const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder);
203
215
  if (sponsoredTx) {
204
- const suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
205
- tx = await this.initOracleTxb(pythFeederKeys, tx, true, suiCoinObject);
216
+ const oracle = await this.initOracleTxb(pythFeederKeys, tx, true, {
217
+ sender: this.requireSenderForSponsored(sender),
218
+ additionalSuiAmount: 0n,
219
+ });
220
+ tx = oracle.tx;
221
+ const { suiCoinObject } = oracle;
206
222
  }
207
223
  else {
208
- tx = await this.initOracleTxb(pythFeederKeys, tx);
224
+ tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx;
209
225
  }
210
226
  const slpCoinObject = this.processCoins(tx, 'slp', lpCoinObjects, false);
211
227
  const [withdrawObject] = tx.splitCoins(slpCoinObject, [tx.pure.u64(amount)]);
@@ -236,7 +252,7 @@ class SLPAPI extends abstract_1.BaseAPI {
236
252
  }
237
253
  // Initialize oracle transaction
238
254
  const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder);
239
- tx = await this.initOracleTxb(pythFeederKeys, tx);
255
+ tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx;
240
256
  const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx);
241
257
  tx.moveCall({
242
258
  target: `${this.consts.sudoCore.upgradedPackage}::market::withdraw`,
@@ -255,18 +271,22 @@ class SLPAPI extends abstract_1.BaseAPI {
255
271
  });
256
272
  return tx;
257
273
  }
258
- async withdrawPtb(coin, lpCoinObjects, amount, minAmountOut = 0, tx, sponsoredTx, suiCoinObjectsForPythUpdate) {
274
+ async withdrawPtb(coin, lpCoinObjects, amount, minAmountOut = 0, tx, sponsoredTx, sender) {
259
275
  if (!tx) {
260
276
  tx = new transactions_1.Transaction();
261
277
  }
262
278
  // Initialize oracle transaction
263
279
  const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder);
264
280
  if (sponsoredTx) {
265
- const suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
266
- tx = await this.initOracleTxb(pythFeederKeys, tx, true, suiCoinObject);
281
+ const oracle = await this.initOracleTxb(pythFeederKeys, tx, true, {
282
+ sender: this.requireSenderForSponsored(sender),
283
+ additionalSuiAmount: 0n,
284
+ });
285
+ tx = oracle.tx;
286
+ const { suiCoinObject } = oracle;
267
287
  }
268
288
  else {
269
- tx = await this.initOracleTxb(pythFeederKeys, tx);
289
+ tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx;
270
290
  }
271
291
  const slpCoinObject = this.processCoins(tx, 'slp', lpCoinObjects, false);
272
292
  const [withdrawObject] = tx.splitCoins(slpCoinObject, [tx.pure.u64(amount)]);
@@ -289,7 +309,7 @@ class SLPAPI extends abstract_1.BaseAPI {
289
309
  return withdrawCoin;
290
310
  }
291
311
  async swap(fromToken, toToken, fromAmount, fromCoinObjects, minAmountOut) {
292
- const tx = await this.initOracleTxb(Object.keys(this.consts.sudoCore.vaults));
312
+ const { tx } = await this.initOracleTxb(Object.keys(this.consts.sudoCore.vaults));
293
313
  const fromCoinObject = this.processCoins(tx, fromToken, fromCoinObjects);
294
314
  const [fromDepositObject] = tx.splitCoins(fromCoinObject, [
295
315
  tx.pure.u64(fromAmount),
@@ -323,7 +343,7 @@ class SLPAPI extends abstract_1.BaseAPI {
323
343
  if (!tx) {
324
344
  tx = new transactions_1.Transaction();
325
345
  }
326
- tx = await this.initOracleTxb(Object.keys(this.consts.sudoCore.vaults), tx);
346
+ tx = (await this.initOracleTxb(Object.keys(this.consts.sudoCore.vaults), tx)).tx;
327
347
  const fromCoinObject = this.processCoins(tx, fromToken, fromCoinObjects);
328
348
  const [fromDepositObject] = tx.splitCoins(fromCoinObject, [
329
349
  tx.pure.u64(fromAmount),
@@ -513,7 +533,7 @@ class SLPAPI extends abstract_1.BaseAPI {
513
533
  /**
514
534
  * Opens a position using Sudo SDK approach
515
535
  */
516
- async openPosition(collateralToken, indexToken, size, collateralAmount, coinObjects, long, reserveAmount, indexPrice, collateralPrice, isLimitOrder = false, isIocOrder = false, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), referralAddress, sender, sponsoredTx, suiCoinObjectsForPythUpdate) {
536
+ async openPosition(collateralToken, indexToken, size, collateralAmount, coinObjects, long, reserveAmount, indexPrice, collateralPrice, isLimitOrder = false, isIocOrder = false, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), referralAddress, sender, sponsoredTx) {
517
537
  let tx = new transactions_1.Transaction();
518
538
  if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
519
539
  tx = await this.addReferral(referralAddress, tx);
@@ -528,11 +548,15 @@ class SLPAPI extends abstract_1.BaseAPI {
528
548
  // Handle oracle initialization and coin processing
529
549
  let suiCoinObject;
530
550
  if (sponsoredTx) {
531
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
532
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
551
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
552
+ sender: this.requireSenderForSponsored(sender),
553
+ additionalSuiAmount: collateralToken === 'sui' ? collateralAmount + relayerFee : 0n,
554
+ });
555
+ tx = oracle.tx;
556
+ suiCoinObject = oracle.suiCoinObject;
533
557
  }
534
558
  else {
535
- tx = await this.initOracleTxb([collateralToken, indexToken], tx);
559
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx;
536
560
  }
537
561
  // Process coin splitting
538
562
  const [depositObject, feeObject] = this.processCoinSplitting(tx, collateralToken, coinObjects, [tx.pure.u64(collateralAmount), tx.pure.u64(relayerFee)], sponsoredTx, suiCoinObject);
@@ -567,7 +591,7 @@ class SLPAPI extends abstract_1.BaseAPI {
567
591
  /**
568
592
  * Opens a position using Sudo SDK approach
569
593
  */
570
- async openPositionWithCoin(collateralToken, indexToken, size, coinObj, long, reserveAmount, indexPrice, collateralPrice, isLimitOrder = false, isIocOrder = false, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), referralAddress, sender, tx, sponsoredTx, suiCoinObjectsForPythUpdate) {
594
+ async openPositionWithCoin(collateralToken, indexToken, size, coinObj, long, reserveAmount, indexPrice, collateralPrice, isLimitOrder = false, isIocOrder = false, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), referralAddress, sender, tx, sponsoredTx) {
571
595
  if (!tx) {
572
596
  tx = new transactions_1.Transaction();
573
597
  }
@@ -584,11 +608,15 @@ class SLPAPI extends abstract_1.BaseAPI {
584
608
  // Handle oracle initialization and coin processing
585
609
  let suiCoinObject;
586
610
  if (sponsoredTx) {
587
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
588
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
611
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
612
+ sender: this.requireSenderForSponsored(sender),
613
+ additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
614
+ });
615
+ tx = oracle.tx;
616
+ suiCoinObject = oracle.suiCoinObject;
589
617
  }
590
618
  else {
591
- tx = await this.initOracleTxb([collateralToken, indexToken], tx);
619
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx;
592
620
  }
593
621
  // Process coin splitting
594
622
  const [feeObject] = tx.splitCoins(coinObj, [tx.pure.u64(relayerFee)]);
@@ -623,7 +651,7 @@ class SLPAPI extends abstract_1.BaseAPI {
623
651
  /**
624
652
  * Opens a new position in SLP (V2 - uses v3 contract)
625
653
  */
626
- 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) {
654
+ 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) {
627
655
  let tx = new transactions_1.Transaction();
628
656
  if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
629
657
  tx = await this.addReferral(referralAddress, tx);
@@ -639,11 +667,15 @@ class SLPAPI extends abstract_1.BaseAPI {
639
667
  // Handle oracle initialization and coin processing
640
668
  let suiCoinObject;
641
669
  if (sponsoredTx) {
642
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
643
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
670
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
671
+ sender: this.requireSenderForSponsored(sender),
672
+ additionalSuiAmount: collateralToken === 'sui' ? collateralAmount + relayerFee : 0n,
673
+ });
674
+ tx = oracle.tx;
675
+ suiCoinObject = oracle.suiCoinObject;
644
676
  }
645
677
  else {
646
- tx = await this.initOracleTxb([collateralToken, indexToken], tx);
678
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx;
647
679
  }
648
680
  // Process coin splitting
649
681
  const [depositObject, feeObject] = this.processCoinSplitting(tx, collateralToken, coinObjects, [tx.pure.u64(collateralAmount), tx.pure.u64(relayerFee)], sponsoredTx, suiCoinObject);
@@ -677,7 +709,7 @@ class SLPAPI extends abstract_1.BaseAPI {
677
709
  /**
678
710
  * Opens a new position with Coin in SLP (V2 - uses v3 contract)
679
711
  */
680
- 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) {
712
+ 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) {
681
713
  if (!tx) {
682
714
  tx = new transactions_1.Transaction();
683
715
  }
@@ -695,11 +727,15 @@ class SLPAPI extends abstract_1.BaseAPI {
695
727
  // Handle oracle initialization and coin processing
696
728
  let suiCoinObject;
697
729
  if (sponsoredTx) {
698
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
699
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
730
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
731
+ sender: this.requireSenderForSponsored(sender),
732
+ additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
733
+ });
734
+ tx = oracle.tx;
735
+ suiCoinObject = oracle.suiCoinObject;
700
736
  }
701
737
  else {
702
- tx = await this.initOracleTxb([collateralToken, indexToken], tx);
738
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx;
703
739
  }
704
740
  // Process coin splitting
705
741
  const [feeObject] = tx.splitCoins(coinObj, [tx.pure.u64(relayerFee)]);
@@ -733,7 +769,7 @@ class SLPAPI extends abstract_1.BaseAPI {
733
769
  /**
734
770
  * Decreases an existing position in SLP using Sudo SDK approach
735
771
  */
736
- 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) {
772
+ 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) {
737
773
  if (!coinObjects) {
738
774
  throw new Error(`${this.constructor.name}: coinObjects is required`);
739
775
  }
@@ -750,11 +786,15 @@ class SLPAPI extends abstract_1.BaseAPI {
750
786
  }
751
787
  let suiCoinObject;
752
788
  if (sponsoredTx) {
753
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
754
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
789
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
790
+ sender: this.requireSenderForSponsored(sender),
791
+ additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
792
+ });
793
+ tx = oracle.tx;
794
+ suiCoinObject = oracle.suiCoinObject;
755
795
  }
756
796
  else {
757
- tx = await this.initOracleTxb([collateralToken, indexToken], tx);
797
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx;
758
798
  }
759
799
  // Handle oracle initialization and coin processing
760
800
  const [feeObject] = this.processCoinSplitting(tx, collateralToken, coinObjects, [tx.pure.u64(relayerFee)], sponsoredTx, suiCoinObject);
@@ -788,7 +828,7 @@ class SLPAPI extends abstract_1.BaseAPI {
788
828
  /**
789
829
  * Decreases an existing position in SLP (V2 - uses v3 contract)
790
830
  */
791
- 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) {
831
+ 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) {
792
832
  if (!coinObjects) {
793
833
  throw new Error(`${this.constructor.name}: coinObjects is required`);
794
834
  }
@@ -806,11 +846,15 @@ class SLPAPI extends abstract_1.BaseAPI {
806
846
  // Handle oracle initialization and coin processing
807
847
  let suiCoinObject;
808
848
  if (sponsoredTx) {
809
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
810
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
849
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
850
+ sender: this.requireSenderForSponsored(sender),
851
+ additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
852
+ });
853
+ tx = oracle.tx;
854
+ suiCoinObject = oracle.suiCoinObject;
811
855
  }
812
856
  else {
813
- tx = await this.initOracleTxb([collateralToken, indexToken], tx);
857
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx;
814
858
  }
815
859
  // Process coin splitting
816
860
  const [feeObject] = this.processCoinSplitting(tx, collateralToken, coinObjects, [tx.pure.u64(relayerFee)], sponsoredTx, suiCoinObject);
@@ -840,18 +884,19 @@ class SLPAPI extends abstract_1.BaseAPI {
840
884
  });
841
885
  return tx;
842
886
  }
843
- async decreaseMultiPositions(positions, tx, sponsoredTx, suiCoinObjectsForPythUpdate) {
887
+ async decreaseMultiPositions(positions, tx, sponsoredTx, sender) {
844
888
  if (!tx) {
845
889
  tx = new transactions_1.Transaction();
846
890
  }
847
891
  // Handle oracle initialization and coin processing
848
892
  let suiCoinObject;
849
893
  if (sponsoredTx) {
850
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
851
- tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx, true, suiCoinObject);
894
+ const oracle = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx, true, { sender: this.requireSenderForSponsored(sender) });
895
+ tx = oracle.tx;
896
+ suiCoinObject = oracle.suiCoinObject;
852
897
  }
853
898
  else {
854
- tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx);
899
+ tx = (await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx)).tx;
855
900
  }
856
901
  for (const position of positions) {
857
902
  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;
@@ -896,14 +941,21 @@ class SLPAPI extends abstract_1.BaseAPI {
896
941
  }
897
942
  return tx;
898
943
  }
899
- async decreaseMultiPositionsV2(positions, tx, sponsoredTx, suiCoinObjectsForPythUpdate, feeObjects) {
900
- const transaction = tx ?? new transactions_1.Transaction();
944
+ async decreaseMultiPositionsV2(positions, tx, sponsoredTx, sender, feeObjects) {
945
+ let transaction = tx ?? new transactions_1.Transaction();
901
946
  // Handle oracle initialization and coin processing
902
947
  const tokens = positions.flatMap(position => [position.collateralToken, position.indexToken]);
903
- const suiCoinObject = sponsoredTx
904
- ? this.processCoins(transaction, 'sui', suiCoinObjectsForPythUpdate || [], true)
905
- : undefined;
906
- await this.initOracleTxb(tokens, transaction, !!sponsoredTx, suiCoinObject);
948
+ let suiCoinObject;
949
+ if (sponsoredTx) {
950
+ const oracle = await this.initOracleTxb(tokens, transaction, true, {
951
+ sender: this.requireSenderForSponsored(sender),
952
+ });
953
+ transaction = oracle.tx;
954
+ suiCoinObject = oracle.suiCoinObject;
955
+ }
956
+ else {
957
+ transaction = (await this.initOracleTxb(tokens, transaction, false)).tx;
958
+ }
907
959
  if (!feeObjects || feeObjects.length !== positions.length) {
908
960
  throw new Error('feeObjects must be provided (pre-processed via buildFeeCoinObjects) and match positions length');
909
961
  }
@@ -948,16 +1000,20 @@ class SLPAPI extends abstract_1.BaseAPI {
948
1000
  }
949
1001
  return transaction;
950
1002
  }
951
- async pledgeInPosition(pcpId, collateralToken, indexToken, amount, coinObjects, long, sponsoredTx, suiCoinObjectsForPythUpdate) {
1003
+ async pledgeInPosition(pcpId, collateralToken, indexToken, amount, coinObjects, long, sponsoredTx, sender) {
952
1004
  let tx = new transactions_1.Transaction();
953
1005
  // Handle oracle initialization and coin processing
954
1006
  let suiCoinObject;
955
1007
  if (sponsoredTx) {
956
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
957
- 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' ? BigInt(amount) : 0n,
1011
+ });
1012
+ tx = oracle.tx;
1013
+ suiCoinObject = oracle.suiCoinObject;
958
1014
  }
959
1015
  else {
960
- tx = await this.initOracleTxb([collateralToken, indexToken], tx);
1016
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx;
961
1017
  }
962
1018
  // Process coin splitting
963
1019
  const [depositObject] = this.processCoinSplitting(tx, collateralToken, coinObjects, [tx.pure.u64(amount)], sponsoredTx, suiCoinObject);
@@ -977,16 +1033,20 @@ class SLPAPI extends abstract_1.BaseAPI {
977
1033
  });
978
1034
  return tx;
979
1035
  }
980
- async redeemFromPosition(pcpId, collateralToken, indexToken, amount, long, sponsoredTx, suiCoinObjectsForPythUpdate) {
1036
+ async redeemFromPosition(pcpId, collateralToken, indexToken, amount, long, sponsoredTx, sender) {
981
1037
  let tx = new transactions_1.Transaction();
982
1038
  // Handle oracle initialization and coin processing
983
1039
  let suiCoinObject;
984
1040
  if (sponsoredTx) {
985
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
986
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
1041
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
1042
+ sender: this.requireSenderForSponsored(sender),
1043
+ additionalSuiAmount: 0n,
1044
+ });
1045
+ tx = oracle.tx;
1046
+ suiCoinObject = oracle.suiCoinObject;
987
1047
  }
988
1048
  else {
989
- tx = await this.initOracleTxb([collateralToken, indexToken], tx);
1049
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx;
990
1050
  }
991
1051
  const symbol = (0, utils_2.joinSymbol)(long ? 'long' : 'short', indexToken);
992
1052
  tx.moveCall({
@@ -1164,7 +1224,7 @@ class SLPAPI extends abstract_1.BaseAPI {
1164
1224
  arguments: [tx.object(this.consts.sudoCore.market), tx.object(orderCapId)],
1165
1225
  });
1166
1226
  }
1167
- async openPositionWithSCard(collateralToken, indexToken, size, collateralAmount, coinObjects, long, reserveAmount, indexPrice, collateralPrice, kioskClient, kioskCap, scard, isLimitOrder = false, isIocOrder = false, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), referralAddress, sender, sponsoredTx, suiCoinObjectsForPythUpdate) {
1227
+ async openPositionWithSCard(collateralToken, indexToken, size, collateralAmount, coinObjects, long, reserveAmount, indexPrice, collateralPrice, kioskClient, kioskCap, scard, isLimitOrder = false, isIocOrder = false, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), referralAddress, sender, sponsoredTx) {
1168
1228
  let tx = new transactions_1.Transaction();
1169
1229
  if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
1170
1230
  tx = await this.addReferral(referralAddress, tx);
@@ -1188,11 +1248,15 @@ class SLPAPI extends abstract_1.BaseAPI {
1188
1248
  // Handle oracle initialization and coin processing
1189
1249
  let suiCoinObject;
1190
1250
  if (sponsoredTx) {
1191
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
1192
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
1251
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
1252
+ sender: this.requireSenderForSponsored(sender),
1253
+ additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
1254
+ });
1255
+ tx = oracle.tx;
1256
+ suiCoinObject = oracle.suiCoinObject;
1193
1257
  }
1194
1258
  else {
1195
- tx = await this.initOracleTxb([collateralToken, indexToken], tx);
1259
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx;
1196
1260
  }
1197
1261
  // Process coin splitting
1198
1262
  const [depositObject, feeObject] = this.processCoinSplitting(tx, collateralToken, coinObjects, [tx.pure.u64(collateralAmount), tx.pure.u64(relayerFee)], sponsoredTx, suiCoinObject);
@@ -1232,7 +1296,7 @@ class SLPAPI extends abstract_1.BaseAPI {
1232
1296
  .finalize();
1233
1297
  return tx;
1234
1298
  }
1235
- async openPositionWithCoinAndSCard(collateralToken, indexToken, size, coinObj, long, reserveAmount, indexPrice, collateralPrice, kioskClient, kioskCap, scard, isLimitOrder = false, isIocOrder = false, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), referralAddress, sender, tx, sponsoredTx, suiCoinObjectsForPythUpdate) {
1299
+ async openPositionWithCoinAndSCard(collateralToken, indexToken, size, coinObj, long, reserveAmount, indexPrice, collateralPrice, kioskClient, kioskCap, scard, isLimitOrder = false, isIocOrder = false, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), referralAddress, sender, tx, sponsoredTx) {
1236
1300
  if (!tx) {
1237
1301
  tx = new transactions_1.Transaction();
1238
1302
  }
@@ -1258,11 +1322,15 @@ class SLPAPI extends abstract_1.BaseAPI {
1258
1322
  // Handle oracle initialization and coin processing
1259
1323
  let suiCoinObject;
1260
1324
  if (sponsoredTx) {
1261
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
1262
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
1325
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
1326
+ sender: this.requireSenderForSponsored(sender),
1327
+ additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
1328
+ });
1329
+ tx = oracle.tx;
1330
+ suiCoinObject = oracle.suiCoinObject;
1263
1331
  }
1264
1332
  else {
1265
- tx = await this.initOracleTxb([collateralToken, indexToken], tx);
1333
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx;
1266
1334
  }
1267
1335
  // Process coin splitting
1268
1336
  const [feeObject] = tx.splitCoins(coinObj, [tx.pure.u64(relayerFee)]);
@@ -1302,7 +1370,7 @@ class SLPAPI extends abstract_1.BaseAPI {
1302
1370
  .finalize();
1303
1371
  return tx;
1304
1372
  }
1305
- 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) {
1373
+ 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) {
1306
1374
  let tx = new transactions_1.Transaction();
1307
1375
  if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
1308
1376
  tx = await this.addReferral(referralAddress, tx);
@@ -1327,11 +1395,15 @@ class SLPAPI extends abstract_1.BaseAPI {
1327
1395
  // Handle oracle initialization and coin processing
1328
1396
  let suiCoinObject;
1329
1397
  if (sponsoredTx) {
1330
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
1331
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
1398
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
1399
+ sender: this.requireSenderForSponsored(sender),
1400
+ additionalSuiAmount: collateralToken === 'sui' ? collateralAmount + relayerFee : 0n,
1401
+ });
1402
+ tx = oracle.tx;
1403
+ suiCoinObject = oracle.suiCoinObject;
1332
1404
  }
1333
1405
  else {
1334
- tx = await this.initOracleTxb([collateralToken, indexToken], tx);
1406
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx;
1335
1407
  }
1336
1408
  // Process coin splitting
1337
1409
  const [depositObject, feeObject] = this.processCoinSplitting(tx, collateralToken, coinObjects, [tx.pure.u64(collateralAmount), tx.pure.u64(relayerFee)], sponsoredTx, suiCoinObject);
@@ -1371,7 +1443,7 @@ class SLPAPI extends abstract_1.BaseAPI {
1371
1443
  return tx;
1372
1444
  }
1373
1445
  // S Card operations
1374
- 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) {
1446
+ 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) {
1375
1447
  if (!tx) {
1376
1448
  tx = new transactions_1.Transaction();
1377
1449
  }
@@ -1398,11 +1470,15 @@ class SLPAPI extends abstract_1.BaseAPI {
1398
1470
  // Handle oracle initialization and coin processing
1399
1471
  let suiCoinObject;
1400
1472
  if (sponsoredTx) {
1401
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
1402
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
1473
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
1474
+ sender: this.requireSenderForSponsored(sender),
1475
+ additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
1476
+ });
1477
+ tx = oracle.tx;
1478
+ suiCoinObject = oracle.suiCoinObject;
1403
1479
  }
1404
1480
  else {
1405
- tx = await this.initOracleTxb([collateralToken, indexToken], tx);
1481
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx;
1406
1482
  }
1407
1483
  // Process coin splitting
1408
1484
  const [feeObject] = tx.splitCoins(coinObj, [tx.pure.u64(relayerFee)]);
@@ -1441,7 +1517,7 @@ class SLPAPI extends abstract_1.BaseAPI {
1441
1517
  .finalize();
1442
1518
  return tx;
1443
1519
  }
1444
- 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) {
1520
+ 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) {
1445
1521
  if (!coinObjects) {
1446
1522
  throw new Error(`${this.constructor.name}: coinObjects is required`);
1447
1523
  }
@@ -1468,11 +1544,15 @@ class SLPAPI extends abstract_1.BaseAPI {
1468
1544
  // Handle oracle initialization and coin processing
1469
1545
  let suiCoinObject;
1470
1546
  if (sponsoredTx) {
1471
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
1472
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
1547
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
1548
+ sender: this.requireSenderForSponsored(sender),
1549
+ additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
1550
+ });
1551
+ tx = oracle.tx;
1552
+ suiCoinObject = oracle.suiCoinObject;
1473
1553
  }
1474
1554
  else {
1475
- tx = await this.initOracleTxb([collateralToken, indexToken], tx);
1555
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx;
1476
1556
  }
1477
1557
  // Process coin splitting
1478
1558
  const [feeObject] = this.processCoinSplitting(tx, collateralToken, coinObjects, [tx.pure.u64(relayerFee)], sponsoredTx, suiCoinObject);
@@ -1511,7 +1591,7 @@ class SLPAPI extends abstract_1.BaseAPI {
1511
1591
  .finalize();
1512
1592
  return tx;
1513
1593
  }
1514
- 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) {
1594
+ 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) {
1515
1595
  if (!coinObjects) {
1516
1596
  throw new Error(`${this.constructor.name}: coinObjects is required`);
1517
1597
  }
@@ -1538,11 +1618,15 @@ class SLPAPI extends abstract_1.BaseAPI {
1538
1618
  // Handle oracle initialization and coin processing
1539
1619
  let suiCoinObject;
1540
1620
  if (sponsoredTx) {
1541
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
1542
- tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
1621
+ const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
1622
+ sender: this.requireSenderForSponsored(sender),
1623
+ additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
1624
+ });
1625
+ tx = oracle.tx;
1626
+ suiCoinObject = oracle.suiCoinObject;
1543
1627
  }
1544
1628
  else {
1545
- tx = await this.initOracleTxb([collateralToken, indexToken], tx);
1629
+ tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx;
1546
1630
  }
1547
1631
  // Process coin splitting
1548
1632
  const [feeObject] = this.processCoinSplitting(tx, collateralToken, coinObjects, [tx.pure.u64(relayerFee)], sponsoredTx, suiCoinObject);
@@ -1580,18 +1664,19 @@ class SLPAPI extends abstract_1.BaseAPI {
1580
1664
  .finalize();
1581
1665
  return tx;
1582
1666
  }
1583
- async decreaseMultiPositionsWithSCard(positions, kioskClient, kioskCap, scard, tx, sponsoredTx, suiCoinObjectsForPythUpdate) {
1667
+ async decreaseMultiPositionsWithSCard(positions, kioskClient, kioskCap, scard, tx, sponsoredTx, sender) {
1584
1668
  if (!tx) {
1585
1669
  tx = new transactions_1.Transaction();
1586
1670
  }
1587
1671
  // Handle oracle initialization and coin processing
1588
1672
  let suiCoinObject;
1589
1673
  if (sponsoredTx) {
1590
- suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
1591
- tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx, true, suiCoinObject);
1674
+ const oracle = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx, true, { sender: this.requireSenderForSponsored(sender) });
1675
+ tx = oracle.tx;
1676
+ suiCoinObject = oracle.suiCoinObject;
1592
1677
  }
1593
1678
  else {
1594
- tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx);
1679
+ tx = (await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx)).tx;
1595
1680
  }
1596
1681
  const kioskTx = new kiosk_1.KioskTransaction({
1597
1682
  transaction: tx,
@@ -1653,14 +1738,21 @@ class SLPAPI extends abstract_1.BaseAPI {
1653
1738
  .finalize();
1654
1739
  return tx;
1655
1740
  }
1656
- async decreaseMultiPositionsWithSCardV2(positions, kioskClient, kioskCap, scard, tx, sponsoredTx, suiCoinObjectsForPythUpdate, feeObjects) {
1657
- const transaction = tx ?? new transactions_1.Transaction();
1741
+ async decreaseMultiPositionsWithSCardV2(positions, kioskClient, kioskCap, scard, tx, sponsoredTx, sender, feeObjects) {
1742
+ let transaction = tx ?? new transactions_1.Transaction();
1658
1743
  // Handle oracle initialization and coin processing
1659
1744
  const tokens = positions.flatMap(position => [position.collateralToken, position.indexToken]);
1660
- const suiCoinObject = sponsoredTx
1661
- ? this.processCoins(transaction, 'sui', suiCoinObjectsForPythUpdate || [], true)
1662
- : undefined;
1663
- await this.initOracleTxb(tokens, transaction, !!sponsoredTx, suiCoinObject);
1745
+ let suiCoinObject;
1746
+ if (sponsoredTx) {
1747
+ const oracle = await this.initOracleTxb(tokens, transaction, true, {
1748
+ sender: this.requireSenderForSponsored(sender),
1749
+ });
1750
+ transaction = oracle.tx;
1751
+ suiCoinObject = oracle.suiCoinObject;
1752
+ }
1753
+ else {
1754
+ transaction = (await this.initOracleTxb(tokens, transaction, false)).tx;
1755
+ }
1664
1756
  if (!feeObjects || feeObjects.length !== positions.length) {
1665
1757
  throw new Error('feeObjects must be provided (pre-processed via buildFeeCoinObjects) and match positions length');
1666
1758
  }
@@ -1734,7 +1826,7 @@ class SLPAPI extends abstract_1.BaseAPI {
1734
1826
  return tx;
1735
1827
  }
1736
1828
  async adminUpdatePriceFeed(collateralToken, indexToken) {
1737
- const tx = await this.initOracleTxb([collateralToken, indexToken]);
1829
+ const { tx } = await this.initOracleTxb([collateralToken, indexToken]);
1738
1830
  return tx;
1739
1831
  }
1740
1832
  adminSettlePosition(_positionId, _owner, _collateralToken, _indexToken, _long) {