@triadxyz/triad-protocol 4.0.6 → 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.
@@ -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
  };
@@ -2894,6 +2894,10 @@
2894
2894
  {
2895
2895
  "name": "fee_recipient",
2896
2896
  "type": "pubkey"
2897
+ },
2898
+ {
2899
+ "name": "fee_bps",
2900
+ "type": "u16"
2897
2901
  }
2898
2902
  ]
2899
2903
  }
@@ -2980,7 +2984,7 @@
2980
2984
  "type": "bool"
2981
2985
  },
2982
2986
  {
2983
- "name": "feed_id",
2987
+ "name": "feed",
2984
2988
  "type": {
2985
2989
  "option": "pubkey"
2986
2990
  }
@@ -3729,10 +3733,8 @@
3729
3733
  "type": "bool"
3730
3734
  },
3731
3735
  {
3732
- "name": "feed_id",
3733
- "type": {
3734
- "array": ["u8", 32]
3735
- }
3736
+ "name": "feed",
3737
+ "type": "pubkey"
3736
3738
  },
3737
3739
  {
3738
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;
@@ -3811,6 +3811,10 @@ export type TriadProtocol = {
3811
3811
  {
3812
3812
  name: 'feeRecipient';
3813
3813
  type: 'pubkey';
3814
+ },
3815
+ {
3816
+ name: 'feeBps';
3817
+ type: 'u16';
3814
3818
  }
3815
3819
  ];
3816
3820
  };
@@ -3897,7 +3901,7 @@ export type TriadProtocol = {
3897
3901
  type: 'bool';
3898
3902
  },
3899
3903
  {
3900
- name: 'feedId';
3904
+ name: 'feed';
3901
3905
  type: {
3902
3906
  option: 'pubkey';
3903
3907
  };
@@ -4646,10 +4650,8 @@ export type TriadProtocol = {
4646
4650
  type: 'bool';
4647
4651
  },
4648
4652
  {
4649
- name: 'feedId';
4650
- type: {
4651
- array: ['u8', 32];
4652
- };
4653
+ name: 'feed';
4654
+ type: 'pubkey';
4653
4655
  },
4654
4656
  {
4655
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.6",
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",