@triadxyz/triad-protocol 2.2.9-beta → 2.3.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.d.ts CHANGED
@@ -255,7 +255,10 @@ export default class Trade {
255
255
  * @param options - RPC options
256
256
  *
257
257
  */
258
- allowMarketToPayout(marketId: number, options?: RpcOptions): Promise<string>;
258
+ allowMarketToPayout({ marketId, poolId }: {
259
+ marketId: number;
260
+ poolId?: number;
261
+ }, options?: RpcOptions): Promise<string>;
259
262
  /**
260
263
  * Create Sub User Trade
261
264
  * @param user - User PublicKey the main user
@@ -366,4 +369,11 @@ export default class Trade {
366
369
  ask: Order[];
367
370
  };
368
371
  }>;
372
+ /**
373
+ * Collect Market Fee
374
+ * @param marketId - The ID of the market
375
+ *
376
+ * @param options - RPC options
377
+ */
378
+ collectMarketFee(marketId: number, options?: RpcOptions): Promise<string>;
369
379
  }
package/dist/trade.js CHANGED
@@ -202,6 +202,12 @@ class Trade {
202
202
  signer: this.program.provider.publicKey
203
203
  })
204
204
  .instruction());
205
+ let userTrade = null;
206
+ try {
207
+ yield this.getUserTrade(this.program.provider.publicKey);
208
+ userTrade = (0, pda_1.getUserTradePDA)(this.program.programId, this.program.provider.publicKey);
209
+ }
210
+ catch (_a) { }
205
211
  for (const market of markets) {
206
212
  if (market.question.length > 80) {
207
213
  throw new Error('Market question must be less than 80 characters');
@@ -220,7 +226,8 @@ class Trade {
220
226
  mint,
221
227
  tokenProgram: (0, helpers_1.getTokenProgram)(mint),
222
228
  pool: poolPDA,
223
- customer
229
+ customer,
230
+ userTrade
224
231
  })
225
232
  .instruction());
226
233
  }
