Skip to content

Commit

Permalink
deployed factory
Browse files Browse the repository at this point in the history
  • Loading branch information
0xJepsen committed Oct 31, 2023
1 parent c944766 commit ad9d3c5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
2 changes: 1 addition & 1 deletion simulation/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down
21 changes: 21 additions & 0 deletions simulation/src/simulation.rs → simulation/src/simulations/mod.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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(())
}
19 changes: 8 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,25 @@ struct Args {
/// Defines the subcommand to execute.
#[command(subcommand)]
command: Option<Commands>,

#[clap(short, long, global = true, required = false, action = ArgAction::Count, value_parser(
clap::value_parser!(u8)))]
verbose: Option<u8>,
}

/// 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(())
Expand Down

0 comments on commit ad9d3c5

Please sign in to comment.