@zofai/zo-sdk 0.2.9 → 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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.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/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 +12 -12
- package/src/coins.ts +115 -0
- package/src/implementations/SLPAPI.ts +199 -115
- package/src/implementations/SLPDataAPI.ts +2 -2
- package/src/implementations/USDZAPI.ts +184 -94
- package/src/implementations/ZBTCVCAPI.ts +98 -52
- package/src/implementations/ZLPAPI.ts +199 -110
- 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
|
|
@@ -1064,7 +1097,6 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1064
1097
|
suiCoinObject,
|
|
1065
1098
|
)
|
|
1066
1099
|
|
|
1067
|
-
|
|
1068
1100
|
tx.moveCall({
|
|
1069
1101
|
target: `${this.consts.zoCore.upgradedPackage}::market::decrease_position`,
|
|
1070
1102
|
typeArguments: [
|
|
@@ -1113,7 +1145,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1113
1145
|
relayerFee = BigInt(0.5),
|
|
1114
1146
|
coinObjects?: string[],
|
|
1115
1147
|
sponsoredTx?: boolean,
|
|
1116
|
-
|
|
1148
|
+
sender?: string,
|
|
1117
1149
|
): Promise<Transaction> {
|
|
1118
1150
|
if (!coinObjects) {
|
|
1119
1151
|
throw new Error(`${this.constructor.name}: coinObjects is required`)
|
|
@@ -1136,11 +1168,15 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1136
1168
|
// Handle oracle initialization and coin processing
|
|
1137
1169
|
let suiCoinObject
|
|
1138
1170
|
if (sponsoredTx) {
|
|
1139
|
-
|
|
1140
|
-
|
|
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
|
|
1141
1177
|
}
|
|
1142
1178
|
else {
|
|
1143
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
1179
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
1144
1180
|
}
|
|
1145
1181
|
|
|
1146
1182
|
// Process coin splitting
|
|
@@ -1153,7 +1189,6 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1153
1189
|
suiCoinObject,
|
|
1154
1190
|
)
|
|
1155
1191
|
|
|
1156
|
-
|
|
1157
1192
|
tx.moveCall({
|
|
1158
1193
|
target: `${this.consts.zoCore.upgradedPackage}::market::decrease_position_v2`,
|
|
1159
1194
|
typeArguments: [
|
|
@@ -1197,7 +1232,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1197
1232
|
collateralSlippage?: number
|
|
1198
1233
|
relayerFee?: bigint
|
|
1199
1234
|
coinObjects?: string[]
|
|
1200
|
-
}>, tx?: Transaction, sponsoredTx?: boolean,
|
|
1235
|
+
}>, tx?: Transaction, sponsoredTx?: boolean, sender?: string): Promise<Transaction> {
|
|
1201
1236
|
if (!tx) {
|
|
1202
1237
|
tx = new Transaction()
|
|
1203
1238
|
}
|
|
@@ -1205,11 +1240,20 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1205
1240
|
// Handle oracle initialization and coin processing
|
|
1206
1241
|
let suiCoinObject
|
|
1207
1242
|
if (sponsoredTx) {
|
|
1208
|
-
|
|
1209
|
-
|
|
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
|
|
1210
1251
|
}
|
|
1211
1252
|
else {
|
|
1212
|
-
tx = await this.initOracleTxb(
|
|
1253
|
+
tx = (await this.initOracleTxb(
|
|
1254
|
+
positions.flatMap(position => [position.collateralToken, position.indexToken]),
|
|
1255
|
+
tx,
|
|
1256
|
+
)).tx
|
|
1213
1257
|
}
|
|
1214
1258
|
|
|
1215
1259
|
for (const position of positions) {
|
|
@@ -1253,7 +1297,6 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1253
1297
|
suiCoinObject,
|
|
1254
1298
|
)
|
|
1255
1299
|
|
|
1256
|
-
|
|
1257
1300
|
tx.moveCall({
|
|
1258
1301
|
target: `${this.consts.zoCore.upgradedPackage}::market::decrease_position`,
|
|
1259
1302
|
typeArguments: [
|
|
@@ -1298,15 +1341,22 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1298
1341
|
collateralSlippage?: number
|
|
1299
1342
|
relayerFee?: bigint
|
|
1300
1343
|
coinObjects?: string[]
|
|
1301
|
-
}>, tx?: Transaction, sponsoredTx?: boolean,
|
|
1302
|
-
|
|
1344
|
+
}>, tx?: Transaction, sponsoredTx?: boolean, sender?: string, feeObjects?: TransactionObjectArgument[]): Promise<Transaction> {
|
|
1345
|
+
let transaction = tx ?? new Transaction()
|
|
1303
1346
|
|
|
1304
1347
|
// Handle oracle initialization and coin processing
|
|
1305
1348
|
const tokens = positions.flatMap(position => [position.collateralToken, position.indexToken])
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
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
|
+
}
|
|
1310
1360
|
|
|
1311
1361
|
if (!feeObjects || feeObjects.length !== positions.length) {
|
|
1312
1362
|
throw new Error('feeObjects must be provided (pre-processed via buildFeeCoinObjects) and match positions length')
|
|
@@ -1342,7 +1392,6 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1342
1392
|
innerIsTakeProfitOrder = true
|
|
1343
1393
|
}
|
|
1344
1394
|
|
|
1345
|
-
|
|
1346
1395
|
transaction.moveCall({
|
|
1347
1396
|
target: `${this.consts.zoCore.upgradedPackage}::market::decrease_position_v2`,
|
|
1348
1397
|
typeArguments: [
|
|
@@ -1392,7 +1441,6 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1392
1441
|
referralAddress?: string,
|
|
1393
1442
|
sender?: string,
|
|
1394
1443
|
sponsoredTx?: boolean,
|
|
1395
|
-
suiCoinObjectsForPythUpdate?: string[],
|
|
1396
1444
|
): Promise<Transaction> {
|
|
1397
1445
|
let tx = new Transaction()
|
|
1398
1446
|
if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
|
|
@@ -1422,11 +1470,15 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1422
1470
|
// Handle oracle initialization and coin processing
|
|
1423
1471
|
let suiCoinObject
|
|
1424
1472
|
if (sponsoredTx) {
|
|
1425
|
-
|
|
1426
|
-
|
|
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
|
|
1427
1479
|
}
|
|
1428
1480
|
else {
|
|
1429
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
1481
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
1430
1482
|
}
|
|
1431
1483
|
|
|
1432
1484
|
// Process coin splitting
|
|
@@ -1499,7 +1551,6 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1499
1551
|
referralAddress?: string,
|
|
1500
1552
|
sender?: string,
|
|
1501
1553
|
sponsoredTx?: boolean,
|
|
1502
|
-
suiCoinObjectsForPythUpdate?: string[],
|
|
1503
1554
|
): Promise<Transaction> {
|
|
1504
1555
|
let tx = new Transaction()
|
|
1505
1556
|
if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
|
|
@@ -1530,11 +1581,15 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1530
1581
|
// Handle oracle initialization and coin processing
|
|
1531
1582
|
let suiCoinObject
|
|
1532
1583
|
if (sponsoredTx) {
|
|
1533
|
-
|
|
1534
|
-
|
|
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
|
|
1535
1590
|
}
|
|
1536
1591
|
else {
|
|
1537
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
1592
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
1538
1593
|
}
|
|
1539
1594
|
|
|
1540
1595
|
// Process coin splitting
|
|
@@ -1606,7 +1661,6 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1606
1661
|
sender?: string,
|
|
1607
1662
|
tx?: Transaction,
|
|
1608
1663
|
sponsoredTx?: boolean,
|
|
1609
|
-
suiCoinObjectsForPythUpdate?: string[],
|
|
1610
1664
|
): Promise<Transaction> {
|
|
1611
1665
|
if (!tx) {
|
|
1612
1666
|
tx = new Transaction()
|
|
@@ -1638,11 +1692,15 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1638
1692
|
// Handle oracle initialization and coin processing
|
|
1639
1693
|
let suiCoinObject
|
|
1640
1694
|
if (sponsoredTx) {
|
|
1641
|
-
|
|
1642
|
-
|
|
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
|
|
1643
1701
|
}
|
|
1644
1702
|
else {
|
|
1645
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
1703
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
1646
1704
|
}
|
|
1647
1705
|
|
|
1648
1706
|
// Process coin splitting
|
|
@@ -1708,7 +1766,6 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1708
1766
|
sender?: string,
|
|
1709
1767
|
tx?: Transaction,
|
|
1710
1768
|
sponsoredTx?: boolean,
|
|
1711
|
-
suiCoinObjectsForPythUpdate?: string[],
|
|
1712
1769
|
): Promise<Transaction> {
|
|
1713
1770
|
if (!tx) {
|
|
1714
1771
|
tx = new Transaction()
|
|
@@ -1741,11 +1798,15 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1741
1798
|
// Handle oracle initialization and coin processing
|
|
1742
1799
|
let suiCoinObject
|
|
1743
1800
|
if (sponsoredTx) {
|
|
1744
|
-
|
|
1745
|
-
|
|
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
|
|
1746
1807
|
}
|
|
1747
1808
|
else {
|
|
1748
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
1809
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
1749
1810
|
}
|
|
1750
1811
|
|
|
1751
1812
|
// Process coin splitting
|
|
@@ -1808,7 +1869,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1808
1869
|
relayerFee = BigInt(0.5),
|
|
1809
1870
|
coinObjects?: string[],
|
|
1810
1871
|
sponsoredTx?: boolean,
|
|
1811
|
-
|
|
1872
|
+
sender?: string,
|
|
1812
1873
|
): Promise<Transaction> {
|
|
1813
1874
|
if (!coinObjects) {
|
|
1814
1875
|
throw new Error(`${this.constructor.name}: coinObjects is required`)
|
|
@@ -1843,11 +1904,15 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1843
1904
|
// Handle oracle initialization and coin processing
|
|
1844
1905
|
let suiCoinObject
|
|
1845
1906
|
if (sponsoredTx) {
|
|
1846
|
-
|
|
1847
|
-
|
|
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
|
|
1848
1913
|
}
|
|
1849
1914
|
else {
|
|
1850
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
1915
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
1851
1916
|
}
|
|
1852
1917
|
|
|
1853
1918
|
// Process coin splitting
|
|
@@ -1860,7 +1925,6 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1860
1925
|
suiCoinObject,
|
|
1861
1926
|
)
|
|
1862
1927
|
|
|
1863
|
-
|
|
1864
1928
|
tx.moveCall({
|
|
1865
1929
|
target: `${this.consts.zoCore.upgradedPackage}::market::decrease_position_with_scard`,
|
|
1866
1930
|
typeArguments: [
|
|
@@ -1917,7 +1981,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1917
1981
|
relayerFee = BigInt(0.5),
|
|
1918
1982
|
coinObjects?: string[],
|
|
1919
1983
|
sponsoredTx?: boolean,
|
|
1920
|
-
|
|
1984
|
+
sender?: string,
|
|
1921
1985
|
): Promise<Transaction> {
|
|
1922
1986
|
if (!coinObjects) {
|
|
1923
1987
|
throw new Error(`${this.constructor.name}: coinObjects is required`)
|
|
@@ -1951,11 +2015,15 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1951
2015
|
// Handle oracle initialization and coin processing
|
|
1952
2016
|
let suiCoinObject
|
|
1953
2017
|
if (sponsoredTx) {
|
|
1954
|
-
|
|
1955
|
-
|
|
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
|
|
1956
2024
|
}
|
|
1957
2025
|
else {
|
|
1958
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
2026
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
1959
2027
|
}
|
|
1960
2028
|
|
|
1961
2029
|
// Process coin splitting
|
|
@@ -1968,7 +2036,6 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
1968
2036
|
suiCoinObject,
|
|
1969
2037
|
)
|
|
1970
2038
|
|
|
1971
|
-
|
|
1972
2039
|
tx.moveCall({
|
|
1973
2040
|
target: `${this.consts.zoCore.upgradedPackage}::market::decrease_position_with_scard_v2`,
|
|
1974
2041
|
typeArguments: [
|
|
@@ -2027,7 +2094,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
2027
2094
|
scard: string,
|
|
2028
2095
|
tx?: Transaction,
|
|
2029
2096
|
sponsoredTx?: boolean,
|
|
2030
|
-
|
|
2097
|
+
sender?: string,
|
|
2031
2098
|
): Promise<Transaction> {
|
|
2032
2099
|
if (!tx) {
|
|
2033
2100
|
tx = new Transaction()
|
|
@@ -2036,11 +2103,20 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
2036
2103
|
// Handle oracle initialization and coin processing
|
|
2037
2104
|
let suiCoinObject
|
|
2038
2105
|
if (sponsoredTx) {
|
|
2039
|
-
|
|
2040
|
-
|
|
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
|
|
2041
2114
|
}
|
|
2042
2115
|
else {
|
|
2043
|
-
tx = await this.initOracleTxb(
|
|
2116
|
+
tx = (await this.initOracleTxb(
|
|
2117
|
+
positions.flatMap(position => [position.collateralToken, position.indexToken]),
|
|
2118
|
+
tx,
|
|
2119
|
+
)).tx
|
|
2044
2120
|
}
|
|
2045
2121
|
|
|
2046
2122
|
const kioskTx = new KioskTransaction({
|
|
@@ -2095,7 +2171,6 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
2095
2171
|
suiCoinObject,
|
|
2096
2172
|
)
|
|
2097
2173
|
|
|
2098
|
-
|
|
2099
2174
|
tx.moveCall({
|
|
2100
2175
|
target: `${this.consts.zoCore.upgradedPackage}::market::decrease_position_with_scard`,
|
|
2101
2176
|
typeArguments: [
|
|
@@ -2156,17 +2231,24 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
2156
2231
|
scard: string,
|
|
2157
2232
|
tx?: Transaction,
|
|
2158
2233
|
sponsoredTx?: boolean,
|
|
2159
|
-
|
|
2234
|
+
sender?: string,
|
|
2160
2235
|
feeObjects?: TransactionObjectArgument[],
|
|
2161
2236
|
): Promise<Transaction> {
|
|
2162
|
-
|
|
2237
|
+
let transaction = tx ?? new Transaction()
|
|
2163
2238
|
|
|
2164
2239
|
// Handle oracle initialization and coin processing
|
|
2165
2240
|
const tokens = positions.flatMap(position => [position.collateralToken, position.indexToken])
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
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
|
+
}
|
|
2170
2252
|
|
|
2171
2253
|
if (!feeObjects || feeObjects.length !== positions.length) {
|
|
2172
2254
|
throw new Error('feeObjects must be provided (pre-processed via buildFeeCoinObjects) and match positions length')
|
|
@@ -2213,7 +2295,6 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
2213
2295
|
innerIsTakeProfitOrder = true
|
|
2214
2296
|
}
|
|
2215
2297
|
|
|
2216
|
-
|
|
2217
2298
|
transaction.moveCall({
|
|
2218
2299
|
target: `${this.consts.zoCore.upgradedPackage}::market::decrease_position_with_scard_v2`,
|
|
2219
2300
|
typeArguments: [
|
|
@@ -2262,17 +2343,21 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
2262
2343
|
coinObjects: string[],
|
|
2263
2344
|
long: boolean,
|
|
2264
2345
|
sponsoredTx?: boolean,
|
|
2265
|
-
|
|
2346
|
+
sender?: string,
|
|
2266
2347
|
): Promise<Transaction> {
|
|
2267
2348
|
let tx = new Transaction()
|
|
2268
2349
|
// Handle oracle initialization and coin processing
|
|
2269
2350
|
let suiCoinObject
|
|
2270
2351
|
if (sponsoredTx) {
|
|
2271
|
-
|
|
2272
|
-
|
|
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
|
|
2273
2358
|
}
|
|
2274
2359
|
else {
|
|
2275
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
2360
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
2276
2361
|
}
|
|
2277
2362
|
|
|
2278
2363
|
// Process coin splitting
|
|
@@ -2305,17 +2390,21 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
2305
2390
|
amount: number,
|
|
2306
2391
|
long: boolean,
|
|
2307
2392
|
sponsoredTx?: boolean,
|
|
2308
|
-
|
|
2393
|
+
sender?: string,
|
|
2309
2394
|
): Promise<Transaction> {
|
|
2310
2395
|
let tx = new Transaction()
|
|
2311
2396
|
// Handle oracle initialization and coin processing
|
|
2312
2397
|
let suiCoinObject
|
|
2313
2398
|
if (sponsoredTx) {
|
|
2314
|
-
|
|
2315
|
-
|
|
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
|
|
2316
2405
|
}
|
|
2317
2406
|
else {
|
|
2318
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
2407
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
2319
2408
|
}
|
|
2320
2409
|
const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
|
|
2321
2410
|
|
|
@@ -2573,7 +2662,7 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
2573
2662
|
collateralToken: string,
|
|
2574
2663
|
indexToken: string,
|
|
2575
2664
|
): Promise<Transaction> {
|
|
2576
|
-
const tx = await this.initOracleTxb([collateralToken, indexToken])
|
|
2665
|
+
const { tx } = await this.initOracleTxb([collateralToken, indexToken])
|
|
2577
2666
|
return tx
|
|
2578
2667
|
}
|
|
2579
2668
|
|