@bench.games/conviction-markets 0.1.0

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.
Files changed (107) hide show
  1. package/README.md +298 -0
  2. package/dist/constants.d.ts +29 -0
  3. package/dist/constants.d.ts.map +1 -0
  4. package/dist/constants.js +29 -0
  5. package/dist/constants.js.map +1 -0
  6. package/dist/idl/conviction_market.d.ts +3760 -0
  7. package/dist/idl/conviction_market.d.ts.map +1 -0
  8. package/dist/idl/conviction_market.js +2 -0
  9. package/dist/idl/conviction_market.js.map +1 -0
  10. package/dist/idl/conviction_market.json +3753 -0
  11. package/dist/index.d.ts +6 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +6 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/instructions/addMarketOption.d.ts +38 -0
  16. package/dist/instructions/addMarketOption.d.ts.map +1 -0
  17. package/dist/instructions/addMarketOption.js +30 -0
  18. package/dist/instructions/addMarketOption.js.map +1 -0
  19. package/dist/instructions/buyMarketShares.d.ts +47 -0
  20. package/dist/instructions/buyMarketShares.d.ts.map +1 -0
  21. package/dist/instructions/buyMarketShares.js +63 -0
  22. package/dist/instructions/buyMarketShares.js.map +1 -0
  23. package/dist/instructions/claimVoteTokens.d.ts +40 -0
  24. package/dist/instructions/claimVoteTokens.d.ts.map +1 -0
  25. package/dist/instructions/claimVoteTokens.js +49 -0
  26. package/dist/instructions/claimVoteTokens.js.map +1 -0
  27. package/dist/instructions/closeShareAccount.d.ts +36 -0
  28. package/dist/instructions/closeShareAccount.d.ts.map +1 -0
  29. package/dist/instructions/closeShareAccount.js +28 -0
  30. package/dist/instructions/closeShareAccount.js.map +1 -0
  31. package/dist/instructions/createMarket.d.ts +48 -0
  32. package/dist/instructions/createMarket.d.ts.map +1 -0
  33. package/dist/instructions/createMarket.js +64 -0
  34. package/dist/instructions/createMarket.js.map +1 -0
  35. package/dist/instructions/incrementOptionTally.d.ts +35 -0
  36. package/dist/instructions/incrementOptionTally.d.ts.map +1 -0
  37. package/dist/instructions/incrementOptionTally.js +27 -0
  38. package/dist/instructions/incrementOptionTally.js.map +1 -0
  39. package/dist/instructions/index.d.ts +13 -0
  40. package/dist/instructions/index.d.ts.map +1 -0
  41. package/dist/instructions/index.js +16 -0
  42. package/dist/instructions/index.js.map +1 -0
  43. package/dist/instructions/initShareAccount.d.ts +34 -0
  44. package/dist/instructions/initShareAccount.d.ts.map +1 -0
  45. package/dist/instructions/initShareAccount.js +33 -0
  46. package/dist/instructions/initShareAccount.js.map +1 -0
  47. package/dist/instructions/initVoteTokenAccount.d.ts +37 -0
  48. package/dist/instructions/initVoteTokenAccount.d.ts.map +1 -0
  49. package/dist/instructions/initVoteTokenAccount.js +48 -0
  50. package/dist/instructions/initVoteTokenAccount.js.map +1 -0
  51. package/dist/instructions/mintVoteTokens.d.ts +40 -0
  52. package/dist/instructions/mintVoteTokens.d.ts.map +1 -0
  53. package/dist/instructions/mintVoteTokens.js +49 -0
  54. package/dist/instructions/mintVoteTokens.js.map +1 -0
  55. package/dist/instructions/openMarket.d.ts +34 -0
  56. package/dist/instructions/openMarket.d.ts.map +1 -0
  57. package/dist/instructions/openMarket.js +29 -0
  58. package/dist/instructions/openMarket.js.map +1 -0
  59. package/dist/instructions/revealShares.d.ts +43 -0
  60. package/dist/instructions/revealShares.d.ts.map +1 -0
  61. package/dist/instructions/revealShares.js +47 -0
  62. package/dist/instructions/revealShares.js.map +1 -0
  63. package/dist/instructions/selectOption.d.ts +36 -0
  64. package/dist/instructions/selectOption.d.ts.map +1 -0
  65. package/dist/instructions/selectOption.js +28 -0
  66. package/dist/instructions/selectOption.js.map +1 -0
  67. package/dist/types/accounts.d.ts +104 -0
  68. package/dist/types/accounts.d.ts.map +1 -0
  69. package/dist/types/accounts.js +2 -0
  70. package/dist/types/accounts.js.map +1 -0
  71. package/dist/types/common.d.ts +21 -0
  72. package/dist/types/common.d.ts.map +1 -0
  73. package/dist/types/common.js +2 -0
  74. package/dist/types/common.js.map +1 -0
  75. package/dist/types/index.d.ts +3 -0
  76. package/dist/types/index.d.ts.map +1 -0
  77. package/dist/types/index.js +3 -0
  78. package/dist/types/index.js.map +1 -0
  79. package/dist/utils/arcium.d.ts +3 -0
  80. package/dist/utils/arcium.d.ts.map +1 -0
  81. package/dist/utils/arcium.js +6 -0
  82. package/dist/utils/arcium.js.map +1 -0
  83. package/dist/utils/awaitComputationFinalization.d.ts +37 -0
  84. package/dist/utils/awaitComputationFinalization.d.ts.map +1 -0
  85. package/dist/utils/awaitComputationFinalization.js +32 -0
  86. package/dist/utils/awaitComputationFinalization.js.map +1 -0
  87. package/dist/utils/computations.d.ts +27 -0
  88. package/dist/utils/computations.d.ts.map +1 -0
  89. package/dist/utils/computations.js +35 -0
  90. package/dist/utils/computations.js.map +1 -0
  91. package/dist/utils/encryption.d.ts +46 -0
  92. package/dist/utils/encryption.d.ts.map +1 -0
  93. package/dist/utils/encryption.js +53 -0
  94. package/dist/utils/encryption.js.map +1 -0
  95. package/dist/utils/index.d.ts +7 -0
  96. package/dist/utils/index.d.ts.map +1 -0
  97. package/dist/utils/index.js +7 -0
  98. package/dist/utils/index.js.map +1 -0
  99. package/dist/utils/keypairs.d.ts +20 -0
  100. package/dist/utils/keypairs.d.ts.map +1 -0
  101. package/dist/utils/keypairs.js +29 -0
  102. package/dist/utils/keypairs.js.map +1 -0
  103. package/dist/utils/pdas.d.ts +38 -0
  104. package/dist/utils/pdas.d.ts.map +1 -0
  105. package/dist/utils/pdas.js +57 -0
  106. package/dist/utils/pdas.js.map +1 -0
  107. package/package.json +45 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/instructions/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAE/B,kCAAkC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAElC,6BAA6B;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { type AnchorProvider } from "@coral-xyz/anchor";
