@triadxyz/triad-protocol 3.4.3-beta → 3.4.5-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
@@ -71,7 +71,7 @@ class TriadProtocol {
71
71
  const orders = yield this.program.account.orderV2.all([
72
72
  {
73
73
  memcmp: {
74
- offset: 8 + 1,
74
+ offset: 8,
75
75
  bytes: wallet.toBase58()
76
76
  }
77
77
  }
@@ -111,7 +111,7 @@ class TriadProtocol {
111
111
  */
112
112
  getUserBookOrdersByMarketId(wallet, marketId) {
113
113
  return __awaiter(this, void 0, void 0, function* () {
114
- const orderBook = yield this.program.account.orderBook.fetch((0, pda_1.getOrderBookPDA)(this.program.programId, marketId));
114
+ const orderBook = yield this.program.account.orderBook.fetch((0, pda_1.getOrderBookPDA)(this.program.programId, marketId), this.provider.opts.commitment);
115
115
  const orders = [...orderBook.hypeOrders, ...orderBook.flopOrders];
116
116
  return orders
117
117
  .map((order) => (0, helpers_2.formatBookOrder)(order, marketId))
@@ -143,7 +143,7 @@ class TriadProtocol {
143
143
  getCustomerById(customerId) {
144
144
  return __awaiter(this, void 0, void 0, function* () {
145
145
  const customerPDA = (0, pda_1.getCustomerPDA)(this.program.programId, customerId);
146
- const customer = yield this.program.account.customer.fetch(customerPDA);
146
+ const customer = yield this.program.account.customer.fetch(customerPDA, this.provider.opts.commitment);
147
147
  return (0, helpers_2.formatCustomer)(customer, customerPDA);
148
148
  });
149
149
  }
@@ -172,7 +172,7 @@ class TriadProtocol {
172
172
  getPoolById(poolId) {
173
173
  return __awaiter(this, void 0, void 0, function* () {
174
174
  const poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
175
- const response = yield this.program.account.pool.fetch(poolPDA);
175
+ const response = yield this.program.account.pool.fetch(poolPDA, this.provider.opts.commitment);
176
176
  return (0, helpers_1.formatPool)(response, poolPDA);
177
177
  });
178
178
  }
@@ -183,7 +183,7 @@ class TriadProtocol {
183
183
  getMarketById(marketId) {
184
184
  return __awaiter(this, void 0, void 0, function* () {
185
185
  const marketPDA = (0, pda_1.getMarketPDA)(this.program.programId, marketId);
186
- const response = yield this.program.account.marketV2.fetch(marketPDA);
186
+ const response = yield this.program.account.marketV2.fetch(marketPDA, this.provider.opts.commitment);
187
187
  return (0, helpers_1.formatMarket)(response, marketPDA);
188
188
  });
189
189
  }
@@ -193,7 +193,7 @@ class TriadProtocol {
193
193
  */
194
194
  getMarketByAddress(marketAddress) {
195
195
  return __awaiter(this, void 0, void 0, function* () {
196
- const account = yield this.program.account.marketV2.fetch(marketAddress);
196
+ const account = yield this.program.account.marketV2.fetch(marketAddress, this.provider.opts.commitment);
197
197
  return (0, helpers_1.formatMarket)(account, marketAddress);
198
198
  });
199
199
  }
@@ -512,6 +512,7 @@ class TriadProtocol {
512
512
  ixs.push(yield this.program.methods
513
513
  .openOrder({
514
514
  amount: new bn_js_1.default(amountInTRD),
515
+ marketId: new bn_js_1.default(marketId),
515
516
  orderDirection
516
517
  })
517
518
  .accounts({
@@ -640,10 +641,12 @@ class TriadProtocol {
640
641
  .placeBidOrder({
641
642
  amount: new bn_js_1.default(order.amount * Math.pow(10, constants_1.BASE_DECIMALS)),
642
643
  price: new bn_js_1.default(order.price * Math.pow(10, constants_1.BASE_DECIMALS)),
644
+ marketId: new bn_js_1.default(order.marketId),
643
645
  orderDirection: order.orderDirection
644
646
  })
645
647
  .accounts({
646
648
  signer: this.program.provider.publicKey,
649
+ payer: this.rpcOptions.payer,
647
650
  market: (0, pda_1.getMarketPDA)(this.program.programId, order.marketId),
648
651
  orderBook: (0, pda_1.getOrderBookPDA)(this.program.programId, order.marketId)
649
652
  })
@@ -677,6 +680,7 @@ class TriadProtocol {
677
680
  .accounts({
678
681
  signer: this.program.provider.publicKey,
679
682
  market: (0, pda_1.getMarketPDA)(this.program.programId, order.marketId),
683
+ order: (0, pda_1.getOrderPDA)(this.program.programId, this.program.provider.publicKey, order.marketId, (0, helpers_1.getOrderDirection)(order.orderDirection)),
680
684
  orderBook: (0, pda_1.getOrderBookPDA)(this.program.programId, order.marketId)
681
685
  })
682
686
  .instruction());
@@ -734,7 +738,8 @@ class TriadProtocol {
734
738
  .accounts({
735
739
  signer: this.program.provider.publicKey,
736
740
  market: (0, pda_1.getMarketPDA)(this.program.programId, order.marketId),
737
- orderBook: (0, pda_1.getOrderBookPDA)(this.program.programId, order.marketId)
741
+ orderBook: (0, pda_1.getOrderBookPDA)(this.program.programId, order.marketId),
742
+ order: (0, pda_1.getOrderPDA)(this.program.programId, this.program.provider.publicKey, order.marketId, (0, helpers_1.getOrderDirection)(order.orderDirection))
738
743
  })
739
744
  .instruction());
740
745
  }
@@ -833,12 +838,14 @@ class TriadProtocol {
833
838
  ixs.push(yield this.program.methods
834
839
  .marketBidOrder({
835
840
  amount: new bn_js_1.default(usdcAmount),
841
+ marketId: new bn_js_1.default(marketId),
836
842
  orderDirection,
837
843
  bookOrderAskId: new bn_js_1.default(order.id),
838
844
  oppositeOrderDirection: (0, helpers_1.getOppositeOrderDirectionEncoded)(orderDirection)
839
845
  })
840
846
  .accounts({
841
847
  signer: this.program.provider.publicKey,
848
+ payer: this.rpcOptions.payer,
842
849
  market: marketPDA,
843
850
  orderBook: (0, pda_1.getOrderBookPDA)(this.program.programId, marketId),
844
851
  bookOrderAskAuthority: new web3_js_1.PublicKey(order.authority),
@@ -900,7 +907,9 @@ class TriadProtocol {
900
907
  market: marketPDA,
901
908
  buyerAuthority: new web3_js_1.PublicKey(order.authority),
902
909
  orderBook: (0, pda_1.getOrderBookPDA)(this.program.programId, marketId),
903
- marketAta: (0, pda_1.getTokenATA)(marketPDA, constants_1.USDC_MINT, spl_token_1.TOKEN_PROGRAM_ID)
910
+ marketAta: (0, pda_1.getTokenATA)(marketPDA, constants_1.USDC_MINT, spl_token_1.TOKEN_PROGRAM_ID),
911
+ bidOrder: (0, pda_1.getOrderPDA)(this.program.programId, new web3_js_1.PublicKey(order.authority), marketId, (0, helpers_1.getOrderDirection)(orderDirection)),
912
+ askOrder: (0, pda_1.getOrderPDA)(this.program.programId, this.program.provider.publicKey, marketId, (0, helpers_1.getOrderDirection)(orderDirection))
904
913
  })
905
914
  .instruction());
906
915
  }
@@ -165,28 +165,7 @@
165
165
  },
166
166
  {
167
167
  "name": "order",
168
- "writable": true,
169
- "pda": {
170
- "seeds": [
171
- {
172
- "kind": "const",
173
- "value": [111, 114, 100, 101, 114]
174
- },
175
- {
176
- "kind": "account",
177
- "path": "signer"
178
- },
179
- {
180
- "kind": "account",
181
- "path": "market.market_id",
182
- "account": "MarketV2"
183
- },
184
- {
185
- "kind": "arg",
186
- "path": "args.order_direction"
187
- }
188
- ]
189
- }
168
+ "writable": true
190
169
  },
191
170
  {
192
171
  "name": "system_program",
@@ -576,28 +555,7 @@
576
555
  },
577
556
  {
578
557
  "name": "order",
579
- "writable": true,
580
- "pda": {
581
- "seeds": [
582
- {
583
- "kind": "const",
584
- "value": [111, 114, 100, 101, 114]
585
- },
586
- {
587
- "kind": "account",
588
- "path": "signer"
589
- },
590
- {
591
- "kind": "account",
592
- "path": "market.market_id",
593
- "account": "MarketV2"
594
- },
595
- {
596
- "kind": "arg",
597
- "path": "order_direction"
598
- }
599
- ]
600
- }
558
+ "writable": true
601
559
  },
602
560
  {
603
561
  "name": "mint",
@@ -1392,53 +1350,11 @@
1392
1350
  },
1393
1351
  {
1394
1352
  "name": "ask_order",
1395
- "writable": true,
1396
- "pda": {
1397
- "seeds": [
1398
- {
1399
- "kind": "const",
1400
- "value": [111, 114, 100, 101, 114]
1401
- },
1402
- {
1403
- "kind": "account",
1404
- "path": "signer"
1405
- },
1406
- {
1407
- "kind": "account",
1408
- "path": "market.market_id",
1409
- "account": "MarketV2"
1410
- },
1411
- {
1412
- "kind": "arg",
1413
- "path": "args.order_direction"
1414
- }
1415
- ]
1416
- }
1353
+ "writable": true
1417
1354
  },
1418
1355
  {
1419
1356
  "name": "bid_order",
1420
- "writable": true,
1421
- "pda": {
1422
- "seeds": [
1423
- {
1424
- "kind": "const",
1425
- "value": [111, 114, 100, 101, 114]
1426
- },
1427
- {
1428
- "kind": "account",
1429
- "path": "buyer_authority"
1430
- },
1431
- {
1432
- "kind": "account",
1433
- "path": "market.market_id",
1434
- "account": "MarketV2"
1435
- },
1436
- {
1437
- "kind": "arg",
1438
- "path": "args.order_direction"
1439
- }
1440
- ]
1441
- }
1357
+ "writable": true
1442
1358
  },
1443
1359
  {
1444
1360
  "name": "buyer_authority",
@@ -1541,9 +1457,8 @@
1541
1457
  "path": "signer"
1542
1458
  },
1543
1459
  {
1544
- "kind": "account",
1545
- "path": "market.market_id",
1546
- "account": "MarketV2"
1460
+ "kind": "arg",
1461
+ "path": "args.market_id"
1547
1462
  },
1548
1463
  {
1549
1464
  "kind": "arg",
@@ -1763,9 +1678,8 @@
1763
1678
  "path": "signer"
1764
1679
  },
1765
1680
  {
1766
- "kind": "account",
1767
- "path": "market.market_id",
1768
- "account": "MarketV2"
1681
+ "kind": "arg",
1682
+ "path": "args.market_id"
1769
1683
  },
1770
1684
  {
1771
1685
  "kind": "arg",
@@ -1877,28 +1791,7 @@
1877
1791
  },
1878
1792
  {
1879
1793
  "name": "order",
1880
- "writable": true,
1881
- "pda": {
1882
- "seeds": [
1883
- {
1884
- "kind": "const",
1885
- "value": [111, 114, 100, 101, 114]
1886
- },
1887
- {
1888
- "kind": "account",
1889
- "path": "signer"
1890
- },
1891
- {
1892
- "kind": "account",
1893
- "path": "market.market_id",
1894
- "account": "MarketV2"
1895
- },
1896
- {
1897
- "kind": "arg",
1898
- "path": "order_direction"
1899
- }
1900
- ]
1901
- }
1794
+ "writable": true
1902
1795
  },
1903
1796
  {
1904
1797
  "name": "mint",
@@ -2002,28 +1895,7 @@
2002
1895
  },
2003
1896
  {
2004
1897
  "name": "order",
2005
- "writable": true,
2006
- "pda": {
2007
- "seeds": [
2008
- {
2009
- "kind": "const",
2010
- "value": [111, 114, 100, 101, 114]
2011
- },
2012
- {
2013
- "kind": "account",
2014
- "path": "signer"
2015
- },
2016
- {
2017
- "kind": "account",
2018
- "path": "market.market_id",
2019
- "account": "MarketV2"
2020
- },
2021
- {
2022
- "kind": "arg",
2023
- "path": "args.order_direction"
2024
- }
2025
- ]
2026
- }
1898
+ "writable": true
2027
1899
  },
2028
1900
  {
2029
1901
  "name": "system_program",
@@ -2077,9 +1949,8 @@
2077
1949
  "path": "signer"
2078
1950
  },
2079
1951
  {
2080
- "kind": "account",
2081
- "path": "market.market_id",
2082
- "account": "MarketV2"
1952
+ "kind": "arg",
1953
+ "path": "args.market_id"
2083
1954
  },
2084
1955
  {
2085
1956
  "kind": "arg",
@@ -3968,6 +3839,10 @@
3968
3839
  }
3969
3840
  }
3970
3841
  },
3842
+ {
3843
+ "name": "market_id",
3844
+ "type": "u64"
3845
+ },
3971
3846
  {
3972
3847
  "name": "opposite_order_direction",
3973
3848
  "type": {
@@ -4313,6 +4188,10 @@
4313
4188
  "name": "amount",
4314
4189
  "type": "u64"
4315
4190
  },
4191
+ {
4192
+ "name": "market_id",
4193
+ "type": "u64"
4194
+ },
4316
4195
  {
4317
4196
  "name": "order_direction",
4318
4197
  "type": {
@@ -4705,6 +4584,10 @@
4705
4584
  "name": "price",
4706
4585
  "type": "u64"
4707
4586
  },
4587
+ {
4588
+ "name": "market_id",
4589
+ "type": "u64"
4590
+ },
4708
4591
  {
4709
4592
  "name": "order_direction",
4710
4593
  "type": {
@@ -242,27 +242,6 @@ export type TriadProtocol = {
242
242
  {
243
243
  name: 'order';
244
244
  writable: true;
245
- pda: {
246
- seeds: [
247
- {
248
- kind: 'const';
249
- value: [111, 114, 100, 101, 114];
250
- },
251
- {
252
- kind: 'account';
253
- path: 'signer';
254
- },
255
- {
256
- kind: 'account';
257
- path: 'market.market_id';
258
- account: 'marketV2';
259
- },
260
- {
261
- kind: 'arg';
262
- path: 'args.order_direction';
263
- }
264
- ];
265
- };
266
245
  },
267
246
  {
268
247
  name: 'systemProgram';
@@ -837,27 +816,6 @@ export type TriadProtocol = {
837
816
  {
838
817
  name: 'order';
839
818
  writable: true;
840
- pda: {
841
- seeds: [
842
- {
843
- kind: 'const';
844
- value: [111, 114, 100, 101, 114];
845
- },
846
- {
847
- kind: 'account';
848
- path: 'signer';
849
- },
850
- {
851
- kind: 'account';
852
- path: 'market.market_id';
853
- account: 'marketV2';
854
- },
855
- {
856
- kind: 'arg';
857
- path: 'orderDirection';
858
- }
859
- ];
860
- };
861
819
  },
862
820
  {
863
821
  name: 'mint';
@@ -1984,52 +1942,10 @@ export type TriadProtocol = {
1984
1942
  {
1985
1943
  name: 'askOrder';
1986
1944
  writable: true;
1987
- pda: {
1988
- seeds: [
1989
- {
1990
- kind: 'const';
1991
- value: [111, 114, 100, 101, 114];
1992
- },
1993
- {
1994
- kind: 'account';
1995
- path: 'signer';
1996
- },
1997
- {
1998
- kind: 'account';
1999
- path: 'market.market_id';
2000
- account: 'marketV2';
2001
- },
2002
- {
2003
- kind: 'arg';
2004
- path: 'args.order_direction';
2005
- }
2006
- ];
2007
- };
2008
1945
  },
2009
1946
  {
2010
1947
  name: 'bidOrder';
2011
1948
  writable: true;
2012
- pda: {
2013
- seeds: [
2014
- {
2015
- kind: 'const';
2016
- value: [111, 114, 100, 101, 114];
2017
- },
2018
- {
2019
- kind: 'account';
2020
- path: 'buyerAuthority';
2021
- },
2022
- {
2023
- kind: 'account';
2024
- path: 'market.market_id';
2025
- account: 'marketV2';
2026
- },
2027
- {
2028
- kind: 'arg';
2029
- path: 'args.order_direction';
2030
- }
2031
- ];
2032
- };
2033
1949
  },
2034
1950
  {
2035
1951
  name: 'buyerAuthority';
@@ -2161,9 +2077,8 @@ export type TriadProtocol = {
2161
2077
  path: 'signer';
2162
2078
  },
2163
2079
  {
2164
- kind: 'account';
2165
- path: 'market.market_id';
2166
- account: 'marketV2';
2080
+ kind: 'arg';
2081
+ path: 'args.market_id';
2167
2082
  },
2168
2083
  {
2169
2084
  kind: 'arg';
@@ -2470,9 +2385,8 @@ export type TriadProtocol = {
2470
2385
  path: 'signer';
2471
2386
  },
2472
2387
  {
2473
- kind: 'account';
2474
- path: 'market.market_id';
2475
- account: 'marketV2';
2388
+ kind: 'arg';
2389
+ path: 'args.market_id';
2476
2390
  },
2477
2391
  {
2478
2392
  kind: 'arg';
@@ -2643,27 +2557,6 @@ export type TriadProtocol = {
2643
2557
  {
2644
2558
  name: 'order';
2645
2559
  writable: true;
2646
- pda: {
2647
- seeds: [
2648
- {
2649
- kind: 'const';
2650
- value: [111, 114, 100, 101, 114];
2651
- },
2652
- {
2653
- kind: 'account';
2654
- path: 'signer';
2655
- },
2656
- {
2657
- kind: 'account';
2658
- path: 'market.market_id';
2659
- account: 'marketV2';
2660
- },
2661
- {
2662
- kind: 'arg';
2663
- path: 'orderDirection';
2664
- }
2665
- ];
2666
- };
2667
2560
  },
2668
2561
  {
2669
2562
  name: 'mint';
@@ -2826,27 +2719,6 @@ export type TriadProtocol = {
2826
2719
  {
2827
2720
  name: 'order';
2828
2721
  writable: true;
2829
- pda: {
2830
- seeds: [
2831
- {
2832
- kind: 'const';
2833
- value: [111, 114, 100, 101, 114];
2834
- },
2835
- {
2836
- kind: 'account';
2837
- path: 'signer';
2838
- },
2839
- {
2840
- kind: 'account';
2841
- path: 'market.market_id';
2842
- account: 'marketV2';
2843
- },
2844
- {
2845
- kind: 'arg';
2846
- path: 'args.order_direction';
2847
- }
2848
- ];
2849
- };
2850
2722
  },
2851
2723
  {
2852
2724
  name: 'systemProgram';
@@ -2900,9 +2772,8 @@ export type TriadProtocol = {
2900
2772
  path: 'signer';
2901
2773
  },
2902
2774
  {
2903
- kind: 'account';
2904
- path: 'market.market_id';
2905
- account: 'marketV2';
2775
+ kind: 'arg';
2776
+ path: 'args.market_id';
2906
2777
  },
2907
2778
  {
2908
2779
  kind: 'arg';
@@ -5059,6 +4930,10 @@ export type TriadProtocol = {
5059
4930
  };
5060
4931
  };
5061
4932
  },
4933
+ {
4934
+ name: 'marketId';
4935
+ type: 'u64';
4936
+ },
5062
4937
  {
5063
4938
  name: 'oppositeOrderDirection';
5064
4939
  type: {
@@ -5404,6 +5279,10 @@ export type TriadProtocol = {
5404
5279
  name: 'amount';
5405
5280
  type: 'u64';
5406
5281
  },
5282
+ {
5283
+ name: 'marketId';
5284
+ type: 'u64';
5285
+ },
5407
5286
  {
5408
5287
  name: 'orderDirection';
5409
5288
  type: {
@@ -5796,6 +5675,10 @@ export type TriadProtocol = {
5796
5675
  name: 'price';
5797
5676
  type: 'u64';
5798
5677
  },
5678
+ {
5679
+ name: 'marketId';
5680
+ type: 'u64';
5681
+ },
5799
5682
  {
5800
5683
  name: 'orderDirection';
5801
5684
  type: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "3.4.3-beta",
3
+ "version": "3.4.5-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",