@triadxyz/triad-protocol 4.2.8 → 4.2.9

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.
@@ -13,6 +13,11 @@ export default class Predictor {
13
13
  * @param customerId - Customer ID
14
14
  */
15
15
  getPredictor(authority: PublicKey, customerId: number): Promise<PredictorType>;
16
+ /**
17
+ * Get predictor by address
18
+ * @param address - Predictor address
19
+ */
20
+ getPredictorByAddress(address: string): Promise<PredictorType>;
16
21
  /**
17
22
  * Get User Orders
18
23
  * @param wallet - User wallet PublicKey
package/dist/predictor.js CHANGED
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ const web3_js_1 = require("@solana/web3.js");
15
16
  const bn_js_1 = __importDefault(require("bn.js"));
16
17
  const constants_1 = require("./utils/constants");
17
18
  const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersionedTransaction"));
@@ -47,6 +48,16 @@ class Predictor {
47
48
  }
48
49
  });
49
50
  }
51
+ /**
52
+ * Get predictor by address
53
+ * @param address - Predictor address
54
+ */
55
+ getPredictorByAddress(address) {
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ const predictor = yield this.program.account.predictor.fetch(new web3_js_1.PublicKey(address), this.rpcOptions.commitment);
58
+ return (0, helpers_1.formatPredictor)(predictor, new web3_js_1.PublicKey(address));
59
+ });
60
+ }
50
61
  /**
51
62
  * Get User Orders
52
63
  * @param wallet - User wallet PublicKey
package/dist/trade.d.ts CHANGED
@@ -33,7 +33,7 @@ export default class Trade {
33
33
  * @param args.orders.price - The price of the Order
34
34
  * @param args.orders.orderDirection - The direction of the Order
35
35
  */
