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.
- 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

View File

@ -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(),
},

View File

@ -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<CloseAccount>) -> Result<()> {
pub fn account_close(ctx: Context<AccountClose>) -> Result<()> {
let group = ctx.accounts.group.load()?;
// don't perform checks if group is just testing

View File

@ -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<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()?;
account.name = fill32_from_str(name)?;

View File

@ -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<EditAccount>,
pub fn account_edit(
ctx: Context<AccountEdit>,
name_opt: Option<String>,
// note: can also be used to unset by using the default pubkey here as a param
delegate_opt: Option<Pubkey>,

View File

@ -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<CloseGroup>) -> Result<()> {
pub fn group_close(_ctx: Context<GroupClose>) -> Result<()> {
// TODO: checks
Ok(())
}

View File

@ -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<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()?;
group.admin = ctx.accounts.admin.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 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;

View File

@ -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<CloseStubOracle>) -> Result<()> {
pub fn stub_oracle_close(_ctx: Context<StubOracleClose>) -> Result<()> {
Ok(())
}

View File

@ -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<CreateStubOracle>, price: I80F48) -> Result<()> {
pub fn stub_oracle_create(ctx: Context<StubOracleCreate>, price: I80F48) -> Result<()> {
let mut oracle = ctx.accounts.oracle.load_init()?;
oracle.group = ctx.accounts.group.key();
oracle.mint = ctx.accounts.token_mint.key();

View File

@ -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<SetStubOracle>, price: I80F48) -> Result<()> {
pub fn stub_oracle_set(ctx: Context<StubOracleSet>, price: I80F48) -> Result<()> {
let mut oracle = ctx.accounts.oracle.load_mut()?;
oracle.price = price;
oracle.last_updated = Clock::get()?.unix_timestamp;

View File

@ -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<UpdateIndex>) -> Result<()> {
pub fn token_update_index(ctx: Context<TokenUpdateIndex>) -> Result<()> {
let mint_info = ctx.accounts.mint_info.load()?;
require_keys_eq!(mint_info.oracle.key(), ctx.accounts.oracle.key());

View File

@ -30,12 +30,12 @@ pub mod mango_v4 {
use super::*;
pub fn create_group(ctx: Context<CreateGroup>, group_num: u32, testing: u8) -> Result<()> {
instructions::create_group(ctx, group_num, testing)
pub fn group_create(ctx: Context<GroupCreate>, group_num: u32, testing: u8) -> Result<()> {
instructions::group_create(ctx, group_num, testing)
}
pub fn close_group(ctx: Context<CloseGroup>) -> Result<()> {
instructions::close_group(ctx)
pub fn group_close(ctx: Context<GroupClose>) -> 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<UpdateIndex>) -> Result<()> {
instructions::update_index(ctx)
pub fn token_update_index(ctx: Context<TokenUpdateIndex>) -> Result<()> {
instructions::token_update_index(ctx)
}
pub fn create_account(
ctx: Context<CreateAccount>,
pub fn account_create(
ctx: Context<AccountCreate>,
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<EditAccount>,
pub fn account_edit(
ctx: Context<AccountEdit>,
name_opt: Option<String>,
delegate_opt: Option<Pubkey>,
) -> 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<()> {
instructions::close_account(ctx)
pub fn account_close(ctx: Context<AccountClose>) -> 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<CreateStubOracle>, price: I80F48) -> Result<()> {
instructions::create_stub_oracle(ctx, price)
pub fn stub_oracle_create(ctx: Context<StubOracleCreate>, price: I80F48) -> Result<()> {
instructions::stub_oracle_create(ctx, price)
}
pub fn close_stub_oracle(ctx: Context<CloseStubOracle>) -> Result<()> {
instructions::close_stub_oracle(ctx)
pub fn stub_oracle_close(ctx: Context<StubOracleClose>) -> Result<()> {
instructions::stub_oracle_close(ctx)
}
pub fn set_stub_oracle(ctx: Context<SetStubOracle>, price: I80F48) -> Result<()> {
instructions::set_stub_oracle(ctx, price)
pub fn stub_oracle_set(ctx: Context<StubOracleSet>, price: I80F48) -> Result<()> {
instructions::stub_oracle_set(ctx, price)
}
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 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,

View File

@ -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,

View File

@ -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,

View File

@ -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(),

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

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

View File

@ -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,
},
)

View File

@ -64,14 +64,14 @@ export class MangoClient {
// Group
public async createGroup(
public async groupCreate(
groupNum: number,
testing: boolean,
insuranceMintPk: PublicKey,
): Promise<TransactionSignature> {
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<TransactionSignature> {
public async groupClose(group: Group): Promise<TransactionSignature> {
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<TransactionSignature> {
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<TransactionSignature> {
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<TransactionSignature> {
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<TransactionSignature> {
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<TransactionSignature> {
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<TransactionSignature> {
return await this.program.methods
.closeAccount()
.accountClose()
.accounts({
group: group.publicKey,
account: mangoAccount.publicKey,

View File

@ -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"
}
]
}

View File

@ -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`,
);

View File

@ -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);
}

View File

@ -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();

View File

@ -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);
}

View File

@ -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();
}