@triadxyz/triad-protocol 2.4.4-beta → 2.4.6-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 +3 -4
- package/dist/index.js +47 -51
- package/dist/types/index.d.ts +15 -18
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Connection, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
|
2
2
|
import { AnchorProvider, Program, Wallet } from '@coral-xyz/anchor';
|
|
3
3
|
import BN from 'bn.js';
|
|
4
4
|
import { TriadProtocol } from './types/triad_protocol';
|
|
5
|
-
import { CreateMarketArgs, OpenOrderArgs, UserTrade, CreateCustomerArgs, MarketBidOrderArgs, CancelBidOrderArgs, CancelAskOrderArgs, PlaceBidOrderArgs, PlaceAskOrderArgs,
|
|
5
|
+
import { CreateMarketArgs, OpenOrderArgs, UserTrade, CreateCustomerArgs, MarketBidOrderArgs, CancelBidOrderArgs, CancelAskOrderArgs, PlaceBidOrderArgs, PlaceAskOrderArgs, CreatePoolArgs, BookOrder, MarketAskOrderArgs, RpcOptions, CollectMarketFeeArgs } from './types';
|
|
6
6
|
import Stake from './stake';
|
|
7
7
|
import Poseidon from './poseidon';
|
|
8
8
|
export default class TriadProtocolClient {
|
|
@@ -174,12 +174,11 @@ export default class TriadProtocolClient {
|
|
|
174
174
|
* @param args.question - question (max 80 characters)
|
|
175
175
|
* @param args.liquidityAtStart - liquidity at start
|
|
176
176
|
* @param args.payoutFee - payout fee (to add affiliate system)
|
|
177
|
-
* @param args.currentMarketId - if fast market, we need check the pool parameters
|
|
178
177
|
*
|
|
179
178
|
* @param options - RPC options
|
|
180
179
|
*
|
|
181
180
|
*/
|
|
182
|
-
createMarket({
|
|
181
|
+
createMarket({ markets, customer, mint, poolId }: CreateMarketArgs, options?: RpcOptions): Promise<string>;
|
|
183
182
|
/**
|
|
184
183
|
* Create Pool
|
|
185
184
|
* @param poolId - The ID of the pool
|
|
@@ -188,7 +187,7 @@ export default class TriadProtocolClient {
|
|
|
188
187
|
*
|
|
189
188
|
* @param options - RPC options
|
|
190
189
|
*/
|
|
191
|
-
|
|
190
|
+
createPool({ poolId, question, markets, mint, customer, startTime, endTime, feeBps, payoutFee, isFast }: CreatePoolArgs, options?: RpcOptions): Promise<string>;
|
|
192
191
|
/**
|
|
193
192
|
* Open Order
|
|
194
193
|
* @param args.marketId - The ID of the Market
|
package/dist/index.js
CHANGED
|
@@ -152,52 +152,53 @@ class TriadProtocolClient {
|
|
|
152
152
|
* @param args.question - question (max 80 characters)
|
|
153
153
|
* @param args.liquidityAtStart - liquidity at start
|
|
154
154
|
* @param args.payoutFee - payout fee (to add affiliate system)
|
|
155
|
-
* @param args.currentMarketId - if fast market, we need check the pool parameters
|
|
156
155
|
*
|
|
157
156
|
* @param options - RPC options
|
|
158
157
|
*
|
|
159
158
|
*/
|
|
160
|
-
createMarket({
|
|
159
|
+
createMarket({ markets, customer, mint, poolId }, options) {
|
|
161
160
|
return __awaiter(this, void 0, void 0, function* () {
|
|
162
|
-
if (question.length > 80) {
|
|
163
|
-
throw new Error('Question must be less than 80 characters');
|
|
164
|
-
}
|
|
165
161
|
const ixs = [];
|
|
166
|
-
let poolPDA = null;
|
|
167
|
-
if (poolId) {
|
|
168
|
-
poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
|
|
169
|
-
}
|
|
170
162
|
let userTrade = null;
|
|
171
163
|
try {
|
|
172
164
|
yield this.getUserTrade(this.program.provider.publicKey);
|
|
173
165
|
userTrade = (0, pda_1.getUserTradePDA)(this.program.programId, this.program.provider.publicKey);
|
|
174
166
|
}
|
|
175
167
|
catch (_a) { }
|
|
176
|
-
|
|
177
|
-
.
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
168
|
+
for (const market of markets) {
|
|
169
|
+
if (market.question.length > 80) {
|
|
170
|
+
throw new Error('Question must be less than 80 characters');
|
|
171
|
+
}
|
|
172
|
+
let poolPDA = null;
|
|
173
|
+
if (poolId) {
|
|
174
|
+
poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
|
|
175
|
+
}
|
|
176
|
+
ixs.push(yield this.program.methods
|
|
177
|
+
.createMarket({
|
|
178
|
+
marketId: new bn_js_1.default(market.marketId),
|
|
179
|
+
question: (0, helpers_1.encodeString)(market.question, 80),
|
|
180
|
+
marketStart: new bn_js_1.default(market.startTime),
|
|
181
|
+
marketEnd: new bn_js_1.default(market.endTime),
|
|
182
|
+
feeBps: market.feeBps,
|
|
183
|
+
payoutFee: market.payoutFee
|
|
184
|
+
})
|
|
185
|
+
.accounts({
|
|
186
|
+
signer: this.program.provider.publicKey,
|
|
187
|
+
mint,
|
|
188
|
+
tokenProgram: (0, helpers_1.getTokenProgram)(mint),
|
|
189
|
+
customer,
|
|
190
|
+
pool: poolPDA,
|
|
191
|
+
userTrade
|
|
192
|
+
})
|
|
193
|
+
.instruction());
|
|
194
|
+
ixs.push(yield this.program.methods
|
|
195
|
+
.createOrderBook(new bn_js_1.default(market.marketId))
|
|
196
|
+
.accounts({
|
|
197
|
+
signer: this.program.provider.publicKey,
|
|
198
|
+
market: (0, pda_1.getMarketPDA)(this.program.programId, market.marketId)
|
|
199
|
+
})
|
|
200
|
+
.instruction());
|
|
201
|
+
}
|
|
201
202
|
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
202
203
|
});
|
|
203
204
|
}
|
|
@@ -209,34 +210,29 @@ class TriadProtocolClient {
|
|
|
209
210
|
*
|
|
210
211
|
* @param options - RPC options
|
|
211
212
|
*/
|
|
212
|
-
|
|
213
|
+
createPool({ poolId, question, markets, mint, customer, startTime, endTime, feeBps, payoutFee, isFast }, options) {
|
|
213
214
|
return __awaiter(this, void 0, void 0, function* () {
|
|
214
215
|
if (question.length > 80) {
|
|
215
216
|
throw new Error('Pool question must be less than 80 characters');
|
|
216
217
|
}
|
|
217
218
|
const ixs = [];
|
|
218
219
|
const poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
.accounts({
|
|
230
|
-
signer: this.program.provider.publicKey
|
|
231
|
-
})
|
|
232
|
-
.instruction());
|
|
233
|
-
}
|
|
220
|
+
ixs.push(yield this.program.methods
|
|
221
|
+
.createPool({
|
|
222
|
+
poolId: new bn_js_1.default(poolId),
|
|
223
|
+
question: (0, helpers_1.encodeString)(question, 80),
|
|
224
|
+
isFast
|
|
225
|
+
})
|
|
226
|
+
.accounts({
|
|
227
|
+
signer: this.program.provider.publicKey
|
|
228
|
+
})
|
|
229
|
+
.instruction());
|
|
234
230
|
let userTrade = null;
|
|
235
231
|
try {
|
|
236
232
|
yield this.getUserTrade(this.program.provider.publicKey);
|
|
237
233
|
userTrade = (0, pda_1.getUserTradePDA)(this.program.programId, this.program.provider.publicKey);
|
|
238
234
|
}
|
|
239
|
-
catch (
|
|
235
|
+
catch (_a) { }
|
|
240
236
|
for (const market of markets) {
|
|
241
237
|
if (market.question.length > 80) {
|
|
242
238
|
throw new Error('Market question must be less than 80 characters');
|
package/dist/types/index.d.ts
CHANGED
|
@@ -156,33 +156,30 @@ export type OpenOrderArgs = {
|
|
|
156
156
|
mint: PublicKey;
|
|
157
157
|
};
|
|
158
158
|
export type CreateMarketArgs = {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
159
|
+
markets: {
|
|
160
|
+
marketId: number;
|
|
161
|
+
startTime: number;
|
|
162
|
+
endTime: number;
|
|
163
|
+
question: string;
|
|
164
|
+
feeBps: number;
|
|
165
|
+
payoutFee: number;
|
|
166
|
+
}[];
|
|
164
167
|
customer: PublicKey | null;
|
|
165
|
-
payoutFee: number;
|
|
166
168
|
mint: PublicKey;
|
|
167
169
|
poolId?: number;
|
|
168
|
-
currentMarketId?: number;
|
|
169
|
-
upPrice?: number;
|
|
170
|
-
downPrice?: number;
|
|
171
170
|
};
|
|
172
|
-
export type
|
|
171
|
+
export type CreatePoolArgs = {
|
|
173
172
|
poolId: number;
|
|
174
|
-
question
|
|
175
|
-
startTime
|
|
176
|
-
endTime
|
|
177
|
-
feeBps
|
|
178
|
-
payoutFee
|
|
179
|
-
mint
|
|
173
|
+
question?: string;
|
|
174
|
+
startTime: number;
|
|
175
|
+
endTime: number;
|
|
176
|
+
feeBps: number;
|
|
177
|
+
payoutFee: number;
|
|
178
|
+
mint: PublicKey;
|
|
180
179
|
customer?: PublicKey | null;
|
|
181
180
|
markets: {
|
|
182
181
|
marketId: number;
|
|
183
182
|
question: string;
|
|
184
|
-
upPrice?: number;
|
|
185
|
-
downPrice?: number;
|
|
186
183
|
}[];
|
|
187
184
|
isFast?: boolean;
|
|
188
185
|
};
|