From ad9d3c58a7a56c932294496f4db0fd9c5af8547e Mon Sep 17 00:00:00 2001 From: Waylon Jepsen Date: Mon, 30 Oct 2023 18:01:38 -0600 Subject: [PATCH] deployed factory --- simulation/src/lib.rs | 2 +- .../src/{simulation.rs => simulations/mod.rs} | 21 +++++++++++++++++++ src/main.rs | 19 +++++++---------- 3 files changed, 30 insertions(+), 12 deletions(-) rename simulation/src/{simulation.rs => simulations/mod.rs} (83%) diff --git a/simulation/src/lib.rs b/simulation/src/lib.rs index b359c2c..a026ce9 100644 --- a/simulation/src/lib.rs +++ b/simulation/src/lib.rs @@ -1,6 +1,6 @@ #[allow(non_snake_case)] pub mod bindings; -pub mod simulation; +pub mod simulations; pub mod v2_core_bindings; use anyhow::{Ok, Result}; use arbiter_core::{ diff --git a/simulation/src/simulation.rs b/simulation/src/simulations/mod.rs similarity index 83% rename from simulation/src/simulation.rs rename to simulation/src/simulations/mod.rs index d6b723f..1d380ff 100644 --- a/simulation/src/simulation.rs +++ b/simulation/src/simulations/mod.rs @@ -1,4 +1,6 @@ use super::*; + +use v2_core_bindings::uniswap_v2_factory::UniswapV2Factory; const FORK_PATH: &str = "../../fork_example/test.json"; // This is an example of deploying a contract and then mutating its state @@ -79,3 +81,22 @@ pub async fn load_contract_from_fork() -> Result<()> { println!("balance is {}", balance); Ok(()) } + + +pub async fn uniswap_example() -> Result<()> { + let environment = EnvironmentBuilder::new().build(); + + let client_with_signer = RevmMiddleware::new(&environment, None)?; + + println!( + "created client with address {:?}", + client_with_signer.address() + ); + + let uniswap_factory = UniswapV2Factory::deploy(client_with_signer.clone(), client_with_signer.address())? + .send() + .await?; + println!("UniswapFactory contract deployed at {:?}", uniswap_factory.address()); + + Ok(()) +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 5eff1f1..96bb285 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,28 +10,25 @@ struct Args { /// Defines the subcommand to execute. #[command(subcommand)] command: Option, - - #[clap(short, long, global = true, required = false, action = ArgAction::Count, value_parser( - clap::value_parser!(u8)))] - verbose: Option, } /// Defines available subcommands for the `Arbiter` tool. #[derive(Subcommand)] enum Commands { - /// Represents the `Bind` subcommand. - Counter {}, - ForkContract {}, - ForkEOA {}, + Counter, + ForkContract, + ForkEOA, + Uniswap, } #[tokio::main] async fn main() -> Result<()> { let args = Args::parse(); match &args.command { - Some(Commands::Counter {}) => simulation::simulation::counter_example().await?, - Some(Commands::ForkContract {}) => simulation::simulation::load_contract_from_fork().await?, - Some(Commands::ForkEOA {}) => simulation::simulation::load_eoa_from_disk().await?, + Some(Commands::Counter {}) => simulation::simulations::counter_example().await?, + Some(Commands::ForkContract {}) => simulation::simulations::load_contract_from_fork().await?, + Some(Commands::ForkEOA {}) => simulation::simulations::load_eoa_from_disk().await?, + Some(Commands::Uniswap) => simulation::simulations::uniswap_example().await?, None => Args::command().print_long_help()?, } Ok(())