@triadxyz/triad-protocol 2.0.0-beta → 2.0.2-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,22 @@ 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
|
+
console.log('userOrders', userOrders);
|
|
578
|
+
console.log('linkedBidOrder', linkedBidOrder);
|
|
579
|
+
if (!linkedBidOrder) {
|
|
580
|
+
throw new Error('Linked bid order not found');
|
|
581
|
+
}
|
|
582
|
+
if (linkedBidOrder.userNonce !== '0') {
|
|
583
|
+
const subUserTradePDA = (0, pda_1.getSubUserTradePDA)(this.program.programId, new web3_js_1.PublicKey(order.authority), Number(linkedBidOrder.userNonce));
|
|
584
|
+
linkedSellerBidTradePDA = (0, pda_1.getUserTradePDA)(this.program.programId, subUserTradePDA);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
571
587
|
const orderPrice = Number(order.price);
|
|
572
588
|
const maxSharesForPrice = remainingUSDC / orderPrice;
|
|
573
589
|
const availableShares = Number(order.totalShares);
|
|
@@ -594,7 +610,8 @@ class Trade {
|
|
|
594
610
|
tokenProgram,
|
|
595
611
|
sellerAuthority: new web3_js_1.PublicKey(order.authority),
|
|
596
612
|
marketAta: (0, pda_2.getTokenATA)(marketPDA, mint, tokenProgram),
|
|
597
|
-
buyerAta: (0, pda_2.getTokenATA)(this.program.provider.publicKey, mint, tokenProgram)
|
|
613
|
+
buyerAta: (0, pda_2.getTokenATA)(this.program.provider.publicKey, mint, tokenProgram),
|
|
614
|
+
linkedSellerBidTrade: linkedSellerBidTradePDA
|
|
598
615
|
})
|
|
599
616
|
.instruction());
|
|
600
617
|
remainingUSDC -= usdcAmount;
|