Rename instructions to follow naming pattern (#97)

This commit is contained in:
Christian Kamm 2022-07-06 14:51:15 +02:00 committed by GitHub
parent 7d68378189
commit ffd83a7a05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 207 additions and 186 deletions

View File

@ -15,6 +15,12 @@ Update this for each mainnet deployment.
argument. The USDC/insurance mint is always used as quote currency for perps. argument. The USDC/insurance mint is always used as quote currency for perps.
- The `UpdateIndex` instruction now requires the `oracle` account to be passed - The `UpdateIndex` instruction now requires the `oracle` account to be passed
for logging purposes. for logging purposes.
- New instructions: `EditAccount`, `TokenEdit`, `PerpEditMarket` for reconfiguring. - New instructions: `AccountEdit`, `TokenEdit`, `PerpEditMarket` for reconfiguring.
- The `delegate` field on `MangoAccount` is now used and many instructions can be - The `delegate` field on `MangoAccount` is now used and many instructions can be
called by the account delegate. called by the account delegate.
- Renamed instructions:
- create/close_group -> group_create/close
- create/edit/close_account -> account_create/edit/close
- update_index -> token_update_index
- create/set_stub_oracle -> stub_oracle_create/set

View File

@ -103,7 +103,7 @@ impl MangoClient {
.instruction(Instruction { .instruction(Instruction {
program_id: mango_v4::id(), program_id: mango_v4::id(),
accounts: anchor_lang::ToAccountMetas::to_account_metas( accounts: anchor_lang::ToAccountMetas::to_account_metas(
&mango_v4::accounts::CreateAccount { &mango_v4::accounts::AccountCreate {
group, group,
owner: payer.pubkey(), owner: payer.pubkey(),
account: { account: {
@ -124,7 +124,7 @@ impl MangoClient {
None, None,
), ),
data: anchor_lang::InstructionData::data( data: anchor_lang::InstructionData::data(
&mango_v4::instruction::CreateAccount { &mango_v4::instruction::AccountCreate {
account_num, account_num,
name: mango_account_name.to_owned(), name: mango_account_name.to_owned(),
}, },

View File

@ -5,7 +5,7 @@ use crate::error::*;
use crate::state::*; use crate::state::*;
#[derive(Accounts)] #[derive(Accounts)]
pub struct CloseAccount<'info> { pub struct AccountClose<'info> {
pub group: AccountLoader<'info, Group>, pub group: AccountLoader<'info, Group>,
#[account( #[account(
@ -25,7 +25,7 @@ pub struct CloseAccount<'info> {
pub token_program: Program<'info, Token>, pub token_program: Program<'info, Token>,
} }
pub fn close_account(ctx: Context<CloseAccount>) -> Result<()> { pub fn account_close(ctx: Context<AccountClose>) -> Result<()> {
let group = ctx.accounts.group.load()?; let group = ctx.accounts.group.load()?;
// don't perform checks if group is just testing // don't perform checks if group is just testing

View File

@ -6,7 +6,7 @@ use crate::util::fill32_from_str;
#[derive(Accounts)] #[derive(Accounts)]
#[instruction(account_num: u8)] #[instruction(account_num: u8)]
pub struct CreateAccount<'info> { pub struct AccountCreate<'info> {
pub group: AccountLoader<'info, Group>, pub group: AccountLoader<'info, Group>,
#[account( #[account(
@ -25,7 +25,7 @@ pub struct CreateAccount<'info> {
pub system_program: Program<'info, System>, pub system_program: Program<'info, System>,
} }
pub fn create_account(ctx: Context<CreateAccount>, account_num: u8, name: String) -> Result<()> { pub fn account_create(ctx: Context<AccountCreate>, account_num: u8, name: String) -> Result<()> {
let mut account = ctx.accounts.account.load_init()?; let mut account = ctx.accounts.account.load_init()?;
account.name = fill32_from_str(name)?; account.name = fill32_from_str(name)?;

View File

@ -5,7 +5,7 @@ use crate::state::*;
use crate::util::fill32_from_str; use crate::util::fill32_from_str;
#[derive(Accounts)] #[derive(Accounts)]
pub struct EditAccount<'info> { pub struct AccountEdit<'info> {
pub group: AccountLoader<'info, Group>, pub group: AccountLoader<'info, Group>,
#[account( #[account(
@ -18,8 +18,8 @@ pub struct EditAccount<'info> {
pub owner: Signer<'info>, pub owner: Signer<'info>,
} }
pub fn edit_account( pub fn account_edit(
ctx: Context<EditAccount>, ctx: Context<AccountEdit>,
name_opt: Option<String>, name_opt: Option<String>,
// note: can also be used to unset by using the default pubkey here as a param // note: can also be used to unset by using the default pubkey here as a param
delegate_opt: Option<Pubkey>, delegate_opt: Option<Pubkey>,

View File

@ -3,7 +3,7 @@ use anchor_lang::prelude::*;
use anchor_spl::token::Token; use anchor_spl::token::Token;
#[derive(Accounts)] #[derive(Accounts)]
pub struct CloseGroup<'info> { pub struct GroupClose<'info> {
#[account( #[account(
mut, mut,
constraint = group.load()?.testing == 1, constraint = group.load()?.testing == 1,
@ -21,7 +21,7 @@ pub struct CloseGroup<'info> {
pub token_program: Program<'info, Token>, pub token_program: Program<'info, Token>,
} }
pub fn close_group(_ctx: Context<CloseGroup>) -> Result<()> { pub fn group_close(_ctx: Context<GroupClose>) -> Result<()> {
// TODO: checks // TODO: checks
Ok(()) Ok(())
} }

View File

@ -6,7 +6,7 @@ use crate::state::*;
#[derive(Accounts)] #[derive(Accounts)]
#[instruction(group_num: u32)] #[instruction(group_num: u32)]
pub struct CreateGroup<'info> { pub struct GroupCreate<'info> {
#[account( #[account(
init, init,
seeds = [b"Group".as_ref(), admin.key().as_ref(), &group_num.to_le_bytes()], seeds = [b"Group".as_ref(), admin.key().as_ref(), &group_num.to_le_bytes()],
@ -38,7 +38,7 @@ pub struct CreateGroup<'info> {
pub rent: Sysvar<'info, Rent>, pub rent: Sysvar<'info, Rent>,
} }
pub fn create_group(ctx: Context<CreateGroup>, group_num: u32, testing: u8) -> Result<()> { pub fn group_create(ctx: Context<GroupCreate>, group_num: u32, testing: u8) -> Result<()> {
let mut group = ctx.accounts.group.load_init()?; let mut group = ctx.accounts.group.load_init()?;
group.admin = ctx.accounts.admin.key(); group.admin = ctx.accounts.admin.key();
group.insurance_vault = ctx.accounts.insurance_vault.key(); group.insurance_vault = ctx.accounts.insurance_vault.key();

View File

@ -1,15 +1,13 @@
pub use account_close::*;
pub use account_create::*;
pub use account_edit::*;
pub use benchmark::*; pub use benchmark::*;
pub use close_account::*;
pub use close_group::*;
pub use close_stub_oracle::*;
pub use compute_account_data::*; pub use compute_account_data::*;
pub use create_account::*;
pub use create_group::*;
pub use create_stub_oracle::*;
pub use edit_account::*;
pub use flash_loan::*; pub use flash_loan::*;
pub use flash_loan2::*; pub use flash_loan2::*;
pub use flash_loan3::*; pub use flash_loan3::*;
pub use group_close::*;
pub use group_create::*;
pub use liq_token_bankruptcy::*; pub use liq_token_bankruptcy::*;
pub use liq_token_with_token::*; pub use liq_token_with_token::*;
pub use perp_cancel_all_orders::*; pub use perp_cancel_all_orders::*;
@ -31,27 +29,27 @@ pub use serum3_liq_force_cancel_orders::*;
pub use serum3_place_order::*; pub use serum3_place_order::*;
pub use serum3_register_market::*; pub use serum3_register_market::*;
pub use serum3_settle_funds::*; pub use serum3_settle_funds::*;
pub use set_stub_oracle::*; pub use stub_oracle_close::*;
pub use stub_oracle_create::*;
pub use stub_oracle_set::*;
pub use token_add_bank::*; pub use token_add_bank::*;
pub use token_deposit::*; pub use token_deposit::*;
pub use token_deregister::*; pub use token_deregister::*;
pub use token_edit::*; pub use token_edit::*;
pub use token_register::*; pub use token_register::*;
pub use token_update_index::*;
pub use token_withdraw::*; pub use token_withdraw::*;
pub use update_index::*;
mod account_close;
mod account_create;
mod account_edit;
mod benchmark; mod benchmark;
mod close_account;
mod close_group;
mod close_stub_oracle;
mod compute_account_data; mod compute_account_data;
mod create_account;
mod create_group;
mod create_stub_oracle;
mod edit_account;
mod flash_loan; mod flash_loan;
mod flash_loan2; mod flash_loan2;
mod flash_loan3; mod flash_loan3;
mod group_close;
mod group_create;
mod liq_token_bankruptcy; mod liq_token_bankruptcy;
mod liq_token_with_token; mod liq_token_with_token;
mod perp_cancel_all_orders; mod perp_cancel_all_orders;
@ -73,11 +71,13 @@ mod serum3_liq_force_cancel_orders;
mod serum3_place_order; mod serum3_place_order;
mod serum3_register_market; mod serum3_register_market;
mod serum3_settle_funds; mod serum3_settle_funds;
mod set_stub_oracle; mod stub_oracle_close;
mod stub_oracle_create;
mod stub_oracle_set;
mod token_add_bank; mod token_add_bank;
mod token_deposit; mod token_deposit;
mod token_deregister; mod token_deregister;
mod token_edit; mod token_edit;
mod token_register; mod token_register;
mod token_update_index;
mod token_withdraw; mod token_withdraw;
mod update_index;

View File

@ -4,7 +4,7 @@ use anchor_spl::token::Token;
use crate::state::*; use crate::state::*;
#[derive(Accounts)] #[derive(Accounts)]
pub struct CloseStubOracle<'info> { pub struct StubOracleClose<'info> {
#[account( #[account(
constraint = group.load()?.testing == 1, constraint = group.load()?.testing == 1,
has_one = admin, has_one = admin,
@ -27,6 +27,6 @@ pub struct CloseStubOracle<'info> {
pub token_program: Program<'info, Token>, pub token_program: Program<'info, Token>,
} }
pub fn close_stub_oracle(_ctx: Context<CloseStubOracle>) -> Result<()> { pub fn stub_oracle_close(_ctx: Context<StubOracleClose>) -> Result<()> {
Ok(()) Ok(())
} }

View File

@ -5,7 +5,7 @@ use fixed::types::I80F48;
use crate::state::*; use crate::state::*;
#[derive(Accounts)] #[derive(Accounts)]
pub struct CreateStubOracle<'info> { pub struct StubOracleCreate<'info> {
#[account( #[account(
has_one = admin, has_one = admin,
)] )]
@ -30,7 +30,7 @@ pub struct CreateStubOracle<'info> {
pub system_program: Program<'info, System>, pub system_program: Program<'info, System>,
} }
pub fn create_stub_oracle(ctx: Context<CreateStubOracle>, price: I80F48) -> Result<()> { pub fn stub_oracle_create(ctx: Context<StubOracleCreate>, price: I80F48) -> Result<()> {
let mut oracle = ctx.accounts.oracle.load_init()?; let mut oracle = ctx.accounts.oracle.load_init()?;
oracle.group = ctx.accounts.group.key(); oracle.group = ctx.accounts.group.key();
oracle.mint = ctx.accounts.token_mint.key(); oracle.mint = ctx.accounts.token_mint.key();

View File

@ -4,7 +4,7 @@ use fixed::types::I80F48;
use crate::state::*; use crate::state::*;
#[derive(Accounts)] #[derive(Accounts)]
pub struct SetStubOracle<'info> { pub struct StubOracleSet<'info> {
#[account( #[account(
has_one = admin, has_one = admin,
)] )]
@ -22,8 +22,7 @@ pub struct SetStubOracle<'info> {
pub payer: Signer<'info>, pub payer: Signer<'info>,
} }
// TODO: add admin requirement for changing price pub fn stub_oracle_set(ctx: Context<StubOracleSet>, price: I80F48) -> Result<()> {
pub fn set_stub_oracle(ctx: Context<SetStubOracle>, price: I80F48) -> Result<()> {
let mut oracle = ctx.accounts.oracle.load_mut()?; let mut oracle = ctx.accounts.oracle.load_mut()?;
oracle.price = price; oracle.price = price;
oracle.last_updated = Clock::get()?.unix_timestamp; oracle.last_updated = Clock::get()?.unix_timestamp;

View File

@ -8,12 +8,12 @@ use crate::{
use checked_math as cm; use checked_math as cm;
use fixed::types::I80F48; use fixed::types::I80F48;
#[derive(Accounts)] #[derive(Accounts)]
pub struct UpdateIndex<'info> { pub struct TokenUpdateIndex<'info> {
pub mint_info: AccountLoader<'info, MintInfo>, pub mint_info: AccountLoader<'info, MintInfo>,
pub oracle: UncheckedAccount<'info>, pub oracle: UncheckedAccount<'info>,
} }
pub fn update_index(ctx: Context<UpdateIndex>) -> Result<()> { pub fn token_update_index(ctx: Context<TokenUpdateIndex>) -> Result<()> {
let mint_info = ctx.accounts.mint_info.load()?; let mint_info = ctx.accounts.mint_info.load()?;
require_keys_eq!(mint_info.oracle.key(), ctx.accounts.oracle.key()); require_keys_eq!(mint_info.oracle.key(), ctx.accounts.oracle.key());

View File

@ -30,12 +30,12 @@ pub mod mango_v4 {
use super::*; use super::*;
pub fn create_group(ctx: Context<CreateGroup>, group_num: u32, testing: u8) -> Result<()> { pub fn group_create(ctx: Context<GroupCreate>, group_num: u32, testing: u8) -> Result<()> {
instructions::create_group(ctx, group_num, testing) instructions::group_create(ctx, group_num, testing)
} }
pub fn close_group(ctx: Context<CloseGroup>) -> Result<()> { pub fn group_close(ctx: Context<GroupClose>) -> Result<()> {
instructions::close_group(ctx) instructions::group_close(ctx)
} }
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
@ -118,28 +118,28 @@ pub mod mango_v4 {
instructions::token_deregister(ctx, token_index) instructions::token_deregister(ctx, token_index)
} }
pub fn update_index(ctx: Context<UpdateIndex>) -> Result<()> { pub fn token_update_index(ctx: Context<TokenUpdateIndex>) -> Result<()> {
instructions::update_index(ctx) instructions::token_update_index(ctx)
} }
pub fn create_account( pub fn account_create(
ctx: Context<CreateAccount>, ctx: Context<AccountCreate>,
account_num: u8, account_num: u8,
name: String, name: String,
) -> Result<()> { ) -> Result<()> {
instructions::create_account(ctx, account_num, name) instructions::account_create(ctx, account_num, name)
} }
pub fn edit_account( pub fn account_edit(
ctx: Context<EditAccount>, ctx: Context<AccountEdit>,
name_opt: Option<String>, name_opt: Option<String>,
delegate_opt: Option<Pubkey>, delegate_opt: Option<Pubkey>,
) -> Result<()> { ) -> Result<()> {
instructions::edit_account(ctx, name_opt, delegate_opt) instructions::account_edit(ctx, name_opt, delegate_opt)
} }
pub fn close_account(ctx: Context<CloseAccount>) -> Result<()> { pub fn account_close(ctx: Context<AccountClose>) -> Result<()> {
instructions::close_account(ctx) instructions::account_close(ctx)
} }
// todo: // todo:
@ -147,16 +147,16 @@ pub mod mango_v4 {
// because generic anchor clients won't know how to deal with it // because generic anchor clients won't know how to deal with it
// and it's tricky to use in typescript generally // and it's tricky to use in typescript generally
// lets do an interface pass later // lets do an interface pass later
pub fn create_stub_oracle(ctx: Context<CreateStubOracle>, price: I80F48) -> Result<()> { pub fn stub_oracle_create(ctx: Context<StubOracleCreate>, price: I80F48) -> Result<()> {
instructions::create_stub_oracle(ctx, price) instructions::stub_oracle_create(ctx, price)
} }
pub fn close_stub_oracle(ctx: Context<CloseStubOracle>) -> Result<()> { pub fn stub_oracle_close(ctx: Context<StubOracleClose>) -> Result<()> {
instructions::close_stub_oracle(ctx) instructions::stub_oracle_close(ctx)
} }
pub fn set_stub_oracle(ctx: Context<SetStubOracle>, price: I80F48) -> Result<()> { pub fn stub_oracle_set(ctx: Context<StubOracleSet>, price: I80F48) -> Result<()> {
instructions::set_stub_oracle(ctx, price) instructions::stub_oracle_set(ctx, price)
} }
pub fn token_deposit(ctx: Context<TokenDeposit>, amount: u64) -> Result<()> { pub fn token_deposit(ctx: Context<TokenDeposit>, amount: u64) -> Result<()> {

View File

@ -1044,7 +1044,7 @@ impl<'keypair> ClientInstruction for TokenDeregisterInstruction<'keypair> {
} }
} }
pub struct SetStubOracleInstruction<'keypair> { pub struct StubOracleSetInstruction<'keypair> {
pub mint: Pubkey, pub mint: Pubkey,
pub group: Pubkey, pub group: Pubkey,
pub admin: &'keypair Keypair, pub admin: &'keypair Keypair,
@ -1052,9 +1052,9 @@ pub struct SetStubOracleInstruction<'keypair> {
pub price: &'static str, pub price: &'static str,
} }
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]
impl<'keypair> ClientInstruction for SetStubOracleInstruction<'keypair> { impl<'keypair> ClientInstruction for StubOracleSetInstruction<'keypair> {
type Accounts = mango_v4::accounts::SetStubOracle; type Accounts = mango_v4::accounts::StubOracleSet;
type Instruction = mango_v4::instruction::SetStubOracle; type Instruction = mango_v4::instruction::StubOracleSet;
async fn to_instruction( async fn to_instruction(
&self, &self,
@ -1091,16 +1091,16 @@ impl<'keypair> ClientInstruction for SetStubOracleInstruction<'keypair> {
} }
} }
pub struct CreateStubOracle<'keypair> { pub struct StubOracleCreate<'keypair> {
pub group: Pubkey, pub group: Pubkey,
pub mint: Pubkey, pub mint: Pubkey,
pub admin: &'keypair Keypair, pub admin: &'keypair Keypair,
pub payer: &'keypair Keypair, pub payer: &'keypair Keypair,
} }
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]
impl<'keypair> ClientInstruction for CreateStubOracle<'keypair> { impl<'keypair> ClientInstruction for StubOracleCreate<'keypair> {
type Accounts = mango_v4::accounts::CreateStubOracle; type Accounts = mango_v4::accounts::StubOracleCreate;
type Instruction = mango_v4::instruction::CreateStubOracle; type Instruction = mango_v4::instruction::StubOracleCreate;
async fn to_instruction( async fn to_instruction(
&self, &self,
@ -1139,16 +1139,16 @@ impl<'keypair> ClientInstruction for CreateStubOracle<'keypair> {
} }
} }
pub struct CloseStubOracleInstruction<'keypair> { pub struct StubOracleCloseInstruction<'keypair> {
pub group: Pubkey, pub group: Pubkey,
pub mint: Pubkey, pub mint: Pubkey,
pub admin: &'keypair Keypair, pub admin: &'keypair Keypair,
pub sol_destination: Pubkey, pub sol_destination: Pubkey,
} }
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]
impl<'keypair> ClientInstruction for CloseStubOracleInstruction<'keypair> { impl<'keypair> ClientInstruction for StubOracleCloseInstruction<'keypair> {
type Accounts = mango_v4::accounts::CloseStubOracle; type Accounts = mango_v4::accounts::StubOracleClose;
type Instruction = mango_v4::instruction::CloseStubOracle; type Instruction = mango_v4::instruction::StubOracleClose;
async fn to_instruction( async fn to_instruction(
&self, &self,
@ -1184,15 +1184,15 @@ impl<'keypair> ClientInstruction for CloseStubOracleInstruction<'keypair> {
} }
} }
pub struct CreateGroupInstruction<'keypair> { pub struct GroupCreateInstruction<'keypair> {
pub admin: &'keypair Keypair, pub admin: &'keypair Keypair,
pub payer: &'keypair Keypair, pub payer: &'keypair Keypair,
pub insurance_mint: Pubkey, pub insurance_mint: Pubkey,
} }
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]
impl<'keypair> ClientInstruction for CreateGroupInstruction<'keypair> { impl<'keypair> ClientInstruction for GroupCreateInstruction<'keypair> {
type Accounts = mango_v4::accounts::CreateGroup; type Accounts = mango_v4::accounts::GroupCreate;
type Instruction = mango_v4::instruction::CreateGroup; type Instruction = mango_v4::instruction::GroupCreate;
async fn to_instruction( async fn to_instruction(
&self, &self,
_account_loader: impl ClientAccountLoader + 'async_trait, _account_loader: impl ClientAccountLoader + 'async_trait,
@ -1239,15 +1239,15 @@ impl<'keypair> ClientInstruction for CreateGroupInstruction<'keypair> {
} }
} }
pub struct CloseGroupInstruction<'keypair> { pub struct GroupCloseInstruction<'keypair> {
pub admin: &'keypair Keypair, pub admin: &'keypair Keypair,
pub group: Pubkey, pub group: Pubkey,
pub sol_destination: Pubkey, pub sol_destination: Pubkey,
} }
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]
impl<'keypair> ClientInstruction for CloseGroupInstruction<'keypair> { impl<'keypair> ClientInstruction for GroupCloseInstruction<'keypair> {
type Accounts = mango_v4::accounts::CloseGroup; type Accounts = mango_v4::accounts::GroupClose;
type Instruction = mango_v4::instruction::CloseGroup; type Instruction = mango_v4::instruction::GroupClose;
async fn to_instruction( async fn to_instruction(
&self, &self,
_account_loader: impl ClientAccountLoader + 'async_trait, _account_loader: impl ClientAccountLoader + 'async_trait,
@ -1271,7 +1271,7 @@ impl<'keypair> ClientInstruction for CloseGroupInstruction<'keypair> {
} }
} }
pub struct CreateAccountInstruction<'keypair> { pub struct AccountCreateInstruction<'keypair> {
pub account_num: u8, pub account_num: u8,
pub group: Pubkey, pub group: Pubkey,
@ -1279,15 +1279,15 @@ pub struct CreateAccountInstruction<'keypair> {
pub payer: &'keypair Keypair, pub payer: &'keypair Keypair,
} }
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]
impl<'keypair> ClientInstruction for CreateAccountInstruction<'keypair> { impl<'keypair> ClientInstruction for AccountCreateInstruction<'keypair> {
type Accounts = mango_v4::accounts::CreateAccount; type Accounts = mango_v4::accounts::AccountCreate;
type Instruction = mango_v4::instruction::CreateAccount; type Instruction = mango_v4::instruction::AccountCreate;
async fn to_instruction( async fn to_instruction(
&self, &self,
_account_loader: impl ClientAccountLoader + 'async_trait, _account_loader: impl ClientAccountLoader + 'async_trait,
) -> (Self::Accounts, instruction::Instruction) { ) -> (Self::Accounts, instruction::Instruction) {
let program_id = mango_v4::id(); let program_id = mango_v4::id();
let instruction = mango_v4::instruction::CreateAccount { let instruction = mango_v4::instruction::AccountCreate {
account_num: self.account_num, account_num: self.account_num,
name: "my_mango_account".to_string(), name: "my_mango_account".to_string(),
}; };
@ -1303,7 +1303,7 @@ impl<'keypair> ClientInstruction for CreateAccountInstruction<'keypair> {
) )
.0; .0;
let accounts = mango_v4::accounts::CreateAccount { let accounts = mango_v4::accounts::AccountCreate {
group: self.group, group: self.group,
owner: self.owner.pubkey(), owner: self.owner.pubkey(),
account, account,
@ -1320,7 +1320,7 @@ impl<'keypair> ClientInstruction for CreateAccountInstruction<'keypair> {
} }
} }
pub struct EditAccountInstruction<'keypair> { pub struct AccountEditInstruction<'keypair> {
pub account_num: u8, pub account_num: u8,
pub group: Pubkey, pub group: Pubkey,
pub owner: &'keypair Keypair, pub owner: &'keypair Keypair,
@ -1328,15 +1328,15 @@ pub struct EditAccountInstruction<'keypair> {
pub delegate: Pubkey, pub delegate: Pubkey,
} }
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]
impl<'keypair> ClientInstruction for EditAccountInstruction<'keypair> { impl<'keypair> ClientInstruction for AccountEditInstruction<'keypair> {
type Accounts = mango_v4::accounts::EditAccount; type Accounts = mango_v4::accounts::AccountEdit;
type Instruction = mango_v4::instruction::EditAccount; type Instruction = mango_v4::instruction::AccountEdit;
async fn to_instruction( async fn to_instruction(
&self, &self,
_account_loader: impl ClientAccountLoader + 'async_trait, _account_loader: impl ClientAccountLoader + 'async_trait,
) -> (Self::Accounts, instruction::Instruction) { ) -> (Self::Accounts, instruction::Instruction) {
let program_id = mango_v4::id(); let program_id = mango_v4::id();
let instruction = mango_v4::instruction::EditAccount { let instruction = mango_v4::instruction::AccountEdit {
name_opt: Option::from(self.name.to_string()), name_opt: Option::from(self.name.to_string()),
delegate_opt: Option::from(self.delegate), delegate_opt: Option::from(self.delegate),
}; };
@ -1352,7 +1352,7 @@ impl<'keypair> ClientInstruction for EditAccountInstruction<'keypair> {
) )
.0; .0;
let accounts = mango_v4::accounts::EditAccount { let accounts = mango_v4::accounts::AccountEdit {
group: self.group, group: self.group,
account, account,
owner: self.owner.pubkey(), owner: self.owner.pubkey(),
@ -1367,16 +1367,16 @@ impl<'keypair> ClientInstruction for EditAccountInstruction<'keypair> {
} }
} }
pub struct CloseAccountInstruction<'keypair> { pub struct AccountCloseInstruction<'keypair> {
pub group: Pubkey, pub group: Pubkey,
pub account: Pubkey, pub account: Pubkey,
pub owner: &'keypair Keypair, pub owner: &'keypair Keypair,
pub sol_destination: Pubkey, pub sol_destination: Pubkey,
} }
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]
impl<'keypair> ClientInstruction for CloseAccountInstruction<'keypair> { impl<'keypair> ClientInstruction for AccountCloseInstruction<'keypair> {
type Accounts = mango_v4::accounts::CloseAccount; type Accounts = mango_v4::accounts::AccountClose;
type Instruction = mango_v4::instruction::CloseAccount; type Instruction = mango_v4::instruction::AccountClose;
async fn to_instruction( async fn to_instruction(
&self, &self,
_account_loader: impl ClientAccountLoader + 'async_trait, _account_loader: impl ClientAccountLoader + 'async_trait,
@ -2545,13 +2545,13 @@ impl ClientInstruction for BenchmarkInstruction {
vec![] vec![]
} }
} }
pub struct UpdateIndexInstruction { pub struct TokenUpdateIndexInstruction {
pub mint_info: Pubkey, pub mint_info: Pubkey,
} }
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]
impl ClientInstruction for UpdateIndexInstruction { impl ClientInstruction for TokenUpdateIndexInstruction {
type Accounts = mango_v4::accounts::UpdateIndex; type Accounts = mango_v4::accounts::TokenUpdateIndex;
type Instruction = mango_v4::instruction::UpdateIndex; type Instruction = mango_v4::instruction::TokenUpdateIndex;
async fn to_instruction( async fn to_instruction(
&self, &self,
loader: impl ClientAccountLoader + 'async_trait, loader: impl ClientAccountLoader + 'async_trait,

View File

@ -38,7 +38,7 @@ impl<'a> GroupWithTokensConfig<'a> {
} = self; } = self;
let create_group_accounts = send_tx( let create_group_accounts = send_tx(
solana, solana,
CreateGroupInstruction { GroupCreateInstruction {
admin, admin,
payer, payer,
insurance_mint: mints[0].pubkey, insurance_mint: mints[0].pubkey,
@ -55,7 +55,7 @@ impl<'a> GroupWithTokensConfig<'a> {
for (index, mint) in mints.iter().enumerate() { for (index, mint) in mints.iter().enumerate() {
let create_stub_oracle_accounts = send_tx( let create_stub_oracle_accounts = send_tx(
solana, solana,
CreateStubOracle { StubOracleCreate {
group, group,
mint: mint.pubkey, mint: mint.pubkey,
admin, admin,
@ -67,7 +67,7 @@ impl<'a> GroupWithTokensConfig<'a> {
let oracle = create_stub_oracle_accounts.oracle; let oracle = create_stub_oracle_accounts.oracle;
send_tx( send_tx(
solana, solana,
SetStubOracleInstruction { StubOracleSetInstruction {
group, group,
admin, admin,
mint: mint.pubkey, mint: mint.pubkey,

View File

@ -42,7 +42,7 @@ async fn test_bankrupt_tokens_socialize_loss() -> Result<(), TransportError> {
// deposit some funds, to the vaults aren't empty // deposit some funds, to the vaults aren't empty
let vault_account = send_tx( let vault_account = send_tx(
solana, solana,
CreateAccountInstruction { AccountCreateInstruction {
account_num: 2, account_num: 2,
group, group,
owner, owner,
@ -87,7 +87,7 @@ async fn test_bankrupt_tokens_socialize_loss() -> Result<(), TransportError> {
// //
let account = send_tx( let account = send_tx(
solana, solana,
CreateAccountInstruction { AccountCreateInstruction {
account_num: 0, account_num: 0,
group, group,
owner, owner,
@ -174,7 +174,7 @@ async fn test_bankrupt_tokens_socialize_loss() -> Result<(), TransportError> {
// //
send_tx( send_tx(
solana, solana,
SetStubOracleInstruction { StubOracleSetInstruction {
group, group,
admin, admin,
mint: borrow_token1.mint.pubkey, mint: borrow_token1.mint.pubkey,
@ -355,7 +355,7 @@ async fn test_bankrupt_tokens_insurance_fund() -> Result<(), TransportError> {
// deposit some funds, to the vaults aren't empty // deposit some funds, to the vaults aren't empty
let vault_account = send_tx( let vault_account = send_tx(
solana, solana,
CreateAccountInstruction { AccountCreateInstruction {
account_num: 2, account_num: 2,
group, group,
owner, owner,
@ -400,7 +400,7 @@ async fn test_bankrupt_tokens_insurance_fund() -> Result<(), TransportError> {
// //
let account = send_tx( let account = send_tx(
solana, solana,
CreateAccountInstruction { AccountCreateInstruction {
account_num: 0, account_num: 0,
group, group,
owner, owner,
@ -487,7 +487,7 @@ async fn test_bankrupt_tokens_insurance_fund() -> Result<(), TransportError> {
// //
send_tx( send_tx(
solana, solana,
SetStubOracleInstruction { StubOracleSetInstruction {
group, group,
admin, admin,
mint: borrow_token2.mint.pubkey, mint: borrow_token2.mint.pubkey,

View File

@ -39,7 +39,7 @@ async fn test_basic() -> Result<(), TransportError> {
let account = send_tx( let account = send_tx(
solana, solana,
CreateAccountInstruction { AccountCreateInstruction {
account_num: 0, account_num: 0,
group, group,
owner, owner,
@ -155,7 +155,7 @@ async fn test_basic() -> Result<(), TransportError> {
// withdraw whatever is remaining, can't close bank vault without this // withdraw whatever is remaining, can't close bank vault without this
send_tx( send_tx(
solana, solana,
UpdateIndexInstruction { TokenUpdateIndexInstruction {
mint_info: tokens[0].mint_info, mint_info: tokens[0].mint_info,
}, },
) )
@ -179,7 +179,7 @@ async fn test_basic() -> Result<(), TransportError> {
// close account // close account
send_tx( send_tx(
solana, solana,
CloseAccountInstruction { AccountCloseInstruction {
group, group,
account, account,
owner, owner,
@ -217,7 +217,7 @@ async fn test_basic() -> Result<(), TransportError> {
// close stub oracle // close stub oracle
send_tx( send_tx(
solana, solana,
CloseStubOracleInstruction { StubOracleCloseInstruction {
group, group,
mint: bank_data.mint, mint: bank_data.mint,
admin, admin,
@ -230,7 +230,7 @@ async fn test_basic() -> Result<(), TransportError> {
// close group // close group
send_tx( send_tx(
solana, solana,
CloseGroupInstruction { GroupCloseInstruction {
group, group,
admin, admin,
sol_destination: payer.pubkey(), sol_destination: payer.pubkey(),

View File

@ -35,7 +35,7 @@ async fn test_delegate() -> Result<(), TransportError> {
let account = send_tx( let account = send_tx(
solana, solana,
CreateAccountInstruction { AccountCreateInstruction {
account_num: 0, account_num: 0,
group, group,
owner, owner,
@ -66,7 +66,7 @@ async fn test_delegate() -> Result<(), TransportError> {
{ {
send_tx( send_tx(
solana, solana,
EditAccountInstruction { AccountEditInstruction {
delegate: delegate.pubkey(), delegate: delegate.pubkey(),
account_num: 0, account_num: 0,
group, group,
@ -84,7 +84,7 @@ async fn test_delegate() -> Result<(), TransportError> {
{ {
let res = send_tx( let res = send_tx(
solana, solana,
EditAccountInstruction { AccountEditInstruction {
delegate: delegate.pubkey(), delegate: delegate.pubkey(),
account_num: 0, account_num: 0,
group, group,
@ -136,7 +136,7 @@ async fn test_delegate() -> Result<(), TransportError> {
.unwrap(); .unwrap();
let res = send_tx( let res = send_tx(
solana, solana,
CloseAccountInstruction { AccountCloseInstruction {
group, group,
account, account,
owner: delegate, owner: delegate,

View File

@ -31,14 +31,14 @@ async fn test_group_address_lookup_tables() -> Result<()> {
// SETUP: Create a group // SETUP: Create a group
// //
let group = send_tx(solana, CreateGroupInstruction { admin, payer }) let group = send_tx(solana, GroupCreateInstruction { admin, payer })
.await .await
.unwrap() .unwrap()
.group; .group;
let account = send_tx( let account = send_tx(
solana, solana,
CreateAccountInstruction { AccountCreateInstruction {
account_num: 0, account_num: 0,
group, group,
owner, owner,
@ -56,7 +56,7 @@ async fn test_group_address_lookup_tables() -> Result<()> {
let register_mint = |index: TokenIndex, mint: MintCookie, address_lookup_table: Pubkey| async move { let register_mint = |index: TokenIndex, mint: MintCookie, address_lookup_table: Pubkey| async move {
let create_stub_oracle_accounts = send_tx( let create_stub_oracle_accounts = send_tx(
solana, solana,
CreateStubOracle { StubOracleCreate {
mint: mint.pubkey, mint: mint.pubkey,
payer, payer,
}, },
@ -66,7 +66,7 @@ async fn test_group_address_lookup_tables() -> Result<()> {
let oracle = create_stub_oracle_accounts.oracle; let oracle = create_stub_oracle_accounts.oracle;
send_tx( send_tx(
solana, solana,
SetStubOracleInstruction { StubOracleSetInstruction {
group, group,
admin, admin,
mint: mint.pubkey, mint: mint.pubkey,

View File

@ -35,7 +35,7 @@ async fn test_health_compute_tokens() -> Result<(), TransportError> {
let account = send_tx( let account = send_tx(
solana, solana,
CreateAccountInstruction { AccountCreateInstruction {
account_num: 0, account_num: 0,
group, group,
owner, owner,
@ -99,7 +99,7 @@ async fn test_health_compute_serum() -> Result<(), TransportError> {
let account = send_tx( let account = send_tx(
solana, solana,
CreateAccountInstruction { AccountCreateInstruction {
account_num: 0, account_num: 0,
group, group,
owner, owner,
@ -210,7 +210,7 @@ async fn test_health_compute_perp() -> Result<(), TransportError> {
let account = send_tx( let account = send_tx(
solana, solana,
CreateAccountInstruction { AccountCreateInstruction {
account_num: 0, account_num: 0,
group, group,
owner, owner,

View File

@ -40,7 +40,7 @@ async fn test_liq_tokens_force_cancel() -> Result<(), TransportError> {
// deposit some funds, to the vaults aren't empty // deposit some funds, to the vaults aren't empty
let vault_account = send_tx( let vault_account = send_tx(
solana, solana,
CreateAccountInstruction { AccountCreateInstruction {
account_num: 2, account_num: 2,
group, group,
owner, owner,
@ -95,7 +95,7 @@ async fn test_liq_tokens_force_cancel() -> Result<(), TransportError> {
// //
let account = send_tx( let account = send_tx(
solana, solana,
CreateAccountInstruction { AccountCreateInstruction {
account_num: 0, account_num: 0,
group, group,
owner, owner,
@ -161,7 +161,7 @@ async fn test_liq_tokens_force_cancel() -> Result<(), TransportError> {
// //
send_tx( send_tx(
solana, solana,
SetStubOracleInstruction { StubOracleSetInstruction {
group, group,
admin, admin,
mint: base_token.mint.pubkey, mint: base_token.mint.pubkey,
@ -249,7 +249,7 @@ async fn test_liq_tokens_with_token() -> Result<(), TransportError> {
// deposit some funds, to the vaults aren't empty // deposit some funds, to the vaults aren't empty
let vault_account = send_tx( let vault_account = send_tx(
solana, solana,
CreateAccountInstruction { AccountCreateInstruction {
account_num: 2, account_num: 2,
group, group,
owner, owner,
@ -279,7 +279,7 @@ async fn test_liq_tokens_with_token() -> Result<(), TransportError> {
// //
let account = send_tx( let account = send_tx(
solana, solana,
CreateAccountInstruction { AccountCreateInstruction {
account_num: 0, account_num: 0,
group, group,
owner, owner,
@ -351,7 +351,7 @@ async fn test_liq_tokens_with_token() -> Result<(), TransportError> {
// //
send_tx( send_tx(
solana, solana,
SetStubOracleInstruction { StubOracleSetInstruction {
group, group,
admin, admin,
mint: borrow_token1.mint.pubkey, mint: borrow_token1.mint.pubkey,

View File

@ -51,7 +51,7 @@ async fn test_margin_trade1() -> Result<(), BanksClientError> {
let provider_account = send_tx( let provider_account = send_tx(
solana, solana,
CreateAccountInstruction { AccountCreateInstruction {
account_num: 1, account_num: 1,
group, group,
owner, owner,
@ -93,7 +93,7 @@ async fn test_margin_trade1() -> Result<(), BanksClientError> {
let account = send_tx( let account = send_tx(
solana, solana,
CreateAccountInstruction { AccountCreateInstruction {
account_num: 0, account_num: 0,
group, group,
owner, owner,
@ -367,7 +367,7 @@ async fn test_margin_trade2() -> Result<(), BanksClientError> {
let provider_account = send_tx( let provider_account = send_tx(
solana, solana,
CreateAccountInstruction { AccountCreateInstruction {
account_num: 1, account_num: 1,
group, group,
owner, owner,
@ -409,7 +409,7 @@ async fn test_margin_trade2() -> Result<(), BanksClientError> {
let account = send_tx( let account = send_tx(
solana, solana,
CreateAccountInstruction { AccountCreateInstruction {
account_num: 0, account_num: 0,
group, group,
owner, owner,
@ -628,7 +628,7 @@ async fn test_margin_trade3() -> Result<(), BanksClientError> {
let provider_account = send_tx( let provider_account = send_tx(
solana, solana,
CreateAccountInstruction { AccountCreateInstruction {
account_num: 1, account_num: 1,
group, group,
owner, owner,
@ -670,7 +670,7 @@ async fn test_margin_trade3() -> Result<(), BanksClientError> {
let account = send_tx( let account = send_tx(
solana, solana,
CreateAccountInstruction { AccountCreateInstruction {
account_num: 0, account_num: 0,
group, group,
owner, owner,

View File

@ -34,7 +34,7 @@ async fn test_perp() -> Result<(), TransportError> {
let account_0 = send_tx( let account_0 = send_tx(
solana, solana,
CreateAccountInstruction { AccountCreateInstruction {
account_num: 0, account_num: 0,
group, group,
owner, owner,
@ -47,7 +47,7 @@ async fn test_perp() -> Result<(), TransportError> {
let account_1 = send_tx( let account_1 = send_tx(
solana, solana,
CreateAccountInstruction { AccountCreateInstruction {
account_num: 1, account_num: 1,
group, group,
owner, owner,

View File

@ -36,7 +36,7 @@ async fn test_position_lifetime() -> Result<()> {
let account = send_tx( let account = send_tx(
solana, solana,
CreateAccountInstruction { AccountCreateInstruction {
account_num: 0, account_num: 0,
group, group,
owner, owner,
@ -49,7 +49,7 @@ async fn test_position_lifetime() -> Result<()> {
let funding_account = send_tx( let funding_account = send_tx(
solana, solana,
CreateAccountInstruction { AccountCreateInstruction {
account_num: 1, account_num: 1,
group, group,
owner, owner,

View File

@ -38,7 +38,7 @@ async fn test_serum() -> Result<(), TransportError> {
let account = send_tx( let account = send_tx(
solana, solana,
CreateAccountInstruction { AccountCreateInstruction {
account_num: 0, account_num: 0,
group, group,
owner, owner,

View File

@ -34,7 +34,7 @@ async fn test_update_index() -> Result<(), TransportError> {
// deposit some funds, to the vaults aren't empty // deposit some funds, to the vaults aren't empty
let deposit_account = send_tx( let deposit_account = send_tx(
solana, solana,
CreateAccountInstruction { AccountCreateInstruction {
account_num: 0, account_num: 0,
group, group,
owner, owner,
@ -61,7 +61,7 @@ async fn test_update_index() -> Result<(), TransportError> {
let withdraw_account = send_tx( let withdraw_account = send_tx(
solana, solana,
CreateAccountInstruction { AccountCreateInstruction {
account_num: 1, account_num: 1,
group, group,
owner, owner,
@ -105,7 +105,7 @@ async fn test_update_index() -> Result<(), TransportError> {
send_tx( send_tx(
solana, solana,
UpdateIndexInstruction { TokenUpdateIndexInstruction {
mint_info: tokens[0].mint_info, mint_info: tokens[0].mint_info,
}, },
) )

View File

@ -64,14 +64,14 @@ export class MangoClient {
// Group // Group
public async createGroup( public async groupCreate(
groupNum: number, groupNum: number,
testing: boolean, testing: boolean,
insuranceMintPk: PublicKey, insuranceMintPk: PublicKey,
): Promise<TransactionSignature> { ): Promise<TransactionSignature> {
const adminPk = (this.program.provider as AnchorProvider).wallet.publicKey; const adminPk = (this.program.provider as AnchorProvider).wallet.publicKey;
return await this.program.methods return await this.program.methods
.createGroup(groupNum, testing ? 1 : 0) .groupCreate(groupNum, testing ? 1 : 0)
.accounts({ .accounts({
admin: adminPk, admin: adminPk,
payer: adminPk, payer: adminPk,
@ -80,10 +80,10 @@ export class MangoClient {
.rpc(); .rpc();
} }
public async closeGroup(group: Group): Promise<TransactionSignature> { public async groupClose(group: Group): Promise<TransactionSignature> {
const adminPk = (this.program.provider as AnchorProvider).wallet.publicKey; const adminPk = (this.program.provider as AnchorProvider).wallet.publicKey;
return await this.program.methods return await this.program.methods
.closeGroup() .groupClose()
.accounts({ .accounts({
group: group.publicKey, group: group.publicKey,
admin: adminPk, admin: adminPk,
@ -338,13 +338,13 @@ export class MangoClient {
// Stub Oracle // Stub Oracle
public async createStubOracle( public async stubOracleCreate(
group: Group, group: Group,
mintPk: PublicKey, mintPk: PublicKey,
price: number, price: number,
): Promise<TransactionSignature> { ): Promise<TransactionSignature> {
return await this.program.methods return await this.program.methods
.createStubOracle({ val: I80F48.fromNumber(price).getData() }) .stubOracleCreate({ val: I80F48.fromNumber(price).getData() })
.accounts({ .accounts({
group: group.publicKey, group: group.publicKey,
admin: (this.program.provider as AnchorProvider).wallet.publicKey, admin: (this.program.provider as AnchorProvider).wallet.publicKey,
@ -354,12 +354,12 @@ export class MangoClient {
.rpc(); .rpc();
} }
public async closeStubOracle( public async stubOracleClose(
group: Group, group: Group,
oracle: PublicKey, oracle: PublicKey,
): Promise<TransactionSignature> { ): Promise<TransactionSignature> {
return await this.program.methods return await this.program.methods
.closeStubOracle() .stubOracleClose()
.accounts({ .accounts({
group: group.publicKey, group: group.publicKey,
oracle: oracle, oracle: oracle,
@ -369,13 +369,13 @@ export class MangoClient {
.rpc(); .rpc();
} }
public async setStubOracle( public async stubOracleSet(
group: Group, group: Group,
oraclePk: PublicKey, oraclePk: PublicKey,
price: number, price: number,
): Promise<TransactionSignature> { ): Promise<TransactionSignature> {
return await this.program.methods return await this.program.methods
.setStubOracle({ val: I80F48.fromNumber(price).getData() }) .stubOracleSet({ val: I80F48.fromNumber(price).getData() })
.accounts({ .accounts({
group: group.publicKey, group: group.publicKey,
admin: (this.program.provider as AnchorProvider).wallet.publicKey, admin: (this.program.provider as AnchorProvider).wallet.publicKey,
@ -434,7 +434,7 @@ export class MangoClient {
name?: string, name?: string,
): Promise<TransactionSignature> { ): Promise<TransactionSignature> {
return await this.program.methods return await this.program.methods
.createAccount(accountNumber, name ?? '') .accountCreate(accountNumber, name ?? '')
.accounts({ .accounts({
group: group.publicKey, group: group.publicKey,
owner: (this.program.provider as AnchorProvider).wallet.publicKey, owner: (this.program.provider as AnchorProvider).wallet.publicKey,
@ -450,7 +450,7 @@ export class MangoClient {
delegate?: PublicKey, delegate?: PublicKey,
): Promise<TransactionSignature> { ): Promise<TransactionSignature> {
return await this.program.methods return await this.program.methods
.editAccount(name, delegate) .accountEdit(name, delegate)
.accounts({ .accounts({
group: group.publicKey, group: group.publicKey,
account: mangoAccount.publicKey, account: mangoAccount.publicKey,
@ -495,7 +495,7 @@ export class MangoClient {
mangoAccount: MangoAccount, mangoAccount: MangoAccount,
): Promise<TransactionSignature> { ): Promise<TransactionSignature> {
return await this.program.methods return await this.program.methods
.closeAccount() .accountClose()
.accounts({ .accounts({
group: group.publicKey, group: group.publicKey,
account: mangoAccount.publicKey, account: mangoAccount.publicKey,

View File

@ -3,7 +3,7 @@ export type MangoV4 = {
"name": "mango_v4", "name": "mango_v4",
"instructions": [ "instructions": [
{ {
"name": "createGroup", "name": "groupCreate",
"accounts": [ "accounts": [
{ {
"name": "group", "name": "group",
@ -91,7 +91,7 @@ export type MangoV4 = {
] ]
}, },
{ {
"name": "closeGroup", "name": "groupClose",
"accounts": [ "accounts": [
{ {
"name": "group", "name": "group",
@ -568,7 +568,7 @@ export type MangoV4 = {
] ]
}, },
{ {
"name": "updateIndex", "name": "tokenUpdateIndex",
"accounts": [ "accounts": [
{ {
"name": "mintInfo", "name": "mintInfo",
@ -584,7 +584,7 @@ export type MangoV4 = {
"args": [] "args": []
}, },
{ {
"name": "createAccount", "name": "accountCreate",
"accounts": [ "accounts": [
{ {
"name": "group", "name": "group",
@ -648,7 +648,7 @@ export type MangoV4 = {
] ]
}, },
{ {
"name": "editAccount", "name": "accountEdit",
"accounts": [ "accounts": [
{ {
"name": "group", "name": "group",
@ -682,7 +682,7 @@ export type MangoV4 = {
] ]
}, },
{ {
"name": "closeAccount", "name": "accountClose",
"accounts": [ "accounts": [
{ {
"name": "group", "name": "group",
@ -713,7 +713,7 @@ export type MangoV4 = {
"args": [] "args": []
}, },
{ {
"name": "createStubOracle", "name": "stubOracleCreate",
"accounts": [ "accounts": [
{ {
"name": "group", "name": "group",
@ -776,7 +776,7 @@ export type MangoV4 = {
] ]
}, },
{ {
"name": "closeStubOracle", "name": "stubOracleClose",
"accounts": [ "accounts": [
{ {
"name": "group", "name": "group",
@ -807,7 +807,7 @@ export type MangoV4 = {
"args": [] "args": []
}, },
{ {
"name": "setStubOracle", "name": "stubOracleSet",
"accounts": [ "accounts": [
{ {
"name": "group", "name": "group",
@ -2810,6 +2810,14 @@ export type MangoV4 = {
4 4
] ]
} }
},
{
"name": "netDeposits",
"type": "f32"
},
{
"name": "netSettled",
"type": "f32"
} }
] ]
} }
@ -4531,7 +4539,7 @@ export const IDL: MangoV4 = {
"name": "mango_v4", "name": "mango_v4",
"instructions": [ "instructions": [
{ {
"name": "createGroup", "name": "groupCreate",
"accounts": [ "accounts": [
{ {
"name": "group", "name": "group",
@ -4619,7 +4627,7 @@ export const IDL: MangoV4 = {
] ]
}, },
{ {
"name": "closeGroup", "name": "groupClose",
"accounts": [ "accounts": [
{ {
"name": "group", "name": "group",
@ -5096,7 +5104,7 @@ export const IDL: MangoV4 = {
] ]
}, },
{ {
"name": "updateIndex", "name": "tokenUpdateIndex",
"accounts": [ "accounts": [
{ {
"name": "mintInfo", "name": "mintInfo",
@ -5112,7 +5120,7 @@ export const IDL: MangoV4 = {
"args": [] "args": []
}, },
{ {
"name": "createAccount", "name": "accountCreate",
"accounts": [ "accounts": [
{ {
"name": "group", "name": "group",
@ -5176,7 +5184,7 @@ export const IDL: MangoV4 = {
] ]
}, },
{ {
"name": "editAccount", "name": "accountEdit",
"accounts": [ "accounts": [
{ {
"name": "group", "name": "group",
@ -5210,7 +5218,7 @@ export const IDL: MangoV4 = {
] ]
}, },
{ {
"name": "closeAccount", "name": "accountClose",
"accounts": [ "accounts": [
{ {
"name": "group", "name": "group",
@ -5241,7 +5249,7 @@ export const IDL: MangoV4 = {
"args": [] "args": []
}, },
{ {
"name": "createStubOracle", "name": "stubOracleCreate",
"accounts": [ "accounts": [
{ {
"name": "group", "name": "group",
@ -5304,7 +5312,7 @@ export const IDL: MangoV4 = {
] ]
}, },
{ {
"name": "closeStubOracle", "name": "stubOracleClose",
"accounts": [ "accounts": [
{ {
"name": "group", "name": "group",
@ -5335,7 +5343,7 @@ export const IDL: MangoV4 = {
"args": [] "args": []
}, },
{ {
"name": "setStubOracle", "name": "stubOracleSet",
"accounts": [ "accounts": [
{ {
"name": "group", "name": "group",
@ -7338,6 +7346,14 @@ export const IDL: MangoV4 = {
4 4
] ]
} }
},
{
"name": "netDeposits",
"type": "f32"
},
{
"name": "netSettled",
"type": "f32"
} }
] ]
} }

View File

@ -44,7 +44,7 @@ async function main() {
const usdcDevnetOracle = ( const usdcDevnetOracle = (
await client.getStubOracle(group, usdcDevnetMint) await client.getStubOracle(group, usdcDevnetMint)
)[0]; )[0];
sig = await client.closeStubOracle(group, usdcDevnetOracle.publicKey); sig = await client.stubOracleClose(group, usdcDevnetOracle.publicKey);
console.log( console.log(
`Closed USDC stub oracle, sig https://explorer.solana.com/tx/${sig}?cluster=devnet`, `Closed USDC stub oracle, sig https://explorer.solana.com/tx/${sig}?cluster=devnet`,
); );
@ -75,7 +75,7 @@ async function main() {
// finally, close the group // finally, close the group
sig = await client.closeGroup(group); sig = await client.groupClose(group);
console.log( console.log(
`Closed group, sig https://explorer.solana.com/tx/${sig}?cluster=devnet`, `Closed group, sig https://explorer.solana.com/tx/${sig}?cluster=devnet`,
); );

View File

@ -55,7 +55,7 @@ async function main() {
console.log(`Creating Group...`); console.log(`Creating Group...`);
const insuranceMint = new PublicKey(DEVNET_MINTS.get('USDC')!); const insuranceMint = new PublicKey(DEVNET_MINTS.get('USDC')!);
try { try {
await client.createGroup(0, true, insuranceMint); await client.groupCreate(0, true, insuranceMint);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }
@ -96,7 +96,7 @@ async function main() {
console.log(`Registering USDC...`); console.log(`Registering USDC...`);
const usdcDevnetMint = new PublicKey(DEVNET_MINTS.get('USDC')!); const usdcDevnetMint = new PublicKey(DEVNET_MINTS.get('USDC')!);
try { try {
await client.createStubOracle(group, usdcDevnetMint, 1.0); await client.stubOracleCreate(group, usdcDevnetMint, 1.0);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }

View File

@ -44,7 +44,7 @@ async function main() {
const usdcMainnetBetaOracle = ( const usdcMainnetBetaOracle = (
await client.getStubOracle(group, usdcMainnetBetaMint) await client.getStubOracle(group, usdcMainnetBetaMint)
)[0]; )[0];
sig = await client.closeStubOracle(group, usdcMainnetBetaOracle.publicKey); sig = await client.stubOracleClose(group, usdcMainnetBetaOracle.publicKey);
console.log( console.log(
`Closed USDC stub oracle, sig https://explorer.solana.com/tx/${sig}`, `Closed USDC stub oracle, sig https://explorer.solana.com/tx/${sig}`,
); );
@ -74,7 +74,7 @@ async function main() {
} }
// finally, close the group // finally, close the group
sig = await client.closeGroup(group); sig = await client.groupClose(group);
console.log(`Closed group, sig https://explorer.solana.com/tx/${sig}`); console.log(`Closed group, sig https://explorer.solana.com/tx/${sig}`);
process.exit(); process.exit();

View File

@ -41,7 +41,7 @@ async function main() {
// group // group
console.log(`Creating Group...`); console.log(`Creating Group...`);
try { try {
await client.createGroup(0, true); await client.groupCreate(0, true);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }
@ -82,7 +82,7 @@ async function main() {
console.log(`Creating USDC stub oracle...`); console.log(`Creating USDC stub oracle...`);
const usdcMainnetMint = new PublicKey(MAINNET_MINTS.get('USDC')!); const usdcMainnetMint = new PublicKey(MAINNET_MINTS.get('USDC')!);
try { try {
await client.createStubOracle(group, usdcMainnetMint, 1.0); await client.stubOracleCreate(group, usdcMainnetMint, 1.0);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }

View File

@ -110,7 +110,7 @@ async function main() {
'devnet', 'devnet',
MANGO_V4_ID['devnet'], MANGO_V4_ID['devnet'],
); );
await client.setStubOracle(group, group.banksMap.get('USDC')?.oracle!, 0.5); await client.stubOracleSet(group, group.banksMap.get('USDC')?.oracle!, 0.5);
process.exit(); process.exit();
} }