36
- placeBidOrder({ orders, customerId }: PlaceBidOrderArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
36
+ placeBidOrder({ orders }: PlaceBidOrderArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
37
37
  /**
38
38
  * Place Ask Order
39
39
  * @param args.orders - Array of orders to execute
@@ -42,14 +42,14 @@ export default class Trade {
42
42
  * @param args.orders.marketId - The Id from the market
43
43
  * @param args.orders.orderDirection - The direction of the Order
44
44
  */
45
- placeAskOrder({ orders, customerId }: PlaceAskOrderArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
45
+ placeAskOrder({ orders }: PlaceAskOrderArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
46
46
  /**
47
47
  * Cancel Bid Order
48
48
  * @param args.orders.bookOrderId - The ID of the Book Order
49
49
  * @param args.orders.marketId - The ID of the Market
50
50
  * @param args.orders.orderDirection - The direction of the Order
51
51
  */
52
- cancelBidOrder({ orders, customerId }: CancelBidOrderArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
52
+ cancelBidOrder({ orders }: CancelBidOrderArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
53
53
  /**
54
54
  * Cancel Ask Order
55
55
  * @param args.orders.marketId - The ID of the Market
@@ -57,7 +57,7 @@ export default class Trade {
57
57
  * @param args.orders.bookOrderId - The ID of the Book Order
58
58
  * @param args.orders.orderDirection - The direction of the Order
59
59
  */
60
- cancelAskOrder({ orders, customerId }: CancelAskOrderArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
60
+ cancelAskOrder({ orders }: CancelAskOrderArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
61
61
  /**
62
62
  * Market Bid Order
63
63
  * @param args.marketId - The ID of the Market
package/dist/trade.js CHANGED
@@ -67,11 +67,11 @@ class Trade {
67
67
  * @param args.orders.price - The price of the Order
68
68
  * @param args.orders.orderDirection - The direction of the Order
69
69
  */
70
- placeBidOrder({ orders, customerId }) {
70
+ placeBidOrder({ orders }) {
71
71
  return __awaiter(this, void 0, void 0, function* () {
72
72
  const ixs = [];
73
- const predictorPDA = (0, pda_1.getPredictorPDA)(this.program.programId, this.program.provider.publicKey, customerId);
74
73
  for (const order of orders) {
74
+ const predictorPDA = (0, pda_1.getPredictorPDA)(this.program.programId, this.program.provider.publicKey, order.customerId);
75
75
  ixs.push(yield this.program.methods
76
76
  .placeBidOrder({
77
77
  amount: new bn_js_1.default(order.amount * Math.pow(10, constants_1.BASE_DECIMALS)),
@@ -100,11 +100,11 @@ class Trade {
100
100
  * @param args.orders.marketId - The Id from the market
101
101
  * @param args.orders.orderDirection - The direction of the Order
102
102
  */
103
- placeAskOrder({ orders, customerId }) {
103
+ placeAskOrder({ orders }) {
104
104
  return __awaiter(this, void 0, void 0, function* () {
105
105
  const ixs = [];
106
- const predictorPDA = (0, pda_1.getPredictorPDA)(this.program.programId, this.program.provider.publicKey, customerId);
107
106
  for (const order of orders) {
107
+ const predictorPDA = (0, pda_1.getPredictorPDA)(this.program.programId, this.program.provider.publicKey, order.customerId);
108
108
  ixs.push(yield this.program.methods
109
109
  .placeAskOrder({
110
110
  shares: new bn_js_1.default(order.amount * Math.pow(10, constants_1.BASE_DECIMALS)),
@@ -129,7 +129,7 @@ class Trade {
129
129
  * @param args.orders.marketId - The ID of the Market
130
130
  * @param args.orders.orderDirection - The direction of the Order
131
131
  */
132
- cancelBidOrder({ orders, customerId }) {
132
+ cancelBidOrder({ orders }) {
133
133
  return __awaiter(this, void 0, void 0, function* () {
134
134
  const ixs = [];
135
135
  for (const order of orders) {
@@ -140,8 +140,8 @@ class Trade {
140
140
  orderDirection: order.orderDirection
141
141
  })
142
142
  .accounts({
143
- signer: new web3_js_1.PublicKey(order.authority),
144
- predictor: (0, pda_1.getPredictorPDA)(this.program.programId, new web3_js_1.PublicKey(order.authority), customerId),
143
+ signer: order.authority,
144
+ predictor: order.predictor,
145
145
  market: (0, pda_1.getMarketPDA)(this.program.programId, order.marketId),
146
146
  orderBook: (0, pda_1.getOrderBookPDA)(this.program.programId, order.marketId)
147
147
  })
@@ -157,10 +157,9 @@ class Trade {
157
157
  * @param args.orders.bookOrderId - The ID of the Book Order
158
158
  * @param args.orders.orderDirection - The direction of the Order
159
159
  */
160
- cancelAskOrder({ orders, customerId }) {
160
+ cancelAskOrder({ orders }) {
161
161
  return __awaiter(this, void 0, void 0, function* () {
162
162
  const ixs = [];
163
- const predictorPDA = (0, pda_1.getPredictorPDA)(this.program.programId, this.program.provider.publicKey, customerId);
164
163
  for (const order of orders) {
165
164
  ixs.push(yield this.program.methods
166
165
  .cancelAskOrder({
@@ -171,10 +170,10 @@ class Trade {
171
170
  .accounts({
172
171
  signer: order.authority,
173
172
  payer: this.rpcOptions.payer,
174
- predictor: predictorPDA,
173
+ predictor: order.predictor,
175
174
  market: (0, pda_1.getMarketPDA)(this.program.programId, order.marketId),
176
175
  orderBook: (0, pda_1.getOrderBookPDA)(this.program.programId, order.marketId),
177
- predictorOrder: (0, pda_1.getPredictorOrderPDA)(this.program.programId, predictorPDA, order.marketId, (0, helpers_1.getOrderDirection)(order.orderDirection))
176
+ predictorOrder: (0, pda_1.getPredictorOrderPDA)(this.program.programId, order.predictor, order.marketId, (0, helpers_1.getOrderDirection)(order.orderDirection))
178
177
  })
179
178
  .instruction());
180
179
  }
@@ -320,7 +319,7 @@ class Trade {
320
319
  return __awaiter(this, void 0, void 0, function* () {
321
320
  const ixs = [];
322
321
  for (const order of orders) {
323
- const predictorPDA = (0, pda_1.getPredictorPDA)(this.program.programId, this.program.provider.publicKey, order.customerId);
322
+ const predictorPDA = (0, pda_1.getPredictorPDA)(this.program.programId, order.authority, order.customerId);
324
323
  ixs.push(yield this.program.methods
325
324
  .payoutOrder()
326
325
  .accounts({
@@ -1160,38 +1160,6 @@
1160
1160
  }
1161
1161
  ]
1162
1162
  },
1163
- {
1164
- "name": "migrate_order",
1165
- "discriminator": [177, 81, 189, 119, 98, 91, 63, 189],
1166
- "accounts": [
1167
- {
1168
- "name": "signer",
1169
- "writable": true
1170
- },
1171
- {
1172
- "name": "payer",
1173
- "writable": true,
1174
- "signer": true
1175
- },
1176
- {
1177
- "name": "order",
1178
- "writable": true
1179
- },
1180
- {
1181
- "name": "predictor",
1182
- "writable": true
1183
- },
1184
- {
1185
- "name": "predictor_order",
1186
- "writable": true
1187
- },
1188
- {
1189
- "name": "system_program",
1190
- "address": "11111111111111111111111111111111"
1191
- }
1192
- ],
1193
- "args": []
1194
- },
1195
1163
  {
1196
1164
  "name": "migrate_stake",
1197
1165
  "discriminator": [178, 5, 26, 85, 56, 20, 153, 160],
@@ -1994,10 +1962,6 @@
1994
1962
  "name": "OrderBook",
1995
1963
  "discriminator": [55, 230, 125, 218, 149, 39, 65, 248]
1996
1964
  },
1997
- {
1998
- "name": "OrderV2",
1999
- "discriminator": [150, 42, 80, 18, 62, 128, 236, 76]
2000
- },
2001
1965
  {
2002
1966
  "name": "Pool",
2003
1967
  "discriminator": [241, 154, 109, 4, 17, 177, 109, 188]
@@ -3462,62 +3426,6 @@
3462
3426
  ]
3463
3427
  }
3464
3428
  },
3465
- {
3466
- "name": "OrderV2",
3467
- "type": {
3468
- "kind": "struct",
3469
- "fields": [
3470
- {
3471
- "name": "authority",
3472
- "type": "pubkey"
3473
- },
3474
- {
3475
- "name": "market_id",
3476
- "type": "u64"
3477
- },
3478
- {
3479
- "name": "shares",
3480
- "type": "u64"
3481
- },
3482
- {
3483
- "name": "price",
3484
- "type": "u64"
3485
- },
3486
- {
3487
- "name": "order_status",
3488
- "type": {
3489
- "defined": {
3490
- "name": "OrderStatus"
3491
- }
3492
- }
3493
- },
3494
- {
3495
- "name": "order_type",
3496
- "type": {
3497
- "defined": {
3498
- "name": "OrderType"
3499
- }
3500
- }
3501
- },
3502
- {
3503
- "name": "order_direction",
3504
- "type": {
3505
- "defined": {
3506
- "name": "OrderDirection"
3507
- }
3508
- }
3509
- },
3510
- {
3511
- "name": "order_side",
3512
- "type": {
3513
- "defined": {
3514
- "name": "OrderSide"
3515
- }
3516
- }
3517
- }
3518
- ]
3519
- }
3520
- },
3521
3429
  {
3522
3430
  "name": "PlaceAskOrderArgs",
3523
3431
  "type": {
@@ -7,8 +7,8 @@ export type PlaceBidOrderArgs = {
7
7
  price: number;
8
8
  orderDirection: OrderDirectionEncoded;
9
9
  marketId: number;
10
+ customerId: number;
10
11
  }[];
11
- customerId: number;
12
12
  };
13
13
  export type PlaceAskOrderArgs = {
14
14
  orders: {
@@ -16,26 +16,26 @@ export type PlaceAskOrderArgs = {
16
16
  price: number;
17
17
  orderDirection: OrderDirectionEncoded;
18
18
  marketId: number;
19
+ customerId: number;
19
20
  }[];
20
- customerId: number;
21
21
  };
22
22
  export type CancelBidOrderArgs = {
23
23
  orders: {
24
24
  authority: PublicKey;
25
+ predictor: PublicKey;
25
26
  marketId: number;
26
27
  bookOrderId: number;
27
28
  orderDirection: OrderDirectionEncoded;
28
29
  }[];
29
- customerId: number;
30
30
  };
31
31
  export type CancelAskOrderArgs = {
32
32
  orders: {
33
33
  authority: PublicKey;
34
+ predictor: PublicKey;
34
35
  marketId: number;
35
36
  bookOrderId: number;
36
37
  orderDirection: OrderDirectionEncoded;
37
38
  }[];
38
- customerId: number;
39
39
  };
40
40
  export type MarketBidOrderArgs = {
41
41
  marketId: number;
@@ -1490,38 +1490,6 @@ export type TriadProtocol = {
1490
1490
  }
1491
1491
  ];
1492
1492
  },
1493
- {
1494
- name: 'migrateOrder';
1495
- discriminator: [177, 81, 189, 119, 98, 91, 63, 189];
1496
- accounts: [
1497
- {
1498
- name: 'signer';
1499
- writable: true;
1500
- },
1501
- {
1502
- name: 'payer';
1503
- writable: true;
1504
- signer: true;
1505
- },
1506
- {
1507
- name: 'order';
1508
- writable: true;
1509
- },
1510
- {
1511
- name: 'predictor';
1512
- writable: true;
1513
- },
1514
- {
1515
- name: 'predictorOrder';
1516
- writable: true;
1517
- },
1518
- {
1519
- name: 'systemProgram';
1520
- address: '11111111111111111111111111111111';
1521
- }
1522
- ];
1523
- args: [];
1524
- },
1525
1493
  {
1526
1494
  name: 'migrateStake';
1527
1495
  discriminator: [178, 5, 26, 85, 56, 20, 153, 160];
@@ -2549,10 +2517,6 @@ export type TriadProtocol = {
2549
2517
  name: 'orderBook';
2550
2518
  discriminator: [55, 230, 125, 218, 149, 39, 65, 248];
2551
2519
  },
2552
- {
2553
- name: 'orderV2';
2554
- discriminator: [150, 42, 80, 18, 62, 128, 236, 76];
2555
- },
2556
2520
  {
2557
2521
  name: 'pool';
2558
2522
  discriminator: [241, 154, 109, 4, 17, 177, 109, 188];
@@ -4017,62 +3981,6 @@ export type TriadProtocol = {
4017
3981
  ];
4018
3982
  };
4019
3983
  },
4020
- {
4021
- name: 'orderV2';
4022
- type: {
4023
- kind: 'struct';
4024
- fields: [
4025
- {
4026
- name: 'authority';
4027
- type: 'pubkey';
4028
- },
4029
- {
4030
- name: 'marketId';
4031
- type: 'u64';
4032
- },
4033
- {
4034
- name: 'shares';
4035
- type: 'u64';
4036
- },
4037
- {
4038
- name: 'price';
4039
- type: 'u64';
4040
- },
4041
- {
4042
- name: 'orderStatus';
4043
- type: {
4044
- defined: {
4045
- name: 'orderStatus';
4046
- };
4047
- };
4048
- },
4049
- {
4050
- name: 'orderType';
4051
- type: {
4052
- defined: {
4053
- name: 'orderType';
4054
- };
4055
- };
4056
- },
4057
- {
4058
- name: 'orderDirection';
4059
- type: {
4060
- defined: {
4061
- name: 'orderDirection';
4062
- };
4063
- };
4064
- },
4065
- {
4066
- name: 'orderSide';
4067
- type: {
4068
- defined: {
4069
- name: 'orderSide';
4070
- };
4071
- };
4072
- }
4073
- ];
4074
- };
4075
- },
4076
3984
  {
4077
3985
  name: 'placeAskOrderArgs';
4078
3986
  type: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "4.2.8",
3
+ "version": "4.2.9",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",