@triadxyz/triad-protocol 3.1.7-beta → 3.1.9-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 +120 -3
- package/dist/index.js +372 -24
- package/dist/types/idl_triad_protocol.json +66 -0
- package/dist/types/index.d.ts +0 -1
- package/dist/types/triad_protocol.d.ts +66 -0
- package/package.json +1 -1
- package/dist/market.d.ts +0 -129
- package/dist/market.js +0 -377
package/dist/index.d.ts
CHANGED
|
@@ -3,11 +3,10 @@ import { Connection, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
|
3
3
|
import { AnchorProvider, Program, Wallet } from '@coral-xyz/anchor';
|
|
4
4
|
import BN from 'bn.js';
|
|
5
5
|
import { TriadProtocol } from './types/triad_protocol';
|
|
6
|
-
import { OpenOrderArgs, UserTrade, CreateCustomerArgs, MarketBidOrderArgs, CancelBidOrderArgs, CancelAskOrderArgs, PlaceBidOrderArgs, PlaceAskOrderArgs, BookOrder, MarketAskOrderArgs, RpcOptions, OrderDirection, CloseOrderArgs } from './types';
|
|
6
|
+
import { OpenOrderArgs, UserTrade, CreateCustomerArgs, MarketBidOrderArgs, CancelBidOrderArgs, CancelAskOrderArgs, PlaceBidOrderArgs, PlaceAskOrderArgs, BookOrder, MarketAskOrderArgs, RpcOptions, OrderDirection, CloseOrderArgs, CreateMarketArgs, CreatePoolArgs, UpdateMarketWinningDirectionArgs } from './types';
|
|
7
7
|
import Stake from './stake';
|
|
8
8
|
import Poseidon from './poseidon';
|
|
9
9
|
import Claim from './claim';
|
|
10
|
-
import Market from './market';
|
|
11
10
|
export * from './types';
|
|
12
11
|
export * from './utils/helpers';
|
|
13
12
|
export * from './utils/merkle';
|
|
@@ -20,7 +19,6 @@ export default class TriadProtocolClient {
|
|
|
20
19
|
stake: Stake;
|
|
21
20
|
poseidon: Poseidon;
|
|
22
21
|
claim: Claim;
|
|
23
|
-
market: Market;
|
|
24
22
|
constructor(connection: Connection, wallet: Wallet, rpcOptions: RpcOptions);
|
|
25
23
|
/**
|
|
26
24
|
* Get My User Trades from a user authority
|
|
@@ -165,6 +163,125 @@ export default class TriadProtocolClient {
|
|
|
165
163
|
poseidon: number;
|
|
166
164
|
padding: number[];
|
|
167
165
|
}>;
|
|
166
|
+
/**
|
|
167
|
+
* Get All Pools
|
|
168
|
+
*/
|
|
169
|
+
getAllPools(): Promise<import("./types").Pool[]>;
|
|
170
|
+
/**
|
|
171
|
+
* Get All Markets
|
|
172
|
+
*/
|
|
173
|
+
getAllMarkets(): Promise<import("./types").Market[]>;
|
|
174
|
+
/**
|
|
175
|
+
* Get Pool By ID
|
|
176
|
+
* @param poolId - The ID of the pool
|
|
177
|
+
*/
|
|
178
|
+
getPoolById(poolId: number): Promise<import("./types").Pool>;
|
|
179
|
+
/**
|
|
180
|
+
* Get Market By ID
|
|
181
|
+
* @param marketId - The ID of the market
|
|
182
|
+
*/
|
|
183
|
+
getMarketById(marketId: number): Promise<import("./types").Market>;
|
|
184
|
+
/**
|
|
185
|
+
* Get Market By Address
|
|
186
|
+
* @param marketAddress - The address of the market
|
|
187
|
+
*/
|
|
188
|
+
getMarketByAddress(marketAddress: PublicKey): Promise<import("./types").Market>;
|
|
189
|
+
/**
|
|
190
|
+
* Get Current Market ID
|
|
191
|
+
*/
|
|
192
|
+
nextMarketId(): Promise<number>;
|
|
193
|
+
/**
|
|
194
|
+
* Get Next Customer ID
|
|
195
|
+
*/
|
|
196
|
+
nextCustomerId(): Promise<number>;
|
|
197
|
+
/**
|
|
198
|
+
* Get Next Pool ID
|
|
199
|
+
*/
|
|
200
|
+
nextPoolId(): Promise<number>;
|
|
201
|
+
/**
|
|
202
|
+
* Create Market
|
|
203
|
+
* @param args.markets - Array of markets to create
|
|
204
|
+
* @param args.markets.marketId - Market ID
|
|
205
|
+
* @param args.markets.startTime - start time
|
|
206
|
+
* @param args.markets.endTime - end time
|
|
207
|
+
* @param args.markets.question - question (max 80 characters)
|
|
208
|
+
* @param args.markets.liquidityAtStart - liquidity at start
|
|
209
|
+
* @param args.markets.payoutFee - payout fee (to add affiliate system)
|
|
210
|
+
* @param args.customer - The customer of the market
|
|
211
|
+
* @param args.poolId - The ID of the pool
|
|
212
|
+
*/
|
|
213
|
+
createMarket({ markets, customer, poolId }: CreateMarketArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
214
|
+
/**
|
|
215
|
+
* Create Pool
|
|
216
|
+
* @param poolId - The ID of the pool
|
|
217
|
+
* @param question - The question of the pool
|
|
218
|
+
* @param markets - The markets of the pool
|
|
219
|
+
*/
|
|
220
|
+
createPool({ poolId, question, markets, customer, startTime, endTime, feeBps, payoutFee, isFast }: CreatePoolArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
221
|
+
/**
|
|
222
|
+
* Resolve Market
|
|
223
|
+
* @param args.marketId - The ID of the Market
|
|
224
|
+
* @param args.poolId - The ID of the Pool
|
|
225
|
+
* @param args.winningDirection - The Winning Direction of the Market
|
|
226
|
+
*/
|
|
227
|
+
updateMarketWinningDirection({ marketId, poolId, winningDirection }: UpdateMarketWinningDirectionArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
228
|
+
/**
|
|
229
|
+
* Update Market Payout
|
|
230
|
+
* @param marketId - The ID of the market
|
|
231
|
+
* @param poolId - The ID of the pool
|
|
232
|
+
* @param allowPayout - Whether to allow the market to payout
|
|
233
|
+
*/
|
|
234
|
+
updateMarketPayout({ marketId, poolId, allowPayout }: {
|
|
235
|
+
marketId: number;
|
|
236
|
+
poolId?: number;
|
|
237
|
+
allowPayout: boolean;
|
|
238
|
+
}): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
239
|
+
/**
|
|
240
|
+
* Update Market End
|
|
241
|
+
* @param marketId - The ID of the market
|
|
242
|
+
* @param marketEnd - The end time of the market
|
|
243
|
+
*/
|
|
244
|
+
updateMarketEnd({ marketId, marketEnd }: {
|
|
245
|
+
marketId: number;
|
|
246
|
+
marketEnd: number;
|
|
247
|
+
}): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
248
|
+
/**
|
|
249
|
+
* Update Market Question
|
|
250
|
+
* @param marketId - The ID of the market
|
|
251
|
+
* @param question - The question of the market
|
|
252
|
+
*/
|
|
253
|
+
updateMarketQuestion({ marketId, question }: {
|
|
254
|
+
marketId: number;
|
|
255
|
+
question: string;
|
|
256
|
+
}): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
257
|
+
/**
|
|
258
|
+
* Collect Market Fee
|
|
259
|
+
* @param args.markets - The markets to collect the fee from
|
|
260
|
+
* @param args.markets.marketAddress - The address of the market
|
|
261
|
+
* @param args.markets.customerId - The ID of the customer
|
|
262
|
+
* @param args.markets.customerFeeRecipient - The address of the customer fee recipient
|
|
263
|
+
*/
|
|
264
|
+
collectMarketFee(markets: {
|
|
265
|
+
marketAddress: PublicKey;
|
|
266
|
+
customerId: number;
|
|
267
|
+
customerFeeRecipient: PublicKey;
|
|
268
|
+
}[]): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
269
|
+
/**
|
|
270
|
+
* Collect Market Order Fee
|
|
271
|
+
* @param marketAddress - The address of the market
|
|
272
|
+
*/
|
|
273
|
+
collectMarketOrderFee(marketAddress: PublicKey[]): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
274
|
+
/**
|
|
275
|
+
* Close Order Book
|
|
276
|
+
* @param marketIds - Market IDs
|
|
277
|
+
*/
|
|
278
|
+
closeOrderBook(marketIds: number[]): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
279
|
+
/**
|
|
280
|
+
* Update Pool Question
|
|
281
|
+
* @param poolId - Pool ID
|
|
282
|
+
* @param question - Question
|
|
283
|
+
*/
|
|
284
|
+
updatePoolQuestion(poolId: number, question: string): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
168
285
|
/**
|
|
169
286
|
* Open Order
|
|
170
287
|
* @param args.marketId - The ID of the Market
|
package/dist/index.js
CHANGED
|
@@ -30,17 +30,17 @@ const web3_js_1 = require("@solana/web3.js");
|
|
|
30
30
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
31
31
|
const spl_token_1 = require("@solana/spl-token");
|
|
32
32
|
const bn_js_1 = __importDefault(require("bn.js"));
|
|
33
|
+
const helpers_1 = require("./utils/helpers");
|
|
33
34
|
const idl_triad_protocol_json_1 = __importDefault(require("./types/idl_triad_protocol.json"));
|
|
34
35
|
const types_1 = require("./types");
|
|
35
36
|
const constants_1 = require("./utils/constants");
|
|
36
|
-
const
|
|
37
|
+
const helpers_2 = require("./utils/helpers");
|
|
37
38
|
const pda_1 = require("./utils/pda");
|
|
38
39
|
const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersionedTransaction"));
|
|
39
40
|
const swap_1 = require("./utils/swap");
|
|
40
41
|
const stake_1 = __importDefault(require("./stake"));
|
|
41
42
|
const poseidon_1 = __importDefault(require("./poseidon"));
|
|
42
43
|
const claim_1 = __importDefault(require("./claim"));
|
|
43
|
-
const market_1 = __importDefault(require("./market"));
|
|
44
44
|
__exportStar(require("./types"), exports);
|
|
45
45
|
__exportStar(require("./utils/helpers"), exports);
|
|
46
46
|
__exportStar(require("./utils/merkle"), exports);
|
|
@@ -59,7 +59,6 @@ class TriadProtocolClient {
|
|
|
59
59
|
this.stake = new stake_1.default(this.program, this.rpcOptions);
|
|
60
60
|
this.poseidon = new poseidon_1.default(this.program, this.rpcOptions);
|
|
61
61
|
this.claim = new claim_1.default(this.program, this.rpcOptions);
|
|
62
|
-
this.market = new market_1.default(this.program, this.rpcOptions);
|
|
63
62
|
}
|
|
64
63
|
/**
|
|
65
64
|
* Get My User Trades from a user authority
|
|
@@ -75,7 +74,7 @@ class TriadProtocolClient {
|
|
|
75
74
|
}
|
|
76
75
|
}
|
|
77
76
|
]);
|
|
78
|
-
return response.map(({ account, publicKey }) => (0,
|
|
77
|
+
return response.map(({ account, publicKey }) => (0, helpers_2.formatUserTrade)(account, publicKey));
|
|
79
78
|
});
|
|
80
79
|
}
|
|
81
80
|
/**
|
|
@@ -107,7 +106,7 @@ class TriadProtocolClient {
|
|
|
107
106
|
const orderBook = yield this.program.account.orderBook.fetch((0, pda_1.getOrderBookPDA)(this.program.programId, marketId));
|
|
108
107
|
const orders = [...orderBook.hypeOrders, ...orderBook.flopOrders];
|
|
109
108
|
return orders
|
|
110
|
-
.map((order) => (0,
|
|
109
|
+
.map((order) => (0, helpers_2.formatBookOrder)(order))
|
|
111
110
|
.filter((order) => order.authority === wallet.toBase58() &&
|
|
112
111
|
order.linkedBookOrderId === constants_1.BOOK_ORDER_NULL.toString());
|
|
113
112
|
});
|
|
@@ -126,7 +125,7 @@ class TriadProtocolClient {
|
|
|
126
125
|
}
|
|
127
126
|
}
|
|
128
127
|
]);
|
|
129
|
-
return (0,
|
|
128
|
+
return (0, helpers_2.formatCustomer)(customer.account, customer.publicKey);
|
|
130
129
|
});
|
|
131
130
|
}
|
|
132
131
|
/**
|
|
@@ -137,7 +136,7 @@ class TriadProtocolClient {
|
|
|
137
136
|
return __awaiter(this, void 0, void 0, function* () {
|
|
138
137
|
const customerPDA = (0, pda_1.getCustomerPDA)(this.program.programId, customerId);
|
|
139
138
|
const customer = yield this.program.account.customer.fetch(customerPDA);
|
|
140
|
-
return (0,
|
|
139
|
+
return (0, helpers_2.formatCustomer)(customer, customerPDA);
|
|
141
140
|
});
|
|
142
141
|
}
|
|
143
142
|
/**
|
|
@@ -164,6 +163,357 @@ class TriadProtocolClient {
|
|
|
164
163
|
return this.program.account.userTrade.fetch(userTradePDA);
|
|
165
164
|
});
|
|
166
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* Get All Pools
|
|
168
|
+
*/
|
|
169
|
+
getAllPools() {
|
|
170
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
171
|
+
const pool = yield this.program.account.pool.all();
|
|
172
|
+
return pool.map(({ account, publicKey }) => (0, helpers_1.formatPool)(account, publicKey));
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Get All Markets
|
|
177
|
+
*/
|
|
178
|
+
getAllMarkets() {
|
|
179
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
+
const marketV2 = yield this.program.account.marketV2.all();
|
|
181
|
+
return marketV2.map(({ account, publicKey }) => (0, helpers_1.formatMarket)(account, publicKey));
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Get Pool By ID
|
|
186
|
+
* @param poolId - The ID of the pool
|
|
187
|
+
*/
|
|
188
|
+
getPoolById(poolId) {
|
|
189
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
190
|
+
const poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
|
|
191
|
+
const response = yield this.program.account.pool.fetch(poolPDA);
|
|
192
|
+
return (0, helpers_1.formatPool)(response, poolPDA);
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Get Market By ID
|
|
197
|
+
* @param marketId - The ID of the market
|
|
198
|
+
*/
|
|
199
|
+
getMarketById(marketId) {
|
|
200
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
201
|
+
const marketPDA = (0, pda_1.getMarketPDA)(this.program.programId, marketId);
|
|
202
|
+
const response = yield this.program.account.marketV2.fetch(marketPDA);
|
|
203
|
+
return (0, helpers_1.formatMarket)(response, marketPDA);
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Get Market By Address
|
|
208
|
+
* @param marketAddress - The address of the market
|
|
209
|
+
*/
|
|
210
|
+
getMarketByAddress(marketAddress) {
|
|
211
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
212
|
+
const account = yield this.program.account.marketV2.fetch(marketAddress);
|
|
213
|
+
return (0, helpers_1.formatMarket)(account, marketAddress);
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Get Current Market ID
|
|
218
|
+
*/
|
|
219
|
+
nextMarketId() {
|
|
220
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
221
|
+
const markets = yield this.program.account.marketV2.all();
|
|
222
|
+
return markets.length + 10;
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Get Next Customer ID
|
|
227
|
+
*/
|
|
228
|
+
nextCustomerId() {
|
|
229
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
230
|
+
const customers = yield this.program.account.customer.all();
|
|
231
|
+
return customers.length + 1;
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Get Next Pool ID
|
|
236
|
+
*/
|
|
237
|
+
nextPoolId() {
|
|
238
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
239
|
+
const pools = yield this.program.account.pool.all();
|
|
240
|
+
return pools.length + 1;
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Create Market
|
|
245
|
+
* @param args.markets - Array of markets to create
|
|
246
|
+
* @param args.markets.marketId - Market ID
|
|
247
|
+
* @param args.markets.startTime - start time
|
|
248
|
+
* @param args.markets.endTime - end time
|
|
249
|
+
* @param args.markets.question - question (max 80 characters)
|
|
250
|
+
* @param args.markets.liquidityAtStart - liquidity at start
|
|
251
|
+
* @param args.markets.payoutFee - payout fee (to add affiliate system)
|
|
252
|
+
* @param args.customer - The customer of the market
|
|
253
|
+
* @param args.poolId - The ID of the pool
|
|
254
|
+
*/
|
|
255
|
+
createMarket({ markets, customer, poolId }) {
|
|
256
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
257
|
+
const ixs = [];
|
|
258
|
+
let poolPDA = null;
|
|
259
|
+
if (poolId) {
|
|
260
|
+
poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
|
|
261
|
+
}
|
|
262
|
+
for (const market of markets) {
|
|
263
|
+
if (market.question.length > 80) {
|
|
264
|
+
throw new Error('Question must be less than 80 characters');
|
|
265
|
+
}
|
|
266
|
+
ixs.push(yield this.program.methods
|
|
267
|
+
.createMarket({
|
|
268
|
+
marketId: new bn_js_1.default(market.marketId),
|
|
269
|
+
question: (0, helpers_1.encodeString)(market.question, 80),
|
|
270
|
+
marketStart: new bn_js_1.default(market.startTime),
|
|
271
|
+
marketEnd: new bn_js_1.default(market.endTime),
|
|
272
|
+
feeBps: market.feeBps,
|
|
273
|
+
payoutFee: market.payoutFee
|
|
274
|
+
})
|
|
275
|
+
.accounts({
|
|
276
|
+
signer: this.program.provider.publicKey,
|
|
277
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
278
|
+
pool: poolPDA,
|
|
279
|
+
customer
|
|
280
|
+
})
|
|
281
|
+
.instruction());
|
|
282
|
+
ixs.push(yield this.program.methods
|
|
283
|
+
.createOrderBook(new bn_js_1.default(market.marketId))
|
|
284
|
+
.accounts({
|
|
285
|
+
signer: this.program.provider.publicKey,
|
|
286
|
+
market: (0, pda_1.getMarketPDA)(this.program.programId, market.marketId)
|
|
287
|
+
})
|
|
288
|
+
.instruction());
|
|
289
|
+
}
|
|
290
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Create Pool
|
|
295
|
+
* @param poolId - The ID of the pool
|
|
296
|
+
* @param question - The question of the pool
|
|
297
|
+
* @param markets - The markets of the pool
|
|
298
|
+
*/
|
|
299
|
+
createPool({ poolId, question, markets, customer, startTime, endTime, feeBps, payoutFee, isFast }) {
|
|
300
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
301
|
+
if (question.length > 80) {
|
|
302
|
+
throw new Error('Pool question must be less than 80 characters');
|
|
303
|
+
}
|
|
304
|
+
const ixs = [];
|
|
305
|
+
const poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
|
|
306
|
+
ixs.push(yield this.program.methods
|
|
307
|
+
.createPool({
|
|
308
|
+
poolId: new bn_js_1.default(poolId),
|
|
309
|
+
question: (0, helpers_1.encodeString)(question, 80),
|
|
310
|
+
isFast
|
|
311
|
+
})
|
|
312
|
+
.accounts({
|
|
313
|
+
signer: this.program.provider.publicKey,
|
|
314
|
+
customer
|
|
315
|
+
})
|
|
316
|
+
.instruction());
|
|
317
|
+
for (const market of markets) {
|
|
318
|
+
if (market.question.length > 80) {
|
|
319
|
+
throw new Error('Market question must be less than 80 characters');
|
|
320
|
+
}
|
|
321
|
+
ixs.push(yield this.program.methods
|
|
322
|
+
.createMarket({
|
|
323
|
+
marketId: new bn_js_1.default(market.marketId),
|
|
324
|
+
question: (0, helpers_1.encodeString)(market.question, 80),
|
|
325
|
+
marketStart: new bn_js_1.default(startTime),
|
|
326
|
+
marketEnd: new bn_js_1.default(endTime),
|
|
327
|
+
feeBps,
|
|
328
|
+
payoutFee
|
|
329
|
+
})
|
|
330
|
+
.accounts({
|
|
331
|
+
signer: this.program.provider.publicKey,
|
|
332
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
333
|
+
pool: poolPDA,
|
|
334
|
+
customer
|
|
335
|
+
})
|
|
336
|
+
.instruction());
|
|
337
|
+
ixs.push(yield this.program.methods
|
|
338
|
+
.createOrderBook(new bn_js_1.default(market.marketId))
|
|
339
|
+
.accounts({
|
|
340
|
+
signer: this.program.provider.publicKey,
|
|
341
|
+
market: (0, pda_1.getMarketPDA)(this.program.programId, market.marketId)
|
|
342
|
+
})
|
|
343
|
+
.instruction());
|
|
344
|
+
}
|
|
345
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Resolve Market
|
|
350
|
+
* @param args.marketId - The ID of the Market
|
|
351
|
+
* @param args.poolId - The ID of the Pool
|
|
352
|
+
* @param args.winningDirection - The Winning Direction of the Market
|
|
353
|
+
*/
|
|
354
|
+
updateMarketWinningDirection({ marketId, poolId, winningDirection }) {
|
|
355
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
356
|
+
let poolPDA = null;
|
|
357
|
+
if (poolId) {
|
|
358
|
+
poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
|
|
359
|
+
}
|
|
360
|
+
const ixs = [
|
|
361
|
+
yield this.program.methods
|
|
362
|
+
.updateMarketWinningDirection(winningDirection)
|
|
363
|
+
.accounts({
|
|
364
|
+
signer: this.program.provider.publicKey,
|
|
365
|
+
market: (0, pda_1.getMarketPDA)(this.program.programId, marketId),
|
|
366
|
+
pool: poolPDA
|
|
367
|
+
})
|
|
368
|
+
.instruction()
|
|
369
|
+
];
|
|
370
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Update Market Payout
|
|
375
|
+
* @param marketId - The ID of the market
|
|
376
|
+
* @param poolId - The ID of the pool
|
|
377
|
+
* @param allowPayout - Whether to allow the market to payout
|
|
378
|
+
*/
|
|
379
|
+
updateMarketPayout({ marketId, poolId, allowPayout }) {
|
|
380
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
381
|
+
let poolPDA = null;
|
|
382
|
+
if (poolId) {
|
|
383
|
+
poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
|
|
384
|
+
}
|
|
385
|
+
const ixs = [
|
|
386
|
+
yield this.program.methods
|
|
387
|
+
.updateMarketPayout(allowPayout)
|
|
388
|
+
.accounts({
|
|
389
|
+
signer: this.program.provider.publicKey,
|
|
390
|
+
market: (0, pda_1.getMarketPDA)(this.program.programId, marketId)
|
|
391
|
+
})
|
|
392
|
+
.instruction()
|
|
393
|
+
];
|
|
394
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Update Market End
|
|
399
|
+
* @param marketId - The ID of the market
|
|
400
|
+
* @param marketEnd - The end time of the market
|
|
401
|
+
*/
|
|
402
|
+
updateMarketEnd({ marketId, marketEnd }) {
|
|
403
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
404
|
+
const ixs = [
|
|
405
|
+
yield this.program.methods
|
|
406
|
+
.updateMarketEnd(new bn_js_1.default(marketEnd))
|
|
407
|
+
.accounts({
|
|
408
|
+
signer: this.program.provider.publicKey,
|
|
409
|
+
market: (0, pda_1.getMarketPDA)(this.program.programId, marketId)
|
|
410
|
+
})
|
|
411
|
+
.instruction()
|
|
412
|
+
];
|
|
413
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Update Market Question
|
|
418
|
+
* @param marketId - The ID of the market
|
|
419
|
+
* @param question - The question of the market
|
|
420
|
+
*/
|
|
421
|
+
updateMarketQuestion({ marketId, question }) {
|
|
422
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
423
|
+
const ixs = [
|
|
424
|
+
yield this.program.methods
|
|
425
|
+
.updateMarketQuestion((0, helpers_1.encodeString)(question, 80))
|
|
426
|
+
.accounts({
|
|
427
|
+
signer: this.program.provider.publicKey,
|
|
428
|
+
market: (0, pda_1.getMarketPDA)(this.program.programId, marketId)
|
|
429
|
+
})
|
|
430
|
+
.instruction()
|
|
431
|
+
];
|
|
432
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Collect Market Fee
|
|
437
|
+
* @param args.markets - The markets to collect the fee from
|
|
438
|
+
* @param args.markets.marketAddress - The address of the market
|
|
439
|
+
* @param args.markets.customerId - The ID of the customer
|
|
440
|
+
* @param args.markets.customerFeeRecipient - The address of the customer fee recipient
|
|
441
|
+
*/
|
|
442
|
+
collectMarketFee(markets) {
|
|
443
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
444
|
+
const ixs = [];
|
|
445
|
+
for (const market of markets) {
|
|
446
|
+
ixs.push(yield this.program.methods
|
|
447
|
+
.collectMarketFee()
|
|
448
|
+
.accounts({
|
|
449
|
+
signer: this.program.provider.publicKey,
|
|
450
|
+
market: market.marketAddress,
|
|
451
|
+
customer: (0, pda_1.getCustomerPDA)(this.program.programId, market.customerId),
|
|
452
|
+
customerFeeRecipient: market.customerFeeRecipient
|
|
453
|
+
})
|
|
454
|
+
.instruction());
|
|
455
|
+
}
|
|
456
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Collect Market Order Fee
|
|
461
|
+
* @param marketAddress - The address of the market
|
|
462
|
+
*/
|
|
463
|
+
collectMarketOrderFee(marketAddress) {
|
|
464
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
465
|
+
const ixs = [];
|
|
466
|
+
for (const market of marketAddress) {
|
|
467
|
+
ixs.push(yield this.program.methods
|
|
468
|
+
.collectMarketOrderFee()
|
|
469
|
+
.accounts({
|
|
470
|
+
signer: this.program.provider.publicKey,
|
|
471
|
+
market: market
|
|
472
|
+
})
|
|
473
|
+
.instruction());
|
|
474
|
+
}
|
|
475
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Close Order Book
|
|
480
|
+
* @param marketIds - Market IDs
|
|
481
|
+
*/
|
|
482
|
+
closeOrderBook(marketIds) {
|
|
483
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
484
|
+
const ixs = [];
|
|
485
|
+
for (const marketId of marketIds) {
|
|
486
|
+
ixs.push(yield this.program.methods
|
|
487
|
+
.closeOrderBook()
|
|
488
|
+
.accounts({
|
|
489
|
+
signer: this.program.provider.publicKey,
|
|
490
|
+
market: (0, pda_1.getMarketPDA)(this.program.programId, marketId),
|
|
491
|
+
orderBook: (0, pda_1.getOrderBookPDA)(this.program.programId, marketId)
|
|
492
|
+
})
|
|
493
|
+
.instruction());
|
|
494
|
+
}
|
|
495
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Update Pool Question
|
|
500
|
+
* @param poolId - Pool ID
|
|
501
|
+
* @param question - Question
|
|
502
|
+
*/
|
|
503
|
+
updatePoolQuestion(poolId, question) {
|
|
504
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
505
|
+
const ixs = [
|
|
506
|
+
yield this.program.methods
|
|
507
|
+
.updatePoolQuestion((0, helpers_1.encodeString)(question, 80))
|
|
508
|
+
.accounts({
|
|
509
|
+
signer: this.program.provider.publicKey,
|
|
510
|
+
pool: (0, pda_1.getPoolPDA)(this.program.programId, poolId)
|
|
511
|
+
})
|
|
512
|
+
.instruction()
|
|
513
|
+
];
|
|
514
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
515
|
+
});
|
|
516
|
+
}
|
|
167
517
|
/**
|
|
168
518
|
* Open Order
|
|
169
519
|
* @param args.marketId - The ID of the Market
|
|
@@ -259,7 +609,7 @@ class TriadProtocolClient {
|
|
|
259
609
|
userTrade: this.getUserPDA(this.program.provider.publicKey, order.userNonce),
|
|
260
610
|
market: (0, pda_1.getMarketPDA)(this.program.programId, order.marketId),
|
|
261
611
|
mint: order.mint,
|
|
262
|
-
tokenProgram: (0,
|
|
612
|
+
tokenProgram: (0, helpers_2.getTokenProgram)(order.mint)
|
|
263
613
|
})
|
|
264
614
|
.instruction());
|
|
265
615
|
}
|
|
@@ -278,7 +628,8 @@ class TriadProtocolClient {
|
|
|
278
628
|
ixs.push(yield this.program.methods
|
|
279
629
|
.createSubUserTrade(subUserTradePDA)
|
|
280
630
|
.accounts({
|
|
281
|
-
signer: this.program.provider.publicKey
|
|
631
|
+
signer: this.program.provider.publicKey,
|
|
632
|
+
payer: this.rpcOptions.payer
|
|
282
633
|
})
|
|
283
634
|
.instruction());
|
|
284
635
|
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
@@ -316,7 +667,8 @@ class TriadProtocolClient {
|
|
|
316
667
|
ixs.push(yield this.program.methods
|
|
317
668
|
.createUserTrade()
|
|
318
669
|
.accounts({
|
|
319
|
-
signer: this.program.provider.publicKey
|
|
670
|
+
signer: this.program.provider.publicKey,
|
|
671
|
+
payer: this.rpcOptions.payer
|
|
320
672
|
})
|
|
321
673
|
.instruction());
|
|
322
674
|
return {
|
|
@@ -328,9 +680,6 @@ class TriadProtocolClient {
|
|
|
328
680
|
try {
|
|
329
681
|
let nonce = null;
|
|
330
682
|
for (const userTrade of myUserTrades) {
|
|
331
|
-
if (userTrade.nonce === '9') {
|
|
332
|
-
continue;
|
|
333
|
-
}
|
|
334
683
|
if (nonce !== null) {
|
|
335
684
|
break;
|
|
336
685
|
}
|
|
@@ -341,7 +690,6 @@ class TriadProtocolClient {
|
|
|
341
690
|
}
|
|
342
691
|
});
|
|
343
692
|
}
|
|
344
|
-
console.log('nonce', nonce);
|
|
345
693
|
if (nonce === null) {
|
|
346
694
|
throw new Error('No open orders found');
|
|
347
695
|
}
|
|
@@ -351,13 +699,13 @@ class TriadProtocolClient {
|
|
|
351
699
|
};
|
|
352
700
|
}
|
|
353
701
|
catch (_a) {
|
|
354
|
-
console.log('No open orders found');
|
|
355
702
|
const mainUserTrade = myUserTrades.find((trade) => !trade.isSubUser);
|
|
356
703
|
const subUserTradePDA = (0, pda_1.getSubUserTradePDA)(this.program.programId, this.program.provider.publicKey, Number(mainUserTrade.nonce) + 1);
|
|
357
704
|
ixs.push(yield this.program.methods
|
|
358
705
|
.createSubUserTrade(subUserTradePDA)
|
|
359
706
|
.accounts({
|
|
360
|
-
signer: this.program.provider.publicKey
|
|
707
|
+
signer: this.program.provider.publicKey,
|
|
708
|
+
payer: this.rpcOptions.payer
|
|
361
709
|
})
|
|
362
710
|
.instruction());
|
|
363
711
|
return {
|
|
@@ -435,11 +783,11 @@ class TriadProtocolClient {
|
|
|
435
783
|
return;
|
|
436
784
|
}
|
|
437
785
|
}
|
|
438
|
-
const { userTradePDA, userTradeIxs } = yield this.getUserTradeNonce(marketId, Object.keys(orders[0].orderDirection)[0]);
|
|
439
|
-
if (userTradeIxs.length > 0) {
|
|
440
|
-
ixs.push(...userTradeIxs);
|
|
441
|
-
}
|
|
442
786
|
for (const order of orders) {
|
|
787
|
+
const { userTradePDA, userTradeIxs } = yield this.getUserTradeNonce(marketId, Object.keys(order.orderDirection)[0]);
|
|
788
|
+
if (userTradeIxs.length > 0) {
|
|
789
|
+
ixs.push(...userTradeIxs);
|
|
790
|
+
}
|
|
443
791
|
ixs.push(yield this.program.methods
|
|
444
792
|
.placeBidOrder({
|
|
445
793
|
amount: new bn_js_1.default(order.amount * Math.pow(10, constants_1.BASE_DECIMALS)),
|
|
@@ -795,11 +1143,11 @@ class TriadProtocolClient {
|
|
|
795
1143
|
for (const order of orders) {
|
|
796
1144
|
if (order.price.eq(new bn_js_1.default(0)))
|
|
797
1145
|
continue;
|
|
798
|
-
if ((0,
|
|
799
|
-
data[side].bid.push((0,
|
|
1146
|
+
if ((0, helpers_2.getOrderSideFromNumber)(order.orderSide) === types_1.OrderSide.BID) {
|
|
1147
|
+
data[side].bid.push((0, helpers_2.formatBookOrder)(order));
|
|
800
1148
|
}
|
|
801
|
-
if ((0,
|
|
802
|
-
data[side].ask.push((0,
|
|
1149
|
+
if ((0, helpers_2.getOrderSideFromNumber)(order.orderSide) === types_1.OrderSide.ASK) {
|
|
1150
|
+
data[side].ask.push((0, helpers_2.formatBookOrder)(order));
|
|
803
1151
|
}
|
|
804
1152
|
}
|
|
805
1153
|
};
|
|
@@ -3028,6 +3028,10 @@
|
|
|
3028
3028
|
"name": "ClaimTokenEvent",
|
|
3029
3029
|
"discriminator": [127, 10, 14, 49, 47, 171, 31, 127]
|
|
3030
3030
|
},
|
|
3031
|
+
{
|
|
3032
|
+
"name": "ClaimVaultEvent",
|
|
3033
|
+
"discriminator": [106, 57, 180, 175, 87, 6, 132, 91]
|
|
3034
|
+
},
|
|
3031
3035
|
{
|
|
3032
3036
|
"name": "CollectMarketFeeEvent",
|
|
3033
3037
|
"discriminator": [210, 147, 203, 216, 158, 111, 59, 143]
|
|
@@ -3563,6 +3567,68 @@
|
|
|
3563
3567
|
]
|
|
3564
3568
|
}
|
|
3565
3569
|
},
|
|
3570
|
+
{
|
|
3571
|
+
"name": "ClaimVaultEvent",
|
|
3572
|
+
"type": {
|
|
3573
|
+
"kind": "struct",
|
|
3574
|
+
"fields": [
|
|
3575
|
+
{
|
|
3576
|
+
"name": "authority",
|
|
3577
|
+
"type": "pubkey"
|
|
3578
|
+
},
|
|
3579
|
+
{
|
|
3580
|
+
"name": "init_ts",
|
|
3581
|
+
"type": "i64"
|
|
3582
|
+
},
|
|
3583
|
+
{
|
|
3584
|
+
"name": "end_ts",
|
|
3585
|
+
"type": "i64"
|
|
3586
|
+
},
|
|
3587
|
+
{
|
|
3588
|
+
"name": "total_amount",
|
|
3589
|
+
"type": "u64"
|
|
3590
|
+
},
|
|
3591
|
+
{
|
|
3592
|
+
"name": "total_claimed",
|
|
3593
|
+
"type": "u64"
|
|
3594
|
+
},
|
|
3595
|
+
{
|
|
3596
|
+
"name": "total_users",
|
|
3597
|
+
"type": "u64"
|
|
3598
|
+
},
|
|
3599
|
+
{
|
|
3600
|
+
"name": "claimed_users",
|
|
3601
|
+
"type": "u64"
|
|
3602
|
+
},
|
|
3603
|
+
{
|
|
3604
|
+
"name": "token_per_user",
|
|
3605
|
+
"type": "u64"
|
|
3606
|
+
},
|
|
3607
|
+
{
|
|
3608
|
+
"name": "mint",
|
|
3609
|
+
"type": "pubkey"
|
|
3610
|
+
},
|
|
3611
|
+
{
|
|
3612
|
+
"name": "is_active",
|
|
3613
|
+
"type": "bool"
|
|
3614
|
+
},
|
|
3615
|
+
{
|
|
3616
|
+
"name": "name",
|
|
3617
|
+
"type": "string"
|
|
3618
|
+
},
|
|
3619
|
+
{
|
|
3620
|
+
"name": "is_first_come_first_served",
|
|
3621
|
+
"type": "bool"
|
|
3622
|
+
},
|
|
3623
|
+
{
|
|
3624
|
+
"name": "merkle_root",
|
|
3625
|
+
"type": {
|
|
3626
|
+
"array": ["u8", 32]
|
|
3627
|
+
}
|
|
3628
|
+
}
|
|
3629
|
+
]
|
|
3630
|
+
}
|
|
3631
|
+
},
|
|
3566
3632
|
{
|
|
3567
3633
|
"name": "ClaimedUser",
|
|
3568
3634
|
"type": {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4131,6 +4131,10 @@ export type TriadProtocol = {
|
|
|
4131
4131
|
name: 'claimTokenEvent';
|
|
4132
4132
|
discriminator: [127, 10, 14, 49, 47, 171, 31, 127];
|
|
4133
4133
|
},
|
|
4134
|
+
{
|
|
4135
|
+
name: 'claimVaultEvent';
|
|
4136
|
+
discriminator: [106, 57, 180, 175, 87, 6, 132, 91];
|
|
4137
|
+
},
|
|
4134
4138
|
{
|
|
4135
4139
|
name: 'collectMarketFeeEvent';
|
|
4136
4140
|
discriminator: [210, 147, 203, 216, 158, 111, 59, 143];
|
|
@@ -4666,6 +4670,68 @@ export type TriadProtocol = {
|
|
|
4666
4670
|
];
|
|
4667
4671
|
};
|
|
4668
4672
|
},
|
|
4673
|
+
{
|
|
4674
|
+
name: 'claimVaultEvent';
|
|
4675
|
+
type: {
|
|
4676
|
+
kind: 'struct';
|
|
4677
|
+
fields: [
|
|
4678
|
+
{
|
|
4679
|
+
name: 'authority';
|
|
4680
|
+
type: 'pubkey';
|
|
4681
|
+
},
|
|
4682
|
+
{
|
|
4683
|
+
name: 'initTs';
|
|
4684
|
+
type: 'i64';
|
|
4685
|
+
},
|
|
4686
|
+
{
|
|
4687
|
+
name: 'endTs';
|
|
4688
|
+
type: 'i64';
|
|
4689
|
+
},
|
|
4690
|
+
{
|
|
4691
|
+
name: 'totalAmount';
|
|
4692
|
+
type: 'u64';
|
|
4693
|
+
},
|
|
4694
|
+
{
|
|
4695
|
+
name: 'totalClaimed';
|
|
4696
|
+
type: 'u64';
|
|
4697
|
+
},
|
|
4698
|
+
{
|
|
4699
|
+
name: 'totalUsers';
|
|
4700
|
+
type: 'u64';
|
|
4701
|
+
},
|
|
4702
|
+
{
|
|
4703
|
+
name: 'claimedUsers';
|
|
4704
|
+
type: 'u64';
|
|
4705
|
+
},
|
|
4706
|
+
{
|
|
4707
|
+
name: 'tokenPerUser';
|
|
4708
|
+
type: 'u64';
|
|
4709
|
+
},
|
|
4710
|
+
{
|
|
4711
|
+
name: 'mint';
|
|
4712
|
+
type: 'pubkey';
|
|
4713
|
+
},
|
|
4714
|
+
{
|
|
4715
|
+
name: 'isActive';
|
|
4716
|
+
type: 'bool';
|
|
4717
|
+
},
|
|
4718
|
+
{
|
|
4719
|
+
name: 'name';
|
|
4720
|
+
type: 'string';
|
|
4721
|
+
},
|
|
4722
|
+
{
|
|
4723
|
+
name: 'isFirstComeFirstServed';
|
|
4724
|
+
type: 'bool';
|
|
4725
|
+
},
|
|
4726
|
+
{
|
|
4727
|
+
name: 'merkleRoot';
|
|
4728
|
+
type: {
|
|
4729
|
+
array: ['u8', 32];
|
|
4730
|
+
};
|
|
4731
|
+
}
|
|
4732
|
+
];
|
|
4733
|
+
};
|
|
4734
|
+
},
|
|
4669
4735
|
{
|
|
4670
4736
|
name: 'claimedUser';
|
|
4671
4737
|
type: {
|
package/package.json
CHANGED
package/dist/market.d.ts
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
/// <reference types="@coral-xyz/anchor/node_modules/@solana/web3.js" />
|
|
2
|
-
import { Program } from '@coral-xyz/anchor';
|
|
3
|
-
import { PublicKey } from '@solana/web3.js';
|
|
4
|
-
import { TriadProtocol } from './types/triad_protocol';
|
|
5
|
-
import { RpcOptions, CreateMarketArgs, CreatePoolArgs, UpdateMarketWinningDirectionArgs } from './types';
|
|
6
|
-
export default class Market {
|
|
7
|
-
private program;
|
|
8
|
-
private rpcOptions;
|
|
9
|
-
constructor(program: Program<TriadProtocol>, rpcOptions: RpcOptions);
|
|
10
|
-
/**
|
|
11
|
-
* Get All Pools
|
|
12
|
-
*/
|
|
13
|
-
getAllPools(): Promise<import("./types").Pool[]>;
|
|
14
|
-
/**
|
|
15
|
-
* Get All Markets
|
|
16
|
-
*/
|
|
17
|
-
getAllMarkets(): Promise<import("./types").Market[]>;
|
|
18
|
-
/**
|
|
19
|
-
* Get Pool By ID
|
|
20
|
-
* @param poolId - The ID of the pool
|
|
21
|
-
*/
|
|
22
|
-
getPoolById(poolId: number): Promise<import("./types").Pool>;
|
|
23
|
-
/**
|
|
24
|
-
* Get Market By ID
|
|
25
|
-
* @param marketId - The ID of the market
|
|
26
|
-
*/
|
|
27
|
-
getMarketById(marketId: number): Promise<import("./types").Market>;
|
|
28
|
-
/**
|
|
29
|
-
* Get Market By Address
|
|
30
|
-
* @param marketAddress - The address of the market
|
|
31
|
-
*/
|
|
32
|
-
getMarketByAddress(marketAddress: PublicKey): Promise<import("./types").Market>;
|
|
33
|
-
/**
|
|
34
|
-
* Get Current Market ID
|
|
35
|
-
*/
|
|
36
|
-
nextMarketId(): Promise<number>;
|
|
37
|
-
/**
|
|
38
|
-
* Get Next Customer ID
|
|
39
|
-
*/
|
|
40
|
-
nextCustomerId(): Promise<number>;
|
|
41
|
-
/**
|
|
42
|
-
* Get Next Pool ID
|
|
43
|
-
*/
|
|
44
|
-
nextPoolId(): Promise<number>;
|
|
45
|
-
/**
|
|
46
|
-
* Create Market
|
|
47
|
-
* @param args.markets - Array of markets to create
|
|
48
|
-
* @param args.markets.marketId - Market ID
|
|
49
|
-
* @param args.markets.startTime - start time
|
|
50
|
-
* @param args.markets.endTime - end time
|
|
51
|
-
* @param args.markets.question - question (max 80 characters)
|
|
52
|
-
* @param args.markets.liquidityAtStart - liquidity at start
|
|
53
|
-
* @param args.markets.payoutFee - payout fee (to add affiliate system)
|
|
54
|
-
* @param args.customer - The customer of the market
|
|
55
|
-
* @param args.poolId - The ID of the pool
|
|
56
|
-
*/
|
|
57
|
-
createMarket({ markets, customer, poolId }: CreateMarketArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
58
|
-
/**
|
|
59
|
-
* Create Pool
|
|
60
|
-
* @param poolId - The ID of the pool
|
|
61
|
-
* @param question - The question of the pool
|
|
62
|
-
* @param markets - The markets of the pool
|
|
63
|
-
*/
|
|
64
|
-
createPool({ poolId, question, markets, customer, startTime, endTime, feeBps, payoutFee, isFast }: CreatePoolArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
65
|
-
/**
|
|
66
|
-
* Resolve Market
|
|
67
|
-
* @param args.marketId - The ID of the Market
|
|
68
|
-
* @param args.poolId - The ID of the Pool
|
|
69
|
-
* @param args.winningDirection - The Winning Direction of the Market
|
|
70
|
-
*/
|
|
71
|
-
updateMarketWinningDirection({ marketId, poolId, winningDirection }: UpdateMarketWinningDirectionArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
72
|
-
/**
|
|
73
|
-
* Update Market Payout
|
|
74
|
-
* @param marketId - The ID of the market
|
|
75
|
-
* @param poolId - The ID of the pool
|
|
76
|
-
* @param allowPayout - Whether to allow the market to payout
|
|
77
|
-
*/
|
|
78
|
-
updateMarketPayout({ marketId, poolId, allowPayout }: {
|
|
79
|
-
marketId: number;
|
|
80
|
-
poolId?: number;
|
|
81
|
-
allowPayout: boolean;
|
|
82
|
-
}): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
83
|
-
/**
|
|
84
|
-
* Update Market End
|
|
85
|
-
* @param marketId - The ID of the market
|
|
86
|
-
* @param marketEnd - The end time of the market
|
|
87
|
-
*/
|
|
88
|
-
updateMarketEnd({ marketId, marketEnd }: {
|
|
89
|
-
marketId: number;
|
|
90
|
-
marketEnd: number;
|
|
91
|
-
}): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
92
|
-
/**
|
|
93
|
-
* Update Market Question
|
|
94
|
-
* @param marketId - The ID of the market
|
|
95
|
-
* @param question - The question of the market
|
|
96
|
-
*/
|
|
97
|
-
updateMarketQuestion({ marketId, question }: {
|
|
98
|
-
marketId: number;
|
|
99
|
-
question: string;
|
|
100
|
-
}): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
101
|
-
/**
|
|
102
|
-
* Collect Market Fee
|
|
103
|
-
* @param args.markets - The markets to collect the fee from
|
|
104
|
-
* @param args.markets.marketAddress - The address of the market
|
|
105
|
-
* @param args.markets.customerId - The ID of the customer
|
|
106
|
-
* @param args.markets.customerFeeRecipient - The address of the customer fee recipient
|
|
107
|
-
*/
|
|
108
|
-
collectMarketFee(markets: {
|
|
109
|
-
marketAddress: PublicKey;
|
|
110
|
-
customerId: number;
|
|
111
|
-
customerFeeRecipient: PublicKey;
|
|
112
|
-
}[]): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
113
|
-
/**
|
|
114
|
-
* Collect Market Order Fee
|
|
115
|
-
* @param marketAddress - The address of the market
|
|
116
|
-
*/
|
|
117
|
-
collectMarketOrderFee(marketAddress: PublicKey[]): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
118
|
-
/**
|
|
119
|
-
* Close Order Book
|
|
120
|
-
* @param marketIds - Market IDs
|
|
121
|
-
*/
|
|
122
|
-
closeOrderBook(marketIds: number[]): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
123
|
-
/**
|
|
124
|
-
* Update Pool Question
|
|
125
|
-
* @param poolId - Pool ID
|
|
126
|
-
* @param question - Question
|
|
127
|
-
*/
|
|
128
|
-
updatePoolQuestion(poolId: number, question: string): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
129
|
-
}
|
package/dist/market.js
DELETED
|
@@ -1,377 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const anchor_1 = require("@coral-xyz/anchor");
|
|
16
|
-
const spl_token_1 = require("@solana/spl-token");
|
|
17
|
-
const helpers_1 = require("./utils/helpers");
|
|
18
|
-
const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersionedTransaction"));
|
|
19
|
-
const pda_1 = require("./utils/pda");
|
|
20
|
-
class Market {
|
|
21
|
-
constructor(program, rpcOptions) {
|
|
22
|
-
this.program = program;
|
|
23
|
-
this.rpcOptions = rpcOptions;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Get All Pools
|
|
27
|
-
*/
|
|
28
|
-
getAllPools() {
|
|
29
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
const pool = yield this.program.account.pool.all();
|
|
31
|
-
return pool.map(({ account, publicKey }) => (0, helpers_1.formatPool)(account, publicKey));
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Get All Markets
|
|
36
|
-
*/
|
|
37
|
-
getAllMarkets() {
|
|
38
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
const marketV2 = yield this.program.account.marketV2.all();
|
|
40
|
-
return marketV2.map(({ account, publicKey }) => (0, helpers_1.formatMarket)(account, publicKey));
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Get Pool By ID
|
|
45
|
-
* @param poolId - The ID of the pool
|
|
46
|
-
*/
|
|
47
|
-
getPoolById(poolId) {
|
|
48
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
const poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
|
|
50
|
-
const response = yield this.program.account.pool.fetch(poolPDA);
|
|
51
|
-
return (0, helpers_1.formatPool)(response, poolPDA);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Get Market By ID
|
|
56
|
-
* @param marketId - The ID of the market
|
|
57
|
-
*/
|
|
58
|
-
getMarketById(marketId) {
|
|
59
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
const marketPDA = (0, pda_1.getMarketPDA)(this.program.programId, marketId);
|
|
61
|
-
const response = yield this.program.account.marketV2.fetch(marketPDA);
|
|
62
|
-
return (0, helpers_1.formatMarket)(response, marketPDA);
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Get Market By Address
|
|
67
|
-
* @param marketAddress - The address of the market
|
|
68
|
-
*/
|
|
69
|
-
getMarketByAddress(marketAddress) {
|
|
70
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
const account = yield this.program.account.marketV2.fetch(marketAddress);
|
|
72
|
-
return (0, helpers_1.formatMarket)(account, marketAddress);
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Get Current Market ID
|
|
77
|
-
*/
|
|
78
|
-
nextMarketId() {
|
|
79
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
-
const markets = yield this.program.account.marketV2.all();
|
|
81
|
-
return markets.length + 10;
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Get Next Customer ID
|
|
86
|
-
*/
|
|
87
|
-
nextCustomerId() {
|
|
88
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
-
const customers = yield this.program.account.customer.all();
|
|
90
|
-
return customers.length + 1;
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Get Next Pool ID
|
|
95
|
-
*/
|
|
96
|
-
nextPoolId() {
|
|
97
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
-
const pools = yield this.program.account.pool.all();
|
|
99
|
-
return pools.length + 1;
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Create Market
|
|
104
|
-
* @param args.markets - Array of markets to create
|
|
105
|
-
* @param args.markets.marketId - Market ID
|
|
106
|
-
* @param args.markets.startTime - start time
|
|
107
|
-
* @param args.markets.endTime - end time
|
|
108
|
-
* @param args.markets.question - question (max 80 characters)
|
|
109
|
-
* @param args.markets.liquidityAtStart - liquidity at start
|
|
110
|
-
* @param args.markets.payoutFee - payout fee (to add affiliate system)
|
|
111
|
-
* @param args.customer - The customer of the market
|
|
112
|
-
* @param args.poolId - The ID of the pool
|
|
113
|
-
*/
|
|
114
|
-
createMarket({ markets, customer, poolId }) {
|
|
115
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
-
const ixs = [];
|
|
117
|
-
let poolPDA = null;
|
|
118
|
-
if (poolId) {
|
|
119
|
-
poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
|
|
120
|
-
}
|
|
121
|
-
for (const market of markets) {
|
|
122
|
-
if (market.question.length > 80) {
|
|
123
|
-
throw new Error('Question must be less than 80 characters');
|
|
124
|
-
}
|
|
125
|
-
ixs.push(yield this.program.methods
|
|
126
|
-
.createMarket({
|
|
127
|
-
marketId: new anchor_1.BN(market.marketId),
|
|
128
|
-
question: (0, helpers_1.encodeString)(market.question, 80),
|
|
129
|
-
marketStart: new anchor_1.BN(market.startTime),
|
|
130
|
-
marketEnd: new anchor_1.BN(market.endTime),
|
|
131
|
-
feeBps: market.feeBps,
|
|
132
|
-
payoutFee: market.payoutFee
|
|
133
|
-
})
|
|
134
|
-
.accounts({
|
|
135
|
-
signer: this.program.provider.publicKey,
|
|
136
|
-
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
137
|
-
pool: poolPDA,
|
|
138
|
-
customer
|
|
139
|
-
})
|
|
140
|
-
.instruction());
|
|
141
|
-
ixs.push(yield this.program.methods
|
|
142
|
-
.createOrderBook(new anchor_1.BN(market.marketId))
|
|
143
|
-
.accounts({
|
|
144
|
-
signer: this.program.provider.publicKey,
|
|
145
|
-
market: (0, pda_1.getMarketPDA)(this.program.programId, market.marketId)
|
|
146
|
-
})
|
|
147
|
-
.instruction());
|
|
148
|
-
}
|
|
149
|
-
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Create Pool
|
|
154
|
-
* @param poolId - The ID of the pool
|
|
155
|
-
* @param question - The question of the pool
|
|
156
|
-
* @param markets - The markets of the pool
|
|
157
|
-
*/
|
|
158
|
-
createPool({ poolId, question, markets, customer, startTime, endTime, feeBps, payoutFee, isFast }) {
|
|
159
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
-
if (question.length > 80) {
|
|
161
|
-
throw new Error('Pool question must be less than 80 characters');
|
|
162
|
-
}
|
|
163
|
-
const ixs = [];
|
|
164
|
-
const poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
|
|
165
|
-
ixs.push(yield this.program.methods
|
|
166
|
-
.createPool({
|
|
167
|
-
poolId: new anchor_1.BN(poolId),
|
|
168
|
-
question: (0, helpers_1.encodeString)(question, 80),
|
|
169
|
-
isFast
|
|
170
|
-
})
|
|
171
|
-
.accounts({
|
|
172
|
-
signer: this.program.provider.publicKey,
|
|
173
|
-
customer
|
|
174
|
-
})
|
|
175
|
-
.instruction());
|
|
176
|
-
for (const market of markets) {
|
|
177
|
-
if (market.question.length > 80) {
|
|
178
|
-
throw new Error('Market question must be less than 80 characters');
|
|
179
|
-
}
|
|
180
|
-
ixs.push(yield this.program.methods
|
|
181
|
-
.createMarket({
|
|
182
|
-
marketId: new anchor_1.BN(market.marketId),
|
|
183
|
-
question: (0, helpers_1.encodeString)(market.question, 80),
|
|
184
|
-
marketStart: new anchor_1.BN(startTime),
|
|
185
|
-
marketEnd: new anchor_1.BN(endTime),
|
|
186
|
-
feeBps,
|
|
187
|
-
payoutFee
|
|
188
|
-
})
|
|
189
|
-
.accounts({
|
|
190
|
-
signer: this.program.provider.publicKey,
|
|
191
|
-
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
192
|
-
pool: poolPDA,
|
|
193
|
-
customer
|
|
194
|
-
})
|
|
195
|
-
.instruction());
|
|
196
|
-
ixs.push(yield this.program.methods
|
|
197
|
-
.createOrderBook(new anchor_1.BN(market.marketId))
|
|
198
|
-
.accounts({
|
|
199
|
-
signer: this.program.provider.publicKey,
|
|
200
|
-
market: (0, pda_1.getMarketPDA)(this.program.programId, market.marketId)
|
|
201
|
-
})
|
|
202
|
-
.instruction());
|
|
203
|
-
}
|
|
204
|
-
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Resolve Market
|
|
209
|
-
* @param args.marketId - The ID of the Market
|
|
210
|
-
* @param args.poolId - The ID of the Pool
|
|
211
|
-
* @param args.winningDirection - The Winning Direction of the Market
|
|
212
|
-
*/
|
|
213
|
-
updateMarketWinningDirection({ marketId, poolId, winningDirection }) {
|
|
214
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
215
|
-
let poolPDA = null;
|
|
216
|
-
if (poolId) {
|
|
217
|
-
poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
|
|
218
|
-
}
|
|
219
|
-
const ixs = [
|
|
220
|
-
yield this.program.methods
|
|
221
|
-
.updateMarketWinningDirection(winningDirection)
|
|
222
|
-
.accounts({
|
|
223
|
-
signer: this.program.provider.publicKey,
|
|
224
|
-
market: (0, pda_1.getMarketPDA)(this.program.programId, marketId),
|
|
225
|
-
pool: poolPDA
|
|
226
|
-
})
|
|
227
|
-
.instruction()
|
|
228
|
-
];
|
|
229
|
-
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Update Market Payout
|
|
234
|
-
* @param marketId - The ID of the market
|
|
235
|
-
* @param poolId - The ID of the pool
|
|
236
|
-
* @param allowPayout - Whether to allow the market to payout
|
|
237
|
-
*/
|
|
238
|
-
updateMarketPayout({ marketId, poolId, allowPayout }) {
|
|
239
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
240
|
-
let poolPDA = null;
|
|
241
|
-
if (poolId) {
|
|
242
|
-
poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
|
|
243
|
-
}
|
|
244
|
-
const ixs = [
|
|
245
|
-
yield this.program.methods
|
|
246
|
-
.updateMarketPayout(allowPayout)
|
|
247
|
-
.accounts({
|
|
248
|
-
signer: this.program.provider.publicKey,
|
|
249
|
-
market: (0, pda_1.getMarketPDA)(this.program.programId, marketId)
|
|
250
|
-
})
|
|
251
|
-
.instruction()
|
|
252
|
-
];
|
|
253
|
-
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* Update Market End
|
|
258
|
-
* @param marketId - The ID of the market
|
|
259
|
-
* @param marketEnd - The end time of the market
|
|
260
|
-
*/
|
|
261
|
-
updateMarketEnd({ marketId, marketEnd }) {
|
|
262
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
263
|
-
const ixs = [
|
|
264
|
-
yield this.program.methods
|
|
265
|
-
.updateMarketEnd(new anchor_1.BN(marketEnd))
|
|
266
|
-
.accounts({
|
|
267
|
-
signer: this.program.provider.publicKey,
|
|
268
|
-
market: (0, pda_1.getMarketPDA)(this.program.programId, marketId)
|
|
269
|
-
})
|
|
270
|
-
.instruction()
|
|
271
|
-
];
|
|
272
|
-
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* Update Market Question
|
|
277
|
-
* @param marketId - The ID of the market
|
|
278
|
-
* @param question - The question of the market
|
|
279
|
-
*/
|
|
280
|
-
updateMarketQuestion({ marketId, question }) {
|
|
281
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
282
|
-
const ixs = [
|
|
283
|
-
yield this.program.methods
|
|
284
|
-
.updateMarketQuestion((0, helpers_1.encodeString)(question, 80))
|
|
285
|
-
.accounts({
|
|
286
|
-
signer: this.program.provider.publicKey,
|
|
287
|
-
market: (0, pda_1.getMarketPDA)(this.program.programId, marketId)
|
|
288
|
-
})
|
|
289
|
-
.instruction()
|
|
290
|
-
];
|
|
291
|
-
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* Collect Market Fee
|
|
296
|
-
* @param args.markets - The markets to collect the fee from
|
|
297
|
-
* @param args.markets.marketAddress - The address of the market
|
|
298
|
-
* @param args.markets.customerId - The ID of the customer
|
|
299
|
-
* @param args.markets.customerFeeRecipient - The address of the customer fee recipient
|
|
300
|
-
*/
|
|
301
|
-
collectMarketFee(markets) {
|
|
302
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
303
|
-
const ixs = [];
|
|
304
|
-
for (const market of markets) {
|
|
305
|
-
ixs.push(yield this.program.methods
|
|
306
|
-
.collectMarketFee()
|
|
307
|
-
.accounts({
|
|
308
|
-
signer: this.program.provider.publicKey,
|
|
309
|
-
market: market.marketAddress,
|
|
310
|
-
customer: (0, pda_1.getCustomerPDA)(this.program.programId, market.customerId),
|
|
311
|
-
customerFeeRecipient: market.customerFeeRecipient
|
|
312
|
-
})
|
|
313
|
-
.instruction());
|
|
314
|
-
}
|
|
315
|
-
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Collect Market Order Fee
|
|
320
|
-
* @param marketAddress - The address of the market
|
|
321
|
-
*/
|
|
322
|
-
collectMarketOrderFee(marketAddress) {
|
|
323
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
324
|
-
const ixs = [];
|
|
325
|
-
for (const market of marketAddress) {
|
|
326
|
-
ixs.push(yield this.program.methods
|
|
327
|
-
.collectMarketOrderFee()
|
|
328
|
-
.accounts({
|
|
329
|
-
signer: this.program.provider.publicKey,
|
|
330
|
-
market: market
|
|
331
|
-
})
|
|
332
|
-
.instruction());
|
|
333
|
-
}
|
|
334
|
-
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* Close Order Book
|
|
339
|
-
* @param marketIds - Market IDs
|
|
340
|
-
*/
|
|
341
|
-
closeOrderBook(marketIds) {
|
|
342
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
343
|
-
const ixs = [];
|
|
344
|
-
for (const marketId of marketIds) {
|
|
345
|
-
ixs.push(yield this.program.methods
|
|
346
|
-
.closeOrderBook()
|
|
347
|
-
.accounts({
|
|
348
|
-
signer: this.program.provider.publicKey,
|
|
349
|
-
market: (0, pda_1.getMarketPDA)(this.program.programId, marketId),
|
|
350
|
-
orderBook: (0, pda_1.getOrderBookPDA)(this.program.programId, marketId)
|
|
351
|
-
})
|
|
352
|
-
.instruction());
|
|
353
|
-
}
|
|
354
|
-
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
/**
|
|
358
|
-
* Update Pool Question
|
|
359
|
-
* @param poolId - Pool ID
|
|
360
|
-
* @param question - Question
|
|
361
|
-
*/
|
|
362
|
-
updatePoolQuestion(poolId, question) {
|
|
363
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
364
|
-
const ixs = [
|
|
365
|
-
yield this.program.methods
|
|
366
|
-
.updatePoolQuestion((0, helpers_1.encodeString)(question, 80))
|
|
367
|
-
.accounts({
|
|
368
|
-
signer: this.program.provider.publicKey,
|
|
369
|
-
pool: (0, pda_1.getPoolPDA)(this.program.programId, poolId)
|
|
370
|
-
})
|
|
371
|
-
.instruction()
|
|
372
|
-
];
|
|
373
|
-
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
exports.default = Market;
|