@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.mjs
CHANGED
|
@@ -1865,13 +1865,30 @@ ${logs.join("\n")}`);
|
|
|
1865
1865
|
const SIDE_BUY = 0;
|
|
1866
1866
|
const SIDE_SELL = 1;
|
|
1867
1867
|
if (t.tokenId === m0.tokenId) {
|
|
1868
|
+
let buySignedOrder, sellCandidates;
|
|
1868
1869
|
if (t.side === SIDE_BUY && makers.every((m) => m.order.side === SIDE_SELL)) {
|
|
1869
|
-
|
|
1870
|
+
buySignedOrder = taker;
|
|
1871
|
+
sellCandidates = makers;
|
|
1872
|
+
} else if (t.side === SIDE_SELL && makers.every((m) => m.order.side === SIDE_BUY)) {
|
|
1873
|
+
buySignedOrder = makers[0];
|
|
1874
|
+
sellCandidates = [taker, ...makers.slice(1)];
|
|
1875
|
+
} else {
|
|
1876
|
+
throw new InvalidParamError("COMPLEMENTARY requires one BUY and one or more SELLs on same tokenId");
|
|
1870
1877
|
}
|
|
1871
|
-
|
|
1872
|
-
|
|
1878
|
+
const crossingSells = sellCandidates.filter((s) => {
|
|
1879
|
+
const buy = buySignedOrder.order;
|
|
1880
|
+
const sell = s.order;
|
|
1881
|
+
const lhs = BigInt(buy.makerAmount.toString()) * BigInt(sell.makerAmount.toString());
|
|
1882
|
+
const rhs = BigInt(buy.takerAmount.toString()) * BigInt(sell.takerAmount.toString());
|
|
1883
|
+
return lhs >= rhs;
|
|
1884
|
+
});
|
|
1885
|
+
if (crossingSells.length === 0) {
|
|
1886
|
+
throw new InvalidParamError("COMPLEMENTARY: no maker orders cross with the buy order");
|
|
1873
1887
|
}
|
|
1874
|
-
|
|
1888
|
+
if (crossingSells.length < sellCandidates.length) {
|
|
1889
|
+
console.warn(`[matchOrders] filtered ${sellCandidates.length - crossingSells.length} non-crossing maker(s)`);
|
|
1890
|
+
}
|
|
1891
|
+
return this.matchComplementary(buySignedOrder, crossingSells, collateralMint, feeRecipient, operatorWallet, alt, opts);
|
|
1875
1892
|
}
|
|
1876
1893
|
const allBuy = t.side === SIDE_BUY && makers.every((m) => m.order.side === SIDE_BUY);
|
|
1877
1894
|
const allSell = t.side === SIDE_SELL && makers.every((m) => m.order.side === SIDE_SELL);
|