triad_protocol/state/
position.rs1use anchor_lang::prelude::*;
2
3#[account]
4pub struct UserPosition {
5 pub ts: i64,
6 pub bump: u8,
7 pub total_deposited: u64,
8 pub total_withdrawn: u64,
9 pub lp_share: u64,
10 pub total_positions: u16,
11 pub ticker: Pubkey,
12 pub authority: Pubkey,
13 pub positions: [Position; 3],
14}
15
16#[derive(AnchorSerialize, AnchorDeserialize, Clone, Copy, Default)]
17pub struct Position {
18 pub amount: u64,
19 pub entry_price: u64,
20 pub ts: i64,
21 pub is_long: bool,
22 pub is_open: bool,
23 pub pnl: i64,
24}
25
26impl UserPosition {
27 pub const PREFIX_SEED: &'static [u8] = b"user_position";
28
29 pub const SPACE: usize = 8 + std::mem::size_of::<Self>();
30}