Skip to main content

percli_program/
lib.rs

1#![allow(unexpected_cfgs, clippy::diverging_sub_expression)]
2
3use anchor_lang::prelude::*;
4
5pub mod error;
6pub mod instructions;
7pub mod state;
8
9use instructions::*;
10
11declare_id!("PercQhVBxXnVCaAhfrPZFc2dVZcQANnwEYroogLJFwm");
12
13#[program]
14pub mod percli_program {
15    use super::*;
16
17    pub fn initialize_market(
18        ctx: Context<InitializeMarket>,
19        init_slot: u64,
20        init_oracle_price: u64,
21        params: RiskParamsInput,
22    ) -> Result<()> {
23        instructions::initialize_market::handler(ctx, init_slot, init_oracle_price, params)
24    }
25
26    pub fn deposit(ctx: Context<Deposit>, account_idx: u16, amount: u64) -> Result<()> {
27        instructions::deposit::handler(ctx, account_idx, amount)
28    }
29
30    pub fn withdraw(
31        ctx: Context<Withdraw>,
32        account_idx: u16,
33        amount: u64,
34        funding_rate: i64,
35    ) -> Result<()> {
36        instructions::withdraw::handler(ctx, account_idx, amount, funding_rate)
37    }
38
39    pub fn trade(
40        ctx: Context<Trade>,
41        account_a: u16,
42        account_b: u16,
43        size_q: i128,
44        exec_price: u64,
45        funding_rate: i64,
46    ) -> Result<()> {
47        instructions::trade::handler(ctx, account_a, account_b, size_q, exec_price, funding_rate)
48    }
49
50    pub fn crank(ctx: Context<Crank>, funding_rate: i64) -> Result<()> {
51        instructions::crank::handler(ctx, funding_rate)
52    }
53
54    pub fn liquidate(ctx: Context<Liquidate>, account_idx: u16, funding_rate: i64) -> Result<bool> {
55        instructions::liquidate::handler(ctx, account_idx, funding_rate)
56    }
57
58    pub fn settle(ctx: Context<Settle>, account_idx: u16, funding_rate: i64) -> Result<()> {
59        instructions::settle::handler(ctx, account_idx, funding_rate)
60    }
61
62    pub fn close_account(
63        ctx: Context<CloseAccount>,
64        account_idx: u16,
65        funding_rate: i64,
66    ) -> Result<()> {
67        instructions::close_account::handler(ctx, account_idx, funding_rate)
68    }
69
70    pub fn reclaim_account(ctx: Context<ReclaimAccount>, account_idx: u16) -> Result<()> {
71        instructions::reclaim_account::handler(ctx, account_idx)
72    }
73
74    pub fn withdraw_insurance(ctx: Context<WithdrawInsurance>, amount: u64) -> Result<()> {
75        instructions::withdraw_insurance::handler(ctx, amount)
76    }
77
78    pub fn top_up_insurance(ctx: Context<TopUpInsurance>, amount: u64) -> Result<()> {
79        instructions::top_up_insurance::handler(ctx, amount)
80    }
81
82    pub fn deposit_fee_credits(
83        ctx: Context<DepositFeeCredits>,
84        account_idx: u16,
85        amount: u64,
86    ) -> Result<()> {
87        instructions::deposit_fee_credits::handler(ctx, account_idx, amount)
88    }
89
90    pub fn convert_released_pnl(
91        ctx: Context<ConvertReleasedPnl>,
92        account_idx: u16,
93        x_req: u64,
94        funding_rate: i64,
95    ) -> Result<()> {
96        instructions::convert_released_pnl::handler(ctx, account_idx, x_req, funding_rate)
97    }
98
99    pub fn accrue_market(ctx: Context<AccrueMarket>) -> Result<()> {
100        instructions::accrue_market::handler(ctx)
101    }
102
103    pub fn update_matcher(ctx: Context<UpdateMatcher>, new_matcher: Pubkey) -> Result<()> {
104        instructions::update_matcher::handler(ctx, new_matcher)
105    }
106
107    pub fn update_oracle(ctx: Context<UpdateOracle>) -> Result<()> {
108        instructions::update_oracle::handler(ctx)
109    }
110}