diff --git a/src/arbitrageur.rs b/src/arbitrageur.rs index e5ed849..4dd7a48 100644 --- a/src/arbitrageur.rs +++ b/src/arbitrageur.rs @@ -167,7 +167,26 @@ impl Behavior 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) } diff --git a/src/deployer.rs b/src/deployer.rs index d0d9343..b231fd7 100644 --- a/src/deployer.rs +++ b/src/deployer.rs @@ -20,6 +20,8 @@ pub enum DeploymentRequest { name: String, symbol: String, decimals: u8, + initial_mint: usize, + receiver: Address, }, LiquidExchange { @@ -93,13 +95,22 @@ impl Behavior 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 diff --git a/src/lib.rs b/src/lib.rs index 039e748..2fbbd80 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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; @@ -23,6 +26,7 @@ use crate::{ }, }, deployer::{DeploymentRequest, DeploymentResponse, PoolParams}, + liquidity_admin::{AllocationRequest, LiquidityAdmin}, price_changer::{PriceChanger, PriceUpdate, Signal}, types::process::{OrnsteinUhlenbeck, StochasticProcess}, }; @@ -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?; @@ -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?; @@ -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, diff --git a/src/liquidity_admin.rs b/src/liquidity_admin.rs index cc32d69..274537c 100644 --- a/src/liquidity_admin.rs +++ b/src/liquidity_admin.rs @@ -1,6 +1,6 @@ use super::*; -#[derive(Debug, Deserialize, Serialize, Clone)] +#[derive(Debug, Deserialize, Default, Serialize, Clone)] pub struct LiquidityAdmin { pub base: Base,