use noop instead of memo

This commit is contained in:
Maximilian Schneider 2023-04-14 12:04:35 +00:00
parent 26ffd8ed1c
commit 14540a7603
5 changed files with 27 additions and 13 deletions

View File

@ -2,6 +2,7 @@ use crate::{
helpers::to_sp_pk,
mango::GroupConfig,
mango_v3_perp_crank_sink::MangoV3PerpCrankSink,
noop,
states::{KeeperInstruction, TransactionSendRecord},
tpu_manager::TpuManager,
};
@ -18,7 +19,6 @@ use solana_sdk::{
hash::Hash, instruction::Instruction, pubkey::Pubkey, signature::Keypair, signer::Signer,
transaction::Transaction,
};
use solana_transaction_status::extract_memos::{ExtractMemos, spl_memo_id_v3};
use std::{
str::FromStr,
sync::{
@ -81,9 +81,16 @@ pub fn start(
}
if let Ok((market, mut ixs)) = instruction_receiver.recv().await {
// TODO add priority fee
ixs.push(Instruction { program_id: spl_memo_id_v3(), accounts: vec![], data: Utc::now().timestamp_micros().to_le_bytes().into() });
// add priority fees
ixs.push(
solana_sdk::compute_budget::ComputeBudgetInstruction::set_compute_unit_price(
prioritization_fee,
),
);
// add timestamp to guarantee unique transactions
ixs.push(noop::instruction(
Utc::now().timestamp_micros().to_le_bytes().into(),
));
let tx = Transaction::new_signed_with_payer(
&ixs,

View File

@ -1,8 +1,7 @@
use solana_transaction_status::extract_memos::spl_memo_id_v3;
use {
crate::{
helpers::to_sdk_instruction,
noop,
states::{KeeperInstruction, PerpMarketCache, TransactionSendRecord},
tpu_manager::TpuManager,
},
@ -111,12 +110,8 @@ pub async fn send_transaction(
prioritization_fee: u64,
keeper_instruction: KeeperInstruction,
) {
// add a memo with a current timestamp to ensure unique txs
ixs.push(Instruction {
program_id: spl_memo_id_v3(),
accounts: vec![],
data: Utc::now().timestamp_micros().to_le_bytes().into(),
});
// add a noop with a current timestamp to ensure unique txs
ixs.push(noop::instruction(Utc::now().timestamp_micros().to_le_bytes().into()));
// add priority fees
ixs.push(
solana_sdk::compute_budget::ComputeBudgetInstruction::set_compute_unit_price(

View File

@ -6,6 +6,7 @@ pub mod keeper;
pub mod mango;
pub mod mango_v3_perp_crank_sink;
pub mod market_markers;
pub mod noop;
pub mod result_writer;
pub mod rotating_queue;
pub mod states;

View File

@ -1,4 +1,4 @@
use std::{cell::RefCell, collections::{BTreeMap, HashSet}, convert::TryFrom, mem::size_of, sync::Arc};
use std::{cell::RefCell, collections::{BTreeMap, HashSet}, convert::TryFrom, mem::size_of};
use arrayref::array_ref;
use async_channel::Sender;

11
src/noop.rs Normal file
View File

@ -0,0 +1,11 @@
use std::str::FromStr;
use solana_sdk::{pubkey::Pubkey, instruction::Instruction};
pub fn instruction(data: Vec<u8>) -> Instruction {
Instruction {
program_id: Pubkey::from_str("noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV").unwrap(),
accounts: vec![],
data,
}
}