@triadxyz/triad-protocol 2.7.5-beta → 2.7.7-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.d.ts CHANGED
@@ -280,6 +280,7 @@ export default class TriadProtocolClient {
280
280
  * @param args.marketId - The ID of the Market
281
281
  * @param args.orderId - The ID of the Order to Payout
282
282
  * @param args.userNonce - The nonce of the user
283
+ * @param args.isTrdPayout - Whether to payout in TRD or not
283
284
  *
284
285
  * @param options - RPC options
285
286
  *
@@ -289,6 +290,8 @@ export default class TriadProtocolClient {
289
290
  orderId: number;
290
291
  userNonce: number;
291
292
  mint: PublicKey;
293
+ shares: number;
294
+ isTrdPayout: boolean;
292
295
  }[], options?: RpcOptions): Promise<string>;
293
296
  /**
294
297
  * Allow Market to Payout
@@ -318,7 +321,11 @@ export default class TriadProtocolClient {
318
321
  * @param options - RPC options
319
322
  *
320
323
  */
321
- updateMarket(marketId: number, marketEnd: number, options?: RpcOptions): Promise<string>;
324
+ updateMarket({ marketId, marketEnd, poolId }: {
325
+ marketId: number;
326
+ marketEnd: number;
327
+ poolId?: number;
328
+ }, options?: RpcOptions): Promise<string>;
322
329
  /**
323
330
  * Create Customer
324
331
  * @param args.id - The ID of the customer
@@ -412,6 +419,7 @@ export default class TriadProtocolClient {
412
419
  * @param args.bidOrderId - The ID of the Bid Order
413
420
  * @param args.direction - The direction of the Order
414
421
  * @param args.mint - The mint of the Order
422
+ * @param args.isTrdPayout - Whether to payout in TRD or not
415
423
  *
416
424
  * @param options - RPC options
417
425
  */
