@theliem/xmarket-sdk 3.6.0 → 3.6.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 +12 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1853,18 +1853,20 @@ ${logs.join("\n")}`);
|
|
|
1853
1853
|
...buyMakers.map((m) => this.registerOrderIfNeeded(m))
|
|
1854
1854
|
]);
|
|
1855
1855
|
const sell = sellTaker.order;
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
const lhs = BigInt(buy.makerAmount.toString()) * BigInt(sell.makerAmount.toString());
|
|
1859
|
-
const rhs = BigInt(buy.takerAmount.toString()) * BigInt(sell.takerAmount.toString());
|
|
1860
|
-
return lhs >= rhs;
|
|
1861
|
-
});
|
|
1862
|
-
if (crossingBuys.length === 0) {
|
|
1863
|
-
throw new InvalidParamError("COMPLEMENTARY: no BUY maker orders cross with the SELL taker");
|
|
1856
|
+
if (buyMakers.length === 0) {
|
|
1857
|
+
throw new InvalidParamError("COMPLEMENTARY: no BUY maker orders provided");
|
|
1864
1858
|
}
|
|
1865
|
-
|
|
1866
|
-
|
|
1859
|
+
const totalBuyPayment = buyMakers.reduce(
|
|
1860
|
+
(acc, b) => acc + BigInt(b.order.makerAmount.toString()),
|
|
1861
|
+
BigInt(0)
|
|
1862
|
+
);
|
|
1863
|
+
const sellExpected = BigInt(sell.takerAmount.toString());
|
|
1864
|
+
if (totalBuyPayment < sellExpected) {
|
|
1865
|
+
throw new InvalidParamError(
|
|
1866
|
+
`COMPLEMENTARY: total buyer payments ${totalBuyPayment} < seller expected ${sellExpected}`
|
|
1867
|
+
);
|
|
1867
1868
|
}
|
|
1869
|
+
const crossingBuys = buyMakers;
|
|
1868
1870
|
const allIxs = [];
|
|
1869
1871
|
for (const buyMaker of crossingBuys) {
|
|
1870
1872
|
const ixs = await this.buildMatchComplementaryIxs(
|