Skip to content

Commit

Permalink
Merge branch 'darkforestry:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
0xDmtri authored Sep 7, 2024
2 parents fab1f20 + a55f895 commit bc94826
Show file tree
Hide file tree
Showing 8 changed files with 225 additions and 111 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ serde_json = "1.0"
thiserror = "1.0"
tokio = { version = "1.38", default-features = false }
tracing = "0.1"
uniswap_v3_math = "0.5.1"
alloy = { version = "0.2", features = [
uniswap_v3_math = { git = "https://github.com/0xKitsune/uniswap-v3-math.git" }
alloy = { version = "0.3", features = [
"contract",
"network",
"provider-ws",
Expand All @@ -49,7 +49,7 @@ criterion = "0.5"
tokio = { version = "1.38", default-features = false, features = [
"rt-multi-thread",
] }
alloy = { version = "0.2", features = ["rpc-client"] }
alloy = { version = "0.3", features = ["rpc-client"] }

[[bench]]
name = "state_space"
Expand Down
14 changes: 11 additions & 3 deletions src/amm/uniswap_v2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,16 @@ impl AutomatedMarketMaker for UniswapV2Pool {

if event_signature == IUniswapV2Pair::Sync::SIGNATURE_HASH {
let sync_event = IUniswapV2Pair::Sync::decode_log(log.as_ref(), true)?;
tracing::info!(reserve_0 = sync_event.reserve0, reserve_1 = sync_event.reserve1, address = ?self.address, "UniswapV2 sync event");

self.reserve_0 = sync_event.reserve0;
self.reserve_1 = sync_event.reserve1;
let (reserve_0, reserve_1) = (
sync_event.reserve0.to::<u128>(),
sync_event.reserve1.to::<u128>(),
);

tracing::info!(reserve_0, reserve_1, address = ?self.address, "UniswapV2 sync event");

self.reserve_0 = reserve_0;
self.reserve_1 = reserve_1;

Ok(())
} else {
Expand Down Expand Up @@ -322,6 +328,8 @@ impl UniswapV2Pool {
Err(contract_error) => return Err(AMMError::ContractError(contract_error)),
};

let (reserve_0, reserve_1) = (reserve_0.to::<u128>(), reserve_1.to::<u128>());

tracing::trace!(reserve_0, reserve_1);

Ok((reserve_0, reserve_1))
Expand Down
5 changes: 3 additions & 2 deletions src/amm/uniswap_v3/batch_request/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::{sync::Arc, vec};
use alloy::{
dyn_abi::{DynSolType, DynSolValue},
network::Network,
primitives::aliases::I24,
providers::Provider,
sol,
transports::Transport,
Expand Down Expand Up @@ -123,9 +124,9 @@ where
provider,
pool.address,
zero_for_one,
tick_start,
I24::unchecked_from(tick_start),
num_ticks,
pool.tick_spacing,
I24::unchecked_from(pool.tick_spacing),
);
let res = if let Some(block_number) = block_number {
deployer.block(block_number.into()).call_raw().await?
Expand Down
2 changes: 1 addition & 1 deletion src/amm/uniswap_v3/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl AutomatedMarketMakerFactory for UniswapV3Factory {
token_b: pool_created_event.token1,
token_a_decimals: 0,
token_b_decimals: 0,
fee: pool_created_event.fee,
fee: pool_created_event.fee.to::<u32>(),
liquidity: 0,
sqrt_price: U256::ZERO,
tick_spacing: 0,
Expand Down
Loading

0 comments on commit bc94826

Please sign in to comment.