zo-sdk 0.1.55 → 0.1.57
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 -0
- package/dist/abstract/BaseAPI.cjs.map +1 -1
- package/dist/abstract/BaseAPI.d.cts +4 -0
- package/dist/abstract/BaseAPI.d.cts.map +1 -1
- package/dist/abstract/BaseAPI.d.mts +4 -0
- package/dist/abstract/BaseAPI.d.mts.map +1 -1
- package/dist/abstract/BaseAPI.mjs +7 -0
- package/dist/abstract/BaseAPI.mjs.map +1 -1
- package/dist/consts/deployments-zlp-mainnet.json +1 -1
- package/dist/consts/deployments-zlp-testnet.json +19 -23
- package/dist/implementations/ZLPAPI.cjs +549 -0
- package/dist/implementations/ZLPAPI.cjs.map +1 -1
- package/dist/implementations/ZLPAPI.d.cts +49 -0
- package/dist/implementations/ZLPAPI.d.cts.map +1 -1
- package/dist/implementations/ZLPAPI.d.mts +49 -0
- package/dist/implementations/ZLPAPI.d.mts.map +1 -1
- package/dist/implementations/ZLPAPI.mjs +549 -0
- package/dist/implementations/ZLPAPI.mjs.map +1 -1
- package/dist/implementations/ZLPDataAPI.cjs +45 -5
- package/dist/implementations/ZLPDataAPI.cjs.map +1 -1
- package/dist/implementations/ZLPDataAPI.d.cts.map +1 -1
- package/dist/implementations/ZLPDataAPI.d.mts.map +1 -1
- package/dist/implementations/ZLPDataAPI.mjs +45 -5
- package/dist/implementations/ZLPDataAPI.mjs.map +1 -1
- package/dist/interfaces/base.d.cts +47 -1
- package/dist/interfaces/base.d.cts.map +1 -1
- package/dist/interfaces/base.d.mts +47 -1
- package/dist/interfaces/base.d.mts.map +1 -1
- package/package.json +1 -1
- package/src/abstract/BaseAPI.ts +8 -0
- package/src/consts/deployments-zlp-mainnet.json +1 -1
- package/src/consts/deployments-zlp-testnet.json +19 -23
- package/src/implementations/ZLPAPI.ts +922 -58
- package/src/implementations/ZLPDataAPI.ts +48 -5
- package/src/interfaces/base.ts +207 -1
|
@@ -543,6 +543,7 @@ class ZLPAPI extends abstract_1.BaseAPI {
|
|
|
543
543
|
const symbol = (0, utils_2.joinSymbol)(long ? 'long' : 'short', indexToken);
|
|
544
544
|
const adjustPrice = this.processSlippage(indexPrice, long, isLimitOrder ? 0 : pricesSlippage);
|
|
545
545
|
const adjustCollateralPrice = this.processSlippage(collateralPrice, false, collateralSlippage);
|
|
546
|
+
const indexPriceThreshold = this.processPriceThreshold(indexPrice, pricesSlippage);
|
|
546
547
|
let allowTrade = consts_1.ALLOW_TRADE_MUST_TRADE;
|
|
547
548
|
if (isLimitOrder) {
|
|
548
549
|
allowTrade = isIocOrder ? consts_1.ALLOW_TRADE_NO_TRADE : consts_1.ALLOW_TRADE_CAN_TRADE;
|
|
@@ -582,6 +583,7 @@ class ZLPAPI extends abstract_1.BaseAPI {
|
|
|
582
583
|
tx.pure.u64(reserveAmount),
|
|
583
584
|
tx.pure.u256(adjustCollateralPrice),
|
|
584
585
|
tx.pure.u256(adjustPrice),
|
|
586
|
+
tx.pure.u256(indexPriceThreshold),
|
|
585
587
|
],
|
|
586
588
|
});
|
|
587
589
|
return tx;
|
|
@@ -589,6 +591,60 @@ class ZLPAPI extends abstract_1.BaseAPI {
|
|
|
589
591
|
/**
|
|
590
592
|
* Opens a new position in ZLP
|
|
591
593
|
*/
|
|
594
|
+
async openPositionV2(collateralToken, indexToken, size, collateralAmount, coinObjects, long, reserveAmount, indexPrice, collateralPrice, isLimitOrder, isIocOrder, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), referralAddress, sender, sponsoredTx, suiCoinObjectsForPythUpdate) {
|
|
595
|
+
let tx = new transactions_1.Transaction();
|
|
596
|
+
if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
|
|
597
|
+
tx = await this.addReferral(referralAddress, tx);
|
|
598
|
+
}
|
|
599
|
+
const symbol = (0, utils_2.joinSymbol)(long ? 'long' : 'short', indexToken);
|
|
600
|
+
const adjustPrice = this.processSlippage(indexPrice, long, isLimitOrder ? 0 : pricesSlippage);
|
|
601
|
+
const adjustCollateralPrice = this.processSlippage(collateralPrice, false, collateralSlippage);
|
|
602
|
+
const indexPriceThreshold = this.processPriceThreshold(indexPrice, pricesSlippage);
|
|
603
|
+
let allowTrade = consts_1.ALLOW_TRADE_MUST_TRADE;
|
|
604
|
+
if (isLimitOrder) {
|
|
605
|
+
allowTrade = isIocOrder ? consts_1.ALLOW_TRADE_NO_TRADE : consts_1.ALLOW_TRADE_CAN_TRADE;
|
|
606
|
+
}
|
|
607
|
+
// Handle oracle initialization and coin processing
|
|
608
|
+
let suiCoinObject;
|
|
609
|
+
if (sponsoredTx) {
|
|
610
|
+
suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
|
|
611
|
+
tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
|
|
612
|
+
}
|
|
613
|
+
else {
|
|
614
|
+
tx = await this.initOracleTxb([collateralToken, indexToken], tx);
|
|
615
|
+
}
|
|
616
|
+
// Process coin splitting
|
|
617
|
+
const [depositObject, feeObject] = this.processCoinSplitting(tx, collateralToken, coinObjects, [tx.pure.u64(collateralAmount), tx.pure.u64(relayerFee)], sponsoredTx, suiCoinObject);
|
|
618
|
+
tx.moveCall({
|
|
619
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::open_position_v2`,
|
|
620
|
+
typeArguments: [
|
|
621
|
+
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
622
|
+
this.consts.coins[collateralToken].module,
|
|
623
|
+
this.consts.coins[indexToken].module,
|
|
624
|
+
`${this.consts.zoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
|
|
625
|
+
this.consts.coins[collateralToken].module,
|
|
626
|
+
],
|
|
627
|
+
arguments: [
|
|
628
|
+
tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
629
|
+
tx.object(this.consts.zoCore.market),
|
|
630
|
+
tx.object(this.consts.zoCore.symbols[symbol].positionConfig),
|
|
631
|
+
tx.object(this.consts.pythFeeder.feeder[collateralToken]),
|
|
632
|
+
tx.object(this.consts.pythFeeder.feeder[indexToken]),
|
|
633
|
+
depositObject,
|
|
634
|
+
feeObject,
|
|
635
|
+
tx.pure.u8(allowTrade),
|
|
636
|
+
tx.pure.u64(size),
|
|
637
|
+
tx.pure.u64(reserveAmount),
|
|
638
|
+
tx.pure.u256(adjustCollateralPrice),
|
|
639
|
+
tx.pure.u256(adjustPrice),
|
|
640
|
+
tx.pure.u256(indexPriceThreshold),
|
|
641
|
+
],
|
|
642
|
+
});
|
|
643
|
+
return tx;
|
|
644
|
+
}
|
|
645
|
+
/**
|
|
646
|
+
* Opens a new position with Coin in ZLP
|
|
647
|
+
*/
|
|
592
648
|
async openPositionWithCoin(collateralToken, indexToken, size, coinObj, long, reserveAmount, indexPrice, collateralPrice, isLimitOrder, isIocOrder, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), referralAddress, sender, tx, sponsoredTx, suiCoinObjectsForPythUpdate) {
|
|
593
649
|
if (!tx) {
|
|
594
650
|
tx = new transactions_1.Transaction();
|
|
@@ -642,6 +698,62 @@ class ZLPAPI extends abstract_1.BaseAPI {
|
|
|
642
698
|
});
|
|
643
699
|
return tx;
|
|
644
700
|
}
|
|
701
|
+
/**
|
|
702
|
+
* Opens a new position with Coin in ZLP (V2)
|
|
703
|
+
*/
|
|
704
|
+
async openPositionWithCoinV2(collateralToken, indexToken, size, coinObj, long, reserveAmount, indexPrice, collateralPrice, isLimitOrder, isIocOrder, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), referralAddress, sender, tx, sponsoredTx, suiCoinObjectsForPythUpdate) {
|
|
705
|
+
if (!tx) {
|
|
706
|
+
tx = new transactions_1.Transaction();
|
|
707
|
+
}
|
|
708
|
+
if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
|
|
709
|
+
tx = await this.addReferral(referralAddress, tx);
|
|
710
|
+
}
|
|
711
|
+
const symbol = (0, utils_2.joinSymbol)(long ? 'long' : 'short', indexToken);
|
|
712
|
+
const adjustPrice = this.processSlippage(indexPrice, long, isLimitOrder ? 0 : pricesSlippage);
|
|
713
|
+
const adjustCollateralPrice = this.processSlippage(collateralPrice, false, collateralSlippage);
|
|
714
|
+
const indexPriceThreshold = this.processPriceThreshold(indexPrice, pricesSlippage);
|
|
715
|
+
let allowTrade = consts_1.ALLOW_TRADE_MUST_TRADE;
|
|
716
|
+
if (isLimitOrder) {
|
|
717
|
+
allowTrade = isIocOrder ? consts_1.ALLOW_TRADE_NO_TRADE : consts_1.ALLOW_TRADE_CAN_TRADE;
|
|
718
|
+
}
|
|
719
|
+
// Handle oracle initialization and coin processing
|
|
720
|
+
let suiCoinObject;
|
|
721
|
+
if (sponsoredTx) {
|
|
722
|
+
suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
|
|
723
|
+
tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
|
|
724
|
+
}
|
|
725
|
+
else {
|
|
726
|
+
tx = await this.initOracleTxb([collateralToken, indexToken], tx);
|
|
727
|
+
}
|
|
728
|
+
// Process coin splitting
|
|
729
|
+
const [feeObject] = tx.splitCoins(coinObj, [tx.pure.u64(relayerFee)]);
|
|
730
|
+
tx.moveCall({
|
|
731
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::open_position_v2`,
|
|
732
|
+
typeArguments: [
|
|
733
|
+
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
734
|
+
this.consts.coins[collateralToken].module,
|
|
735
|
+
this.consts.coins[indexToken].module,
|
|
736
|
+
`${this.consts.zoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
|
|
737
|
+
this.consts.coins[collateralToken].module,
|
|
738
|
+
],
|
|
739
|
+
arguments: [
|
|
740
|
+
tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
741
|
+
tx.object(this.consts.zoCore.market),
|
|
742
|
+
tx.object(this.consts.zoCore.symbols[symbol].positionConfig),
|
|
743
|
+
tx.object(this.consts.pythFeeder.feeder[collateralToken]),
|
|
744
|
+
tx.object(this.consts.pythFeeder.feeder[indexToken]),
|
|
745
|
+
coinObj,
|
|
746
|
+
feeObject,
|
|
747
|
+
tx.pure.u8(allowTrade),
|
|
748
|
+
tx.pure.u64(size),
|
|
749
|
+
tx.pure.u64(reserveAmount),
|
|
750
|
+
tx.pure.u256(adjustCollateralPrice),
|
|
751
|
+
tx.pure.u256(adjustPrice),
|
|
752
|
+
tx.pure.u256(indexPriceThreshold),
|
|
753
|
+
],
|
|
754
|
+
});
|
|
755
|
+
return tx;
|
|
756
|
+
}
|
|
645
757
|
/**
|
|
646
758
|
* Decreases an existing position in ZLP
|
|
647
759
|
*/
|
|
@@ -698,6 +810,62 @@ class ZLPAPI extends abstract_1.BaseAPI {
|
|
|
698
810
|
});
|
|
699
811
|
return tx;
|
|
700
812
|
}
|
|
813
|
+
/**
|
|
814
|
+
* Decreases an existing position in ZLP
|
|
815
|
+
*/
|
|
816
|
+
async decreasePositionV2(pcpId, collateralToken, indexToken, amount, long, indexPrice, collateralPrice, isTriggerOrder = false, isTakeProfitOrder = true, isIocOrder = false, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), coinObjects, sponsoredTx, suiCoinObjectsForPythUpdate) {
|
|
817
|
+
if (!coinObjects) {
|
|
818
|
+
throw new Error(`${this.constructor.name}: coinObjects is required`);
|
|
819
|
+
}
|
|
820
|
+
let tx = new transactions_1.Transaction();
|
|
821
|
+
const symbol = (0, utils_2.joinSymbol)(long ? 'long' : 'short', indexToken);
|
|
822
|
+
const adjustPrice = this.processSlippage(indexPrice, !long, isTriggerOrder ? 0 : pricesSlippage);
|
|
823
|
+
const adjustCollateralPrice = this.processSlippage(collateralPrice, false, collateralSlippage);
|
|
824
|
+
const indexPriceThreshold = this.processPriceThreshold(indexPrice, pricesSlippage);
|
|
825
|
+
let allowTrade = consts_1.ALLOW_TRADE_MUST_TRADE;
|
|
826
|
+
if (isTriggerOrder) {
|
|
827
|
+
allowTrade = isIocOrder || !isTakeProfitOrder ? consts_1.ALLOW_TRADE_NO_TRADE : consts_1.ALLOW_TRADE_CAN_TRADE;
|
|
828
|
+
}
|
|
829
|
+
else {
|
|
830
|
+
isTakeProfitOrder = true;
|
|
831
|
+
}
|
|
832
|
+
// Handle oracle initialization and coin processing
|
|
833
|
+
let suiCoinObject;
|
|
834
|
+
if (sponsoredTx) {
|
|
835
|
+
suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
|
|
836
|
+
tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
|
|
837
|
+
}
|
|
838
|
+
else {
|
|
839
|
+
tx = await this.initOracleTxb([collateralToken, indexToken], tx);
|
|
840
|
+
}
|
|
841
|
+
// Process coin splitting
|
|
842
|
+
const [feeObject] = this.processCoinSplitting(tx, collateralToken, coinObjects, [tx.pure.u64(relayerFee)], sponsoredTx, suiCoinObject);
|
|
843
|
+
tx.moveCall({
|
|
844
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::decrease_position_v2`,
|
|
845
|
+
typeArguments: [
|
|
846
|
+
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
847
|
+
this.consts.coins[collateralToken].module,
|
|
848
|
+
this.consts.coins[indexToken].module,
|
|
849
|
+
`${this.consts.zoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
|
|
850
|
+
this.consts.coins[collateralToken].module,
|
|
851
|
+
],
|
|
852
|
+
arguments: [
|
|
853
|
+
tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
854
|
+
tx.object(this.consts.zoCore.market),
|
|
855
|
+
tx.object(pcpId),
|
|
856
|
+
tx.object(this.consts.pythFeeder.feeder[collateralToken]),
|
|
857
|
+
tx.object(this.consts.pythFeeder.feeder[indexToken]),
|
|
858
|
+
feeObject,
|
|
859
|
+
tx.pure.u8(allowTrade),
|
|
860
|
+
tx.pure.bool(isTakeProfitOrder),
|
|
861
|
+
tx.pure.u64(amount),
|
|
862
|
+
tx.pure.u256(adjustCollateralPrice),
|
|
863
|
+
tx.pure.u256(adjustPrice),
|
|
864
|
+
tx.pure.u256(indexPriceThreshold),
|
|
865
|
+
],
|
|
866
|
+
});
|
|
867
|
+
return tx;
|
|
868
|
+
}
|
|
701
869
|
async decreaseMultiPositions(positions, tx, sponsoredTx, suiCoinObjectsForPythUpdate) {
|
|
702
870
|
if (!tx) {
|
|
703
871
|
tx = new transactions_1.Transaction();
|
|
@@ -754,6 +922,62 @@ class ZLPAPI extends abstract_1.BaseAPI {
|
|
|
754
922
|
}
|
|
755
923
|
return tx;
|
|
756
924
|
}
|
|
925
|
+
async decreaseMultiPositionsV2(positions, tx, sponsoredTx, suiCoinObjectsForPythUpdate) {
|
|
926
|
+
if (!tx) {
|
|
927
|
+
tx = new transactions_1.Transaction();
|
|
928
|
+
}
|
|
929
|
+
// Handle oracle initialization and coin processing
|
|
930
|
+
let suiCoinObject;
|
|
931
|
+
if (sponsoredTx) {
|
|
932
|
+
suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
|
|
933
|
+
tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx, true, suiCoinObject);
|
|
934
|
+
}
|
|
935
|
+
else {
|
|
936
|
+
tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx);
|
|
937
|
+
}
|
|
938
|
+
for (const position of positions) {
|
|
939
|
+
const { pcpId, collateralToken, coinObjects = [], indexToken, amount, long, indexPrice, collateralPrice, isTriggerOrder = false, isTakeProfitOrder = true, isIocOrder = false, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), } = position;
|
|
940
|
+
let innerIsTakeProfitOrder = isTakeProfitOrder;
|
|
941
|
+
const symbol = (0, utils_2.joinSymbol)(long ? 'long' : 'short', indexToken);
|
|
942
|
+
const adjustPrice = this.processSlippage(indexPrice, !long, isTriggerOrder ? 0 : pricesSlippage);
|
|
943
|
+
const adjustCollateralPrice = this.processSlippage(collateralPrice, false, collateralSlippage);
|
|
944
|
+
const indexPriceThreshold = this.processPriceThreshold(indexPrice, pricesSlippage);
|
|
945
|
+
let allowTrade = consts_1.ALLOW_TRADE_MUST_TRADE;
|
|
946
|
+
if (isTriggerOrder) {
|
|
947
|
+
allowTrade = isIocOrder || !innerIsTakeProfitOrder ? consts_1.ALLOW_TRADE_NO_TRADE : consts_1.ALLOW_TRADE_CAN_TRADE;
|
|
948
|
+
}
|
|
949
|
+
else {
|
|
950
|
+
innerIsTakeProfitOrder = true;
|
|
951
|
+
}
|
|
952
|
+
// Process coin splitting
|
|
953
|
+
const [feeObject] = this.processCoinSplitting(tx, collateralToken, coinObjects, [tx.pure.u64(relayerFee)], sponsoredTx, suiCoinObject);
|
|
954
|
+
tx.moveCall({
|
|
955
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::decrease_position_v2`,
|
|
956
|
+
typeArguments: [
|
|
957
|
+
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
958
|
+
this.consts.coins[collateralToken].module,
|
|
959
|
+
this.consts.coins[indexToken].module,
|
|
960
|
+
`${this.consts.zoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
|
|
961
|
+
this.consts.coins[collateralToken].module,
|
|
962
|
+
],
|
|
963
|
+
arguments: [
|
|
964
|
+
tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
965
|
+
tx.object(this.consts.zoCore.market),
|
|
966
|
+
tx.object(pcpId),
|
|
967
|
+
tx.object(this.consts.pythFeeder.feeder[collateralToken]),
|
|
968
|
+
tx.object(this.consts.pythFeeder.feeder[indexToken]),
|
|
969
|
+
feeObject,
|
|
970
|
+
tx.pure.u8(allowTrade),
|
|
971
|
+
tx.pure.bool(innerIsTakeProfitOrder),
|
|
972
|
+
tx.pure.u64(amount),
|
|
973
|
+
tx.pure.u256(adjustCollateralPrice),
|
|
974
|
+
tx.pure.u256(adjustPrice),
|
|
975
|
+
tx.pure.u256(indexPriceThreshold),
|
|
976
|
+
],
|
|
977
|
+
});
|
|
978
|
+
}
|
|
979
|
+
return tx;
|
|
980
|
+
}
|
|
757
981
|
async openPositionWithSCard(collateralToken, indexToken, size, collateralAmount, coinObjects, long, reserveAmount, indexPrice, collateralPrice, kioskClient, kioskCap, scard, isLimitOrder, isIocOrder, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), referralAddress, sender, sponsoredTx, suiCoinObjectsForPythUpdate) {
|
|
758
982
|
let tx = new transactions_1.Transaction();
|
|
759
983
|
if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
|
|
@@ -822,6 +1046,74 @@ class ZLPAPI extends abstract_1.BaseAPI {
|
|
|
822
1046
|
.finalize();
|
|
823
1047
|
return tx;
|
|
824
1048
|
}
|
|
1049
|
+
async openPositionWithSCardV2(collateralToken, indexToken, size, collateralAmount, coinObjects, long, reserveAmount, indexPrice, collateralPrice, kioskClient, kioskCap, scard, isLimitOrder, isIocOrder, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), referralAddress, sender, sponsoredTx, suiCoinObjectsForPythUpdate) {
|
|
1050
|
+
let tx = new transactions_1.Transaction();
|
|
1051
|
+
if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
|
|
1052
|
+
tx = await this.addReferral(referralAddress, tx);
|
|
1053
|
+
}
|
|
1054
|
+
const symbol = (0, utils_2.joinSymbol)(long ? 'long' : 'short', indexToken);
|
|
1055
|
+
const adjustPrice = this.processSlippage(indexPrice, long, isLimitOrder ? 0 : pricesSlippage);
|
|
1056
|
+
const adjustCollateralPrice = this.processSlippage(collateralPrice, false, collateralSlippage);
|
|
1057
|
+
const indexPriceThreshold = this.processPriceThreshold(indexPrice, pricesSlippage);
|
|
1058
|
+
let allowTrade = consts_1.ALLOW_TRADE_MUST_TRADE;
|
|
1059
|
+
if (isLimitOrder) {
|
|
1060
|
+
allowTrade = isIocOrder ? consts_1.ALLOW_TRADE_NO_TRADE : consts_1.ALLOW_TRADE_CAN_TRADE;
|
|
1061
|
+
}
|
|
1062
|
+
const kioskTx = new kiosk_1.KioskTransaction({
|
|
1063
|
+
transaction: tx,
|
|
1064
|
+
kioskClient,
|
|
1065
|
+
cap: kioskCap,
|
|
1066
|
+
});
|
|
1067
|
+
const [sudoCard, promise] = kioskTx.borrow({
|
|
1068
|
+
itemType: `0xe7e651e4974fe367aa2837712d68081efb299c470242a15e2b9c26ea326159ec::card::SudoCard`,
|
|
1069
|
+
itemId: scard,
|
|
1070
|
+
});
|
|
1071
|
+
// Handle oracle initialization and coin processing
|
|
1072
|
+
let suiCoinObject;
|
|
1073
|
+
if (sponsoredTx) {
|
|
1074
|
+
suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
|
|
1075
|
+
tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
|
|
1076
|
+
}
|
|
1077
|
+
else {
|
|
1078
|
+
tx = await this.initOracleTxb([collateralToken, indexToken], tx);
|
|
1079
|
+
}
|
|
1080
|
+
// Process coin splitting
|
|
1081
|
+
const [depositObject, feeObject] = this.processCoinSplitting(tx, collateralToken, coinObjects, [tx.pure.u64(collateralAmount), tx.pure.u64(relayerFee)], sponsoredTx, suiCoinObject);
|
|
1082
|
+
tx.moveCall({
|
|
1083
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::open_position_with_scard_v2`,
|
|
1084
|
+
typeArguments: [
|
|
1085
|
+
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
1086
|
+
this.consts.coins[collateralToken].module,
|
|
1087
|
+
this.consts.coins[indexToken].module,
|
|
1088
|
+
`${this.consts.zoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
|
|
1089
|
+
this.consts.coins[collateralToken].module,
|
|
1090
|
+
],
|
|
1091
|
+
arguments: [
|
|
1092
|
+
tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
1093
|
+
tx.object(this.consts.zoCore.market),
|
|
1094
|
+
tx.object(this.consts.zoCore.symbols[symbol].positionConfig),
|
|
1095
|
+
tx.object(this.consts.pythFeeder.feeder[collateralToken]),
|
|
1096
|
+
tx.object(this.consts.pythFeeder.feeder[indexToken]),
|
|
1097
|
+
depositObject,
|
|
1098
|
+
feeObject,
|
|
1099
|
+
tx.pure.u8(allowTrade),
|
|
1100
|
+
tx.pure.u64(size),
|
|
1101
|
+
tx.pure.u64(reserveAmount),
|
|
1102
|
+
tx.pure.u256(adjustCollateralPrice),
|
|
1103
|
+
tx.pure.u256(adjustPrice),
|
|
1104
|
+
tx.pure.u256(indexPriceThreshold),
|
|
1105
|
+
sudoCard,
|
|
1106
|
+
],
|
|
1107
|
+
});
|
|
1108
|
+
kioskTx
|
|
1109
|
+
.return({
|
|
1110
|
+
itemType: `0xe7e651e4974fe367aa2837712d68081efb299c470242a15e2b9c26ea326159ec::card::SudoCard`,
|
|
1111
|
+
item: sudoCard,
|
|
1112
|
+
promise,
|
|
1113
|
+
})
|
|
1114
|
+
.finalize();
|
|
1115
|
+
return tx;
|
|
1116
|
+
}
|
|
825
1117
|
async openPositionWithCoinAndSCard(collateralToken, indexToken, size, coinObj, long, reserveAmount, indexPrice, collateralPrice, kioskClient, kioskCap, scard, isLimitOrder, isIocOrder, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), referralAddress, sender, tx, sponsoredTx, suiCoinObjectsForPythUpdate) {
|
|
826
1118
|
if (!tx) {
|
|
827
1119
|
tx = new transactions_1.Transaction();
|
|
@@ -892,6 +1184,76 @@ class ZLPAPI extends abstract_1.BaseAPI {
|
|
|
892
1184
|
.finalize();
|
|
893
1185
|
return tx;
|
|
894
1186
|
}
|
|
1187
|
+
async openPositionWithCoinAndSCardV2(collateralToken, indexToken, size, coinObj, long, reserveAmount, indexPrice, collateralPrice, kioskClient, kioskCap, scard, isLimitOrder, isIocOrder, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), referralAddress, sender, tx, sponsoredTx, suiCoinObjectsForPythUpdate) {
|
|
1188
|
+
if (!tx) {
|
|
1189
|
+
tx = new transactions_1.Transaction();
|
|
1190
|
+
}
|
|
1191
|
+
if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
|
|
1192
|
+
tx = await this.addReferral(referralAddress, tx);
|
|
1193
|
+
}
|
|
1194
|
+
const symbol = (0, utils_2.joinSymbol)(long ? 'long' : 'short', indexToken);
|
|
1195
|
+
const adjustPrice = this.processSlippage(indexPrice, long, isLimitOrder ? 0 : pricesSlippage);
|
|
1196
|
+
const adjustCollateralPrice = this.processSlippage(collateralPrice, false, collateralSlippage);
|
|
1197
|
+
const indexPriceThreshold = this.processPriceThreshold(indexPrice, pricesSlippage);
|
|
1198
|
+
let allowTrade = consts_1.ALLOW_TRADE_MUST_TRADE;
|
|
1199
|
+
if (isLimitOrder) {
|
|
1200
|
+
allowTrade = isIocOrder ? consts_1.ALLOW_TRADE_NO_TRADE : consts_1.ALLOW_TRADE_CAN_TRADE;
|
|
1201
|
+
}
|
|
1202
|
+
const kioskTx = new kiosk_1.KioskTransaction({
|
|
1203
|
+
transaction: tx,
|
|
1204
|
+
kioskClient,
|
|
1205
|
+
cap: kioskCap,
|
|
1206
|
+
});
|
|
1207
|
+
const [sudoCard, promise] = kioskTx.borrow({
|
|
1208
|
+
itemType: `0xe7e651e4974fe367aa2837712d68081efb299c470242a15e2b9c26ea326159ec::card::SudoCard`,
|
|
1209
|
+
itemId: scard,
|
|
1210
|
+
});
|
|
1211
|
+
// Handle oracle initialization and coin processing
|
|
1212
|
+
let suiCoinObject;
|
|
1213
|
+
if (sponsoredTx) {
|
|
1214
|
+
suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
|
|
1215
|
+
tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
|
|
1216
|
+
}
|
|
1217
|
+
else {
|
|
1218
|
+
tx = await this.initOracleTxb([collateralToken, indexToken], tx);
|
|
1219
|
+
}
|
|
1220
|
+
// Process coin splitting
|
|
1221
|
+
const [feeObject] = tx.splitCoins(coinObj, [tx.pure.u64(relayerFee)]);
|
|
1222
|
+
tx.moveCall({
|
|
1223
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::open_position_with_scard_v2`,
|
|
1224
|
+
typeArguments: [
|
|
1225
|
+
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
1226
|
+
this.consts.coins[collateralToken].module,
|
|
1227
|
+
this.consts.coins[indexToken].module,
|
|
1228
|
+
`${this.consts.zoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
|
|
1229
|
+
this.consts.coins[collateralToken].module,
|
|
1230
|
+
],
|
|
1231
|
+
arguments: [
|
|
1232
|
+
tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
1233
|
+
tx.object(this.consts.zoCore.market),
|
|
1234
|
+
tx.object(this.consts.zoCore.symbols[symbol].positionConfig),
|
|
1235
|
+
tx.object(this.consts.pythFeeder.feeder[collateralToken]),
|
|
1236
|
+
tx.object(this.consts.pythFeeder.feeder[indexToken]),
|
|
1237
|
+
coinObj,
|
|
1238
|
+
feeObject,
|
|
1239
|
+
tx.pure.u8(allowTrade),
|
|
1240
|
+
tx.pure.u64(size),
|
|
1241
|
+
tx.pure.u64(reserveAmount),
|
|
1242
|
+
tx.pure.u256(adjustCollateralPrice),
|
|
1243
|
+
tx.pure.u256(adjustPrice),
|
|
1244
|
+
tx.pure.u256(indexPriceThreshold),
|
|
1245
|
+
sudoCard,
|
|
1246
|
+
],
|
|
1247
|
+
});
|
|
1248
|
+
kioskTx
|
|
1249
|
+
.return({
|
|
1250
|
+
itemType: `0xe7e651e4974fe367aa2837712d68081efb299c470242a15e2b9c26ea326159ec::card::SudoCard`,
|
|
1251
|
+
item: sudoCard,
|
|
1252
|
+
promise,
|
|
1253
|
+
})
|
|
1254
|
+
.finalize();
|
|
1255
|
+
return tx;
|
|
1256
|
+
}
|
|
895
1257
|
async decreasePositionWithSCard(pcpId, collateralToken, indexToken, amount, long, indexPrice, collateralPrice, kioskClient, kioskCap, scard, isTriggerOrder = false, isTakeProfitOrder = true, isIocOrder = false, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), coinObjects, sponsoredTx, suiCoinObjectsForPythUpdate) {
|
|
896
1258
|
if (!coinObjects) {
|
|
897
1259
|
throw new Error(`${this.constructor.name}: coinObjects is required`);
|
|
@@ -962,6 +1324,76 @@ class ZLPAPI extends abstract_1.BaseAPI {
|
|
|
962
1324
|
.finalize();
|
|
963
1325
|
return tx;
|
|
964
1326
|
}
|
|
1327
|
+
async decreasePositionWithSCardV2(pcpId, collateralToken, indexToken, amount, long, indexPrice, collateralPrice, kioskClient, kioskCap, scard, isTriggerOrder = false, isTakeProfitOrder = true, isIocOrder = false, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), coinObjects, sponsoredTx, suiCoinObjectsForPythUpdate) {
|
|
1328
|
+
if (!coinObjects) {
|
|
1329
|
+
throw new Error(`${this.constructor.name}: coinObjects is required`);
|
|
1330
|
+
}
|
|
1331
|
+
let tx = new transactions_1.Transaction();
|
|
1332
|
+
const kioskTx = new kiosk_1.KioskTransaction({
|
|
1333
|
+
transaction: tx,
|
|
1334
|
+
kioskClient,
|
|
1335
|
+
cap: kioskCap,
|
|
1336
|
+
});
|
|
1337
|
+
const [sudoCard, promise] = kioskTx.borrow({
|
|
1338
|
+
itemType: `0xe7e651e4974fe367aa2837712d68081efb299c470242a15e2b9c26ea326159ec::card::SudoCard`,
|
|
1339
|
+
itemId: scard,
|
|
1340
|
+
});
|
|
1341
|
+
const symbol = (0, utils_2.joinSymbol)(long ? 'long' : 'short', indexToken);
|
|
1342
|
+
const adjustPrice = this.processSlippage(indexPrice, !long, isTriggerOrder ? 0 : pricesSlippage);
|
|
1343
|
+
const adjustCollateralPrice = this.processSlippage(collateralPrice, false, collateralSlippage);
|
|
1344
|
+
const indexPriceThreshold = this.processPriceThreshold(indexPrice, pricesSlippage);
|
|
1345
|
+
let allowTrade = consts_1.ALLOW_TRADE_MUST_TRADE;
|
|
1346
|
+
if (isTriggerOrder) {
|
|
1347
|
+
allowTrade = isIocOrder || !isTakeProfitOrder ? consts_1.ALLOW_TRADE_NO_TRADE : consts_1.ALLOW_TRADE_CAN_TRADE;
|
|
1348
|
+
}
|
|
1349
|
+
else {
|
|
1350
|
+
isTakeProfitOrder = true;
|
|
1351
|
+
}
|
|
1352
|
+
// Handle oracle initialization and coin processing
|
|
1353
|
+
let suiCoinObject;
|
|
1354
|
+
if (sponsoredTx) {
|
|
1355
|
+
suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
|
|
1356
|
+
tx = await this.initOracleTxb([collateralToken, indexToken], tx, true, suiCoinObject);
|
|
1357
|
+
}
|
|
1358
|
+
else {
|
|
1359
|
+
tx = await this.initOracleTxb([collateralToken, indexToken], tx);
|
|
1360
|
+
}
|
|
1361
|
+
// Process coin splitting
|
|
1362
|
+
const [feeObject] = this.processCoinSplitting(tx, collateralToken, coinObjects, [tx.pure.u64(relayerFee)], sponsoredTx, suiCoinObject);
|
|
1363
|
+
tx.moveCall({
|
|
1364
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::decrease_position_with_scard_v2`,
|
|
1365
|
+
typeArguments: [
|
|
1366
|
+
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
1367
|
+
this.consts.coins[collateralToken].module,
|
|
1368
|
+
this.consts.coins[indexToken].module,
|
|
1369
|
+
`${this.consts.zoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
|
|
1370
|
+
this.consts.coins[collateralToken].module,
|
|
1371
|
+
],
|
|
1372
|
+
arguments: [
|
|
1373
|
+
tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
1374
|
+
tx.object(this.consts.zoCore.market),
|
|
1375
|
+
tx.object(pcpId),
|
|
1376
|
+
tx.object(this.consts.pythFeeder.feeder[collateralToken]),
|
|
1377
|
+
tx.object(this.consts.pythFeeder.feeder[indexToken]),
|
|
1378
|
+
feeObject,
|
|
1379
|
+
tx.pure.u8(allowTrade),
|
|
1380
|
+
tx.pure.bool(isTakeProfitOrder),
|
|
1381
|
+
tx.pure.u64(amount),
|
|
1382
|
+
tx.pure.u256(adjustCollateralPrice),
|
|
1383
|
+
tx.pure.u256(adjustPrice),
|
|
1384
|
+
tx.pure.u256(indexPriceThreshold),
|
|
1385
|
+
sudoCard,
|
|
1386
|
+
],
|
|
1387
|
+
});
|
|
1388
|
+
kioskTx
|
|
1389
|
+
.return({
|
|
1390
|
+
itemType: `0xe7e651e4974fe367aa2837712d68081efb299c470242a15e2b9c26ea326159ec::card::SudoCard`,
|
|
1391
|
+
item: sudoCard,
|
|
1392
|
+
promise,
|
|
1393
|
+
})
|
|
1394
|
+
.finalize();
|
|
1395
|
+
return tx;
|
|
1396
|
+
}
|
|
965
1397
|
async decreaseMultiPositionsWithSCard(positions, kioskClient, kioskCap, scard, tx, sponsoredTx, suiCoinObjectsForPythUpdate) {
|
|
966
1398
|
if (!tx) {
|
|
967
1399
|
tx = new transactions_1.Transaction();
|
|
@@ -1035,6 +1467,79 @@ class ZLPAPI extends abstract_1.BaseAPI {
|
|
|
1035
1467
|
.finalize();
|
|
1036
1468
|
return tx;
|
|
1037
1469
|
}
|
|
1470
|
+
async decreaseMultiPositionsWithSCardV2(positions, kioskClient, kioskCap, scard, tx, sponsoredTx, suiCoinObjectsForPythUpdate) {
|
|
1471
|
+
if (!tx) {
|
|
1472
|
+
tx = new transactions_1.Transaction();
|
|
1473
|
+
}
|
|
1474
|
+
// Handle oracle initialization and coin processing
|
|
1475
|
+
let suiCoinObject;
|
|
1476
|
+
if (sponsoredTx) {
|
|
1477
|
+
suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
|
|
1478
|
+
tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx, true, suiCoinObject);
|
|
1479
|
+
}
|
|
1480
|
+
else {
|
|
1481
|
+
tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx);
|
|
1482
|
+
}
|
|
1483
|
+
const kioskTx = new kiosk_1.KioskTransaction({
|
|
1484
|
+
transaction: tx,
|
|
1485
|
+
kioskClient,
|
|
1486
|
+
cap: kioskCap,
|
|
1487
|
+
});
|
|
1488
|
+
const [sudoCard, promise] = kioskTx.borrow({
|
|
1489
|
+
itemType: `0xe7e651e4974fe367aa2837712d68081efb299c470242a15e2b9c26ea326159ec::card::SudoCard`,
|
|
1490
|
+
itemId: scard,
|
|
1491
|
+
});
|
|
1492
|
+
for (const position of positions) {
|
|
1493
|
+
const { pcpId, collateralToken, indexToken, amount, long, indexPrice, collateralPrice, isTriggerOrder = false, isTakeProfitOrder = true, isIocOrder = false, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), coinObjects = [], } = position;
|
|
1494
|
+
let innerIsTakeProfitOrder = isTakeProfitOrder;
|
|
1495
|
+
const symbol = (0, utils_2.joinSymbol)(long ? 'long' : 'short', indexToken);
|
|
1496
|
+
const adjustPrice = this.processSlippage(indexPrice, !long, isTriggerOrder ? 0 : pricesSlippage);
|
|
1497
|
+
const adjustCollateralPrice = this.processSlippage(collateralPrice, false, collateralSlippage);
|
|
1498
|
+
const indexPriceThreshold = this.processPriceThreshold(indexPrice, pricesSlippage);
|
|
1499
|
+
let allowTrade = consts_1.ALLOW_TRADE_MUST_TRADE;
|
|
1500
|
+
if (isTriggerOrder) {
|
|
1501
|
+
allowTrade = isIocOrder || !innerIsTakeProfitOrder ? consts_1.ALLOW_TRADE_NO_TRADE : consts_1.ALLOW_TRADE_CAN_TRADE;
|
|
1502
|
+
}
|
|
1503
|
+
else {
|
|
1504
|
+
innerIsTakeProfitOrder = true;
|
|
1505
|
+
}
|
|
1506
|
+
// Process coin splitting
|
|
1507
|
+
const [feeObject] = this.processCoinSplitting(tx, collateralToken, coinObjects, [tx.pure.u64(relayerFee)], sponsoredTx, suiCoinObject);
|
|
1508
|
+
tx.moveCall({
|
|
1509
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::decrease_position_with_scard_v2`,
|
|
1510
|
+
typeArguments: [
|
|
1511
|
+
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
1512
|
+
this.consts.coins[collateralToken].module,
|
|
1513
|
+
this.consts.coins[indexToken].module,
|
|
1514
|
+
`${this.consts.zoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
|
|
1515
|
+
this.consts.coins[collateralToken].module,
|
|
1516
|
+
],
|
|
1517
|
+
arguments: [
|
|
1518
|
+
tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
1519
|
+
tx.object(this.consts.zoCore.market),
|
|
1520
|
+
tx.object(pcpId),
|
|
1521
|
+
tx.object(this.consts.pythFeeder.feeder[collateralToken]),
|
|
1522
|
+
tx.object(this.consts.pythFeeder.feeder[indexToken]),
|
|
1523
|
+
feeObject,
|
|
1524
|
+
tx.pure.u8(allowTrade),
|
|
1525
|
+
tx.pure.bool(innerIsTakeProfitOrder),
|
|
1526
|
+
tx.pure.u64(amount),
|
|
1527
|
+
tx.pure.u256(adjustCollateralPrice),
|
|
1528
|
+
tx.pure.u256(adjustPrice),
|
|
1529
|
+
tx.pure.u256(indexPriceThreshold),
|
|
1530
|
+
sudoCard,
|
|
1531
|
+
],
|
|
1532
|
+
});
|
|
1533
|
+
}
|
|
1534
|
+
kioskTx
|
|
1535
|
+
.return({
|
|
1536
|
+
itemType: `0xe7e651e4974fe367aa2837712d68081efb299c470242a15e2b9c26ea326159ec::card::SudoCard`,
|
|
1537
|
+
item: sudoCard,
|
|
1538
|
+
promise,
|
|
1539
|
+
})
|
|
1540
|
+
.finalize();
|
|
1541
|
+
return tx;
|
|
1542
|
+
}
|
|
1038
1543
|
/**
|
|
1039
1544
|
* Pledges in position (ZLP-specific functionality)
|
|
1040
1545
|
*/
|
|
@@ -1104,12 +1609,20 @@ class ZLPAPI extends abstract_1.BaseAPI {
|
|
|
1104
1609
|
functionName = isV11Order ? 'clear_open_position_order' : 'clear_open_position_order';
|
|
1105
1610
|
break;
|
|
1106
1611
|
}
|
|
1612
|
+
case 'OPEN_MARKET': {
|
|
1613
|
+
functionName = 'clear_open_market_order';
|
|
1614
|
+
break;
|
|
1615
|
+
}
|
|
1107
1616
|
case 'DECREASE_POSITION': {
|
|
1108
1617
|
functionName = isV11Order
|
|
1109
1618
|
? 'clear_decrease_position_order'
|
|
1110
1619
|
: 'clear_decrease_position_order';
|
|
1111
1620
|
break;
|
|
1112
1621
|
}
|
|
1622
|
+
case 'DECREASE_MARKET': {
|
|
1623
|
+
functionName = 'clear_decrease_market_order';
|
|
1624
|
+
break;
|
|
1625
|
+
}
|
|
1113
1626
|
default: {
|
|
1114
1627
|
throw new Error('invalid order type');
|
|
1115
1628
|
}
|
|
@@ -1139,12 +1652,20 @@ class ZLPAPI extends abstract_1.BaseAPI {
|
|
|
1139
1652
|
functionName = isV11Order ? 'clear_open_position_order' : 'clear_open_position_order';
|
|
1140
1653
|
break;
|
|
1141
1654
|
}
|
|
1655
|
+
case 'OPEN_MARKET': {
|
|
1656
|
+
functionName = 'clear_open_market_order';
|
|
1657
|
+
break;
|
|
1658
|
+
}
|
|
1142
1659
|
case 'DECREASE_POSITION': {
|
|
1143
1660
|
functionName = isV11Order
|
|
1144
1661
|
? 'clear_decrease_position_order'
|
|
1145
1662
|
: 'clear_decrease_position_order';
|
|
1146
1663
|
break;
|
|
1147
1664
|
}
|
|
1665
|
+
case 'DECREASE_MARKET': {
|
|
1666
|
+
functionName = 'clear_decrease_market_order';
|
|
1667
|
+
break;
|
|
1668
|
+
}
|
|
1148
1669
|
default: {
|
|
1149
1670
|
throw new Error('invalid order type');
|
|
1150
1671
|
}
|
|
@@ -1189,6 +1710,20 @@ class ZLPAPI extends abstract_1.BaseAPI {
|
|
|
1189
1710
|
arguments: [tx.object(this.consts.zoCore.market), tx.object(orderCapId)],
|
|
1190
1711
|
});
|
|
1191
1712
|
}
|
|
1713
|
+
clearOpenMarketOrder(orderCapId, collateralToken, indexToken, long, tx, isV11Order) {
|
|
1714
|
+
const funcName = 'clear_open_market_order';
|
|
1715
|
+
tx.moveCall({
|
|
1716
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::${funcName}`,
|
|
1717
|
+
typeArguments: [
|
|
1718
|
+
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
1719
|
+
this.consts.coins[collateralToken].module,
|
|
1720
|
+
this.consts.coins[indexToken].module,
|
|
1721
|
+
`${this.consts.zoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
|
|
1722
|
+
this.consts.coins[collateralToken].module,
|
|
1723
|
+
],
|
|
1724
|
+
arguments: [tx.object(this.consts.zoCore.market), tx.object(orderCapId)],
|
|
1725
|
+
});
|
|
1726
|
+
}
|
|
1192
1727
|
clearDecreasePositionOrder(orderCapId, collateralToken, indexToken, long, tx, isV11Order) {
|
|
1193
1728
|
const funcName = isV11Order ? 'clear_decrease_position_order' : 'clear_decrease_position_order';
|
|
1194
1729
|
tx.moveCall({
|
|
@@ -1203,6 +1738,20 @@ class ZLPAPI extends abstract_1.BaseAPI {
|
|
|
1203
1738
|
arguments: [tx.object(this.consts.zoCore.market), tx.object(orderCapId)],
|
|
1204
1739
|
});
|
|
1205
1740
|
}
|
|
1741
|
+
clearDecreaseMarketOrder(orderCapId, collateralToken, indexToken, long, tx, isV11Order) {
|
|
1742
|
+
const funcName = 'clear_decrease_market_order';
|
|
1743
|
+
tx.moveCall({
|
|
1744
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::${funcName}`,
|
|
1745
|
+
typeArguments: [
|
|
1746
|
+
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
1747
|
+
this.consts.coins[collateralToken].module,
|
|
1748
|
+
this.consts.coins[indexToken].module,
|
|
1749
|
+
`${this.consts.zoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
|
|
1750
|
+
this.consts.coins[collateralToken].module,
|
|
1751
|
+
],
|
|
1752
|
+
arguments: [tx.object(this.consts.zoCore.market), tx.object(orderCapId)],
|
|
1753
|
+
});
|
|
1754
|
+
}
|
|
1206
1755
|
addReferral(referralAddress, tx) {
|
|
1207
1756
|
if (!tx) {
|
|
1208
1757
|
tx = new transactions_1.Transaction();
|