@zemyth/raise-sdk 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.
- package/README.md +416 -0
- package/dist/accounts/index.cjs +258 -0
- package/dist/accounts/index.cjs.map +1 -0
- package/dist/accounts/index.d.cts +115 -0
- package/dist/accounts/index.d.ts +115 -0
- package/dist/accounts/index.js +245 -0
- package/dist/accounts/index.js.map +1 -0
- package/dist/constants/index.cjs +174 -0
- package/dist/constants/index.cjs.map +1 -0
- package/dist/constants/index.d.cts +143 -0
- package/dist/constants/index.d.ts +143 -0
- package/dist/constants/index.js +158 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/errors/index.cjs +177 -0
- package/dist/errors/index.cjs.map +1 -0
- package/dist/errors/index.d.cts +83 -0
- package/dist/errors/index.d.ts +83 -0
- package/dist/errors/index.js +170 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.cjs +2063 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +680 -0
- package/dist/index.d.ts +680 -0
- package/dist/index.js +1926 -0
- package/dist/index.js.map +1 -0
- package/dist/instructions/index.cjs +852 -0
- package/dist/instructions/index.cjs.map +1 -0
- package/dist/instructions/index.d.cts +452 -0
- package/dist/instructions/index.d.ts +452 -0
- package/dist/instructions/index.js +809 -0
- package/dist/instructions/index.js.map +1 -0
- package/dist/pdas/index.cjs +241 -0
- package/dist/pdas/index.cjs.map +1 -0
- package/dist/pdas/index.d.cts +171 -0
- package/dist/pdas/index.d.ts +171 -0
- package/dist/pdas/index.js +217 -0
- package/dist/pdas/index.js.map +1 -0
- package/dist/types/index.cjs +44 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.d.cts +229 -0
- package/dist/types/index.d.ts +229 -0
- package/dist/types/index.js +39 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +130 -0
- package/src/accounts/index.ts +329 -0
- package/src/client.ts +715 -0
- package/src/constants/index.ts +205 -0
- package/src/errors/index.ts +222 -0
- package/src/events/index.ts +256 -0
- package/src/index.ts +253 -0
- package/src/instructions/index.ts +1504 -0
- package/src/pdas/index.ts +404 -0
- package/src/types/index.ts +267 -0
- package/src/utils/index.ts +277 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { PublicKey } from '@solana/web3.js';
|
|
2
|
+
import { BN } from '@coral-xyz/anchor';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Raise PDA Derivation Helpers
|
|
6
|
+
*
|
|
7
|
+
* All PDA derivation functions for the Raise program.
|
|
8
|
+
* PDAs are deterministic addresses derived from seeds and program ID.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Derive Project PDA from project ID
|
|
13
|
+
*
|
|
14
|
+
* @param projectId - Unique project identifier
|
|
15
|
+
* @param programId - Raise program ID
|
|
16
|
+
* @returns Project account PDA
|
|
17
|
+
*/
|
|
18
|
+
declare function getProjectPDA(projectId: BN | number | string, programId: PublicKey): PublicKey;
|
|
19
|
+
/**
|
|
20
|
+
* Derive Escrow PDA from project ID
|
|
21
|
+
*
|
|
22
|
+
* @param projectId - Project identifier
|
|
23
|
+
* @param programId - Raise program ID
|
|
24
|
+
* @returns Escrow account PDA
|
|
25
|
+
*/
|
|
26
|
+
declare function getEscrowPDA(projectId: BN | number | string, programId: PublicKey): PublicKey;
|
|
27
|
+
/**
|
|
28
|
+
* Derive Milestone PDA from project PDA and milestone index
|
|
29
|
+
*
|
|
30
|
+
* @param projectPda - Project account PDA
|
|
31
|
+
* @param milestoneIndex - Milestone index (0-based)
|
|
32
|
+
* @param programId - Raise program ID
|
|
33
|
+
* @returns Milestone account PDA
|
|
34
|
+
*/
|
|
35
|
+
declare function getMilestonePDA(projectPda: PublicKey, milestoneIndex: number, programId: PublicKey): PublicKey;
|
|
36
|
+
/**
|
|
37
|
+
* Derive Investment PDA from project PDA and NFT mint
|
|
38
|
+
*
|
|
39
|
+
* @param projectPda - Project account PDA
|
|
40
|
+
* @param nftMint - Investment NFT mint address
|
|
41
|
+
* @param programId - Raise program ID
|
|
42
|
+
* @returns Investment account PDA
|
|
43
|
+
*/
|
|
44
|
+
declare function getInvestmentPDA(projectPda: PublicKey, nftMint: PublicKey, programId: PublicKey): PublicKey;
|
|
45
|
+
/**
|
|
46
|
+
* Derive Vote PDA from milestone PDA, voter key, and voting round
|
|
47
|
+
*
|
|
48
|
+
* @param milestonePda - Milestone account PDA
|
|
49
|
+
* @param voterKey - Voter's public key
|
|
50
|
+
* @param votingRound - Current voting round (0 initially, incremented on resubmit)
|
|
51
|
+
* @param programId - Raise program ID
|
|
52
|
+
* @returns Vote account PDA
|
|
53
|
+
*/
|
|
54
|
+
declare function getVotePDA(milestonePda: PublicKey, voterKey: PublicKey, votingRound: number, programId: PublicKey): PublicKey;
|
|
55
|
+
/**
|
|
56
|
+
* Derive PivotProposal PDA from project PDA and pivot count
|
|
57
|
+
*
|
|
58
|
+
* @param projectPda - Project account PDA
|
|
59
|
+
* @param pivotCount - Current pivot count from project account
|
|
60
|
+
* @param programId - Raise program ID
|
|
61
|
+
* @returns PivotProposal account PDA
|
|
62
|
+
*/
|
|
63
|
+
declare function getPivotProposalPDA(projectPda: PublicKey, pivotCount: number, programId: PublicKey): PublicKey;
|
|
64
|
+
/**
|
|
65
|
+
* Derive TgeEscrow PDA from project PDA
|
|
66
|
+
*
|
|
67
|
+
* @param projectPda - Project account PDA
|
|
68
|
+
* @param programId - Raise program ID
|
|
69
|
+
* @returns TgeEscrow account PDA
|
|
70
|
+
*/
|
|
71
|
+
declare function getTgeEscrowPDA(projectPda: PublicKey, programId: PublicKey): PublicKey;
|
|
72
|
+
/**
|
|
73
|
+
* Derive TgeEscrowVault PDA from project PDA
|
|
74
|
+
* Used for holding 10% USDC holdback from final milestone
|
|
75
|
+
*
|
|
76
|
+
* @param projectPda - Project account PDA
|
|
77
|
+
* @param programId - Raise program ID
|
|
78
|
+
* @returns TgeEscrowVault PDA
|
|
79
|
+
*/
|
|
80
|
+
declare function getTgeEscrowVaultPDA(projectPda: PublicKey, programId: PublicKey): PublicKey;
|
|
81
|
+
/**
|
|
82
|
+
* Derive TokenVault PDA from project PDA
|
|
83
|
+
* Used for holding project tokens for investor distribution
|
|
84
|
+
*
|
|
85
|
+
* @param projectPda - Project account PDA
|
|
86
|
+
* @param programId - Raise program ID
|
|
87
|
+
* @returns TokenVault PDA
|
|
88
|
+
*/
|
|
89
|
+
declare function getTokenVaultPDA(projectPda: PublicKey, programId: PublicKey): PublicKey;
|
|
90
|
+
/**
|
|
91
|
+
* Derive ScamReport PDA from project PDA and NFT mint
|
|
92
|
+
*
|
|
93
|
+
* @param projectPda - Project account PDA
|
|
94
|
+
* @param nftMint - Reporter's NFT mint address
|
|
95
|
+
* @param programId - Raise program ID
|
|
96
|
+
* @returns ScamReport account PDA
|
|
97
|
+
*/
|
|
98
|
+
declare function getScamReportPDA(projectPda: PublicKey, nftMint: PublicKey, programId: PublicKey): PublicKey;
|
|
99
|
+
/**
|
|
100
|
+
* Derive AdminConfig PDA (global admin authority)
|
|
101
|
+
*
|
|
102
|
+
* @param programId - Raise program ID
|
|
103
|
+
* @returns AdminConfig account PDA
|
|
104
|
+
*/
|
|
105
|
+
declare function getAdminConfigPDA(programId: PublicKey): PublicKey;
|
|
106
|
+
/**
|
|
107
|
+
* Derive NFT Mint PDA
|
|
108
|
+
*
|
|
109
|
+
* @param projectId - Project identifier
|
|
110
|
+
* @param investor - Investor's public key
|
|
111
|
+
* @param investmentCount - Investment count (u64 in Rust, 8 bytes LE)
|
|
112
|
+
* @param programId - Raise program ID
|
|
113
|
+
* @returns NFT Mint PDA and bump
|
|
114
|
+
*/
|
|
115
|
+
declare function getNftMintPDA(projectId: BN | number | string, investor: PublicKey, investmentCount: BN | number, programId: PublicKey): [PublicKey, number];
|
|
116
|
+
/**
|
|
117
|
+
* Derive Program Authority PDA
|
|
118
|
+
*
|
|
119
|
+
* @param programId - Raise program ID
|
|
120
|
+
* @returns Program authority PDA and bump
|
|
121
|
+
*/
|
|
122
|
+
declare function getProgramAuthorityPDA(programId: PublicKey): [PublicKey, number];
|
|
123
|
+
/**
|
|
124
|
+
* Helper to derive all PDAs for a project
|
|
125
|
+
*
|
|
126
|
+
* @param projectId - Project identifier
|
|
127
|
+
* @param programId - Raise program ID
|
|
128
|
+
* @returns Object with project and escrow PDAs
|
|
129
|
+
*/
|
|
130
|
+
declare function getProjectPDAs(projectId: BN, programId: PublicKey): {
|
|
131
|
+
project: PublicKey;
|
|
132
|
+
escrow: PublicKey;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Derive Tokenomics PDA from project PDA
|
|
136
|
+
*/
|
|
137
|
+
declare function getTokenomicsPDA(projectPda: PublicKey, programId: PublicKey): PublicKey;
|
|
138
|
+
/**
|
|
139
|
+
* Derive Token Mint PDA from project PDA
|
|
140
|
+
*/
|
|
141
|
+
declare function getTokenMintPDA(projectPda: PublicKey, programId: PublicKey): PublicKey;
|
|
142
|
+
/**
|
|
143
|
+
* Derive Vault Authority PDA from project PDA
|
|
144
|
+
*/
|
|
145
|
+
declare function getVaultAuthorityPDA(projectPda: PublicKey, programId: PublicKey): PublicKey;
|
|
146
|
+
/**
|
|
147
|
+
* Derive Investor Vault PDA from project PDA
|
|
148
|
+
*/
|
|
149
|
+
declare function getInvestorVaultPDA(projectPda: PublicKey, programId: PublicKey): PublicKey;
|
|
150
|
+
/**
|
|
151
|
+
* Derive Founder Vault PDA from project PDA
|
|
152
|
+
*/
|
|
153
|
+
declare function getFounderVaultPDA(projectPda: PublicKey, programId: PublicKey): PublicKey;
|
|
154
|
+
/**
|
|
155
|
+
* Derive LP Token Vault PDA from project PDA
|
|
156
|
+
*/
|
|
157
|
+
declare function getLpTokenVaultPDA(projectPda: PublicKey, programId: PublicKey): PublicKey;
|
|
158
|
+
/**
|
|
159
|
+
* Derive Treasury Vault PDA from project PDA
|
|
160
|
+
*/
|
|
161
|
+
declare function getTreasuryVaultPDA(projectPda: PublicKey, programId: PublicKey): PublicKey;
|
|
162
|
+
/**
|
|
163
|
+
* Derive LP USDC Vault PDA from project PDA
|
|
164
|
+
*/
|
|
165
|
+
declare function getLpUsdcVaultPDA(projectPda: PublicKey, programId: PublicKey): PublicKey;
|
|
166
|
+
/**
|
|
167
|
+
* Derive Founder Vesting PDA from project PDA
|
|
168
|
+
*/
|
|
169
|
+
declare function getFounderVestingPDA(projectPda: PublicKey, programId: PublicKey): PublicKey;
|
|
170
|
+
|
|
171
|
+
export { getAdminConfigPDA, getEscrowPDA, getFounderVaultPDA, getFounderVestingPDA, getInvestmentPDA, getInvestorVaultPDA, getLpTokenVaultPDA, getLpUsdcVaultPDA, getMilestonePDA, getNftMintPDA, getPivotProposalPDA, getProgramAuthorityPDA, getProjectPDA, getProjectPDAs, getScamReportPDA, getTgeEscrowPDA, getTgeEscrowVaultPDA, getTokenMintPDA, getTokenVaultPDA, getTokenomicsPDA, getTreasuryVaultPDA, getVaultAuthorityPDA, getVotePDA };
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { PublicKey } from '@solana/web3.js';
|
|
2
|
+
import { BN } from '@coral-xyz/anchor';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Raise PDA Derivation Helpers
|
|
6
|
+
*
|
|
7
|
+
* All PDA derivation functions for the Raise program.
|
|
8
|
+
* PDAs are deterministic addresses derived from seeds and program ID.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Derive Project PDA from project ID
|
|
13
|
+
*
|
|
14
|
+
* @param projectId - Unique project identifier
|
|
15
|
+
* @param programId - Raise program ID
|
|
16
|
+
* @returns Project account PDA
|
|
17
|
+
*/
|
|
18
|
+
declare function getProjectPDA(projectId: BN | number | string, programId: PublicKey): PublicKey;
|
|
19
|
+
/**
|
|
20
|
+
* Derive Escrow PDA from project ID
|
|
21
|
+
*
|
|
22
|
+
* @param projectId - Project identifier
|
|
23
|
+
* @param programId - Raise program ID
|
|
24
|
+
* @returns Escrow account PDA
|
|
25
|
+
*/
|
|
26
|
+
declare function getEscrowPDA(projectId: BN | number | string, programId: PublicKey): PublicKey;
|
|
27
|
+
/**
|
|
28
|
+
* Derive Milestone PDA from project PDA and milestone index
|
|
29
|
+
*
|
|
30
|
+
* @param projectPda - Project account PDA
|
|
31
|
+
* @param milestoneIndex - Milestone index (0-based)
|
|
32
|
+
* @param programId - Raise program ID
|
|
33
|
+
* @returns Milestone account PDA
|
|
34
|
+
*/
|
|
35
|
+
declare function getMilestonePDA(projectPda: PublicKey, milestoneIndex: number, programId: PublicKey): PublicKey;
|
|
36
|
+
/**
|
|
37
|
+
* Derive Investment PDA from project PDA and NFT mint
|
|
38
|
+
*
|
|
39
|
+
* @param projectPda - Project account PDA
|
|
40
|
+
* @param nftMint - Investment NFT mint address
|
|
41
|
+
* @param programId - Raise program ID
|
|
42
|
+
* @returns Investment account PDA
|
|
43
|
+
*/
|
|
44
|
+
declare function getInvestmentPDA(projectPda: PublicKey, nftMint: PublicKey, programId: PublicKey): PublicKey;
|
|
45
|
+
/**
|
|
46
|
+
* Derive Vote PDA from milestone PDA, voter key, and voting round
|
|
47
|
+
*
|
|
48
|
+
* @param milestonePda - Milestone account PDA
|
|
49
|
+
* @param voterKey - Voter's public key
|
|
50
|
+
* @param votingRound - Current voting round (0 initially, incremented on resubmit)
|
|
51
|
+
* @param programId - Raise program ID
|
|
52
|
+
* @returns Vote account PDA
|
|
53
|
+
*/
|
|
54
|
+
declare function getVotePDA(milestonePda: PublicKey, voterKey: PublicKey, votingRound: number, programId: PublicKey): PublicKey;
|
|
55
|
+
/**
|
|
56
|
+
* Derive PivotProposal PDA from project PDA and pivot count
|
|
57
|
+
*
|
|
58
|
+
* @param projectPda - Project account PDA
|
|
59
|
+
* @param pivotCount - Current pivot count from project account
|
|
60
|
+
* @param programId - Raise program ID
|
|
61
|
+
* @returns PivotProposal account PDA
|
|
62
|
+
*/
|
|
63
|
+
declare function getPivotProposalPDA(projectPda: PublicKey, pivotCount: number, programId: PublicKey): PublicKey;
|
|
64
|
+
/**
|
|
65
|
+
* Derive TgeEscrow PDA from project PDA
|
|
66
|
+
*
|
|
67
|
+
* @param projectPda - Project account PDA
|
|
68
|
+
* @param programId - Raise program ID
|
|
69
|
+
* @returns TgeEscrow account PDA
|
|
70
|
+
*/
|
|
71
|
+
declare function getTgeEscrowPDA(projectPda: PublicKey, programId: PublicKey): PublicKey;
|
|
72
|
+
/**
|
|
73
|
+
* Derive TgeEscrowVault PDA from project PDA
|
|
74
|
+
* Used for holding 10% USDC holdback from final milestone
|
|
75
|
+
*
|
|
76
|
+
* @param projectPda - Project account PDA
|
|
77
|
+
* @param programId - Raise program ID
|
|
78
|
+
* @returns TgeEscrowVault PDA
|
|
79
|
+
*/
|
|
80
|
+
declare function getTgeEscrowVaultPDA(projectPda: PublicKey, programId: PublicKey): PublicKey;
|
|
81
|
+
/**
|
|
82
|
+
* Derive TokenVault PDA from project PDA
|
|
83
|
+
* Used for holding project tokens for investor distribution
|
|
84
|
+
*
|
|
85
|
+
* @param projectPda - Project account PDA
|
|
86
|
+
* @param programId - Raise program ID
|
|
87
|
+
* @returns TokenVault PDA
|
|
88
|
+
*/
|
|
89
|
+
declare function getTokenVaultPDA(projectPda: PublicKey, programId: PublicKey): PublicKey;
|
|
90
|
+
/**
|
|
91
|
+
* Derive ScamReport PDA from project PDA and NFT mint
|
|
92
|
+
*
|
|
93
|
+
* @param projectPda - Project account PDA
|
|
94
|
+
* @param nftMint - Reporter's NFT mint address
|
|
95
|
+
* @param programId - Raise program ID
|
|
96
|
+
* @returns ScamReport account PDA
|
|
97
|
+
*/
|
|
98
|
+
declare function getScamReportPDA(projectPda: PublicKey, nftMint: PublicKey, programId: PublicKey): PublicKey;
|
|
99
|
+
/**
|
|
100
|
+
* Derive AdminConfig PDA (global admin authority)
|
|
101
|
+
*
|
|
102
|
+
* @param programId - Raise program ID
|
|
103
|
+
* @returns AdminConfig account PDA
|
|
104
|
+
*/
|
|
105
|
+
declare function getAdminConfigPDA(programId: PublicKey): PublicKey;
|
|
106
|
+
/**
|
|
107
|
+
* Derive NFT Mint PDA
|
|
108
|
+
*
|
|
109
|
+
* @param projectId - Project identifier
|
|
110
|
+
* @param investor - Investor's public key
|
|
111
|
+
* @param investmentCount - Investment count (u64 in Rust, 8 bytes LE)
|
|
112
|
+
* @param programId - Raise program ID
|
|
113
|
+
* @returns NFT Mint PDA and bump
|
|
114
|
+
*/
|
|
115
|
+
declare function getNftMintPDA(projectId: BN | number | string, investor: PublicKey, investmentCount: BN | number, programId: PublicKey): [PublicKey, number];
|
|
116
|
+
/**
|
|
117
|
+
* Derive Program Authority PDA
|
|
118
|
+
*
|
|
119
|
+
* @param programId - Raise program ID
|
|
120
|
+
* @returns Program authority PDA and bump
|
|
121
|
+
*/
|
|
122
|
+
declare function getProgramAuthorityPDA(programId: PublicKey): [PublicKey, number];
|
|
123
|
+
/**
|
|
124
|
+
* Helper to derive all PDAs for a project
|
|
125
|
+
*
|
|
126
|
+
* @param projectId - Project identifier
|
|
127
|
+
* @param programId - Raise program ID
|
|
128
|
+
* @returns Object with project and escrow PDAs
|
|
129
|
+
*/
|
|
130
|
+
declare function getProjectPDAs(projectId: BN, programId: PublicKey): {
|
|
131
|
+
project: PublicKey;
|
|
132
|
+
escrow: PublicKey;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Derive Tokenomics PDA from project PDA
|
|
136
|
+
*/
|
|
137
|
+
declare function getTokenomicsPDA(projectPda: PublicKey, programId: PublicKey): PublicKey;
|
|
138
|
+
/**
|
|
139
|
+
* Derive Token Mint PDA from project PDA
|
|
140
|
+
*/
|
|
141
|
+
declare function getTokenMintPDA(projectPda: PublicKey, programId: PublicKey): PublicKey;
|
|
142
|
+
/**
|
|
143
|
+
* Derive Vault Authority PDA from project PDA
|
|
144
|
+
*/
|
|
145
|
+
declare function getVaultAuthorityPDA(projectPda: PublicKey, programId: PublicKey): PublicKey;
|
|
146
|
+
/**
|
|
147
|
+
* Derive Investor Vault PDA from project PDA
|
|
148
|
+
*/
|
|
149
|
+
declare function getInvestorVaultPDA(projectPda: PublicKey, programId: PublicKey): PublicKey;
|
|
150
|
+
/**
|
|
151
|
+
* Derive Founder Vault PDA from project PDA
|
|
152
|
+
*/
|
|
153
|
+
declare function getFounderVaultPDA(projectPda: PublicKey, programId: PublicKey): PublicKey;
|
|
154
|
+
/**
|
|
155
|
+
* Derive LP Token Vault PDA from project PDA
|
|
156
|
+
*/
|
|
157
|
+
declare function getLpTokenVaultPDA(projectPda: PublicKey, programId: PublicKey): PublicKey;
|
|
158
|
+
/**
|
|
159
|
+
* Derive Treasury Vault PDA from project PDA
|
|
160
|
+
*/
|
|
161
|
+
declare function getTreasuryVaultPDA(projectPda: PublicKey, programId: PublicKey): PublicKey;
|
|
162
|
+
/**
|
|
163
|
+
* Derive LP USDC Vault PDA from project PDA
|
|
164
|
+
*/
|
|
165
|
+
declare function getLpUsdcVaultPDA(projectPda: PublicKey, programId: PublicKey): PublicKey;
|
|
166
|
+
/**
|
|
167
|
+
* Derive Founder Vesting PDA from project PDA
|
|
168
|
+
*/
|
|
169
|
+
declare function getFounderVestingPDA(projectPda: PublicKey, programId: PublicKey): PublicKey;
|
|
170
|
+
|
|
171
|
+
export { getAdminConfigPDA, getEscrowPDA, getFounderVaultPDA, getFounderVestingPDA, getInvestmentPDA, getInvestorVaultPDA, getLpTokenVaultPDA, getLpUsdcVaultPDA, getMilestonePDA, getNftMintPDA, getPivotProposalPDA, getProgramAuthorityPDA, getProjectPDA, getProjectPDAs, getScamReportPDA, getTgeEscrowPDA, getTgeEscrowVaultPDA, getTokenMintPDA, getTokenVaultPDA, getTokenomicsPDA, getTreasuryVaultPDA, getVaultAuthorityPDA, getVotePDA };
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { PublicKey } from '@solana/web3.js';
|
|
2
|
+
import { BN } from '@coral-xyz/anchor';
|
|
3
|
+
|
|
4
|
+
// src/pdas/index.ts
|
|
5
|
+
|
|
6
|
+
// src/constants/index.ts
|
|
7
|
+
var SEEDS = {
|
|
8
|
+
PROJECT: "project",
|
|
9
|
+
MILESTONE: "milestone",
|
|
10
|
+
INVESTMENT: "investment",
|
|
11
|
+
VOTE: "vote",
|
|
12
|
+
ESCROW: "escrow",
|
|
13
|
+
PIVOT: "pivot",
|
|
14
|
+
TGE_ESCROW: "tge_escrow",
|
|
15
|
+
TGE_ESCROW_VAULT: "tge_escrow_vault",
|
|
16
|
+
SCAM_REPORT: "scam_report",
|
|
17
|
+
ADMIN_CONFIG: "admin-config",
|
|
18
|
+
NFT_MINT: "nft_mint",
|
|
19
|
+
AUTHORITY: "authority"
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// src/pdas/index.ts
|
|
23
|
+
function ensureBN(value) {
|
|
24
|
+
if (value && typeof value.toArrayLike === "function") {
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
return new BN(String(value));
|
|
28
|
+
}
|
|
29
|
+
function getProjectPDA(projectId, programId) {
|
|
30
|
+
const projectIdBN = ensureBN(projectId);
|
|
31
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
32
|
+
[Buffer.from(SEEDS.PROJECT), projectIdBN.toArrayLike(Buffer, "le", 8)],
|
|
33
|
+
programId
|
|
34
|
+
);
|
|
35
|
+
return pda;
|
|
36
|
+
}
|
|
37
|
+
function getEscrowPDA(projectId, programId) {
|
|
38
|
+
const projectIdBN = ensureBN(projectId);
|
|
39
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
40
|
+
[Buffer.from(SEEDS.ESCROW), projectIdBN.toArrayLike(Buffer, "le", 8)],
|
|
41
|
+
programId
|
|
42
|
+
);
|
|
43
|
+
return pda;
|
|
44
|
+
}
|
|
45
|
+
function getMilestonePDA(projectPda, milestoneIndex, programId) {
|
|
46
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
47
|
+
[
|
|
48
|
+
Buffer.from(SEEDS.MILESTONE),
|
|
49
|
+
projectPda.toBuffer(),
|
|
50
|
+
Buffer.from([milestoneIndex])
|
|
51
|
+
],
|
|
52
|
+
programId
|
|
53
|
+
);
|
|
54
|
+
return pda;
|
|
55
|
+
}
|
|
56
|
+
function getInvestmentPDA(projectPda, nftMint, programId) {
|
|
57
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
58
|
+
[
|
|
59
|
+
Buffer.from(SEEDS.INVESTMENT),
|
|
60
|
+
projectPda.toBuffer(),
|
|
61
|
+
nftMint.toBuffer()
|
|
62
|
+
],
|
|
63
|
+
programId
|
|
64
|
+
);
|
|
65
|
+
return pda;
|
|
66
|
+
}
|
|
67
|
+
function getVotePDA(milestonePda, voterKey, votingRound, programId) {
|
|
68
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
69
|
+
[Buffer.from(SEEDS.VOTE), milestonePda.toBuffer(), voterKey.toBuffer(), Buffer.from([votingRound])],
|
|
70
|
+
programId
|
|
71
|
+
);
|
|
72
|
+
return pda;
|
|
73
|
+
}
|
|
74
|
+
function getPivotProposalPDA(projectPda, pivotCount, programId) {
|
|
75
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
76
|
+
[
|
|
77
|
+
Buffer.from(SEEDS.PIVOT),
|
|
78
|
+
// Use PIVOT seed, not PIVOT_PROPOSAL
|
|
79
|
+
projectPda.toBuffer(),
|
|
80
|
+
Buffer.from([pivotCount])
|
|
81
|
+
// pivot_count is u8 (1 byte) on-chain
|
|
82
|
+
],
|
|
83
|
+
programId
|
|
84
|
+
);
|
|
85
|
+
return pda;
|
|
86
|
+
}
|
|
87
|
+
function getTgeEscrowPDA(projectPda, programId) {
|
|
88
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
89
|
+
[Buffer.from(SEEDS.TGE_ESCROW), projectPda.toBuffer()],
|
|
90
|
+
programId
|
|
91
|
+
);
|
|
92
|
+
return pda;
|
|
93
|
+
}
|
|
94
|
+
function getTgeEscrowVaultPDA(projectPda, programId) {
|
|
95
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
96
|
+
[Buffer.from(SEEDS.TGE_ESCROW_VAULT), projectPda.toBuffer()],
|
|
97
|
+
programId
|
|
98
|
+
);
|
|
99
|
+
return pda;
|
|
100
|
+
}
|
|
101
|
+
function getTokenVaultPDA(projectPda, programId) {
|
|
102
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
103
|
+
[Buffer.from("token_vault"), projectPda.toBuffer()],
|
|
104
|
+
programId
|
|
105
|
+
);
|
|
106
|
+
return pda;
|
|
107
|
+
}
|
|
108
|
+
function getScamReportPDA(projectPda, nftMint, programId) {
|
|
109
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
110
|
+
[
|
|
111
|
+
Buffer.from(SEEDS.SCAM_REPORT),
|
|
112
|
+
projectPda.toBuffer(),
|
|
113
|
+
nftMint.toBuffer()
|
|
114
|
+
],
|
|
115
|
+
programId
|
|
116
|
+
);
|
|
117
|
+
return pda;
|
|
118
|
+
}
|
|
119
|
+
function getAdminConfigPDA(programId) {
|
|
120
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
121
|
+
[Buffer.from(SEEDS.ADMIN_CONFIG)],
|
|
122
|
+
programId
|
|
123
|
+
);
|
|
124
|
+
return pda;
|
|
125
|
+
}
|
|
126
|
+
function getNftMintPDA(projectId, investor, investmentCount, programId) {
|
|
127
|
+
const projectIdBN = ensureBN(projectId);
|
|
128
|
+
const countBN = ensureBN(investmentCount);
|
|
129
|
+
return PublicKey.findProgramAddressSync(
|
|
130
|
+
[
|
|
131
|
+
Buffer.from(SEEDS.NFT_MINT),
|
|
132
|
+
projectIdBN.toArrayLike(Buffer, "le", 8),
|
|
133
|
+
investor.toBuffer(),
|
|
134
|
+
countBN.toArrayLike(Buffer, "le", 8)
|
|
135
|
+
// u64 is 8 bytes LE
|
|
136
|
+
],
|
|
137
|
+
programId
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
function getProgramAuthorityPDA(programId) {
|
|
141
|
+
return PublicKey.findProgramAddressSync(
|
|
142
|
+
[Buffer.from(SEEDS.AUTHORITY)],
|
|
143
|
+
programId
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
function getProjectPDAs(projectId, programId) {
|
|
147
|
+
const project = getProjectPDA(projectId, programId);
|
|
148
|
+
const escrow = getEscrowPDA(projectId, programId);
|
|
149
|
+
return { project, escrow };
|
|
150
|
+
}
|
|
151
|
+
function getTokenomicsPDA(projectPda, programId) {
|
|
152
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
153
|
+
[Buffer.from("tokenomics"), projectPda.toBuffer()],
|
|
154
|
+
programId
|
|
155
|
+
);
|
|
156
|
+
return pda;
|
|
157
|
+
}
|
|
158
|
+
function getTokenMintPDA(projectPda, programId) {
|
|
159
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
160
|
+
[Buffer.from("token_mint"), projectPda.toBuffer()],
|
|
161
|
+
programId
|
|
162
|
+
);
|
|
163
|
+
return pda;
|
|
164
|
+
}
|
|
165
|
+
function getVaultAuthorityPDA(projectPda, programId) {
|
|
166
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
167
|
+
[Buffer.from("vault_authority"), projectPda.toBuffer()],
|
|
168
|
+
programId
|
|
169
|
+
);
|
|
170
|
+
return pda;
|
|
171
|
+
}
|
|
172
|
+
function getInvestorVaultPDA(projectPda, programId) {
|
|
173
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
174
|
+
[Buffer.from("investor_vault"), projectPda.toBuffer()],
|
|
175
|
+
programId
|
|
176
|
+
);
|
|
177
|
+
return pda;
|
|
178
|
+
}
|
|
179
|
+
function getFounderVaultPDA(projectPda, programId) {
|
|
180
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
181
|
+
[Buffer.from("founder_vault"), projectPda.toBuffer()],
|
|
182
|
+
programId
|
|
183
|
+
);
|
|
184
|
+
return pda;
|
|
185
|
+
}
|
|
186
|
+
function getLpTokenVaultPDA(projectPda, programId) {
|
|
187
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
188
|
+
[Buffer.from("lp_token_vault"), projectPda.toBuffer()],
|
|
189
|
+
programId
|
|
190
|
+
);
|
|
191
|
+
return pda;
|
|
192
|
+
}
|
|
193
|
+
function getTreasuryVaultPDA(projectPda, programId) {
|
|
194
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
195
|
+
[Buffer.from("treasury_vault"), projectPda.toBuffer()],
|
|
196
|
+
programId
|
|
197
|
+
);
|
|
198
|
+
return pda;
|
|
199
|
+
}
|
|
200
|
+
function getLpUsdcVaultPDA(projectPda, programId) {
|
|
201
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
202
|
+
[Buffer.from("lp_usdc_vault"), projectPda.toBuffer()],
|
|
203
|
+
programId
|
|
204
|
+
);
|
|
205
|
+
return pda;
|
|
206
|
+
}
|
|
207
|
+
function getFounderVestingPDA(projectPda, programId) {
|
|
208
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
209
|
+
[Buffer.from("founder_vesting"), projectPda.toBuffer()],
|
|
210
|
+
programId
|
|
211
|
+
);
|
|
212
|
+
return pda;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export { getAdminConfigPDA, getEscrowPDA, getFounderVaultPDA, getFounderVestingPDA, getInvestmentPDA, getInvestorVaultPDA, getLpTokenVaultPDA, getLpUsdcVaultPDA, getMilestonePDA, getNftMintPDA, getPivotProposalPDA, getProgramAuthorityPDA, getProjectPDA, getProjectPDAs, getScamReportPDA, getTgeEscrowPDA, getTgeEscrowVaultPDA, getTokenMintPDA, getTokenVaultPDA, getTokenomicsPDA, getTreasuryVaultPDA, getVaultAuthorityPDA, getVotePDA };
|
|
216
|
+
//# sourceMappingURL=index.js.map
|
|
217
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/constants/index.ts","../../src/pdas/index.ts"],"names":[],"mappings":";;;;;;AAWO,IAAM,KAAA,GAAQ;AAAA,EACnB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AA,OAAO,GAAA;AACT;AAKO,SAAS,mBAAA,CAAoB,YAAuB,SAAA,EAAiC;AAC1F,EAAA,MAAM,CAAC,GAAG,CAAA,GAAI,SAAA,CAAU,sBAAA;AAAA,IACtB,CAAC,MAAA,CAAO,IAAA,CAAK,gBAAgB,CAAA,EAAG,UAAA,CAAW,UAAU,CAAA;AAAA,IACrD;AAAA,GACF;AACA,EAAA,OAAO,GAAA;AACT;AAKO,SAAS,iBAAA,CAAkB,YAAuB,SAAA,EAAiC;AACxF,EAAA,MAAM,CAAC,GAAG,CAAA,GAAI,SAAA,CAAU,sBAAA;AAAA,IACtB,CAAC,MAAA,CAAO,IAAA,CAAK,eAAe,CAAA,EAAG,UAAA,CAAW,UAAU,CAAA;AAAA,IACpD;AAAA,GACF;AACA,EAAA,OAAO,GAAA;AACT;AAKO,SAAS,oBAAA,CAAqB,YAAuB,SAAA,EAAiC;AAC3F,EAAA,MAAM,CAAC,GAAG,CAAA,GAAI,SAAA,CAAU,sBAAA;AAAA,IACtB,CAAC,MAAA,CAAO,IAAA,CAAK,iBAAiB,CAAA,EAAG,UAAA,CAAW,UAAU,CAAA;AAAA,IACtD;AAAA,GACF;AACA,EAAA,OAAO,GAAA;AACT","file":"index.js","sourcesContent":["/**\n * Raise Constants\n *\n * Mirrors the on-chain program constants for client-side validation\n * and display purposes.\n */\n\n// =============================================================================\n// PDA Seeds\n// =============================================================================\n\nexport const SEEDS = {\n PROJECT: 'project',\n MILESTONE: 'milestone',\n INVESTMENT: 'investment',\n VOTE: 'vote',\n ESCROW: 'escrow',\n PIVOT: 'pivot',\n PIVOT_PROPOSAL: 'pivot_proposal',\n TGE_ESCROW: 'tge_escrow',\n TGE_ESCROW_VAULT: 'tge_escrow_vault',\n SCAM_REPORT: 'scam_report',\n ADMIN_CONFIG: 'admin-config',\n NFT_MINT: 'nft_mint',\n AUTHORITY: 'authority',\n} as const;\n\n// =============================================================================\n// Validation Constants\n// =============================================================================\n\nexport const VALIDATION = {\n /** Minimum number of milestones per project */\n MIN_MILESTONES: 2,\n /** Maximum number of milestones per project */\n MAX_MILESTONES: 10,\n /** Milestone percentages must sum to this value */\n MILESTONE_PERCENTAGE_SUM: 100,\n /** Maximum funding buffer (110% of goal) */\n MAX_FUNDING_BUFFER_PERCENT: 110,\n /** Maximum metadata URI length */\n MAX_METADATA_URI_LENGTH: 200,\n /** Maximum pivot description length */\n MAX_PIVOT_DESCRIPTION_LEN: 256,\n /** Maximum pivot vision length */\n MAX_PIVOT_VISION_LEN: 512,\n /** Maximum pivot justification length */\n MAX_PIVOT_JUSTIFICATION_LEN: 512,\n} as const;\n\n// =============================================================================\n// Timing Constants (in seconds)\n// =============================================================================\n\nexport const TIMING = {\n /** Production voting period (14 days) */\n VOTING_PERIOD_SECONDS: 1_209_600,\n /** Production hold period (7 days) */\n HOLD_PERIOD_SECONDS: 604_800,\n /** Inactivity timeout (90 days) */\n INACTIVITY_TIMEOUT_SECONDS: 7_776_000,\n /** Abandonment timeout (90 days) */\n ABANDONMENT_TIMEOUT_SECONDS: 7_776_000,\n /** Refund window (14 days) */\n REFUND_WINDOW_SECONDS: 1_209_600,\n /** Pivot withdrawal window (7 days) */\n PIVOT_WITHDRAWAL_WINDOW_SECONDS: 604_800,\n /** Minimum TGE date (15 days from now) */\n TGE_MIN_DAYS: 1_296_000,\n /** Maximum TGE date (90 days from now) */\n TGE_MAX_DAYS: 7_776_000,\n /** Post-TGE holdback period (30 days) */\n POST_TGE_HOLDBACK_DAYS: 2_592_000,\n} as const;\n\n// =============================================================================\n// Tier Configuration Constraints\n// =============================================================================\n\nexport const TIER_CONSTRAINTS = {\n /** Minimum number of tiers */\n MIN_TIERS: 1,\n /** Maximum number of tiers */\n MAX_TIERS: 10,\n /** Minimum tier amount (10 USDC in lamports) */\n MIN_TIER_AMOUNT: 10_000_000n,\n /** Minimum max_lots per tier */\n MIN_TIER_MAX_LOTS: 1,\n /** Minimum token ratio */\n MIN_TIER_TOKEN_RATIO: 1n,\n /** Minimum vote multiplier (100 = 1.0x) */\n MIN_TIER_VOTE_MULTIPLIER: 100,\n} as const;\n\n// =============================================================================\n// Investment Tiers (Legacy - kept for backwards compatibility)\n// =============================================================================\n\nexport enum InvestmentTier {\n Bronze = 'Bronze',\n Silver = 'Silver',\n Gold = 'Gold',\n Platinum = 'Platinum',\n Diamond = 'Diamond',\n}\n\n/** Investment tier minimum amounts in USDC lamports (6 decimals) - LEGACY */\nexport const TIER_MINIMUMS = {\n [InvestmentTier.Bronze]: 100_000_000n, // 100 USDC\n [InvestmentTier.Silver]: 500_000_000n, // 500 USDC\n [InvestmentTier.Gold]: 1_000_000_000n, // 1,000 USDC\n [InvestmentTier.Platinum]: 5_000_000_000n, // 5,000 USDC\n [InvestmentTier.Diamond]: 10_000_000_000n, // 10,000 USDC\n} as const;\n\n/** Vote weight multipliers (scaled by 100) - LEGACY */\nexport const TIER_VOTE_MULTIPLIERS = {\n [InvestmentTier.Bronze]: 100, // 1.0x\n [InvestmentTier.Silver]: 120, // 1.2x\n [InvestmentTier.Gold]: 150, // 1.5x\n [InvestmentTier.Platinum]: 200, // 2.0x\n [InvestmentTier.Diamond]: 300, // 3.0x\n} as const;\n\n/** Token allocation multipliers (same as vote multipliers) - LEGACY */\nexport const TIER_TOKEN_MULTIPLIERS = {\n [InvestmentTier.Bronze]: 100,\n [InvestmentTier.Silver]: 120,\n [InvestmentTier.Gold]: 150,\n [InvestmentTier.Platinum]: 200,\n [InvestmentTier.Diamond]: 300,\n} as const;\n\n/** Get tier from investment amount (in lamports) - LEGACY, use project.tiers instead */\nexport function getTierFromAmount(amount: bigint): InvestmentTier {\n if (amount >= TIER_MINIMUMS[InvestmentTier.Diamond]) return InvestmentTier.Diamond;\n if (amount >= TIER_MINIMUMS[InvestmentTier.Platinum]) return InvestmentTier.Platinum;\n if (amount >= TIER_MINIMUMS[InvestmentTier.Gold]) return InvestmentTier.Gold;\n if (amount >= TIER_MINIMUMS[InvestmentTier.Silver]) return InvestmentTier.Silver;\n return InvestmentTier.Bronze;\n}\n\n/** Get vote multiplier for an investment amount - LEGACY */\nexport function getVoteMultiplier(amount: bigint): number {\n const tier = getTierFromAmount(amount);\n return TIER_VOTE_MULTIPLIERS[tier] / 100;\n}\n\n/** Get token multiplier for an investment amount - LEGACY */\nexport function getTokenMultiplier(amount: bigint): number {\n const tier = getTierFromAmount(amount);\n return TIER_TOKEN_MULTIPLIERS[tier] / 100;\n}\n\n/**\n * Find matching tier index for an investment amount (threshold-based)\n * Returns the highest tier where amount >= tier.amount\n */\nexport function findTierIndex(tiers: Array<{ amount: bigint }>, amount: bigint): number | null {\n for (let i = tiers.length - 1; i >= 0; i--) {\n if (amount >= tiers[i].amount) {\n return i;\n }\n }\n return null;\n}\n\n// =============================================================================\n// Voting and Governance\n// =============================================================================\n\nexport const GOVERNANCE = {\n /** Scam report threshold (30%) */\n SCAM_THRESHOLD_PERCENT: 30,\n /** Consecutive milestone failures before exit window eligible */\n CONSECUTIVE_FAILURES_THRESHOLD: 3,\n /** Milestone approval threshold (>50% weighted approval per whitepaper voting.md:100-101) */\n MILESTONE_APPROVAL_THRESHOLD_PERCENT: 50,\n} as const;\n\n// =============================================================================\n// NFT Constants\n// =============================================================================\n\nexport const NFT = {\n /** NFT symbol */\n SYMBOL: 'SNI',\n /** NFT name prefix */\n NAME_PREFIX: 'Raise Investment #',\n /** Royalty basis points (2%) */\n ROYALTY_BASIS_POINTS: 200,\n} as const;\n\n// =============================================================================\n// USDC Constants\n// =============================================================================\n\nexport const USDC = {\n /** USDC decimals */\n DECIMALS: 6,\n /** Convert USDC to lamports */\n toAmount: (usdc: number): bigint => BigInt(Math.floor(usdc * 10 ** 6)),\n /** Convert lamports to USDC */\n fromAmount: (lamports: bigint): number => Number(lamports) / 10 ** 6,\n} as const;\n","/**\n * Raise PDA Derivation Helpers\n *\n * All PDA derivation functions for the Raise program.\n * PDAs are deterministic addresses derived from seeds and program ID.\n */\n\nimport { PublicKey } from '@solana/web3.js';\nimport { BN } from '@coral-xyz/anchor';\nimport { SEEDS } from '../constants/index.js';\n\n/**\n * Ensure value is a proper BN instance\n * This handles cases where BN objects lose their prototype chain\n * (e.g., when passing through React state or JSON serialization)\n *\n * Uses duck typing instead of instanceof to handle different BN module instances\n */\nfunction ensureBN(value: BN | number | string | { toString(): string }): BN {\n // Duck typing: if it has toArrayLike, it's BN-like and we can use it\n if (value && typeof (value as BN).toArrayLike === 'function') {\n return value as BN;\n }\n // Always create a fresh BN from the SDK's imported BN class\n return new BN(String(value));\n}\n\n/**\n * Derive Project PDA from project ID\n *\n * @param projectId - Unique project identifier\n * @param programId - Raise program ID\n * @returns Project account PDA\n */\nexport function getProjectPDA(projectId: BN | number | string, programId: PublicKey): PublicKey {\n const projectIdBN = ensureBN(projectId);\n const [pda] = PublicKey.findProgramAddressSync(\n [Buffer.from(SEEDS.PROJECT), projectIdBN.toArrayLike(Buffer, 'le', 8)],\n programId\n );\n return pda;\n}\n\n/**\n * Derive Escrow PDA from project ID\n *\n * @param projectId - Project identifier\n * @param programId - Raise program ID\n * @returns Escrow account PDA\n */\nexport function getEscrowPDA(projectId: BN | number | string, programId: PublicKey): PublicKey {\n const projectIdBN = ensureBN(projectId);\n const [pda] = PublicKey.findProgramAddressSync(\n [Buffer.from(SEEDS.ESCROW), projectIdBN.toArrayLike(Buffer, 'le', 8)],\n programId\n );\n return pda;\n}\n\n/**\n * Derive Milestone PDA from project PDA and milestone index\n *\n * @param projectPda - Project account PDA\n * @param milestoneIndex - Milestone index (0-based)\n * @param programId - Raise program ID\n * @returns Milestone account PDA\n */\nexport function getMilestonePDA(\n projectPda: PublicKey,\n milestoneIndex: number,\n programId: PublicKey\n): PublicKey {\n const [pda] = PublicKey.findProgramAddressSync(\n [\n Buffer.from(SEEDS.MILESTONE),\n projectPda.toBuffer(),\n Buffer.from([milestoneIndex]),\n ],\n programId\n );\n return pda;\n}\n\n/**\n * Derive Investment PDA from project PDA and NFT mint\n *\n * @param projectPda - Project account PDA\n * @param nftMint - Investment NFT mint address\n * @param programId - Raise program ID\n * @returns Investment account PDA\n */\nexport function getInvestmentPDA(\n projectPda: PublicKey,\n nftMint: PublicKey,\n programId: PublicKey\n): PublicKey {\n const [pda] = PublicKey.findProgramAddressSync(\n [\n Buffer.from(SEEDS.INVESTMENT),\n projectPda.toBuffer(),\n nftMint.toBuffer(),\n ],\n programId\n );\n return pda;\n}\n\n/**\n * Derive Vote PDA from milestone PDA, voter key, and voting round\n *\n * @param milestonePda - Milestone account PDA\n * @param voterKey - Voter's public key\n * @param votingRound - Current voting round (0 initially, incremented on resubmit)\n * @param programId - Raise program ID\n * @returns Vote account PDA\n */\nexport function getVotePDA(\n milestonePda: PublicKey,\n voterKey: PublicKey,\n votingRound: number,\n programId: PublicKey\n): PublicKey {\n const [pda] = PublicKey.findProgramAddressSync(\n [Buffer.from(SEEDS.VOTE), milestonePda.toBuffer(), voterKey.toBuffer(), Buffer.from([votingRound])],\n programId\n );\n return pda;\n}\n\n/**\n * Derive PivotProposal PDA from project PDA and pivot count\n *\n * @param projectPda - Project account PDA\n * @param pivotCount - Current pivot count from project account\n * @param programId - Raise program ID\n * @returns PivotProposal account PDA\n */\nexport function getPivotProposalPDA(\n projectPda: PublicKey,\n pivotCount: number,\n programId: PublicKey\n): PublicKey {\n const [pda] = PublicKey.findProgramAddressSync(\n [\n Buffer.from(SEEDS.PIVOT), // Use PIVOT seed, not PIVOT_PROPOSAL\n projectPda.toBuffer(),\n Buffer.from([pivotCount]), // pivot_count is u8 (1 byte) on-chain\n ],\n programId\n );\n return pda;\n}\n\n/**\n * Derive TgeEscrow PDA from project PDA\n *\n * @param projectPda - Project account PDA\n * @param programId - Raise program ID\n * @returns TgeEscrow account PDA\n */\nexport function getTgeEscrowPDA(\n projectPda: PublicKey,\n programId: PublicKey\n): PublicKey {\n const [pda] = PublicKey.findProgramAddressSync(\n [Buffer.from(SEEDS.TGE_ESCROW), projectPda.toBuffer()],\n programId\n );\n return pda;\n}\n\n/**\n * Derive TgeEscrowVault PDA from project PDA\n * Used for holding 10% USDC holdback from final milestone\n *\n * @param projectPda - Project account PDA\n * @param programId - Raise program ID\n * @returns TgeEscrowVault PDA\n */\nexport function getTgeEscrowVaultPDA(\n projectPda: PublicKey,\n programId: PublicKey\n): PublicKey {\n const [pda] = PublicKey.findProgramAddressSync(\n [Buffer.from(SEEDS.TGE_ESCROW_VAULT), projectPda.toBuffer()],\n programId\n );\n return pda;\n}\n\n/**\n * Derive TokenVault PDA from project PDA\n * Used for holding project tokens for investor distribution\n *\n * @param projectPda - Project account PDA\n * @param programId - Raise program ID\n * @returns TokenVault PDA\n */\nexport function getTokenVaultPDA(\n projectPda: PublicKey,\n programId: PublicKey\n): PublicKey {\n const [pda] = PublicKey.findProgramAddressSync(\n [Buffer.from('token_vault'), projectPda.toBuffer()],\n programId\n );\n return pda;\n}\n\n/**\n * Derive ScamReport PDA from project PDA and NFT mint\n *\n * @param projectPda - Project account PDA\n * @param nftMint - Reporter's NFT mint address\n * @param programId - Raise program ID\n * @returns ScamReport account PDA\n */\nexport function getScamReportPDA(\n projectPda: PublicKey,\n nftMint: PublicKey,\n programId: PublicKey\n): PublicKey {\n const [pda] = PublicKey.findProgramAddressSync(\n [\n Buffer.from(SEEDS.SCAM_REPORT),\n projectPda.toBuffer(),\n nftMint.toBuffer(),\n ],\n programId\n );\n return pda;\n}\n\n/**\n * Derive AdminConfig PDA (global admin authority)\n *\n * @param programId - Raise program ID\n * @returns AdminConfig account PDA\n */\nexport function getAdminConfigPDA(programId: PublicKey): PublicKey {\n const [pda] = PublicKey.findProgramAddressSync(\n [Buffer.from(SEEDS.ADMIN_CONFIG)],\n programId\n );\n return pda;\n}\n\n/**\n * Derive NFT Mint PDA\n *\n * @param projectId - Project identifier\n * @param investor - Investor's public key\n * @param investmentCount - Investment count (u64 in Rust, 8 bytes LE)\n * @param programId - Raise program ID\n * @returns NFT Mint PDA and bump\n */\nexport function getNftMintPDA(\n projectId: BN | number | string,\n investor: PublicKey,\n investmentCount: BN | number,\n programId: PublicKey\n): [PublicKey, number] {\n // Ensure both values are proper BN instances (handles prototype chain issues)\n const projectIdBN = ensureBN(projectId);\n const countBN = ensureBN(investmentCount);\n return PublicKey.findProgramAddressSync(\n [\n Buffer.from(SEEDS.NFT_MINT),\n projectIdBN.toArrayLike(Buffer, 'le', 8),\n investor.toBuffer(),\n countBN.toArrayLike(Buffer, 'le', 8), // u64 is 8 bytes LE\n ],\n programId\n );\n}\n\n/**\n * Derive Program Authority PDA\n *\n * @param programId - Raise program ID\n * @returns Program authority PDA and bump\n */\nexport function getProgramAuthorityPDA(programId: PublicKey): [PublicKey, number] {\n return PublicKey.findProgramAddressSync(\n [Buffer.from(SEEDS.AUTHORITY)],\n programId\n );\n}\n\n/**\n * Helper to derive all PDAs for a project\n *\n * @param projectId - Project identifier\n * @param programId - Raise program ID\n * @returns Object with project and escrow PDAs\n */\nexport function getProjectPDAs(projectId: BN, programId: PublicKey) {\n const project = getProjectPDA(projectId, programId);\n const escrow = getEscrowPDA(projectId, programId);\n return { project, escrow };\n}\n\n// =============================================================================\n// ZTM v2.0 PDAs\n// =============================================================================\n\n/**\n * Derive Tokenomics PDA from project PDA\n */\nexport function getTokenomicsPDA(projectPda: PublicKey, programId: PublicKey): PublicKey {\n const [pda] = PublicKey.findProgramAddressSync(\n [Buffer.from('tokenomics'), projectPda.toBuffer()],\n programId\n );\n return pda;\n}\n\n/**\n * Derive Token Mint PDA from project PDA\n */\nexport function getTokenMintPDA(projectPda: PublicKey, programId: PublicKey): PublicKey {\n const [pda] = PublicKey.findProgramAddressSync(\n [Buffer.from('token_mint'), projectPda.toBuffer()],\n programId\n );\n return pda;\n}\n\n/**\n * Derive Vault Authority PDA from project PDA\n */\nexport function getVaultAuthorityPDA(projectPda: PublicKey, programId: PublicKey): PublicKey {\n const [pda] = PublicKey.findProgramAddressSync(\n [Buffer.from('vault_authority'), projectPda.toBuffer()],\n programId\n );\n return pda;\n}\n\n/**\n * Derive Investor Vault PDA from project PDA\n */\nexport function getInvestorVaultPDA(projectPda: PublicKey, programId: PublicKey): PublicKey {\n const [pda] = PublicKey.findProgramAddressSync(\n [Buffer.from('investor_vault'), projectPda.toBuffer()],\n programId\n );\n return pda;\n}\n\n/**\n * Derive Founder Vault PDA from project PDA\n */\nexport function getFounderVaultPDA(projectPda: PublicKey, programId: PublicKey): PublicKey {\n const [pda] = PublicKey.findProgramAddressSync(\n [Buffer.from('founder_vault'), projectPda.toBuffer()],\n programId\n );\n return pda;\n}\n\n/**\n * Derive LP Token Vault PDA from project PDA\n */\nexport function getLpTokenVaultPDA(projectPda: PublicKey, programId: PublicKey): PublicKey {\n const [pda] = PublicKey.findProgramAddressSync(\n [Buffer.from('lp_token_vault'), projectPda.toBuffer()],\n programId\n );\n return pda;\n}\n\n/**\n * Derive Treasury Vault PDA from project PDA\n */\nexport function getTreasuryVaultPDA(projectPda: PublicKey, programId: PublicKey): PublicKey {\n const [pda] = PublicKey.findProgramAddressSync(\n [Buffer.from('treasury_vault'), projectPda.toBuffer()],\n programId\n );\n return pda;\n}\n\n/**\n * Derive LP USDC Vault PDA from project PDA\n */\nexport function getLpUsdcVaultPDA(projectPda: PublicKey, programId: PublicKey): PublicKey {\n const [pda] = PublicKey.findProgramAddressSync(\n [Buffer.from('lp_usdc_vault'), projectPda.toBuffer()],\n programId\n );\n return pda;\n}\n\n/**\n * Derive Founder Vesting PDA from project PDA\n */\nexport function getFounderVestingPDA(projectPda: PublicKey, programId: PublicKey): PublicKey {\n const [pda] = PublicKey.findProgramAddressSync(\n [Buffer.from('founder_vesting'), projectPda.toBuffer()],\n programId\n );\n return pda;\n}\n"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/types/index.ts
|
|
4
|
+
var ProjectState = /* @__PURE__ */ ((ProjectState2) => {
|
|
5
|
+
ProjectState2["Draft"] = "draft";
|
|
6
|
+
ProjectState2["PendingApproval"] = "pendingApproval";
|
|
7
|
+
ProjectState2["Open"] = "open";
|
|
8
|
+
ProjectState2["Funded"] = "funded";
|
|
9
|
+
ProjectState2["InProgress"] = "inProgress";
|
|
10
|
+
ProjectState2["Completed"] = "completed";
|
|
11
|
+
ProjectState2["Abandoned"] = "abandoned";
|
|
12
|
+
ProjectState2["Failed"] = "failed";
|
|
13
|
+
ProjectState2["TGEFailed"] = "tgeFailed";
|
|
14
|
+
ProjectState2["Cancelled"] = "cancelled";
|
|
15
|
+
return ProjectState2;
|
|
16
|
+
})(ProjectState || {});
|
|
17
|
+
var MilestoneState = /* @__PURE__ */ ((MilestoneState2) => {
|
|
18
|
+
MilestoneState2["Proposed"] = "proposed";
|
|
19
|
+
MilestoneState2["Approved"] = "approved";
|
|
20
|
+
MilestoneState2["InProgress"] = "inProgress";
|
|
21
|
+
MilestoneState2["UnderReview"] = "underReview";
|
|
22
|
+
MilestoneState2["Passed"] = "passed";
|
|
23
|
+
MilestoneState2["Failed"] = "failed";
|
|
24
|
+
MilestoneState2["Unlocked"] = "unlocked";
|
|
25
|
+
return MilestoneState2;
|
|
26
|
+
})(MilestoneState || {});
|
|
27
|
+
var VoteChoice = /* @__PURE__ */ ((VoteChoice2) => {
|
|
28
|
+
VoteChoice2["Good"] = "good";
|
|
29
|
+
VoteChoice2["Bad"] = "bad";
|
|
30
|
+
return VoteChoice2;
|
|
31
|
+
})(VoteChoice || {});
|
|
32
|
+
var PivotState = /* @__PURE__ */ ((PivotState2) => {
|
|
33
|
+
PivotState2["PendingModeratorApproval"] = "pendingModeratorApproval";
|
|
34
|
+
PivotState2["ApprovedAwaitingInvestorWindow"] = "approvedAwaitingInvestorWindow";
|
|
35
|
+
PivotState2["Finalized"] = "finalized";
|
|
36
|
+
return PivotState2;
|
|
37
|
+
})(PivotState || {});
|
|
38
|
+
|
|
39
|
+
exports.MilestoneState = MilestoneState;
|
|
40
|
+
exports.PivotState = PivotState;
|
|
41
|
+
exports.ProjectState = ProjectState;
|
|
42
|
+
exports.VoteChoice = VoteChoice;
|
|
43
|
+
//# sourceMappingURL=index.cjs.map
|
|
44
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/types/index.ts"],"names":["ProjectState","MilestoneState","VoteChoice","PivotState"],"mappings":";;;AAaO,IAAK,YAAA,qBAAAA,aAAAA,KAAL;AACL,EAAAA,cAAA,OAAA,CAAA,GAAQ,OAAA;AACR,EAAAA,cAAA,iBAAA,CAAA,GAAkB,iBAAA;AAClB,EAAAA,cAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,cAAA,QAAA,CAAA,GAAS,QAAA;AACT,EAAAA,cAAA,YAAA,CAAA,GAAa,YAAA;AACb,EAAAA,cAAA,WAAA,CAAA,GAAY,WAAA;AACZ,EAAAA,cAAA,WAAA,CAAA,GAAY,WAAA;AACZ,EAAAA,cAAA,QAAA,CAAA,GAAS,QAAA;AACT,EAAAA,cAAA,WAAA,CAAA,GAAY,WAAA;AACZ,EAAAA,cAAA,WAAA,CAAA,GAAY,WAAA;AAVF,EAAA,OAAAA,aAAAA;AAAA,CAAA,EAAA,YAAA,IAAA,EAAA;AAaL,IAAK,cAAA,qBAAAC,eAAAA,KAAL;AACL,EAAAA,gBAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,gBAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,gBAAA,YAAA,CAAA,GAAa,YAAA;AACb,EAAAA,gBAAA,aAAA,CAAA,GAAc,aAAA;AACd,EAAAA,gBAAA,QAAA,CAAA,GAAS,QAAA;AACT,EAAAA,gBAAA,QAAA,CAAA,GAAS,QAAA;AACT,EAAAA,gBAAA,UAAA,CAAA,GAAW,UAAA;AAPD,EAAA,OAAAA,eAAAA;AAAA,CAAA,EAAA,cAAA,IAAA,EAAA;AAUL,IAAK,UAAA,qBAAAC,WAAAA,KAAL;AACL,EAAAA,YAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,YAAA,KAAA,CAAA,GAAM,KAAA;AAFI,EAAA,OAAAA,WAAAA;AAAA,CAAA,EAAA,UAAA,IAAA,EAAA;AAKL,IAAK,UAAA,qBAAAC,WAAAA,KAAL;AACL,EAAAA,YAAA,0BAAA,CAAA,GAA2B,0BAAA;AAC3B,EAAAA,YAAA,gCAAA,CAAA,GAAiC,gCAAA;AACjC,EAAAA,YAAA,WAAA,CAAA,GAAY,WAAA;AAHF,EAAA,OAAAA,WAAAA;AAAA,CAAA,EAAA,UAAA,IAAA,EAAA","file":"index.cjs","sourcesContent":["/**\n * Raise Type Definitions\n *\n * Re-exports types from the IDL and provides additional utility types.\n */\n\nimport { PublicKey } from '@solana/web3.js';\nimport { BN } from '@coral-xyz/anchor';\n\n// =============================================================================\n// Project State Enums\n// =============================================================================\n\nexport enum ProjectState {\n Draft = 'draft',\n PendingApproval = 'pendingApproval',\n Open = 'open',\n Funded = 'funded',\n InProgress = 'inProgress',\n Completed = 'completed',\n Abandoned = 'abandoned',\n Failed = 'failed',\n TGEFailed = 'tgeFailed',\n Cancelled = 'cancelled',\n}\n\nexport enum MilestoneState {\n Proposed = 'proposed',\n Approved = 'approved',\n InProgress = 'inProgress',\n UnderReview = 'underReview',\n Passed = 'passed',\n Failed = 'failed',\n Unlocked = 'unlocked',\n}\n\nexport enum VoteChoice {\n Good = 'good',\n Bad = 'bad',\n}\n\nexport enum PivotState {\n PendingModeratorApproval = 'pendingModeratorApproval',\n ApprovedAwaitingInvestorWindow = 'approvedAwaitingInvestorWindow',\n Finalized = 'finalized',\n}\n\n// =============================================================================\n// Account Types\n// =============================================================================\n\n/**\n * Tier configuration stored on-chain (includes filled_lots)\n */\nexport interface Tier {\n /** USDC amount per lot */\n amount: BN;\n /** Maximum lots available */\n maxLots: number;\n /** Currently filled lots */\n filledLots: number;\n /** Token allocation per $1 invested */\n tokenRatio: BN;\n /** Vote weight multiplier (basis points, 100 = 1.0x) */\n voteMultiplier: number;\n}\n\n/**\n * Tier configuration input for project initialization\n * Founders pass these when creating a project\n */\nexport interface TierConfig {\n /** USDC amount per lot (must be >= 10 USDC = 10_000_000 lamports) */\n amount: BN;\n /** Maximum lots available (must be >= 1) */\n maxLots: number;\n /** Token allocation per $1 invested (must be >= 1) */\n tokenRatio: BN;\n /** Vote weight multiplier (basis points, must be >= 100 = 1.0x) */\n voteMultiplier: number;\n}\n\nexport interface ProjectAccount {\n founder: PublicKey;\n projectId: BN;\n fundingGoal: BN;\n amountRaised: BN;\n state: ProjectState;\n metadataUri: string;\n escrow: PublicKey;\n currentMilestone: number;\n totalMilestones: number;\n /** Number of active tiers (1-10) */\n tierCount: number;\n /** All tier slots (only first tierCount are active) */\n tiers: Tier[];\n tokenMint: PublicKey | null;\n tgeDate: BN | null;\n tokensDeposited: BN;\n tokenAllocationBps: number;\n totalTokenAllocation: BN;\n consecutiveFailures: number;\n investorCount: number;\n bump: number;\n}\n\nexport interface MilestoneAccount {\n project: PublicKey;\n milestoneIndex: number;\n percentage: number;\n description: string;\n state: MilestoneState;\n yesVotes: BN;\n noVotes: BN;\n totalWeight: BN;\n voterCount: number;\n votingEndsAt: BN | null;\n bump: number;\n}\n\nexport interface InvestmentAccount {\n project: PublicKey;\n investor: PublicKey;\n nftMint: PublicKey;\n amount: BN;\n voteWeight: BN;\n tokenAllocation: BN;\n tier: number;\n investedAt: BN;\n tokensClaimed: boolean;\n withdrawnFromPivot: boolean;\n refundClaimed: boolean;\n bump: number;\n}\n\nexport interface VoteAccount {\n milestone: PublicKey;\n voter: PublicKey;\n choice: VoteChoice;\n weight: BN;\n votedAt: BN;\n bump: number;\n}\n\nexport interface AdminConfigAccount {\n admin: PublicKey;\n pendingAdmin: PublicKey | null;\n bump: number;\n}\n\nexport interface PivotProposalAccount {\n project: PublicKey;\n newMetadataUri: string;\n newMilestones: Array<{ percentage: number; description: string }>;\n state: PivotState;\n proposedAt: BN;\n approvedAt: BN | null;\n withdrawalWindowEndsAt: BN | null;\n withdrawnAmount: BN;\n withdrawnCount: number;\n bump: number;\n}\n\nexport interface TgeEscrowAccount {\n project: PublicKey;\n holdbackAmount: BN;\n scamReports: BN;\n scamWeight: BN;\n scamConfirmed: boolean;\n holdbackReleased: boolean;\n bump: number;\n}\n\n// =============================================================================\n// Instruction Arguments\n// =============================================================================\n\nexport interface InitializeProjectArgs {\n projectId: BN;\n fundingGoal: BN;\n metadataUri: string;\n /** Founder-configured tiers (1-10 tiers) */\n tiers: TierConfig[];\n}\n\nexport interface CreateMilestoneArgs {\n milestoneIndex: number;\n percentage: number;\n description: string;\n}\n\nexport interface InvestArgs {\n amount: BN;\n}\n\nexport interface VoteOnMilestoneArgs {\n choice: VoteChoice;\n}\n\nexport interface SetTgeDateArgs {\n tgeDate: BN;\n tokenMint: PublicKey;\n}\n\nexport interface DepositTokensArgs {\n amount: BN;\n}\n\nexport interface ProposePivotArgs {\n newMetadataUri: string;\n newMilestones: Array<{ percentage: number; description: string }>;\n}\n\n// =============================================================================\n// Event Types\n// =============================================================================\n\nexport interface ProjectCreatedEvent {\n projectId: BN;\n founder: PublicKey;\n fundingGoal: BN;\n metadataUri: string;\n}\n\nexport interface InvestmentMadeEvent {\n projectId: BN;\n investor: PublicKey;\n amount: BN;\n nftMint: PublicKey;\n tier: number;\n voteWeight: BN;\n}\n\nexport interface MilestoneVoteCastEvent {\n projectId: BN;\n milestoneIndex: number;\n voter: PublicKey;\n choice: VoteChoice;\n weight: BN;\n}\n\nexport interface MilestoneVoteFinalizedEvent {\n projectId: BN;\n milestoneIndex: number;\n passed: boolean;\n yesVotes: BN;\n noVotes: BN;\n}\n\n// =============================================================================\n// Utility Types\n// =============================================================================\n\nexport interface InvestmentWithKey {\n publicKey: PublicKey;\n account: InvestmentAccount;\n}\n\nexport interface MilestoneWithKey {\n publicKey: PublicKey;\n account: MilestoneAccount;\n}\n\nexport interface VoteWithKey {\n publicKey: PublicKey;\n account: VoteAccount;\n}\n"]}
|