remove perp zero out, was only added to cleanup testing perp market, can be re-added if needed (#430)

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
microwavedcola1 2023-02-06 11:59:12 +01:00 committed by GitHub
parent 257aeb298c
commit 4e3a7f22b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 1 additions and 124 deletions

View File

@ -29,7 +29,6 @@ pub use perp_place_order::*;
pub use perp_settle_fees::*;
pub use perp_settle_pnl::*;
pub use perp_update_funding::*;
pub use perp_zero_out::*;
pub use serum3_cancel_all_orders::*;
pub use serum3_cancel_order::*;
pub use serum3_close_open_orders::*;
@ -85,7 +84,6 @@ mod perp_place_order;
mod perp_settle_fees;
mod perp_settle_pnl;
mod perp_update_funding;
mod perp_zero_out;
mod serum3_cancel_all_orders;
mod serum3_cancel_order;
mod serum3_close_open_orders;

View File

@ -1,47 +0,0 @@
use anchor_lang::prelude::*;
use crate::error::*;
use crate::state::*;
#[derive(Accounts)]
pub struct PerpZeroOutForMarket<'info> {
#[account(
has_one = admin,
constraint = group.load()?.is_testing()
)]
pub group: AccountLoader<'info, Group>,
#[account(
mut,
has_one = group,
constraint = account.load()?.is_operational() @ MangoError::AccountIsFrozen
)]
pub account: AccountLoader<'info, MangoAccountFixed>,
#[account(
has_one = group,
constraint = perp_market.load()?.perp_market_index == 1
)]
pub perp_market: AccountLoader<'info, PerpMarket>,
pub admin: Signer<'info>,
}
pub fn perp_zero_out_for_market(ctx: Context<PerpZeroOutForMarket>) -> Result<()> {
let mut account = ctx.accounts.account.load_full_mut()?;
let perp_market = ctx.accounts.perp_market.load()?;
let perp_position = account.perp_position_mut(perp_market.perp_market_index)?;
*perp_position = PerpPosition::default();
for i in 0..account.header.perp_oo_count() {
let oo = account.perp_order_mut_by_raw_index(i);
if !oo.is_active_for_market(perp_market.perp_market_index) {
continue;
}
*oo = PerpOpenOrder::default();
}
Ok(())
}

View File

@ -563,10 +563,6 @@ pub mod mango_v4 {
instructions::perp_deactivate_position(ctx)
}
pub fn perp_zero_out_for_market(ctx: Context<PerpZeroOutForMarket>) -> Result<()> {
instructions::perp_zero_out_for_market(ctx)
}
#[allow(clippy::too_many_arguments)]
pub fn perp_place_order(
ctx: Context<PerpPlaceOrder>,

View File

@ -9,6 +9,7 @@ import {
AccountMeta,
AddressLookupTableAccount,
Cluster,
Commitment,
Keypair,
MemcmpFilter,
PublicKey,
@ -18,7 +19,6 @@ import {
SystemProgram,
TransactionInstruction,
TransactionSignature,
Commitment,
} from '@solana/web3.js';
import bs58 from 'bs58';
import { Bank, MintInfo, TokenIndex } from './accounts/bank';
@ -1970,24 +1970,6 @@ export class MangoClient {
return await this.sendAndConfirmTransactionForGroup(group, [ix]);
}
public async perpZeroOutForMarket(
group: Group,
mangoAccount: MangoAccount,
perpMarketIndex: PerpMarketIndex,
): Promise<TransactionSignature> {
const perpMarket = group.getPerpMarketByMarketIndex(perpMarketIndex);
const ix = await this.program.methods
.perpZeroOutForMarket()
.accounts({
group: group.publicKey,
account: mangoAccount.publicKey,
perpMarket: perpMarket.publicKey,
admin: group.admin,
})
.instruction();
return await this.sendAndConfirmTransactionForGroup(group, [ix]);
}
// perpPlaceOrder ix returns an optional, custom order id,
// but, since we use a customer tx sender, this method
// doesn't return it

View File

@ -2879,32 +2879,6 @@ export type MangoV4 = {
],
"args": []
},
{
"name": "perpZeroOutForMarket",
"accounts": [
{
"name": "group",
"isMut": false,
"isSigner": false
},
{
"name": "account",
"isMut": true,
"isSigner": false
},
{
"name": "perpMarket",
"isMut": false,
"isSigner": false
},
{
"name": "admin",
"isMut": false,
"isSigner": true
}
],
"args": []
},
{
"name": "perpPlaceOrder",
"accounts": [
@ -11223,32 +11197,6 @@ export const IDL: MangoV4 = {
],
"args": []
},
{
"name": "perpZeroOutForMarket",
"accounts": [
{
"name": "group",
"isMut": false,
"isSigner": false
},
{
"name": "account",
"isMut": true,
"isSigner": false
},
{
"name": "perpMarket",
"isMut": false,
"isSigner": false
},
{
"name": "admin",
"isMut": false,
"isSigner": true
}
],
"args": []
},
{
"name": "perpPlaceOrder",
"accounts": [