@zofai/zo-sdk 0.2.8 → 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/abstract/BaseAPI.cjs +7 -1
- package/dist/abstract/BaseAPI.cjs.map +1 -1
- package/dist/abstract/BaseAPI.d.cts +8 -7
- package/dist/abstract/BaseAPI.d.cts.map +1 -1
- package/dist/abstract/BaseAPI.d.mts +8 -7
- package/dist/abstract/BaseAPI.d.mts.map +1 -1
- package/dist/abstract/BaseAPI.mjs +7 -1
- package/dist/abstract/BaseAPI.mjs.map +1 -1
- package/dist/api.cjs +12 -12
- package/dist/api.cjs.map +1 -1
- package/dist/api.d.cts.map +1 -1
- package/dist/api.d.mts.map +1 -1
- package/dist/api.mjs +12 -12
- package/dist/api.mjs.map +1 -1
- package/dist/coins.cjs +74 -0
- package/dist/coins.cjs.map +1 -0
- package/dist/coins.d.cts +37 -0
- package/dist/coins.d.cts.map +1 -0
- package/dist/coins.d.mts +37 -0
- package/dist/coins.d.mts.map +1 -0
- package/dist/coins.mjs +67 -0
- package/dist/coins.mjs.map +1 -0
- package/dist/consts/deployments-usdz-mainnet.json +1 -1
- package/dist/implementations/SLPAPI.cjs +192 -100
- package/dist/implementations/SLPAPI.cjs.map +1 -1
- package/dist/implementations/SLPAPI.d.cts +23 -23
- package/dist/implementations/SLPAPI.d.cts.map +1 -1
- package/dist/implementations/SLPAPI.d.mts +23 -23
- package/dist/implementations/SLPAPI.d.mts.map +1 -1
- package/dist/implementations/SLPAPI.mjs +192 -100
- package/dist/implementations/SLPAPI.mjs.map +1 -1
- package/dist/implementations/SLPDataAPI.cjs +2 -2
- package/dist/implementations/SLPDataAPI.cjs.map +1 -1
- package/dist/implementations/SLPDataAPI.mjs +2 -2
- package/dist/implementations/SLPDataAPI.mjs.map +1 -1
- package/dist/implementations/USDZAPI.cjs +176 -92
- package/dist/implementations/USDZAPI.cjs.map +1 -1
- package/dist/implementations/USDZAPI.d.cts +21 -21
- package/dist/implementations/USDZAPI.d.cts.map +1 -1
- package/dist/implementations/USDZAPI.d.mts +21 -21
- package/dist/implementations/USDZAPI.d.mts.map +1 -1
- package/dist/implementations/USDZAPI.mjs +176 -92
- package/dist/implementations/USDZAPI.mjs.map +1 -1
- package/dist/implementations/ZBTCVCAPI.cjs +84 -46
- package/dist/implementations/ZBTCVCAPI.cjs.map +1 -1
- package/dist/implementations/ZBTCVCAPI.d.cts +11 -11
- package/dist/implementations/ZBTCVCAPI.d.cts.map +1 -1
- package/dist/implementations/ZBTCVCAPI.d.mts +11 -11
- package/dist/implementations/ZBTCVCAPI.d.mts.map +1 -1
- package/dist/implementations/ZBTCVCAPI.mjs +84 -46
- package/dist/implementations/ZBTCVCAPI.mjs.map +1 -1
- package/dist/implementations/ZLPAPI.cjs +192 -100
- package/dist/implementations/ZLPAPI.cjs.map +1 -1
- package/dist/implementations/ZLPAPI.d.cts +23 -23
- package/dist/implementations/ZLPAPI.d.cts.map +1 -1
- package/dist/implementations/ZLPAPI.d.mts +23 -23
- package/dist/implementations/ZLPAPI.d.mts.map +1 -1
- package/dist/implementations/ZLPAPI.mjs +192 -100
- package/dist/implementations/ZLPAPI.mjs.map +1 -1
- package/dist/index.cjs +1 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -1
- package/dist/interfaces/base.d.cts +25 -21
- package/dist/interfaces/base.d.cts.map +1 -1
- package/dist/interfaces/base.d.mts +25 -21
- package/dist/interfaces/base.d.mts.map +1 -1
- package/dist/interfaces/slp.d.cts +1 -1
- package/dist/interfaces/slp.d.cts.map +1 -1
- package/dist/interfaces/slp.d.mts +1 -1
- package/dist/interfaces/slp.d.mts.map +1 -1
- package/dist/interfaces/usdz.d.cts +1 -1
- package/dist/interfaces/usdz.d.cts.map +1 -1
- package/dist/interfaces/usdz.d.mts +1 -1
- package/dist/interfaces/usdz.d.mts.map +1 -1
- package/dist/interfaces/zbtcvc.d.cts +1 -1
- package/dist/interfaces/zbtcvc.d.cts.map +1 -1
- package/dist/interfaces/zbtcvc.d.mts +1 -1
- package/dist/interfaces/zbtcvc.d.mts.map +1 -1
- package/dist/interfaces/zlp.d.cts +1 -1
- package/dist/interfaces/zlp.d.cts.map +1 -1
- package/dist/interfaces/zlp.d.mts +1 -1
- package/dist/interfaces/zlp.d.mts.map +1 -1
- package/dist/oracle.cjs +27 -22
- package/dist/oracle.cjs.map +1 -1
- package/dist/oracle.d.cts +13 -1
- package/dist/oracle.d.cts.map +1 -1
- package/dist/oracle.d.mts +13 -1
- package/dist/oracle.d.mts.map +1 -1
- package/dist/oracle.mjs +27 -22
- package/dist/oracle.mjs.map +1 -1
- package/package.json +1 -1
- package/src/abstract/BaseAPI.ts +10 -8
- package/src/api.ts +17 -13
- package/src/coins.ts +115 -0
- package/src/consts/deployments-usdz-mainnet.json +1 -1
- package/src/implementations/SLPAPI.ts +201 -117
- package/src/implementations/SLPDataAPI.ts +2 -2
- package/src/implementations/USDZAPI.ts +184 -94
- package/src/implementations/ZBTCVCAPI.ts +98 -48
- package/src/implementations/ZLPAPI.ts +199 -102
- package/src/index.ts +1 -0
- package/src/interfaces/base.ts +13 -21
- package/src/interfaces/slp.ts +0 -1
- package/src/interfaces/usdz.ts +0 -1
- package/src/interfaces/zbtcvc.ts +0 -1
- package/src/interfaces/zlp.ts +0 -1
- package/src/oracle.ts +64 -28
|
@@ -53,7 +53,6 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
53
53
|
referralAddress?: string,
|
|
54
54
|
sender?: string,
|
|
55
55
|
sponsoredTx?: boolean,
|
|
56
|
-
suiCoinObjectsForPythUpdate?: string[],
|
|
57
56
|
): Promise<Transaction> {
|
|
58
57
|
let tx = new Transaction()
|
|
59
58
|
|
|
@@ -67,12 +66,16 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
67
66
|
|
|
68
67
|
// Handle sponsored transaction case
|
|
69
68
|
if (sponsoredTx) {
|
|
70
|
-
const
|
|
71
|
-
|
|
69
|
+
const oracle = await this.initOracleTxb(pythFeederKeys, tx, true, {
|
|
70
|
+
sender: this.requireSenderForSponsored(sender),
|
|
71
|
+
additionalSuiAmount: coin === 'sui' ? BigInt(amount) : 0n,
|
|
72
|
+
})
|
|
73
|
+
tx = oracle.tx
|
|
74
|
+
const { suiCoinObject } = oracle
|
|
72
75
|
|
|
73
76
|
// Process deposit coins
|
|
74
77
|
const depositObject = coin === 'sui'
|
|
75
|
-
? tx.splitCoins(suiCoinObject
|
|
78
|
+
? tx.splitCoins(suiCoinObject!, [tx.pure.u64(amount)])[0]
|
|
76
79
|
: tx.splitCoins(this.processCoins(tx, coin, coinObjects, true), [tx.pure.u64(amount)])[0]
|
|
77
80
|
|
|
78
81
|
const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
|
|
@@ -93,7 +96,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
93
96
|
}
|
|
94
97
|
|
|
95
98
|
// Handle non-sponsored transaction case
|
|
96
|
-
tx = await this.initOracleTxb(pythFeederKeys, tx)
|
|
99
|
+
tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx
|
|
97
100
|
const depositObject = tx.splitCoins(
|
|
98
101
|
this.processCoins(tx, coin, coinObjects, false),
|
|
99
102
|
[tx.pure.u64(amount)],
|
|
@@ -131,7 +134,6 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
131
134
|
sender?: string,
|
|
132
135
|
tx?: Transaction,
|
|
133
136
|
sponsoredTx?: boolean,
|
|
134
|
-
suiCoinObjectsForPythUpdate?: string[],
|
|
135
137
|
): Promise<TransactionObjectArgument> {
|
|
136
138
|
if (!tx) {
|
|
137
139
|
tx = new Transaction()
|
|
@@ -147,12 +149,16 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
147
149
|
|
|
148
150
|
// Handle sponsored transaction case
|
|
149
151
|
if (sponsoredTx) {
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
+
const oracle = await this.initOracleTxb(pythFeederKeys, tx, true, {
|
|
153
|
+
sender: this.requireSenderForSponsored(sender),
|
|
154
|
+
additionalSuiAmount: coin === 'sui' ? BigInt(amount) : 0n,
|
|
155
|
+
})
|
|
156
|
+
tx = oracle.tx
|
|
157
|
+
const { suiCoinObject } = oracle
|
|
152
158
|
|
|
153
159
|
// Process deposit coins
|
|
154
160
|
const depositObject = coin === 'sui'
|
|
155
|
-
? tx.splitCoins(suiCoinObject
|
|
161
|
+
? tx.splitCoins(suiCoinObject!, [tx.pure.u64(amount)])[0]
|
|
156
162
|
: tx.splitCoins(this.processCoins(tx, coin, coinObjects, true), [tx.pure.u64(amount)])[0]
|
|
157
163
|
|
|
158
164
|
const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
|
|
@@ -173,7 +179,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
173
179
|
}
|
|
174
180
|
|
|
175
181
|
// Handle non-sponsored transaction case
|
|
176
|
-
tx = await this.initOracleTxb(pythFeederKeys, tx)
|
|
182
|
+
tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx
|
|
177
183
|
const depositObject = tx.splitCoins(
|
|
178
184
|
this.processCoins(tx, coin, coinObjects, false),
|
|
179
185
|
[tx.pure.u64(amount)],
|
|
@@ -208,7 +214,6 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
208
214
|
sender?: string,
|
|
209
215
|
tx?: Transaction,
|
|
210
216
|
sponsoredTx?: boolean,
|
|
211
|
-
suiCoinObjectsForPythUpdate?: string[],
|
|
212
217
|
): Promise<Transaction> {
|
|
213
218
|
if (!tx) {
|
|
214
219
|
tx = new Transaction()
|
|
@@ -224,8 +229,12 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
224
229
|
|
|
225
230
|
// Handle sponsored transaction case
|
|
226
231
|
if (sponsoredTx) {
|
|
227
|
-
const
|
|
228
|
-
|
|
232
|
+
const oracle = await this.initOracleTxb(pythFeederKeys, tx, true, {
|
|
233
|
+
sender: this.requireSenderForSponsored(sender),
|
|
234
|
+
additionalSuiAmount: 0n,
|
|
235
|
+
})
|
|
236
|
+
tx = oracle.tx
|
|
237
|
+
const { suiCoinObject } = oracle
|
|
229
238
|
|
|
230
239
|
const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
|
|
231
240
|
|
|
@@ -245,7 +254,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
245
254
|
}
|
|
246
255
|
|
|
247
256
|
// Handle non-sponsored transaction case
|
|
248
|
-
tx = await this.initOracleTxb(pythFeederKeys, tx)
|
|
257
|
+
tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx
|
|
249
258
|
|
|
250
259
|
const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
|
|
251
260
|
|
|
@@ -276,7 +285,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
276
285
|
amount: number,
|
|
277
286
|
minAmountOut = 0,
|
|
278
287
|
sponsoredTx?: boolean,
|
|
279
|
-
|
|
288
|
+
sender?: string,
|
|
280
289
|
): Promise<Transaction> {
|
|
281
290
|
let tx = new Transaction()
|
|
282
291
|
|
|
@@ -284,11 +293,15 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
284
293
|
const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder)
|
|
285
294
|
|
|
286
295
|
if (sponsoredTx) {
|
|
287
|
-
const
|
|
288
|
-
|
|
296
|
+
const oracle = await this.initOracleTxb(pythFeederKeys, tx, true, {
|
|
297
|
+
sender: this.requireSenderForSponsored(sender),
|
|
298
|
+
additionalSuiAmount: 0n,
|
|
299
|
+
})
|
|
300
|
+
tx = oracle.tx
|
|
301
|
+
const { suiCoinObject } = oracle
|
|
289
302
|
}
|
|
290
303
|
else {
|
|
291
|
-
tx = await this.initOracleTxb(pythFeederKeys, tx)
|
|
304
|
+
tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx
|
|
292
305
|
}
|
|
293
306
|
const zlpCoinObject = this.processCoins(tx, 'zlp', lpCoinObjects, false)
|
|
294
307
|
const [withdrawObject] = tx.splitCoins(zlpCoinObject, [tx.pure.u64(amount)])
|
|
@@ -327,7 +340,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
327
340
|
// Initialize oracle transaction
|
|
328
341
|
const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder)
|
|
329
342
|
|
|
330
|
-
tx = await this.initOracleTxb(pythFeederKeys, tx)
|
|
343
|
+
tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx
|
|
331
344
|
const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
|
|
332
345
|
|
|
333
346
|
tx.moveCall({
|
|
@@ -355,7 +368,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
355
368
|
minAmountOut = 0,
|
|
356
369
|
tx?: Transaction,
|
|
357
370
|
sponsoredTx?: boolean,
|
|
358
|
-
|
|
371
|
+
sender?: string,
|
|
359
372
|
): Promise<TransactionObjectArgument> {
|
|
360
373
|
if (!tx) {
|
|
361
374
|
tx = new Transaction()
|
|
@@ -365,11 +378,15 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
365
378
|
const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder)
|
|
366
379
|
|
|
367
380
|
if (sponsoredTx) {
|
|
368
|
-
const
|
|
369
|
-
|
|
381
|
+
const oracle = await this.initOracleTxb(pythFeederKeys, tx, true, {
|
|
382
|
+
sender: this.requireSenderForSponsored(sender),
|
|
383
|
+
additionalSuiAmount: 0n,
|
|
384
|
+
})
|
|
385
|
+
tx = oracle.tx
|
|
386
|
+
const { suiCoinObject } = oracle
|
|
370
387
|
}
|
|
371
388
|
else {
|
|
372
|
-
tx = await this.initOracleTxb(pythFeederKeys, tx)
|
|
389
|
+
tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx
|
|
373
390
|
}
|
|
374
391
|
const zlpCoinObject = this.processCoins(tx, 'zlp', lpCoinObjects, false)
|
|
375
392
|
const [withdrawObject] = tx.splitCoins(zlpCoinObject, [tx.pure.u64(amount)])
|
|
@@ -599,7 +616,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
599
616
|
fromCoinObjects: string[],
|
|
600
617
|
minAmountOut?: number,
|
|
601
618
|
): Promise<Transaction> {
|
|
602
|
-
const tx = await this.initOracleTxb(Object.keys(this.consts.zoCore.vaults))
|
|
619
|
+
const { tx } = await this.initOracleTxb(Object.keys(this.consts.zoCore.vaults))
|
|
603
620
|
const fromCoinObject = this.processCoins(tx, fromToken, fromCoinObjects)
|
|
604
621
|
const [fromDepositObject] = tx.splitCoins(fromCoinObject, [tx.pure.u64(fromAmount)])
|
|
605
622
|
const vaultsValuation = this.dataAPI.valuateVaults(tx)
|
|
@@ -640,7 +657,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
640
657
|
if (!tx) {
|
|
641
658
|
tx = new Transaction()
|
|
642
659
|
}
|
|
643
|
-
tx = await this.initOracleTxb(Object.keys(this.consts.zoCore.vaults), tx)
|
|
660
|
+
tx = (await this.initOracleTxb(Object.keys(this.consts.zoCore.vaults), tx)).tx
|
|
644
661
|
const fromCoinObject = this.processCoins(tx, fromToken, fromCoinObjects)
|
|
645
662
|
const [fromDepositObject] = tx.splitCoins(fromCoinObject, [
|
|
646
663
|
tx.pure.u64(fromAmount),
|
|
@@ -688,7 +705,6 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
688
705
|
referralAddress?: string,
|
|
689
706
|
sender?: string,
|
|
690
707
|
sponsoredTx?: boolean,
|
|
691
|
-
suiCoinObjectsForPythUpdate?: string[],
|
|
692
708
|
): Promise<Transaction> {
|
|
693
709
|
let tx = new Transaction()
|
|
694
710
|
if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
|
|
@@ -707,11 +723,15 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
707
723
|
// Handle oracle initialization and coin processing
|
|
708
724
|
let suiCoinObject
|
|
709
725
|
if (sponsoredTx) {
|
|
710
|
-
|
|
711
|
-
|
|
726
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
727
|
+
sender: this.requireSenderForSponsored(sender),
|
|
728
|
+
additionalSuiAmount: collateralToken === 'sui' ? collateralAmount + relayerFee : 0n,
|
|
729
|
+
})
|
|
730
|
+
tx = oracle.tx
|
|
731
|
+
suiCoinObject = oracle.suiCoinObject
|
|
712
732
|
}
|
|
713
733
|
else {
|
|
714
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
734
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
715
735
|
}
|
|
716
736
|
|
|
717
737
|
// Process coin splitting
|
|
@@ -775,7 +795,6 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
775
795
|
referralAddress?: string,
|
|
776
796
|
sender?: string,
|
|
777
797
|
sponsoredTx?: boolean,
|
|
778
|
-
suiCoinObjectsForPythUpdate?: string[],
|
|
779
798
|
): Promise<Transaction> {
|
|
780
799
|
let tx = new Transaction()
|
|
781
800
|
if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
|
|
@@ -795,11 +814,15 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
795
814
|
// Handle oracle initialization and coin processing
|
|
796
815
|
let suiCoinObject
|
|
797
816
|
if (sponsoredTx) {
|
|
798
|
-
|
|
799
|
-
|
|
817
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
818
|
+
sender: this.requireSenderForSponsored(sender),
|
|
819
|
+
additionalSuiAmount: collateralToken === 'sui' ? collateralAmount + relayerFee : 0n,
|
|
820
|
+
})
|
|
821
|
+
tx = oracle.tx
|
|
822
|
+
suiCoinObject = oracle.suiCoinObject
|
|
800
823
|
}
|
|
801
824
|
else {
|
|
802
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
825
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
803
826
|
}
|
|
804
827
|
|
|
805
828
|
// Process coin splitting
|
|
@@ -862,7 +885,6 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
862
885
|
sender?: string,
|
|
863
886
|
tx?: Transaction,
|
|
864
887
|
sponsoredTx?: boolean,
|
|
865
|
-
suiCoinObjectsForPythUpdate?: string[],
|
|
866
888
|
): Promise<Transaction> {
|
|
867
889
|
if (!tx) {
|
|
868
890
|
tx = new Transaction()
|
|
@@ -883,11 +905,15 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
883
905
|
// Handle oracle initialization and coin processing
|
|
884
906
|
let suiCoinObject
|
|
885
907
|
if (sponsoredTx) {
|
|
886
|
-
|
|
887
|
-
|
|
908
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
909
|
+
sender: this.requireSenderForSponsored(sender),
|
|
910
|
+
additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
|
|
911
|
+
})
|
|
912
|
+
tx = oracle.tx
|
|
913
|
+
suiCoinObject = oracle.suiCoinObject
|
|
888
914
|
}
|
|
889
915
|
else {
|
|
890
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
916
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
891
917
|
}
|
|
892
918
|
|
|
893
919
|
// Process coin splitting
|
|
@@ -944,7 +970,6 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
944
970
|
sender?: string,
|
|
945
971
|
tx?: Transaction,
|
|
946
972
|
sponsoredTx?: boolean,
|
|
947
|
-
suiCoinObjectsForPythUpdate?: string[],
|
|
948
973
|
): Promise<Transaction> {
|
|
949
974
|
if (!tx) {
|
|
950
975
|
tx = new Transaction()
|
|
@@ -966,11 +991,15 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
966
991
|
// Handle oracle initialization and coin processing
|
|
967
992
|
let suiCoinObject
|
|
968
993
|
if (sponsoredTx) {
|
|
969
|
-
|
|
970
|
-
|
|
994
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
995
|
+
sender: this.requireSenderForSponsored(sender),
|
|
996
|
+
additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
|
|
997
|
+
})
|
|
998
|
+
tx = oracle.tx
|
|
999
|
+
suiCoinObject = oracle.suiCoinObject
|
|
971
1000
|
}
|
|
972
1001
|
else {
|
|
973
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
1002
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
974
1003
|
}
|
|
975
1004
|
|
|
976
1005
|
// Process coin splitting
|
|
@@ -1024,7 +1053,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1024
1053
|
relayerFee = BigInt(0.5),
|
|
1025
1054
|
coinObjects?: string[],
|
|
1026
1055
|
sponsoredTx?: boolean,
|
|
1027
|
-
|
|
1056
|
+
sender?: string,
|
|
1028
1057
|
): Promise<Transaction> {
|
|
1029
1058
|
if (!coinObjects) {
|
|
1030
1059
|
throw new Error(`${this.constructor.name}: coinObjects is required`)
|
|
@@ -1047,11 +1076,15 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1047
1076
|
// Handle oracle initialization and coin processing
|
|
1048
1077
|
let suiCoinObject
|
|
1049
1078
|
if (sponsoredTx) {
|
|
1050
|
-
|
|
1051
|
-
|
|
1079
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
1080
|
+
sender: this.requireSenderForSponsored(sender),
|
|
1081
|
+
additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
|
|
1082
|
+
})
|
|
1083
|
+
tx = oracle.tx
|
|
1084
|
+
suiCoinObject = oracle.suiCoinObject
|
|
1052
1085
|
}
|
|
1053
1086
|
else {
|
|
1054
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
1087
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
1055
1088
|
}
|
|
1056
1089
|
|
|
1057
1090
|
// Process coin splitting
|
|
@@ -1112,7 +1145,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1112
1145
|
relayerFee = BigInt(0.5),
|
|
1113
1146
|
coinObjects?: string[],
|
|
1114
1147
|
sponsoredTx?: boolean,
|
|
1115
|
-
|
|
1148
|
+
sender?: string,
|
|
1116
1149
|
): Promise<Transaction> {
|
|
1117
1150
|
if (!coinObjects) {
|
|
1118
1151
|
throw new Error(`${this.constructor.name}: coinObjects is required`)
|
|
@@ -1135,11 +1168,15 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1135
1168
|
// Handle oracle initialization and coin processing
|
|
1136
1169
|
let suiCoinObject
|
|
1137
1170
|
if (sponsoredTx) {
|
|
1138
|
-
|
|
1139
|
-
|
|
1171
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
1172
|
+
sender: this.requireSenderForSponsored(sender),
|
|
1173
|
+
additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
|
|
1174
|
+
})
|
|
1175
|
+
tx = oracle.tx
|
|
1176
|
+
suiCoinObject = oracle.suiCoinObject
|
|
1140
1177
|
}
|
|
1141
1178
|
else {
|
|
1142
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
1179
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
1143
1180
|
}
|
|
1144
1181
|
|
|
1145
1182
|
// Process coin splitting
|
|
@@ -1195,7 +1232,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1195
1232
|
collateralSlippage?: number
|
|
1196
1233
|
relayerFee?: bigint
|
|
1197
1234
|
coinObjects?: string[]
|
|
1198
|
-
}>, tx?: Transaction, sponsoredTx?: boolean,
|
|
1235
|
+
}>, tx?: Transaction, sponsoredTx?: boolean, sender?: string): Promise<Transaction> {
|
|
1199
1236
|
if (!tx) {
|
|
1200
1237
|
tx = new Transaction()
|
|
1201
1238
|
}
|
|
@@ -1203,11 +1240,20 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1203
1240
|
// Handle oracle initialization and coin processing
|
|
1204
1241
|
let suiCoinObject
|
|
1205
1242
|
if (sponsoredTx) {
|
|
1206
|
-
|
|
1207
|
-
|
|
1243
|
+
const oracle = await this.initOracleTxb(
|
|
1244
|
+
positions.flatMap(position => [position.collateralToken, position.indexToken]),
|
|
1245
|
+
tx,
|
|
1246
|
+
true,
|
|
1247
|
+
{ sender: this.requireSenderForSponsored(sender) },
|
|
1248
|
+
)
|
|
1249
|
+
tx = oracle.tx
|
|
1250
|
+
suiCoinObject = oracle.suiCoinObject
|
|
1208
1251
|
}
|
|
1209
1252
|
else {
|
|
1210
|
-
tx = await this.initOracleTxb(
|
|
1253
|
+
tx = (await this.initOracleTxb(
|
|
1254
|
+
positions.flatMap(position => [position.collateralToken, position.indexToken]),
|
|
1255
|
+
tx,
|
|
1256
|
+
)).tx
|
|
1211
1257
|
}
|
|
1212
1258
|
|
|
1213
1259
|
for (const position of positions) {
|
|
@@ -1295,15 +1341,22 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1295
1341
|
collateralSlippage?: number
|
|
1296
1342
|
relayerFee?: bigint
|
|
1297
1343
|
coinObjects?: string[]
|
|
1298
|
-
}>, tx?: Transaction, sponsoredTx?: boolean,
|
|
1299
|
-
|
|
1344
|
+
}>, tx?: Transaction, sponsoredTx?: boolean, sender?: string, feeObjects?: TransactionObjectArgument[]): Promise<Transaction> {
|
|
1345
|
+
let transaction = tx ?? new Transaction()
|
|
1300
1346
|
|
|
1301
1347
|
// Handle oracle initialization and coin processing
|
|
1302
1348
|
const tokens = positions.flatMap(position => [position.collateralToken, position.indexToken])
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1349
|
+
let suiCoinObject
|
|
1350
|
+
if (sponsoredTx) {
|
|
1351
|
+
const oracle = await this.initOracleTxb(tokens, transaction, true, {
|
|
1352
|
+
sender: this.requireSenderForSponsored(sender),
|
|
1353
|
+
})
|
|
1354
|
+
transaction = oracle.tx
|
|
1355
|
+
suiCoinObject = oracle.suiCoinObject
|
|
1356
|
+
}
|
|
1357
|
+
else {
|
|
1358
|
+
transaction = (await this.initOracleTxb(tokens, transaction, false)).tx
|
|
1359
|
+
}
|
|
1307
1360
|
|
|
1308
1361
|
if (!feeObjects || feeObjects.length !== positions.length) {
|
|
1309
1362
|
throw new Error('feeObjects must be provided (pre-processed via buildFeeCoinObjects) and match positions length')
|
|
@@ -1388,7 +1441,6 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1388
1441
|
referralAddress?: string,
|
|
1389
1442
|
sender?: string,
|
|
1390
1443
|
sponsoredTx?: boolean,
|
|
1391
|
-
suiCoinObjectsForPythUpdate?: string[],
|
|
1392
1444
|
): Promise<Transaction> {
|
|
1393
1445
|
let tx = new Transaction()
|
|
1394
1446
|
if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
|
|
@@ -1418,11 +1470,15 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1418
1470
|
// Handle oracle initialization and coin processing
|
|
1419
1471
|
let suiCoinObject
|
|
1420
1472
|
if (sponsoredTx) {
|
|
1421
|
-
|
|
1422
|
-
|
|
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
|
|
1423
1479
|
}
|
|
1424
1480
|
else {
|
|
1425
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
1481
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
1426
1482
|
}
|
|
1427
1483
|
|
|
1428
1484
|
// Process coin splitting
|
|
@@ -1495,7 +1551,6 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1495
1551
|
referralAddress?: string,
|
|
1496
1552
|
sender?: string,
|
|
1497
1553
|
sponsoredTx?: boolean,
|
|
1498
|
-
suiCoinObjectsForPythUpdate?: string[],
|
|
1499
1554
|
): Promise<Transaction> {
|
|
1500
1555
|
let tx = new Transaction()
|
|
1501
1556
|
if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
|
|
@@ -1526,11 +1581,15 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1526
1581
|
// Handle oracle initialization and coin processing
|
|
1527
1582
|
let suiCoinObject
|
|
1528
1583
|
if (sponsoredTx) {
|
|
1529
|
-
|
|
1530
|
-
|
|
1584
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
1585
|
+
sender: this.requireSenderForSponsored(sender),
|
|
1586
|
+
additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
|
|
1587
|
+
})
|
|
1588
|
+
tx = oracle.tx
|
|
1589
|
+
suiCoinObject = oracle.suiCoinObject
|
|
1531
1590
|
}
|
|
1532
1591
|
else {
|
|
1533
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
1592
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
1534
1593
|
}
|
|
1535
1594
|
|
|
1536
1595
|
// Process coin splitting
|
|
@@ -1602,7 +1661,6 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1602
1661
|
sender?: string,
|
|
1603
1662
|
tx?: Transaction,
|
|
1604
1663
|
sponsoredTx?: boolean,
|
|
1605
|
-
suiCoinObjectsForPythUpdate?: string[],
|
|
1606
1664
|
): Promise<Transaction> {
|
|
1607
1665
|
if (!tx) {
|
|
1608
1666
|
tx = new Transaction()
|
|
@@ -1634,11 +1692,15 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1634
1692
|
// Handle oracle initialization and coin processing
|
|
1635
1693
|
let suiCoinObject
|
|
1636
1694
|
if (sponsoredTx) {
|
|
1637
|
-
|
|
1638
|
-
|
|
1695
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
1696
|
+
sender: this.requireSenderForSponsored(sender),
|
|
1697
|
+
additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
|
|
1698
|
+
})
|
|
1699
|
+
tx = oracle.tx
|
|
1700
|
+
suiCoinObject = oracle.suiCoinObject
|
|
1639
1701
|
}
|
|
1640
1702
|
else {
|
|
1641
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
1703
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
1642
1704
|
}
|
|
1643
1705
|
|
|
1644
1706
|
// Process coin splitting
|
|
@@ -1704,7 +1766,6 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1704
1766
|
sender?: string,
|
|
1705
1767
|
tx?: Transaction,
|
|
1706
1768
|
sponsoredTx?: boolean,
|
|
1707
|
-
suiCoinObjectsForPythUpdate?: string[],
|
|
1708
1769
|
): Promise<Transaction> {
|
|
1709
1770
|
if (!tx) {
|
|
1710
1771
|
tx = new Transaction()
|
|
@@ -1737,11 +1798,15 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1737
1798
|
// Handle oracle initialization and coin processing
|
|
1738
1799
|
let suiCoinObject
|
|
1739
1800
|
if (sponsoredTx) {
|
|
1740
|
-
|
|
1741
|
-
|
|
1801
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
1802
|
+
sender: this.requireSenderForSponsored(sender),
|
|
1803
|
+
additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
|
|
1804
|
+
})
|
|
1805
|
+
tx = oracle.tx
|
|
1806
|
+
suiCoinObject = oracle.suiCoinObject
|
|
1742
1807
|
}
|
|
1743
1808
|
else {
|
|
1744
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
1809
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
1745
1810
|
}
|
|
1746
1811
|
|
|
1747
1812
|
// Process coin splitting
|
|
@@ -1804,7 +1869,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1804
1869
|
relayerFee = BigInt(0.5),
|
|
1805
1870
|
coinObjects?: string[],
|
|
1806
1871
|
sponsoredTx?: boolean,
|
|
1807
|
-
|
|
1872
|
+
sender?: string,
|
|
1808
1873
|
): Promise<Transaction> {
|
|
1809
1874
|
if (!coinObjects) {
|
|
1810
1875
|
throw new Error(`${this.constructor.name}: coinObjects is required`)
|
|
@@ -1839,11 +1904,15 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1839
1904
|
// Handle oracle initialization and coin processing
|
|
1840
1905
|
let suiCoinObject
|
|
1841
1906
|
if (sponsoredTx) {
|
|
1842
|
-
|
|
1843
|
-
|
|
1907
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
1908
|
+
sender: this.requireSenderForSponsored(sender),
|
|
1909
|
+
additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
|
|
1910
|
+
})
|
|
1911
|
+
tx = oracle.tx
|
|
1912
|
+
suiCoinObject = oracle.suiCoinObject
|
|
1844
1913
|
}
|
|
1845
1914
|
else {
|
|
1846
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
1915
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
1847
1916
|
}
|
|
1848
1917
|
|
|
1849
1918
|
// Process coin splitting
|
|
@@ -1912,7 +1981,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1912
1981
|
relayerFee = BigInt(0.5),
|
|
1913
1982
|
coinObjects?: string[],
|
|
1914
1983
|
sponsoredTx?: boolean,
|
|
1915
|
-
|
|
1984
|
+
sender?: string,
|
|
1916
1985
|
): Promise<Transaction> {
|
|
1917
1986
|
if (!coinObjects) {
|
|
1918
1987
|
throw new Error(`${this.constructor.name}: coinObjects is required`)
|
|
@@ -1946,11 +2015,15 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1946
2015
|
// Handle oracle initialization and coin processing
|
|
1947
2016
|
let suiCoinObject
|
|
1948
2017
|
if (sponsoredTx) {
|
|
1949
|
-
|
|
1950
|
-
|
|
2018
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
2019
|
+
sender: this.requireSenderForSponsored(sender),
|
|
2020
|
+
additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
|
|
2021
|
+
})
|
|
2022
|
+
tx = oracle.tx
|
|
2023
|
+
suiCoinObject = oracle.suiCoinObject
|
|
1951
2024
|
}
|
|
1952
2025
|
else {
|
|
1953
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
2026
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
1954
2027
|
}
|
|
1955
2028
|
|
|
1956
2029
|
// Process coin splitting
|
|
@@ -2021,7 +2094,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
2021
2094
|
scard: string,
|
|
2022
2095
|
tx?: Transaction,
|
|
2023
2096
|
sponsoredTx?: boolean,
|
|
2024
|
-
|
|
2097
|
+
sender?: string,
|
|
2025
2098
|
): Promise<Transaction> {
|
|
2026
2099
|
if (!tx) {
|
|
2027
2100
|
tx = new Transaction()
|
|
@@ -2030,11 +2103,20 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
2030
2103
|
// Handle oracle initialization and coin processing
|
|
2031
2104
|
let suiCoinObject
|
|
2032
2105
|
if (sponsoredTx) {
|
|
2033
|
-
|
|
2034
|
-
|
|
2106
|
+
const oracle = await this.initOracleTxb(
|
|
2107
|
+
positions.flatMap(position => [position.collateralToken, position.indexToken]),
|
|
2108
|
+
tx,
|
|
2109
|
+
true,
|
|
2110
|
+
{ sender: this.requireSenderForSponsored(sender) },
|
|
2111
|
+
)
|
|
2112
|
+
tx = oracle.tx
|
|
2113
|
+
suiCoinObject = oracle.suiCoinObject
|
|
2035
2114
|
}
|
|
2036
2115
|
else {
|
|
2037
|
-
tx = await this.initOracleTxb(
|
|
2116
|
+
tx = (await this.initOracleTxb(
|
|
2117
|
+
positions.flatMap(position => [position.collateralToken, position.indexToken]),
|
|
2118
|
+
tx,
|
|
2119
|
+
)).tx
|
|
2038
2120
|
}
|
|
2039
2121
|
|
|
2040
2122
|
const kioskTx = new KioskTransaction({
|
|
@@ -2149,17 +2231,24 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
2149
2231
|
scard: string,
|
|
2150
2232
|
tx?: Transaction,
|
|
2151
2233
|
sponsoredTx?: boolean,
|
|
2152
|
-
|
|
2234
|
+
sender?: string,
|
|
2153
2235
|
feeObjects?: TransactionObjectArgument[],
|
|
2154
2236
|
): Promise<Transaction> {
|
|
2155
|
-
|
|
2237
|
+
let transaction = tx ?? new Transaction()
|
|
2156
2238
|
|
|
2157
2239
|
// Handle oracle initialization and coin processing
|
|
2158
2240
|
const tokens = positions.flatMap(position => [position.collateralToken, position.indexToken])
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2241
|
+
let suiCoinObject
|
|
2242
|
+
if (sponsoredTx) {
|
|
2243
|
+
const oracle = await this.initOracleTxb(tokens, transaction, true, {
|
|
2244
|
+
sender: this.requireSenderForSponsored(sender),
|
|
2245
|
+
})
|
|
2246
|
+
transaction = oracle.tx
|
|
2247
|
+
suiCoinObject = oracle.suiCoinObject
|
|
2248
|
+
}
|
|
2249
|
+
else {
|
|
2250
|
+
transaction = (await this.initOracleTxb(tokens, transaction, false)).tx
|
|
2251
|
+
}
|
|
2163
2252
|
|
|
2164
2253
|
if (!feeObjects || feeObjects.length !== positions.length) {
|
|
2165
2254
|
throw new Error('feeObjects must be provided (pre-processed via buildFeeCoinObjects) and match positions length')
|
|
@@ -2254,17 +2343,21 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
2254
2343
|
coinObjects: string[],
|
|
2255
2344
|
long: boolean,
|
|
2256
2345
|
sponsoredTx?: boolean,
|
|
2257
|
-
|
|
2346
|
+
sender?: string,
|
|
2258
2347
|
): Promise<Transaction> {
|
|
2259
2348
|
let tx = new Transaction()
|
|
2260
2349
|
// Handle oracle initialization and coin processing
|
|
2261
2350
|
let suiCoinObject
|
|
2262
2351
|
if (sponsoredTx) {
|
|
2263
|
-
|
|
2264
|
-
|
|
2352
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
2353
|
+
sender: this.requireSenderForSponsored(sender),
|
|
2354
|
+
additionalSuiAmount: collateralToken === 'sui' ? BigInt(amount) : 0n,
|
|
2355
|
+
})
|
|
2356
|
+
tx = oracle.tx
|
|
2357
|
+
suiCoinObject = oracle.suiCoinObject
|
|
2265
2358
|
}
|
|
2266
2359
|
else {
|
|
2267
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
2360
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
2268
2361
|
}
|
|
2269
2362
|
|
|
2270
2363
|
// Process coin splitting
|
|
@@ -2297,17 +2390,21 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
2297
2390
|
amount: number,
|
|
2298
2391
|
long: boolean,
|
|
2299
2392
|
sponsoredTx?: boolean,
|
|
2300
|
-
|
|
2393
|
+
sender?: string,
|
|
2301
2394
|
): Promise<Transaction> {
|
|
2302
2395
|
let tx = new Transaction()
|
|
2303
2396
|
// Handle oracle initialization and coin processing
|
|
2304
2397
|
let suiCoinObject
|
|
2305
2398
|
if (sponsoredTx) {
|
|
2306
|
-
|
|
2307
|
-
|
|
2399
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
2400
|
+
sender: this.requireSenderForSponsored(sender),
|
|
2401
|
+
additionalSuiAmount: 0n,
|
|
2402
|
+
})
|
|
2403
|
+
tx = oracle.tx
|
|
2404
|
+
suiCoinObject = oracle.suiCoinObject
|
|
2308
2405
|
}
|
|
2309
2406
|
else {
|
|
2310
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
2407
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
2311
2408
|
}
|
|
2312
2409
|
const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
|
|
2313
2410
|
|
|
@@ -2565,7 +2662,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
2565
2662
|
collateralToken: string,
|
|
2566
2663
|
indexToken: string,
|
|
2567
2664
|
): Promise<Transaction> {
|
|
2568
|
-
const tx = await this.initOracleTxb([collateralToken, indexToken])
|
|
2665
|
+
const { tx } = await this.initOracleTxb([collateralToken, indexToken])
|
|
2569
2666
|
return tx
|
|
2570
2667
|
}
|
|
2571
2668
|
|