@@ -438,12 +446,18 @@ export default class TriadProtocolClient {
438
446
  /**
439
447
  * Collect Market Fee
440
448
  * @param args.markets - The markets to collect the fee from
449
+ * @param args.markets.mint - The mint of the market
450
+ * @param args.markets.marketAddress - The address of the market
451
+ * @param args.markets.customerId - The ID of the customer
452
+ * @param args.markets.customerFeeRecipient - The address of the customer fee recipient
441
453
  *
442
454
  * @param options - RPC options
443
455
  */
444
456
  collectMarketFee(markets: {
445
457
  mint: PublicKey;
446
458
  marketAddress: PublicKey;
459
+ customerId: number;
460
+ customerFeeRecipient: PublicKey;
447
461
  }[], options?: RpcOptions): Promise<string>;
448
462
  /**
449
463
  * Close Order Book
package/dist/index.js CHANGED
@@ -463,6 +463,7 @@ class TriadProtocolClient {
463
463
  * @param args.marketId - The ID of the Market
464
464
  * @param args.orderId - The ID of the Order to Payout
465
465
  * @param args.userNonce - The nonce of the user
466
+ * @param args.isTrdPayout - Whether to payout in TRD or not
466
467
  *
467
468
  * @param options - RPC options
468
469
  *
@@ -484,6 +485,20 @@ class TriadProtocolClient {
484
485
  tokenProgram: (0, helpers_1.getTokenProgram)(order.mint)
485
486
  })
486
487
  .instruction());
488
+ if (order.isTrdPayout) {
489
+ const { setupInstructions, swapIxs, addressLookupTableAccounts } = yield (0, swap_1.swap)({
490
+ connection: this.program.provider.connection,
491
+ wallet: this.program.provider.publicKey.toBase58(),
492
+ inToken: constants_1.USDC_MINT.toBase58(),
493
+ amount: order.shares
494
+ });
495
+ if (swapIxs.length === 0) {
496
+ return;
497
+ }
498
+ ixs.push(...setupInstructions);
499
+ ixs.push(...swapIxs);
500
+ addressLookupTableAccounts.push(...addressLookupTableAccounts);
501
+ }
487
502
  }
488
503
  return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
489
504
  });
@@ -547,9 +562,13 @@ class TriadProtocolClient {
547
562
  * @param options - RPC options
548
563
  *
549
564
  */
550
- updateMarket(marketId, marketEnd, options) {
565
+ updateMarket({ marketId, marketEnd, poolId }, options) {
551
566
  return __awaiter(this, void 0, void 0, function* () {
552
567
  const ixs = [];
568
+ let poolPDA = null;
569
+ if (poolId) {
570
+ poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
571
+ }
553
572
  ixs.push(yield this.program.methods
554
573
  .updateMarket({
555
574
  marketEnd: new bn_js_1.default(marketEnd),
@@ -559,7 +578,7 @@ class TriadProtocolClient {
559
578
  .accounts({
560
579
  signer: this.program.provider.publicKey,
561
580
  market: (0, pda_1.getMarketPDA)(this.program.programId, marketId),
562
- pool: null
581
+ pool: poolPDA
563
582
  })
564
583
  .instruction());
565
584
  return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
@@ -826,7 +845,7 @@ class TriadProtocolClient {
826
845
  .mul(new bn_js_1.default(Math.pow(10, this.decimals)))
827
846
  .div(adjustedPrice);
828
847
  const sharesToBuy = bn_js_1.default.min(maxSharesForPrice, availableShares);
829
- if (sharesToBuy.lt(new bn_js_1.default(1000000)))
848
+ if (sharesToBuy.lte(new bn_js_1.default(0)))
830
849
  continue;
831
850
  const usdcAmount = sharesToBuy
832
851
  .mul(adjustedPrice)
@@ -869,6 +888,7 @@ class TriadProtocolClient {
869
888
  * @param args.bidOrderId - The ID of the Bid Order
870
889
  * @param args.direction - The direction of the Order
871
890
  * @param args.mint - The mint of the Order
891
+ * @param args.isTrdPayout - Whether to payout in TRD or not
872
892
  *
873
893
  * @param options - RPC options
874
894
  */
@@ -887,7 +907,8 @@ class TriadProtocolClient {
887
907
  for (const order of sortedOrders) {
888
908
  if (remainingShares.lte(new bn_js_1.default(0)))
889
909
  break;
890
- if (order.authority === this.program.provider.publicKey.toBase58()) {
910
+ if (order.authority === this.program.provider.publicKey.toBase58() ||
911
+ order.linkedBookOrderId !== constants_1.BOOK_ORDER_NULL.toString()) {
891
912
  continue;
892
913
  }
893
914
  const availableShares = new bn_js_1.default(order.totalShares).sub(new bn_js_1.default(order.filledShares));
@@ -964,6 +985,10 @@ class TriadProtocolClient {
964
985
  /**
965
986
  * Collect Market Fee
966
987
  * @param args.markets - The markets to collect the fee from
988
+ * @param args.markets.mint - The mint of the market
989
+ * @param args.markets.marketAddress - The address of the market
990
+ * @param args.markets.customerId - The ID of the customer
991
+ * @param args.markets.customerFeeRecipient - The address of the customer fee recipient
967
992
  *
968
993
  * @param options - RPC options
969
994
  */
@@ -977,6 +1002,8 @@ class TriadProtocolClient {
977
1002
  signer: this.program.provider.publicKey,
978
1003
  market: market.marketAddress,
979
1004
  mint: market.mint,
1005
+ customer: (0, pda_1.getCustomerPDA)(this.program.programId, market.customerId),
1006
+ customerFeeRecipient: market.customerFeeRecipient,
980
1007
  tokenProgram: (0, helpers_1.getTokenProgram)(market.mint)
981
1008
  })
982
1009
  .instruction());
@@ -452,6 +452,14 @@
452
452
  "name": "market",
453
453
  "writable": true
454
454
  },
455
+ {
456
+ "name": "customer_fee_recipient",
457
+ "writable": true
458
+ },
459
+ {
460
+ "name": "customer",
461
+ "writable": true
462
+ },
455
463
  {
456
464
  "name": "mint",
457
465
  "writable": true
@@ -512,6 +520,34 @@
512
520
  }
513
521
  }
514
522
  },
523
+ {
524
+ "name": "customer_ata",
525
+ "writable": true,
526
+ "pda": {
527
+ "seeds": [
528
+ {
529
+ "kind": "account",
530
+ "path": "customer_fee_recipient"
531
+ },
532
+ {
533
+ "kind": "account",
534
+ "path": "token_program"
535
+ },
536
+ {
537
+ "kind": "account",
538
+ "path": "mint"
539
+ }
540
+ ],
541
+ "program": {
542
+ "kind": "const",
543
+ "value": [
544
+ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
545
+ 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
546
+ 219, 233, 248, 89
547
+ ]
548
+ }
549
+ }
550
+ },
515
551
  {
516
552
  "name": "token_program"
517
553
  },
@@ -2238,6 +2274,10 @@
2238
2274
  "name": "MarketEvent",
2239
2275
  "discriminator": [212, 67, 145, 23, 58, 104, 52, 83]
2240
2276
  },
2277
+ {
2278
+ "name": "MarketFeeCollectedEvent",
2279
+ "discriminator": [248, 190, 87, 22, 89, 145, 188, 207]
2280
+ },
2241
2281
  {
2242
2282
  "name": "OrderEvent",
2243
2283
  "discriminator": [209, 51, 146, 206, 88, 127, 112, 69]
@@ -2395,6 +2435,16 @@
2395
2435
  "code": 6027,
2396
2436
  "name": "MarketAlreadyPaidOut",
2397
2437
  "msg": "Market already paid out"
2438
+ },
2439
+ {
2440
+ "code": 6028,
2441
+ "name": "InvalidNonce",
2442
+ "msg": "Invalid Nonce"
2443
+ },
2444
+ {
2445
+ "code": 6029,
2446
+ "name": "InvalidMainOrder",
2447
+ "msg": "Invalid Main Order"
2398
2448
  }
2399
2449
  ],
2400
2450
  "types": [
@@ -3041,6 +3091,46 @@
3041
3091
  ]
3042
3092
  }
3043
3093
  },
3094
+ {
3095
+ "name": "MarketFeeCollectedEvent",
3096
+ "type": {
3097
+ "kind": "struct",
3098
+ "fields": [
3099
+ {
3100
+ "name": "market_id",
3101
+ "type": "u64"
3102
+ },
3103
+ {
3104
+ "name": "triad_fee",
3105
+ "type": "u64"
3106
+ },
3107
+ {
3108
+ "name": "customer_fee",
3109
+ "type": "u64"
3110
+ },
3111
+ {
3112
+ "name": "triad_fee_recipient",
3113
+ "type": "pubkey"
3114
+ },
3115
+ {
3116
+ "name": "customer_fee_recipient",
3117
+ "type": "pubkey"
3118
+ },
3119
+ {
3120
+ "name": "customer_id",
3121
+ "type": "u16"
3122
+ },
3123
+ {
3124
+ "name": "customer_fee_bps",
3125
+ "type": "u16"
3126
+ },
3127
+ {
3128
+ "name": "timestamp",
3129
+ "type": "i64"
3130
+ }
3131
+ ]
3132
+ }
3133
+ },
3044
3134
  {
3045
3135
  "name": "MarketV2",
3046
3136
  "type": {
@@ -227,6 +227,7 @@ export type MarketAskOrderArgs = {
227
227
  flop: {};
228
228
  };
229
229
  mint: PublicKey;
230
+ isTrdPayout: boolean;
230
231
  };
231
232
  export type Refer = {
232
233
  id: number;
@@ -644,6 +644,14 @@ export type TriadProtocol = {
644
644
  name: 'market';
645
645
  writable: true;
646
646
  },
647
+ {
648
+ name: 'customerFeeRecipient';
649
+ writable: true;
650
+ },
651
+ {
652
+ name: 'customer';
653
+ writable: true;
654
+ },
647
655
  {
648
656
  name: 'mint';
649
657
  writable: true;
@@ -762,6 +770,63 @@ export type TriadProtocol = {
762
770
  };
763
771
  };
764
772
  },
773
+ {
774
+ name: 'customerAta';
775
+ writable: true;
776
+ pda: {
777
+ seeds: [
778
+ {
779
+ kind: 'account';
780
+ path: 'customerFeeRecipient';
781
+ },
782
+ {
783
+ kind: 'account';
784
+ path: 'tokenProgram';
785
+ },
786
+ {
787
+ kind: 'account';
788
+ path: 'mint';
789
+ }
790
+ ];
791
+ program: {
792
+ kind: 'const';
793
+ value: [
794
+ 140,
795
+ 151,
796
+ 37,
797
+ 143,
798
+ 78,
799
+ 36,
800
+ 137,
801
+ 241,
802
+ 187,
803
+ 61,
804
+ 16,
805
+ 41,
806
+ 20,
807
+ 142,
808
+ 13,
809
+ 131,
810
+ 11,
811
+ 90,
812
+ 19,
813
+ 153,
814
+ 218,
815
+ 255,
816
+ 16,
817
+ 132,
818
+ 4,
819
+ 142,
820
+ 123,
821
+ 216,
822
+ 219,
823
+ 233,
824
+ 248,
825
+ 89
826
+ ];
827
+ };
828
+ };
829
+ },
765
830
  {
766
831
  name: 'tokenProgram';
767
832
  },
@@ -3029,6 +3094,10 @@ export type TriadProtocol = {
3029
3094
  name: 'marketEvent';
3030
3095
  discriminator: [212, 67, 145, 23, 58, 104, 52, 83];
3031
3096
  },
3097
+ {
3098
+ name: 'marketFeeCollectedEvent';
3099
+ discriminator: [248, 190, 87, 22, 89, 145, 188, 207];
3100
+ },
3032
3101
  {
3033
3102
  name: 'orderEvent';
3034
3103
  discriminator: [209, 51, 146, 206, 88, 127, 112, 69];
@@ -3186,6 +3255,16 @@ export type TriadProtocol = {
3186
3255
  code: 6027;
3187
3256
  name: 'marketAlreadyPaidOut';
3188
3257
  msg: 'Market already paid out';
3258
+ },
3259
+ {
3260
+ code: 6028;
3261
+ name: 'invalidNonce';
3262
+ msg: 'Invalid Nonce';
3263
+ },
3264
+ {
3265
+ code: 6029;
3266
+ name: 'invalidMainOrder';
3267
+ msg: 'Invalid Main Order';
3189
3268
  }
3190
3269
  ];
3191
3270
  types: [
@@ -3832,6 +3911,46 @@ export type TriadProtocol = {
3832
3911
  ];
3833
3912
  };
3834
3913
  },
3914
+ {
3915
+ name: 'marketFeeCollectedEvent';
3916
+ type: {
3917
+ kind: 'struct';
3918
+ fields: [
3919
+ {
3920
+ name: 'marketId';
3921
+ type: 'u64';
3922
+ },
3923
+ {
3924
+ name: 'triadFee';
3925
+ type: 'u64';
3926
+ },
3927
+ {
3928
+ name: 'customerFee';
3929
+ type: 'u64';
3930
+ },
3931
+ {
3932
+ name: 'triadFeeRecipient';
3933
+ type: 'pubkey';
3934
+ },
3935
+ {
3936
+ name: 'customerFeeRecipient';
3937
+ type: 'pubkey';
3938
+ },
3939
+ {
3940
+ name: 'customerId';
3941
+ type: 'u16';
3942
+ },
3943
+ {
3944
+ name: 'customerFeeBps';
3945
+ type: 'u16';
3946
+ },
3947
+ {
3948
+ name: 'timestamp';
3949
+ type: 'i64';
3950
+ }
3951
+ ];
3952
+ };
3953
+ },
3835
3954
  {
3836
3955
  name: 'marketV2';
3837
3956
  type: {
@@ -8,3 +8,4 @@ export declare const TICKET_CORE_COLLECTION: PublicKey;
8
8
  export declare const POSEIDON_COLLECTION_SYMBOL = "$PSN";
9
9
  export declare const POSEIDON_CORE_COLLECTION: PublicKey;
10
10
  export declare const TICKET_COLLECTION_SYMBOL = "PTCKT";
11
+ export declare const BOOK_ORDER_NULL = 61;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TICKET_COLLECTION_SYMBOL = exports.POSEIDON_CORE_COLLECTION = exports.POSEIDON_COLLECTION_SYMBOL = exports.TICKET_CORE_COLLECTION = exports.SOL_MINT = exports.TRIAD_ADMIN = exports.TRD_MINT = exports.USDC_MINT = exports.TRD_DECIMALS = void 0;
3
+ exports.BOOK_ORDER_NULL = exports.TICKET_COLLECTION_SYMBOL = exports.POSEIDON_CORE_COLLECTION = exports.POSEIDON_COLLECTION_SYMBOL = exports.TICKET_CORE_COLLECTION = exports.SOL_MINT = exports.TRIAD_ADMIN = exports.TRD_MINT = exports.USDC_MINT = exports.TRD_DECIMALS = void 0;
4
4
  const web3_js_1 = require("@solana/web3.js");
5
5
  exports.TRD_DECIMALS = 6;
6
6
  exports.USDC_MINT = new web3_js_1.PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v');
@@ -11,3 +11,4 @@ exports.TICKET_CORE_COLLECTION = new web3_js_1.PublicKey('BaqopH1VXYUCT6VsojbTib
11
11
  exports.POSEIDON_COLLECTION_SYMBOL = '$PSN';
12
12
  exports.POSEIDON_CORE_COLLECTION = new web3_js_1.PublicKey('69CLccefLRmvDSAJP7Er632dvn878qkpdcnvq5ZUspSm');
13
13
  exports.TICKET_COLLECTION_SYMBOL = 'PTCKT';
14
+ exports.BOOK_ORDER_NULL = 61;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "2.7.5-beta",
3
+ "version": "2.7.7-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",