mango-v4/programs/mango-v4/src/lib.rs

85 lines
2.2 KiB
Rust
Raw Normal View History

use fixed::types::I80F48;
extern crate static_assertions;
use anchor_lang::prelude::*;
use instructions::*;
pub mod address_lookup_table;
pub mod error;
pub mod instructions;
2022-02-25 04:10:51 -08:00
pub mod state;
pub mod util;
declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
#[program]
pub mod mango_v4 {
use super::*;
2022-02-22 00:49:02 -08:00
pub fn create_group(ctx: Context<CreateGroup>) -> Result<()> {
instructions::create_group(ctx)
}
2022-02-22 01:09:09 -08:00
pub fn register_token(
ctx: Context<RegisterToken>,
decimals: u8,
maint_asset_weight: f32,
init_asset_weight: f32,
maint_liab_weight: f32,
init_liab_weight: f32,
) -> Result<()> {
instructions::register_token(
ctx,
decimals,
maint_asset_weight,
init_asset_weight,
maint_liab_weight,
init_liab_weight,
)
2022-02-22 01:09:09 -08:00
}
2022-02-22 04:15:13 -08:00
pub fn create_account(
ctx: Context<CreateAccount>,
account_num: u8,
address_lookup_table_recent_slot: u64,
) -> Result<()> {
instructions::create_account(ctx, account_num, address_lookup_table_recent_slot)
2022-02-22 04:15:13 -08:00
}
2022-02-22 05:23:13 -08:00
// todo:
// ckamm: generally, using an I80F48 arg will make it harder to call
// because generic anchor clients won't know how to deal with it
// and it's tricky to use in typescript generally
// lets do an interface pass later
pub fn create_stub_oracle(ctx: Context<CreateStubOracle>, price: I80F48) -> Result<()> {
instructions::create_stub_oracle(ctx, price)
}
pub fn set_stub_oracle(ctx: Context<SetStubOracle>, price: I80F48) -> Result<()> {
instructions::set_stub_oracle(ctx, price)
}
2022-02-22 05:23:13 -08:00
pub fn deposit(ctx: Context<Deposit>, amount: u64) -> Result<()> {
instructions::deposit(ctx, amount)
}
2022-02-25 06:14:15 -08:00
pub fn withdraw(ctx: Context<Withdraw>, amount: u64, allow_borrow: bool) -> Result<()> {
instructions::withdraw(ctx, amount, allow_borrow)
}
pub fn margin_trade(ctx: Context<MarginTrade>, cpi_data: Vec<u8>) -> Result<()> {
instructions::margin_trade(ctx, cpi_data)
}
}
#[derive(Clone)]
pub struct Mango;
impl anchor_lang::Id for Mango {
fn id() -> Pubkey {
ID
}
}