@@ -401,9 +408,13 @@ class Trade {
401
408
  * @param options - RPC options
402
409
  *
403
410
  */
404
- allowMarketToPayout(marketId, options) {
411
+ allowMarketToPayout({ marketId, poolId }, options) {
405
412
  return __awaiter(this, void 0, void 0, function* () {
406
413
  const ixs = [];
414
+ let poolPDA = null;
415
+ if (poolId) {
416
+ poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
417
+ }
407
418
  ixs.push(yield this.program.methods
408
419
  .updateMarket({
409
420
  winningDirection: null,
@@ -412,7 +423,8 @@ class Trade {
412
423
  })
413
424
  .accounts({
414
425
  signer: this.program.provider.publicKey,
415
- market: (0, pda_1.getMarketPDA)(this.program.programId, marketId)
426
+ market: (0, pda_1.getMarketPDA)(this.program.programId, marketId),
427
+ pool: poolPDA
416
428
  })
417
429
  .instruction());
418
430
  return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
@@ -837,5 +849,25 @@ class Trade {
837
849
  return orderBook;
838
850
  });
839
851
  }
852
+ /**
853
+ * Collect Market Fee
854
+ * @param marketId - The ID of the market
855
+ *
856
+ * @param options - RPC options
857
+ */
858
+ collectMarketFee(marketId, options) {
859
+ return __awaiter(this, void 0, void 0, function* () {
860
+ const ixs = [];
861
+ ixs.push(yield this.program.methods
862
+ .collectMarketFee()
863
+ .accounts({
864
+ signer: this.program.provider.publicKey,
865
+ market: (0, pda_1.getMarketPDA)(this.program.programId, marketId),
866
+ mint: constants_1.TRD_MINT
867
+ })
868
+ .instruction());
869
+ return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
870
+ });
871
+ }
840
872
  }
841
873
  exports.default = Trade;
@@ -762,6 +762,99 @@
762
762
  ],
763
763
  "args": []
764
764
  },
765
+ {
766
+ "name": "collect_market_fee",
767
+ "discriminator": [139, 4, 96, 182, 216, 250, 122, 79],
768
+ "accounts": [
769
+ {
770
+ "name": "signer",
771
+ "writable": true,
772
+ "signer": true
773
+ },
774
+ {
775
+ "name": "squads",
776
+ "writable": true,
777
+ "address": "6fcSf6qfwPNR9AUUNC1UWYZDy5cQ4TzTb2aaipN2zFdq"
778
+ },
779
+ {
780
+ "name": "market",
781
+ "writable": true
782
+ },
783
+ {
784
+ "name": "mint",
785
+ "writable": true
786
+ },
787
+ {
788
+ "name": "market_ata",
789
+ "writable": true,
790
+ "pda": {
791
+ "seeds": [
792
+ {
793
+ "kind": "account",
794
+ "path": "market"
795
+ },
796
+ {
797
+ "kind": "account",
798
+ "path": "token_program"
799
+ },
800
+ {
801
+ "kind": "account",
802
+ "path": "mint"
803
+ }
804
+ ],
805
+ "program": {
806
+ "kind": "const",
807
+ "value": [
808
+ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
809
+ 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
810
+ 219, 233, 248, 89
811
+ ]
812
+ }
813
+ }
814
+ },
815
+ {
816
+ "name": "receiver_ata",
817
+ "writable": true,
818
+ "pda": {
819
+ "seeds": [
820
+ {
821
+ "kind": "account",
822
+ "path": "squads"
823
+ },
824
+ {
825
+ "kind": "account",
826
+ "path": "token_program"
827
+ },
828
+ {
829
+ "kind": "account",
830
+ "path": "mint"
831
+ }
832
+ ],
833
+ "program": {
834
+ "kind": "const",
835
+ "value": [
836
+ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
837
+ 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
838
+ 219, 233, 248, 89
839
+ ]
840
+ }
841
+ }
842
+ },
843
+ {
844
+ "name": "token_program",
845
+ "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
846
+ },
847
+ {
848
+ "name": "associated_token_program",
849
+ "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
850
+ },
851
+ {
852
+ "name": "system_program",
853
+ "address": "11111111111111111111111111111111"
854
+ }
855
+ ],
856
+ "args": []
857
+ },
765
858
  {
766
859
  "name": "collect_remaining_liquidity",
767
860
  "discriminator": [153, 107, 201, 83, 183, 195, 59, 186],
@@ -3292,10 +3385,8 @@
3292
3385
  "type": "u16"
3293
3386
  },
3294
3387
  {
3295
- "name": "padding_2",
3296
- "type": {
3297
- "array": ["u8", 8]
3298
- }
3388
+ "name": "fee_recipient",
3389
+ "type": "pubkey"
3299
3390
  },
3300
3391
  {
3301
3392
  "name": "pool_id",
@@ -3304,7 +3395,7 @@
3304
3395
  {
3305
3396
  "name": "padding",
3306
3397
  "type": {
3307
- "array": ["u8", 72]
3398
+ "array": ["u8", 48]
3308
3399
  }
3309
3400
  }
3310
3401
  ]
@@ -37,6 +37,7 @@ export type Market = {
37
37
  payoutFee: number;
38
38
  customer: string;
39
39
  poolId: number;
40
+ feeRecipient: string;
40
41
  };
41
42
  export type UserTrade = {
42
43
  user: string;
@@ -1186,6 +1186,157 @@ export type TriadProtocol = {
1186
1186
  ];
1187
1187
  args: [];
1188
1188
  },
1189
+ {
1190
+ name: 'collectMarketFee';
1191
+ discriminator: [139, 4, 96, 182, 216, 250, 122, 79];
1192
+ accounts: [
1193
+ {
1194
+ name: 'signer';
1195
+ writable: true;
1196
+ signer: true;
1197
+ },
1198
+ {
1199
+ name: 'squads';
1200
+ writable: true;
1201
+ address: '6fcSf6qfwPNR9AUUNC1UWYZDy5cQ4TzTb2aaipN2zFdq';
1202
+ },
1203
+ {
1204
+ name: 'market';
1205
+ writable: true;
1206
+ },
1207
+ {
1208
+ name: 'mint';
1209
+ writable: true;
1210
+ },
1211
+ {
1212
+ name: 'marketAta';
1213
+ writable: true;
1214
+ pda: {
1215
+ seeds: [
1216
+ {
1217
+ kind: 'account';
1218
+ path: 'market';
1219
+ },
1220
+ {
1221
+ kind: 'account';
1222
+ path: 'tokenProgram';
1223
+ },
1224
+ {
1225
+ kind: 'account';
1226
+ path: 'mint';
1227
+ }
1228
+ ];
1229
+ program: {
1230
+ kind: 'const';
1231
+ value: [
1232
+ 140,
1233
+ 151,
1234
+ 37,
1235
+ 143,
1236
+ 78,
1237
+ 36,
1238
+ 137,
1239
+ 241,
1240
+ 187,
1241
+ 61,
1242
+ 16,
1243
+ 41,
1244
+ 20,
1245
+ 142,
1246
+ 13,
1247
+ 131,
1248
+ 11,
1249
+ 90,
1250
+ 19,
1251
+ 153,
1252
+ 218,
1253
+ 255,
1254
+ 16,
1255
+ 132,
1256
+ 4,
1257
+ 142,
1258
+ 123,
1259
+ 216,
1260
+ 219,
1261
+ 233,
1262
+ 248,
1263
+ 89
1264
+ ];
1265
+ };
1266
+ };
1267
+ },
1268
+ {
1269
+ name: 'receiverAta';
1270
+ writable: true;
1271
+ pda: {
1272
+ seeds: [
1273
+ {
1274
+ kind: 'account';
1275
+ path: 'squads';
1276
+ },
1277
+ {
1278
+ kind: 'account';
1279
+ path: 'tokenProgram';
1280
+ },
1281
+ {
1282
+ kind: 'account';
1283
+ path: 'mint';
1284
+ }
1285
+ ];
1286
+ program: {
1287
+ kind: 'const';
1288
+ value: [
1289
+ 140,
1290
+ 151,
1291
+ 37,
1292
+ 143,
1293
+ 78,
1294
+ 36,
1295
+ 137,
1296
+ 241,
1297
+ 187,
1298
+ 61,
1299
+ 16,
1300
+ 41,
1301
+ 20,
1302
+ 142,
1303
+ 13,
1304
+ 131,
1305
+ 11,
1306
+ 90,
1307
+ 19,
1308
+ 153,
1309
+ 218,
1310
+ 255,
1311
+ 16,
1312
+ 132,
1313
+ 4,
1314
+ 142,
1315
+ 123,
1316
+ 216,
1317
+ 219,
1318
+ 233,
1319
+ 248,
1320
+ 89
1321
+ ];
1322
+ };
1323
+ };
1324
+ },
1325
+ {
1326
+ name: 'tokenProgram';
1327
+ address: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb';
1328
+ },
1329
+ {
1330
+ name: 'associatedTokenProgram';
1331
+ address: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
1332
+ },
1333
+ {
1334
+ name: 'systemProgram';
1335
+ address: '11111111111111111111111111111111';
1336
+ }
1337
+ ];
1338
+ args: [];
1339
+ },
1189
1340
  {
1190
1341
  name: 'collectRemainingLiquidity';
1191
1342
  discriminator: [153, 107, 201, 83, 183, 195, 59, 186];
@@ -4361,10 +4512,8 @@ export type TriadProtocol = {
4361
4512
  type: 'u16';
4362
4513
  },
4363
4514
  {
4364
- name: 'padding2';
4365
- type: {
4366
- array: ['u8', 8];
4367
- };
4515
+ name: 'feeRecipient';
4516
+ type: 'pubkey';
4368
4517
  },
4369
4518
  {
4370
4519
  name: 'poolId';
@@ -4373,7 +4522,7 @@ export type TriadProtocol = {
4373
4522
  {
4374
4523
  name: 'padding';
4375
4524
  type: {
4376
- array: ['u8', 72];
4525
+ array: ['u8', 48];
4377
4526
  };
4378
4527
  }
4379
4528
  ];
@@ -95,7 +95,8 @@ const formatMarket = (account, address) => {
95
95
  : '0',
96
96
  payoutFee: account.payoutFee,
97
97
  customer: account.customerId === 0 ? 'Triad' : account.customerId.toString(),
98
- poolId: account.poolId.toNumber()
98
+ poolId: account.poolId.toNumber(),
99
+ feeRecipient: account.feeRecipient.toString()
99
100
  };
100
101
  };
101
102
  exports.formatMarket = formatMarket;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "2.2.9-beta",
3
+ "version": "2.3.1-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",