Skip to content

Commit

Permalink
fix(pumpman): start without parameters (#12)
Browse files Browse the repository at this point in the history
* fix(pumpman): start without parameters

* fix(fee): sub of priority fee

* fix(pumpman): priority fee could not be neg

* chore(md): update docker command in README

* fix(pumpman): empty jobid on creation
  • Loading branch information
clearloop authored Aug 28, 2024
1 parent 10c4e7b commit d90a0d0
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "replika"
version = "0.0.2"
version = "0.0.3"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
``` sh
docker build -t clearloop/takeover . --platform=linux/amd64
docker build -t clearloop/spr . --platform=linux/amd64
```

``` sh
Expand Down
7 changes: 7 additions & 0 deletions src/emoji.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//! emojis since emacs doesn't support
pub const ROCKET: &str = "🚀";
pub const STOP: &str = "⏹️";
pub const EXPLOSION: &str = "💥";
pub const RANDOM: &str = "🎲";
pub const RESET: &str = "👾";
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub mod api;
mod cli;
pub mod config;
pub mod context;
pub mod emoji;
mod model;
mod schema;
pub mod service;
Expand Down
23 changes: 13 additions & 10 deletions src/model/pumpman_job.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
config,
config, emoji,
model::{pumpman::Speed, Pumpman, PumpmanGlobal},
sol::{pump::PUMP_FEE_BASIS, utils::LAMPORTS_PER_SIGNATURE},
telegram::{
Expand Down Expand Up @@ -108,7 +108,10 @@ pub trait PumpmanJob {
JobCommand::BatchUp => *self.batch_mut() += 1,
JobCommand::BatchRandom => *self.batch_mut() = rng.gen_range(1..6),
JobCommand::BatchReset => *self.batch_mut() = 1,
JobCommand::PriorityFeeDown => *self.priority_fee_mut() -= &global.priority_fee_step,
JobCommand::PriorityFeeDown => {
*self.priority_fee_mut() =
(self.priority_fee() - &global.priority_fee_step).max(BigDecimal::zero())
}
JobCommand::PriorityFeeUp => *self.priority_fee_mut() += &global.priority_fee_step,
JobCommand::PriorityFeeRandom => {
*self.priority_fee_mut() = &global.priority_fee_step * rng.gen_range(0..10)
Expand Down Expand Up @@ -179,12 +182,12 @@ impl PumpmanJob for Pumpman {
let id = self.job_id();
Ok(if self.active() {
vec![InlineKeyboardButton::callback(
"Stop",
format!("Stop {}", emoji::STOP),
Callback::job(JobCommand::Stop, id).format()?,
)]
} else {
vec![InlineKeyboardButton::callback(
"Start",
format!("Start {}", emoji::ROCKET),
Callback::job(JobCommand::Start, id).format()?,
)]
})
Expand All @@ -194,11 +197,11 @@ impl PumpmanJob for Pumpman {
let id = self.job_id();
let batch = self.batch();
let btn = InlineKeyboardButton::callback(
format!("Batch {}", batch),
format!("{} Batch {}", emoji::RANDOM, batch),
Callback::job(JobCommand::BatchRandom, id).format()?,
);
let reset = InlineKeyboardButton::callback(
"Reset",
format!("Reset {}", emoji::RESET),
Callback::job(JobCommand::BatchReset, id).format()?,
);

Expand All @@ -208,11 +211,11 @@ impl PumpmanJob for Pumpman {
fn tx_fee_button(&self) -> Result<Vec<InlineKeyboardButton>> {
let id = self.job_id();
let btn = InlineKeyboardButton::callback(
format!("Tx Fee {}", self.tx_fee().round(6)),
format!("{} Tx Fee {}", emoji::RANDOM, self.tx_fee().round(6)),
Callback::job(JobCommand::PriorityFeeRandom, id).format()?,
);
let reset = InlineKeyboardButton::callback(
"Reset",
format!("Reset {}", emoji::RESET),
Callback::job(JobCommand::PriorityFeeReset, id).format()?,
);

Expand All @@ -223,11 +226,11 @@ impl PumpmanJob for Pumpman {
let id = self.job_id();
let amount = self.amount().round(3);
let btn = InlineKeyboardButton::callback(
format!("Amount {}", amount),
format!("{} Amount {}", emoji::RANDOM, amount),
Callback::job(JobCommand::AmountRandom, id).format()?,
);
let reset = InlineKeyboardButton::callback(
"Reset",
format!("Reset {}", emoji::RESET),
Callback::job(JobCommand::AmountReset, id).format()?,
);

Expand Down
2 changes: 2 additions & 0 deletions src/telegram/pumpman/callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ impl JobCommand {
msg: &Message,
job_id: i64,
) -> Result<()> {
tracing::trace!("handling job: {job_id}");
let mut job = context.job_by_id(job_id).await?;
job.apply_command(self, &context.global);

Expand All @@ -189,6 +190,7 @@ impl JobCommand {
context: PumpmanContext,
msg: Message,
) -> Result<()> {
tracing::trace!("handle global {}", msg.chat.id.0);
let mut global = context.pglobal(msg.chat.id.0).await?;
global.apply_command(self, &context.global);

Expand Down
6 changes: 5 additions & 1 deletion src/telegram/pumpman/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,17 @@ impl Command {
..
}) = msg.kind
else {
return Ok(());
};

if text == "/start" {
// handle common start
bot.send_message(msg.chat.id, message::menu(&context, msg.chat.id.0).await?)
.parse_mode(ParseMode::Html)
.await?;

return Ok(());
};
}

let mint = text.trim_start_matches("/start").trim();
let job = context.job(msg.chat.id.0, mint).await?;
Expand Down
4 changes: 2 additions & 2 deletions src/telegram/pumpman/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ impl PumpmanContext {
Ok(job)
} else {
let job = self.pglobal(tgid).await?.generate(mint);
diesel::insert_into(pumpmen::table)
let job = diesel::insert_into(pumpmen::table)
.values(&job)
.execute(postgres)
.get_result(postgres)
.await?;

Ok(job)
Expand Down
2 changes: 0 additions & 2 deletions src/telegram/pumpman/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ pub async fn menu(context: &PumpmanContext, user: i64) -> Result<String> {
r#"
The easiest way to keep your token staying on the first page of PumpFun!
<b>🎁 30% off on service fee till we reach 300 users!</b>
/fees of bumping a token for 10 mins with /config: <code>{} SOL</code>
Please paste a pumpfun link in the chat, for example: <code>https://pump.fun/2GncVSSwhxsJu4B5wGt14jRoG2iGCCFzQk6D9Lmspump</code>
Expand Down

0 comments on commit d90a0d0

Please sign in to comment.