Skip to main content

escrow_api/
consts.rs

1use const_crypto::ed25519;
2use solana_program::{pubkey, pubkey::Pubkey};
3
4// Test initializer (mac::id.json)
5// pub const INITIALIZER_ADDRESS: Pubkey = pubkey!("Ac2ev4ofDx61tuSJCgq9ToSBfVwHD2a1FVJf6p7TAqiB");
6// Test initializer (mac&hp::test-id.json)
7pub const INITIALIZER_ADDRESS: Pubkey = pubkey!("4ALL9EAVHpv7ioJF95ktDLtrHUEJezPuFxTFFMy3fpSy");
8
9/// The authority allowed to initialize the program.
10// pub const INITIALIZER_ADDRESS: Pubkey = pubkey!("staryJacbXodPh4WfwVtgA5jkJhvsMHERtkdttnLEHc");
11
12/// Basis points denominator for percentage calculations (1 basis point = 0.01%).
13pub const BASIS_POINTS_DENOMINATOR: u128 = 10_000;
14
15pub const DEFAULT_FEE_BPS: u16 = 100; // 1%
16
17/// Closure delay constants (in seconds)
18pub const CLOSURE_DELAY_RELEASE_REFUND: i64 = 7 * 24 * 60 * 60; // 7 days
19pub const CLOSURE_DELAY_CANCEL: i64 = 3 * 24 * 60 * 60; // 3 days
20pub const CLOSURE_DELAY_ARBITRATION: i64 = 3 * 24 * 60 * 60; // 3 days after arbitration
21
22/// TTL (Time To Live) constants (in seconds)
23pub const MIN_TTL_SECONDS: i64 = 24 * 60 * 60; // 1 day minimum
24pub const DEFAULT_TTL_SECONDS: i64 = 14 * 24 * 60 * 60; // 14 days default
25pub const MAX_TTL_SECONDS: i64 = 365 * 24 * 60 * 60; // 365 days maximum
26
27/// Payment state constants
28pub const PAYMENT_STATE_FUNDED: u8 = 0; // Account created and funded atomically
29pub const PAYMENT_STATE_RELEASED: u8 = 1; // Released to seller (normal flow)
30pub const PAYMENT_STATE_REFUNDED: u8 = 2; // Refunded to buyer (normal flow)
31pub const PAYMENT_STATE_DISPUTED: u8 = 3; // Under dispute
32pub const PAYMENT_STATE_ARBITRATED: u8 = 4; // Admin has made arbitration decision
33
34/// The seed of the bank account PDA.
35pub const BANK: &[u8] = b"bank";
36
37/// The seed of the config account PDA.
38pub const CONFIG: &[u8] = b"config";
39
40/// The seed for escrow account PDAs.
41pub const ESCROW: &[u8] = b"escrow";
42
43pub const SOL_STORAGE: &[u8] = b"sol_storage";
44
45/// The seed for payment account PDAs.
46pub const PAYMENT: &[u8] = b"payment";
47
48pub const MARS_MINT_ADDRESS: Pubkey = pubkey!("7RAV5UPRTzxn46kLeA8MiJsdNy9VKc5fip8FWEgTpTHh");
49pub const USDC_MINT_ADDRESS: Pubkey = pubkey!("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
50pub const USDT_MINT_ADDRESS: Pubkey = pubkey!("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB");
51pub const WSOL_MINT_ADDRESS: Pubkey = pubkey!("So11111111111111111111111111111111111111112");
52pub const MIRACLE_MINT_ADDRESS: Pubkey = pubkey!("Mirab4SFVff6sCuK48PPnSUj7PNpDDrBWY6FkJmuifG");
53pub const TESTCOIN_MINT_ADDRESS: Pubkey = pubkey!("2gNCDGj8Xi9Zs7LNQTPWf4pfZvAM7UHusY4xhKNYg6W6");
54
55/// Program id for const pda derivations
56const PROGRAM_ID: [u8; 32] = unsafe { *(&crate::id() as *const Pubkey as *const [u8; 32]) };
57
58/// The address of the bank account.
59pub const BANK_ADDRESS: Pubkey =
60    Pubkey::new_from_array(ed25519::derive_program_address(&[BANK], &PROGRAM_ID).0);
61
62/// The bump of the bank account.
63pub const BANK_BUMP: u8 = ed25519::derive_program_address(&[BANK], &PROGRAM_ID).1;
64
65/// The address of the config account.
66pub const CONFIG_ADDRESS: Pubkey =
67    Pubkey::new_from_array(ed25519::derive_program_address(&[CONFIG], &PROGRAM_ID).0);
68
69pub const MARS_ESCROW_ADDRESS: Pubkey = Pubkey::new_from_array(
70    ed25519::derive_program_address(
71        &[
72            ESCROW,
73            unsafe { &*(&MARS_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
74            unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
75        ],
76        &PROGRAM_ID,
77    )
78    .0,
79);
80pub const MARS_ESCROW_BUMP: u8 = ed25519::derive_program_address(
81    &[
82        ESCROW,
83        unsafe { &*(&MARS_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
84        unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
85    ],
86    &PROGRAM_ID,
87)
88.1;
89pub const MARS_ESCROW_TOKENS_ADDRESS: Pubkey = Pubkey::new_from_array(
90    ed25519::derive_program_address(
91        &[
92            unsafe { &*(&MARS_ESCROW_ADDRESS as *const Pubkey as *const [u8; 32]) },
93            unsafe { &*(&spl_token::id() as *const Pubkey as *const [u8; 32]) },
94            unsafe { &*(&MARS_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
95        ],
96        unsafe { &*(&spl_associated_token_account::id() as *const Pubkey as *const [u8; 32]) },
97    )
98    .0,
99);
100
101pub const MIRACLE_ESCROW_ADDRESS: Pubkey = Pubkey::new_from_array(
102    ed25519::derive_program_address(
103        &[
104            ESCROW,
105            unsafe { &*(&MIRACLE_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
106            unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
107        ],
108        &PROGRAM_ID,
109    )
110    .0,
111);
112pub const MIRACLE_ESCROW_BUMP: u8 = ed25519::derive_program_address(
113    &[
114        ESCROW,
115        unsafe { &*(&MIRACLE_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
116        unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
117    ],
118    &PROGRAM_ID,
119)
120.1;
121pub const MIRACLE_ESCROW_TOKENS_ADDRESS: Pubkey = Pubkey::new_from_array(
122    ed25519::derive_program_address(
123        &[
124            unsafe { &*(&MIRACLE_ESCROW_ADDRESS as *const Pubkey as *const [u8; 32]) },
125            unsafe { &*(&spl_token::id() as *const Pubkey as *const [u8; 32]) },
126            unsafe { &*(&MIRACLE_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
127        ],
128        unsafe { &*(&spl_associated_token_account::id() as *const Pubkey as *const [u8; 32]) },
129    )
130    .0,
131);
132
133pub const USDC_ESCROW_ADDRESS: Pubkey = Pubkey::new_from_array(
134    ed25519::derive_program_address(
135        &[
136            ESCROW,
137            unsafe { &*(&USDC_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
138            unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
139        ],
140        &PROGRAM_ID,
141    )
142    .0,
143);
144pub const USDC_ESCROW_BUMP: u8 = ed25519::derive_program_address(
145    &[
146        ESCROW,
147        unsafe { &*(&USDC_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
148        unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
149    ],
150    &PROGRAM_ID,
151)
152.1;
153pub const USDC_ESCROW_TOKENS_ADDRESS: Pubkey = Pubkey::new_from_array(
154    ed25519::derive_program_address(
155        &[
156            unsafe { &*(&USDC_ESCROW_ADDRESS as *const Pubkey as *const [u8; 32]) },
157            unsafe { &*(&spl_token::id() as *const Pubkey as *const [u8; 32]) },
158            unsafe { &*(&USDC_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
159        ],
160        unsafe { &*(&spl_associated_token_account::id() as *const Pubkey as *const [u8; 32]) },
161    )
162    .0,
163);
164
165pub const USDT_ESCROW_ADDRESS: Pubkey = Pubkey::new_from_array(
166    ed25519::derive_program_address(
167        &[
168            ESCROW,
169            unsafe { &*(&USDT_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
170            unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
171        ],
172        &PROGRAM_ID,
173    )
174    .0,
175);
176pub const USDT_ESCROW_BUMP: u8 = ed25519::derive_program_address(
177    &[
178        ESCROW,
179        unsafe { &*(&USDT_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
180        unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
181    ],
182    &PROGRAM_ID,
183)
184.1;
185pub const USDT_ESCROW_TOKENS_ADDRESS: Pubkey = Pubkey::new_from_array(
186    ed25519::derive_program_address(
187        &[
188            unsafe { &*(&USDT_ESCROW_ADDRESS as *const Pubkey as *const [u8; 32]) },
189            unsafe { &*(&spl_token::id() as *const Pubkey as *const [u8; 32]) },
190            unsafe { &*(&USDT_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
191        ],
192        unsafe { &*(&spl_associated_token_account::id() as *const Pubkey as *const [u8; 32]) },
193    )
194    .0,
195);
196
197pub const WSOL_ESCROW_ADDRESS: Pubkey = Pubkey::new_from_array(
198    ed25519::derive_program_address(
199        &[
200            ESCROW,
201            unsafe { &*(&WSOL_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
202            unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
203        ],
204        &PROGRAM_ID,
205    )
206    .0,
207);
208pub const WSOL_ESCROW_BUMP: u8 = ed25519::derive_program_address(
209    &[
210        ESCROW,
211        unsafe { &*(&WSOL_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
212        unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
213    ],
214    &PROGRAM_ID,
215)
216.1;
217pub const WSOL_ESCROW_TOKENS_ADDRESS: Pubkey = Pubkey::new_from_array(
218    ed25519::derive_program_address(
219        &[
220            unsafe { &*(&WSOL_ESCROW_ADDRESS as *const Pubkey as *const [u8; 32]) },
221            unsafe { &*(&spl_token::id() as *const Pubkey as *const [u8; 32]) },
222            unsafe { &*(&WSOL_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
223        ],
224        unsafe { &*(&spl_associated_token_account::id() as *const Pubkey as *const [u8; 32]) },
225    )
226    .0,
227);
228pub const TESTCOIN_ESCROW_ADDRESS: Pubkey = Pubkey::new_from_array(
229    ed25519::derive_program_address(
230        &[
231            ESCROW,
232            unsafe { &*(&TESTCOIN_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
233            unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
234        ],
235        &PROGRAM_ID,
236    )
237    .0,
238);
239pub const TESTCOIN_ESCROW_BUMP: u8 = ed25519::derive_program_address(
240    &[
241        ESCROW,
242        unsafe { &*(&TESTCOIN_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
243        unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
244    ],
245    &PROGRAM_ID,
246)
247.1;
248pub const TESTCOIN_ESCROW_TOKENS_ADDRESS: Pubkey = Pubkey::new_from_array(
249    ed25519::derive_program_address(
250        &[
251            unsafe { &*(&TESTCOIN_ESCROW_ADDRESS as *const Pubkey as *const [u8; 32]) },
252            unsafe { &*(&spl_token::id() as *const Pubkey as *const [u8; 32]) },
253            unsafe { &*(&TESTCOIN_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
254        ],
255        unsafe { &*(&spl_associated_token_account::id() as *const Pubkey as *const [u8; 32]) },
256    )
257    .0,
258);