From ffd83a7a05d751732ae7c2208f301502e8ee3001 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Wed, 6 Jul 2022 14:51:15 +0200 Subject: [PATCH] Rename instructions to follow naming pattern (#97) --- CHANGELOG.md | 8 +- client/src/client.rs | 4 +- .../{close_account.rs => account_close.rs} | 4 +- .../{create_account.rs => account_create.rs} | 4 +- .../{edit_account.rs => account_edit.rs} | 6 +- .../{close_group.rs => group_close.rs} | 4 +- .../{create_group.rs => group_create.rs} | 4 +- programs/mango-v4/src/instructions/mod.rs | 36 ++++----- ...se_stub_oracle.rs => stub_oracle_close.rs} | 4 +- ...e_stub_oracle.rs => stub_oracle_create.rs} | 4 +- ...{set_stub_oracle.rs => stub_oracle_set.rs} | 5 +- ...{update_index.rs => token_update_index.rs} | 4 +- programs/mango-v4/src/lib.rs | 40 +++++----- .../tests/program_test/mango_client.rs | 80 +++++++++---------- .../tests/program_test/mango_setup.rs | 6 +- .../mango-v4/tests/test_bankrupt_tokens.rs | 12 +-- programs/mango-v4/tests/test_basic.rs | 10 +-- programs/mango-v4/tests/test_delegate.rs | 8 +- .../tests/test_group_address_lookup_tables.rs | 8 +- .../mango-v4/tests/test_health_compute.rs | 6 +- programs/mango-v4/tests/test_liq_tokens.rs | 12 +-- programs/mango-v4/tests/test_margin_trade.rs | 12 +-- programs/mango-v4/tests/test_perp.rs | 4 +- .../mango-v4/tests/test_position_lifetime.rs | 4 +- programs/mango-v4/tests/test_serum.rs | 2 +- programs/mango-v4/tests/test_update_index.rs | 6 +- ts/client/src/client.ts | 26 +++--- ts/client/src/mango_v4.ts | 52 +++++++----- ts/client/src/scripts/example1-admin-close.ts | 4 +- ts/client/src/scripts/example1-admin.ts | 4 +- .../src/scripts/mb-example1-admin-close.ts | 4 +- ts/client/src/scripts/mb-example1-admin.ts | 4 +- .../example1-create-liquidation-candidate.ts | 2 +- 33 files changed, 207 insertions(+), 186 deletions(-) rename programs/mango-v4/src/instructions/{close_account.rs => account_close.rs} (92%) rename programs/mango-v4/src/instructions/{create_account.rs => account_create.rs} (92%) rename programs/mango-v4/src/instructions/{edit_account.rs => account_edit.rs} (94%) rename programs/mango-v4/src/instructions/{close_group.rs => group_close.rs} (84%) rename programs/mango-v4/src/instructions/{create_group.rs => group_create.rs} (93%) rename programs/mango-v4/src/instructions/{close_stub_oracle.rs => stub_oracle_close.rs} (86%) rename programs/mango-v4/src/instructions/{create_stub_oracle.rs => stub_oracle_create.rs} (90%) rename programs/mango-v4/src/instructions/{set_stub_oracle.rs => stub_oracle_set.rs} (78%) rename programs/mango-v4/src/instructions/{update_index.rs => token_update_index.rs} (96%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3392b9fe6..3f57a0fc8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,12 @@ Update this for each mainnet deployment. argument. The USDC/insurance mint is always used as quote currency for perps. - The `UpdateIndex` instruction now requires the `oracle` account to be passed 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 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 diff --git a/client/src/client.rs b/client/src/client.rs index 7f92cef49..e9783c3ec 100644 --- a/client/src/client.rs +++ b/client/src/client.rs @@ -103,7 +103,7 @@ impl MangoClient { .instruction(Instruction { program_id: mango_v4::id(), accounts: anchor_lang::ToAccountMetas::to_account_metas( - &mango_v4::accounts::CreateAccount { + &mango_v4::accounts::AccountCreate { group, owner: payer.pubkey(), account: { @@ -124,7 +124,7 @@ impl MangoClient { None, ), data: anchor_lang::InstructionData::data( - &mango_v4::instruction::CreateAccount { + &mango_v4::instruction::AccountCreate { account_num, name: mango_account_name.to_owned(), }, diff --git a/programs/mango-v4/src/instructions/close_account.rs b/programs/mango-v4/src/instructions/account_close.rs similarity index 92% rename from programs/mango-v4/src/instructions/close_account.rs rename to programs/mango-v4/src/instructions/account_close.rs index ce6e39a59..5e49d4cce 100644 --- a/programs/mango-v4/src/instructions/close_account.rs +++ b/programs/mango-v4/src/instructions/account_close.rs @@ -5,7 +5,7 @@ use crate::error::*; use crate::state::*; #[derive(Accounts)] -pub struct CloseAccount<'info> { +pub struct AccountClose<'info> { pub group: AccountLoader<'info, Group>, #[account( @@ -25,7 +25,7 @@ pub struct CloseAccount<'info> { pub token_program: Program<'info, Token>, } -pub fn close_account(ctx: Context) -> Result<()> { +pub fn account_close(ctx: Context) -> Result<()> { let group = ctx.accounts.group.load()?; // don't perform checks if group is just testing diff --git a/programs/mango-v4/src/instructions/create_account.rs b/programs/mango-v4/src/instructions/account_create.rs similarity index 92% rename from programs/mango-v4/src/instructions/create_account.rs rename to programs/mango-v4/src/instructions/account_create.rs index d91e70193..738bd5299 100644 --- a/programs/mango-v4/src/instructions/create_account.rs +++ b/programs/mango-v4/src/instructions/account_create.rs @@ -6,7 +6,7 @@ use crate::util::fill32_from_str; #[derive(Accounts)] #[instruction(account_num: u8)] -pub struct CreateAccount<'info> { +pub struct AccountCreate<'info> { pub group: AccountLoader<'info, Group>, #[account( @@ -25,7 +25,7 @@ pub struct CreateAccount<'info> { pub system_program: Program<'info, System>, } -pub fn create_account(ctx: Context, account_num: u8, name: String) -> Result<()> { +pub fn account_create(ctx: Context, account_num: u8, name: String) -> Result<()> { let mut account = ctx.accounts.account.load_init()?; account.name = fill32_from_str(name)?; diff --git a/programs/mango-v4/src/instructions/edit_account.rs b/programs/mango-v4/src/instructions/account_edit.rs similarity index 94% rename from programs/mango-v4/src/instructions/edit_account.rs rename to programs/mango-v4/src/instructions/account_edit.rs index 28bee8f45..ea0dccf56 100644 --- a/programs/mango-v4/src/instructions/edit_account.rs +++ b/programs/mango-v4/src/instructions/account_edit.rs @@ -5,7 +5,7 @@ use crate::state::*; use crate::util::fill32_from_str; #[derive(Accounts)] -pub struct EditAccount<'info> { +pub struct AccountEdit<'info> { pub group: AccountLoader<'info, Group>, #[account( @@ -18,8 +18,8 @@ pub struct EditAccount<'info> { pub owner: Signer<'info>, } -pub fn edit_account( - ctx: Context, +pub fn account_edit( + ctx: Context, name_opt: Option, // note: can also be used to unset by using the default pubkey here as a param delegate_opt: Option, diff --git a/programs/mango-v4/src/instructions/close_group.rs b/programs/mango-v4/src/instructions/group_close.rs similarity index 84% rename from programs/mango-v4/src/instructions/close_group.rs rename to programs/mango-v4/src/instructions/group_close.rs index e68b30996..6a1dff53b 100644 --- a/programs/mango-v4/src/instructions/close_group.rs +++ b/programs/mango-v4/src/instructions/group_close.rs @@ -3,7 +3,7 @@ use anchor_lang::prelude::*; use anchor_spl::token::Token; #[derive(Accounts)] -pub struct CloseGroup<'info> { +pub struct GroupClose<'info> { #[account( mut, constraint = group.load()?.testing == 1, @@ -21,7 +21,7 @@ pub struct CloseGroup<'info> { pub token_program: Program<'info, Token>, } -pub fn close_group(_ctx: Context) -> Result<()> { +pub fn group_close(_ctx: Context) -> Result<()> { // TODO: checks Ok(()) } diff --git a/programs/mango-v4/src/instructions/create_group.rs b/programs/mango-v4/src/instructions/group_create.rs similarity index 93% rename from programs/mango-v4/src/instructions/create_group.rs rename to programs/mango-v4/src/instructions/group_create.rs index 1ade6001b..7ba4204a4 100644 --- a/programs/mango-v4/src/instructions/create_group.rs +++ b/programs/mango-v4/src/instructions/group_create.rs @@ -6,7 +6,7 @@ use crate::state::*; #[derive(Accounts)] #[instruction(group_num: u32)] -pub struct CreateGroup<'info> { +pub struct GroupCreate<'info> { #[account( init, 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 fn create_group(ctx: Context, group_num: u32, testing: u8) -> Result<()> { +pub fn group_create(ctx: Context, group_num: u32, testing: u8) -> Result<()> { let mut group = ctx.accounts.group.load_init()?; group.admin = ctx.accounts.admin.key(); group.insurance_vault = ctx.accounts.insurance_vault.key(); diff --git a/programs/mango-v4/src/instructions/mod.rs b/programs/mango-v4/src/instructions/mod.rs index ebda4963f..a032b0089 100644 --- a/programs/mango-v4/src/instructions/mod.rs +++ b/programs/mango-v4/src/instructions/mod.rs @@ -1,15 +1,13 @@ +pub use account_close::*; +pub use account_create::*; +pub use account_edit::*; pub use benchmark::*; -pub use close_account::*; -pub use close_group::*; -pub use close_stub_oracle::*; 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_loan2::*; pub use flash_loan3::*; +pub use group_close::*; +pub use group_create::*; pub use liq_token_bankruptcy::*; pub use liq_token_with_token::*; 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_register_market::*; 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_deposit::*; pub use token_deregister::*; pub use token_edit::*; pub use token_register::*; +pub use token_update_index::*; pub use token_withdraw::*; -pub use update_index::*; +mod account_close; +mod account_create; +mod account_edit; mod benchmark; -mod close_account; -mod close_group; -mod close_stub_oracle; mod compute_account_data; -mod create_account; -mod create_group; -mod create_stub_oracle; -mod edit_account; mod flash_loan; mod flash_loan2; mod flash_loan3; +mod group_close; +mod group_create; mod liq_token_bankruptcy; mod liq_token_with_token; mod perp_cancel_all_orders; @@ -73,11 +71,13 @@ mod serum3_liq_force_cancel_orders; mod serum3_place_order; mod serum3_register_market; 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_deposit; mod token_deregister; mod token_edit; mod token_register; +mod token_update_index; mod token_withdraw; -mod update_index; diff --git a/programs/mango-v4/src/instructions/close_stub_oracle.rs b/programs/mango-v4/src/instructions/stub_oracle_close.rs similarity index 86% rename from programs/mango-v4/src/instructions/close_stub_oracle.rs rename to programs/mango-v4/src/instructions/stub_oracle_close.rs index edee153f2..2814de1da 100644 --- a/programs/mango-v4/src/instructions/close_stub_oracle.rs +++ b/programs/mango-v4/src/instructions/stub_oracle_close.rs @@ -4,7 +4,7 @@ use anchor_spl::token::Token; use crate::state::*; #[derive(Accounts)] -pub struct CloseStubOracle<'info> { +pub struct StubOracleClose<'info> { #[account( constraint = group.load()?.testing == 1, has_one = admin, @@ -27,6 +27,6 @@ pub struct CloseStubOracle<'info> { pub token_program: Program<'info, Token>, } -pub fn close_stub_oracle(_ctx: Context) -> Result<()> { +pub fn stub_oracle_close(_ctx: Context) -> Result<()> { Ok(()) } diff --git a/programs/mango-v4/src/instructions/create_stub_oracle.rs b/programs/mango-v4/src/instructions/stub_oracle_create.rs similarity index 90% rename from programs/mango-v4/src/instructions/create_stub_oracle.rs rename to programs/mango-v4/src/instructions/stub_oracle_create.rs index c03dc854d..0a3196915 100644 --- a/programs/mango-v4/src/instructions/create_stub_oracle.rs +++ b/programs/mango-v4/src/instructions/stub_oracle_create.rs @@ -5,7 +5,7 @@ use fixed::types::I80F48; use crate::state::*; #[derive(Accounts)] -pub struct CreateStubOracle<'info> { +pub struct StubOracleCreate<'info> { #[account( has_one = admin, )] @@ -30,7 +30,7 @@ pub struct CreateStubOracle<'info> { pub system_program: Program<'info, System>, } -pub fn create_stub_oracle(ctx: Context, price: I80F48) -> Result<()> { +pub fn stub_oracle_create(ctx: Context, price: I80F48) -> Result<()> { let mut oracle = ctx.accounts.oracle.load_init()?; oracle.group = ctx.accounts.group.key(); oracle.mint = ctx.accounts.token_mint.key(); diff --git a/programs/mango-v4/src/instructions/set_stub_oracle.rs b/programs/mango-v4/src/instructions/stub_oracle_set.rs similarity index 78% rename from programs/mango-v4/src/instructions/set_stub_oracle.rs rename to programs/mango-v4/src/instructions/stub_oracle_set.rs index ecf55c32b..db600610d 100644 --- a/programs/mango-v4/src/instructions/set_stub_oracle.rs +++ b/programs/mango-v4/src/instructions/stub_oracle_set.rs @@ -4,7 +4,7 @@ use fixed::types::I80F48; use crate::state::*; #[derive(Accounts)] -pub struct SetStubOracle<'info> { +pub struct StubOracleSet<'info> { #[account( has_one = admin, )] @@ -22,8 +22,7 @@ pub struct SetStubOracle<'info> { pub payer: Signer<'info>, } -// TODO: add admin requirement for changing price -pub fn set_stub_oracle(ctx: Context, price: I80F48) -> Result<()> { +pub fn stub_oracle_set(ctx: Context, price: I80F48) -> Result<()> { let mut oracle = ctx.accounts.oracle.load_mut()?; oracle.price = price; oracle.last_updated = Clock::get()?.unix_timestamp; diff --git a/programs/mango-v4/src/instructions/update_index.rs b/programs/mango-v4/src/instructions/token_update_index.rs similarity index 96% rename from programs/mango-v4/src/instructions/update_index.rs rename to programs/mango-v4/src/instructions/token_update_index.rs index 6abed272f..39d3d15c0 100644 --- a/programs/mango-v4/src/instructions/update_index.rs +++ b/programs/mango-v4/src/instructions/token_update_index.rs @@ -8,12 +8,12 @@ use crate::{ use checked_math as cm; use fixed::types::I80F48; #[derive(Accounts)] -pub struct UpdateIndex<'info> { +pub struct TokenUpdateIndex<'info> { pub mint_info: AccountLoader<'info, MintInfo>, pub oracle: UncheckedAccount<'info>, } -pub fn update_index(ctx: Context) -> Result<()> { +pub fn token_update_index(ctx: Context) -> Result<()> { let mint_info = ctx.accounts.mint_info.load()?; require_keys_eq!(mint_info.oracle.key(), ctx.accounts.oracle.key()); diff --git a/programs/mango-v4/src/lib.rs b/programs/mango-v4/src/lib.rs index 4a39d28bb..f914cde0b 100644 --- a/programs/mango-v4/src/lib.rs +++ b/programs/mango-v4/src/lib.rs @@ -30,12 +30,12 @@ pub mod mango_v4 { use super::*; - pub fn create_group(ctx: Context, group_num: u32, testing: u8) -> Result<()> { - instructions::create_group(ctx, group_num, testing) + pub fn group_create(ctx: Context, group_num: u32, testing: u8) -> Result<()> { + instructions::group_create(ctx, group_num, testing) } - pub fn close_group(ctx: Context) -> Result<()> { - instructions::close_group(ctx) + pub fn group_close(ctx: Context) -> Result<()> { + instructions::group_close(ctx) } #[allow(clippy::too_many_arguments)] @@ -118,28 +118,28 @@ pub mod mango_v4 { instructions::token_deregister(ctx, token_index) } - pub fn update_index(ctx: Context) -> Result<()> { - instructions::update_index(ctx) + pub fn token_update_index(ctx: Context) -> Result<()> { + instructions::token_update_index(ctx) } - pub fn create_account( - ctx: Context, + pub fn account_create( + ctx: Context, account_num: u8, name: String, ) -> Result<()> { - instructions::create_account(ctx, account_num, name) + instructions::account_create(ctx, account_num, name) } - pub fn edit_account( - ctx: Context, + pub fn account_edit( + ctx: Context, name_opt: Option, delegate_opt: Option, ) -> Result<()> { - instructions::edit_account(ctx, name_opt, delegate_opt) + instructions::account_edit(ctx, name_opt, delegate_opt) } - pub fn close_account(ctx: Context) -> Result<()> { - instructions::close_account(ctx) + pub fn account_close(ctx: Context) -> Result<()> { + instructions::account_close(ctx) } // todo: @@ -147,16 +147,16 @@ pub mod mango_v4 { // 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, price: I80F48) -> Result<()> { - instructions::create_stub_oracle(ctx, price) + pub fn stub_oracle_create(ctx: Context, price: I80F48) -> Result<()> { + instructions::stub_oracle_create(ctx, price) } - pub fn close_stub_oracle(ctx: Context) -> Result<()> { - instructions::close_stub_oracle(ctx) + pub fn stub_oracle_close(ctx: Context) -> Result<()> { + instructions::stub_oracle_close(ctx) } - pub fn set_stub_oracle(ctx: Context, price: I80F48) -> Result<()> { - instructions::set_stub_oracle(ctx, price) + pub fn stub_oracle_set(ctx: Context, price: I80F48) -> Result<()> { + instructions::stub_oracle_set(ctx, price) } pub fn token_deposit(ctx: Context, amount: u64) -> Result<()> { diff --git a/programs/mango-v4/tests/program_test/mango_client.rs b/programs/mango-v4/tests/program_test/mango_client.rs index 5c7276cee..e7e16df45 100644 --- a/programs/mango-v4/tests/program_test/mango_client.rs +++ b/programs/mango-v4/tests/program_test/mango_client.rs @@ -1044,7 +1044,7 @@ impl<'keypair> ClientInstruction for TokenDeregisterInstruction<'keypair> { } } -pub struct SetStubOracleInstruction<'keypair> { +pub struct StubOracleSetInstruction<'keypair> { pub mint: Pubkey, pub group: Pubkey, pub admin: &'keypair Keypair, @@ -1052,9 +1052,9 @@ pub struct SetStubOracleInstruction<'keypair> { pub price: &'static str, } #[async_trait::async_trait(?Send)] -impl<'keypair> ClientInstruction for SetStubOracleInstruction<'keypair> { - type Accounts = mango_v4::accounts::SetStubOracle; - type Instruction = mango_v4::instruction::SetStubOracle; +impl<'keypair> ClientInstruction for StubOracleSetInstruction<'keypair> { + type Accounts = mango_v4::accounts::StubOracleSet; + type Instruction = mango_v4::instruction::StubOracleSet; async fn to_instruction( &self, @@ -1091,16 +1091,16 @@ impl<'keypair> ClientInstruction for SetStubOracleInstruction<'keypair> { } } -pub struct CreateStubOracle<'keypair> { +pub struct StubOracleCreate<'keypair> { pub group: Pubkey, pub mint: Pubkey, pub admin: &'keypair Keypair, pub payer: &'keypair Keypair, } #[async_trait::async_trait(?Send)] -impl<'keypair> ClientInstruction for CreateStubOracle<'keypair> { - type Accounts = mango_v4::accounts::CreateStubOracle; - type Instruction = mango_v4::instruction::CreateStubOracle; +impl<'keypair> ClientInstruction for StubOracleCreate<'keypair> { + type Accounts = mango_v4::accounts::StubOracleCreate; + type Instruction = mango_v4::instruction::StubOracleCreate; async fn to_instruction( &self, @@ -1139,16 +1139,16 @@ impl<'keypair> ClientInstruction for CreateStubOracle<'keypair> { } } -pub struct CloseStubOracleInstruction<'keypair> { +pub struct StubOracleCloseInstruction<'keypair> { pub group: Pubkey, pub mint: Pubkey, pub admin: &'keypair Keypair, pub sol_destination: Pubkey, } #[async_trait::async_trait(?Send)] -impl<'keypair> ClientInstruction for CloseStubOracleInstruction<'keypair> { - type Accounts = mango_v4::accounts::CloseStubOracle; - type Instruction = mango_v4::instruction::CloseStubOracle; +impl<'keypair> ClientInstruction for StubOracleCloseInstruction<'keypair> { + type Accounts = mango_v4::accounts::StubOracleClose; + type Instruction = mango_v4::instruction::StubOracleClose; async fn to_instruction( &self, @@ -1184,15 +1184,15 @@ impl<'keypair> ClientInstruction for CloseStubOracleInstruction<'keypair> { } } -pub struct CreateGroupInstruction<'keypair> { +pub struct GroupCreateInstruction<'keypair> { pub admin: &'keypair Keypair, pub payer: &'keypair Keypair, pub insurance_mint: Pubkey, } #[async_trait::async_trait(?Send)] -impl<'keypair> ClientInstruction for CreateGroupInstruction<'keypair> { - type Accounts = mango_v4::accounts::CreateGroup; - type Instruction = mango_v4::instruction::CreateGroup; +impl<'keypair> ClientInstruction for GroupCreateInstruction<'keypair> { + type Accounts = mango_v4::accounts::GroupCreate; + type Instruction = mango_v4::instruction::GroupCreate; async fn to_instruction( &self, _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 group: Pubkey, pub sol_destination: Pubkey, } #[async_trait::async_trait(?Send)] -impl<'keypair> ClientInstruction for CloseGroupInstruction<'keypair> { - type Accounts = mango_v4::accounts::CloseGroup; - type Instruction = mango_v4::instruction::CloseGroup; +impl<'keypair> ClientInstruction for GroupCloseInstruction<'keypair> { + type Accounts = mango_v4::accounts::GroupClose; + type Instruction = mango_v4::instruction::GroupClose; async fn to_instruction( &self, _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 group: Pubkey, @@ -1279,15 +1279,15 @@ pub struct CreateAccountInstruction<'keypair> { pub payer: &'keypair Keypair, } #[async_trait::async_trait(?Send)] -impl<'keypair> ClientInstruction for CreateAccountInstruction<'keypair> { - type Accounts = mango_v4::accounts::CreateAccount; - type Instruction = mango_v4::instruction::CreateAccount; +impl<'keypair> ClientInstruction for AccountCreateInstruction<'keypair> { + type Accounts = mango_v4::accounts::AccountCreate; + type Instruction = mango_v4::instruction::AccountCreate; async fn to_instruction( &self, _account_loader: impl ClientAccountLoader + 'async_trait, ) -> (Self::Accounts, instruction::Instruction) { let program_id = mango_v4::id(); - let instruction = mango_v4::instruction::CreateAccount { + let instruction = mango_v4::instruction::AccountCreate { account_num: self.account_num, name: "my_mango_account".to_string(), }; @@ -1303,7 +1303,7 @@ impl<'keypair> ClientInstruction for CreateAccountInstruction<'keypair> { ) .0; - let accounts = mango_v4::accounts::CreateAccount { + let accounts = mango_v4::accounts::AccountCreate { group: self.group, owner: self.owner.pubkey(), account, @@ -1320,7 +1320,7 @@ impl<'keypair> ClientInstruction for CreateAccountInstruction<'keypair> { } } -pub struct EditAccountInstruction<'keypair> { +pub struct AccountEditInstruction<'keypair> { pub account_num: u8, pub group: Pubkey, pub owner: &'keypair Keypair, @@ -1328,15 +1328,15 @@ pub struct EditAccountInstruction<'keypair> { pub delegate: Pubkey, } #[async_trait::async_trait(?Send)] -impl<'keypair> ClientInstruction for EditAccountInstruction<'keypair> { - type Accounts = mango_v4::accounts::EditAccount; - type Instruction = mango_v4::instruction::EditAccount; +impl<'keypair> ClientInstruction for AccountEditInstruction<'keypair> { + type Accounts = mango_v4::accounts::AccountEdit; + type Instruction = mango_v4::instruction::AccountEdit; async fn to_instruction( &self, _account_loader: impl ClientAccountLoader + 'async_trait, ) -> (Self::Accounts, instruction::Instruction) { 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()), delegate_opt: Option::from(self.delegate), }; @@ -1352,7 +1352,7 @@ impl<'keypair> ClientInstruction for EditAccountInstruction<'keypair> { ) .0; - let accounts = mango_v4::accounts::EditAccount { + let accounts = mango_v4::accounts::AccountEdit { group: self.group, account, 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 account: Pubkey, pub owner: &'keypair Keypair, pub sol_destination: Pubkey, } #[async_trait::async_trait(?Send)] -impl<'keypair> ClientInstruction for CloseAccountInstruction<'keypair> { - type Accounts = mango_v4::accounts::CloseAccount; - type Instruction = mango_v4::instruction::CloseAccount; +impl<'keypair> ClientInstruction for AccountCloseInstruction<'keypair> { + type Accounts = mango_v4::accounts::AccountClose; + type Instruction = mango_v4::instruction::AccountClose; async fn to_instruction( &self, _account_loader: impl ClientAccountLoader + 'async_trait, @@ -2545,13 +2545,13 @@ impl ClientInstruction for BenchmarkInstruction { vec![] } } -pub struct UpdateIndexInstruction { +pub struct TokenUpdateIndexInstruction { pub mint_info: Pubkey, } #[async_trait::async_trait(?Send)] -impl ClientInstruction for UpdateIndexInstruction { - type Accounts = mango_v4::accounts::UpdateIndex; - type Instruction = mango_v4::instruction::UpdateIndex; +impl ClientInstruction for TokenUpdateIndexInstruction { + type Accounts = mango_v4::accounts::TokenUpdateIndex; + type Instruction = mango_v4::instruction::TokenUpdateIndex; async fn to_instruction( &self, loader: impl ClientAccountLoader + 'async_trait, diff --git a/programs/mango-v4/tests/program_test/mango_setup.rs b/programs/mango-v4/tests/program_test/mango_setup.rs index fbcf52d2c..9f10d618f 100644 --- a/programs/mango-v4/tests/program_test/mango_setup.rs +++ b/programs/mango-v4/tests/program_test/mango_setup.rs @@ -38,7 +38,7 @@ impl<'a> GroupWithTokensConfig<'a> { } = self; let create_group_accounts = send_tx( solana, - CreateGroupInstruction { + GroupCreateInstruction { admin, payer, insurance_mint: mints[0].pubkey, @@ -55,7 +55,7 @@ impl<'a> GroupWithTokensConfig<'a> { for (index, mint) in mints.iter().enumerate() { let create_stub_oracle_accounts = send_tx( solana, - CreateStubOracle { + StubOracleCreate { group, mint: mint.pubkey, admin, @@ -67,7 +67,7 @@ impl<'a> GroupWithTokensConfig<'a> { let oracle = create_stub_oracle_accounts.oracle; send_tx( solana, - SetStubOracleInstruction { + StubOracleSetInstruction { group, admin, mint: mint.pubkey, diff --git a/programs/mango-v4/tests/test_bankrupt_tokens.rs b/programs/mango-v4/tests/test_bankrupt_tokens.rs index 10aa5ff6f..d248fdd38 100644 --- a/programs/mango-v4/tests/test_bankrupt_tokens.rs +++ b/programs/mango-v4/tests/test_bankrupt_tokens.rs @@ -42,7 +42,7 @@ async fn test_bankrupt_tokens_socialize_loss() -> Result<(), TransportError> { // deposit some funds, to the vaults aren't empty let vault_account = send_tx( solana, - CreateAccountInstruction { + AccountCreateInstruction { account_num: 2, group, owner, @@ -87,7 +87,7 @@ async fn test_bankrupt_tokens_socialize_loss() -> Result<(), TransportError> { // let account = send_tx( solana, - CreateAccountInstruction { + AccountCreateInstruction { account_num: 0, group, owner, @@ -174,7 +174,7 @@ async fn test_bankrupt_tokens_socialize_loss() -> Result<(), TransportError> { // send_tx( solana, - SetStubOracleInstruction { + StubOracleSetInstruction { group, admin, 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 let vault_account = send_tx( solana, - CreateAccountInstruction { + AccountCreateInstruction { account_num: 2, group, owner, @@ -400,7 +400,7 @@ async fn test_bankrupt_tokens_insurance_fund() -> Result<(), TransportError> { // let account = send_tx( solana, - CreateAccountInstruction { + AccountCreateInstruction { account_num: 0, group, owner, @@ -487,7 +487,7 @@ async fn test_bankrupt_tokens_insurance_fund() -> Result<(), TransportError> { // send_tx( solana, - SetStubOracleInstruction { + StubOracleSetInstruction { group, admin, mint: borrow_token2.mint.pubkey, diff --git a/programs/mango-v4/tests/test_basic.rs b/programs/mango-v4/tests/test_basic.rs index 3302df083..6b31eaec8 100644 --- a/programs/mango-v4/tests/test_basic.rs +++ b/programs/mango-v4/tests/test_basic.rs @@ -39,7 +39,7 @@ async fn test_basic() -> Result<(), TransportError> { let account = send_tx( solana, - CreateAccountInstruction { + AccountCreateInstruction { account_num: 0, group, owner, @@ -155,7 +155,7 @@ async fn test_basic() -> Result<(), TransportError> { // withdraw whatever is remaining, can't close bank vault without this send_tx( solana, - UpdateIndexInstruction { + TokenUpdateIndexInstruction { mint_info: tokens[0].mint_info, }, ) @@ -179,7 +179,7 @@ async fn test_basic() -> Result<(), TransportError> { // close account send_tx( solana, - CloseAccountInstruction { + AccountCloseInstruction { group, account, owner, @@ -217,7 +217,7 @@ async fn test_basic() -> Result<(), TransportError> { // close stub oracle send_tx( solana, - CloseStubOracleInstruction { + StubOracleCloseInstruction { group, mint: bank_data.mint, admin, @@ -230,7 +230,7 @@ async fn test_basic() -> Result<(), TransportError> { // close group send_tx( solana, - CloseGroupInstruction { + GroupCloseInstruction { group, admin, sol_destination: payer.pubkey(), diff --git a/programs/mango-v4/tests/test_delegate.rs b/programs/mango-v4/tests/test_delegate.rs index 70ca717f7..021505776 100644 --- a/programs/mango-v4/tests/test_delegate.rs +++ b/programs/mango-v4/tests/test_delegate.rs @@ -35,7 +35,7 @@ async fn test_delegate() -> Result<(), TransportError> { let account = send_tx( solana, - CreateAccountInstruction { + AccountCreateInstruction { account_num: 0, group, owner, @@ -66,7 +66,7 @@ async fn test_delegate() -> Result<(), TransportError> { { send_tx( solana, - EditAccountInstruction { + AccountEditInstruction { delegate: delegate.pubkey(), account_num: 0, group, @@ -84,7 +84,7 @@ async fn test_delegate() -> Result<(), TransportError> { { let res = send_tx( solana, - EditAccountInstruction { + AccountEditInstruction { delegate: delegate.pubkey(), account_num: 0, group, @@ -136,7 +136,7 @@ async fn test_delegate() -> Result<(), TransportError> { .unwrap(); let res = send_tx( solana, - CloseAccountInstruction { + AccountCloseInstruction { group, account, owner: delegate, diff --git a/programs/mango-v4/tests/test_group_address_lookup_tables.rs b/programs/mango-v4/tests/test_group_address_lookup_tables.rs index a64d97fa8..b09e09749 100644 --- a/programs/mango-v4/tests/test_group_address_lookup_tables.rs +++ b/programs/mango-v4/tests/test_group_address_lookup_tables.rs @@ -31,14 +31,14 @@ async fn test_group_address_lookup_tables() -> Result<()> { // SETUP: Create a group // - let group = send_tx(solana, CreateGroupInstruction { admin, payer }) + let group = send_tx(solana, GroupCreateInstruction { admin, payer }) .await .unwrap() .group; let account = send_tx( solana, - CreateAccountInstruction { + AccountCreateInstruction { account_num: 0, group, 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 create_stub_oracle_accounts = send_tx( solana, - CreateStubOracle { + StubOracleCreate { mint: mint.pubkey, payer, }, @@ -66,7 +66,7 @@ async fn test_group_address_lookup_tables() -> Result<()> { let oracle = create_stub_oracle_accounts.oracle; send_tx( solana, - SetStubOracleInstruction { + StubOracleSetInstruction { group, admin, mint: mint.pubkey, diff --git a/programs/mango-v4/tests/test_health_compute.rs b/programs/mango-v4/tests/test_health_compute.rs index 1bb6a7d62..89dce2cdb 100644 --- a/programs/mango-v4/tests/test_health_compute.rs +++ b/programs/mango-v4/tests/test_health_compute.rs @@ -35,7 +35,7 @@ async fn test_health_compute_tokens() -> Result<(), TransportError> { let account = send_tx( solana, - CreateAccountInstruction { + AccountCreateInstruction { account_num: 0, group, owner, @@ -99,7 +99,7 @@ async fn test_health_compute_serum() -> Result<(), TransportError> { let account = send_tx( solana, - CreateAccountInstruction { + AccountCreateInstruction { account_num: 0, group, owner, @@ -210,7 +210,7 @@ async fn test_health_compute_perp() -> Result<(), TransportError> { let account = send_tx( solana, - CreateAccountInstruction { + AccountCreateInstruction { account_num: 0, group, owner, diff --git a/programs/mango-v4/tests/test_liq_tokens.rs b/programs/mango-v4/tests/test_liq_tokens.rs index 640f0401e..f9a0905b0 100644 --- a/programs/mango-v4/tests/test_liq_tokens.rs +++ b/programs/mango-v4/tests/test_liq_tokens.rs @@ -40,7 +40,7 @@ async fn test_liq_tokens_force_cancel() -> Result<(), TransportError> { // deposit some funds, to the vaults aren't empty let vault_account = send_tx( solana, - CreateAccountInstruction { + AccountCreateInstruction { account_num: 2, group, owner, @@ -95,7 +95,7 @@ async fn test_liq_tokens_force_cancel() -> Result<(), TransportError> { // let account = send_tx( solana, - CreateAccountInstruction { + AccountCreateInstruction { account_num: 0, group, owner, @@ -161,7 +161,7 @@ async fn test_liq_tokens_force_cancel() -> Result<(), TransportError> { // send_tx( solana, - SetStubOracleInstruction { + StubOracleSetInstruction { group, admin, 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 let vault_account = send_tx( solana, - CreateAccountInstruction { + AccountCreateInstruction { account_num: 2, group, owner, @@ -279,7 +279,7 @@ async fn test_liq_tokens_with_token() -> Result<(), TransportError> { // let account = send_tx( solana, - CreateAccountInstruction { + AccountCreateInstruction { account_num: 0, group, owner, @@ -351,7 +351,7 @@ async fn test_liq_tokens_with_token() -> Result<(), TransportError> { // send_tx( solana, - SetStubOracleInstruction { + StubOracleSetInstruction { group, admin, mint: borrow_token1.mint.pubkey, diff --git a/programs/mango-v4/tests/test_margin_trade.rs b/programs/mango-v4/tests/test_margin_trade.rs index edd6bf6a0..9ecdd4d86 100644 --- a/programs/mango-v4/tests/test_margin_trade.rs +++ b/programs/mango-v4/tests/test_margin_trade.rs @@ -51,7 +51,7 @@ async fn test_margin_trade1() -> Result<(), BanksClientError> { let provider_account = send_tx( solana, - CreateAccountInstruction { + AccountCreateInstruction { account_num: 1, group, owner, @@ -93,7 +93,7 @@ async fn test_margin_trade1() -> Result<(), BanksClientError> { let account = send_tx( solana, - CreateAccountInstruction { + AccountCreateInstruction { account_num: 0, group, owner, @@ -367,7 +367,7 @@ async fn test_margin_trade2() -> Result<(), BanksClientError> { let provider_account = send_tx( solana, - CreateAccountInstruction { + AccountCreateInstruction { account_num: 1, group, owner, @@ -409,7 +409,7 @@ async fn test_margin_trade2() -> Result<(), BanksClientError> { let account = send_tx( solana, - CreateAccountInstruction { + AccountCreateInstruction { account_num: 0, group, owner, @@ -628,7 +628,7 @@ async fn test_margin_trade3() -> Result<(), BanksClientError> { let provider_account = send_tx( solana, - CreateAccountInstruction { + AccountCreateInstruction { account_num: 1, group, owner, @@ -670,7 +670,7 @@ async fn test_margin_trade3() -> Result<(), BanksClientError> { let account = send_tx( solana, - CreateAccountInstruction { + AccountCreateInstruction { account_num: 0, group, owner, diff --git a/programs/mango-v4/tests/test_perp.rs b/programs/mango-v4/tests/test_perp.rs index 02d86271f..ce71c068f 100644 --- a/programs/mango-v4/tests/test_perp.rs +++ b/programs/mango-v4/tests/test_perp.rs @@ -34,7 +34,7 @@ async fn test_perp() -> Result<(), TransportError> { let account_0 = send_tx( solana, - CreateAccountInstruction { + AccountCreateInstruction { account_num: 0, group, owner, @@ -47,7 +47,7 @@ async fn test_perp() -> Result<(), TransportError> { let account_1 = send_tx( solana, - CreateAccountInstruction { + AccountCreateInstruction { account_num: 1, group, owner, diff --git a/programs/mango-v4/tests/test_position_lifetime.rs b/programs/mango-v4/tests/test_position_lifetime.rs index b1ef59c72..0f1be2629 100644 --- a/programs/mango-v4/tests/test_position_lifetime.rs +++ b/programs/mango-v4/tests/test_position_lifetime.rs @@ -36,7 +36,7 @@ async fn test_position_lifetime() -> Result<()> { let account = send_tx( solana, - CreateAccountInstruction { + AccountCreateInstruction { account_num: 0, group, owner, @@ -49,7 +49,7 @@ async fn test_position_lifetime() -> Result<()> { let funding_account = send_tx( solana, - CreateAccountInstruction { + AccountCreateInstruction { account_num: 1, group, owner, diff --git a/programs/mango-v4/tests/test_serum.rs b/programs/mango-v4/tests/test_serum.rs index 3b8e4faed..e2c6d798a 100644 --- a/programs/mango-v4/tests/test_serum.rs +++ b/programs/mango-v4/tests/test_serum.rs @@ -38,7 +38,7 @@ async fn test_serum() -> Result<(), TransportError> { let account = send_tx( solana, - CreateAccountInstruction { + AccountCreateInstruction { account_num: 0, group, owner, diff --git a/programs/mango-v4/tests/test_update_index.rs b/programs/mango-v4/tests/test_update_index.rs index 5a36527b3..2efc9ba49 100644 --- a/programs/mango-v4/tests/test_update_index.rs +++ b/programs/mango-v4/tests/test_update_index.rs @@ -34,7 +34,7 @@ async fn test_update_index() -> Result<(), TransportError> { // deposit some funds, to the vaults aren't empty let deposit_account = send_tx( solana, - CreateAccountInstruction { + AccountCreateInstruction { account_num: 0, group, owner, @@ -61,7 +61,7 @@ async fn test_update_index() -> Result<(), TransportError> { let withdraw_account = send_tx( solana, - CreateAccountInstruction { + AccountCreateInstruction { account_num: 1, group, owner, @@ -105,7 +105,7 @@ async fn test_update_index() -> Result<(), TransportError> { send_tx( solana, - UpdateIndexInstruction { + TokenUpdateIndexInstruction { mint_info: tokens[0].mint_info, }, ) diff --git a/ts/client/src/client.ts b/ts/client/src/client.ts index 682169f37..2d5fca15e 100644 --- a/ts/client/src/client.ts +++ b/ts/client/src/client.ts @@ -64,14 +64,14 @@ export class MangoClient { // Group - public async createGroup( + public async groupCreate( groupNum: number, testing: boolean, insuranceMintPk: PublicKey, ): Promise { const adminPk = (this.program.provider as AnchorProvider).wallet.publicKey; return await this.program.methods - .createGroup(groupNum, testing ? 1 : 0) + .groupCreate(groupNum, testing ? 1 : 0) .accounts({ admin: adminPk, payer: adminPk, @@ -80,10 +80,10 @@ export class MangoClient { .rpc(); } - public async closeGroup(group: Group): Promise { + public async groupClose(group: Group): Promise { const adminPk = (this.program.provider as AnchorProvider).wallet.publicKey; return await this.program.methods - .closeGroup() + .groupClose() .accounts({ group: group.publicKey, admin: adminPk, @@ -338,13 +338,13 @@ export class MangoClient { // Stub Oracle - public async createStubOracle( + public async stubOracleCreate( group: Group, mintPk: PublicKey, price: number, ): Promise { return await this.program.methods - .createStubOracle({ val: I80F48.fromNumber(price).getData() }) + .stubOracleCreate({ val: I80F48.fromNumber(price).getData() }) .accounts({ group: group.publicKey, admin: (this.program.provider as AnchorProvider).wallet.publicKey, @@ -354,12 +354,12 @@ export class MangoClient { .rpc(); } - public async closeStubOracle( + public async stubOracleClose( group: Group, oracle: PublicKey, ): Promise { return await this.program.methods - .closeStubOracle() + .stubOracleClose() .accounts({ group: group.publicKey, oracle: oracle, @@ -369,13 +369,13 @@ export class MangoClient { .rpc(); } - public async setStubOracle( + public async stubOracleSet( group: Group, oraclePk: PublicKey, price: number, ): Promise { return await this.program.methods - .setStubOracle({ val: I80F48.fromNumber(price).getData() }) + .stubOracleSet({ val: I80F48.fromNumber(price).getData() }) .accounts({ group: group.publicKey, admin: (this.program.provider as AnchorProvider).wallet.publicKey, @@ -434,7 +434,7 @@ export class MangoClient { name?: string, ): Promise { return await this.program.methods - .createAccount(accountNumber, name ?? '') + .accountCreate(accountNumber, name ?? '') .accounts({ group: group.publicKey, owner: (this.program.provider as AnchorProvider).wallet.publicKey, @@ -450,7 +450,7 @@ export class MangoClient { delegate?: PublicKey, ): Promise { return await this.program.methods - .editAccount(name, delegate) + .accountEdit(name, delegate) .accounts({ group: group.publicKey, account: mangoAccount.publicKey, @@ -495,7 +495,7 @@ export class MangoClient { mangoAccount: MangoAccount, ): Promise { return await this.program.methods - .closeAccount() + .accountClose() .accounts({ group: group.publicKey, account: mangoAccount.publicKey, diff --git a/ts/client/src/mango_v4.ts b/ts/client/src/mango_v4.ts index 5cdfe892a..467df8fad 100644 --- a/ts/client/src/mango_v4.ts +++ b/ts/client/src/mango_v4.ts @@ -3,7 +3,7 @@ export type MangoV4 = { "name": "mango_v4", "instructions": [ { - "name": "createGroup", + "name": "groupCreate", "accounts": [ { "name": "group", @@ -91,7 +91,7 @@ export type MangoV4 = { ] }, { - "name": "closeGroup", + "name": "groupClose", "accounts": [ { "name": "group", @@ -568,7 +568,7 @@ export type MangoV4 = { ] }, { - "name": "updateIndex", + "name": "tokenUpdateIndex", "accounts": [ { "name": "mintInfo", @@ -584,7 +584,7 @@ export type MangoV4 = { "args": [] }, { - "name": "createAccount", + "name": "accountCreate", "accounts": [ { "name": "group", @@ -648,7 +648,7 @@ export type MangoV4 = { ] }, { - "name": "editAccount", + "name": "accountEdit", "accounts": [ { "name": "group", @@ -682,7 +682,7 @@ export type MangoV4 = { ] }, { - "name": "closeAccount", + "name": "accountClose", "accounts": [ { "name": "group", @@ -713,7 +713,7 @@ export type MangoV4 = { "args": [] }, { - "name": "createStubOracle", + "name": "stubOracleCreate", "accounts": [ { "name": "group", @@ -776,7 +776,7 @@ export type MangoV4 = { ] }, { - "name": "closeStubOracle", + "name": "stubOracleClose", "accounts": [ { "name": "group", @@ -807,7 +807,7 @@ export type MangoV4 = { "args": [] }, { - "name": "setStubOracle", + "name": "stubOracleSet", "accounts": [ { "name": "group", @@ -2810,6 +2810,14 @@ export type MangoV4 = { 4 ] } + }, + { + "name": "netDeposits", + "type": "f32" + }, + { + "name": "netSettled", + "type": "f32" } ] } @@ -4531,7 +4539,7 @@ export const IDL: MangoV4 = { "name": "mango_v4", "instructions": [ { - "name": "createGroup", + "name": "groupCreate", "accounts": [ { "name": "group", @@ -4619,7 +4627,7 @@ export const IDL: MangoV4 = { ] }, { - "name": "closeGroup", + "name": "groupClose", "accounts": [ { "name": "group", @@ -5096,7 +5104,7 @@ export const IDL: MangoV4 = { ] }, { - "name": "updateIndex", + "name": "tokenUpdateIndex", "accounts": [ { "name": "mintInfo", @@ -5112,7 +5120,7 @@ export const IDL: MangoV4 = { "args": [] }, { - "name": "createAccount", + "name": "accountCreate", "accounts": [ { "name": "group", @@ -5176,7 +5184,7 @@ export const IDL: MangoV4 = { ] }, { - "name": "editAccount", + "name": "accountEdit", "accounts": [ { "name": "group", @@ -5210,7 +5218,7 @@ export const IDL: MangoV4 = { ] }, { - "name": "closeAccount", + "name": "accountClose", "accounts": [ { "name": "group", @@ -5241,7 +5249,7 @@ export const IDL: MangoV4 = { "args": [] }, { - "name": "createStubOracle", + "name": "stubOracleCreate", "accounts": [ { "name": "group", @@ -5304,7 +5312,7 @@ export const IDL: MangoV4 = { ] }, { - "name": "closeStubOracle", + "name": "stubOracleClose", "accounts": [ { "name": "group", @@ -5335,7 +5343,7 @@ export const IDL: MangoV4 = { "args": [] }, { - "name": "setStubOracle", + "name": "stubOracleSet", "accounts": [ { "name": "group", @@ -7338,6 +7346,14 @@ export const IDL: MangoV4 = { 4 ] } + }, + { + "name": "netDeposits", + "type": "f32" + }, + { + "name": "netSettled", + "type": "f32" } ] } diff --git a/ts/client/src/scripts/example1-admin-close.ts b/ts/client/src/scripts/example1-admin-close.ts index ea37ba60a..69dad0064 100644 --- a/ts/client/src/scripts/example1-admin-close.ts +++ b/ts/client/src/scripts/example1-admin-close.ts @@ -44,7 +44,7 @@ async function main() { const usdcDevnetOracle = ( await client.getStubOracle(group, usdcDevnetMint) )[0]; - sig = await client.closeStubOracle(group, usdcDevnetOracle.publicKey); + sig = await client.stubOracleClose(group, usdcDevnetOracle.publicKey); console.log( `Closed USDC stub oracle, sig https://explorer.solana.com/tx/${sig}?cluster=devnet`, ); @@ -75,7 +75,7 @@ async function main() { // 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}?cluster=devnet`, ); diff --git a/ts/client/src/scripts/example1-admin.ts b/ts/client/src/scripts/example1-admin.ts index bbf293213..ef3d4c364 100644 --- a/ts/client/src/scripts/example1-admin.ts +++ b/ts/client/src/scripts/example1-admin.ts @@ -55,7 +55,7 @@ async function main() { console.log(`Creating Group...`); const insuranceMint = new PublicKey(DEVNET_MINTS.get('USDC')!); try { - await client.createGroup(0, true, insuranceMint); + await client.groupCreate(0, true, insuranceMint); } catch (error) { console.log(error); } @@ -96,7 +96,7 @@ async function main() { console.log(`Registering USDC...`); const usdcDevnetMint = new PublicKey(DEVNET_MINTS.get('USDC')!); try { - await client.createStubOracle(group, usdcDevnetMint, 1.0); + await client.stubOracleCreate(group, usdcDevnetMint, 1.0); } catch (error) { console.log(error); } diff --git a/ts/client/src/scripts/mb-example1-admin-close.ts b/ts/client/src/scripts/mb-example1-admin-close.ts index 1f2e54c19..4cf94b715 100644 --- a/ts/client/src/scripts/mb-example1-admin-close.ts +++ b/ts/client/src/scripts/mb-example1-admin-close.ts @@ -44,7 +44,7 @@ async function main() { const usdcMainnetBetaOracle = ( await client.getStubOracle(group, usdcMainnetBetaMint) )[0]; - sig = await client.closeStubOracle(group, usdcMainnetBetaOracle.publicKey); + sig = await client.stubOracleClose(group, usdcMainnetBetaOracle.publicKey); console.log( `Closed USDC stub oracle, sig https://explorer.solana.com/tx/${sig}`, ); @@ -74,7 +74,7 @@ async function main() { } // 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}`); process.exit(); diff --git a/ts/client/src/scripts/mb-example1-admin.ts b/ts/client/src/scripts/mb-example1-admin.ts index 7ef1574a9..73ba98660 100644 --- a/ts/client/src/scripts/mb-example1-admin.ts +++ b/ts/client/src/scripts/mb-example1-admin.ts @@ -41,7 +41,7 @@ async function main() { // group console.log(`Creating Group...`); try { - await client.createGroup(0, true); + await client.groupCreate(0, true); } catch (error) { console.log(error); } @@ -82,7 +82,7 @@ async function main() { console.log(`Creating USDC stub oracle...`); const usdcMainnetMint = new PublicKey(MAINNET_MINTS.get('USDC')!); try { - await client.createStubOracle(group, usdcMainnetMint, 1.0); + await client.stubOracleCreate(group, usdcMainnetMint, 1.0); } catch (error) { console.log(error); } diff --git a/ts/client/src/scripts/scratch/example1-create-liquidation-candidate.ts b/ts/client/src/scripts/scratch/example1-create-liquidation-candidate.ts index 10021ef36..e1e589e42 100644 --- a/ts/client/src/scripts/scratch/example1-create-liquidation-candidate.ts +++ b/ts/client/src/scripts/scratch/example1-create-liquidation-candidate.ts @@ -110,7 +110,7 @@ async function main() { '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(); }