oil_api/state/bid.rs
1use serde::{Deserialize, Serialize};
2use steel::*;
3
4use crate::state::bid_pda;
5
6use super::OilAccount;
7
8/// Bid account tracks individual user contributions to auction pools for a specific epoch
9/// PDA: [BID, authority, well_id, epoch_id]
10/// One Bid account per user per well per epoch (Macaron-style)
11#[repr(C)]
12#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
13pub struct Bid {
14 /// Authority who made the contribution
15 pub authority: Pubkey,
16
17 /// Well ID this bid is for (0-3)
18 pub well_id: u64,
19
20 /// Epoch ID this bid is for (included in PDA, stored here for convenience)
21 pub epoch_id: u64,
22
23 /// Total amount of SOL contributed to this epoch's pool (in lamports)
24 /// Incremented on each JoinAuctionPool call for this epoch
25 /// Used for proportional reward distribution: contribution / pool_total
26 pub contribution: u64,
27
28 /// Timestamp when bid was created (first contribution to this epoch)
29 pub created_at: u64,
30
31 /// Buffer field (for future use)
32 pub buffer_a: u64,
33
34 /// Buffer field (for future use)
35 pub buffer_b: u64,
36}
37
38impl Bid {
39 pub fn pda(authority: Pubkey, well_id: u64, epoch_id: u64) -> (Pubkey, u8) {
40 bid_pda(authority, well_id, epoch_id)
41 }
42}
43
44account!(OilAccount, Bid);
45