triad_protocol/state/
vault.rs

1use anchor_lang::prelude::*;
2
3#[account]
4pub struct Vault {
5    pub bump: u8,
6    pub authority: Pubkey,
7    pub name: String,
8    pub token_account: Pubkey,
9    pub ticker_address: Pubkey,
10    pub total_deposited: u64,
11    pub total_withdrawn: u64,
12    pub init_ts: i64,
13    pub net_deposits: u128,
14    pub net_withdraws: u128,
15    pub long_balance: u64,
16    pub short_balance: u64,
17    pub long_positions_opened: u64,
18    pub short_positions_opened: u64,
19}
20
21#[derive(AnchorSerialize, AnchorDeserialize, Clone)]
22pub struct OpenPositionArgs {
23    pub amount: u64,
24    pub is_long: bool,
25}
26
27#[derive(AnchorSerialize, AnchorDeserialize)]
28pub struct ClosePositionArgs {
29    pub position_index: u8,
30}
31
32impl Vault {
33    pub const PREFIX_SEED: &'static [u8] = b"vault";
34
35    pub const SPACE: usize = 8 + std::mem::size_of::<Self>();
36
37    pub const PREFIX_SEED_VAULT_TOKEN_ACCOUNT: &'static [u8] = b"vault_token_account";
38}