add prioritization for token rate update ix in keeper (#153)

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
microwavedcola1 2022-08-08 16:31:59 +02:00 committed by GitHub
parent 24c359ef92
commit ca790c9ef3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -8,6 +8,7 @@ use client::prettify_client_error;
use futures::Future;
use mango_v4::state::{EventQueue, EventType, FillEvent, OutEvent, PerpMarket, TokenIndex};
use solana_sdk::{
compute_budget::ComputeBudgetInstruction,
instruction::{AccountMeta, Instruction},
pubkey::Pubkey,
};
@ -79,6 +80,7 @@ pub async fn loop_update_index_and_rate(
let program = client.program();
let mut req = program.request();
req = req.instruction(ComputeBudgetInstruction::set_compute_unit_price(1));
for token_index in token_indices_clone.iter() {
let token = client.context.token(*token_index);
let banks_for_a_token = token.mint_info.banks();

View File

@ -12,6 +12,11 @@ use anchor_lang::Discriminator;
use checked_math as cm;
use fixed::types::I80F48;
pub mod compute_budget {
use solana_program::declare_id;
declare_id!("ComputeBudget111111111111111111111111111111");
}
#[derive(Accounts)]
pub struct TokenUpdateIndexAndRate<'info> {
pub group: AccountLoader<'info, Group>, // Required for group metadata parsing
@ -46,9 +51,10 @@ pub fn token_update_index_and_rate(ctx: Context<TokenUpdateIndexAndRate>) -> Res
// for now we just whitelist to other token_update_index_and_rate ix
// 2. we want to forbid cpi, since ix we would like to blacklist could just be called from cpi
require!(
ix.program_id == crate::id()
(ix.program_id == crate::id()
&& ix.data[0..8]
== crate::instruction::TokenUpdateIndexAndRate::discriminator(),
== crate::instruction::TokenUpdateIndexAndRate::discriminator())
|| (ix.program_id == compute_budget::id()),
MangoError::SomeError
);