@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;
@@ -827,6 +827,11 @@
827
827
  "name": "seller_trade",
828
828
  "writable": true
829
829
  },
830
+ {
831
+ "name": "linked_seller_bid_trade",
832
+ "writable": true,
833
+ "optional": true
834
+ },
830
835
  {
831
836
  "name": "market",
832
837
  "writable": true
@@ -1135,6 +1135,11 @@ export type TriadProtocol = {
1135
1135
  name: 'sellerTrade';
1136
1136
  writable: true;
1137
1137
  },
1138
+ {
1139
+ name: 'linkedSellerBidTrade';
1140
+ writable: true;
1141
+ optional: true;
1142
+ },
1138
1143
  {
1139
1144
  name: 'market';
1140
1145
  writable: true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "2.0.0-beta",
3
+ "version": "2.0.1-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",