@triadxyz/triad-protocol 2.0.0-beta → 2.0.1-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/trade.js
CHANGED
|
@@ -568,6 +568,20 @@ class Trade {
|
|
|
568
568
|
if (order.authority === this.program.provider.publicKey.toBase58()) {
|
|
569
569
|
continue;
|
|
570
570
|
}
|
|
571
|
+
let linkedSellerBidTradePDA = null;
|
|
572
|
+
if (order.linkedBidOrderId !== '0') {
|
|
573
|
+
const userOrders = yield this.getUserOrders(new web3_js_1.PublicKey(order.authority));
|
|
574
|
+
let linkedSellerBidTradePDA = (0, pda_1.getUserTradePDA)(this.program.programId, new web3_js_1.PublicKey(order.authority));
|
|
575
|
+
const linkedBidOrder = userOrders.find((order) => order.orderId === order.linkedBidOrderId &&
|
|
576
|
+
order.marketId === marketId.toString());
|
|
577
|
+
if (!linkedBidOrder) {
|
|
578
|
+
throw new Error('Linked bid order not found');
|
|
579
|
+
}
|
|
580
|
+
if (linkedBidOrder.userNonce !== '0') {
|
|
581
|
+
const subUserTradePDA = (0, pda_1.getSubUserTradePDA)(this.program.programId, new web3_js_1.PublicKey(order.authority), Number(linkedBidOrder.userNonce));
|
|
582
|
+
linkedSellerBidTradePDA = (0, pda_1.getUserTradePDA)(this.program.programId, subUserTradePDA);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
571
585
|
const orderPrice = Number(order.price);
|
|
572
586
|
const maxSharesForPrice = remainingUSDC / orderPrice;
|
|
573
587
|
const availableShares = Number(order.totalShares);
|
|
@@ -594,7 +608,8 @@ class Trade {
|
|
|
594
608
|
tokenProgram,
|
|
595
609
|
sellerAuthority: new web3_js_1.PublicKey(order.authority),
|
|
596
610
|
marketAta: (0, pda_2.getTokenATA)(marketPDA, mint, tokenProgram),
|
|
597
|
-
buyerAta: (0, pda_2.getTokenATA)(this.program.provider.publicKey, mint, tokenProgram)
|
|
611
|
+
buyerAta: (0, pda_2.getTokenATA)(this.program.provider.publicKey, mint, tokenProgram),
|
|
612
|
+
linkedSellerBidTrade: linkedSellerBidTradePDA
|
|
598
613
|
})
|
|
599
614
|
.instruction());
|
|
600
615
|
remainingUSDC -= usdcAmount;
|