Skip to content

Commit

Permalink
feat - use bindings instead of sol! macro
Browse files Browse the repository at this point in the history
  • Loading branch information
Dvisacker committed Nov 28, 2024
1 parent 661a849 commit 271b0ab
Show file tree
Hide file tree
Showing 24 changed files with 98 additions and 1,252 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

38 changes: 13 additions & 25 deletions src/amm/camelot_v3/batch_request/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,12 @@ use tracing::instrument;

use crate::{
amm::{AutomatedMarketMaker, AMM},
bindings,
errors::AMMError,
};

use super::CamelotV3Pool;

sol! {
#[allow(missing_docs)]
#[sol(rpc)]
IGetCamelotV3PoolDataBatchRequest,
"src/amm/camelot_v3/batch_request/GetCamelotV3PoolDataBatchRequestABI.json"
}

sol! {
#[allow(missing_docs)]
#[sol(rpc)]
IGetCamelotV3TickDataBatchRequest,
"src/amm/camelot_v3/batch_request/GetCamelotV3TickDataBatchRequestABI.json"
}

sol! {
#[allow(missing_docs)]
#[sol(rpc)]
ISyncCamelotV3PoolBatchRequest,
"src/amm/camelot_v3/batch_request/SyncCamelotV3PoolBatchRequestABI.json"
}

#[inline]
fn populate_pool_data_from_tokens(
mut pool: CamelotV3Pool,
Expand Down Expand Up @@ -66,7 +46,7 @@ where
N: Network,
P: Provider<T, N>,
{
let deployer = IGetCamelotV3PoolDataBatchRequest::deploy_builder(provider, vec![pool.address]);
let deployer = bindings::getcamelotv3pooldatabatchrequest::GetCamelotV3PoolDataBatchRequest::deploy_builder(provider, vec![pool.address]);
let res = if let Some(block_number) = block_number {
deployer.block(block_number.into()).call_raw().await?
} else {
Expand Down Expand Up @@ -120,7 +100,7 @@ where
N: Network,
P: Provider<T, N>,
{
let deployer = IGetCamelotV3TickDataBatchRequest::deploy_builder(
let deployer = bindings::getcamelotv3tickdatabatchrequest::GetCamelotV3TickDataBatchRequest::deploy_builder(
provider,
pool.address,
zero_for_one,
Expand Down Expand Up @@ -198,7 +178,11 @@ where
N: Network,
P: Provider<T, N>,
{
let deployer = ISyncCamelotV3PoolBatchRequest::deploy_builder(provider, vec![pool.address]);
let deployer =
bindings::synccamelotv3poolbatchrequest::SyncCamelotV3PoolBatchRequest::deploy_builder(
provider,
vec![pool.address],
);
let res = deployer.call_raw().await?;

let constructor_return = DynSolType::Array(Box::new(DynSolType::Tuple(vec![
Expand Down Expand Up @@ -264,7 +248,11 @@ where
target_addresses.push(amm.address());
}

let deployer = IGetCamelotV3PoolDataBatchRequest::deploy_builder(provider, target_addresses);
let deployer =
bindings::getcamelotv3pooldatabatchrequest::GetCamelotV3PoolDataBatchRequest::deploy_builder(
provider,
target_addresses,
);
let res = deployer.block(block_number.into()).call_raw().await?;

let constructor_return = DynSolType::Array(Box::new(DynSolType::Tuple(vec![
Expand Down

This file was deleted.

134 changes: 0 additions & 134 deletions src/amm/common/mod.rs

This file was deleted.

This file was deleted.

15 changes: 5 additions & 10 deletions src/amm/curve/batch_request/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,14 @@ use alloy::{
network::Network,
primitives::{Address, U256},
providers::Provider,
sol,
transports::Transport,
};
use std::sync::Arc;

use crate::errors::AMMError;
use crate::{bindings, errors::AMMError};

use super::CurvePool;

sol! {
#[allow(missing_docs)]
#[sol(rpc)]
IGetCurvePoolDataBatchRequest,
"src/amm/curve/batch_request/GetCurvePoolDataBatchRequestABI.json"
}

#[derive(Debug)]
struct PoolData {
coins: [Address; 8],
Expand Down Expand Up @@ -76,7 +68,10 @@ where
N: Network,
P: Provider<T, N>,
{
let deployer = IGetCurvePoolDataBatchRequest::deploy_builder(provider, vec![pool.address]);
let deployer = bindings::getcurvepoolbatchrequest::GetCurvePoolBatchRequest::deploy_builder(
provider,
vec![pool.address],
);
let res = deployer.call_raw().await?;

let constructor_return = DynSolType::Array(Box::new(DynSolType::Tuple(vec![
Expand Down

This file was deleted.

14 changes: 5 additions & 9 deletions src/amm/erc_4626/batch_request/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::sync::Arc;

use crate::{amm::AutomatedMarketMaker, errors::AMMError};
use crate::{amm::AutomatedMarketMaker, bindings, errors::AMMError};

use alloy::{
dyn_abi::{DynSolType, DynSolValue},
Expand All @@ -13,13 +13,6 @@ use alloy::{

use super::ERC4626Vault;

sol! {
#[allow(missing_docs)]
#[sol(rpc)]
IGetERC4626VaultDataBatchRequest,
"src/amm/erc_4626/batch_request/GetERC4626VaultDataBatchRequestABI.json"
}

#[inline]
fn populate_pool_data_from_tokens(
mut vault: ERC4626Vault,
Expand Down Expand Up @@ -77,7 +70,10 @@ where
P: Provider<T, N>,
{
let deployer =
IGetERC4626VaultDataBatchRequest::deploy_builder(provider, vec![vault.vault_token]);
bindings::geterc4626vaultdatabatchrequest::GetERC4626VaultDataBatchRequest::deploy_builder(
provider,
vec![vault.vault_token],
);
let res = deployer.call_raw().await?;

let constructor_return = DynSolType::Array(Box::new(DynSolType::Tuple(vec![
Expand Down
4 changes: 1 addition & 3 deletions src/amm/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pub mod camelot_v3;
pub mod common;
pub mod consts;
pub mod curve;
pub mod erc_4626;
Expand Down Expand Up @@ -31,7 +30,7 @@ use crate::errors::{AMMError, ArithmeticError, EventLogError, SwapSimulationErro

use self::{
camelot_v3::CamelotV3Pool, curve::CurvePool, erc_4626::ERC4626Vault, uniswap_v2::UniswapV2Pool,
uniswap_v3::UniswapV3Pool, ve33::Ve33Pool,
uniswap_v3::UniswapV3Pool,
};

sol! {
Expand Down Expand Up @@ -252,7 +251,6 @@ macro_rules! amm {
amm!(
UniswapV2Pool,
UniswapV3Pool,
Ve33Pool,
ERC4626Vault,
CamelotV3Pool,
CurvePool
Expand Down
1 change: 0 additions & 1 deletion src/amm/uniswap_v2/batch_request/GetUniV2PoolData.json

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 271b0ab

Please sign in to comment.