@triadxyz/triad-protocol 4.0.5 → 4.0.7

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/README.md CHANGED
@@ -111,4 +111,4 @@ The documentation will be available in the `docs/` folder.
111
111
 
112
112
  ## 📄 License
113
113
 
114
- MIT
114
+ ISC
@@ -1,3 +1,4 @@
1
+ /// <reference types="jito-ts/node_modules/@solana/web3.js" />
1
2
  import { PublicKey } from '@solana/web3.js';
2
3
  import { Program } from '@coral-xyz/anchor';
3
4
  import { TriadProtocol } from './types/triad_protocol';
@@ -27,6 +28,7 @@ export default class Customer {
27
28
  * @param args.name - The name of the customer
28
29
  * @param args.authority - The authority of the customer
29
30
  * @param args.feeRecipient - The fee recipient of the customer
31
+ * @param args.feeBps - The fee in basis points of the customer
30
32
  */
31
- createCustomer({ id, name, authority, feeRecipient }: CreateCustomerArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
33
+ createCustomer({ id, name, authority, feeRecipient, feeBps }: CreateCustomerArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
32
34
  }
package/dist/customer.js CHANGED
@@ -63,12 +63,13 @@ class Customer {
63
63
  * @param args.name - The name of the customer
64
64
  * @param args.authority - The authority of the customer
65
65
  * @param args.feeRecipient - The fee recipient of the customer
66
+ * @param args.feeBps - The fee in basis points of the customer
66
67
  */
67
- createCustomer({ id, name, authority, feeRecipient }) {
68
+ createCustomer({ id, name, authority, feeRecipient, feeBps }) {
68
69
  return __awaiter(this, void 0, void 0, function* () {
69
70
  const ixs = [
70
71
  yield this.program.methods
71
- .createCustomer({ id, name, authority, feeRecipient })
72
+ .createCustomer({ id, name, authority, feeRecipient, feeBps })
72
73
  .accounts({
73
74
  signer: this.program.provider.publicKey
74
75
  })
package/dist/index.d.ts CHANGED
@@ -1,12 +1,14 @@
1
+ /// <reference types="jito-ts/node_modules/@solana/web3.js" />
1
2
  import { Connection, PublicKey } from '@solana/web3.js';
2
3
  import { AnchorProvider, Program, Wallet } from '@coral-xyz/anchor';
3
4
  import { TriadProtocol as TriadProtocolIDL } from './types/triad_protocol';
4
- import { RpcOptions, CreateMarketArgs, CreatePoolArgs, UpdateMarketWinningDirectionArgs, UpdateMarketPayoutArgs, UpdateMarketQuestionArgs, UpdateMarketEndArgs } from './types';
5
+ import { RpcOptions, CreateMarketArgs, CreatePoolArgs, UpdateMarketWinningDirectionArgs, UpdateMarketPayoutArgs, UpdateMarketQuestionArgs, UpdateMarketEndArgs, CreateMarketPythArgs } from './types';
5
6
  import Stake from './stake';
6
7
  import Poseidon from './poseidon';
7
8
  import Predictor from './predictor';
8
9
  import Trade from './trade';
9
10
  import Customer from './customer';
11
+ import { PythSolanaReceiver } from '@pythnetwork/pyth-solana-receiver';
10
12
  export * from './types';
11
13
  export * from './types/predictor';
12
14
  export * from './types/stake';
@@ -27,6 +29,7 @@ export default class TriadProtocol {
27
29
  predictor: Predictor;
28
30
  trade: Trade;
29
31
  customer: Customer;
32
+ pythSolanaReceiver: PythSolanaReceiver;
30
33
  constructor(connection: Connection, wallet: Wallet, rpcOptions: RpcOptions);
31
34
  /**
32
35
  * Get User Orders
@@ -102,6 +105,14 @@ export default class TriadProtocol {
102
105
  * @param poolId - The ID of the pool
103
106
  * @param question - The question of the pool
104
107
  * @param markets - The markets of the pool
108
+ * @param customer - The customer of the pool
109
+ * @param startTime - The start time of the pool
110
+ * @param endTime - The end time of the pool
111
+ * @param feeBps - The fee in basis points of the pool
112
+ * @param payoutFee - The payout fee of the pool
113
+ * @param isFast - Whether the pool is fast
114
+ * @param isPyth - Whether the pool is pyth
115
+ * @param feedId - The feed ID of the pool
105
116
  */
106
117
  createPool({ poolId, question, markets, customer, startTime, endTime, feeBps, payoutFee, isFast, isPyth, feedId }: CreatePoolArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
107
118
  /**
@@ -155,4 +166,13 @@ export default class TriadProtocol {
155
166
  * @param question - Question
156
167
  */
157
168
  updatePoolQuestion(poolId: number, question: string): Promise<string | import("@solana/web3.js").VersionedTransaction>;
169
+ /**
170
+ * Create Market Pyth
171
+ * @param args.markets - Array of markets to create
172
+ * @param args.markets.marketId - Market ID
173
+ * @param args.markets.resolveIn - Time to add for resolver the market in seconds
174
+ * @param args.customer - The customer of the market
175
+ * @param args.poolId - The ID of the pool
176
+ */
177
+ createMarketPyth({ markets, customer, poolId }: CreateMarketPythArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
158
178
  }
package/dist/index.js CHANGED
@@ -41,6 +41,7 @@ const poseidon_1 = __importDefault(require("./poseidon"));
41
41
  const predictor_1 = __importDefault(require("./predictor"));
42
42
  const trade_1 = __importDefault(require("./trade"));
43
43
  const customer_1 = __importDefault(require("./customer"));
44
+ const pyth_solana_receiver_1 = require("@pythnetwork/pyth-solana-receiver");
44
45
  __exportStar(require("./types"), exports);
45
46
  __exportStar(require("./types/predictor"), exports);
46
47
  __exportStar(require("./types/stake"), exports);
@@ -58,6 +59,7 @@ class TriadProtocol {
58
59
  if (!this.rpcOptions.payer) {
59
60
  this.rpcOptions.payer = this.wallet.publicKey;
60
61
  }
62
+ this.pythSolanaReceiver = new pyth_solana_receiver_1.PythSolanaReceiver({ connection, wallet });
61
63
  this.provider = new anchor_1.AnchorProvider(this.connection, this.wallet, {
62
64
  commitment: this.rpcOptions.commitment || 'confirmed'
63
65
  });
@@ -268,6 +270,14 @@ class TriadProtocol {
268
270
  * @param poolId - The ID of the pool
269
271
  * @param question - The question of the pool
270
272
  * @param markets - The markets of the pool
273
+ * @param customer - The customer of the pool
274
+ * @param startTime - The start time of the pool
275
+ * @param endTime - The end time of the pool
276
+ * @param feeBps - The fee in basis points of the pool
277
+ * @param payoutFee - The payout fee of the pool
278
+ * @param isFast - Whether the pool is fast
279
+ * @param isPyth - Whether the pool is pyth
280
+ * @param feedId - The feed ID of the pool
271
281
  */
272
282
  createPool({ poolId, question, markets, customer, startTime, endTime, feeBps, payoutFee, isFast, isPyth, feedId }) {
273
283
  return __awaiter(this, void 0, void 0, function* () {
@@ -275,6 +285,7 @@ class TriadProtocol {
275
285
  throw new Error('Pool question must be less than 80 characters');
276
286
  }
277
287
  const ixs = [];
288
+ const feedPDA = this.pythSolanaReceiver.getPriceFeedAccountAddress(0, feedId);
278
289
  const poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
279
290
  ixs.push(yield this.program.methods
280
291
  .createPool({
@@ -282,7 +293,7 @@ class TriadProtocol {
282
293
  question: (0, helpers_1.encodeString)(question, 80),
283
294
  isFast,
284
295
  isPyth,
285
- feedId
296
+ feed: feedPDA
286
297
  })
287
298
  .accounts({
288
299
  signer: this.program.provider.publicKey,
@@ -462,5 +473,41 @@ class TriadProtocol {
462
473
  return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
463
474
  });
464
475
  }
476
+ /**
477
+ * Create Market Pyth
478
+ * @param args.markets - Array of markets to create
479
+ * @param args.markets.marketId - Market ID
480
+ * @param args.markets.resolveIn - Time to add for resolver the market in seconds
481
+ * @param args.customer - The customer of the market
482
+ * @param args.poolId - The ID of the pool
483
+ */
484
+ createMarketPyth({ markets, customer, poolId }) {
485
+ return __awaiter(this, void 0, void 0, function* () {
486
+ const ixs = [];
487
+ let poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
488
+ for (const market of markets) {
489
+ ixs.push(yield this.program.methods
490
+ .createMarketPyth({
491
+ marketId: new bn_js_1.default(market.marketId),
492
+ resolveIn: new bn_js_1.default(market.resolveIn)
493
+ })
494
+ .accounts({
495
+ signer: this.program.provider.publicKey,
496
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
497
+ pool: poolPDA,
498
+ customer
499
+ })
500
+ .instruction());
501
+ ixs.push(yield this.program.methods
502
+ .createOrderBook(new bn_js_1.default(market.marketId))
503
+ .accounts({
504
+ signer: this.program.provider.publicKey,
505
+ market: (0, pda_1.getMarketPDA)(this.program.programId, market.marketId)
506
+ })
507
+ .instruction());
508
+ }
509
+ return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
510
+ });
511
+ }
465
512
  }
466
513
  exports.default = TriadProtocol;
@@ -1,3 +1,4 @@
1
+ /// <reference types="jito-ts/node_modules/@solana/web3.js" />
1
2
  import { Program } from '@coral-xyz/anchor';
2
3
  import { PublicKey } from '@solana/web3.js';
3
4
  import { TriadProtocol } from './types/triad_protocol';
@@ -1,3 +1,4 @@
1
+ /// <reference types="jito-ts/node_modules/@solana/web3.js" />
1
2
  import { PublicKey } from '@solana/web3.js';
2
3
  import { Program } from '@coral-xyz/anchor';
3
4
  import { TriadProtocol } from './types/triad_protocol';
package/dist/stake.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /// <reference types="jito-ts/node_modules/@solana/web3.js" />
1
2
  import { Program } from '@coral-xyz/anchor';
2
3
  import { PublicKey } from '@solana/web3.js';
3
4
  import { TriadProtocol } from './types/triad_protocol';
package/dist/trade.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /// <reference types="jito-ts/node_modules/@solana/web3.js" />
1
2
  import { PublicKey } from '@solana/web3.js';
2
3
  import { Program } from '@coral-xyz/anchor';
3
4
  import { TriadProtocol } from './types/triad_protocol';
@@ -13,4 +13,5 @@ export type CreateCustomerArgs = {
13
13
  name: string;
14
14
  authority: PublicKey;
15
15
  feeRecipient: PublicKey;
16
+ feeBps: number;
16
17
  };
@@ -1241,7 +1241,31 @@
1241
1241
  },
1242
1242
  {
1243
1243
  "name": "buyer_ata",
1244
- "writable": true
1244
+ "writable": true,
1245
+ "pda": {
1246
+ "seeds": [
1247
+ {
1248
+ "kind": "account",
1249
+ "path": "signer"
1250
+ },
1251
+ {
1252
+ "kind": "account",
1253
+ "path": "token_program"
1254
+ },
1255
+ {
1256
+ "kind": "account",
1257
+ "path": "mint"
1258
+ }
1259
+ ],
1260
+ "program": {
1261
+ "kind": "const",
1262
+ "value": [
1263
+ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
1264
+ 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
1265
+ 219, 233, 248, 89
1266
+ ]
1267
+ }
1268
+ }
1245
1269
  },
1246
1270
  {
1247
1271
  "name": "seller_ata",
@@ -1273,7 +1297,31 @@
1273
1297
  },
1274
1298
  {
1275
1299
  "name": "market_ata",
1276
- "writable": true
1300
+ "writable": true,
1301
+ "pda": {
1302
+ "seeds": [
1303
+ {
1304
+ "kind": "account",
1305
+ "path": "market"
1306
+ },
1307
+ {
1308
+ "kind": "account",
1309
+ "path": "token_program"
1310
+ },
1311
+ {
1312
+ "kind": "account",
1313
+ "path": "mint"
1314
+ }
1315
+ ],
1316
+ "program": {
1317
+ "kind": "const",
1318
+ "value": [
1319
+ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
1320
+ 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
1321
+ 219, 233, 248, 89
1322
+ ]
1323
+ }
1324
+ }
1277
1325
  },
1278
1326
  {
1279
1327
  "name": "token_program",
@@ -2846,6 +2894,10 @@
2846
2894
  {
2847
2895
  "name": "fee_recipient",
2848
2896
  "type": "pubkey"
2897
+ },
2898
+ {
2899
+ "name": "fee_bps",
2900
+ "type": "u16"
2849
2901
  }
2850
2902
  ]
2851
2903
  }
@@ -2932,7 +2984,7 @@
2932
2984
  "type": "bool"
2933
2985
  },
2934
2986
  {
2935
- "name": "feed_id",
2987
+ "name": "feed",
2936
2988
  "type": {
2937
2989
  "option": "pubkey"
2938
2990
  }
@@ -3681,10 +3733,8 @@
3681
3733
  "type": "bool"
3682
3734
  },
3683
3735
  {
3684
- "name": "feed_id",
3685
- "type": {
3686
- "array": ["u8", 32]
3687
- }
3736
+ "name": "feed",
3737
+ "type": "pubkey"
3688
3738
  },
3689
3739
  {
3690
3740
  "name": "padding",
@@ -150,6 +150,14 @@ export type CreateMarketArgs = {
150
150
  customer: PublicKey;
151
151
  poolId?: number;
152
152
  };
153
+ export type CreateMarketPythArgs = {
154
+ markets: {
155
+ marketId: number;
156
+ resolveIn: number;
157
+ }[];
158
+ customer: PublicKey;
159
+ poolId: number;
160
+ };
153
161
  export type CreatePoolArgs = {
154
162
  poolId: number;
155
163
  question?: string;
@@ -164,7 +172,7 @@ export type CreatePoolArgs = {
164
172
  }[];
165
173
  isFast?: boolean;
166
174
  isPyth?: boolean;
167
- feedId?: PublicKey;
175
+ feedId: string;
168
176
  };
169
177
  export type UpdateMarketWinningDirectionArgs = {
170
178
  marketId: number;
@@ -1718,6 +1718,59 @@ export type TriadProtocol = {
1718
1718
  {
1719
1719
  name: 'buyerAta';
1720
1720
  writable: true;
1721
+ pda: {
1722
+ seeds: [
1723
+ {
1724
+ kind: 'account';
1725
+ path: 'signer';
1726
+ },
1727
+ {
1728
+ kind: 'account';
1729
+ path: 'tokenProgram';
1730
+ },
1731
+ {
1732
+ kind: 'account';
1733
+ path: 'mint';
1734
+ }
1735
+ ];
1736
+ program: {
1737
+ kind: 'const';
1738
+ value: [
1739
+ 140,
1740
+ 151,
1741
+ 37,
1742
+ 143,
1743
+ 78,
1744
+ 36,
1745
+ 137,
1746
+ 241,
1747
+ 187,
1748
+ 61,
1749
+ 16,
1750
+ 41,
1751
+ 20,
1752
+ 142,
1753
+ 13,
1754
+ 131,
1755
+ 11,
1756
+ 90,
1757
+ 19,
1758
+ 153,
1759
+ 218,
1760
+ 255,
1761
+ 16,
1762
+ 132,
1763
+ 4,
1764
+ 142,
1765
+ 123,
1766
+ 216,
1767
+ 219,
1768
+ 233,
1769
+ 248,
1770
+ 89
1771
+ ];
1772
+ };
1773
+ };
1721
1774
  },
1722
1775
  {
1723
1776
  name: 'sellerAta';
@@ -1779,6 +1832,59 @@ export type TriadProtocol = {
1779
1832
  {
1780
1833
  name: 'marketAta';
1781
1834
  writable: true;
1835
+ pda: {
1836
+ seeds: [
1837
+ {
1838
+ kind: 'account';
1839
+ path: 'market';
1840
+ },
1841
+ {
1842
+ kind: 'account';
1843
+ path: 'tokenProgram';
1844
+ },
1845
+ {
1846
+ kind: 'account';
1847
+ path: 'mint';
1848
+ }
1849
+ ];
1850
+ program: {
1851
+ kind: 'const';
1852
+ value: [
1853
+ 140,
1854
+ 151,
1855
+ 37,
1856
+ 143,
1857
+ 78,
1858
+ 36,
1859
+ 137,
1860
+ 241,
1861
+ 187,
1862
+ 61,
1863
+ 16,
1864
+ 41,
1865
+ 20,
1866
+ 142,
1867
+ 13,
1868
+ 131,
1869
+ 11,
1870
+ 90,
1871
+ 19,
1872
+ 153,
1873
+ 218,
1874
+ 255,
1875
+ 16,
1876
+ 132,
1877
+ 4,
1878
+ 142,
1879
+ 123,
1880
+ 216,
1881
+ 219,
1882
+ 233,
1883
+ 248,
1884
+ 89
1885
+ ];
1886
+ };
1887
+ };
1782
1888
  },
1783
1889
  {
1784
1890
  name: 'tokenProgram';
@@ -3705,6 +3811,10 @@ export type TriadProtocol = {
3705
3811
  {
3706
3812
  name: 'feeRecipient';
3707
3813
  type: 'pubkey';
3814
+ },
3815
+ {
3816
+ name: 'feeBps';
3817
+ type: 'u16';
3708
3818
  }
3709
3819
  ];
3710
3820
  };
@@ -3791,7 +3901,7 @@ export type TriadProtocol = {
3791
3901
  type: 'bool';
3792
3902
  },
3793
3903
  {
3794
- name: 'feedId';
3904
+ name: 'feed';
3795
3905
  type: {
3796
3906
  option: 'pubkey';
3797
3907
  };
@@ -4540,10 +4650,8 @@ export type TriadProtocol = {
4540
4650
  type: 'bool';
4541
4651
  },
4542
4652
  {
4543
- name: 'feedId';
4544
- type: {
4545
- array: ['u8', 32];
4546
- };
4653
+ name: 'feed';
4654
+ type: 'pubkey';
4547
4655
  },
4548
4656
  {
4549
4657
  name: 'padding';
@@ -7,3 +7,8 @@ export declare const POSEIDON_CORE_COLLECTION: PublicKey;
7
7
  export declare const POSEIDON_COLLECTION_SYMBOL = "$PSN";
8
8
  export declare const BASE_DECIMALS = 6;
9
9
  export declare const BOOK_ORDER_NULL = 61;
10
+ export declare const PRICE_FEED: {
11
+ BTC: string;
12
+ SOL: string;
13
+ ETH: string;
14
+ };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BOOK_ORDER_NULL = exports.BASE_DECIMALS = exports.POSEIDON_COLLECTION_SYMBOL = exports.POSEIDON_CORE_COLLECTION = exports.TRIAD_ADMIN = exports.UNIT_MINT = exports.TRD_MINT = exports.USDC_MINT = void 0;
3
+ exports.PRICE_FEED = exports.BOOK_ORDER_NULL = exports.BASE_DECIMALS = exports.POSEIDON_COLLECTION_SYMBOL = exports.POSEIDON_CORE_COLLECTION = exports.TRIAD_ADMIN = exports.UNIT_MINT = exports.TRD_MINT = exports.USDC_MINT = void 0;
4
4
  const web3_js_1 = require("@solana/web3.js");
5
5
  exports.USDC_MINT = new web3_js_1.PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v');
6
6
  exports.TRD_MINT = new web3_js_1.PublicKey('t3DohmswhKk94PPbPYwA6ZKACyY3y5kbcqeQerAJjmV');
@@ -10,3 +10,8 @@ exports.POSEIDON_CORE_COLLECTION = new web3_js_1.PublicKey('69CLccefLRmvDSAJP7Er
10
10
  exports.POSEIDON_COLLECTION_SYMBOL = '$PSN';
11
11
  exports.BASE_DECIMALS = 6;
12
12
  exports.BOOK_ORDER_NULL = 61;
13
+ exports.PRICE_FEED = {
14
+ BTC: '0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43',
15
+ SOL: '0xef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d',
16
+ ETH: '0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace'
17
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "4.0.5",
3
+ "version": "4.0.7",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -33,6 +33,7 @@
33
33
  "license": "ISC",
34
34
  "dependencies": {
35
35
  "@coral-xyz/anchor": "0.31.1",
36
+ "@pythnetwork/pyth-solana-receiver": "0.14.0",
36
37
  "@solana/spl-token": "0.4.14",
37
38
  "@solana/web3.js": "1.98.4",
38
39
  "axios": "1.13.6",