@triadxyz/triad-protocol 3.3.5-beta → 3.3.6-beta
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 +9 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1038,6 +1038,7 @@ class TriadProtocol {
|
|
|
1038
1038
|
const marketPDA = (0, pda_1.getMarketPDA)(this.program.programId, marketId);
|
|
1039
1039
|
const ixs = [];
|
|
1040
1040
|
const addressLookupTableAccounts = [];
|
|
1041
|
+
const buyerTradeIxs = [];
|
|
1041
1042
|
const orderBook = yield this.getOrderBook(marketId);
|
|
1042
1043
|
const bidOrders = Object.keys(orderDirection)[0] === 'hype'
|
|
1043
1044
|
? orderBook.hype.bid
|
|
@@ -1062,6 +1063,10 @@ class TriadProtocol {
|
|
|
1062
1063
|
const effectivePriceDecimal = (0, feeCalculator_1.applySellFee)(orderPrice.toNumber() / 1000000);
|
|
1063
1064
|
const adjustedPrice = new bn_js_1.default(Math.floor(effectivePriceDecimal * 1000000));
|
|
1064
1065
|
amountOfUSDC = amountOfUSDC.add(sharesToSell.mul(adjustedPrice).div(new bn_js_1.default(Math.pow(10, constants_1.BASE_DECIMALS))));
|
|
1066
|
+
const { userTradePDA: buyerTradePDA, userTradeIxs: innerBuyerTradeIxs } = yield this.getUserTradeNonce(new web3_js_1.PublicKey(order.authority), marketId, Object.keys(orderDirection)[0]);
|
|
1067
|
+
if (innerBuyerTradeIxs.length > 0 && buyerTradeIxs.length === 0) {
|
|
1068
|
+
buyerTradeIxs.push(...innerBuyerTradeIxs);
|
|
1069
|
+
}
|
|
1065
1070
|
ixs.push(yield this.program.methods
|
|
1066
1071
|
.marketAskOrder({
|
|
1067
1072
|
shares: new bn_js_1.default(sharesToSell),
|
|
@@ -1074,7 +1079,7 @@ class TriadProtocol {
|
|
|
1074
1079
|
payer: this.rpcOptions.payer,
|
|
1075
1080
|
market: marketPDA,
|
|
1076
1081
|
buyerAuthority: new web3_js_1.PublicKey(order.authority),
|
|
1077
|
-
buyerTrade:
|
|
1082
|
+
buyerTrade: buyerTradePDA,
|
|
1078
1083
|
orderBook: (0, pda_1.getOrderBookPDA)(this.program.programId, marketId),
|
|
1079
1084
|
marketAta: (0, pda_1.getTokenATA)(marketPDA, constants_1.USDC_MINT, spl_token_1.TOKEN_PROGRAM_ID),
|
|
1080
1085
|
sellerTrade: this.getUserPDA(this.program.provider.publicKey, inputOrder.userNonce)
|
|
@@ -1097,6 +1102,9 @@ class TriadProtocol {
|
|
|
1097
1102
|
addressLookupTableAccounts.push(...swapAddressLookupTableAccounts);
|
|
1098
1103
|
}
|
|
1099
1104
|
}
|
|
1105
|
+
if (buyerTradeIxs.length > 0) {
|
|
1106
|
+
ixs.unshift(...buyerTradeIxs);
|
|
1107
|
+
}
|
|
1100
1108
|
if (ixs.length === 0) {
|
|
1101
1109
|
throw new Error('No matching orders found to fill the requested amount');
|
|
1102
1110
|
}
|