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