oil_api/state/auction.rs
1use serde::{Deserialize, Serialize};
2use steel::*;
3
4use crate::state::auction_pda;
5
6use super::OilAccount;
7
8/// Singleton auction configuration account
9#[repr(C)]
10#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
11pub struct Auction {
12 /// Halving period in seconds (28 days = 2,419,200)
13 pub halving_period_seconds: u64,
14
15 /// Timestamp of last halving event
16 pub last_halving_time: u64,
17
18 /// Base mining rates per well (OIL per second, in atomic units)
19 /// Significantly lower than Macaron's rates with high differentiation for strategic choices:
20 /// - Well 0 (Entry): 0.05 OIL/s = 5,000,000,000 atomic units/s (low rate, accessible)
21 /// - Well 1 (Standard): 0.15 OIL/s = 15,000,000,000 atomic units/s (3x Well 0)
22 /// - Well 2 (Premium): 0.35 OIL/s = 35,000,000,000 atomic units/s (7x Well 0, 2.3x Well 1)
23 /// - Well 3 (Elite): 0.65 OIL/s = 65,000,000,000 atomic units/s (13x Well 0, 4.3x Well 1, 1.9x Well 2)
24 /// Total: 1.2 OIL/s (vs Macaron's 4.0 OIL/s) = 70% reduction
25 /// Creates meaningful trade-offs: higher rates = higher competition & prices
26 pub base_mining_rates: [u64; 4],
27
28 /// Auction duration in seconds (1 hour = 3600)
29 pub auction_duration_seconds: u64,
30
31 /// Starting prices per well (in lamports)
32 /// Scaled to match mining rate differentiation for strategic choices:
33 /// - Well 0 (Entry): 0.1 SOL = 100,000,000 lamports (lowest price, accessible)
34 /// - Well 1 (Standard): 0.2 SOL = 200,000,000 lamports (3x Well 0)
35 /// - Well 2 (Premium): 0.3 SOL = 300,000,000 lamports (7x Well 0)
36 /// - Well 3 (Elite): 0.4 SOL = 400,000,000 lamports (13x Well 0)
37 pub starting_prices: [u64; 4],
38
39 /// Minimum contribution to join auction pool (0.01 SOL = 10,000,000 lamports)
40 pub min_pool_contribution: u64,
41
42 /// Buffer field (for future use)
43 pub buffer_a: Numeric,
44
45 /// Buffer field (for future use)
46 pub buffer_b: u64,
47
48 /// Buffer field (for future use)
49 pub buffer_c: u64,
50
51 /// Buffer field (for future use)
52 pub buffer_d: u64,
53}
54
55impl Auction {
56 pub fn pda() -> (Pubkey, u8) {
57 auction_pda()
58 }
59
60 /// Check if halving should be applied (returns number of halvings to apply)
61 /// Note: Actual halving is applied per EpochState in its check_and_apply_halving method
62 pub fn should_apply_halving(&self, clock: &Clock) -> u64 {
63 let current_time = clock.unix_timestamp as u64;
64 let time_since_last_halving = current_time.saturating_sub(self.last_halving_time);
65
66 if time_since_last_halving >= self.halving_period_seconds {
67 time_since_last_halving / self.halving_period_seconds
68 } else {
69 0
70 }
71 }
72}
73
74account!(OilAccount, Auction);
75