@triadxyz/triad-protocol 4.2.2 → 4.2.4

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.
@@ -10,39 +10,39 @@ export default class Predictor {
10
10
  /**
11
11
  * Get predictor
12
12
  * @param authority - Authority public key
13
- * @param customerId - Customer ID (optional) defaults to 7 from Triadmarkets
13
+ * @param customerId - Customer ID
14
14
  */
15
- getPredictor(authority: PublicKey, customerId?: number): Promise<PredictorType>;
15
+ getPredictor(authority: PublicKey, customerId: number): Promise<PredictorType>;
16
16
  /**
17
17
  * Get User Orders
18
18
  * @param wallet - User wallet PublicKey
19
19
  */
20
- getUserOrders(wallet: PublicKey, customerId?: number): Promise<import("./types").PredictorOrder[]>;
20
+ getUserOrders(wallet: PublicKey, customerId: number): Promise<import("./types").PredictorOrder[]>;
21
21
  /**
22
22
  * Get User Orders By Market ID
23
23
  * @param wallet - User wallet PublicKey
24
24
  * @param marketId - The ID of the market
25
25
  */
26
- getUserOrdersByMarketId(wallet: PublicKey, marketId: number, customerId?: number): Promise<import("./types").PredictorOrder[]>;
26
+ getUserOrdersByMarketId(wallet: PublicKey, marketId: number, customerId: number): Promise<import("./types").PredictorOrder[]>;
27
27
  /**
28
28
  * Get all User Book Orders
29
29
  * @param wallet - User wallet PublicKey
30
30
  * @param customerId - User Customer ID
31
31
  */
32
- getUserBookOrders(wallet: PublicKey, customerId?: number): Promise<import("./types").BookOrder[]>;
32
+ getUserBookOrders(wallet: PublicKey, customerId: number): Promise<import("./types").BookOrder[]>;
33
33
  /**
34
34
  * Get User Book Orders By Market ID
35
35
  * @param wallet - User wallet PublicKey
36
36
  * @param marketId - The ID of the market
37
37
  * @param customerId - User Customer ID
38
38
  */
39
- getUserBookOrdersByMarketId(wallet: PublicKey, marketId: number, customerId?: number): Promise<import("./types").BookOrder[]>;
39
+ getUserBookOrdersByMarketId(wallet: PublicKey, marketId: number, customerId: number): Promise<import("./types").BookOrder[]>;
40
40
  /**
41
41
  * Deposit
42
42
  * @param args.authority - Authority of the deposit
43
43
  * @param args.amount - Amount to deposit
44
- * @param args.refer - Referral public key (optional) defaults to Triadmarkets public key
45
- * @param args.customerId - Customer ID (optional) defaults to 7 from Triadmarkets
44
+ * @param args.refer - Referral public key
45
+ * @param args.customerId - Customer ID
46
46
  */
47
47
  deposit({ authority, amount, refer, customerId }: DepositArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
48
48
  /**
@@ -56,7 +56,7 @@ export default class Predictor {
56
56
  * Collect Rewards
57
57
  * Claims accumulated TRIAD token rewards for the predictor.
58
58
  * @param args.authority - Authority of the predictor
59
- * @param args.customerId - Customer ID (optional) defaults to 7 from Triadmarkets
59
+ * @param args.customerId - Customer ID
60
60
  */
61
61
  collectRewards({ authority, customerId }: CollectRewardsArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
62
62
  }
package/dist/predictor.js CHANGED
@@ -12,7 +12,6 @@ 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");
16
15
  const bn_js_1 = __importDefault(require("bn.js"));
17
16
  const constants_1 = require("./utils/constants");
18
17
  const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersionedTransaction"));
@@ -26,9 +25,9 @@ class Predictor {
26
25
  /**
27
26
  * Get predictor
28
27
  * @param authority - Authority public key
29
- * @param customerId - Customer ID (optional) defaults to 7 from Triadmarkets
28
+ * @param customerId - Customer ID
30
29
  */
31
- getPredictor(authority, customerId = 7) {
30
+ getPredictor(authority, customerId) {
32
31
  return __awaiter(this, void 0, void 0, function* () {
33
32
  const predictorPDA = (0, pda_1.getPredictorPDA)(this.program.programId, authority, customerId);
34
33
  try {
@@ -52,7 +51,7 @@ class Predictor {
52
51
  * Get User Orders
53
52
  * @param wallet - User wallet PublicKey
54
53
  */
55
- getUserOrders(wallet, customerId = 7) {
54
+ getUserOrders(wallet, customerId) {
56
55
  return __awaiter(this, void 0, void 0, function* () {
57
56
  const predictorPDA = (0, pda_1.getPredictorPDA)(this.program.programId, wallet, customerId);
58
57
  const orders = yield this.program.account.predictorOrder.all([
@@ -71,7 +70,7 @@ class Predictor {
71
70
  * @param wallet - User wallet PublicKey
72
71
  * @param marketId - The ID of the market
73
72
  */
74
- getUserOrdersByMarketId(wallet, marketId, customerId = 7) {
73
+ getUserOrdersByMarketId(wallet, marketId, customerId) {
75
74
  return __awaiter(this, void 0, void 0, function* () {
76
75
  const orders = yield this.getUserOrders(wallet, customerId);
77
76
  return orders.filter((order) => order.marketId === marketId.toString());
@@ -82,7 +81,7 @@ class Predictor {
82
81
  * @param wallet - User wallet PublicKey
83
82
  * @param customerId - User Customer ID
84
83
  */
85
- getUserBookOrders(wallet, customerId = 7) {
84
+ getUserBookOrders(wallet, customerId) {
86
85
  return __awaiter(this, void 0, void 0, function* () {
87
86
  const orderbooks = yield this.program.account.orderBook.all();
88
87
  const predictorPDA = (0, pda_1.getPredictorPDA)(this.program.programId, wallet, customerId);
@@ -101,7 +100,7 @@ class Predictor {
101
100
  * @param marketId - The ID of the market
102
101
  * @param customerId - User Customer ID
103
102
  */
104
- getUserBookOrdersByMarketId(wallet, marketId, customerId = 7) {
103
+ getUserBookOrdersByMarketId(wallet, marketId, customerId) {
105
104
  return __awaiter(this, void 0, void 0, function* () {
106
105
  const orderBook = yield this.program.account.orderBook.fetch((0, pda_1.getOrderBookPDA)(this.program.programId, marketId), this.rpcOptions.commitment);
107
106
  const orders = [...orderBook.hypeOrders, ...orderBook.flopOrders];
@@ -116,10 +115,10 @@ class Predictor {
116
115
  * Deposit
117
116
  * @param args.authority - Authority of the deposit
118
117
  * @param args.amount - Amount to deposit
119
- * @param args.refer - Referral public key (optional) defaults to Triadmarkets public key
120
- * @param args.customerId - Customer ID (optional) defaults to 7 from Triadmarkets
118
+ * @param args.refer - Referral public key
119
+ * @param args.customerId - Customer ID
121
120
  */
122
- deposit({ authority, amount, refer = new web3_js_1.PublicKey('DqL77dzdTruyY9qssbU1aQNeDDywxL587k9FquxVv6iX'), customerId = 7 }) {
121
+ deposit({ authority, amount, refer, customerId }) {
123
122
  return __awaiter(this, void 0, void 0, function* () {
124
123
  const ixs = [];
125
124
  const predictorPDA = (0, pda_1.getPredictorPDA)(this.program.programId, authority, customerId);
@@ -154,7 +153,7 @@ class Predictor {
154
153
  * @param args.amount - Amount to deposit
155
154
  * @param args.customerId - Customer ID (optional) defaults to 7 from Triadmarkets
156
155
  */
157
- withdraw({ authority, amount, customerId = 7 }) {
156
+ withdraw({ authority, amount, customerId }) {
158
157
  return __awaiter(this, void 0, void 0, function* () {
159
158
  const predictorPDA = (0, pda_1.getPredictorPDA)(this.program.programId, authority, customerId);
160
159
  const ixs = [
@@ -162,6 +161,7 @@ class Predictor {
162
161
  .withdraw(new bn_js_1.default(amount * Math.pow(10, constants_1.BASE_DECIMALS)))
163
162
  .accounts({
164
163
  signer: authority,
164
+ payer: this.rpcOptions.payer,
165
165
  predictor: predictorPDA
166
166
  })
167
167
  .instruction()
@@ -173,9 +173,9 @@ class Predictor {
173
173
  * Collect Rewards
174
174
  * Claims accumulated TRIAD token rewards for the predictor.
175
175
  * @param args.authority - Authority of the predictor
176
- * @param args.customerId - Customer ID (optional) defaults to 7 from Triadmarkets
176
+ * @param args.customerId - Customer ID
177
177
  */
178
- collectRewards({ authority, customerId = 7 }) {
178
+ collectRewards({ authority, customerId }) {
179
179
  return __awaiter(this, void 0, void 0, function* () {
180
180
  const predictorPDA = (0, pda_1.getPredictorPDA)(this.program.programId, authority, customerId);
181
181
  const ixs = [
@@ -183,6 +183,7 @@ class Predictor {
183
183
  .collectRewards()
184
184
  .accounts({
185
185
  signer: authority,
186
+ payer: this.rpcOptions.payer,
186
187
  predictor: predictorPDA
187
188
  })
188
189
  .instruction()
package/dist/trade.js CHANGED
@@ -67,7 +67,7 @@ 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 = 7 }) {
70
+ placeBidOrder({ orders, customerId }) {
71
71
  return __awaiter(this, void 0, void 0, function* () {
72
72
  const ixs = [];
73
73
  const predictorPDA = (0, pda_1.getPredictorPDA)(this.program.programId, this.program.provider.publicKey, customerId);
@@ -100,7 +100,7 @@ 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 = 7 }) {
103
+ placeAskOrder({ orders, customerId }) {
104
104
  return __awaiter(this, void 0, void 0, function* () {
105
105
  const ixs = [];
106
106
  const predictorPDA = (0, pda_1.getPredictorPDA)(this.program.programId, this.program.provider.publicKey, customerId);
@@ -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 = 7 }) {
132
+ cancelBidOrder({ orders, customerId }) {
133
133
  return __awaiter(this, void 0, void 0, function* () {
134
134
  const ixs = [];
135
135
  for (const order of orders) {
@@ -157,7 +157,7 @@ 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 = 7 }) {
160
+ cancelAskOrder({ orders, customerId }) {
161
161
  return __awaiter(this, void 0, void 0, function* () {
162
162
  const ixs = [];
163
163
  const predictorPDA = (0, pda_1.getPredictorPDA)(this.program.programId, this.program.provider.publicKey, customerId);
@@ -456,6 +456,11 @@
456
456
  "writable": true,
457
457
  "signer": true
458
458
  },
459
+ {
460
+ "name": "payer",
461
+ "writable": true,
462
+ "signer": true
463
+ },
459
464
  {
460
465
  "name": "central",
461
466
  "writable": true,
@@ -872,6 +877,22 @@
872
877
  "writable": true,
873
878
  "signer": true
874
879
  },
880
+ {
881
+ "name": "customer",
882
+ "writable": true,
883
+ "pda": {
884
+ "seeds": [
885
+ {
886
+ "kind": "const",
887
+ "value": [99, 117, 115, 116, 111, 109, 101, 114]
888
+ },
889
+ {
890
+ "kind": "arg",
891
+ "path": "args.customer_id"
892
+ }
893
+ ]
894
+ }
895
+ },
875
896
  {
876
897
  "name": "predictor",
877
898
  "writable": true,
@@ -1911,6 +1932,11 @@
1911
1932
  "writable": true,
1912
1933
  "signer": true
1913
1934
  },
1935
+ {
1936
+ "name": "payer",
1937
+ "writable": true,
1938
+ "signer": true
1939
+ },
1914
1940
  {
1915
1941
  "name": "central",
1916
1942
  "writable": true,
@@ -2628,10 +2654,6 @@
2628
2654
  "name": "bump",
2629
2655
  "type": "u8"
2630
2656
  },
2631
- {
2632
- "name": "balance",
2633
- "type": "u64"
2634
- },
2635
2657
  {
2636
2658
  "name": "is_locked",
2637
2659
  "type": "bool"
@@ -2651,7 +2673,7 @@
2651
2673
  {
2652
2674
  "name": "padding",
2653
2675
  "type": {
2654
- "array": ["u8", 287]
2676
+ "array": ["u8", 295]
2655
2677
  }
2656
2678
  }
2657
2679
  ]
@@ -2958,6 +2980,10 @@
2958
2980
  "name": "predictor",
2959
2981
  "type": "pubkey"
2960
2982
  },
2983
+ {
2984
+ "name": "customer_id",
2985
+ "type": "u16"
2986
+ },
2961
2987
  {
2962
2988
  "name": "amount",
2963
2989
  "type": "u64"
@@ -4216,6 +4242,10 @@
4216
4242
  "name": "predictor",
4217
4243
  "type": "pubkey"
4218
4244
  },
4245
+ {
4246
+ "name": "customer_id",
4247
+ "type": "u16"
4248
+ },
4219
4249
  {
4220
4250
  "name": "amount",
4221
4251
  "type": "u64"
@@ -11,15 +11,15 @@ export type Predictor = {
11
11
  export type DepositArgs = {
12
12
  authority: PublicKey;
13
13
  amount: number;
14
- refer?: PublicKey;
15
- customerId?: number;
14
+ refer: PublicKey;
15
+ customerId: number;
16
16
  };
17
17
  export type WithdrawArgs = {
18
18
  authority: PublicKey;
19
19
  amount: number;
20
- customerId?: number;
20
+ customerId: number;
21
21
  };
22
22
  export type CollectRewardsArgs = {
23
23
  authority: PublicKey;
24
- customerId?: number;
24
+ customerId: number;
25
25
  };
@@ -619,6 +619,11 @@ export type TriadProtocol = {
619
619
  writable: true;
620
620
  signer: true;
621
621
  },
622
+ {
623
+ name: 'payer';
624
+ writable: true;
625
+ signer: true;
626
+ },
622
627
  {
623
628
  name: 'central';
624
629
  writable: true;
@@ -1133,6 +1138,22 @@ export type TriadProtocol = {
1133
1138
  writable: true;
1134
1139
  signer: true;
1135
1140
  },
1141
+ {
1142
+ name: 'customer';
1143
+ writable: true;
1144
+ pda: {
1145
+ seeds: [
1146
+ {
1147
+ kind: 'const';
1148
+ value: [99, 117, 115, 116, 111, 109, 101, 114];
1149
+ },
1150
+ {
1151
+ kind: 'arg';
1152
+ path: 'args.customer_id';
1153
+ }
1154
+ ];
1155
+ };
1156
+ },
1136
1157
  {
1137
1158
  name: 'predictor';
1138
1159
  writable: true;
@@ -2466,6 +2487,11 @@ export type TriadProtocol = {
2466
2487
  writable: true;
2467
2488
  signer: true;
2468
2489
  },
2490
+ {
2491
+ name: 'payer';
2492
+ writable: true;
2493
+ signer: true;
2494
+ },
2469
2495
  {
2470
2496
  name: 'central';
2471
2497
  writable: true;
@@ -3252,10 +3278,6 @@ export type TriadProtocol = {
3252
3278
  name: 'bump';
3253
3279
  type: 'u8';
3254
3280
  },
3255
- {
3256
- name: 'balance';
3257
- type: 'u64';
3258
- },
3259
3281
  {
3260
3282
  name: 'isLocked';
3261
3283
  type: 'bool';
@@ -3275,7 +3297,7 @@ export type TriadProtocol = {
3275
3297
  {
3276
3298
  name: 'padding';
3277
3299
  type: {
3278
- array: ['u8', 287];
3300
+ array: ['u8', 295];
3279
3301
  };
3280
3302
  }
3281
3303
  ];
@@ -3582,6 +3604,10 @@ export type TriadProtocol = {
3582
3604
  name: 'predictor';
3583
3605
  type: 'pubkey';
3584
3606
  },
3607
+ {
3608
+ name: 'customerId';
3609
+ type: 'u16';
3610
+ },
3585
3611
  {
3586
3612
  name: 'amount';
3587
3613
  type: 'u64';
@@ -4840,6 +4866,10 @@ export type TriadProtocol = {
4840
4866
  name: 'predictor';
4841
4867
  type: 'pubkey';
4842
4868
  },
4869
+ {
4870
+ name: 'customerId';
4871
+ type: 'u16';
4872
+ },
4843
4873
  {
4844
4874
  name: 'amount';
4845
4875
  type: 'u64';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "4.2.2",
3
+ "version": "4.2.4",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",