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");
53
54/// Program id for const pda derivations
55const PROGRAM_ID: [u8; 32] = unsafe { *(&crate::id() as *const Pubkey as *const [u8; 32]) };
56
57/// The address of the bank account.
58pub const BANK_ADDRESS: Pubkey =
59    Pubkey::new_from_array(ed25519::derive_program_address(&[BANK], &PROGRAM_ID).0);
60
61/// The bump of the bank account.
62pub const BANK_BUMP: u8 = ed25519::derive_program_address(&[BANK], &PROGRAM_ID).1;
63
64/// The address of the config account.
65pub const CONFIG_ADDRESS: Pubkey =
66    Pubkey::new_from_array(ed25519::derive_program_address(&[CONFIG], &PROGRAM_ID).0);
67
68pub const MARS_ESCROW_ADDRESS: Pubkey = Pubkey::new_from_array(
69    ed25519::derive_program_address(
70        &[
71            ESCROW,
72            unsafe { &*(&MARS_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
73            unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
74        ],
75        &PROGRAM_ID,
76    )
77    .0,
78);
79pub const MARS_ESCROW_BUMP: u8 = ed25519::derive_program_address(
80    &[
81        ESCROW,
82        unsafe { &*(&MARS_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
83        unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
84    ],
85    &PROGRAM_ID,
86)
87.1;
88pub const MARS_ESCROW_TOKENS_ADDRESS: Pubkey = Pubkey::new_from_array(
89    ed25519::derive_program_address(
90        &[
91            unsafe { &*(&MARS_ESCROW_ADDRESS as *const Pubkey as *const [u8; 32]) },
92            unsafe { &*(&spl_token::id() as *const Pubkey as *const [u8; 32]) },
93            unsafe { &*(&MARS_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
94        ],
95        unsafe { &*(&spl_associated_token_account::id() as *const Pubkey as *const [u8; 32]) },
96    )
97    .0,
98);
99
100pub const MIRACLE_ESCROW_ADDRESS: Pubkey = Pubkey::new_from_array(
101    ed25519::derive_program_address(
102        &[
103            ESCROW,
104            unsafe { &*(&MIRACLE_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
105            unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
106        ],
107        &PROGRAM_ID,
108    )
109    .0,
110);
111pub const MIRACLE_ESCROW_BUMP: u8 = ed25519::derive_program_address(
112    &[
113        ESCROW,
114        unsafe { &*(&MIRACLE_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
115        unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
116    ],
117    &PROGRAM_ID,
118)
119.1;
120pub const MIRACLE_ESCROW_TOKENS_ADDRESS: Pubkey = Pubkey::new_from_array(
121    ed25519::derive_program_address(
122        &[
123            unsafe { &*(&MIRACLE_ESCROW_ADDRESS as *const Pubkey as *const [u8; 32]) },
124            unsafe { &*(&spl_token::id() as *const Pubkey as *const [u8; 32]) },
125            unsafe { &*(&MIRACLE_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
126        ],
127        unsafe { &*(&spl_associated_token_account::id() as *const Pubkey as *const [u8; 32]) },
128    )
129    .0,
130);
131
132pub const USDC_ESCROW_ADDRESS: Pubkey = Pubkey::new_from_array(
133    ed25519::derive_program_address(
134        &[
135            ESCROW,
136            unsafe { &*(&USDC_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
137            unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
138        ],
139        &PROGRAM_ID,
140    )
141    .0,
142);
143pub const USDC_ESCROW_BUMP: u8 = ed25519::derive_program_address(
144    &[
145        ESCROW,
146        unsafe { &*(&USDC_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
147        unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
148    ],
149    &PROGRAM_ID,
150)
151.1;
152pub const USDC_ESCROW_TOKENS_ADDRESS: Pubkey = Pubkey::new_from_array(
153    ed25519::derive_program_address(
154        &[
155            unsafe { &*(&USDC_ESCROW_ADDRESS as *const Pubkey as *const [u8; 32]) },
156            unsafe { &*(&spl_token::id() as *const Pubkey as *const [u8; 32]) },
157            unsafe { &*(&USDC_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
158        ],
159        unsafe { &*(&spl_associated_token_account::id() as *const Pubkey as *const [u8; 32]) },
160    )
161    .0,
162);
163
164pub const USDT_ESCROW_ADDRESS: Pubkey = Pubkey::new_from_array(
165    ed25519::derive_program_address(
166        &[
167            ESCROW,
168            unsafe { &*(&USDT_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
169            unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
170        ],
171        &PROGRAM_ID,
172    )
173    .0,
174);
175pub const USDT_ESCROW_BUMP: u8 = ed25519::derive_program_address(
176    &[
177        ESCROW,
178        unsafe { &*(&USDT_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
179        unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
180    ],
181    &PROGRAM_ID,
182)
183.1;
184pub const USDT_ESCROW_TOKENS_ADDRESS: Pubkey = Pubkey::new_from_array(
185    ed25519::derive_program_address(
186        &[
187            unsafe { &*(&USDT_ESCROW_ADDRESS as *const Pubkey as *const [u8; 32]) },
188            unsafe { &*(&spl_token::id() as *const Pubkey as *const [u8; 32]) },
189            unsafe { &*(&USDT_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
190        ],
191        unsafe { &*(&spl_associated_token_account::id() as *const Pubkey as *const [u8; 32]) },
192    )
193    .0,
194);
195
196pub const WSOL_ESCROW_ADDRESS: Pubkey = Pubkey::new_from_array(
197    ed25519::derive_program_address(
198        &[
199            ESCROW,
200            unsafe { &*(&WSOL_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
201            unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
202        ],
203        &PROGRAM_ID,
204    )
205    .0,
206);
207pub const WSOL_ESCROW_BUMP: u8 = ed25519::derive_program_address(
208    &[
209        ESCROW,
210        unsafe { &*(&WSOL_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
211        unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
212    ],
213    &PROGRAM_ID,
214)
215.1;
216pub const WSOL_ESCROW_TOKENS_ADDRESS: Pubkey = Pubkey::new_from_array(
217    ed25519::derive_program_address(
218        &[
219            unsafe { &*(&WSOL_ESCROW_ADDRESS as *const Pubkey as *const [u8; 32]) },
220            unsafe { &*(&spl_token::id() as *const Pubkey as *const [u8; 32]) },
221            unsafe { &*(&WSOL_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
222        ],
223        unsafe { &*(&spl_associated_token_account::id() as *const Pubkey as *const [u8; 32]) },
224    )
225    .0,
226);