@theliem/xmarket-sdk 3.4.0 → 3.4.1
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.js +21 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1891,13 +1891,30 @@ ${logs.join("\n")}`);
|
|
|
1891
1891
|
const SIDE_BUY = 0;
|
|
1892
1892
|
const SIDE_SELL = 1;
|
|
1893
1893
|
if (t.tokenId === m0.tokenId) {
|
|
1894
|
+
let buySignedOrder, sellCandidates;
|
|
1894
1895
|
if (t.side === SIDE_BUY && makers.every((m) => m.order.side === SIDE_SELL)) {
|
|
1895
|
-
|
|
1896
|
+
buySignedOrder = taker;
|
|
1897
|
+
sellCandidates = makers;
|
|
1898
|
+
} else if (t.side === SIDE_SELL && makers.every((m) => m.order.side === SIDE_BUY)) {
|
|
1899
|
+
buySignedOrder = makers[0];
|
|
1900
|
+
sellCandidates = [taker, ...makers.slice(1)];
|
|
1901
|
+
} else {
|
|
1902
|
+
throw new InvalidParamError("COMPLEMENTARY requires one BUY and one or more SELLs on same tokenId");
|
|
1896
1903
|
}
|
|
1897
|
-
|
|
1898
|
-
|
|
1904
|
+
const crossingSells = sellCandidates.filter((s) => {
|
|
1905
|
+
const buy = buySignedOrder.order;
|
|
1906
|
+
const sell = s.order;
|
|
1907
|
+
const lhs = BigInt(buy.makerAmount.toString()) * BigInt(sell.makerAmount.toString());
|
|
1908
|
+
const rhs = BigInt(buy.takerAmount.toString()) * BigInt(sell.takerAmount.toString());
|
|
1909
|
+
return lhs >= rhs;
|
|
1910
|
+
});
|
|
1911
|
+
if (crossingSells.length === 0) {
|
|
1912
|
+
throw new InvalidParamError("COMPLEMENTARY: no maker orders cross with the buy order");
|
|
1899
1913
|
}
|
|
1900
|
-
|
|
1914
|
+
if (crossingSells.length < sellCandidates.length) {
|
|
1915
|
+
console.warn(`[matchOrders] filtered ${sellCandidates.length - crossingSells.length} non-crossing maker(s)`);
|
|
1916
|
+
}
|
|
1917
|
+
return this.matchComplementary(buySignedOrder, crossingSells, collateralMint, feeRecipient, operatorWallet, alt, opts);
|
|
1901
1918
|
}
|
|
1902
1919
|
const allBuy = t.side === SIDE_BUY && makers.every((m) => m.order.side === SIDE_BUY);
|
|
1903
1920
|
const allSell = t.side === SIDE_SELL && makers.every((m) => m.order.side === SIDE_SELL);
|