@triadxyz/triad-protocol 4.0.3 → 4.0.4-beta.1

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.
@@ -16,12 +16,12 @@ export default class Customer {
16
16
  * Get Costumer By Wallet Address
17
17
  * @param wallet - The wallet address of the customer
18
18
  */
19
- getCustomerByWallet(wallet: PublicKey): Promise<import("@triadxyz/triad-protocol").Customer>;
19
+ getCustomerByWallet(wallet: PublicKey): Promise<import("./types/customer").Customer>;
20
20
  /**
21
21
  * Get Customer By ID
22
22
  * @param customerId - The ID of the customer
23
23
  */
24
- getCustomerById(customerId: number): Promise<import("@triadxyz/triad-protocol").Customer>;
24
+ getCustomerById(customerId: number): Promise<import("./types/customer").Customer>;
25
25
  /**
26
26
  * Create Customer
27
27
  * @param args.id - The ID of the customer
package/dist/customer.js CHANGED
@@ -13,7 +13,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersionedTransaction"));
16
- const triad_protocol_1 = require("@triadxyz/triad-protocol");
16
+ const helpers_1 = require("./utils/helpers");
17
+ const pda_1 = require("./utils/pda");
17
18
  class Customer {
18
19
  constructor(program, rpcOptions) {
19
20
  this.program = program;
@@ -42,7 +43,7 @@ class Customer {
42
43
  }
43
44
  }
44
45
  ]);
45
- return (0, triad_protocol_1.formatCustomer)(customer.account, customer.publicKey);
46
+ return (0, helpers_1.formatCustomer)(customer.account, customer.publicKey);
46
47
  });
47
48
  }
48
49
  /**
@@ -51,9 +52,9 @@ class Customer {
51
52
  */
52
53
  getCustomerById(customerId) {
53
54
  return __awaiter(this, void 0, void 0, function* () {
54
- const customerPDA = (0, triad_protocol_1.getCustomerPDA)(this.program.programId, customerId);
55
+ const customerPDA = (0, pda_1.getCustomerPDA)(this.program.programId, customerId);
55
56
  const customer = yield this.program.account.customer.fetch(customerPDA, this.rpcOptions.commitment);
56
- return (0, triad_protocol_1.formatCustomer)(customer, customerPDA);
57
+ return (0, helpers_1.formatCustomer)(customer, customerPDA);
57
58
  });
58
59
  }
59
60
  /**
package/dist/predictor.js CHANGED
@@ -18,6 +18,7 @@ const constants_1 = require("./utils/constants");
18
18
  const pda_1 = require("./utils/pda");
19
19
  const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersionedTransaction"));
20
20
  const helpers_1 = require("./utils/helpers");
21
+ const spl_token_1 = require("@solana/spl-token");
21
22
  class Predictor {
22
23
  constructor(program, rpcOptions) {
23
24
  this.program = program;
@@ -33,7 +34,7 @@ class Predictor {
33
34
  const predictorPDA = (0, pda_1.getPredictorPDA)(this.program.programId, authority, customerId);
34
35
  try {
35
36
  const predictor = yield this.program.account.predictor.fetch(predictorPDA);
36
- const balance = yield this.program.provider.connection.getTokenAccountBalance((0, pda_1.getTokenATA)(authority, constants_1.UNIT_MINT, this.program.programId));
37
+ const balance = yield this.program.provider.connection.getTokenAccountBalance((0, pda_1.getTokenATA)(predictorPDA, constants_1.UNIT_MINT, spl_token_1.TOKEN_PROGRAM_ID));
37
38
  return (0, helpers_1.formatPredictor)(predictor, predictorPDA, new bn_js_1.default(balance.value.amount));
38
39
  }
39
40
  catch (e) {
@@ -1,4 +1,3 @@
1
- /// <reference types="@coral-xyz/anchor/node_modules/@solana/web3.js" />
2
1
  import { PublicKey } from '@solana/web3.js';
3
2
  export type Customer = {
4
3
  id: number;
@@ -422,9 +422,8 @@
422
422
  "signer": true
423
423
  },
424
424
  {
425
- "name": "squads",
426
- "writable": true,
427
- "address": "Hk1r2NUL4LbUhx1agg1w44tyZiNr72mbeLsg6suF5MA4"
425
+ "name": "authority",
426
+ "writable": true
428
427
  },
429
428
  {
430
429
  "name": "market",
@@ -1509,6 +1508,116 @@
1509
1508
  }
1510
1509
  ]
1511
1510
  },
1511
+ {
1512
+ "name": "place_order_v0",
1513
+ "discriminator": [100, 204, 57, 226, 245, 228, 61, 187],
1514
+ "accounts": [
1515
+ {
1516
+ "name": "signer",
1517
+ "writable": true,
1518
+ "signer": true
1519
+ },
1520
+ {
1521
+ "name": "payer",
1522
+ "writable": true,
1523
+ "signer": true
1524
+ },
1525
+ {
1526
+ "name": "market",
1527
+ "writable": true
1528
+ },
1529
+ {
1530
+ "name": "order_book",
1531
+ "writable": true
1532
+ },
1533
+ {
1534
+ "name": "order",
1535
+ "writable": true
1536
+ },
1537
+ {
1538
+ "name": "mint",
1539
+ "address": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
1540
+ },
1541
+ {
1542
+ "name": "user_ata",
1543
+ "writable": true,
1544
+ "pda": {
1545
+ "seeds": [
1546
+ {
1547
+ "kind": "account",
1548
+ "path": "signer"
1549
+ },
1550
+ {
1551
+ "kind": "account",
1552
+ "path": "token_program"
1553
+ },
1554
+ {
1555
+ "kind": "account",
1556
+ "path": "mint"
1557
+ }
1558
+ ],
1559
+ "program": {
1560
+ "kind": "const",
1561
+ "value": [
1562
+ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
1563
+ 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
1564
+ 219, 233, 248, 89
1565
+ ]
1566
+ }
1567
+ }
1568
+ },
1569
+ {
1570
+ "name": "market_ata",
1571
+ "writable": true,
1572
+ "pda": {
1573
+ "seeds": [
1574
+ {
1575
+ "kind": "account",
1576
+ "path": "market"
1577
+ },
1578
+ {
1579
+ "kind": "account",
1580
+ "path": "token_program"
1581
+ },
1582
+ {
1583
+ "kind": "account",
1584
+ "path": "mint"
1585
+ }
1586
+ ],
1587
+ "program": {
1588
+ "kind": "const",
1589
+ "value": [
1590
+ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
1591
+ 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
1592
+ 219, 233, 248, 89
1593
+ ]
1594
+ }
1595
+ }
1596
+ },
1597
+ {
1598
+ "name": "token_program",
1599
+ "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
1600
+ },
1601
+ {
1602
+ "name": "associated_token_program",
1603
+ "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
1604
+ },
1605
+ {
1606
+ "name": "system_program",
1607
+ "address": "11111111111111111111111111111111"
1608
+ }
1609
+ ],
1610
+ "args": [
1611
+ {
1612
+ "name": "args",
1613
+ "type": {
1614
+ "defined": {
1615
+ "name": "PlaceOrderV0Args"
1616
+ }
1617
+ }
1618
+ }
1619
+ ]
1620
+ },
1512
1621
  {
1513
1622
  "name": "remove_trader_poseidon",
1514
1623
  "discriminator": [150, 5, 46, 188, 189, 13, 246, 11],
@@ -2369,10 +2478,6 @@
2369
2478
  "name": "ActivityEvent",
2370
2479
  "discriminator": [231, 225, 142, 104, 209, 97, 39, 202]
2371
2480
  },
2372
- {
2373
- "name": "BookOrderEvent",
2374
- "discriminator": [175, 216, 61, 224, 98, 215, 181, 62]
2375
- },
2376
2481
  {
2377
2482
  "name": "ClaimTokenEvent",
2378
2483
  "discriminator": [127, 10, 14, 49, 47, 171, 31, 127]
@@ -2744,66 +2849,6 @@
2744
2849
  ]
2745
2850
  }
2746
2851
  },
2747
- {
2748
- "name": "BookOrderEvent",
2749
- "type": {
2750
- "kind": "struct",
2751
- "fields": [
2752
- {
2753
- "name": "market_id",
2754
- "type": "u64"
2755
- },
2756
- {
2757
- "name": "timestamp",
2758
- "type": "i64"
2759
- },
2760
- {
2761
- "name": "price",
2762
- "type": "u64"
2763
- },
2764
- {
2765
- "name": "total_shares",
2766
- "type": "u64"
2767
- },
2768
- {
2769
- "name": "filled_shares",
2770
- "type": "u64"
2771
- },
2772
- {
2773
- "name": "authority",
2774
- "type": "pubkey"
2775
- },
2776
- {
2777
- "name": "user_nonce",
2778
- "type": "u32"
2779
- },
2780
- {
2781
- "name": "id",
2782
- "type": "u8"
2783
- },
2784
- {
2785
- "name": "linked_book_order_id",
2786
- "type": "u8"
2787
- },
2788
- {
2789
- "name": "order_direction",
2790
- "type": {
2791
- "defined": {
2792
- "name": "OrderDirection"
2793
- }
2794
- }
2795
- },
2796
- {
2797
- "name": "order_side",
2798
- "type": {
2799
- "defined": {
2800
- "name": "OrderSide"
2801
- }
2802
- }
2803
- }
2804
- ]
2805
- }
2806
- },
2807
2852
  {
2808
2853
  "name": "CancelOrderArgs",
2809
2854
  "type": {
@@ -3806,6 +3851,38 @@
3806
3851
  ]
3807
3852
  }
3808
3853
  },
3854
+ {
3855
+ "name": "PlaceOrderV0Args",
3856
+ "type": {
3857
+ "kind": "struct",
3858
+ "fields": [
3859
+ {
3860
+ "name": "shares",
3861
+ "type": "u64"
3862
+ },
3863
+ {
3864
+ "name": "price",
3865
+ "type": "u64"
3866
+ },
3867
+ {
3868
+ "name": "order_direction",
3869
+ "type": {
3870
+ "defined": {
3871
+ "name": "OrderDirection"
3872
+ }
3873
+ }
3874
+ },
3875
+ {
3876
+ "name": "order_side",
3877
+ "type": {
3878
+ "defined": {
3879
+ "name": "OrderSide"
3880
+ }
3881
+ }
3882
+ }
3883
+ ]
3884
+ }
3885
+ },
3809
3886
  {
3810
3887
  "name": "Pool",
3811
3888
  "type": {
@@ -1,4 +1,3 @@
1
- /// <reference types="@coral-xyz/anchor/node_modules/@solana/web3.js" />
2
1
  import { Commitment, PublicKey } from '@solana/web3.js';
3
2
  export type RpcOptions = {
4
3
  skipPreflight?: boolean;
@@ -1,4 +1,3 @@
1
- /// <reference types="@coral-xyz/anchor/node_modules/@solana/web3.js" />
2
1
  import { PublicKey } from '@solana/web3.js';
3
2
  export type Predictor = {
4
3
  address: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="@coral-xyz/anchor/node_modules/@solana/web3.js" />
2
1
  import { PublicKey } from '@solana/web3.js';
3
2
  import { OrderDirectionEncoded } from './';
4
3
  export type PlaceBidOrderArgs = {
@@ -626,9 +626,8 @@ export type TriadProtocol = {
626
626
  signer: true;
627
627
  },
628
628
  {
629
- name: 'squads';
629
+ name: 'authority';
630
630
  writable: true;
631
- address: 'Hk1r2NUL4LbUhx1agg1w44tyZiNr72mbeLsg6suF5MA4';
632
631
  },
633
632
  {
634
633
  name: 'market';
@@ -2159,6 +2158,174 @@ export type TriadProtocol = {
2159
2158
  }
2160
2159
  ];
2161
2160
  },
2161
+ {
2162
+ name: 'placeOrderV0';
2163
+ discriminator: [100, 204, 57, 226, 245, 228, 61, 187];
2164
+ accounts: [
2165
+ {
2166
+ name: 'signer';
2167
+ writable: true;
2168
+ signer: true;
2169
+ },
2170
+ {
2171
+ name: 'payer';
2172
+ writable: true;
2173
+ signer: true;
2174
+ },
2175
+ {
2176
+ name: 'market';
2177
+ writable: true;
2178
+ },
2179
+ {
2180
+ name: 'orderBook';
2181
+ writable: true;
2182
+ },
2183
+ {
2184
+ name: 'order';
2185
+ writable: true;
2186
+ },
2187
+ {
2188
+ name: 'mint';
2189
+ address: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v';
2190
+ },
2191
+ {
2192
+ name: 'userAta';
2193
+ writable: true;
2194
+ pda: {
2195
+ seeds: [
2196
+ {
2197
+ kind: 'account';
2198
+ path: 'signer';
2199
+ },
2200
+ {
2201
+ kind: 'account';
2202
+ path: 'tokenProgram';
2203
+ },
2204
+ {
2205
+ kind: 'account';
2206
+ path: 'mint';
2207
+ }
2208
+ ];
2209
+ program: {
2210
+ kind: 'const';
2211
+ value: [
2212
+ 140,
2213
+ 151,
2214
+ 37,
2215
+ 143,
2216
+ 78,
2217
+ 36,
2218
+ 137,
2219
+ 241,
2220
+ 187,
2221
+ 61,
2222
+ 16,
2223
+ 41,
2224
+ 20,
2225
+ 142,
2226
+ 13,
2227
+ 131,
2228
+ 11,
2229
+ 90,
2230
+ 19,
2231
+ 153,
2232
+ 218,
2233
+ 255,
2234
+ 16,
2235
+ 132,
2236
+ 4,
2237
+ 142,
2238
+ 123,
2239
+ 216,
2240
+ 219,
2241
+ 233,
2242
+ 248,
2243
+ 89
2244
+ ];
2245
+ };
2246
+ };
2247
+ },
2248
+ {
2249
+ name: 'marketAta';
2250
+ writable: true;
2251
+ pda: {
2252
+ seeds: [
2253
+ {
2254
+ kind: 'account';
2255
+ path: 'market';
2256
+ },
2257
+ {
2258
+ kind: 'account';
2259
+ path: 'tokenProgram';
2260
+ },
2261
+ {
2262
+ kind: 'account';
2263
+ path: 'mint';
2264
+ }
2265
+ ];
2266
+ program: {
2267
+ kind: 'const';
2268
+ value: [
2269
+ 140,
2270
+ 151,
2271
+ 37,
2272
+ 143,
2273
+ 78,
2274
+ 36,
2275
+ 137,
2276
+ 241,
2277
+ 187,
2278
+ 61,
2279
+ 16,
2280
+ 41,
2281
+ 20,
2282
+ 142,
2283
+ 13,
2284
+ 131,
2285
+ 11,
2286
+ 90,
2287
+ 19,
2288
+ 153,
2289
+ 218,
2290
+ 255,
2291
+ 16,
2292
+ 132,
2293
+ 4,
2294
+ 142,
2295
+ 123,
2296
+ 216,
2297
+ 219,
2298
+ 233,
2299
+ 248,
2300
+ 89
2301
+ ];
2302
+ };
2303
+ };
2304
+ },
2305
+ {
2306
+ name: 'tokenProgram';
2307
+ address: 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA';
2308
+ },
2309
+ {
2310
+ name: 'associatedTokenProgram';
2311
+ address: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
2312
+ },
2313
+ {
2314
+ name: 'systemProgram';
2315
+ address: '11111111111111111111111111111111';
2316
+ }
2317
+ ];
2318
+ args: [
2319
+ {
2320
+ name: 'args';
2321
+ type: {
2322
+ defined: {
2323
+ name: 'placeOrderV0Args';
2324
+ };
2325
+ };
2326
+ }
2327
+ ];
2328
+ },
2162
2329
  {
2163
2330
  name: 'removeTraderPoseidon';
2164
2331
  discriminator: [150, 5, 46, 188, 189, 13, 246, 11];
@@ -3257,10 +3424,6 @@ export type TriadProtocol = {
3257
3424
  name: 'activityEvent';
3258
3425
  discriminator: [231, 225, 142, 104, 209, 97, 39, 202];
3259
3426
  },
3260
- {
3261
- name: 'bookOrderEvent';
3262
- discriminator: [175, 216, 61, 224, 98, 215, 181, 62];
3263
- },
3264
3427
  {
3265
3428
  name: 'claimTokenEvent';
3266
3429
  discriminator: [127, 10, 14, 49, 47, 171, 31, 127];
@@ -3632,66 +3795,6 @@ export type TriadProtocol = {
3632
3795
  ];
3633
3796
  };
3634
3797
  },
3635
- {
3636
- name: 'bookOrderEvent';
3637
- type: {
3638
- kind: 'struct';
3639
- fields: [
3640
- {
3641
- name: 'marketId';
3642
- type: 'u64';
3643
- },
3644
- {
3645
- name: 'timestamp';
3646
- type: 'i64';
3647
- },
3648
- {
3649
- name: 'price';
3650
- type: 'u64';
3651
- },
3652
- {
3653
- name: 'totalShares';
3654
- type: 'u64';
3655
- },
3656
- {
3657
- name: 'filledShares';
3658
- type: 'u64';
3659
- },
3660
- {
3661
- name: 'authority';
3662
- type: 'pubkey';
3663
- },
3664
- {
3665
- name: 'userNonce';
3666
- type: 'u32';
3667
- },
3668
- {
3669
- name: 'id';
3670
- type: 'u8';
3671
- },
3672
- {
3673
- name: 'linkedBookOrderId';
3674
- type: 'u8';
3675
- },
3676
- {
3677
- name: 'orderDirection';
3678
- type: {
3679
- defined: {
3680
- name: 'orderDirection';
3681
- };
3682
- };
3683
- },
3684
- {
3685
- name: 'orderSide';
3686
- type: {
3687
- defined: {
3688
- name: 'orderSide';
3689
- };
3690
- };
3691
- }
3692
- ];
3693
- };
3694
- },
3695
3798
  {
3696
3799
  name: 'cancelOrderArgs';
3697
3800
  type: {
@@ -4694,6 +4797,38 @@ export type TriadProtocol = {
4694
4797
  ];
4695
4798
  };
4696
4799
  },
4800
+ {
4801
+ name: 'placeOrderV0Args';
4802
+ type: {
4803
+ kind: 'struct';
4804
+ fields: [
4805
+ {
4806
+ name: 'shares';
4807
+ type: 'u64';
4808
+ },
4809
+ {
4810
+ name: 'price';
4811
+ type: 'u64';
4812
+ },
4813
+ {
4814
+ name: 'orderDirection';
4815
+ type: {
4816
+ defined: {
4817
+ name: 'orderDirection';
4818
+ };
4819
+ };
4820
+ },
4821
+ {
4822
+ name: 'orderSide';
4823
+ type: {
4824
+ defined: {
4825
+ name: 'orderSide';
4826
+ };
4827
+ };
4828
+ }
4829
+ ];
4830
+ };
4831
+ },
4697
4832
  {
4698
4833
  name: 'pool';
4699
4834
  type: {
@@ -1,4 +1,3 @@
1
- /// <reference types="@coral-xyz/anchor/node_modules/@solana/web3.js" />
2
1
  import { PublicKey } from '@solana/web3.js';
3
2
  export declare const USDC_MINT: PublicKey;
4
3
  export declare const TRD_MINT: PublicKey;
@@ -8,16 +8,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
11
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const axios_1 = __importDefault(require("axios"));
16
12
  const getPriorityFee = () => __awaiter(void 0, void 0, void 0, function* () {
17
13
  let fee = 1000;
18
14
  try {
19
- const response = yield axios_1.default.get('https://solanacompass.com/api/fees');
20
- fee = response.data[1].priorityTx;
15
+ const response = yield fetch('https://solanacompass.com/api/fees');
16
+ const data = yield response.json();
17
+ fee = data[1].priorityTx;
21
18
  }
22
19
  catch (_a) { }
23
20
  return fee;
@@ -1,4 +1,3 @@
1
- /// <reference types="@coral-xyz/anchor/node_modules/@solana/web3.js" />
2
1
  import { PublicKey } from '@solana/web3.js';
3
2
  import { OrderDirection } from '../types';
4
3
  export declare const getTokenATA: (address: PublicKey, Mint: PublicKey, program?: PublicKey) => PublicKey;
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "4.0.3",
3
+ "version": "4.0.4-beta.1",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "scripts": {
8
8
  "clean": "rimraf dist",
9
9
  "build": "yarn run clean && tsc",
10
+ "docs": "typedoc",
10
11
  "prepublishOnly": "yarn build"
11
12
  },
12
13
  "publishConfig": {
@@ -34,20 +35,12 @@
34
35
  "@coral-xyz/anchor": "0.30.1",
35
36
  "@solana/spl-token": "0.4.8",
36
37
  "@solana/web3.js": "1.95.3",
37
- "axios": "1.9.0",
38
- "bn.js": "5.2.2",
38
+ "bn.js": "5.2.3",
39
39
  "bs58": "6.0.0"
40
40
  },
41
41
  "devDependencies": {
42
- "@typescript-eslint/eslint-plugin": "6.7.3",
43
- "@typescript-eslint/parser": "6.7.3",
44
42
  "@types/bn.js": "^5.1.0",
45
- "eslint": "8.50.0",
46
- "eslint-config-prettier": "9.0.0",
47
- "eslint-plugin-prettier": "5.0.0",
48
- "prettier": "3.2.4",
49
- "rimraf": "^5.0.5",
50
- "typedoc": "0.25.1",
43
+ "rimraf": "6.1.3",
51
44
  "typescript": "5.2.2"
52
45
  }
53
46
  }