Skip to content

Commit

Permalink
nit: fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ts0yu committed Feb 21, 2024
1 parent 0861536 commit e5dd078
Show file tree
Hide file tree
Showing 4 changed files with 202 additions and 262 deletions.
34 changes: 24 additions & 10 deletions src/behaviors/deployer.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
use std::sync::Arc;
use anyhow::anyhow;
use anyhow::Result;

use anyhow::{anyhow, Result};
use arbiter_core::middleware::ArbiterMiddleware;
use arbiter_engine::{
machine::{Behavior, EventStream},
messager::{Messager, To},
};

use ethers::types::H160;

use super::*;
use crate::bindings::{token::ArbiterToken, uniswap_v3_factory::UniswapV3Factory, liquid_exchange::LiquidExchange};
use crate::bindings::{
liquid_exchange::LiquidExchange, token::ArbiterToken, uniswap_v3_factory::UniswapV3Factory,
};

#[derive(Debug, Deserialize, Serialize)]
pub struct DeploymentData {
Expand All @@ -22,7 +23,13 @@ pub struct DeploymentData {
}

impl DeploymentData {
pub fn new(token_0: H160, token_1: H160, factory: H160, liquid_exchange: H160, pool: H160) -> Self {
pub fn new(
token_0: H160,
token_1: H160,
factory: H160,
liquid_exchange: H160,
pool: H160,
) -> Self {
Self {
token_0,
token_1,
Expand All @@ -48,8 +55,10 @@ impl Behavior<()> for Deployer {

let factory = self.deploy_factory(&client).await?;
let liquid_exchange = self.deploy_liquid_exchange(&client).await?;

let pool = self.create_pool(&factory, token_0.address(), token_1.address()).await?;

let pool = self
.create_pool(&factory, token_0.address(), token_1.address())
.await?;

let deployment_data = DeploymentData {
token_0: token_0.address(),
Expand All @@ -59,7 +68,9 @@ impl Behavior<()> for Deployer {
pool,
};

messager.send(To::All, serde_json::to_string(&deployment_data)?).await;
messager
.send(To::All, serde_json::to_string(&deployment_data)?)
.await;

Ok(None)
}
Expand Down Expand Up @@ -104,12 +115,15 @@ impl Deployer {
.map_err(|e| anyhow!("Failed to send liquid exchange: {}", e))
}

async fn create_pool<M>(
async fn create_pool<M>(
&self,
factory: &UniswapV3Factory<M>,
token_0: H160,
token_1: H160,
) -> Result<H160> where M: ethers::providers::Middleware {
) -> Result<H160>
where
M: ethers::providers::Middleware,
{
factory
.create_pool(token_0, token_1, 100)
.call()
Expand Down
2 changes: 1 addition & 1 deletion src/behaviors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ use serde::{Deserialize, Serialize};

pub mod deployer;

pub use deployer::Deployer;
pub use deployer::Deployer;
Loading

0 comments on commit e5dd078

Please sign in to comment.