Skip to content

Commit

Permalink
Revert "add priority fees; move processing to module"
Browse files Browse the repository at this point in the history
This reverts commit 498548d.
  • Loading branch information
samuelvanderwaal committed Mar 23, 2024
1 parent 498548d commit 9345055
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 169 deletions.
9 changes: 2 additions & 7 deletions src/airdrop/mod.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
pub mod process;
pub mod sol;
pub mod spl;
pub use process::*;
pub use sol::*;
pub use spl::*;

pub use std::{collections::HashMap, fs::File, path::PathBuf, str::FromStr};

pub use anyhow::Result;
use indicatif::ProgressBar;
pub use jib::{Jib, JibFailedTransaction, Network};
pub use jib::{Jib, Network};
pub use log::debug;
pub use serde::{Deserialize, Serialize};
pub use solana_client::rpc_client::RpcClient;
pub use solana_sdk::{pubkey::Pubkey, signer::Signer};
use structopt::StructOpt;

pub use crate::update::{parse_keypair, parse_solana_config};

Expand All @@ -31,5 +27,4 @@ struct Recipient {
amount: u64,
}

// Test transactions take 3_150, but we pad it a bit.
pub const AIRDROP_SOL_CU: u32 = 5_000;
pub const PRIORITY_FEE: u64 = 25_000;
134 changes: 0 additions & 134 deletions src/airdrop/process.rs

This file was deleted.

18 changes: 4 additions & 14 deletions src/airdrop/sol.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use indicatif::ProgressBar;
use jib::JibFailedTransaction;
use metaboss_lib::data::Priority;

use super::*;

Expand All @@ -9,12 +8,10 @@ pub struct AirdropSolArgs {
pub keypair: Option<String>,
pub recipient_list: Option<String>,
pub cache_file: Option<String>,
pub priority: Priority,
pub boost: bool,
pub rate_limit: Option<u64>,
}



pub async fn airdrop_sol(args: AirdropSolArgs) -> Result<()> {
let solana_opts = parse_solana_config();
let keypair = parse_keypair(args.keypair, solana_opts);
Expand All @@ -34,16 +31,9 @@ pub async fn airdrop_sol(args: AirdropSolArgs) -> Result<()> {
let mut cache_file_name = format!("mb-cache-airdrop-{timestamp}.bin");
let successful_tx_file_name = format!("mb-successful-airdrops-{timestamp}.json");

let priority_fee = match args.priority {
Priority::None => 200, // 1 lamport
Priority::Low => 200_000, // 1_000 lamports
Priority::Medium => 1_000_000, // 5_000 lamports
Priority::High => 5_000_000, // 25_000 lamports
Priority::Max => 20_000_000, // 100_000 lamports
};

jib.set_priority_fee(priority_fee);
jib.set_compute_budget(AIRDROP_SOL_CU);
if args.boost {
jib.set_priority_fee(PRIORITY_FEE);
}

if let Some(rate) = args.rate_limit {
jib.set_rate_limit(rate);
Expand Down
17 changes: 5 additions & 12 deletions src/airdrop/spl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::anyhow;
use borsh::{BorshDeserialize, BorshSerialize};
use indicatif::ProgressBar;
use jib::JibFailedTransaction;
use metaboss_lib::{data::Priority, transaction::send_and_confirm_tx};
use metaboss_lib::transaction::send_and_confirm_tx;
use solana_program::{
instruction::{AccountMeta, Instruction},
program_pack::Pack,
Expand All @@ -20,7 +20,7 @@ pub struct AirdropSplArgs {
pub cache_file: Option<String>,
pub mint: Pubkey,
pub mint_tokens: bool,
pub priority: Priority,
pub boost: bool,
pub rate_limit: Option<u64>,
}

Expand Down Expand Up @@ -61,16 +61,9 @@ pub async fn airdrop_spl(args: AirdropSplArgs) -> Result<()> {
let mut cache_file_name = format!("mb-cache-airdrop-{timestamp}.bin");
let successful_tx_file_name = format!("mb-successful-airdrops-{timestamp}.json");

let priority_fee = match args.priority {
Priority::None => 200, // 1 lamport
Priority::Low => 200_000, // 1_000 lamports
Priority::Medium => 1_000_000, // 5_000 lamports
Priority::High => 5_000_000, // 25_000 lamports
Priority::Max => 20_000_000, // 100_000 lamports
};

jib.set_priority_fee(priority_fee);
jib.set_compute_budget(AIRDROP_SOL_CU);
if args.boost {
jib.set_priority_fee(PRIORITY_FEE);
}

if let Some(rate) = args.rate_limit {
jib.set_rate_limit(rate);
Expand Down
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
extern crate log;

use anyhow::Result;
use metaboss::airdrop::process_airdrop;
use metaboss::check::process_check;
use metaboss::constants::PUBLIC_RPC_URLS;
use metaboss::extend_program::process_extend_program;
Expand Down
67 changes: 66 additions & 1 deletion src/opt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use solana_program::pubkey::Pubkey;
use structopt::StructOpt;

use crate::{
airdrop::AirdropSubcommands,
check::CheckSubcommands,
collections::GetCollectionItemsMethods,
constants::DEFAULT_RATE_LIMIT,
Expand Down Expand Up @@ -163,6 +162,72 @@ pub enum Command {
},
}

#[derive(Debug, StructOpt)]
pub enum AirdropSubcommands {
/// Airdrop SOL (experimental)
#[structopt(name = "sol")]
Sol {
/// Path to the owner keypair file
#[structopt(short, long)]
keypair: Option<String>,

/// Path to the mint list file
#[structopt(short = "L", long)]
recipient_list: Option<String>,

/// Cache file
#[structopt(short, long)]
cache_file: Option<String>,

/// Rate limit in requests per second; defaults to 10
#[structopt(short = "R", long)]
rate_limit: Option<u64>,

/// Boost the transactions w/ priority fees
#[structopt(long)]
boost: bool,
},
/// Airdrop SPL tokens (experimental)
#[structopt(name = "spl")]
Spl {
/// Path to the owner keypair file
#[structopt(short, long)]
keypair: Option<String>,

/// Path to the mint list file
#[structopt(short = "L", long)]
recipient_list: Option<String>,

/// Cache file
#[structopt(short, long)]
cache_file: Option<String>,

/// Mint from the SPL token mint
#[structopt(short, long)]
mint: Pubkey,

#[structopt(long)]
mint_tokens: bool,

/// Rate limit in requests per second; defaults to 10
#[structopt(short = "R", long)]
rate_limit: Option<u64>,

/// Boost the transactions w/ priority fees
#[structopt(long)]
boost: bool,
},
/// Convert the bin cache file to json for readability
ReadCache {
/// Path to the cache file
cache_file: String,

/// Print errors to std out in addition to converting the cache file to json
#[structopt(long)]
errors: bool,
},
}

#[derive(Debug, StructOpt)]
pub enum BurnSubcommands {
/// Burn an asset.
Expand Down
Loading

0 comments on commit 9345055

Please sign in to comment.