Skip to content

Commit

Permalink
feat: add initial token mint parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
ts0yu authored Jul 31, 2024
1 parent 9ccfbdd commit 1f5296c
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 4 deletions.
19 changes: 19 additions & 0 deletions src/arbitrageur.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,26 @@ impl Behavior<Message> for Arbitrageur {
let p_uni = f64::from(scaled_price) / 10f64.powi(18);
let p_ext = f64::from(lex_price) / 10f64.powi(18);

match p_uni.partial_cmp(&p_ext) {
Some(Ordering::Greater) => {
let swap_amount = self
.optimal_swap(p_ext, p_uni, 0.003, get_slot0_return.tick as f64)
.await;

println!("greater: Optimal swap amount: {}", swap_amount);
}
Some(Ordering::Less) => {
let swap_amount = self
.optimal_swap(p_uni, p_ext, 0.003, get_slot0_return.tick as f64)
.await;
println!("lesser: Optimal swap amount: {}", swap_amount);
}
Some(Ordering::Equal) => return Ok(ControlFlow::Continue),
None => panic!(),
}

println!("tick: {}", get_slot0_return.tick);
println!("price: {}", p_ext);

Ok(ControlFlow::Continue)
}
Expand Down
13 changes: 12 additions & 1 deletion src/deployer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ pub enum DeploymentRequest {
name: String,
symbol: String,
decimals: u8,
initial_mint: usize,
receiver: Address,
},

LiquidExchange {
Expand Down Expand Up @@ -93,13 +95,22 @@ impl Behavior<Message> for Deployer {
name,
symbol,
decimals,
initial_mint,
receiver,
} => {
let token =
ArenaToken::deploy(self.base.client.clone().unwrap(), name, symbol, decimals)
.await
.unwrap();

println!("Token deployed at address: {:?}", token.address());
token
.mint(receiver, Uint::from(initial_mint))
.send()
.await
.unwrap()
.watch()
.await
.unwrap();

self.base
.messager
Expand Down
13 changes: 11 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use std::{fmt::Debug, str::FromStr, sync::Arc};
use std::{cmp::Ordering, fmt::Debug, str::FromStr, sync::Arc};

use alloy::primitives::{Address, Bytes, Uint, U256};
use alloy::{
primitives::{Address, Bytes, Uint, U256},
providers::WalletProvider,
};
use alloy_sol_types::sol_data::FixedBytes;
use anyhow::Result;
use futures::stream::StreamExt;
Expand All @@ -23,6 +26,7 @@ use crate::{
},
},
deployer::{DeploymentRequest, DeploymentResponse, PoolParams},
liquidity_admin::{AllocationRequest, LiquidityAdmin},
price_changer::{PriceChanger, PriceUpdate, Signal},
types::process::{OrnsteinUhlenbeck, StochasticProcess},
};
Expand Down Expand Up @@ -76,6 +80,8 @@ mod tests {
name: String::from("TEST0"),
symbol: String::from("TST0"),
decimals: 18,
initial_mint: 1000000,
receiver: self.client.clone().unwrap().default_signer_address(),
},
)
.await?;
Expand All @@ -87,6 +93,8 @@ mod tests {
name: String::from("TEST1"),
symbol: String::from("TST1"),
decimals: 18,
initial_mint: 1000000,
receiver: self.client.clone().unwrap().default_signer_address(),
},
)
.await?;
Expand Down Expand Up @@ -201,6 +209,7 @@ mod tests {
});

let deployer = Agent::builder("deployer").with_behavior(Deployer::default());
let liquidity_admin = Agent::builder("liqadmin").with_behavior(LiquidityAdmin::default());

let mock_deployer = Agent::builder("mock_deployer").with_behavior(MockOrchestrator {
client: None,
Expand Down
2 changes: 1 addition & 1 deletion src/liquidity_admin.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;

#[derive(Debug, Deserialize, Serialize, Clone)]
#[derive(Debug, Deserialize, Default, Serialize, Clone)]
pub struct LiquidityAdmin {
pub base: Base,

Expand Down

0 comments on commit 1f5296c

Please sign in to comment.