2
+ import { type Keypair, type PublicKey } from "@solana/web3.js";
3
+ /**
4
+ * Parameters for initializing a share account
5
+ */
6
+ export interface InitShareAccountParams {
7
+ /** User creating the share account */
8
+ signer: Keypair;
9
+ /** Market PDA to create share account for */
10
+ market: PublicKey;
11
+ /** Optional program ID (defaults to PROGRAM_ID) */
12
+ programId?: PublicKey;
13
+ }
14
+ /**
15
+ * Result from initializing a share account
16
+ */
17
+ export interface InitShareAccountResult {
18
+ /** Transaction signature */
19
+ signature: string;
20
+ /** PDA of the created share account */
21
+ shareAccountPda: PublicKey;
22
+ }
23
+ /**
24
+ * Initializes a share account for a user in a specific market
25
+ *
26
+ * This must be called before buying shares. The share account will
27
+ * store the user's encrypted position (shares + selected option).
28
+ *
29
+ * @param provider - Anchor provider for connection and wallet
30
+ * @param params - Init share account parameters
31
+ * @returns Transaction signature and share account PDA
32
+ */
33
+ export declare function initShareAccount(provider: AnchorProvider, params: InitShareAccountParams): Promise<InitShareAccountResult>;
34
+ //# sourceMappingURL=initShareAccount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initShareAccount.d.ts","sourceRoot":"","sources":["../../src/instructions/initShareAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAiB,KAAK,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAM9E;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,sCAAsC;IACtC,MAAM,EAAE,OAAO,CAAC;IAChB,6CAA6C;IAC7C,MAAM,EAAE,SAAS,CAAC;IAClB,mDAAmD;IACnD,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,4BAA4B;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,eAAe,EAAE,SAAS,CAAC;CAC5B;AAED;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,sBAAsB,CAAC,CA2BjC"}
@@ -0,0 +1,33 @@
1
+ import { Program } from "@coral-xyz/anchor";
2
+ import { SystemProgram } from "@solana/web3.js";
3
+ import { PROGRAM_ID } from "../constants";
4
+ import { deriveShareAccountPda, generateNonce, nonceToU128 } from "../utils";
5
+ import IDL from "../idl/conviction_market.json";
6
+ /**
7
+ * Initializes a share account for a user in a specific market
8
+ *
9
+ * This must be called before buying shares. The share account will
10
+ * store the user's encrypted position (shares + selected option).
11
+ *
12
+ * @param provider - Anchor provider for connection and wallet
13
+ * @param params - Init share account parameters
14
+ * @returns Transaction signature and share account PDA
15
+ */
16
+ export async function initShareAccount(provider, params) {
17
+ const programId = params.programId ?? PROGRAM_ID;
18
+ const program = new Program(IDL, provider);
19
+ const [shareAccountPda] = deriveShareAccountPda(params.signer.publicKey, params.market, programId);
20
+ // Generate random nonce for encrypted state
21
+ const nonce = generateNonce();
22
+ const nonceBN = nonceToU128(nonce);
23
+ const signature = await program.methods
24
+ .initShareAccount(nonceBN)
25
+ .accountsPartial({
26
+ market: params.market,
27
+ systemProgram: SystemProgram.programId,
28
+ })
29
+ .signers([params.signer])
30
+ .rpc();
31
+ return { signature, shareAccountPda };
32
+ }
33
+ //# sourceMappingURL=initShareAccount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initShareAccount.js","sourceRoot":"","sources":["../../src/instructions/initShareAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAuB,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,aAAa,EAAgC,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC7E,OAAO,GAAG,MAAM,+BAA+B,CAAC;AAyBhD;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,QAAwB,EACxB,MAA8B;IAE9B,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,UAAU,CAAC;IACjD,MAAM,OAAO,GAAG,IAAI,OAAO,CACzB,GAAuB,EACvB,QAAQ,CACoB,CAAC;IAE/B,MAAM,CAAC,eAAe,CAAC,GAAG,qBAAqB,CAC7C,MAAM,CAAC,MAAM,CAAC,SAAS,EACvB,MAAM,CAAC,MAAM,EACb,SAAS,CACV,CAAC;IAEF,4CAA4C;IAC5C,MAAM,KAAK,GAAG,aAAa,EAAE,CAAC;IAC9B,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;IAEnC,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,OAAO;SACpC,gBAAgB,CAAC,OAAO,CAAC;SACzB,eAAe,CAAC;QACf,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,aAAa,EAAE,aAAa,CAAC,SAAS;KACvC,CAAC;SACD,OAAO,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;SACxB,GAAG,EAAE,CAAC;IAET,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;AACxC,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { BN, type AnchorProvider } from "@coral-xyz/anchor";
2
+ import { type Keypair, type PublicKey } from "@solana/web3.js";
3
+ import type { X25519Keypair } from "../types";
4
+ /**
5
+ * Parameters for initializing a vote token account
6
+ */
7
+ export interface InitVoteTokenAccountParams {
8
+ /** User creating the vote token account */
9
+ signer: Keypair;
10
+ /** User's X25519 keypair for encryption */
11
+ userX25519Keypair: X25519Keypair;
12
+ /** Optional program ID (defaults to PROGRAM_ID) */
13
+ programId?: PublicKey;
14
+ }
15
+ /**
16
+ * Result from initializing a vote token account
17
+ */
18
+ export interface InitVoteTokenAccountResult {
19
+ /** Transaction signature */
20
+ signature: string;
21
+ /** PDA of the created vote token account */
22
+ voteTokenAccountPda: PublicKey;
23
+ /** Computation offset (pass to awaitComputationFinalization) */
24
+ computationOffset: BN;
25
+ }
26
+ /**
27
+ * Initializes a vote token account via encrypted computation
28
+ *
29
+ * Sets up the encrypted balance state for a user. Must be called before
30
+ * minting vote tokens.
31
+ *
32
+ * @param provider - Anchor provider for connection and wallet
33
+ * @param params - Init vote token account parameters
34
+ * @returns Transaction signature, vote token account PDA, and await helper
35
+ */
36
+ export declare function initVoteTokenAccount(provider: AnchorProvider, params: InitVoteTokenAccountParams): Promise<InitVoteTokenAccountResult>;
37
+ //# sourceMappingURL=initVoteTokenAccount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initVoteTokenAccount.d.ts","sourceRoot":"","sources":["../../src/instructions/initVoteTokenAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,EAAE,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAiB,KAAK,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAkB9E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAI9C;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,2CAA2C;IAC3C,MAAM,EAAE,OAAO,CAAC;IAChB,2CAA2C;IAC3C,iBAAiB,EAAE,aAAa,CAAC;IACjC,mDAAmD;IACnD,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,4BAA4B;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,mBAAmB,EAAE,SAAS,CAAC;IAC/B,gEAAgE;IAChE,iBAAiB,EAAE,EAAE,CAAC;CACvB;AAED;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,0BAA0B,GACjC,OAAO,CAAC,0BAA0B,CAAC,CAqDrC"}
@@ -0,0 +1,48 @@
1
+ import { Program } from "@coral-xyz/anchor";
2
+ import { SystemProgram } from "@solana/web3.js";
3
+ import { getCompDefAccOffset, getMXEAccAddress, getMempoolAccAddress, getExecutingPoolAccAddress, getComputationAccAddress, getCompDefAccAddress, } from "@arcium-hq/client";
4
+ import { PROGRAM_ID, COMP_DEF_OFFSETS } from "../constants";
5
+ import { deriveVoteTokenAccountPda, generateComputationOffset, generateNonce, nonceToU128, ARCIUM_CLUSTER_OFFSET, getClusterAddress, } from "../utils";
6
+ import IDL from "../idl/conviction_market.json";
7
+ /**
8
+ * Initializes a vote token account via encrypted computation
9
+ *
10
+ * Sets up the encrypted balance state for a user. Must be called before
11
+ * minting vote tokens.
12
+ *
13
+ * @param provider - Anchor provider for connection and wallet
14
+ * @param params - Init vote token account parameters
15
+ * @returns Transaction signature, vote token account PDA, and await helper
16
+ */
17
+ export async function initVoteTokenAccount(provider, params) {
18
+ const programId = params.programId ?? PROGRAM_ID;
19
+ const program = new Program(IDL, provider);
20
+ const clusterAccount = getClusterAddress();
21
+ // Derive vote token account PDA
22
+ const [voteTokenAccountPda] = deriveVoteTokenAccountPda(params.signer.publicKey, programId);
23
+ // Auto-generate computation offset and nonce
24
+ const computationOffset = generateComputationOffset();
25
+ const nonce = generateNonce();
26
+ const nonceBN = nonceToU128(nonce);
27
+ const signature = await program.methods
28
+ .initVoteTokenAccount(computationOffset, Array.from(params.userX25519Keypair.publicKey), nonceBN)
29
+ .accountsPartial({
30
+ signer: params.signer.publicKey,
31
+ voteTokenAccount: voteTokenAccountPda,
32
+ computationAccount: getComputationAccAddress(ARCIUM_CLUSTER_OFFSET, computationOffset),
33
+ clusterAccount,
34
+ mxeAccount: getMXEAccAddress(programId),
35
+ mempoolAccount: getMempoolAccAddress(ARCIUM_CLUSTER_OFFSET),
36
+ executingPool: getExecutingPoolAccAddress(ARCIUM_CLUSTER_OFFSET),
37
+ compDefAccount: getCompDefAccAddress(programId, Buffer.from(getCompDefAccOffset(COMP_DEF_OFFSETS.INIT_VOTE_TOKEN_ACCOUNT)).readUInt32LE()),
38
+ systemProgram: SystemProgram.programId,
39
+ })
40
+ .signers([params.signer])
41
+ .rpc({ skipPreflight: false });
42
+ return {
43
+ signature,
44
+ voteTokenAccountPda,
45
+ computationOffset,
46
+ };
47
+ }
48
+ //# sourceMappingURL=initVoteTokenAccount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initVoteTokenAccount.js","sourceRoot":"","sources":["../../src/instructions/initVoteTokenAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA2B,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,aAAa,EAAgC,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,0BAA0B,EAC1B,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,aAAa,EACb,WAAW,EACX,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAElB,OAAO,GAAG,MAAM,+BAA+B,CAAC;AA2BhD;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,QAAwB,EACxB,MAAkC;IAElC,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,UAAU,CAAC;IACjD,MAAM,OAAO,GAAG,IAAI,OAAO,CACzB,GAAuB,EACvB,QAAQ,CACoB,CAA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z/anchor";
2
+ import { type Keypair, type PublicKey } from "@solana/web3.js";
3
+ import type { X25519Keypair } from "../types";
4
+ /**
5
+ * Parameters for minting vote tokens
6
+ */
7
+ export interface MintVoteTokensParams {
8
+ /** User minting tokens (pays SOL) */
9
+ signer: Keypair;
10
+ /** User's X25519 keypair for encryption */
11
+ userX25519Keypair: X25519Keypair;
12
+ /** Number of vote tokens to mint */
13
+ amount: number | BN;
14
+ /** Optional program ID (defaults to PROGRAM_ID) */
15
+ programId?: PublicKey;
16
+ }
17
+ /**
18
+ * Result from minting vote tokens
19
+ */
20
+ export interface MintVoteTokensResult {
21
+ /** Transaction signature */
22
+ signature: string;
23
+ /** PDA of the vote token account */
24
+ voteTokenAccountPda: PublicKey;
25
+ /** Computation offset (pass to awaitComputationFinalization) */
26
+ computationOffset: BN;
27
+ }
28
+ /**
29
+ * Mints vote tokens by paying SOL
30
+ *
31
+ * Users buy vote tokens which can be used to purchase market shares.
32
+ * Each token costs PRICE_PER_VOTE_TOKEN_LAMPORTS (0.001 SOL).
33
+ * Uses MPC to update the encrypted balance.
34
+ *
35
+ * @param provider - Anchor provider for connection and wallet
36
+ * @param params - Mint vote tokens parameters
37
+ * @returns Transaction signature, vote token account PDA, and await helper
38
+ */
39
+ export declare function mintVoteTokens(provider: AnchorProvider, params: MintVoteTokensParams): Promise<MintVoteTokensResult>;
40
+ //# sourceMappingURL=mintVoteTokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mintVoteTokens.d.ts","sourceRoot":"","sources":["../../src/instructions/mintVoteTokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,EAAE,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAiB,KAAK,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAgB9E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAI9C;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,qCAAqC;IACrC,MAAM,EAAE,OAAO,CAAC;IAChB,2CAA2C;IAC3C,iBAAiB,EAAE,aAAa,CAAC;IACjC,oCAAoC;IACpC,MAAM,EAAE,MAAM,GAAG,EAAE,CAAC;IACpB,mDAAmD;IACnD,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,4BAA4B;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,oCAAoC;IACpC,mBAAmB,EAAE,SAAS,CAAC;IAC/B,gEAAgE;IAChE,iBAAiB,EAAE,EAAE,CAAC;CACvB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,cAAc,CAClC,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,oBAAoB,CAAC,CAuD/B"}
@@ -0,0 +1,49 @@
1
+ import { Program, BN } from "@coral-xyz/anchor";
2
+ import { SystemProgram } from "@solana/web3.js";
3
+ import { getCompDefAccOffset, getMXEAccAddress, getMempoolAccAddress, getExecutingPoolAccAddress, getComputationAccAddress, getCompDefAccAddress, } from "@arcium-hq/client";
4
+ import { PROGRAM_ID, COMP_DEF_OFFSETS } from "../constants";
5
+ import { deriveVoteTokenAccountPda, generateComputationOffset, ARCIUM_CLUSTER_OFFSET, getClusterAddress, } from "../utils";
6
+ import IDL from "../idl/conviction_market.json";
7
+ /**
8
+ * Mints vote tokens by paying SOL
9
+ *
10
+ * Users buy vote tokens which can be used to purchase market shares.
11
+ * Each token costs PRICE_PER_VOTE_TOKEN_LAMPORTS (0.001 SOL).
12
+ * Uses MPC to update the encrypted balance.
13
+ *
14
+ * @param provider - Anchor provider for connection and wallet
15
+ * @param params - Mint vote tokens parameters
16
+ * @returns Transaction signature, vote token account PDA, and await helper
17
+ */
18
+ export async function mintVoteTokens(provider, params) {
19
+ const programId = params.programId ?? PROGRAM_ID;
20
+ const program = new Program(IDL, provider);
21
+ const clusterAccount = getClusterAddress();
22
+ // Derive vote token account PDA
23
+ const [voteTokenAccountPda] = deriveVoteTokenAccountPda(params.signer.publicKey, programId);
24
+ // Auto-generate computation offset
25
+ const computationOffset = generateComputationOffset();
26
+ // Convert amount to BN
27
+ const amountBN = typeof params.amount === "number" ? new BN(params.amount) : params.amount;
28
+ const signature = await program.methods
29
+ .mintVoteTokens(computationOffset, Array.from(params.userX25519Keypair.publicKey), amountBN)
30
+ .accountsPartial({
31
+ signer: params.signer.publicKey,
32
+ voteTokenAccount: voteTokenAccountPda,
33
+ computationAccount: getComputationAccAddress(ARCIUM_CLUSTER_OFFSET, computationOffset),
34
+ clusterAccount,
35
+ mxeAccount: getMXEAccAddress(programId),
36
+ mempoolAccount: getMempoolAccAddress(ARCIUM_CLUSTER_OFFSET),
37
+ executingPool: getExecutingPoolAccAddress(ARCIUM_CLUSTER_OFFSET),
38
+ compDefAccount: getCompDefAccAddress(programId, Buffer.from(getCompDefAccOffset(COMP_DEF_OFFSETS.BUY_VOTE_TOKENS)).readUInt32LE()),
39
+ systemProgram: SystemProgram.programId,
40
+ })
41
+ .signers([params.signer])
42
+ .rpc({ skipPreflight: true });
43
+ return {
44
+ signature,
45
+ voteTokenAccountPda,
46
+ computationOffset,
47
+ };
48
+ }
49
+ //# sourceMappingURL=mintVoteTokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mintVoteTokens.js","sourceRoot":"","sources":["../../src/instructions/mintVoteTokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,EAAE,EAAuB,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,aAAa,EAAgC,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,0BAA0B,EAC1B,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EACL,yBAAyB,EACzB,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C,SAAS,EACT,MAAM,CAAC,IAAI,CACT,mBAAmB,CAAC,gBAAgB,CAAC,eAAe,CAAC,CACtD,CAAC,YAAY,EAAE,CACjB;QACD,aAAa,EAAE,aAAa,CAAC,SAAS;KACvC,CAAC;SACD,OAAO,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;SACxB,GAAG,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAEhC,OAAO;QACL,SAAS;QACT,mBAAmB;QACnB,iBAAiB;KAClB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { BN, type AnchorProvider } from "@coral-xyz/anchor";
2
+ import type { Keypair, PublicKey } from "@solana/web3.js";
3
+ /**
4
+ * Parameters for opening a market
5
+ */
6
+ export interface OpenMarketParams {
7
+ /** Market creator (must be the original creator) */
8
+ creator: Keypair;
9
+ /** Market PDA to open */
10
+ market: PublicKey;
11
+ /** Unix timestamp when market opens for trading */
12
+ openTimestamp: number | BN;
13
+ /** Optional program ID (defaults to PROGRAM_ID) */
14
+ programId?: PublicKey;
15
+ }
16
+ /**
17
+ * Result from opening a market
18
+ */
19
+ export interface OpenMarketResult {
20
+ /** Transaction signature */
21
+ signature: string;
22
+ }
23
+ /**
24
+ * Opens a market for trading
25
+ *
26
+ * After creating a market and adding options, the creator must open it
27
+ * with a specific timestamp. The market must be funded before opening.
28
+ *
29
+ * @param provider - Anchor provider for connection and wallet
30
+ * @param params - Open market parameters
31
+ * @returns Transaction signature
32
+ */
33
+ export declare function openMarket(provider: AnchorProvider, params: OpenMarketParams): Promise<OpenMarketResult>;
34
+ //# sourceMappingURL=openMarket.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openMarket.d.ts","sourceRoot":"","sources":["../../src/instructions/openMarket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,EAAE,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAK1D;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,oDAAoD;IACpD,OAAO,EAAE,OAAO,CAAC;IACjB,yBAAyB;IACzB,MAAM,EAAE,SAAS,CAAC;IAClB,mDAAmD;IACnD,aAAa,EAAE,MAAM,GAAG,EAAE,CAAC;IAC3B,mDAAmD;IACnD,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,4BAA4B;IAC5B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;GASG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,gBAAgB,CAAC,CAqB3B"}
@@ -0,0 +1,29 @@
1
+ import { Program, BN } from "@coral-xyz/anchor";
2
+ import { PROGRAM_ID } from "../constants";
3
+ import IDL from "../idl/conviction_market.json";
4
+ /**
5
+ * Opens a market for trading
6
+ *
7
+ * After creating a market and adding options, the creator must open it
8
+ * with a specific timestamp. The market must be funded before opening.
9
+ *
10
+ * @param provider - Anchor provider for connection and wallet
11
+ * @param params - Open market parameters
12
+ * @returns Transaction signature
13
+ */
14
+ export async function openMarket(provider, params) {
15
+ const programId = params.programId ?? PROGRAM_ID;
16
+ const program = new Program(IDL, provider);
17
+ const openTimestampBN = typeof params.openTimestamp === "number"
18
+ ? new BN(params.openTimestamp)
19
+ : params.openTimestamp;
20
+ const signature = await program.methods
21
+ .openMarket(openTimestampBN)
22
+ .accountsPartial({
23
+ market: params.market,
24
+ })
25
+ .signers([params.creator])
26
+ .rpc();
27
+ return { signature };
28
+ }
29
+ //# sourceMappingURL=openMarket.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openMarket.js","sourceRoot":"","sources":["../../src/instructions/openMarket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,EAAE,EAAuB,MAAM,mBAAmB,CAAC;AAErE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,GAAG,MAAM,+BAA+B,CAAC;AAyBhD;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,QAAwB,EACxB,MAAwB;IAExB,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,UAAU,CAAC;IACjD,MAAM,OAAO,GAAG,IAAI,OAAO,CACzB,GAAuB,EACvB,QAAQ,CACoB,CAAC;IAE/B,MAAM,eAAe,GACnB,OAAO,MAAM,CAAC,aAAa,KAAK,QAAQ;QACtC,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC;QAC9B,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC;IAE3B,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,OAAO;SACpC,UAAU,CAAC,eAAe,CAAC;SAC3B,eAAe,CAAC;QACf,MAAM,EAAE,MAAM,CAAC,MAAM;KACtB,CAAC;SACD,OAAO,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;SACzB,GAAG,EAAE,CAAC;IAET,OAAO,EAAE,SAAS,EAAE,CAAC;AACvB,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { BN, type AnchorProvider } from "@coral-xyz/anchor";
2
+ import type { Keypair, PublicKey } from "@solana/web3.js";
3
+ import type { X25519Keypair } from "../types";
4
+ /**
5
+ * Parameters for revealing shares
6
+ */
7
+ export interface RevealSharesParams {
8
+ /** User calling the reveal (can be anyone) */
9
+ signer: Keypair;
10
+ /** Owner of the share account to reveal */
11
+ owner: PublicKey;
12
+ /** Market PDA */
13
+ market: PublicKey;
14
+ /** Owner's X25519 keypair for encryption */
15
+ ownerX25519Keypair: X25519Keypair;
16
+ /** Optional program ID (defaults to PROGRAM_ID) */
17
+ programId?: PublicKey;
18
+ }
19
+ /**
20
+ * Result from revealing shares
21
+ */
22
+ export interface RevealSharesResult {
23
+ /** Transaction signature */
24
+ signature: string;
25
+ /** PDA of the share account */
26
+ shareAccountPda: PublicKey;
27
+ /** Computation offset (pass to awaitComputationFinalization) */
28
+ computationOffset: BN;
29
+ }
30
+ /**
31
+ * Reveals a user's encrypted shares after staking ends
32
+ *
33
+ * Permissionless - anyone can reveal anyone's shares after the staking
34
+ * period ends and the winning option is selected.
35
+ * Updates share account with revealed amount/option and credits vote
36
+ * token balance back to the user.
37
+ *
38
+ * @param provider - Anchor provider for connection and wallet
39
+ * @param params - Reveal shares parameters
40
+ * @returns Transaction signature, share account PDA, and await helper
41
+ */
42
+ export declare function revealShares(provider: AnchorProvider, params: RevealSharesParams): Promise<RevealSharesResult>;
43
+ //# sourceMappingURL=revealShares.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"revealShares.d.ts","sourceRoot":"","sources":["../../src/instructions/revealShares.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,EAAE,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAiB1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAI9C;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,8CAA8C;IAC9C,MAAM,EAAE,OAAO,CAAC;IAChB,2CAA2C;IAC3C,KAAK,EAAE,SAAS,CAAC;IACjB,iBAAiB;IACjB,MAAM,EAAE,SAAS,CAAC;IAClB,4CAA4C;IAC5C,kBAAkB,EAAE,aAAa,CAAC;IAClC,mDAAmD;IACnD,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,4BAA4B;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,+BAA+B;IAC/B,eAAe,EAAE,SAAS,CAAC;IAC3B,gEAAgE;IAChE,iBAAiB,EAAE,EAAE,CAAC;CACvB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,YAAY,CAChC,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,kBAAkB,CAAC,CAsD7B"}
@@ -0,0 +1,47 @@
1
+ import { Program } from "@coral-xyz/anchor";
2
+ import { getCompDefAccOffset, getMXEAccAddress, getMempoolAccAddress, getExecutingPoolAccAddress, getComputationAccAddress, getCompDefAccAddress, } from "@arcium-hq/client";
3
+ import { PROGRAM_ID, COMP_DEF_OFFSETS } from "../constants";
4
+ import { deriveVoteTokenAccountPda, deriveShareAccountPda, generateComputationOffset, ARCIUM_CLUSTER_OFFSET, getClusterAddress, } from "../utils";
5
+ import IDL from "../idl/conviction_market.json";
6
+ /**
7
+ * Reveals a user's encrypted shares after staking ends
8
+ *
9
+ * Permissionless - anyone can reveal anyone's shares after the staking
10
+ * period ends and the winning option is selected.
11
+ * Updates share account with revealed amount/option and credits vote
12
+ * token balance back to the user.
13
+ *
14
+ * @param provider - Anchor provider for connection and wallet
15
+ * @param params - Reveal shares parameters
16
+ * @returns Transaction signature, share account PDA, and await helper
17
+ */
18
+ export async function revealShares(provider, params) {
19
+ const programId = params.programId ?? PROGRAM_ID;
20
+ const program = new Program(IDL, provider);
21
+ const clusterAccount = getClusterAddress();
22
+ // Derive accounts
23
+ const [voteTokenAccountPda] = deriveVoteTokenAccountPda(params.owner, programId);
24
+ const [shareAccountPda] = deriveShareAccountPda(params.owner, params.market, programId);
25
+ // Auto-generate computation offset
26
+ const computationOffset = generateComputationOffset();
27
+ const signature = await program.methods
28
+ .revealShares(computationOffset, Array.from(params.ownerX25519Keypair.publicKey))
29
+ .accountsPartial({
30
+ owner: params.owner,
31
+ market: params.market,
32
+ computationAccount: getComputationAccAddress(ARCIUM_CLUSTER_OFFSET, computationOffset),
33
+ clusterAccount,
34
+ mxeAccount: getMXEAccAddress(programId),
35
+ mempoolAccount: getMempoolAccAddress(ARCIUM_CLUSTER_OFFSET),
36
+ executingPool: getExecutingPoolAccAddress(ARCIUM_CLUSTER_OFFSET),
37
+ compDefAccount: getCompDefAccAddress(programId, Buffer.from(getCompDefAccOffset(COMP_DEF_OFFSETS.REVEAL_SHARES)).readUInt32LE()),
38
+ })
39
+ .signers([params.signer])
40
+ .rpc({ skipPreflight: true });
41
+ return {
42
+ signature,
43
+ shareAccountPda,
44
+ computationOffset,
45
+ };
46
+ }
47
+ //# sourceMappingURL=revealShares.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"revealShares.js","sourceRoot":"","sources":["../../src/instructions/revealShares.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA2B,MAAM,mBAAmB,CAAC;AAErE,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,0BAA0B,EAC1B,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,yBAAyB,EACzB,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAElB,OAAO,GAAG,MAAM,+BAA+B,CAAC;AA+BhD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,QAAwB,EACxB,MAA0B;IAE1B,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,UAAU,CAAC;IACjD,MAAM,OAAO,GAAG,IAAI,OAAO,CACzB,GAAuB,EACvB,QAAQ,CACoB,CAAC;IAE/B,MAAM,cAAc,GAAG,iBAAiB,EAAE,CAAC;IAE3C,kBAAkB;IAClB,MAAM,CAAC,mBAAmB,CAAC,GAAG,yBAAyB,CACrD,MAAM,CAAC,KAAK,EACZ,SAAS,CACV,CAAC;IACF,MAAM,CAAC,eAAe,CAAC,GAAG,qBAAqB,CAC7C,MAAM,CAAC,KAAK,EACZ,MAAM,CAAC,MAAM,EACb,SAAS,CACV,CAAC;IAEF,mCAAmC;IACnC,MAAM,iBAAiB,GAAG,yBAAyB,EAAE,CAAC;IAEtD,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,OAAO;SACpC,YAAY,CACX,iBAAiB,EACjB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAChD;SACA,eAAe,CAAC;QACf,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,kBAAkB,EAAE,wBAAwB,CAC1C,qBAAqB,EACrB,iBAAiB,CAClB;QACD,cAAc;QACd,UAAU,EAAE,gBAAgB,CAAC,SAAS,CAAC;QACvC,cAAc,EAAE,oBAAoB,CAAC,qBAAqB,CAAC;QAC3D,aAAa,EAAE,0BAA0B,CAAC,qBAAqB,CAAC;QAChE,cAAc,EAAE,oBAAoB,CAClC,SAAS,EACT,MAAM,CAAC,IAAI,CACT,mBAAmB,CAAC,gBAAgB,CAAC,aAAa,CAAC,CACpD,CAAC,YAAY,EAAE,CACjB;KACF,CAAC;SACD,OAAO,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;SACxB,GAAG,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAEhC,OAAO;QACL,SAAS;QACT,eAAe;QACf,iBAAiB;KAClB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { type AnchorProvider } from "@coral-xyz/anchor";
2
+ import type { Keypair, PublicKey } from "@solana/web3.js";
3
+ /**
4
+ * Parameters for selecting the winning option
5
+ */
6
+ export interface SelectOptionParams {
7
+ /** Authority (creator or select_authority) */
8
+ authority: Keypair;
9
+ /** Market PDA */
10
+ market: PublicKey;
11
+ /** Winning option index */
12
+ optionIndex: number;
13
+ /** Optional program ID (defaults to PROGRAM_ID) */
14
+ programId?: PublicKey;
15
+ }
16
+ /**
17
+ * Result from selecting an option
18
+ */
19
+ export interface SelectOptionResult {
20
+ /** Transaction signature */
21
+ signature: string;
22
+ /** PDA of the selected option */
23
+ optionPda: PublicKey;
24
+ }
25
+ /**
26
+ * Selects the winning option for a market
27
+ *
28
+ * Can be called by the market creator or designated select_authority.
29
+ * Automatically closes the staking period if still open.
30
+ *
31
+ * @param provider - Anchor provider for connection and wallet
32
+ * @param params - Select option parameters
33
+ * @returns Transaction signature and option PDA
34
+ */
35
+ export declare function selectOption(provider: AnchorProvider, params: SelectOptionParams): Promise<SelectOptionResult>;
36
+ //# sourceMappingURL=selectOption.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectOption.d.ts","sourceRoot":"","sources":["../../src/instructions/selectOption.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAM1D;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,8CAA8C;IAC9C,SAAS,EAAE,OAAO,CAAC;IACnB,iBAAiB;IACjB,MAAM,EAAE,SAAS,CAAC;IAClB,2BAA2B;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,4BAA4B;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,SAAS,EAAE,SAAS,CAAC;CACtB;AAED;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAChC,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,kBAAkB,CAAC,CAsB7B"}
@@ -0,0 +1,28 @@
1
+ import { Program } from "@coral-xyz/anchor";
2
+ import { PROGRAM_ID } from "../constants";
3
+ import { deriveOptionPda } from "../utils";
4
+ import IDL from "../idl/conviction_market.json";
5
+ /**
6
+ * Selects the winning option for a market
7
+ *
8
+ * Can be called by the market creator or designated select_authority.
9
+ * Automatically closes the staking period if still open.
10
+ *
11
+ * @param provider - Anchor provider for connection and wallet
12
+ * @param params - Select option parameters
13
+ * @returns Transaction signature and option PDA
14
+ */
15
+ export async function selectOption(provider, params) {
16
+ const programId = params.programId ?? PROGRAM_ID;
17
+ const program = new Program(IDL, provider);
18
+ const signature = await program.methods
19
+ .selectOption(params.optionIndex)
20
+ .accountsPartial({
21
+ market: params.market,
22
+ })
23
+ .signers([params.authority])
24
+ .rpc();
25
+ const [optionPda] = deriveOptionPda(params.market, params.optionIndex, programId);
26
+ return { signature, optionPda };
27
+ }
28
+ //# sourceMappingURL=selectOption.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectOption.js","sourceRoot":"","sources":["../../src/instructions/selectOption.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAuB,MAAM,mBAAmB,CAAC;AAEjE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,GAAG,MAAM,+BAA+B,CAAC;AA2BhD;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,QAAwB,EACxB,MAA0B;IAE1B,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,UAAU,CAAC;IACjD,MAAM,OAAO,GAAG,IAAI,OAAO,CACzB,GAAuB,EACvB,QAAQ,CACoB,CAAC;IAE/B,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,OAAO;SACpC,YAAY,CAAC,MAAM,CAAC,WAAW,CAAC;SAChC,eAAe,CAAC;QACf,MAAM,EAAE,MAAM,CAAC,MAAM;KACtB,CAAC;SACD,OAAO,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;SAC3B,GAAG,EAAE,CAAC;IAET,MAAM,CAAC,SAAS,CAAC,GAAG,eAAe,CACjC,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,WAAW,EAClB,SAAS,CACV,CAAC;IAEF,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AAClC,CAAC"}
@@ -0,0 +1,104 @@
1
+ import type { PublicKey } from "@solana/web3.js";
2
+ import type { BN } from "@coral-xyz/anchor";
3
+ /**
4
+ * Conviction Market account structure
5
+ *
6
+ * Represents a prediction/voting market where users can stake capital
7
+ * on their preferred option with encrypted votes.
8
+ */
9
+ export interface ConvictionMarketAccount {
10
+ /** Encrypted available shares state */
11
+ encryptedAvailableShares: Uint8Array[][];
12
+ /** PDA bump seed */
13
+ bump: number;
14
+ /** Market creator's public key */
15
+ creator: PublicKey;
16
+ /** Unique market index */
17
+ index: BN;
18
+ /** Current number of options added */
19
+ totalOptions: number;
20
+ /** Maximum number of options allowed */
21
+ maxOptions: number;
22
+ /** Timestamp when market opens for trading */
23
+ openTimestamp?: BN;
24
+ /** Duration of staking period in seconds */
25
+ timeToStake: BN;
26
+ /** Duration of reveal period in seconds */
27
+ timeToReveal: BN;
28
+ /** Selected winning option (if set) */
29
+ selectedOption?: number;
30
+ /** Nonce for encrypted state */
31
+ stateNonce: BN;
32
+ /** Maximum shares available for purchase */
33
+ maxShares: BN;
34
+ /** Reward pool in lamports for winners */
35
+ rewardLamports: BN;
36
+ /** Optional authority that can select winning option */
37
+ selectAuthority?: PublicKey;
38
+ }
39
+ /**
40
+ * Vote Token Account structure
41
+ *
42
+ * Holds a user's encrypted vote token balance.
43
+ * Vote tokens are used to purchase market shares.
44
+ */
45
+ export interface VoteTokenAccountData {
46
+ /** Encrypted token balance state */
47
+ encryptedState: Uint8Array[][];
48
+ /** PDA bump seed */
49
+ bump: number;
50
+ /** Account owner's public key */
51
+ owner: PublicKey;
52
+ /** Nonce for encrypted state */
53
+ stateNonce: BN;
54
+ }
55
+ /**
56
+ * Share Account structure
57
+ *
58
+ * Represents a user's encrypted position in a specific market,
59
+ * including the amount of shares and selected option.
60
+ */
61
+ export interface ShareAccountData {
62
+ /** Encrypted state: [share_amount, selected_option] */
63
+ encryptedState: Uint8Array[][];
64
+ /** Nonce for encrypted state */
65
+ stateNonce: BN;
66
+ /** PDA bump seed */
67
+ bump: number;
68
+ /** Account owner's public key */
69
+ owner: PublicKey;
70
+ /** Market this share account is for */
71
+ market: PublicKey;
72
+ /** Encrypted state disclosure for analytics */
73
+ encryptedStateDisclosure: Uint8Array[][];
74
+ /** Nonce for disclosure state */
75
+ stateNonceDisclosure: BN;
76
+ /** Timestamp when shares were purchased */
77
+ boughtAtTimestamp: BN;
78
+ /** Revealed share amount (after reveal) */
79
+ revealedAmount?: BN;
80
+ /** Revealed option choice (after reveal) */
81
+ revealedOption?: number;
82
+ /** Conviction score (amount * time-in-market) */
83
+ revealedScore?: BN;
84
+ /** Whether tally has been incremented for this share */
85
+ totalIncremented: boolean;
86
+ }
87
+ /**
88
+ * Market Option structure
89
+ *
90
+ * Represents a named voting option in a market.
91
+ */
92
+ export interface ConvictionMarketOptionData {
93
+ /** PDA bump seed */
94
+ bump: number;
95
+ /** Market creator's public key */
96
+ creator: PublicKey;
97
+ /** Human-readable name of the option */
98
+ name: string;
99
+ /** Total shares bought for this option */
100
+ totalShares?: BN;
101
+ /** Total conviction score for this option */
102
+ totalScore?: BN;
103
+ }
104
+ //# sourceMappingURL=accounts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/types/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACtC,uCAAuC;IACvC,wBAAwB,EAAE,UAAU,EAAE,EAAE,CAAC;IACzC,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,OAAO,EAAE,SAAS,CAAC;IACnB,0BAA0B;IAC1B,KAAK,EAAE,EAAE,CAAC;IACV,sCAAsC;IACtC,YAAY,EAAE,MAAM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