1use solana_program::pubkey::Pubkey;
2
3pub const DELEGATION_RECORD_TAG: &[u8] = b"delegation";
4#[macro_export]
5macro_rules! delegation_record_seeds_from_delegated_account {
6 ($delegated_account: expr) => {
7 &[
8 $crate::pda::DELEGATION_RECORD_TAG,
9 &$delegated_account.as_ref(),
10 ]
11 };
12}
13
14pub const DELEGATION_METADATA_TAG: &[u8] = b"delegation-metadata";
15#[macro_export]
16macro_rules! delegation_metadata_seeds_from_delegated_account {
17 ($delegated_account: expr) => {
18 &[
19 $crate::pda::DELEGATION_METADATA_TAG,
20 &$delegated_account.as_ref(),
21 ]
22 };
23}
24
25pub const COMMIT_STATE_TAG: &[u8] = b"state-diff";
26#[macro_export]
27macro_rules! commit_state_seeds_from_delegated_account {
28 ($delegated_account: expr) => {
29 &[$crate::pda::COMMIT_STATE_TAG, &$delegated_account.as_ref()]
30 };
31}
32
33pub const COMMIT_RECORD_TAG: &[u8] = b"commit-state-record";
34#[macro_export]
35macro_rules! commit_record_seeds_from_delegated_account {
36 ($delegated_account: expr) => {
37 &[$crate::pda::COMMIT_RECORD_TAG, &$delegated_account.as_ref()]
38 };
39}
40
41pub const DELEGATE_BUFFER_TAG: &[u8] = b"buffer";
42#[macro_export]
43macro_rules! delegate_buffer_seeds_from_delegated_account {
44 ($delegated_account: expr) => {
45 &[
46 $crate::pda::DELEGATE_BUFFER_TAG,
47 &$delegated_account.as_ref(),
48 ]
49 };
50}
51
52pub const UNDELEGATE_BUFFER_TAG: &[u8] = b"undelegate-buffer";
53#[macro_export]
54macro_rules! undelegate_buffer_seeds_from_delegated_account {
55 ($delegated_account: expr) => {
56 &[
57 $crate::pda::UNDELEGATE_BUFFER_TAG,
58 &$delegated_account.as_ref(),
59 ]
60 };
61}
62
63#[macro_export]
64macro_rules! fees_vault_seeds {
65 () => {
66 &[b"fees-vault"]
67 };
68}
69
70pub const VALIDATOR_FEES_VAULT_TAG: &[u8] = b"v-fees-vault";
71#[macro_export]
72macro_rules! validator_fees_vault_seeds_from_validator {
73 ($validator: expr) => {
74 &[$crate::pda::VALIDATOR_FEES_VAULT_TAG, &$validator.as_ref()]
75 };
76}
77
78pub const PROGRAM_CONFIG_TAG: &[u8] = b"p-conf";
79#[macro_export]
80macro_rules! program_config_seeds_from_program_id {
81 ($program_id: expr) => {
82 &[$crate::pda::PROGRAM_CONFIG_TAG, &$program_id.as_ref()]
83 };
84}
85
86pub const MAGIC_FEE_VAULT_TAG: &[u8] = b"magic-fee-vault";
87#[macro_export]
88macro_rules! magic_fee_vault_seeds_from_validator {
89 ($validator: expr) => {
90 &[$crate::pda::MAGIC_FEE_VAULT_TAG, &$validator.as_ref()]
91 };
92}
93
94pub fn magic_fee_vault_pda_from_validator(validator: &Pubkey) -> Pubkey {
95 Pubkey::find_program_address(
96 magic_fee_vault_seeds_from_validator!(validator),
97 &crate::id(),
98 )
99 .0
100}
101
102pub const EPHEMERAL_BALANCE_TAG: &[u8] = b"balance";
103#[macro_export]
104macro_rules! ephemeral_balance_seeds_from_payer {
105 ($payer: expr, $index: expr) => {
106 &[
107 $crate::pda::EPHEMERAL_BALANCE_TAG,
108 &$payer.as_ref(),
109 &[$index],
110 ]
111 };
112}
113
114pub fn delegation_record_pda_from_delegated_account(
115 delegated_account: &Pubkey,
116) -> Pubkey {
117 Pubkey::find_program_address(
118 delegation_record_seeds_from_delegated_account!(delegated_account),
119 &crate::id(),
120 )
121 .0
122}
123
124pub fn delegation_metadata_pda_from_delegated_account(
125 delegated_account: &Pubkey,
126) -> Pubkey {
127 Pubkey::find_program_address(
128 delegation_metadata_seeds_from_delegated_account!(delegated_account),
129 &crate::id(),
130 )
131 .0
132}
133
134pub fn commit_state_pda_from_delegated_account(
135 delegated_account: &Pubkey,
136) -> Pubkey {
137 Pubkey::find_program_address(
138 commit_state_seeds_from_delegated_account!(delegated_account),
139 &crate::id(),
140 )
141 .0
142}
143
144pub fn commit_record_pda_from_delegated_account(
145 delegated_account: &Pubkey,
146) -> Pubkey {
147 Pubkey::find_program_address(
148 commit_record_seeds_from_delegated_account!(delegated_account),
149 &crate::id(),
150 )
151 .0
152}
153
154pub fn delegate_buffer_pda_from_delegated_account_and_owner_program(
155 delegated_account: &Pubkey,
156 owner_program: &Pubkey,
157) -> Pubkey {
158 Pubkey::find_program_address(
159 delegate_buffer_seeds_from_delegated_account!(delegated_account),
160 owner_program,
161 )
162 .0
163}
164
165pub fn undelegate_buffer_pda_from_delegated_account(
166 delegated_account: &Pubkey,
167) -> Pubkey {
168 Pubkey::find_program_address(
169 undelegate_buffer_seeds_from_delegated_account!(delegated_account),
170 &crate::id(),
171 )
172 .0
173}
174
175pub fn fees_vault_pda() -> Pubkey {
176 Pubkey::find_program_address(fees_vault_seeds!(), &crate::id()).0
177}
178
179pub fn validator_fees_vault_pda_from_validator(validator: &Pubkey) -> Pubkey {
180 Pubkey::find_program_address(
181 validator_fees_vault_seeds_from_validator!(validator),
182 &crate::id(),
183 )
184 .0
185}
186
187pub fn program_config_from_program_id(program_id: &Pubkey) -> Pubkey {
188 Pubkey::find_program_address(
189 program_config_seeds_from_program_id!(program_id),
190 &crate::id(),
191 )
192 .0
193}
194
195pub fn ephemeral_balance_pda_from_payer(payer: &Pubkey, index: u8) -> Pubkey {
196 Pubkey::find_program_address(
197 ephemeral_balance_seeds_from_payer!(payer, index),
198 &crate::id(),
199 )
200 .0
201}