precog-markets 1.2.2 → 1.2.4
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 +4 -3
- package/package.json +2 -2
- package/src/client.js +5 -4
- package/src/constants.js +55 -48
- package/src/index.d.ts +7 -2
- package/src/instructions.js +6 -6
package/README.md
CHANGED
|
@@ -159,10 +159,11 @@ Each builder returns a `TransactionInstruction`. Pass your own accounts — the
|
|
|
159
159
|
> **Note:** Instruction data uses a single `u8` byte discriminator (NOT a 4-byte or 8-byte Anchor discriminator).
|
|
160
160
|
|
|
161
161
|
```js
|
|
162
|
-
import { placeBet } from "precog-markets";
|
|
162
|
+
import { placeBet, findProtocolConfigAddress } from "precog-markets";
|
|
163
163
|
|
|
164
|
+
const [protocolConfig] = findProtocolConfigAddress();
|
|
164
165
|
const ix = placeBet(
|
|
165
|
-
{ market, vault, position, bettor: bettor.publicKey },
|
|
166
|
+
{ market, vault, position, bettor: bettor.publicKey, protocolConfig },
|
|
166
167
|
{ outcomeIndex: 0, amount: 1_000_000_000n }
|
|
167
168
|
);
|
|
168
169
|
```
|
|
@@ -461,4 +462,4 @@ console.log(reader.readBool()); // true
|
|
|
461
462
|
|
|
462
463
|
## License
|
|
463
464
|
|
|
464
|
-
MIT
|
|
465
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "precog-markets",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "JavaScript SDK for Precog Markets — a Solana prediction market program — pari-mutuel markets with SOL, SPL Token, and Token-2022 support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -66,4 +66,4 @@
|
|
|
66
66
|
"engines": {
|
|
67
67
|
"node": ">=18"
|
|
68
68
|
}
|
|
69
|
-
}
|
|
69
|
+
}
|
package/src/client.js
CHANGED
|
@@ -451,9 +451,10 @@ export class PrecogMarketsClient {
|
|
|
451
451
|
params.bettor.publicKey,
|
|
452
452
|
params.outcomeIndex
|
|
453
453
|
);
|
|
454
|
+
const [protocolConfig] = this.findProtocolConfig();
|
|
454
455
|
|
|
455
456
|
const instruction = ix.placeBet(
|
|
456
|
-
{ market: params.market, vault, position, bettor: params.bettor.publicKey },
|
|
457
|
+
{ market: params.market, vault, position, bettor: params.bettor.publicKey, protocolConfig },
|
|
457
458
|
{ outcomeIndex: params.outcomeIndex, amount: params.amount },
|
|
458
459
|
this.programId
|
|
459
460
|
);
|
|
@@ -486,7 +487,7 @@ export class PrecogMarketsClient {
|
|
|
486
487
|
params.bettor.publicKey,
|
|
487
488
|
params.outcomeIndex
|
|
488
489
|
);
|
|
489
|
-
const [
|
|
490
|
+
const [protocolConfig] = this.findProtocolConfig();
|
|
490
491
|
|
|
491
492
|
const instruction = ix.placeBet(
|
|
492
493
|
{
|
|
@@ -494,11 +495,11 @@ export class PrecogMarketsClient {
|
|
|
494
495
|
vault,
|
|
495
496
|
position,
|
|
496
497
|
bettor: params.bettor.publicKey,
|
|
498
|
+
protocolConfig,
|
|
497
499
|
bettorTokenAccount: params.bettorTokenAccount,
|
|
498
500
|
tokenVault: params.tokenVault,
|
|
499
501
|
tokenMint: params.tokenMint,
|
|
500
502
|
tokenProgram: params.tokenProgram,
|
|
501
|
-
vaultAuthority,
|
|
502
503
|
},
|
|
503
504
|
{ outcomeIndex: params.outcomeIndex, amount: params.amount },
|
|
504
505
|
this.programId
|
|
@@ -1044,4 +1045,4 @@ export class PrecogMarketsClient {
|
|
|
1044
1045
|
|
|
1045
1046
|
return { signature, estimatedUnits, priorityFee };
|
|
1046
1047
|
}
|
|
1047
|
-
}
|
|
1048
|
+
}
|
package/src/constants.js
CHANGED
|
@@ -119,56 +119,63 @@ export const ErrorCode = /** @type {const} */ ({
|
|
|
119
119
|
6: "MarketNotOpen",
|
|
120
120
|
7: "MarketNotResolved",
|
|
121
121
|
8: "MarketAlreadyResolved",
|
|
122
|
-
9: "
|
|
123
|
-
10: "
|
|
124
|
-
11: "
|
|
125
|
-
12: "
|
|
126
|
-
13: "
|
|
127
|
-
14: "
|
|
128
|
-
15: "
|
|
129
|
-
16: "
|
|
130
|
-
17: "
|
|
131
|
-
18: "
|
|
132
|
-
19: "
|
|
133
|
-
20: "
|
|
134
|
-
21: "
|
|
135
|
-
22: "
|
|
136
|
-
23: "
|
|
137
|
-
24: "
|
|
138
|
-
25: "
|
|
139
|
-
26: "
|
|
140
|
-
27: "
|
|
141
|
-
28: "
|
|
142
|
-
29: "
|
|
143
|
-
30: "
|
|
144
|
-
31: "
|
|
145
|
-
32: "
|
|
146
|
-
33: "
|
|
147
|
-
34: "
|
|
148
|
-
35: "
|
|
149
|
-
36: "
|
|
150
|
-
37: "
|
|
151
|
-
38: "
|
|
152
|
-
39: "
|
|
153
|
-
40: "
|
|
154
|
-
41: "
|
|
155
|
-
42: "
|
|
156
|
-
43: "
|
|
157
|
-
44: "
|
|
158
|
-
45: "
|
|
159
|
-
46: "
|
|
160
|
-
47: "
|
|
161
|
-
48: "
|
|
162
|
-
49: "
|
|
163
|
-
50: "
|
|
164
|
-
51: "
|
|
165
|
-
52: "
|
|
166
|
-
53: "
|
|
167
|
-
54: "
|
|
168
|
-
55: "
|
|
122
|
+
9: "WinningPoolEmpty",
|
|
123
|
+
10: "InsufficientDistinctPositions",
|
|
124
|
+
11: "DeadlineNotReached",
|
|
125
|
+
12: "DeadlinePassed",
|
|
126
|
+
13: "MarketInDispute",
|
|
127
|
+
14: "ZeroBetAmount",
|
|
128
|
+
15: "BetBelowMinimum",
|
|
129
|
+
16: "InvalidOutcomeIndex",
|
|
130
|
+
17: "NoWinningPosition",
|
|
131
|
+
18: "AlreadyClaimedWinnings",
|
|
132
|
+
19: "RefundNotAvailable",
|
|
133
|
+
20: "UnauthorizedAuthority",
|
|
134
|
+
21: "UnauthorizedAdmin",
|
|
135
|
+
22: "UnauthorizedPositionOwner",
|
|
136
|
+
23: "MissingSignature",
|
|
137
|
+
24: "InvalidPDA",
|
|
138
|
+
25: "AccountAlreadyInitialized",
|
|
139
|
+
26: "AccountNotInitialized",
|
|
140
|
+
27: "InvalidVault",
|
|
141
|
+
28: "InvalidSystemProgram",
|
|
142
|
+
29: "ArithmeticOverflow",
|
|
143
|
+
30: "DivisionByZero",
|
|
144
|
+
31: "FeeTooHigh",
|
|
145
|
+
32: "DisputePeriodExpired",
|
|
146
|
+
33: "DisputePeriodNotExpired",
|
|
147
|
+
34: "InvalidTokenProgram",
|
|
148
|
+
35: "TokenMintMismatch",
|
|
149
|
+
36: "InvalidTokenVaultOwner",
|
|
150
|
+
37: "InvalidTokenAccount",
|
|
151
|
+
38: "TokenTransferFailed",
|
|
152
|
+
39: "DenominationMismatch",
|
|
153
|
+
40: "InvalidMint",
|
|
154
|
+
41: "DecimalsMismatch",
|
|
155
|
+
42: "TransferFeeExceedsLimit",
|
|
156
|
+
43: "InsufficientPostFeeAmount",
|
|
157
|
+
44: "TransferHookNotAllowed",
|
|
158
|
+
45: "UnsupportedTokenExtension",
|
|
159
|
+
46: "HarvestNotAuthorized",
|
|
160
|
+
47: "NewDeadlineInPast",
|
|
161
|
+
48: "MarketNotOpenForUpdate",
|
|
162
|
+
49: "MultisigSignersFull",
|
|
163
|
+
50: "CannotRemoveSigner",
|
|
164
|
+
51: "SignerNotFound",
|
|
165
|
+
52: "MarketNotRequired",
|
|
166
|
+
53: "InvalidMultisigThreshold",
|
|
167
|
+
54: "TooManyMultisigSigners",
|
|
168
|
+
55: "DuplicateMultisigSigner",
|
|
169
|
+
56: "InsufficientMultisigSignatures",
|
|
170
|
+
57: "SignerNotMultisigMember",
|
|
171
|
+
58: "ProposalAlreadyExecuted",
|
|
172
|
+
59: "ProposalExpired",
|
|
173
|
+
60: "AlreadyApprovedProposal",
|
|
174
|
+
61: "SignerSetChanged",
|
|
175
|
+
62: "FeeBelowProtocolMinimum",
|
|
169
176
|
});
|
|
170
177
|
|
|
171
178
|
/** Map error name → code */
|
|
172
179
|
export const ErrorName = Object.fromEntries(
|
|
173
180
|
Object.entries(ErrorCode).map(([k, v]) => [v, Number(k)])
|
|
174
|
-
);
|
|
181
|
+
);
|
package/src/index.d.ts
CHANGED
|
@@ -327,11 +327,16 @@ export interface PlaceBetAccounts {
|
|
|
327
327
|
vault: PublicKey;
|
|
328
328
|
position: PublicKey;
|
|
329
329
|
bettor: PublicKey;
|
|
330
|
+
/** Checked for paused flag; PDA [PROTOCOL_CONFIG_SEED] */
|
|
331
|
+
protocolConfig: PublicKey;
|
|
332
|
+
/** SPL/Token-2022 only */
|
|
330
333
|
bettorTokenAccount?: PublicKey;
|
|
334
|
+
/** SPL/Token-2022 only */
|
|
331
335
|
tokenVault?: PublicKey;
|
|
336
|
+
/** SPL/Token-2022 only */
|
|
332
337
|
tokenMint?: PublicKey;
|
|
338
|
+
/** SPL/Token-2022 only */
|
|
333
339
|
tokenProgram?: PublicKey;
|
|
334
|
-
vaultAuthority?: PublicKey;
|
|
335
340
|
}
|
|
336
341
|
|
|
337
342
|
export declare function placeBet(
|
|
@@ -784,4 +789,4 @@ export declare class PrecogMarketsClient {
|
|
|
784
789
|
estimatedUnits: number;
|
|
785
790
|
priorityFee: number;
|
|
786
791
|
}>;
|
|
787
|
-
}
|
|
792
|
+
}
|
package/src/instructions.js
CHANGED
|
@@ -208,11 +208,11 @@ export function createMarket(accounts, args, programId = PROGRAM_ID) {
|
|
|
208
208
|
* @property {PublicKey} vault
|
|
209
209
|
* @property {PublicKey} position
|
|
210
210
|
* @property {PublicKey} bettor
|
|
211
|
-
* @property {PublicKey} [
|
|
212
|
-
* @property {PublicKey} [
|
|
213
|
-
* @property {PublicKey} [
|
|
214
|
-
* @property {PublicKey} [
|
|
215
|
-
* @property {PublicKey} [
|
|
211
|
+
* @property {PublicKey} protocolConfig - Checked for paused flag; PDA [PROTOCOL_CONFIG_SEED]
|
|
212
|
+
* @property {PublicKey} [bettorTokenAccount] - SPL/Token-2022 only
|
|
213
|
+
* @property {PublicKey} [tokenVault] - SPL/Token-2022 only
|
|
214
|
+
* @property {PublicKey} [tokenMint] - SPL/Token-2022 only
|
|
215
|
+
* @property {PublicKey} [tokenProgram] - SPL/Token-2022 only
|
|
216
216
|
*/
|
|
217
217
|
|
|
218
218
|
/**
|
|
@@ -232,6 +232,7 @@ export function placeBet(accounts, args, programId = PROGRAM_ID) {
|
|
|
232
232
|
w(accounts.vault),
|
|
233
233
|
w(accounts.position),
|
|
234
234
|
ws(accounts.bettor),
|
|
235
|
+
ro(accounts.protocolConfig),
|
|
235
236
|
ro(SYSTEM_PROGRAM_ID),
|
|
236
237
|
];
|
|
237
238
|
|
|
@@ -240,7 +241,6 @@ export function placeBet(accounts, args, programId = PROGRAM_ID) {
|
|
|
240
241
|
keys.push(w(accounts.tokenVault));
|
|
241
242
|
keys.push(ro(accounts.tokenMint));
|
|
242
243
|
keys.push(ro(accounts.tokenProgram));
|
|
243
|
-
keys.push(ro(accounts.vaultAuthority));
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
return new TransactionInstruction({ programId, keys, data: wr.toBuffer() });
|