oil_api/state/
auction_pool.rs

1use serde::{Deserialize, Serialize};
2use steel::*;
3
4use crate::state::auction_pool_pda;
5
6use super::OilAccount;
7
8/// Auction Pool account (per-epoch pool)
9/// PDA: [AUCTION_POOL, well_id, epoch_id]
10/// This account holds SOL contributions for this specific epoch/auction
11#[repr(C)]
12#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
13pub struct AuctionPool {
14    /// Well ID (0-3) - which well this pool is for
15    pub well_id: u64,
16    
17    /// Epoch ID - which auction round this pool belongs to
18    pub epoch_id: u64,
19    
20    /// Total SOL in this pool (sum of all contributions for this epoch, in lamports)
21    pub pool_total: u64,
22    
23    /// Status: 0 = active, 1 = settled/abandoned (for refunds)
24    /// When pool doesn't win and auction ends, status = 1
25    pub status: u64,
26    
27    /// Original pool_total from when the pool won (before bid_amount was deducted)
28    /// Used for calculating proportional shares when pool is outbid
29    /// Stored here to avoid overwrite issues when multiple pools are outbid sequentially
30    pub original_pool_total: u64,
31    
32    /// Accumulated OIL from this pool when it was outbid by a solo bidder
33    /// Pool contributors can claim their proportional share from this amount
34    /// Stored per-epoch to avoid accumulation/overwrite issues
35    pub pool_accumulated_oil: u64,
36    
37    /// 86% SOL from bidder when this pool was outbid (for proportional distribution to pool contributors)
38    /// Pool contributors can claim their proportional share from this amount
39    /// Stored per-epoch to avoid accumulation/overwrite issues
40    pub pool_outbid_sol: u64,
41    
42    /// Buffer field
43    pub buffer_d: u64,
44}
45
46impl AuctionPool {
47    pub fn pda(well_id: u64, epoch_id: u64) -> (Pubkey, u8) {
48        auction_pool_pda(well_id, epoch_id)
49    }
50}
51
52account!(OilAccount, AuctionPool);
53