@bench.games/conviction-markets 0.1.0 → 0.1.2
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/instructions/addMarketOption.d.ts +8 -8
- package/dist/instructions/addMarketOption.d.ts.map +1 -1
- package/dist/instructions/addMarketOption.js +6 -7
- package/dist/instructions/addMarketOption.js.map +1 -1
- package/dist/instructions/buyMarketShares.d.ts +8 -8
- package/dist/instructions/buyMarketShares.d.ts.map +1 -1
- package/dist/instructions/buyMarketShares.js +9 -11
- package/dist/instructions/buyMarketShares.js.map +1 -1
- package/dist/instructions/claimVoteTokens.d.ts +8 -8
- package/dist/instructions/claimVoteTokens.d.ts.map +1 -1
- package/dist/instructions/claimVoteTokens.js +8 -9
- package/dist/instructions/claimVoteTokens.js.map +1 -1
- package/dist/instructions/closeShareAccount.d.ts +8 -8
- package/dist/instructions/closeShareAccount.d.ts.map +1 -1
- package/dist/instructions/closeShareAccount.js +6 -7
- package/dist/instructions/closeShareAccount.js.map +1 -1
- package/dist/instructions/createMarket.d.ts +8 -8
- package/dist/instructions/createMarket.d.ts.map +1 -1
- package/dist/instructions/createMarket.js +8 -9
- package/dist/instructions/createMarket.js.map +1 -1
- package/dist/instructions/incrementOptionTally.d.ts +7 -7
- package/dist/instructions/incrementOptionTally.d.ts.map +1 -1
- package/dist/instructions/incrementOptionTally.js +6 -6
- package/dist/instructions/incrementOptionTally.js.map +1 -1
- package/dist/instructions/initShareAccount.d.ts +8 -8
- package/dist/instructions/initShareAccount.d.ts.map +1 -1
- package/dist/instructions/initShareAccount.js +7 -8
- package/dist/instructions/initShareAccount.js.map +1 -1
- package/dist/instructions/initVoteTokenAccount.d.ts +8 -8
- package/dist/instructions/initVoteTokenAccount.d.ts.map +1 -1
- package/dist/instructions/initVoteTokenAccount.js +8 -9
- package/dist/instructions/initVoteTokenAccount.js.map +1 -1
- package/dist/instructions/mintVoteTokens.d.ts +8 -8
- package/dist/instructions/mintVoteTokens.d.ts.map +1 -1
- package/dist/instructions/mintVoteTokens.js +8 -9
- package/dist/instructions/mintVoteTokens.js.map +1 -1
- package/dist/instructions/openMarket.d.ts +8 -8
- package/dist/instructions/openMarket.d.ts.map +1 -1
- package/dist/instructions/openMarket.js +6 -7
- package/dist/instructions/openMarket.js.map +1 -1
- package/dist/instructions/revealShares.d.ts +8 -8
- package/dist/instructions/revealShares.d.ts.map +1 -1
- package/dist/instructions/revealShares.js +6 -7
- package/dist/instructions/revealShares.js.map +1 -1
- package/dist/instructions/selectOption.d.ts +8 -8
- package/dist/instructions/selectOption.d.ts.map +1 -1
- package/dist/instructions/selectOption.js +6 -7
- package/dist/instructions/selectOption.js.map +1 -1
- package/dist/utils/keypairs.d.ts +6 -0
- package/dist/utils/keypairs.d.ts.map +1 -1
- package/dist/utils/keypairs.js +11 -0
- package/dist/utils/keypairs.js.map +1 -1
- package/package.json +21 -21
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type AnchorProvider } from "@coral-xyz/anchor";
|
|
2
|
-
import { type
|
|
2
|
+
import { type PublicKey, Transaction } from "@solana/web3.js";
|
|
3
3
|
/**
|
|
4
4
|
* Parameters for adding a market option
|
|
5
5
|
*/
|
|
6
6
|
export interface AddMarketOptionParams {
|
|
7
7
|
/** Market creator (must be the original creator) */
|
|
8
|
-
creator:
|
|
8
|
+
creator: PublicKey;
|
|
9
9
|
/** Market PDA to add option to */
|
|
10
10
|
market: PublicKey;
|
|
11
11
|
/** Option index (1-based, must be sequential) */
|
|
@@ -16,23 +16,23 @@ export interface AddMarketOptionParams {
|
|
|
16
16
|
programId?: PublicKey;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
* Result from
|
|
19
|
+
* Result from building add market option transaction
|
|
20
20
|
*/
|
|
21
21
|
export interface AddMarketOptionResult {
|
|
22
|
-
/** Transaction
|
|
23
|
-
|
|
22
|
+
/** Transaction to sign and send */
|
|
23
|
+
transaction: Transaction;
|
|
24
24
|
/** PDA of the created option account */
|
|
25
25
|
optionPda: PublicKey;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* Builds a transaction to add a named option to a market
|
|
29
29
|
*
|
|
30
30
|
* Options must be added before opening the market. Option indices
|
|
31
31
|
* must be sequential starting from 1.
|
|
32
32
|
*
|
|
33
|
-
* @param provider - Anchor provider for connection
|
|
33
|
+
* @param provider - Anchor provider for connection
|
|
34
34
|
* @param params - Add market option parameters
|
|
35
|
-
* @returns Transaction
|
|
35
|
+
* @returns Transaction to sign and send, and option PDA
|
|
36
36
|
*/
|
|
37
37
|
export declare function addMarketOption(provider: AnchorProvider, params: AddMarketOptionParams): Promise<AddMarketOptionResult>;
|
|
38
38
|
//# sourceMappingURL=addMarketOption.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addMarketOption.d.ts","sourceRoot":"","sources":["../../src/instructions/addMarketOption.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAiB,KAAK,
|
|
1
|
+
{"version":3,"file":"addMarketOption.d.ts","sourceRoot":"","sources":["../../src/instructions/addMarketOption.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAiB,KAAK,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAM7E;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,oDAAoD;IACpD,OAAO,EAAE,SAAS,CAAC;IACnB,kCAAkC;IAClC,MAAM,EAAE,SAAS,CAAC;IAClB,iDAAiD;IACjD,WAAW,EAAE,MAAM,CAAC;IACpB,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,mCAAmC;IACnC,WAAW,EAAE,WAAW,CAAC;IACzB,wCAAwC;IACxC,SAAS,EAAE,SAAS,CAAC;CACtB;AAED;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC,CAsBhC"}
|
|
@@ -4,27 +4,26 @@ import { PROGRAM_ID } from "../constants";
|
|
|
4
4
|
import { deriveOptionPda } from "../utils";
|
|
5
5
|
import IDL from "../idl/conviction_market.json";
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Builds a transaction to add a named option to a market
|
|
8
8
|
*
|
|
9
9
|
* Options must be added before opening the market. Option indices
|
|
10
10
|
* must be sequential starting from 1.
|
|
11
11
|
*
|
|
12
|
-
* @param provider - Anchor provider for connection
|
|
12
|
+
* @param provider - Anchor provider for connection
|
|
13
13
|
* @param params - Add market option parameters
|
|
14
|
-
* @returns Transaction
|
|
14
|
+
* @returns Transaction to sign and send, and option PDA
|
|
15
15
|
*/
|
|
16
16
|
export async function addMarketOption(provider, params) {
|
|
17
17
|
const programId = params.programId ?? PROGRAM_ID;
|
|
18
18
|
const program = new Program(IDL, provider);
|
|
19
19
|
const [optionPda] = deriveOptionPda(params.market, params.optionIndex, programId);
|
|
20
|
-
const
|
|
20
|
+
const transaction = await program.methods
|
|
21
21
|
.addMarketOption(params.optionIndex, params.name)
|
|
22
22
|
.accountsPartial({
|
|
23
23
|
market: params.market,
|
|
24
24
|
systemProgram: SystemProgram.programId,
|
|
25
25
|
})
|
|
26
|
-
.
|
|
27
|
-
|
|
28
|
-
return { signature, optionPda };
|
|
26
|
+
.transaction();
|
|
27
|
+
return { transaction, optionPda };
|
|
29
28
|
}
|
|
30
29
|
//# sourceMappingURL=addMarketOption.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addMarketOption.js","sourceRoot":"","sources":["../../src/instructions/addMarketOption.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAuB,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"addMarketOption.js","sourceRoot":"","sources":["../../src/instructions/addMarketOption.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAuB,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,aAAa,EAA+B,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,GAAG,MAAM,+BAA+B,CAAC;AA6BhD;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,QAAwB,EACxB,MAA6B;IAE7B,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,SAAS,CAAC,GAAG,eAAe,CACjC,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,WAAW,EAClB,SAAS,CACV,CAAC;IAEF,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,OAAO;SACtC,eAAe,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC;SAChD,eAAe,CAAC;QACf,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,aAAa,EAAE,aAAa,CAAC,SAAS;KACvC,CAAC;SACD,WAAW,EAAE,CAAC;IAEjB,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC;AACpC,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { BN, type AnchorProvider } from "@coral-xyz/anchor";
|
|
2
|
-
import type {
|
|
2
|
+
import type { PublicKey, Transaction } from "@solana/web3.js";
|
|
3
3
|
import type { X25519Keypair } from "../types";
|
|
4
4
|
/**
|
|
5
5
|
* Parameters for buying market shares
|
|
6
6
|
*/
|
|
7
7
|
export interface BuyMarketSharesParams {
|
|
8
8
|
/** User buying shares */
|
|
9
|
-
signer:
|
|
9
|
+
signer: PublicKey;
|
|
10
10
|
/** User's X25519 keypair for encryption */
|
|
11
11
|
userX25519Keypair: X25519Keypair;
|
|
12
12
|
/** Market PDA to buy shares in */
|
|
@@ -21,27 +21,27 @@ export interface BuyMarketSharesParams {
|
|
|
21
21
|
programId?: PublicKey;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
* Result from
|
|
24
|
+
* Result from building buy market shares transaction
|
|
25
25
|
*/
|
|
26
26
|
export interface BuyMarketSharesResult {
|
|
27
|
-
/** Transaction
|
|
28
|
-
|
|
27
|
+
/** Transaction to sign and send */
|
|
28
|
+
transaction: Transaction;
|
|
29
29
|
/** PDA of the share account */
|
|
30
30
|
shareAccountPda: PublicKey;
|
|
31
31
|
/** Computation offset (pass to awaitComputationFinalization) */
|
|
32
32
|
computationOffset: BN;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
35
|
+
* Builds a transaction to buy market shares with encrypted input
|
|
36
36
|
*
|
|
37
37
|
* User purchases shares for a market option using encrypted computation.
|
|
38
38
|
* The amount and selected option are encrypted automatically.
|
|
39
39
|
* Deducts from vote token balance and stores encrypted share state.
|
|
40
40
|
* Only works during the staking period.
|
|
41
41
|
*
|
|
42
|
-
* @param provider - Anchor provider for connection
|
|
42
|
+
* @param provider - Anchor provider for connection
|
|
43
43
|
* @param params - Buy market shares parameters
|
|
44
|
-
* @returns Transaction
|
|
44
|
+
* @returns Transaction to sign and send, share account PDA, and computation offset
|
|
45
45
|
*/
|
|
46
46
|
export declare function buyMarketShares(provider: AnchorProvider, params: BuyMarketSharesParams): Promise<BuyMarketSharesResult>;
|
|
47
47
|
//# sourceMappingURL=buyMarketShares.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buyMarketShares.d.ts","sourceRoot":"","sources":["../../src/instructions/buyMarketShares.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,EAAE,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"buyMarketShares.d.ts","sourceRoot":"","sources":["../../src/instructions/buyMarketShares.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,EAAE,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAqB9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAI9C;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,yBAAyB;IACzB,MAAM,EAAE,SAAS,CAAC;IAClB,2CAA2C;IAC3C,iBAAiB,EAAE,aAAa,CAAC;IACjC,kCAAkC;IAClC,MAAM,EAAE,SAAS,CAAC;IAClB,+DAA+D;IAC/D,MAAM,EAAE,MAAM,GAAG,EAAE,CAAC;IACpB,6DAA6D;IAC7D,cAAc,EAAE,MAAM,CAAC;IACvB,kEAAkE;IAClE,4BAA4B,CAAC,EAAE,UAAU,CAAC;IAC1C,mDAAmD;IACnD,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,mCAAmC;IACnC,WAAW,EAAE,WAAW,CAAC;IACzB,+BAA+B;IAC/B,eAAe,EAAE,SAAS,CAAC;IAC3B,gEAAgE;IAChE,iBAAiB,EAAE,EAAE,CAAC;CACvB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC,CAqFhC"}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { Program } from "@coral-xyz/anchor";
|
|
2
2
|
import { getCompDefAccOffset, getMXEAccAddress, getMempoolAccAddress, getExecutingPoolAccAddress, getComputationAccAddress, getCompDefAccAddress, getMXEPublicKey, } from "@arcium-hq/client";
|
|
3
3
|
import { PROGRAM_ID, COMP_DEF_OFFSETS } from "../constants";
|
|
4
|
-
import {
|
|
4
|
+
import { deriveShareAccountPda, generateComputationOffset, generateNonce, nonceToU128, createEncryptionContext, encryptBuySharesInput, ARCIUM_CLUSTER_OFFSET, getClusterAddress, } from "../utils";
|
|
5
5
|
import IDL from "../idl/conviction_market.json";
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Builds a transaction to buy market shares with encrypted input
|
|
8
8
|
*
|
|
9
9
|
* User purchases shares for a market option using encrypted computation.
|
|
10
10
|
* The amount and selected option are encrypted automatically.
|
|
11
11
|
* Deducts from vote token balance and stores encrypted share state.
|
|
12
12
|
* Only works during the staking period.
|
|
13
13
|
*
|
|
14
|
-
* @param provider - Anchor provider for connection
|
|
14
|
+
* @param provider - Anchor provider for connection
|
|
15
15
|
* @param params - Buy market shares parameters
|
|
16
|
-
* @returns Transaction
|
|
16
|
+
* @returns Transaction to sign and send, share account PDA, and computation offset
|
|
17
17
|
*/
|
|
18
18
|
export async function buyMarketShares(provider, params) {
|
|
19
19
|
const programId = params.programId ?? PROGRAM_ID;
|
|
@@ -24,9 +24,8 @@ export async function buyMarketShares(provider, params) {
|
|
|
24
24
|
if (!mxePublicKey) {
|
|
25
25
|
throw new Error("Failed to fetch MXE public key");
|
|
26
26
|
}
|
|
27
|
-
// Derive
|
|
28
|
-
const [
|
|
29
|
-
const [shareAccountPda] = deriveShareAccountPda(params.signer.publicKey, params.market, programId);
|
|
27
|
+
// Derive share account
|
|
28
|
+
const [shareAccountPda] = deriveShareAccountPda(params.signer, params.market, programId);
|
|
30
29
|
// Auto-generate computation offset and nonces
|
|
31
30
|
const computationOffset = generateComputationOffset();
|
|
32
31
|
const inputNonce = generateNonce();
|
|
@@ -41,7 +40,7 @@ export async function buyMarketShares(provider, params) {
|
|
|
41
40
|
const { amountCiphertext, selectedOptionCiphertext } = encryptBuySharesInput(encryptionContext, amountBigInt, BigInt(params.selectedOption), inputNonce);
|
|
42
41
|
// Use user's own pubkey for disclosure if not specified
|
|
43
42
|
const authorizedReaderPubkey = params.authorizedReaderX25519Pubkey ?? params.userX25519Keypair.publicKey;
|
|
44
|
-
const
|
|
43
|
+
const transaction = await program.methods
|
|
45
44
|
.buyMarketShares(computationOffset, Array.from(amountCiphertext), Array.from(selectedOptionCiphertext), Array.from(params.userX25519Keypair.publicKey), inputNonceBN, Array.from(authorizedReaderPubkey), disclosureNonceBN)
|
|
46
45
|
.accountsPartial({
|
|
47
46
|
market: params.market,
|
|
@@ -52,10 +51,9 @@ export async function buyMarketShares(provider, params) {
|
|
|
52
51
|
executingPool: getExecutingPoolAccAddress(ARCIUM_CLUSTER_OFFSET),
|
|
53
52
|
compDefAccount: getCompDefAccAddress(programId, Buffer.from(getCompDefAccOffset(COMP_DEF_OFFSETS.BUY_CONVICTION_MARKET_SHARES)).readUInt32LE()),
|
|
54
53
|
})
|
|
55
|
-
.
|
|
56
|
-
.rpc({ skipPreflight: true });
|
|
54
|
+
.transaction();
|
|
57
55
|
return {
|
|
58
|
-
|
|
56
|
+
transaction,
|
|
59
57
|
shareAccountPda,
|
|
60
58
|
computationOffset,
|
|
61
59
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buyMarketShares.js","sourceRoot":"","sources":["../../src/instructions/buyMarketShares.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,EACpB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"buyMarketShares.js","sourceRoot":"","sources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AAc,EAAE,oBAAoB,CAClC,SAAS,EACT,MAAM,CAAC,IAAI,CACT,mBAAmB,CAAC,gBAAgB,CAAC,4BAA4B,CAAC,CACnE,CAAC,YAAY,EAAE,CACjB;KACF,CAAC;SACD,WAAW,EAAE,CAAC;IAEjB,OAAO;QACL,WAAW;QACX,eAAe;QACf,iBAAiB;KAClB,CAAC;AACJ,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { BN, type AnchorProvider } from "@coral-xyz/anchor";
|
|
2
|
-
import { type
|
|
2
|
+
import { type PublicKey, Transaction } from "@solana/web3.js";
|
|
3
3
|
import type { X25519Keypair } from "../types";
|
|
4
4
|
/**
|
|
5
5
|
* Parameters for claiming/selling vote tokens
|
|
6
6
|
*/
|
|
7
7
|
export interface ClaimVoteTokensParams {
|
|
8
8
|
/** User claiming tokens (receives SOL) */
|
|
9
|
-
signer:
|
|
9
|
+
signer: PublicKey;
|
|
10
10
|
/** User's X25519 keypair for encryption */
|
|
11
11
|
userX25519Keypair: X25519Keypair;
|
|
12
12
|
/** Number of vote tokens to sell */
|
|
@@ -15,26 +15,26 @@ export interface ClaimVoteTokensParams {
|
|
|
15
15
|
programId?: PublicKey;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* Result from
|
|
18
|
+
* Result from building claim vote tokens transaction
|
|
19
19
|
*/
|
|
20
20
|
export interface ClaimVoteTokensResult {
|
|
21
|
-
/** Transaction
|
|
22
|
-
|
|
21
|
+
/** Transaction to sign and send */
|
|
22
|
+
transaction: Transaction;
|
|
23
23
|
/** PDA of the vote token account */
|
|
24
24
|
voteTokenAccountPda: PublicKey;
|
|
25
25
|
/** Computation offset (pass to awaitComputationFinalization) */
|
|
26
26
|
computationOffset: BN;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* Builds a transaction to claim (sell) vote tokens for SOL
|
|
30
30
|
*
|
|
31
31
|
* Users can sell their unused vote tokens back for SOL.
|
|
32
32
|
* Uses MPC to verify balance and deduct tokens.
|
|
33
33
|
* Transfers SOL from the vote token account back to the user.
|
|
34
34
|
*
|
|
35
|
-
* @param provider - Anchor provider for connection
|
|
35
|
+
* @param provider - Anchor provider for connection
|
|
36
36
|
* @param params - Claim vote tokens parameters
|
|
37
|
-
* @returns Transaction
|
|
37
|
+
* @returns Transaction to sign and send, vote token account PDA, and computation offset
|
|
38
38
|
*/
|
|
39
39
|
export declare function claimVoteTokens(provider: AnchorProvider, params: ClaimVoteTokensParams): Promise<ClaimVoteTokensResult>;
|
|
40
40
|
//# sourceMappingURL=claimVoteTokens.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claimVoteTokens.d.ts","sourceRoot":"","sources":["../../src/instructions/claimVoteTokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,EAAE,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAiB,KAAK,
|
|
1
|
+
{"version":3,"file":"claimVoteTokens.d.ts","sourceRoot":"","sources":["../../src/instructions/claimVoteTokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,EAAE,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAiB,KAAK,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAgB7E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAI9C;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,0CAA0C;IAC1C,MAAM,EAAE,SAAS,CAAC;IAClB,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,qBAAqB;IACpC,mCAAmC;IACnC,WAAW,EAAE,WAAW,CAAC;IACzB,oCAAoC;IACpC,mBAAmB,EAAE,SAAS,CAAC;IAC/B,gEAAgE;IAChE,iBAAiB,EAAE,EAAE,CAAC;CACvB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC,CAsDhC"}
|
|
@@ -5,30 +5,30 @@ import { PROGRAM_ID, COMP_DEF_OFFSETS } from "../constants";
|
|
|
5
5
|
import { deriveVoteTokenAccountPda, generateComputationOffset, ARCIUM_CLUSTER_OFFSET, getClusterAddress, } from "../utils";
|
|
6
6
|
import IDL from "../idl/conviction_market.json";
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Builds a transaction to claim (sell) vote tokens for SOL
|
|
9
9
|
*
|
|
10
10
|
* Users can sell their unused vote tokens back for SOL.
|
|
11
11
|
* Uses MPC to verify balance and deduct tokens.
|
|
12
12
|
* Transfers SOL from the vote token account back to the user.
|
|
13
13
|
*
|
|
14
|
-
* @param provider - Anchor provider for connection
|
|
14
|
+
* @param provider - Anchor provider for connection
|
|
15
15
|
* @param params - Claim vote tokens parameters
|
|
16
|
-
* @returns Transaction
|
|
16
|
+
* @returns Transaction to sign and send, vote token account PDA, and computation offset
|
|
17
17
|
*/
|
|
18
18
|
export async function claimVoteTokens(provider, params) {
|
|
19
19
|
const programId = params.programId ?? PROGRAM_ID;
|
|
20
20
|
const program = new Program(IDL, provider);
|
|
21
21
|
const clusterAccount = getClusterAddress();
|
|
22
22
|
// Derive vote token account PDA
|
|
23
|
-
const [voteTokenAccountPda] = deriveVoteTokenAccountPda(params.signer
|
|
23
|
+
const [voteTokenAccountPda] = deriveVoteTokenAccountPda(params.signer, programId);
|
|
24
24
|
// Auto-generate computation offset
|
|
25
25
|
const computationOffset = generateComputationOffset();
|
|
26
26
|
// Convert amount to BN
|
|
27
27
|
const amountBN = typeof params.amount === "number" ? new BN(params.amount) : params.amount;
|
|
28
|
-
const
|
|
28
|
+
const transaction = await program.methods
|
|
29
29
|
.claimVoteTokens(computationOffset, Array.from(params.userX25519Keypair.publicKey), amountBN)
|
|
30
30
|
.accountsPartial({
|
|
31
|
-
signer: params.signer
|
|
31
|
+
signer: params.signer,
|
|
32
32
|
voteTokenAccount: voteTokenAccountPda,
|
|
33
33
|
computationAccount: getComputationAccAddress(ARCIUM_CLUSTER_OFFSET, computationOffset),
|
|
34
34
|
clusterAccount,
|
|
@@ -38,10 +38,9 @@ export async function claimVoteTokens(provider, params) {
|
|
|
38
38
|
compDefAccount: getCompDefAccAddress(programId, Buffer.from(getCompDefAccOffset(COMP_DEF_OFFSETS.CLAIM_VOTE_TOKENS)).readUInt32LE()),
|
|
39
39
|
systemProgram: SystemProgram.programId,
|
|
40
40
|
})
|
|
41
|
-
.
|
|
42
|
-
.rpc({ skipPreflight: true });
|
|
41
|
+
.transaction();
|
|
43
42
|
return {
|
|
44
|
-
|
|
43
|
+
transaction,
|
|
45
44
|
voteTokenAccountPda,
|
|
46
45
|
computationOffset,
|
|
47
46
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claimVoteTokens.js","sourceRoot":"","sources":["../../src/instructions/claimVoteTokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,EAAE,EAAuB,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"claimVoteTokens.js","sourceRoot":"","sources":["../../src/instructions/claimVoteTokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,EAAE,EAAuB,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,aAAa,EAA+B,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,0BAA0B,EAC1B,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE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,cAAc,EAAE,oBAAoB,CAClC,SAAS,EACT,MAAM,CAAC,IAAI,CACT,mBAAmB,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CACxD,CAAC,YAAY,EAAE,CACjB;QACD,aAAa,EAAE,aAAa,CAAC,SAAS;KACvC,CAAC;SACD,WAAW,EAAE,CAAC;IAEjB,OAAO;QACL,WAAW;QACX,mBAAmB;QACnB,iBAAiB;KAClB,CAAC;AACJ,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type AnchorProvider } from "@coral-xyz/anchor";
|
|
2
|
-
import type {
|
|
2
|
+
import type { PublicKey, Transaction } from "@solana/web3.js";
|
|
3
3
|
/**
|
|
4
4
|
* Parameters for closing a share account
|
|
5
5
|
*/
|
|
6
6
|
export interface CloseShareAccountParams {
|
|
7
7
|
/** Share account owner */
|
|
8
|
-
owner:
|
|
8
|
+
owner: PublicKey;
|
|
9
9
|
/** Market PDA */
|
|
10
10
|
market: PublicKey;
|
|
11
11
|
/** Revealed option index */
|
|
@@ -14,23 +14,23 @@ export interface CloseShareAccountParams {
|
|
|
14
14
|
programId?: PublicKey;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
* Result from
|
|
17
|
+
* Result from building close share account transaction
|
|
18
18
|
*/
|
|
19
19
|
export interface CloseShareAccountResult {
|
|
20
|
-
/** Transaction
|
|
21
|
-
|
|
20
|
+
/** Transaction to sign and send */
|
|
21
|
+
transaction: Transaction;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* Builds a transaction to close a share account after the reveal period ends
|
|
25
25
|
*
|
|
26
26
|
* Only callable if shares were revealed and match the option_index.
|
|
27
27
|
* If the user voted for the winning option and incremented the tally,
|
|
28
28
|
* transfers proportional yield: (user_score / total_score) * reward_lamports.
|
|
29
29
|
* Closes the account and returns rent lamports to owner.
|
|
30
30
|
*
|
|
31
|
-
* @param provider - Anchor provider for connection
|
|
31
|
+
* @param provider - Anchor provider for connection
|
|
32
32
|
* @param params - Close share account parameters
|
|
33
|
-
* @returns Transaction
|
|
33
|
+
* @returns Transaction to sign and send
|
|
34
34
|
*/
|
|
35
35
|
export declare function closeShareAccount(provider: AnchorProvider, params: CloseShareAccountParams): Promise<CloseShareAccountResult>;
|
|
36
36
|
//# sourceMappingURL=closeShareAccount.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"closeShareAccount.d.ts","sourceRoot":"","sources":["../../src/instructions/closeShareAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"closeShareAccount.d.ts","sourceRoot":"","sources":["../../src/instructions/closeShareAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAM9D;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,0BAA0B;IAC1B,KAAK,EAAE,SAAS,CAAC;IACjB,iBAAiB;IACjB,MAAM,EAAE,SAAS,CAAC;IAClB,4BAA4B;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,mCAAmC;IACnC,WAAW,EAAE,WAAW,CAAC;CAC1B;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,uBAAuB,CAAC,CAelC"}
|
|
@@ -2,27 +2,26 @@ import { Program } from "@coral-xyz/anchor";
|
|
|
2
2
|
import { PROGRAM_ID } from "../constants";
|
|
3
3
|
import IDL from "../idl/conviction_market.json";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Builds a transaction to close a share account after the reveal period ends
|
|
6
6
|
*
|
|
7
7
|
* Only callable if shares were revealed and match the option_index.
|
|
8
8
|
* If the user voted for the winning option and incremented the tally,
|
|
9
9
|
* transfers proportional yield: (user_score / total_score) * reward_lamports.
|
|
10
10
|
* Closes the account and returns rent lamports to owner.
|
|
11
11
|
*
|
|
12
|
-
* @param provider - Anchor provider for connection
|
|
12
|
+
* @param provider - Anchor provider for connection
|
|
13
13
|
* @param params - Close share account parameters
|
|
14
|
-
* @returns Transaction
|
|
14
|
+
* @returns Transaction to sign and send
|
|
15
15
|
*/
|
|
16
16
|
export async function closeShareAccount(provider, params) {
|
|
17
17
|
const programId = params.programId ?? PROGRAM_ID;
|
|
18
18
|
const program = new Program(IDL, provider);
|
|
19
|
-
const
|
|
19
|
+
const transaction = await program.methods
|
|
20
20
|
.closeShareAccount(params.optionIndex)
|
|
21
21
|
.accountsPartial({
|
|
22
22
|
market: params.market,
|
|
23
23
|
})
|
|
24
|
-
.
|
|
25
|
-
|
|
26
|
-
return { signature };
|
|
24
|
+
.transaction();
|
|
25
|
+
return { transaction };
|
|
27
26
|
}
|
|
28
27
|
//# sourceMappingURL=closeShareAccount.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"closeShareAccount.js","sourceRoot":"","sources":["../../src/instructions/closeShareAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAuB,MAAM,mBAAmB,CAAC;AAEjE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,GAAG,MAAM,+BAA+B,CAAC;AAyBhD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,QAAwB,EACxB,MAA+B;IAE/B,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,UAAU,CAAC;IACjD,MAAM,OAAO,GAAG,IAAI,OAAO,CACzB,GAAuB,EACvB,QAAQ,CACoB,CAAC;IAE/B,MAAM,
|
|
1
|
+
{"version":3,"file":"closeShareAccount.js","sourceRoot":"","sources":["../../src/instructions/closeShareAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAuB,MAAM,mBAAmB,CAAC;AAEjE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,GAAG,MAAM,+BAA+B,CAAC;AAyBhD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,QAAwB,EACxB,MAA+B;IAE/B,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,UAAU,CAAC;IACjD,MAAM,OAAO,GAAG,IAAI,OAAO,CACzB,GAAuB,EACvB,QAAQ,CACoB,CAAC;IAE/B,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,OAAO;SACtC,iBAAiB,CAAC,MAAM,CAAC,WAAW,CAAC;SACrC,eAAe,CAAC;QACf,MAAM,EAAE,MAAM,CAAC,MAAM;KACtB,CAAC;SACD,WAAW,EAAE,CAAC;IAEjB,OAAO,EAAE,WAAW,EAAE,CAAC;AACzB,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { BN, type AnchorProvider } from "@coral-xyz/anchor";
|
|
2
|
-
import { type
|
|
2
|
+
import { type PublicKey, Transaction } from "@solana/web3.js";
|
|
3
3
|
/**
|
|
4
4
|
* Parameters for creating a market
|
|
5
5
|
*/
|
|
6
6
|
export interface CreateMarketParams {
|
|
7
7
|
/** Market creator (pays for account creation) */
|
|
8
|
-
creator:
|
|
8
|
+
creator: PublicKey;
|
|
9
9
|
/** Unique market index */
|
|
10
10
|
marketIndex: number | BN;
|
|
11
11
|
/** Maximum number of options allowed */
|
|
@@ -24,25 +24,25 @@ export interface CreateMarketParams {
|
|
|
24
24
|
programId?: PublicKey;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
* Result from
|
|
27
|
+
* Result from building create market transaction
|
|
28
28
|
*/
|
|
29
29
|
export interface CreateMarketResult {
|
|
30
|
-
/** Transaction
|
|
31
|
-
|
|
30
|
+
/** Transaction to sign and send */
|
|
31
|
+
transaction: Transaction;
|
|
32
32
|
/** PDA of the created market */
|
|
33
33
|
marketPda: PublicKey;
|
|
34
34
|
/** Computation offset (pass to awaitComputationFinalization) */
|
|
35
35
|
computationOffset: BN;
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
38
|
+
* Builds a transaction to create a new conviction market with encrypted state
|
|
39
39
|
*
|
|
40
40
|
* Initializes a market with encrypted available shares via MPC computation.
|
|
41
41
|
* After creation, options must be added and the market must be funded and opened.
|
|
42
42
|
*
|
|
43
|
-
* @param provider - Anchor provider for connection
|
|
43
|
+
* @param provider - Anchor provider for connection
|
|
44
44
|
* @param params - Create market parameters
|
|
45
|
-
* @returns Transaction
|
|
45
|
+
* @returns Transaction to sign and send, market PDA, and computation offset
|
|
46
46
|
*/
|
|
47
47
|
export declare function createMarket(provider: AnchorProvider, params: CreateMarketParams): Promise<CreateMarketResult>;
|
|
48
48
|
//# sourceMappingURL=createMarket.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMarket.d.ts","sourceRoot":"","sources":["../../src/instructions/createMarket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,EAAE,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAiB,KAAK,
|
|
1
|
+
{"version":3,"file":"createMarket.d.ts","sourceRoot":"","sources":["../../src/instructions/createMarket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,EAAE,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAiB,KAAK,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAqB7E;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,iDAAiD;IACjD,OAAO,EAAE,SAAS,CAAC;IACnB,0BAA0B;IAC1B,WAAW,EAAE,MAAM,GAAG,EAAE,CAAC;IACzB,wCAAwC;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,4CAA4C;IAC5C,SAAS,EAAE,MAAM,GAAG,EAAE,CAAC;IACvB,0CAA0C;IAC1C,cAAc,EAAE,MAAM,GAAG,EAAE,CAAC;IAC5B,4CAA4C;IAC5C,WAAW,EAAE,MAAM,GAAG,EAAE,CAAC;IACzB,2CAA2C;IAC3C,YAAY,EAAE,MAAM,GAAG,EAAE,CAAC;IAC1B,wDAAwD;IACxD,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,mDAAmD;IACnD,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,mCAAmC;IACnC,WAAW,EAAE,WAAW,CAAC;IACzB,gCAAgC;IAChC,SAAS,EAAE,SAAS,CAAC;IACrB,gEAAgE;IAChE,iBAAiB,EAAE,EAAE,CAAC;CACvB;AAED;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAChC,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,kBAAkB,CAAC,CAiF7B"}
|
|
@@ -5,14 +5,14 @@ import { PROGRAM_ID, COMP_DEF_OFFSETS } from "../constants";
|
|
|
5
5
|
import { deriveMarketPda, generateComputationOffset, generateNonce, nonceToU128, ARCIUM_CLUSTER_OFFSET, getClusterAddress, } from "../utils";
|
|
6
6
|
import IDL from "../idl/conviction_market.json";
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Builds a transaction to create a new conviction market with encrypted state
|
|
9
9
|
*
|
|
10
10
|
* Initializes a market with encrypted available shares via MPC computation.
|
|
11
11
|
* After creation, options must be added and the market must be funded and opened.
|
|
12
12
|
*
|
|
13
|
-
* @param provider - Anchor provider for connection
|
|
13
|
+
* @param provider - Anchor provider for connection
|
|
14
14
|
* @param params - Create market parameters
|
|
15
|
-
* @returns Transaction
|
|
15
|
+
* @returns Transaction to sign and send, market PDA, and computation offset
|
|
16
16
|
*/
|
|
17
17
|
export async function createMarket(provider, params) {
|
|
18
18
|
const programId = params.programId ?? PROGRAM_ID;
|
|
@@ -35,15 +35,15 @@ export async function createMarket(provider, params) {
|
|
|
35
35
|
? new BN(params.timeToReveal)
|
|
36
36
|
: params.timeToReveal;
|
|
37
37
|
// Derive market PDA
|
|
38
|
-
const [marketPda] = deriveMarketPda(params.creator
|
|
38
|
+
const [marketPda] = deriveMarketPda(params.creator, marketIndexBN, programId);
|
|
39
39
|
// Auto-generate computation offset and nonce
|
|
40
40
|
const computationOffset = generateComputationOffset();
|
|
41
41
|
const nonce = generateNonce();
|
|
42
42
|
const nonceBN = nonceToU128(nonce);
|
|
43
|
-
const
|
|
43
|
+
const transaction = await program.methods
|
|
44
44
|
.createMarket(marketIndexBN, computationOffset, params.maxOptions, maxSharesBN, rewardLamportsBN, timeToStakeBN, timeToRevealBN, nonceBN, params.selectAuthority ?? null)
|
|
45
45
|
.accountsPartial({
|
|
46
|
-
creator: params.creator
|
|
46
|
+
creator: params.creator,
|
|
47
47
|
market: marketPda,
|
|
48
48
|
computationAccount: getComputationAccAddress(ARCIUM_CLUSTER_OFFSET, computationOffset),
|
|
49
49
|
clusterAccount,
|
|
@@ -53,10 +53,9 @@ export async function createMarket(provider, params) {
|
|
|
53
53
|
compDefAccount: getCompDefAccAddress(programId, Buffer.from(getCompDefAccOffset(COMP_DEF_OFFSETS.INIT_MARKET_SHARES)).readUInt32LE()),
|
|
54
54
|
systemProgram: SystemProgram.programId,
|
|
55
55
|
})
|
|
56
|
-
.
|
|
57
|
-
.rpc({ skipPreflight: true });
|
|
56
|
+
.transaction();
|
|
58
57
|
return {
|
|
59
|
-
|
|
58
|
+
transaction,
|
|
60
59
|
marketPda,
|
|
61
60
|
computationOffset,
|
|
62
61
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMarket.js","sourceRoot":"","sources":["../../src/instructions/createMarket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,EAAE,EAAuB,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"createMarket.js","sourceRoot":"","sources":["../../src/instructions/createMarket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,EAAE,EAAuB,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,aAAa,EAA+B,MAAM,iBAAiB,CAAC;AAC7E,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,eAAe,EACf,yBAAyB,EACzB,aAAa,EACb,WAAW,EACX,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAClB,OAAO,GAAG,MAAM,+BAA+B,CAAC;AAuChD;;;;;;;;;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,cAAc,GAAG,iBAAiB,EAAE,CAAC;IAE3C,2BAA2B;IAC3B,MAAM,aAAa,GACjB,OAAO,MAAM,CAAC,WAAW,KAAK,QAAQ;QACpC,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC;QAC5B,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC;IACzB,MAAM,WAAW,GACf,OAAO,MAAM,CAAC,SAAS,KAAK,QAAQ;QAClC,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC;QAC1B,CAAC,CAAC,MAAM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AAqB,CAAC;QAC3D,aAAa,EAAE,0BAA0B,CAAC,qBAAqB,CAAC;QAChE,cAAc,EAAE,oBAAoB,CAClC,SAAS,EACT,MAAM,CAAC,IAAI,CACT,mBAAmB,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CACzD,CAAC,YAAY,EAAE,CACjB;QACD,aAAa,EAAE,aAAa,CAAC,SAAS;KACvC,CAAC;SACD,WAAW,EAAE,CAAC;IAEjB,OAAO;QACL,WAAW;QACX,SAAS;QACT,iBAAiB;KAClB,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AnchorProvider } from "@coral-xyz/anchor";
|
|
2
|
-
import type { PublicKey } from "@solana/web3.js";
|
|
2
|
+
import type { PublicKey, Transaction } from "@solana/web3.js";
|
|
3
3
|
/**
|
|
4
4
|
* Parameters for incrementing option tally
|
|
5
5
|
*/
|
|
@@ -14,22 +14,22 @@ export interface IncrementOptionTallyParams {
|
|
|
14
14
|
programId?: PublicKey;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
* Result from
|
|
17
|
+
* Result from building increment option tally transaction
|
|
18
18
|
*/
|
|
19
19
|
export interface IncrementOptionTallyResult {
|
|
20
|
-
/** Transaction
|
|
21
|
-
|
|
20
|
+
/** Transaction to sign and send */
|
|
21
|
+
transaction: Transaction;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* Builds a transaction to increment the tally for an option after shares are revealed
|
|
25
25
|
*
|
|
26
26
|
* This is permissionless - anyone can call it for any revealed share account.
|
|
27
27
|
* Calculates conviction score (amount * time-in-market) and adds it to the
|
|
28
28
|
* option's total. Each share account can only increment once.
|
|
29
29
|
*
|
|
30
|
-
* @param provider - Anchor provider for connection
|
|
30
|
+
* @param provider - Anchor provider for connection
|
|
31
31
|
* @param params - Increment option tally parameters
|
|
32
|
-
* @returns Transaction
|
|
32
|
+
* @returns Transaction to sign and send
|
|
33
33
|
*/
|
|
34
34
|
export declare function incrementOptionTally(provider: AnchorProvider, params: IncrementOptionTallyParams): Promise<IncrementOptionTallyResult>;
|
|
35
35
|
//# sourceMappingURL=incrementOptionTally.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"incrementOptionTally.d.ts","sourceRoot":"","sources":["../../src/instructions/incrementOptionTally.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"incrementOptionTally.d.ts","sourceRoot":"","sources":["../../src/instructions/incrementOptionTally.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAM9D;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,iBAAiB;IACjB,MAAM,EAAE,SAAS,CAAC;IAClB,0BAA0B;IAC1B,KAAK,EAAE,SAAS,CAAC;IACjB,gCAAgC;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,mCAAmC;IACnC,WAAW,EAAE,WAAW,CAAC;CAC1B;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,0BAA0B,GACjC,OAAO,CAAC,0BAA0B,CAAC,CAgBrC"}
|