mod ledger;
mod market;
mod position;
mod treasury;
pub use ledger::*;
pub use market::*;
pub use position::*;
pub use treasury::*;
use crate::consts::{LEDGER, MARKET, POSITION, TREASURY};
use num_enum::{IntoPrimitive, TryFromPrimitive};
use steel::*;
#[repr(u8)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, IntoPrimitive, TryFromPrimitive)]
pub enum StreakAccount {
Treasury = 1,
Ledger = 2,
Market = 3,
Position = 4,
}
pub fn treasury_pda() -> (Pubkey, u8) {
Pubkey::find_program_address(&[TREASURY], &crate::ID)
}
pub fn ledger_pda(authority: Pubkey) -> (Pubkey, u8) {
Pubkey::find_program_address(&[LEDGER, authority.as_ref()], &crate::ID)
}
pub fn market_pda(period: u64) -> (Pubkey, u8) {
Pubkey::find_program_address(&[MARKET, &period.to_le_bytes()], &crate::ID)
}
pub fn position_pda(period: u64, authority: Pubkey) -> (Pubkey, u8) {
Pubkey::find_program_address(
&[
POSITION,
&period.to_le_bytes(),
authority.as_ref(),
],
&crate::ID,
)
}