@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
|
@@ -105,7 +105,6 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
|
|
|
105
105
|
referralAddress?: string,
|
|
106
106
|
sender?: string,
|
|
107
107
|
sponsoredTx?: boolean,
|
|
108
|
-
suiCoinObjectsForPythUpdate?: string[],
|
|
109
108
|
): Promise<Transaction> {
|
|
110
109
|
let tx = new Transaction()
|
|
111
110
|
if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
|
|
@@ -135,11 +134,15 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
|
|
|
135
134
|
// Handle oracle initialization and coin processing
|
|
136
135
|
let suiCoinObject
|
|
137
136
|
if (sponsoredTx) {
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
138
|
+
sender: this.requireSenderForSponsored(sender),
|
|
139
|
+
additionalSuiAmount: collateralToken === 'sui' ? collateralAmount + relayerFee : 0n,
|
|
140
|
+
})
|
|
141
|
+
tx = oracle.tx
|
|
142
|
+
suiCoinObject = oracle.suiCoinObject
|
|
140
143
|
}
|
|
141
144
|
else {
|
|
142
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
145
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
143
146
|
}
|
|
144
147
|
|
|
145
148
|
// Process coin splitting
|
|
@@ -209,7 +212,7 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
|
|
|
209
212
|
relayerFee = BigInt(0.5),
|
|
210
213
|
coinObjects?: string[],
|
|
211
214
|
sponsoredTx?: boolean,
|
|
212
|
-
|
|
215
|
+
sender?: string,
|
|
213
216
|
): Promise<Transaction> {
|
|
214
217
|
if (!coinObjects) {
|
|
215
218
|
throw new Error(`${this.constructor.name}: coinObjects is required`)
|
|
@@ -244,11 +247,15 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
|
|
|
244
247
|
// Handle oracle initialization and coin processing
|
|
245
248
|
let suiCoinObject
|
|
246
249
|
if (sponsoredTx) {
|
|
247
|
-
|
|
248
|
-
|
|
250
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
251
|
+
sender: this.requireSenderForSponsored(sender),
|
|
252
|
+
additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
|
|
253
|
+
})
|
|
254
|
+
tx = oracle.tx
|
|
255
|
+
suiCoinObject = oracle.suiCoinObject
|
|
249
256
|
}
|
|
250
257
|
else {
|
|
251
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
258
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
252
259
|
}
|
|
253
260
|
|
|
254
261
|
// Process coin splitting
|
|
@@ -320,7 +327,7 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
|
|
|
320
327
|
scard: string,
|
|
321
328
|
tx?: Transaction,
|
|
322
329
|
sponsoredTx?: boolean,
|
|
323
|
-
|
|
330
|
+
sender?: string,
|
|
324
331
|
): Promise<Transaction> {
|
|
325
332
|
if (!tx) {
|
|
326
333
|
tx = new Transaction()
|
|
@@ -329,11 +336,20 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
|
|
|
329
336
|
// Handle oracle initialization and coin processing
|
|
330
337
|
let suiCoinObject
|
|
331
338
|
if (sponsoredTx) {
|
|
332
|
-
|
|
333
|
-
|
|
339
|
+
const oracle = await this.initOracleTxb(
|
|
340
|
+
positions.flatMap(position => [position.collateralToken, position.indexToken]),
|
|
341
|
+
tx,
|
|
342
|
+
true,
|
|
343
|
+
{ sender: this.requireSenderForSponsored(sender) },
|
|
344
|
+
)
|
|
345
|
+
tx = oracle.tx
|
|
346
|
+
suiCoinObject = oracle.suiCoinObject
|
|
334
347
|
}
|
|
335
348
|
else {
|
|
336
|
-
tx = await this.initOracleTxb(
|
|
349
|
+
tx = (await this.initOracleTxb(
|
|
350
|
+
positions.flatMap(position => [position.collateralToken, position.indexToken]),
|
|
351
|
+
tx,
|
|
352
|
+
)).tx
|
|
337
353
|
}
|
|
338
354
|
|
|
339
355
|
const kioskTx = new KioskTransaction({
|
|
@@ -437,7 +453,6 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
|
|
|
437
453
|
referralAddress?: string,
|
|
438
454
|
sender?: string,
|
|
439
455
|
sponsoredTx?: boolean,
|
|
440
|
-
suiCoinObjectsForPythUpdate?: string[],
|
|
441
456
|
): Promise<Transaction> {
|
|
442
457
|
let tx = new Transaction()
|
|
443
458
|
|
|
@@ -451,12 +466,16 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
|
|
|
451
466
|
|
|
452
467
|
// Handle sponsored transaction case
|
|
453
468
|
if (sponsoredTx) {
|
|
454
|
-
const
|
|
455
|
-
|
|
469
|
+
const oracle = await this.initOracleTxb(pythFeederKeys, tx, true, {
|
|
470
|
+
sender: this.requireSenderForSponsored(sender),
|
|
471
|
+
additionalSuiAmount: coin === 'sui' ? BigInt(amount) : 0n,
|
|
472
|
+
})
|
|
473
|
+
tx = oracle.tx
|
|
474
|
+
const { suiCoinObject } = oracle
|
|
456
475
|
|
|
457
476
|
// Process deposit coins
|
|
458
477
|
const depositObject = coin === 'sui'
|
|
459
|
-
? tx.splitCoins(suiCoinObject
|
|
478
|
+
? tx.splitCoins(suiCoinObject!, [tx.pure.u64(amount)])[0]
|
|
460
479
|
: tx.splitCoins(this.processCoins(tx, coin, coinObjects, true), [tx.pure.u64(amount)])[0]
|
|
461
480
|
|
|
462
481
|
const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
|
|
@@ -477,7 +496,7 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
|
|
|
477
496
|
}
|
|
478
497
|
|
|
479
498
|
// Handle non-sponsored transaction case
|
|
480
|
-
tx = await this.initOracleTxb(pythFeederKeys, tx)
|
|
499
|
+
tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx
|
|
481
500
|
const depositObject = tx.splitCoins(
|
|
482
501
|
this.processCoins(tx, coin, coinObjects, false),
|
|
483
502
|
[tx.pure.u64(amount)],
|
|
@@ -515,7 +534,6 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
|
|
|
515
534
|
sender?: string,
|
|
516
535
|
tx?: Transaction,
|
|
517
536
|
sponsoredTx?: boolean,
|
|
518
|
-
suiCoinObjectsForPythUpdate?: string[],
|
|
519
537
|
): Promise<any> {
|
|
520
538
|
if (!tx) {
|
|
521
539
|
tx = new Transaction()
|
|
@@ -531,12 +549,16 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
|
|
|
531
549
|
|
|
532
550
|
// Handle sponsored transaction case
|
|
533
551
|
if (sponsoredTx) {
|
|
534
|
-
const
|
|
535
|
-
|
|
552
|
+
const oracle = await this.initOracleTxb(pythFeederKeys, tx, true, {
|
|
553
|
+
sender: this.requireSenderForSponsored(sender),
|
|
554
|
+
additionalSuiAmount: coin === 'sui' ? BigInt(amount) : 0n,
|
|
555
|
+
})
|
|
556
|
+
tx = oracle.tx
|
|
557
|
+
const { suiCoinObject } = oracle
|
|
536
558
|
|
|
537
559
|
// Process deposit coins
|
|
538
560
|
const depositObject = coin === 'sui'
|
|
539
|
-
? tx.splitCoins(suiCoinObject
|
|
561
|
+
? tx.splitCoins(suiCoinObject!, [tx.pure.u64(amount)])[0]
|
|
540
562
|
: tx.splitCoins(this.processCoins(tx, coin, coinObjects, true), [tx.pure.u64(amount)])[0]
|
|
541
563
|
|
|
542
564
|
const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx)
|
|
@@ -557,7 +579,7 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
|
|
|
557
579
|
}
|
|
558
580
|
|
|
559
581
|
// Handle non-sponsored transaction case
|
|
560
|
-
tx = await this.initOracleTxb(pythFeederKeys, tx)
|
|
582
|
+
tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx
|
|
561
583
|
const depositObject = tx.splitCoins(
|
|
562
584
|
this.processCoins(tx, coin, coinObjects, false),
|
|
563
585
|
[tx.pure.u64(amount)],
|
|
@@ -593,7 +615,7 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
|
|
|
593
615
|
amount: number,
|
|
594
616
|
minAmountOut = 0,
|
|
595
617
|
sponsoredTx?: boolean,
|
|
596
|
-
|
|
618
|
+
sender?: string,
|
|
597
619
|
): Promise<Transaction> {
|
|
598
620
|
let tx = new Transaction()
|
|
599
621
|
|
|
@@ -601,11 +623,15 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
|
|
|
601
623
|
const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder)
|
|
602
624
|
|
|
603
625
|
if (sponsoredTx) {
|
|
604
|
-
const
|
|
605
|
-
|
|
626
|
+
const oracle = await this.initOracleTxb(pythFeederKeys, tx, true, {
|
|
627
|
+
sender: this.requireSenderForSponsored(sender),
|
|
628
|
+
additionalSuiAmount: 0n,
|
|
629
|
+
})
|
|
630
|
+
tx = oracle.tx
|
|
631
|
+
const { suiCoinObject } = oracle
|
|
606
632
|
}
|
|
607
633
|
else {
|
|
608
|
-
tx = await this.initOracleTxb(pythFeederKeys, tx)
|
|
634
|
+
tx = (await this.initOracleTxb(pythFeederKeys, tx)).tx
|
|
609
635
|
}
|
|
610
636
|
const zbtcvcCoinObject = this.processCoins(tx, 'zbtcvc', lpCoinObjects, false)
|
|
611
637
|
const [withdrawObject] = tx.splitCoins(zbtcvcCoinObject, [tx.pure.u64(amount)])
|
|
@@ -740,7 +766,7 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
|
|
|
740
766
|
fromCoinObjects: string[],
|
|
741
767
|
minAmountOut?: number,
|
|
742
768
|
): Promise<Transaction> {
|
|
743
|
-
const tx = await this.initOracleTxb(Object.keys(this.consts.zoCore.vaults))
|
|
769
|
+
const { tx } = await this.initOracleTxb(Object.keys(this.consts.zoCore.vaults))
|
|
744
770
|
const fromCoinObject = this.processCoins(tx, fromToken, fromCoinObjects)
|
|
745
771
|
const [fromDepositObject] = tx.splitCoins(fromCoinObject, [tx.pure.u64(fromAmount)])
|
|
746
772
|
const vaultsValuation = this.dataAPI.valuateVaults(tx)
|
|
@@ -784,7 +810,6 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
|
|
|
784
810
|
referralAddress?: string,
|
|
785
811
|
sender?: string,
|
|
786
812
|
sponsoredTx?: boolean,
|
|
787
|
-
suiCoinObjectsForPythUpdate?: string[],
|
|
788
813
|
): Promise<Transaction> {
|
|
789
814
|
let tx = new Transaction()
|
|
790
815
|
if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
|
|
@@ -803,11 +828,15 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
|
|
|
803
828
|
// Handle oracle initialization and coin processing
|
|
804
829
|
let suiCoinObject
|
|
805
830
|
if (sponsoredTx) {
|
|
806
|
-
|
|
807
|
-
|
|
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
|
|
808
837
|
}
|
|
809
838
|
else {
|
|
810
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
839
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
811
840
|
}
|
|
812
841
|
|
|
813
842
|
// Process coin splitting
|
|
@@ -868,7 +897,7 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
|
|
|
868
897
|
relayerFee = BigInt(0.5),
|
|
869
898
|
coinObjects?: string[],
|
|
870
899
|
sponsoredTx?: boolean,
|
|
871
|
-
|
|
900
|
+
sender?: string,
|
|
872
901
|
): Promise<Transaction> {
|
|
873
902
|
if (!coinObjects) {
|
|
874
903
|
throw new Error(`${this.constructor.name}: coinObjects is required`)
|
|
@@ -890,11 +919,15 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
|
|
|
890
919
|
// Handle oracle initialization and coin processing
|
|
891
920
|
let suiCoinObject
|
|
892
921
|
if (sponsoredTx) {
|
|
893
|
-
|
|
894
|
-
|
|
922
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
923
|
+
sender: this.requireSenderForSponsored(sender),
|
|
924
|
+
additionalSuiAmount: collateralToken === 'sui' ? relayerFee : 0n,
|
|
925
|
+
})
|
|
926
|
+
tx = oracle.tx
|
|
927
|
+
suiCoinObject = oracle.suiCoinObject
|
|
895
928
|
}
|
|
896
929
|
else {
|
|
897
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
930
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
898
931
|
}
|
|
899
932
|
|
|
900
933
|
// Process coin splitting
|
|
@@ -951,7 +984,7 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
|
|
|
951
984
|
collateralSlippage?: number
|
|
952
985
|
relayerFee?: bigint
|
|
953
986
|
coinObjects?: string[]
|
|
954
|
-
}>, tx?: Transaction, sponsoredTx?: boolean,
|
|
987
|
+
}>, tx?: Transaction, sponsoredTx?: boolean, sender?: string): Promise<Transaction> {
|
|
955
988
|
if (!tx) {
|
|
956
989
|
tx = new Transaction()
|
|
957
990
|
}
|
|
@@ -959,11 +992,20 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
|
|
|
959
992
|
// Handle oracle initialization and coin processing
|
|
960
993
|
let suiCoinObject
|
|
961
994
|
if (sponsoredTx) {
|
|
962
|
-
|
|
963
|
-
|
|
995
|
+
const oracle = await this.initOracleTxb(
|
|
996
|
+
positions.flatMap(position => [position.collateralToken, position.indexToken]),
|
|
997
|
+
tx,
|
|
998
|
+
true,
|
|
999
|
+
{ sender: this.requireSenderForSponsored(sender) },
|
|
1000
|
+
)
|
|
1001
|
+
tx = oracle.tx
|
|
1002
|
+
suiCoinObject = oracle.suiCoinObject
|
|
964
1003
|
}
|
|
965
1004
|
else {
|
|
966
|
-
tx = await this.initOracleTxb(
|
|
1005
|
+
tx = (await this.initOracleTxb(
|
|
1006
|
+
positions.flatMap(position => [position.collateralToken, position.indexToken]),
|
|
1007
|
+
tx,
|
|
1008
|
+
)).tx
|
|
967
1009
|
}
|
|
968
1010
|
|
|
969
1011
|
for (const position of positions) {
|
|
@@ -1047,17 +1089,21 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
|
|
|
1047
1089
|
coinObjects: string[],
|
|
1048
1090
|
long: boolean,
|
|
1049
1091
|
sponsoredTx?: boolean,
|
|
1050
|
-
|
|
1092
|
+
sender?: string,
|
|
1051
1093
|
): Promise<Transaction> {
|
|
1052
1094
|
let tx = new Transaction()
|
|
1053
1095
|
// Handle oracle initialization and coin processing
|
|
1054
1096
|
let suiCoinObject
|
|
1055
1097
|
if (sponsoredTx) {
|
|
1056
|
-
|
|
1057
|
-
|
|
1098
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
1099
|
+
sender: this.requireSenderForSponsored(sender),
|
|
1100
|
+
additionalSuiAmount: collateralToken === 'sui' ? BigInt(amount) : 0n,
|
|
1101
|
+
})
|
|
1102
|
+
tx = oracle.tx
|
|
1103
|
+
suiCoinObject = oracle.suiCoinObject
|
|
1058
1104
|
}
|
|
1059
1105
|
else {
|
|
1060
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
1106
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
1061
1107
|
}
|
|
1062
1108
|
|
|
1063
1109
|
// Process coin splitting
|
|
@@ -1090,17 +1136,21 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
|
|
|
1090
1136
|
amount: number,
|
|
1091
1137
|
long: boolean,
|
|
1092
1138
|
sponsoredTx?: boolean,
|
|
1093
|
-
|
|
1139
|
+
sender?: string,
|
|
1094
1140
|
): Promise<Transaction> {
|
|
1095
1141
|
let tx = new Transaction()
|
|
1096
1142
|
// Handle oracle initialization and coin processing
|
|
1097
1143
|
let suiCoinObject
|
|
1098
1144
|
if (sponsoredTx) {
|
|
1099
|
-
|
|
1100
|
-
|
|
1145
|
+
const oracle = await this.initOracleTxb([collateralToken, indexToken], tx, true, {
|
|
1146
|
+
sender: this.requireSenderForSponsored(sender),
|
|
1147
|
+
additionalSuiAmount: 0n,
|
|
1148
|
+
})
|
|
1149
|
+
tx = oracle.tx
|
|
1150
|
+
suiCoinObject = oracle.suiCoinObject
|
|
1101
1151
|
}
|
|
1102
1152
|
else {
|
|
1103
|
-
tx = await this.initOracleTxb([collateralToken, indexToken], tx)
|
|
1153
|
+
tx = (await this.initOracleTxb([collateralToken, indexToken], tx)).tx
|
|
1104
1154
|
}
|
|
1105
1155
|
const symbol = joinSymbol(long ? 'long' : 'short', indexToken)
|
|
1106
1156
|
|
|
@@ -1235,7 +1285,7 @@ export class ZBTCVCAPI extends BaseAPI implements IZBTCVCAPI {
|
|
|
1235
1285
|
collateralToken: string,
|
|
1236
1286
|
indexToken: string,
|
|
1237
1287
|
): Promise<Transaction> {
|
|
1238
|
-
const tx = await this.initOracleTxb([collateralToken, indexToken])
|
|
1288
|
+
const { tx } = await this.initOracleTxb([collateralToken, indexToken])
|
|
1239
1289
|
return tx
|
|
1240
1290
|
}
|
|
1241
1291
|
|