@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 SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
53
53
|
referralAddress?: string,
|
|
54
54
|
sender?: string,
|
|
55
55
|
sponsoredTx?: boolean,
|
|
56
|
-
suiCoinObjectsForPythUpdate?: string[],
|
|
57
56
|
): Promise<Transaction> {
|
|
58
57
|
let tx = new Transaction()
|
|
59
58
|
|
|
@@ -67,12 +66,16 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
67
66
|
|
|
68
67
|
// Handle sponsored transaction case
|
|
69
68
|
if (sponsoredTx) {
|
|
70
|
-
const
|
|
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)
|
|
@@ -96,7 +99,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
96
99
|
}
|
|
97
100
|
|
|
98
101
|
// Handle non-sponsored transaction case
|
|
99
|
-
tx = await this.initOracleTxb(pythFeederKeys, tx)
|
|
102
|
+
tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx
|
|
100
103
|
const depositObject = tx.splitCoins(
|
|
101
104
|
this.processCoins(tx, coin, coinObjects, false),
|
|
102
105
|
[tx.pure.u64(amount)],
|
|
@@ -134,7 +137,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
134
137
|
sender?: string,
|
|
135
138
|
tx?: Transaction,
|
|
136
139
|
sponsoredTx?: boolean,
|
|
137
|
-
suiCoinObjectsForPythUpdate?: string[],
|
|
138
140
|
): Promise<TransactionObjectArgument> {
|
|
139
141
|
if (!tx) {
|
|
140
142
|
tx = new Transaction()
|
|
@@ -150,12 +152,16 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
150
152
|
|
|
151
153
|
// Handle sponsored transaction case
|
|
152
154
|
if (sponsoredTx) {
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
+
const oracle = await this.initOracleTxb(pythFeederKeys, tx, true, {
|
|
156
|
+
sender: this.requireSenderForSponsored(sender),
|
|
157
|
+
additionalSuiAmount: coin === 'sui' ? BigInt(amount) : 0n,
|
|
158
|
+
})
|
|
159
|
+
tx = oracle.tx
|
|
160
|
+
const { suiCoinObject } = oracle
|
|
155
161
|
|
|
156
162
|
// Process deposit coins
|
|
157
163
|
const depositObject = coin === 'sui'
|
|
158
|
-
? tx.splitCoins(suiCoinObject
|
|
164
|
+
? tx.splitCoins(suiCoinObject!, [tx.pure.u64(amount)])[0]
|
|
159
165
|
: tx.splitCoins(this.processCoins(tx, coin, coinObjects, true), [tx.pure.u64(amount)])[0]
|
|
160
166
|
|
|
161
167
|
const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
|
|
@@ -176,7 +182,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
176
182
|
}
|
|
177
183
|
|
|
178
184
|
// Handle non-sponsored transaction case
|
|
179
|
-
tx = await this.initOracleTxb(pythFeederKeys, tx)
|
|
185
|
+
tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx
|
|
180
186
|
const depositObject = tx.splitCoins(
|
|
181
187
|
this.processCoins(tx, coin, coinObjects, false),
|
|
182
188
|
[tx.pure.u64(amount)],
|
|
@@ -214,7 +220,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
214
220
|
sender?: string,
|
|
215
221
|
tx?: Transaction,
|
|
216
222
|
sponsoredTx?: boolean,
|
|
217
|
-
suiCoinObjectsForPythUpdate?: string[],
|
|
218
223
|
): Promise<Transaction> {
|
|
219
224
|
if (!tx) {
|
|
220
225
|
tx = new Transaction()
|
|
@@ -230,8 +235,12 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
230
235
|
|
|
231
236
|
// Handle sponsored transaction case
|
|
232
237
|
if (sponsoredTx) {
|
|
233
|
-
const
|
|
234
|
-
|
|
238
|
+
const oracle = await this.initOracleTxb(pythFeederKeys, tx, true, {
|
|
239
|
+
sender: this.requireSenderForSponsored(sender),
|
|
240
|
+
additionalSuiAmount: 0n,
|
|
241
|
+
})
|
|
242
|
+
tx = oracle.tx
|
|
243
|
+
const { suiCoinObject } = oracle
|
|
235
244
|
|
|
236
245
|
const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
|
|
237
246
|
|
|
@@ -254,7 +263,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
254
263
|
}
|
|
255
264
|
|
|
256
265
|
// Handle non-sponsored transaction case
|
|
257
|
-
tx = await this.initOracleTxb(pythFeederKeys, tx)
|
|
266
|
+
tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx
|
|
258
267
|
|
|
259
268
|
const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
|
|
260
269
|
|
|
@@ -285,7 +294,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
285
294
|
amount: number,
|
|
286
295
|
minAmountOut = 0,
|
|
287
296
|
sponsoredTx?: boolean,
|
|
288
|
-
|
|
297
|
+
sender?: string,
|
|
289
298
|
): Promise<Transaction> {
|
|
290
299
|
let tx = new Transaction()
|
|
291
300
|
|
|
@@ -293,11 +302,15 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
293
302
|
const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder)
|
|
294
303
|
|
|
295
304
|
if (sponsoredTx) {
|
|
296
|
-
const
|
|
297
|
-
|
|
305
|
+
const oracle = await this.initOracleTxb(pythFeederKeys, tx, true, {
|
|
306
|
+
sender: this.requireSenderForSponsored(sender),
|
|
307
|
+
additionalSuiAmount: 0n,
|
|
308
|
+
})
|
|
309
|
+
tx = oracle.tx
|
|
310
|
+
const { suiCoinObject } = oracle
|
|
298
311
|
}
|
|
299
312
|
else {
|
|
300
|
-
tx = await this.initOracleTxb(pythFeederKeys, tx)
|
|
313
|
+
tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx
|
|
301
314
|
}
|
|
302
315
|
|
|
303
316
|
const slpCoinObject = this.processCoins(tx, 'slp', lpCoinObjects, false)
|
|
@@ -338,7 +351,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
338
351
|
// Initialize oracle transaction
|
|
339
352
|
const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder)
|
|
340
353
|
|
|
341
|
-
tx = await this.initOracleTxb(pythFeederKeys, tx)
|
|
354
|
+
tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx
|
|
342
355
|
const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
|
|
343
356
|
|
|
344
357
|
tx.moveCall({
|
|
@@ -366,7 +379,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
366
379
|
minAmountOut = 0,
|
|
367
380
|
tx?: Transaction,
|
|
368
381
|
sponsoredTx?: boolean,
|
|
369
|
-
|
|
382
|
+
sender?: string,
|
|
370
383
|
): Promise<TransactionObjectArgument> {
|
|
371
384
|
if (!tx) {
|
|
372
385
|
tx = new Transaction()
|
|
@@ -376,11 +389,15 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
376
389
|
const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder)
|
|
377
390
|
|
|
378
391
|
if (sponsoredTx) {
|
|
379
|
-
const
|
|
380
|
-
|
|
392
|
+
const oracle = await this.initOracleTxb(pythFeederKeys, tx, true, {
|
|
393
|
+
sender: this.requireSenderForSponsored(sender),
|
|
394
|
+
additionalSuiAmount: 0n,
|
|
395
|
+
})
|
|
396
|
+
tx = oracle.tx
|
|
397
|
+
const { suiCoinObject } = oracle
|
|
381
398
|
}
|
|
382
399
|
else {
|
|
383
|
-
tx = await this.initOracleTxb(pythFeederKeys, tx)
|
|
400
|
+
tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx
|
|
384
401
|
}
|
|
385
402
|
|
|
386
403
|
const slpCoinObject = this.processCoins(tx, 'slp', lpCoinObjects, false)
|
|
@@ -412,9 +429,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
412
429
|
fromCoinObjects: string[],
|
|
413
430
|
minAmountOut?: number,
|
|
414
431
|
): Promise<Transaction> {
|
|
415
|
-
const tx = await this.initOracleTxb(
|
|
416
|
-
Object.keys(this.consts.sudoCore.vaults),
|
|
417
|
-
)
|
|
432
|
+
const { tx } = await this.initOracleTxb(Object.keys(this.consts.sudoCore.vaults))
|
|
418
433
|
const fromCoinObject = this.processCoins(tx, fromToken, fromCoinObjects)
|
|
419
434
|
const [fromDepositObject] = tx.splitCoins(fromCoinObject, [
|
|
420
435
|
tx.pure.u64(fromAmount),
|
|
@@ -457,10 +472,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
457
472
|
if (!tx) {
|
|
458
473
|
tx = new Transaction()
|
|
459
474
|
}
|
|
460
|
-
tx = await this.initOracleTxb(
|
|
461
|
-
Object.keys(this.consts.sudoCore.vaults),
|
|
462
|
-
tx,
|
|
463
|
-
)
|
|
475
|
+
tx = (await this.initOracleTxb(Object.keys(this.consts.sudoCore.vaults), tx)).tx
|
|
464
476
|
const fromCoinObject = this.processCoins(tx, fromToken, fromCoinObjects)
|
|
465
477
|
const [fromDepositObject] = tx.splitCoins(fromCoinObject, [
|
|
466
478
|
tx.pure.u64(fromAmount),
|
|
@@ -707,7 +719,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
707
719
|
referralAddress?: string,
|
|
708
720
|
sender?: string,
|
|
709
721
|
sponsoredTx?: boolean,
|
|
710
|
-
suiCoinObjectsForPythUpdate?: string[],
|
|
711
722
|
): Promise<Transaction> {
|
|
712
723
|
let tx = new Transaction()
|
|
713
724
|
if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
|
|
@@ -725,11 +736,15 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
725
736
|
// Handle oracle initialization and coin processing
|
|
726
737
|
let suiCoinObject
|
|
727
738
|
if (sponsoredTx) {
|
|
728
|
-
|
|
729
|
-
|
|
739
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
740
|
+
sender: this.requireSenderForSponsored(sender),
|
|
741
|
+
additionalSuiAmount: collateralToken === 'sui' ? collateralAmount + relayerFee : 0n,
|
|
742
|
+
})
|
|
743
|
+
tx = oracle.tx
|
|
744
|
+
suiCoinObject = oracle.suiCoinObject
|
|
730
745
|
}
|
|
731
746
|
else {
|
|
732
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
747
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
733
748
|
}
|
|
734
749
|
|
|
735
750
|
// Process coin splitting
|
|
@@ -794,7 +809,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
794
809
|
sender?: string,
|
|
795
810
|
tx?: Transaction,
|
|
796
811
|
sponsoredTx?: boolean,
|
|
797
|
-
suiCoinObjectsForPythUpdate?: string[],
|
|
798
812
|
): Promise<Transaction> {
|
|
799
813
|
if (!tx) {
|
|
800
814
|
tx = new Transaction()
|
|
@@ -814,11 +828,15 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
814
828
|
// Handle oracle initialization and coin processing
|
|
815
829
|
let suiCoinObject
|
|
816
830
|
if (sponsoredTx) {
|
|
817
|
-
|
|
818
|
-
|
|
831
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
832
|
+
sender: this.requireSenderForSponsored(sender),
|
|
833
|
+
additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
|
|
834
|
+
})
|
|
835
|
+
tx = oracle.tx
|
|
836
|
+
suiCoinObject = oracle.suiCoinObject
|
|
819
837
|
}
|
|
820
838
|
else {
|
|
821
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
839
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
822
840
|
}
|
|
823
841
|
|
|
824
842
|
// Process coin splitting
|
|
@@ -876,7 +894,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
876
894
|
referralAddress?: string,
|
|
877
895
|
sender?: string,
|
|
878
896
|
sponsoredTx?: boolean,
|
|
879
|
-
suiCoinObjectsForPythUpdate?: string[],
|
|
880
897
|
): Promise<Transaction> {
|
|
881
898
|
let tx = new Transaction()
|
|
882
899
|
if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
|
|
@@ -896,11 +913,15 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
896
913
|
// Handle oracle initialization and coin processing
|
|
897
914
|
let suiCoinObject
|
|
898
915
|
if (sponsoredTx) {
|
|
899
|
-
|
|
900
|
-
|
|
916
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
917
|
+
sender: this.requireSenderForSponsored(sender),
|
|
918
|
+
additionalSuiAmount: collateralToken === 'sui' ? collateralAmount + relayerFee : 0n,
|
|
919
|
+
})
|
|
920
|
+
tx = oracle.tx
|
|
921
|
+
suiCoinObject = oracle.suiCoinObject
|
|
901
922
|
}
|
|
902
923
|
else {
|
|
903
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
924
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
904
925
|
}
|
|
905
926
|
|
|
906
927
|
// Process coin splitting
|
|
@@ -963,7 +984,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
963
984
|
sender?: string,
|
|
964
985
|
tx?: Transaction,
|
|
965
986
|
sponsoredTx?: boolean,
|
|
966
|
-
suiCoinObjectsForPythUpdate?: string[],
|
|
967
987
|
): Promise<Transaction> {
|
|
968
988
|
if (!tx) {
|
|
969
989
|
tx = new Transaction()
|
|
@@ -985,11 +1005,15 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
985
1005
|
// Handle oracle initialization and coin processing
|
|
986
1006
|
let suiCoinObject
|
|
987
1007
|
if (sponsoredTx) {
|
|
988
|
-
|
|
989
|
-
|
|
1008
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
1009
|
+
sender: this.requireSenderForSponsored(sender),
|
|
1010
|
+
additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
|
|
1011
|
+
})
|
|
1012
|
+
tx = oracle.tx
|
|
1013
|
+
suiCoinObject = oracle.suiCoinObject
|
|
990
1014
|
}
|
|
991
1015
|
else {
|
|
992
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
1016
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
993
1017
|
}
|
|
994
1018
|
|
|
995
1019
|
// Process coin splitting
|
|
@@ -1043,7 +1067,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
1043
1067
|
relayerFee = BigInt(0.5),
|
|
1044
1068
|
coinObjects?: string[],
|
|
1045
1069
|
sponsoredTx?: boolean,
|
|
1046
|
-
|
|
1070
|
+
sender?: string,
|
|
1047
1071
|
): Promise<Transaction> {
|
|
1048
1072
|
if (!coinObjects) {
|
|
1049
1073
|
throw new Error(`${this.constructor.name}: coinObjects is required`)
|
|
@@ -1069,11 +1093,15 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
1069
1093
|
|
|
1070
1094
|
let suiCoinObject
|
|
1071
1095
|
if (sponsoredTx) {
|
|
1072
|
-
|
|
1073
|
-
|
|
1096
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
1097
|
+
sender: this.requireSenderForSponsored(sender),
|
|
1098
|
+
additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
|
|
1099
|
+
})
|
|
1100
|
+
tx = oracle.tx
|
|
1101
|
+
suiCoinObject = oracle.suiCoinObject
|
|
1074
1102
|
}
|
|
1075
1103
|
else {
|
|
1076
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
1104
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
1077
1105
|
}
|
|
1078
1106
|
|
|
1079
1107
|
// Handle oracle initialization and coin processing
|
|
@@ -1086,7 +1114,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
1086
1114
|
suiCoinObject,
|
|
1087
1115
|
)
|
|
1088
1116
|
|
|
1089
|
-
|
|
1090
1117
|
tx.moveCall({
|
|
1091
1118
|
target: `${this.consts.sudoCore.upgradedPackage}::market::decrease_position_v2_1`,
|
|
1092
1119
|
typeArguments: [
|
|
@@ -1137,7 +1164,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
1137
1164
|
relayerFee = BigInt(0.5),
|
|
1138
1165
|
coinObjects?: string[],
|
|
1139
1166
|
sponsoredTx?: boolean,
|
|
1140
|
-
|
|
1167
|
+
sender?: string,
|
|
1141
1168
|
): Promise<Transaction> {
|
|
1142
1169
|
if (!coinObjects) {
|
|
1143
1170
|
throw new Error(`${this.constructor.name}: coinObjects is required`)
|
|
@@ -1160,11 +1187,15 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
1160
1187
|
// Handle oracle initialization and coin processing
|
|
1161
1188
|
let suiCoinObject
|
|
1162
1189
|
if (sponsoredTx) {
|
|
1163
|
-
|
|
1164
|
-
|
|
1190
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
1191
|
+
sender: this.requireSenderForSponsored(sender),
|
|
1192
|
+
additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
|
|
1193
|
+
})
|
|
1194
|
+
tx = oracle.tx
|
|
1195
|
+
suiCoinObject = oracle.suiCoinObject
|
|
1165
1196
|
}
|
|
1166
1197
|
else {
|
|
1167
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
1198
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
1168
1199
|
}
|
|
1169
1200
|
|
|
1170
1201
|
// Process coin splitting
|
|
@@ -1177,7 +1208,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
1177
1208
|
suiCoinObject,
|
|
1178
1209
|
)
|
|
1179
1210
|
|
|
1180
|
-
|
|
1181
1211
|
tx.moveCall({
|
|
1182
1212
|
target: `${this.consts.sudoCore.upgradedPackage}::market::decrease_position_v3`,
|
|
1183
1213
|
typeArguments: [
|
|
@@ -1225,7 +1255,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
1225
1255
|
}>,
|
|
1226
1256
|
tx?: Transaction,
|
|
1227
1257
|
sponsoredTx?: boolean,
|
|
1228
|
-
|
|
1258
|
+
sender?: string,
|
|
1229
1259
|
): Promise<Transaction> {
|
|
1230
1260
|
if (!tx) {
|
|
1231
1261
|
tx = new Transaction()
|
|
@@ -1234,11 +1264,20 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
1234
1264
|
// Handle oracle initialization and coin processing
|
|
1235
1265
|
let suiCoinObject
|
|
1236
1266
|
if (sponsoredTx) {
|
|
1237
|
-
|
|
1238
|
-
|
|
1267
|
+
const oracle = await this.initOracleTxb(
|
|
1268
|
+
positions.flatMap(position => [position.collateralToken, position.indexToken]),
|
|
1269
|
+
tx,
|
|
1270
|
+
true,
|
|
1271
|
+
{ sender: this.requireSenderForSponsored(sender) },
|
|
1272
|
+
)
|
|
1273
|
+
tx = oracle.tx
|
|
1274
|
+
suiCoinObject = oracle.suiCoinObject
|
|
1239
1275
|
}
|
|
1240
1276
|
else {
|
|
1241
|
-
tx = await this.initOracleTxb(
|
|
1277
|
+
tx = (await this.initOracleTxb(
|
|
1278
|
+
positions.flatMap(position => [position.collateralToken, position.indexToken]),
|
|
1279
|
+
tx,
|
|
1280
|
+
)).tx
|
|
1242
1281
|
}
|
|
1243
1282
|
|
|
1244
1283
|
for (const position of positions) {
|
|
@@ -1282,7 +1321,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
1282
1321
|
suiCoinObject,
|
|
1283
1322
|
)
|
|
1284
1323
|
|
|
1285
|
-
|
|
1286
1324
|
tx.moveCall({
|
|
1287
1325
|
target: `${this.consts.sudoCore.upgradedPackage}::market::decrease_position_v2_1`,
|
|
1288
1326
|
typeArguments: [
|
|
@@ -1329,15 +1367,22 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
1329
1367
|
collateralSlippage?: number
|
|
1330
1368
|
relayerFee?: bigint
|
|
1331
1369
|
coinObjects?: string[]
|
|
1332
|
-
}>, tx?: Transaction, sponsoredTx?: boolean,
|
|
1333
|
-
|
|
1370
|
+
}>, tx?: Transaction, sponsoredTx?: boolean, sender?: string, feeObjects?: TransactionObjectArgument[]): Promise<Transaction> {
|
|
1371
|
+
let transaction = tx ?? new Transaction()
|
|
1334
1372
|
|
|
1335
1373
|
// Handle oracle initialization and coin processing
|
|
1336
1374
|
const tokens = positions.flatMap(position => [position.collateralToken, position.indexToken])
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1375
|
+
let suiCoinObject
|
|
1376
|
+
if (sponsoredTx) {
|
|
1377
|
+
const oracle = await this.initOracleTxb(tokens, transaction, true, {
|
|
1378
|
+
sender: this.requireSenderForSponsored(sender),
|
|
1379
|
+
})
|
|
1380
|
+
transaction = oracle.tx
|
|
1381
|
+
suiCoinObject = oracle.suiCoinObject
|
|
1382
|
+
}
|
|
1383
|
+
else {
|
|
1384
|
+
transaction = (await this.initOracleTxb(tokens, transaction, false)).tx
|
|
1385
|
+
}
|
|
1341
1386
|
|
|
1342
1387
|
if (!feeObjects || feeObjects.length !== positions.length) {
|
|
1343
1388
|
throw new Error('feeObjects must be provided (pre-processed via buildFeeCoinObjects) and match positions length')
|
|
@@ -1373,7 +1418,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
1373
1418
|
innerIsTakeProfitOrder = true
|
|
1374
1419
|
}
|
|
1375
1420
|
|
|
1376
|
-
|
|
1377
1421
|
transaction.moveCall({
|
|
1378
1422
|
target: `${this.consts.sudoCore.upgradedPackage}::market::decrease_position_v3`,
|
|
1379
1423
|
typeArguments: [
|
|
@@ -1410,18 +1454,22 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
1410
1454
|
coinObjects: string[],
|
|
1411
1455
|
long: boolean,
|
|
1412
1456
|
sponsoredTx?: boolean,
|
|
1413
|
-
|
|
1457
|
+
sender?: string,
|
|
1414
1458
|
): Promise<Transaction> {
|
|
1415
1459
|
let tx = new Transaction()
|
|
1416
1460
|
|
|
1417
1461
|
// Handle oracle initialization and coin processing
|
|
1418
1462
|
let suiCoinObject
|
|
1419
1463
|
if (sponsoredTx) {
|
|
1420
|
-
|
|
1421
|
-
|
|
1464
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
1465
|
+
sender: this.requireSenderForSponsored(sender),
|
|
1466
|
+
additionalSuiAmount: collateralToken === 'sui' ? BigInt(amount) : 0n,
|
|
1467
|
+
})
|
|
1468
|
+
tx = oracle.tx
|
|
1469
|
+
suiCoinObject = oracle.suiCoinObject
|
|
1422
1470
|
}
|
|
1423
1471
|
else {
|
|
1424
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
1472
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
1425
1473
|
}
|
|
1426
1474
|
|
|
1427
1475
|
// Process coin splitting
|
|
@@ -1458,17 +1506,21 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
1458
1506
|
amount: number,
|
|
1459
1507
|
long: boolean,
|
|
1460
1508
|
sponsoredTx?: boolean,
|
|
1461
|
-
|
|
1509
|
+
sender?: string,
|
|
1462
1510
|
): Promise<Transaction> {
|
|
1463
1511
|
let tx = new Transaction()
|
|
1464
1512
|
// Handle oracle initialization and coin processing
|
|
1465
1513
|
let suiCoinObject
|
|
1466
1514
|
if (sponsoredTx) {
|
|
1467
|
-
|
|
1468
|
-
|
|
1515
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
1516
|
+
sender: this.requireSenderForSponsored(sender),
|
|
1517
|
+
additionalSuiAmount: 0n,
|
|
1518
|
+
})
|
|
1519
|
+
tx = oracle.tx
|
|
1520
|
+
suiCoinObject = oracle.suiCoinObject
|
|
1469
1521
|
}
|
|
1470
1522
|
else {
|
|
1471
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
1523
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
1472
1524
|
}
|
|
1473
1525
|
const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
|
|
1474
1526
|
|
|
@@ -1732,7 +1784,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
1732
1784
|
referralAddress?: string,
|
|
1733
1785
|
sender?: string,
|
|
1734
1786
|
sponsoredTx?: boolean,
|
|
1735
|
-
suiCoinObjectsForPythUpdate?: string[],
|
|
1736
1787
|
): Promise<Transaction> {
|
|
1737
1788
|
let tx = new Transaction()
|
|
1738
1789
|
if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
|
|
@@ -1762,11 +1813,15 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
1762
1813
|
// Handle oracle initialization and coin processing
|
|
1763
1814
|
let suiCoinObject
|
|
1764
1815
|
if (sponsoredTx) {
|
|
1765
|
-
|
|
1766
|
-
|
|
1816
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
1817
|
+
sender: this.requireSenderForSponsored(sender),
|
|
1818
|
+
additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
|
|
1819
|
+
})
|
|
1820
|
+
tx = oracle.tx
|
|
1821
|
+
suiCoinObject = oracle.suiCoinObject
|
|
1767
1822
|
}
|
|
1768
1823
|
else {
|
|
1769
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
1824
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
1770
1825
|
}
|
|
1771
1826
|
|
|
1772
1827
|
// Process coin splitting
|
|
@@ -1840,7 +1895,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
1840
1895
|
sender?: string,
|
|
1841
1896
|
tx?: Transaction,
|
|
1842
1897
|
sponsoredTx?: boolean,
|
|
1843
|
-
suiCoinObjectsForPythUpdate?: string[],
|
|
1844
1898
|
): Promise<Transaction> {
|
|
1845
1899
|
if (!tx) {
|
|
1846
1900
|
tx = new Transaction()
|
|
@@ -1872,11 +1926,15 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
1872
1926
|
// Handle oracle initialization and coin processing
|
|
1873
1927
|
let suiCoinObject
|
|
1874
1928
|
if (sponsoredTx) {
|
|
1875
|
-
|
|
1876
|
-
|
|
1929
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
1930
|
+
sender: this.requireSenderForSponsored(sender),
|
|
1931
|
+
additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
|
|
1932
|
+
})
|
|
1933
|
+
tx = oracle.tx
|
|
1934
|
+
suiCoinObject = oracle.suiCoinObject
|
|
1877
1935
|
}
|
|
1878
1936
|
else {
|
|
1879
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
1937
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
1880
1938
|
}
|
|
1881
1939
|
|
|
1882
1940
|
// Process coin splitting
|
|
@@ -1943,7 +2001,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
1943
2001
|
referralAddress?: string,
|
|
1944
2002
|
sender?: string,
|
|
1945
2003
|
sponsoredTx?: boolean,
|
|
1946
|
-
suiCoinObjectsForPythUpdate?: string[],
|
|
1947
2004
|
): Promise<Transaction> {
|
|
1948
2005
|
let tx = new Transaction()
|
|
1949
2006
|
if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
|
|
@@ -1974,11 +2031,15 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
1974
2031
|
// Handle oracle initialization and coin processing
|
|
1975
2032
|
let suiCoinObject
|
|
1976
2033
|
if (sponsoredTx) {
|
|
1977
|
-
|
|
1978
|
-
|
|
2034
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
2035
|
+
sender: this.requireSenderForSponsored(sender),
|
|
2036
|
+
additionalSuiAmount: collateralToken === 'sui' ? collateralAmount + relayerFee : 0n,
|
|
2037
|
+
})
|
|
2038
|
+
tx = oracle.tx
|
|
2039
|
+
suiCoinObject = oracle.suiCoinObject
|
|
1979
2040
|
}
|
|
1980
2041
|
else {
|
|
1981
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
2042
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
1982
2043
|
}
|
|
1983
2044
|
|
|
1984
2045
|
// Process coin splitting
|
|
@@ -2051,7 +2112,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
2051
2112
|
sender?: string,
|
|
2052
2113
|
tx?: Transaction,
|
|
2053
2114
|
sponsoredTx?: boolean,
|
|
2054
|
-
suiCoinObjectsForPythUpdate?: string[],
|
|
2055
2115
|
): Promise<Transaction> {
|
|
2056
2116
|
if (!tx) {
|
|
2057
2117
|
tx = new Transaction()
|
|
@@ -2084,11 +2144,15 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
2084
2144
|
// Handle oracle initialization and coin processing
|
|
2085
2145
|
let suiCoinObject
|
|
2086
2146
|
if (sponsoredTx) {
|
|
2087
|
-
|
|
2088
|
-
|
|
2147
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
2148
|
+
sender: this.requireSenderForSponsored(sender),
|
|
2149
|
+
additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
|
|
2150
|
+
})
|
|
2151
|
+
tx = oracle.tx
|
|
2152
|
+
suiCoinObject = oracle.suiCoinObject
|
|
2089
2153
|
}
|
|
2090
2154
|
else {
|
|
2091
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
2155
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
2092
2156
|
}
|
|
2093
2157
|
|
|
2094
2158
|
// Process coin splitting
|
|
@@ -2151,7 +2215,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
2151
2215
|
relayerFee = BigInt(0.5),
|
|
2152
2216
|
coinObjects?: string[],
|
|
2153
2217
|
sponsoredTx?: boolean,
|
|
2154
|
-
|
|
2218
|
+
sender?: string,
|
|
2155
2219
|
): Promise<Transaction> {
|
|
2156
2220
|
if (!coinObjects) {
|
|
2157
2221
|
throw new Error(`${this.constructor.name}: coinObjects is required`)
|
|
@@ -2189,11 +2253,15 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
2189
2253
|
// Handle oracle initialization and coin processing
|
|
2190
2254
|
let suiCoinObject
|
|
2191
2255
|
if (sponsoredTx) {
|
|
2192
|
-
|
|
2193
|
-
|
|
2256
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
2257
|
+
sender: this.requireSenderForSponsored(sender),
|
|
2258
|
+
additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
|
|
2259
|
+
})
|
|
2260
|
+
tx = oracle.tx
|
|
2261
|
+
suiCoinObject = oracle.suiCoinObject
|
|
2194
2262
|
}
|
|
2195
2263
|
else {
|
|
2196
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
2264
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
2197
2265
|
}
|
|
2198
2266
|
|
|
2199
2267
|
// Process coin splitting
|
|
@@ -2206,7 +2274,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
2206
2274
|
suiCoinObject,
|
|
2207
2275
|
)
|
|
2208
2276
|
|
|
2209
|
-
|
|
2210
2277
|
tx.moveCall({
|
|
2211
2278
|
target: `${this.consts.sudoCore.upgradedPackage}::market::decrease_position_with_scard_v1`,
|
|
2212
2279
|
typeArguments: [
|
|
@@ -2265,7 +2332,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
2265
2332
|
relayerFee = BigInt(0.5),
|
|
2266
2333
|
coinObjects?: string[],
|
|
2267
2334
|
sponsoredTx?: boolean,
|
|
2268
|
-
|
|
2335
|
+
sender?: string,
|
|
2269
2336
|
): Promise<Transaction> {
|
|
2270
2337
|
if (!coinObjects) {
|
|
2271
2338
|
throw new Error(`${this.constructor.name}: coinObjects is required`)
|
|
@@ -2299,11 +2366,15 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
2299
2366
|
// Handle oracle initialization and coin processing
|
|
2300
2367
|
let suiCoinObject
|
|
2301
2368
|
if (sponsoredTx) {
|
|
2302
|
-
|
|
2303
|
-
|
|
2369
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
2370
|
+
sender: this.requireSenderForSponsored(sender),
|
|
2371
|
+
additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
|
|
2372
|
+
})
|
|
2373
|
+
tx = oracle.tx
|
|
2374
|
+
suiCoinObject = oracle.suiCoinObject
|
|
2304
2375
|
}
|
|
2305
2376
|
else {
|
|
2306
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
2377
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
2307
2378
|
}
|
|
2308
2379
|
|
|
2309
2380
|
// Process coin splitting
|
|
@@ -2316,7 +2387,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
2316
2387
|
suiCoinObject,
|
|
2317
2388
|
)
|
|
2318
2389
|
|
|
2319
|
-
|
|
2320
2390
|
tx.moveCall({
|
|
2321
2391
|
target: `${this.consts.sudoCore.upgradedPackage}::market::decrease_position_with_scard_v2`,
|
|
2322
2392
|
typeArguments: [
|
|
@@ -2375,7 +2445,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
2375
2445
|
scard: string,
|
|
2376
2446
|
tx?: Transaction,
|
|
2377
2447
|
sponsoredTx?: boolean,
|
|
2378
|
-
|
|
2448
|
+
sender?: string,
|
|
2379
2449
|
): Promise<Transaction> {
|
|
2380
2450
|
if (!tx) {
|
|
2381
2451
|
tx = new Transaction()
|
|
@@ -2384,11 +2454,20 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
2384
2454
|
// Handle oracle initialization and coin processing
|
|
2385
2455
|
let suiCoinObject
|
|
2386
2456
|
if (sponsoredTx) {
|
|
2387
|
-
|
|
2388
|
-
|
|
2457
|
+
const oracle = await this.initOracleTxb(
|
|
2458
|
+
positions.flatMap(position => [position.collateralToken, position.indexToken]),
|
|
2459
|
+
tx,
|
|
2460
|
+
true,
|
|
2461
|
+
{ sender: this.requireSenderForSponsored(sender) },
|
|
2462
|
+
)
|
|
2463
|
+
tx = oracle.tx
|
|
2464
|
+
suiCoinObject = oracle.suiCoinObject
|
|
2389
2465
|
}
|
|
2390
2466
|
else {
|
|
2391
|
-
tx = await this.initOracleTxb(
|
|
2467
|
+
tx = (await this.initOracleTxb(
|
|
2468
|
+
positions.flatMap(position => [position.collateralToken, position.indexToken]),
|
|
2469
|
+
tx,
|
|
2470
|
+
)).tx
|
|
2392
2471
|
}
|
|
2393
2472
|
|
|
2394
2473
|
const kioskTx = new KioskTransaction({
|
|
@@ -2443,7 +2522,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
2443
2522
|
suiCoinObject,
|
|
2444
2523
|
)
|
|
2445
2524
|
|
|
2446
|
-
|
|
2447
2525
|
tx.moveCall({
|
|
2448
2526
|
target: `${this.consts.sudoCore.upgradedPackage}::market::decrease_position_with_scard_v1`,
|
|
2449
2527
|
typeArguments: [
|
|
@@ -2506,17 +2584,24 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
2506
2584
|
scard: string,
|
|
2507
2585
|
tx?: Transaction,
|
|
2508
2586
|
sponsoredTx?: boolean,
|
|
2509
|
-
|
|
2587
|
+
sender?: string,
|
|
2510
2588
|
feeObjects?: TransactionObjectArgument[],
|
|
2511
2589
|
): Promise<Transaction> {
|
|
2512
|
-
|
|
2590
|
+
let transaction = tx ?? new Transaction()
|
|
2513
2591
|
|
|
2514
2592
|
// Handle oracle initialization and coin processing
|
|
2515
2593
|
const tokens = positions.flatMap(position => [position.collateralToken, position.indexToken])
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2594
|
+
let suiCoinObject
|
|
2595
|
+
if (sponsoredTx) {
|
|
2596
|
+
const oracle = await this.initOracleTxb(tokens, transaction, true, {
|
|
2597
|
+
sender: this.requireSenderForSponsored(sender),
|
|
2598
|
+
})
|
|
2599
|
+
transaction = oracle.tx
|
|
2600
|
+
suiCoinObject = oracle.suiCoinObject
|
|
2601
|
+
}
|
|
2602
|
+
else {
|
|
2603
|
+
transaction = (await this.initOracleTxb(tokens, transaction, false)).tx
|
|
2604
|
+
}
|
|
2520
2605
|
|
|
2521
2606
|
if (!feeObjects || feeObjects.length !== positions.length) {
|
|
2522
2607
|
throw new Error('feeObjects must be provided (pre-processed via buildFeeCoinObjects) and match positions length')
|
|
@@ -2563,7 +2648,6 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
2563
2648
|
innerIsTakeProfitOrder = true
|
|
2564
2649
|
}
|
|
2565
2650
|
|
|
2566
|
-
|
|
2567
2651
|
transaction.moveCall({
|
|
2568
2652
|
target: `${this.consts.sudoCore.upgradedPackage}::market::decrease_position_with_scard_v2`,
|
|
2569
2653
|
typeArguments: [
|
|
@@ -2621,7 +2705,7 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
2621
2705
|
collateralToken: string,
|
|
2622
2706
|
indexToken: string,
|
|
2623
2707
|
): Promise<Transaction> {
|
|
2624
|
-
const tx = await this.initOracleTxb([collateralToken, indexToken])
|
|
2708
|
+
const { tx } = await this.initOracleTxb([collateralToken, indexToken])
|
|
2625
2709
|
return tx
|
|
2626
2710
|
}
|
|
2627
2711
|
|