@triadxyz/triad-protocol 3.1.0-beta → 3.1.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/index.d.ts CHANGED
@@ -80,12 +80,6 @@ export default class TriadProtocolClient {
80
80
  *
81
81
  */
82
82
  getCustomerById(customerId: number): Promise<import("./types").Customer>;
83
- /**
84
- * Get Refer By Wallet Address
85
- * @param wallet - The wallet address of the refer
86
- *
87
- */
88
- getReferByWallet(wallet: PublicKey): Promise<import("./types").Refer>;
89
83
  /**
90
84
  * Get Current Market ID
91
85
  *
@@ -119,7 +113,7 @@ export default class TriadProtocolClient {
119
113
  authority: PublicKey;
120
114
  totalDeposits: BN;
121
115
  totalWithdraws: BN;
122
- referId: BN;
116
+ padding1: number[];
123
117
  orders: {
124
118
  ts: BN;
125
119
  orderId: BN;
@@ -298,7 +292,8 @@ export default class TriadProtocolClient {
298
292
  * @param args.marketId - The ID of the Market
299
293
  * @param args.orderId - The ID of the Order to Payout
300
294
  * @param args.userNonce - The nonce of the user
301
- * @param args.isTrdPayout - Whether to payout in TRD or not
295
+ * @param args.mint - The mint of the market
296
+ * @param args.shares - The shares of the order
302
297
  *
303
298
  * @param options - RPC options
304
299
  *
@@ -309,8 +304,6 @@ export default class TriadProtocolClient {
309
304
  userNonce: number;
310
305
  mint: PublicKey;
311
306
  shares: number;
312
- isTrdPayout: boolean;
313
- isWinner: boolean;
314
307
  }[], options?: RpcOptions): Promise<string>;
315
308
  /**
316
309
  * Allow Market to Payout
@@ -364,7 +357,6 @@ export default class TriadProtocolClient {
364
357
  getUserTradeNonceWithSlots(userTrades: UserTrade[]): PublicKey;
365
358
  /**
366
359
  * Get User Trade Ixs
367
- * @param refer - The refer public key
368
360
  *
369
361
  */
370
362
  getUserTradeIxs(): Promise<{
@@ -496,13 +488,6 @@ export default class TriadProtocolClient {
496
488
  * @param options - RPC options
497
489
  */
498
490
  closeOrderBook(marketIds: number[], options?: RpcOptions): Promise<string>;
499
- /**
500
- * Create Refer
501
- * @param id - The ID of the refer
502
- *
503
- * @param options - RPC options
504
- */
505
- createRefer(options?: RpcOptions): Promise<string>;
506
491
  /**
507
492
  * Update Customer Fee
508
493
  * @param feeBps - The fee in basis points
package/dist/index.js CHANGED
@@ -192,18 +192,6 @@ class TriadProtocolClient {
192
192
  return (0, helpers_1.formatCustomer)(customer, customerPDA);
193
193
  });
194
194
  }
195
- /**
196
- * Get Refer By Wallet Address
197
- * @param wallet - The wallet address of the refer
198
- *
199
- */
200
- getReferByWallet(wallet) {
201
- return __awaiter(this, void 0, void 0, function* () {
202
- const referPDA = (0, pda_1.getReferPDA)(this.program.programId, wallet);
203
- const refer = yield this.program.account.refer.fetch(referPDA);
204
- return (0, helpers_1.formatRefer)(refer);
205
- });
206
- }
207
195
  /**
208
196
  * Get Current Market ID
209
197
  *
@@ -502,7 +490,8 @@ class TriadProtocolClient {
502
490
  * @param args.marketId - The ID of the Market
503
491
  * @param args.orderId - The ID of the Order to Payout
504
492
  * @param args.userNonce - The nonce of the user
505
- * @param args.isTrdPayout - Whether to payout in TRD or not
493
+ * @param args.mint - The mint of the market
494
+ * @param args.shares - The shares of the order
506
495
  *
507
496
  * @param options - RPC options
508
497
  *
@@ -524,21 +513,6 @@ class TriadProtocolClient {
524
513
  tokenProgram: (0, helpers_1.getTokenProgram)(order.mint)
525
514
  })
526
515
  .instruction());
527
- if (order.isTrdPayout && order.isWinner) {
528
- const { setupInstructions, swapIxs, addressLookupTableAccounts } = yield (0, swap_1.swap)({
529
- connection: this.program.provider.connection,
530
- wallet: this.program.provider.publicKey.toBase58(),
531
- inToken: constants_1.USDC_MINT.toBase58(),
532
- outToken: constants_1.TRD_MINT.toString(),
533
- amount: Math.floor(order.shares / Math.pow(10, this.decimals))
534
- });
535
- if (swapIxs.length === 0) {
536
- return;
537
- }
538
- ixs.push(...setupInstructions);
539
- ixs.push(...swapIxs);
540
- addressLookupTableAccounts.push(...addressLookupTableAccounts);
541
- }
542
516
  }
543
517
  return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
544
518
  });
@@ -671,7 +645,6 @@ class TriadProtocolClient {
671
645
  }
672
646
  /**
673
647
  * Get User Trade Ixs
674
- * @param refer - The refer public key
675
648
  *
676
649
  */
677
650
  getUserTradeIxs() {
@@ -679,13 +652,11 @@ class TriadProtocolClient {
679
652
  const ixs = [];
680
653
  let myUserTrades = [];
681
654
  myUserTrades = yield this.getMyUserTrades(this.program.provider.publicKey);
682
- let referPDA = null;
683
655
  if (myUserTrades.length === 0) {
684
656
  ixs.push(yield this.program.methods
685
657
  .createUserTrade()
686
658
  .accounts({
687
- signer: this.program.provider.publicKey,
688
- refer: referPDA
659
+ signer: this.program.provider.publicKey
689
660
  })
690
661
  .instruction());
691
662
  return {
@@ -1227,24 +1198,6 @@ class TriadProtocolClient {
1227
1198
  return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
1228
1199
  });
1229
1200
  }
1230
- /**
1231
- * Create Refer
1232
- * @param id - The ID of the refer
1233
- *
1234
- * @param options - RPC options
1235
- */
1236
- createRefer(options) {
1237
- return __awaiter(this, void 0, void 0, function* () {
1238
- const ixs = [];
1239
- ixs.push(yield this.program.methods
1240
- .createRefer()
1241
- .accounts({
1242
- signer: this.program.provider.publicKey
1243
- })
1244
- .instruction());
1245
- return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
1246
- });
1247
- }
1248
1201
  /**
1249
1202
  * Update Customer Fee
1250
1203
  * @param feeBps - The fee in basis points
@@ -919,50 +919,6 @@
919
919
  }
920
920
  ]
921
921
  },
922
- {
923
- "name": "create_refer",
924
- "discriminator": [63, 215, 18, 129, 0, 78, 205, 88],
925
- "accounts": [
926
- {
927
- "name": "signer",
928
- "writable": true,
929
- "signer": true
930
- },
931
- {
932
- "name": "global",
933
- "writable": true,
934
- "pda": {
935
- "seeds": [
936
- {
937
- "kind": "const",
938
- "value": [103, 108, 111, 98, 97, 108]
939
- }
940
- ]
941
- }
942
- },
943
- {
944
- "name": "refer",
945
- "writable": true,
946
- "pda": {
947
- "seeds": [
948
- {
949
- "kind": "const",
950
- "value": [114, 101, 102, 101, 114]
951
- },
952
- {
953
- "kind": "account",
954
- "path": "signer"
955
- }
956
- ]
957
- }
958
- },
959
- {
960
- "name": "system_program",
961
- "address": "11111111111111111111111111111111"
962
- }
963
- ],
964
- "args": []
965
- },
966
922
  {
967
923
  "name": "create_sub_user_trade",
968
924
  "discriminator": [77, 201, 111, 73, 47, 229, 244, 161],
@@ -1041,11 +997,6 @@
1041
997
  ]
1042
998
  }
1043
999
  },
1044
- {
1045
- "name": "refer",
1046
- "writable": true,
1047
- "optional": true
1048
- },
1049
1000
  {
1050
1001
  "name": "system_program",
1051
1002
  "address": "11111111111111111111111111111111"
@@ -2220,10 +2171,6 @@
2220
2171
  "name": "Customer",
2221
2172
  "discriminator": [112, 147, 140, 31, 93, 186, 103, 18]
2222
2173
  },
2223
- {
2224
- "name": "Global",
2225
- "discriminator": [167, 232, 232, 177, 200, 108, 114, 127]
2226
- },
2227
2174
  {
2228
2175
  "name": "MarketV2",
2229
2176
  "discriminator": [27, 60, 50, 75, 191, 193, 86, 227]
@@ -2240,10 +2187,6 @@
2240
2187
  "name": "Pool",
2241
2188
  "discriminator": [241, 154, 109, 4, 17, 177, 109, 188]
2242
2189
  },
2243
- {
2244
- "name": "Refer",
2245
- "discriminator": [5, 204, 50, 144, 77, 136, 87, 66]
2246
- },
2247
2190
  {
2248
2191
  "name": "StakeV3",
2249
2192
  "discriminator": [33, 54, 166, 108, 88, 184, 96, 190]
@@ -2839,9 +2782,7 @@
2839
2782
  },
2840
2783
  {
2841
2784
  "name": "fee_bps",
2842
- "docs": [
2843
- "Fee in basis points to receive from the market fee available"
2844
- ],
2785
+ "docs": ["Fee in basis points to receive from the market fee"],
2845
2786
  "type": "u16"
2846
2787
  },
2847
2788
  {
@@ -2857,40 +2798,6 @@
2857
2798
  ]
2858
2799
  }
2859
2800
  },
2860
- {
2861
- "name": "Global",
2862
- "type": {
2863
- "kind": "struct",
2864
- "fields": [
2865
- {
2866
- "name": "bump",
2867
- "type": "u8"
2868
- },
2869
- {
2870
- "name": "authority",
2871
- "type": "pubkey"
2872
- },
2873
- {
2874
- "name": "next_refer_id",
2875
- "type": "u64"
2876
- },
2877
- {
2878
- "name": "trd_price",
2879
- "type": "u64"
2880
- },
2881
- {
2882
- "name": "trd_price_ts",
2883
- "type": "i64"
2884
- },
2885
- {
2886
- "name": "padding",
2887
- "type": {
2888
- "array": ["u8", 428]
2889
- }
2890
- }
2891
- ]
2892
- }
2893
- },
2894
2801
  {
2895
2802
  "name": "Key",
2896
2803
  "type": {
@@ -3744,44 +3651,6 @@
3744
3651
  ]
3745
3652
  }
3746
3653
  },
3747
- {
3748
- "name": "Refer",
3749
- "type": {
3750
- "kind": "struct",
3751
- "fields": [
3752
- {
3753
- "name": "bump",
3754
- "type": "u8"
3755
- },
3756
- {
3757
- "name": "id",
3758
- "type": "u64"
3759
- },
3760
- {
3761
- "name": "authority",
3762
- "type": "pubkey"
3763
- },
3764
- {
3765
- "name": "fee_bps",
3766
- "type": "u16"
3767
- },
3768
- {
3769
- "name": "fee_claimed",
3770
- "type": "u64"
3771
- },
3772
- {
3773
- "name": "users_referred",
3774
- "type": "u64"
3775
- },
3776
- {
3777
- "name": "padding",
3778
- "type": {
3779
- "array": ["u8", 24]
3780
- }
3781
- }
3782
- ]
3783
- }
3784
- },
3785
3654
  {
3786
3655
  "name": "RequestUnstakeArgs",
3787
3656
  "type": {
@@ -4073,8 +3942,10 @@
4073
3942
  "type": "u64"
4074
3943
  },
4075
3944
  {
4076
- "name": "refer_id",
4077
- "type": "u64"
3945
+ "name": "padding_1",
3946
+ "type": {
3947
+ "array": ["u8", 8]
3948
+ }
4078
3949
  },
4079
3950
  {
4080
3951
  "name": "orders",
@@ -240,13 +240,6 @@ export type MarketAskOrderArgs = {
240
240
  isTrdPayout: boolean;
241
241
  feeBps: number;
242
242
  };
243
- export type Refer = {
244
- id: number;
245
- authority: string;
246
- feeBps: number;
247
- feeClaimed: number;
248
- usersReferred: number;
249
- };
250
243
  export type Customer = {
251
244
  id: number;
252
245
  authority: string;
@@ -1285,50 +1285,6 @@ export type TriadProtocol = {
1285
1285
  }
1286
1286
  ];
1287
1287
  },
1288
- {
1289
- name: 'createRefer';
1290
- discriminator: [63, 215, 18, 129, 0, 78, 205, 88];
1291
- accounts: [
1292
- {
1293
- name: 'signer';
1294
- writable: true;
1295
- signer: true;
1296
- },
1297
- {
1298
- name: 'global';
1299
- writable: true;
1300
- pda: {
1301
- seeds: [
1302
- {
1303
- kind: 'const';
1304
- value: [103, 108, 111, 98, 97, 108];
1305
- }
1306
- ];
1307
- };
1308
- },
1309
- {
1310
- name: 'refer';
1311
- writable: true;
1312
- pda: {
1313
- seeds: [
1314
- {
1315
- kind: 'const';
1316
- value: [114, 101, 102, 101, 114];
1317
- },
1318
- {
1319
- kind: 'account';
1320
- path: 'signer';
1321
- }
1322
- ];
1323
- };
1324
- },
1325
- {
1326
- name: 'systemProgram';
1327
- address: '11111111111111111111111111111111';
1328
- }
1329
- ];
1330
- args: [];
1331
- },
1332
1288
  {
1333
1289
  name: 'createSubUserTrade';
1334
1290
  discriminator: [77, 201, 111, 73, 47, 229, 244, 161];
@@ -1407,11 +1363,6 @@ export type TriadProtocol = {
1407
1363
  ];
1408
1364
  };
1409
1365
  },
1410
- {
1411
- name: 'refer';
1412
- writable: true;
1413
- optional: true;
1414
- },
1415
1366
  {
1416
1367
  name: 'systemProgram';
1417
1368
  address: '11111111111111111111111111111111';
@@ -3040,10 +2991,6 @@ export type TriadProtocol = {
3040
2991
  name: 'customer';
3041
2992
  discriminator: [112, 147, 140, 31, 93, 186, 103, 18];
3042
2993
  },
3043
- {
3044
- name: 'global';
3045
- discriminator: [167, 232, 232, 177, 200, 108, 114, 127];
3046
- },
3047
2994
  {
3048
2995
  name: 'marketV2';
3049
2996
  discriminator: [27, 60, 50, 75, 191, 193, 86, 227];
@@ -3060,10 +3007,6 @@ export type TriadProtocol = {
3060
3007
  name: 'pool';
3061
3008
  discriminator: [241, 154, 109, 4, 17, 177, 109, 188];
3062
3009
  },
3063
- {
3064
- name: 'refer';
3065
- discriminator: [5, 204, 50, 144, 77, 136, 87, 66];
3066
- },
3067
3010
  {
3068
3011
  name: 'stakeV3';
3069
3012
  discriminator: [33, 54, 166, 108, 88, 184, 96, 190];
@@ -3659,9 +3602,7 @@ export type TriadProtocol = {
3659
3602
  },
3660
3603
  {
3661
3604
  name: 'feeBps';
3662
- docs: [
3663
- 'Fee in basis points to receive from the market fee available'
3664
- ];
3605
+ docs: ['Fee in basis points to receive from the market fee'];
3665
3606
  type: 'u16';
3666
3607
  },
3667
3608
  {
@@ -3677,40 +3618,6 @@ export type TriadProtocol = {
3677
3618
  ];
3678
3619
  };
3679
3620
  },
3680
- {
3681
- name: 'global';
3682
- type: {
3683
- kind: 'struct';
3684
- fields: [
3685
- {
3686
- name: 'bump';
3687
- type: 'u8';
3688
- },
3689
- {
3690
- name: 'authority';
3691
- type: 'pubkey';
3692
- },
3693
- {
3694
- name: 'nextReferId';
3695
- type: 'u64';
3696
- },
3697
- {
3698
- name: 'trdPrice';
3699
- type: 'u64';
3700
- },
3701
- {
3702
- name: 'trdPriceTs';
3703
- type: 'i64';
3704
- },
3705
- {
3706
- name: 'padding';
3707
- type: {
3708
- array: ['u8', 428];
3709
- };
3710
- }
3711
- ];
3712
- };
3713
- },
3714
3621
  {
3715
3622
  name: 'key';
3716
3623
  type: {
@@ -4564,44 +4471,6 @@ export type TriadProtocol = {
4564
4471
  ];
4565
4472
  };
4566
4473
  },
4567
- {
4568
- name: 'refer';
4569
- type: {
4570
- kind: 'struct';
4571
- fields: [
4572
- {
4573
- name: 'bump';
4574
- type: 'u8';
4575
- },
4576
- {
4577
- name: 'id';
4578
- type: 'u64';
4579
- },
4580
- {
4581
- name: 'authority';
4582
- type: 'pubkey';
4583
- },
4584
- {
4585
- name: 'feeBps';
4586
- type: 'u16';
4587
- },
4588
- {
4589
- name: 'feeClaimed';
4590
- type: 'u64';
4591
- },
4592
- {
4593
- name: 'usersReferred';
4594
- type: 'u64';
4595
- },
4596
- {
4597
- name: 'padding';
4598
- type: {
4599
- array: ['u8', 24];
4600
- };
4601
- }
4602
- ];
4603
- };
4604
- },
4605
4474
  {
4606
4475
  name: 'requestUnstakeArgs';
4607
4476
  type: {
@@ -4893,8 +4762,10 @@ export type TriadProtocol = {
4893
4762
  type: 'u64';
4894
4763
  },
4895
4764
  {
4896
- name: 'referId';
4897
- type: 'u64';
4765
+ name: 'padding1';
4766
+ type: {
4767
+ array: ['u8', 8];
4768
+ };
4898
4769
  },
4899
4770
  {
4900
4771
  name: 'orders';
@@ -1,7 +1,7 @@
1
1
  import { PublicKey } from '@solana/web3.js';
2
2
  import { IdlAccounts } from '@coral-xyz/anchor';
3
3
  import { Stake, StakeVault, Unstake } from './../types/stake';
4
- import { Market, Order, OrderDirection, OrderSide, OrderStatus, OrderType, UserTrade, Pool, BookOrder, Refer, Customer } from '../types';
4
+ import { Market, Order, OrderDirection, OrderSide, OrderStatus, OrderType, UserTrade, Pool, BookOrder, Customer } from '../types';
5
5
  import { TriadProtocol } from '../types/triad_protocol';
6
6
  export declare const encodeString: (value: string, alloc?: number) => number[];
7
7
  export declare const decodeString: (bytes: number[]) => string;
@@ -45,5 +45,4 @@ export declare const getOrderStatus: (status: {
45
45
  } | {
46
46
  waiting: {};
47
47
  }) => OrderStatus;
48
- export declare const formatRefer: (account: IdlAccounts<TriadProtocol>['refer']) => Refer;
49
48
  export declare const formatCustomer: (account: IdlAccounts<TriadProtocol>['customer'], publicKey: PublicKey) => Customer;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formatCustomer = exports.formatRefer = exports.getOrderStatus = exports.getOrderSide = exports.getOrderType = exports.getOrderSideFromNumber = exports.getOrderDirectionFromNumber = exports.getOrderDirection = exports.getTokenProgram = exports.calculateStakeRewards = exports.formatBookOrder = exports.formatOrder = exports.formatUserTrade = exports.formatMarket = exports.formatPool = exports.formatUnstake = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
3
+ exports.formatCustomer = exports.getOrderStatus = exports.getOrderSide = exports.getOrderType = exports.getOrderSideFromNumber = exports.getOrderDirectionFromNumber = exports.getOrderDirection = exports.getTokenProgram = exports.calculateStakeRewards = exports.formatBookOrder = exports.formatOrder = exports.formatUserTrade = exports.formatMarket = exports.formatPool = exports.formatUnstake = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
4
4
  const web3_js_1 = require("@solana/web3.js");
5
5
  const spl_token_1 = require("@solana/spl-token");
6
6
  const types_1 = require("../types");
@@ -227,16 +227,6 @@ const getOrderStatus = (status) => {
227
227
  }
228
228
  };
229
229
  exports.getOrderStatus = getOrderStatus;
230
- const formatRefer = (account) => {
231
- return {
232
- id: account.id.toNumber(),
233
- authority: account.authority.toString(),
234
- feeBps: account.feeBps,
235
- feeClaimed: account.feeClaimed.toNumber(),
236
- usersReferred: account.usersReferred.toNumber()
237
- };
238
- };
239
- exports.formatRefer = formatRefer;
240
230
  const formatCustomer = (account, publicKey) => {
241
231
  return {
242
232
  id: account.id,
@@ -6,4 +6,3 @@ export declare const getCustomerPDA: (programId: PublicKey, customerId: number)
6
6
  export declare const getUserTradePDA: (programId: PublicKey, wallet: PublicKey) => PublicKey;
7
7
  export declare const getSubUserTradePDA: (programId: PublicKey, wallet: PublicKey, nonce: number) => PublicKey;
8
8
  export declare const getPoolPDA: (programId: PublicKey, poolId: number) => PublicKey;
9
- export declare const getReferPDA: (programId: PublicKey, refer: PublicKey) => PublicKey;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getReferPDA = exports.getPoolPDA = exports.getSubUserTradePDA = exports.getUserTradePDA = exports.getCustomerPDA = exports.getOrderBookPDA = exports.getMarketPDA = exports.getTokenATA = void 0;
6
+ exports.getPoolPDA = exports.getSubUserTradePDA = exports.getUserTradePDA = exports.getCustomerPDA = exports.getOrderBookPDA = exports.getMarketPDA = exports.getTokenATA = void 0;
7
7
  const web3_js_1 = require("@solana/web3.js");
8
8
  const bn_js_1 = __importDefault(require("bn.js"));
9
9
  const spl_token_1 = require("@solana/spl-token");
@@ -39,7 +39,3 @@ const getPoolPDA = (programId, poolId) => {
39
39
  return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('pool'), new bn_js_1.default(poolId).toArrayLike(Buffer, 'le', 8)], programId)[0];
40
40
  };
41
41
  exports.getPoolPDA = getPoolPDA;
42
- const getReferPDA = (programId, refer) => {
43
- return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('refer'), refer.toBuffer()], programId)[0];
44
- };
45
- exports.getReferPDA = getReferPDA;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "3.1.0-beta",
3
+ "version": "3.1.1-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",