use serde::{Deserialize, Serialize};
use steel::*;

use crate::state::auction_pool_pda;

use super::OilAccount;

/// Auction Pool account (per-epoch pool)
/// PDA: [AUCTION_POOL, well_id, epoch_id]
/// This account holds SOL contributions for this specific epoch/auction
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
pub struct AuctionPool {
    /// Well ID (0-3) - which well this pool is for
    pub well_id: u64,
    
    /// Epoch ID - which auction round this pool belongs to
    pub epoch_id: u64,
    
    /// Total SOL in this pool (sum of all contributions for this epoch, in lamports)
    pub pool_total: u64,
    
    /// Status: 0 = active, 1 = settled/abandoned (for refunds)
    /// When pool doesn't win and auction ends, status = 1
    pub status: u64,
    
    /// Buffer fields
    pub buffer_a: u64,
    pub buffer_b: u64,
    pub buffer_c: u64,
    pub buffer_d: u64,
}

impl AuctionPool {
    pub fn pda(well_id: u64, epoch_id: u64) -> (Pubkey, u8) {
        auction_pool_pda(well_id, epoch_id)
    }
}

account!(OilAccount, AuctionPool);

