@theliem/xmarket-sdk 3.6.1 → 3.7.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 +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +27 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -37
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1843,19 +1843,14 @@ ${logs.join("\n")}`);
|
|
|
1843
1843
|
}
|
|
1844
1844
|
/**
|
|
1845
1845
|
* 1 SELL taker vs N BUY makers.
|
|
1846
|
-
*
|
|
1847
|
-
*
|
|
1848
|
-
* Engine must use limitPrice for BUY.makerAmount to pass per-pair crossing check.
|
|
1846
|
+
* Program now supports SELL-as-taker natively → 1 instruction with all BUY makers
|
|
1847
|
+
* in remaining_accounts (same structure as BUY taker case).
|
|
1849
1848
|
*/
|
|
1850
1849
|
async matchComplementarySellVsMultiBuy(sellTaker, buyMakers, collateralMint, feeRecipient, operatorWallet, lookupTable, opts) {
|
|
1851
|
-
await Promise.all([
|
|
1852
|
-
this.registerOrderIfNeeded(sellTaker),
|
|
1853
|
-
...buyMakers.map((m) => this.registerOrderIfNeeded(m))
|
|
1854
|
-
]);
|
|
1855
|
-
const sell = sellTaker.order;
|
|
1856
1850
|
if (buyMakers.length === 0) {
|
|
1857
1851
|
throw new InvalidParamError("COMPLEMENTARY: no BUY maker orders provided");
|
|
1858
1852
|
}
|
|
1853
|
+
const sell = sellTaker.order;
|
|
1859
1854
|
const totalBuyPayment = buyMakers.reduce(
|
|
1860
1855
|
(acc, b) => acc + BigInt(b.order.makerAmount.toString()),
|
|
1861
1856
|
BigInt(0)
|
|
@@ -1866,24 +1861,20 @@ ${logs.join("\n")}`);
|
|
|
1866
1861
|
`COMPLEMENTARY: total buyer payments ${totalBuyPayment} < seller expected ${sellExpected}`
|
|
1867
1862
|
);
|
|
1868
1863
|
}
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
);
|
|
1884
|
-
allIxs.push(...ixs);
|
|
1885
|
-
}
|
|
1886
|
-
const sig = await this.sendMatchTx(allIxs, lookupTable, operatorWallet);
|
|
1864
|
+
await Promise.all([
|
|
1865
|
+
this.registerOrderIfNeeded(sellTaker),
|
|
1866
|
+
...buyMakers.map((m) => this.registerOrderIfNeeded(m))
|
|
1867
|
+
]);
|
|
1868
|
+
const ixs = await this.buildMatchComplementaryIxs(
|
|
1869
|
+
sellTaker,
|
|
1870
|
+
buyMakers,
|
|
1871
|
+
collateralMint,
|
|
1872
|
+
feeRecipient,
|
|
1873
|
+
operatorWallet.publicKey,
|
|
1874
|
+
opts,
|
|
1875
|
+
false
|
|
1876
|
+
);
|
|
1877
|
+
const sig = await this.sendMatchTx(ixs, lookupTable, operatorWallet);
|
|
1887
1878
|
return { signature: sig };
|
|
1888
1879
|
}
|
|
1889
1880
|
/**
|
|
@@ -2126,18 +2117,17 @@ ${logs.join("\n")}`);
|
|
|
2126
2117
|
throw new InvalidParamError("COMPLEMENTARY requires one BUY and one or more SELLs on same tokenId");
|
|
2127
2118
|
}
|
|
2128
2119
|
const buy = buySignedOrder.order;
|
|
2129
|
-
const
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
if (finalSells.length < sellCandidates.length) {
|
|
2139
|
-
console.warn(`[matchOrders] filtered ${sellCandidates.length - finalSells.length} non-crossing maker(s)`);
|
|
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
|
+
);
|
|
2140
2129
|
}
|
|
2130
|
+
const finalSells = sellCandidates;
|
|
2141
2131
|
return this.matchComplementary(buySignedOrder, finalSells, collateralMint, feeRecipient, operatorWallet, alt, opts);
|
|
2142
2132
|
}
|
|
2143
2133
|
const allBuy = t.side === SIDE_BUY && makers.every((m) => m.order.side === SIDE_BUY);
|