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: u128) -> 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: u128,
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>, oracle_price: u64, funding_rate: i64) -> Result<()> {
51 instructions::crank::handler(ctx, oracle_price, 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}