@theliem/xmarket-sdk 3.7.0 → 3.9.0
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/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +40 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -31
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1750,7 +1750,7 @@ ${logs.join("\n")}`);
|
|
|
1750
1750
|
* [extraAccountMetaList, hookConfig, hookProgram]
|
|
1751
1751
|
* [feeManagement, fee_config, mkt_override, company_ata, oracle_vault] (when fee > 0)
|
|
1752
1752
|
*/
|
|
1753
|
-
async buildMatchComplementaryIxs(takerSigned, makersSigned, collateralMint, feeRecipient, operator, opts, useTakerPrice = false) {
|
|
1753
|
+
async buildMatchComplementaryIxs(takerSigned, makersSigned, collateralMint, feeRecipient, operator, opts, useTakerPrice = false, skipCrossingCheck = true) {
|
|
1754
1754
|
const condition = takerSigned.order.condition;
|
|
1755
1755
|
const tokenId = takerSigned.order.tokenId;
|
|
1756
1756
|
const taker = takerSigned.order.maker;
|
|
@@ -1790,17 +1790,21 @@ ${logs.join("\n")}`);
|
|
|
1790
1790
|
if (takerSigned.order.fee.gtn(0) && this.programIds.feeManagement && this.feeConfigOwner) {
|
|
1791
1791
|
const companyAddr = await this.companyAddress();
|
|
1792
1792
|
if (companyAddr) {
|
|
1793
|
-
const
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1793
|
+
const feeOverridePda = PDA.marketFeeOverride(condition, this.programIds)[0];
|
|
1794
|
+
const feeOverrideExists = await this.provider.connection.getAccountInfo(feeOverridePda);
|
|
1795
|
+
if (feeOverrideExists) {
|
|
1796
|
+
const oracleVault = opts?.marketOracleVault ?? this.walletPubkey;
|
|
1797
|
+
feeAccounts = [
|
|
1798
|
+
{ pubkey: this.programIds.feeManagement, isSigner: false, isWritable: false },
|
|
1799
|
+
{ pubkey: PDA.feeConfig(this.feeConfigOwner, this.programIds)[0], isSigner: false, isWritable: false },
|
|
1800
|
+
{ pubkey: feeOverridePda, isSigner: false, isWritable: false },
|
|
1801
|
+
{ pubkey: getAssociatedTokenAddressSync(collateralMint, companyAddr), isSigner: false, isWritable: true },
|
|
1802
|
+
{ pubkey: oracleVault, isSigner: false, isWritable: true }
|
|
1803
|
+
];
|
|
1804
|
+
}
|
|
1801
1805
|
}
|
|
1802
1806
|
}
|
|
1803
|
-
const matchIx = await this.program.methods.matchComplementary(takerNonce, fillAmount, useTakerPrice).accounts({
|
|
1807
|
+
const matchIx = await this.program.methods.matchComplementary(takerNonce, fillAmount, useTakerPrice, skipCrossingCheck).accounts({
|
|
1804
1808
|
operator,
|
|
1805
1809
|
payer: this.walletPubkey,
|
|
1806
1810
|
clobConfig: this.configPda(),
|
|
@@ -1937,7 +1941,7 @@ ${logs.join("\n")}`);
|
|
|
1937
1941
|
{ pubkey: hookConfig, isSigner: false, isWritable: false },
|
|
1938
1942
|
{ pubkey: hookProgram, isSigner: false, isWritable: false }
|
|
1939
1943
|
);
|
|
1940
|
-
const matchIx = await this.program.methods.matchMintOrders(takerNonce, fillAmount).accounts({
|
|
1944
|
+
const matchIx = await this.program.methods.matchMintOrders(takerNonce, fillAmount, true).accounts({
|
|
1941
1945
|
operator: operatorWallet.publicKey,
|
|
1942
1946
|
payer: this.walletPubkey,
|
|
1943
1947
|
clobConfig,
|
|
@@ -2033,17 +2037,21 @@ ${logs.join("\n")}`);
|
|
|
2033
2037
|
if (yesSigned.order.fee.gtn(0) && this.programIds.feeManagement && this.feeConfigOwner) {
|
|
2034
2038
|
const companyAddr = await this.companyAddress();
|
|
2035
2039
|
if (companyAddr) {
|
|
2036
|
-
const
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2040
|
+
const feeOverridePda = PDA.marketFeeOverride(condition, this.programIds)[0];
|
|
2041
|
+
const feeOverrideExists = await this.provider.connection.getAccountInfo(feeOverridePda);
|
|
2042
|
+
if (feeOverrideExists) {
|
|
2043
|
+
const oracleVault = opts?.marketOracleVault ?? this.walletPubkey;
|
|
2044
|
+
remainingAccounts.push(
|
|
2045
|
+
{ pubkey: this.programIds.feeManagement, isSigner: false, isWritable: false },
|
|
2046
|
+
{ pubkey: PDA.feeConfig(this.feeConfigOwner, this.programIds)[0], isSigner: false, isWritable: false },
|
|
2047
|
+
{ pubkey: feeOverridePda, isSigner: false, isWritable: false },
|
|
2048
|
+
{ pubkey: getAssociatedTokenAddressSync(collateralMint, companyAddr), isSigner: false, isWritable: true },
|
|
2049
|
+
{ pubkey: oracleVault, isSigner: false, isWritable: true }
|
|
2050
|
+
);
|
|
2051
|
+
}
|
|
2044
2052
|
}
|
|
2045
2053
|
}
|
|
2046
|
-
const matchIx = await this.program.methods.matchMergeOrders(takerNonce, fillAmount).accounts({
|
|
2054
|
+
const matchIx = await this.program.methods.matchMergeOrders(takerNonce, fillAmount, true).accounts({
|
|
2047
2055
|
operator: operatorWallet.publicKey,
|
|
2048
2056
|
payer: this.walletPubkey,
|
|
2049
2057
|
clobConfig,
|
|
@@ -2116,17 +2124,6 @@ ${logs.join("\n")}`);
|
|
|
2116
2124
|
} else {
|
|
2117
2125
|
throw new InvalidParamError("COMPLEMENTARY requires one BUY and one or more SELLs on same tokenId");
|
|
2118
2126
|
}
|
|
2119
|
-
const buy = buySignedOrder.order;
|
|
2120
|
-
const totalSellDemand = sellCandidates.reduce(
|
|
2121
|
-
(acc, s) => acc + BigInt(s.order.takerAmount.toString()),
|
|
2122
|
-
BigInt(0)
|
|
2123
|
-
);
|
|
2124
|
-
const buyBudget = BigInt(buy.makerAmount.toString());
|
|
2125
|
-
if (buyBudget < totalSellDemand) {
|
|
2126
|
-
throw new InvalidParamError(
|
|
2127
|
-
`COMPLEMENTARY: total sell demand ${totalSellDemand} > buy budget ${buyBudget}. Build taker order with limitPrice, not averageMatchedPrice.`
|
|
2128
|
-
);
|
|
2129
|
-
}
|
|
2130
2127
|
const finalSells = sellCandidates;
|
|
2131
2128
|
return this.matchComplementary(buySignedOrder, finalSells, collateralMint, feeRecipient, operatorWallet, alt, opts);
|
|
2132
2129
|
}
|
|
@@ -8828,6 +8825,10 @@ var clob_exchange_default = {
|
|
|
8828
8825
|
{
|
|
8829
8826
|
name: "use_taker_price",
|
|
8830
8827
|
type: "bool"
|
|
8828
|
+
},
|
|
8829
|
+
{
|
|
8830
|
+
name: "skip_crossing_check",
|
|
8831
|
+
type: "bool"
|
|
8831
8832
|
}
|
|
8832
8833
|
]
|
|
8833
8834
|
},
|
|
@@ -9103,6 +9104,10 @@ var clob_exchange_default = {
|
|
|
9103
9104
|
{
|
|
9104
9105
|
name: "fill_amount",
|
|
9105
9106
|
type: "u64"
|
|
9107
|
+
},
|
|
9108
|
+
{
|
|
9109
|
+
name: "skip_crossing_check",
|
|
9110
|
+
type: "bool"
|
|
9106
9111
|
}
|
|
9107
9112
|
]
|
|
9108
9113
|
},
|
|
@@ -9394,6 +9399,10 @@ var clob_exchange_default = {
|
|
|
9394
9399
|
{
|
|
9395
9400
|
name: "fill_amount",
|
|
9396
9401
|
type: "u64"
|
|
9402
|
+
},
|
|
9403
|
+
{
|
|
9404
|
+
name: "skip_crossing_check",
|
|
9405
|
+
type: "bool"
|
|
9397
9406
|
}
|
|
9398
9407
|
]
|
|
9399
9408
|
},
|