Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ itertools = "0.10.5"
hex-literal = "0.4.1"
hex = "0.4.3"
async-trait = "0.1.88"
chrono = { version = "0.4.26", features = ["serde"] }

# Tycho dependencies
tycho-client = ">=0.133.0"
tycho-common = ">=0.133.0"
tycho-ethereum = ">=0.133.0"
tycho-execution = ">=0.155.0"
tycho-common = { git = "https://github.com/propeller-heads/tycho-indexer", branch = "ah/v1-quote-interface" }
tycho-client = { git = "https://github.com/propeller-heads/tycho-indexer", branch = "ah/v1-quote-interface" }
tycho-ethereum = { git = "https://github.com/propeller-heads/tycho-indexer", branch = "ah/v1-quote-interface" }
tycho-execution = { git = "https://github.com/propeller-heads/tycho-execution", branch = "ah/v1-quote-interface" }

# EVM dependencies
# Alloy's dyn-abi 1.4.0 has a security vulnerability, so we require at least 1.4.1
Expand All @@ -58,7 +59,7 @@ serde = { workspace = true }
serde_json = { workspace = true }
uuid = { version = "1.4.1", features = ["serde", "v4", "fast-rng", "macro-diagnostics"] }
hex = { workspace = true }
chrono = { version = "0.4.26", features = ["serde"] }
chrono = { workspace = true }
typetag = { workspace = true }

# Error handling
Expand Down Expand Up @@ -103,7 +104,7 @@ tokio-stream = "0.1.16"
dialoguer = "0.10.4"

# Ekubo
evm_ekubo_sdk = {version = "0.6.5", features = ["serde"]}
evm_ekubo_sdk = { version = "0.6.5", features = ["serde"] }
ekubo_sdk = { version = "=1.0.2", features = ["evm", "serde"] }

# rfq
Expand Down
4 changes: 2 additions & 2 deletions src/evm/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ mock! {
delta: ProtocolStateDelta,
tokens: &HashMap<Bytes, Token>,
balances: &Balances,
) -> Result<(), TransitionError<String>>;
) -> Result<(), TransitionError>;
pub fn clone_box(&self) -> Box<dyn ProtocolSim>;
pub fn eq(&self, other: &dyn ProtocolSim) -> bool;
}
Expand Down Expand Up @@ -1053,7 +1053,7 @@ impl ProtocolSim for MockProtocolSim {
delta: ProtocolStateDelta,
tokens: &HashMap<Bytes, Token>,
balances: &Balances,
) -> Result<(), TransitionError<String>> {
) -> Result<(), TransitionError> {
self.delta_transition(delta, tokens, balances)
}

Expand Down
2 changes: 1 addition & 1 deletion src/evm/protocol/aerodrome_slipstreams/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ impl ProtocolSim for AerodromeSlipstreamsState {
delta: ProtocolStateDelta,
_tokens: &HashMap<Bytes, Token>,
_balances: &Balances,
) -> Result<(), TransitionError<String>> {
) -> Result<(), TransitionError> {
if let Some(block_timestamp) = delta
.updated_attributes
.get("block_timestamp")
Expand Down
2 changes: 1 addition & 1 deletion src/evm/protocol/cowamm/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ impl ProtocolSim for CowAMMState {
delta: ProtocolStateDelta,
_tokens: &HashMap<Bytes, Token>,
_balances: &Balances,
) -> Result<(), TransitionError<String>> {
) -> Result<(), TransitionError> {
// liquidity_a, liquidity_b and lp_token_supply are considered required attributes and are
// expected in every delta we process
let liquidity_a = U256::from_be_slice(
Expand Down
42 changes: 21 additions & 21 deletions src/evm/protocol/cowamm/tycho_decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::collections::HashMap;

use alloy::primitives::U256;
use tycho_client::feed::{synchronizer::ComponentWithState, BlockHeader};
use tycho_common::{dto::ProtocolComponent, models::token::Token, Bytes};
use tycho_common::{models::token::Token, Bytes};

use crate::{
evm::protocol::cowamm::state::CowAMMState,
Expand Down Expand Up @@ -136,32 +136,32 @@ pub fn static_attributes() -> HashMap<String, Bytes> {
])
}

pub fn component() -> ProtocolComponent {
ProtocolComponent { static_attributes: static_attributes(), ..Default::default() }
}

pub fn state() -> CowAMMState {
CowAMMState::new(
Bytes::from(vec![0; 32]),
Bytes::from(vec![0; 32]),
Bytes::from(vec![0; 32]),
U256::from(0),
U256::from(0),
Bytes::from(vec![0; 32]),
U256::from(0),
U256::from(0),
U256::from(0),
0u64,
)
}

#[cfg(test)]
mod tests {
use rstest::rstest;
use tycho_common::dto::ResponseProtocolState;
use tycho_common::dto::{ProtocolComponent, ResponseProtocolState};

use super::*;

fn component() -> ProtocolComponent {
ProtocolComponent { static_attributes: static_attributes(), ..Default::default() }
}

fn state() -> CowAMMState {
CowAMMState::new(
Bytes::from(vec![0; 32]),
Bytes::from(vec![0; 32]),
Bytes::from(vec![0; 32]),
U256::from(0),
U256::from(0),
Bytes::from(vec![0; 32]),
U256::from(0),
U256::from(0),
U256::from(0),
0u64,
)
}

fn header() -> BlockHeader {
BlockHeader {
number: 1,
Expand Down
8 changes: 4 additions & 4 deletions src/evm/protocol/cpmm/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ pub fn cpmm_get_amount_out(
/// the actual price impact to be slightly less than 90%. For typical fees (0.25%-0.3%), the
/// actual price impact is approximately 89.9% instead of exactly 90%.
pub fn cpmm_get_limits(
sell_token: Bytes,
buy_token: Bytes,
sell_token: &Bytes,
buy_token: &Bytes,
reserve0: U256,
reserve1: U256,
fee_bps: u32,
Expand Down Expand Up @@ -126,10 +126,10 @@ pub fn cpmm_get_limits(
}

pub fn cpmm_delta_transition(
delta: ProtocolStateDelta,
delta: &ProtocolStateDelta,
reserve0_mut: &mut U256,
reserve1_mut: &mut U256,
) -> Result<(), TransitionError<String>> {
) -> Result<(), TransitionError> {
// reserve0 and reserve1 are considered required attributes and are expected in every delta
// we process
let reserve0 = U256::from_be_slice(
Expand Down
2 changes: 1 addition & 1 deletion src/evm/protocol/ekubo/pool/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl EkuboPool for BasePool {
&mut self,
updated_attributes: HashMap<String, Bytes>,
deleted_attributes: HashSet<String>,
) -> Result<(), TransitionError<String>> {
) -> Result<(), TransitionError> {
let active_tick_update = updated_attributes
.get("tick")
.and_then(|updated_tick| {
Expand Down
2 changes: 1 addition & 1 deletion src/evm/protocol/ekubo/pool/full_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl EkuboPool for FullRangePool {
&mut self,
_updated_attributes: HashMap<String, Bytes>,
_deleted_attributes: HashSet<String>,
) -> Result<(), TransitionError<String>> {
) -> Result<(), TransitionError> {
Ok(())
}
}
2 changes: 1 addition & 1 deletion src/evm/protocol/ekubo/pool/mev_resist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ impl EkuboPool for MevResistPool {
&mut self,
updated_attributes: HashMap<String, Bytes>,
deleted_attributes: HashSet<String>,
) -> Result<(), TransitionError<String>> {
) -> Result<(), TransitionError> {
let active_tick_update = updated_attributes
.get("tick")
.and_then(|updated_tick| {
Expand Down
2 changes: 1 addition & 1 deletion src/evm/protocol/ekubo/pool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub trait EkuboPool {
&mut self,
updated_attributes: HashMap<String, Bytes>,
deleted_attributes: HashSet<String>,
) -> Result<(), TransitionError<String>>;
) -> Result<(), TransitionError>;

fn quote(
&self,
Expand Down
2 changes: 1 addition & 1 deletion src/evm/protocol/ekubo/pool/oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl EkuboPool for OraclePool {
&mut self,
_updated_attributes: HashMap<String, Bytes>,
_deleted_attributes: HashSet<String>,
) -> Result<(), TransitionError<String>> {
) -> Result<(), TransitionError> {
self.swapped_this_block = false;

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/evm/protocol/ekubo/pool/twamm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ impl EkuboPool for TwammPool {
&mut self,
updated_attributes: HashMap<String, Bytes>,
deleted_attributes: HashSet<String>,
) -> Result<(), TransitionError<String>> {
) -> Result<(), TransitionError> {
if let Some(token0_sale_rate) = updated_attributes.get("token0_sale_rate") {
self.state.token0_sale_rate = token0_sale_rate.clone().into();
}
Expand Down
2 changes: 1 addition & 1 deletion src/evm/protocol/ekubo/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl ProtocolSim for EkuboState {
delta: ProtocolStateDelta,
_tokens: &HashMap<Bytes, Token>,
_balances: &Balances,
) -> Result<(), TransitionError<String>> {
) -> Result<(), TransitionError> {
if let Some(liquidity) = delta
.updated_attributes
.get("liquidity")
Expand Down
2 changes: 1 addition & 1 deletion src/evm/protocol/ekubo_v3/pool/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl EkuboPool for BasePool {
&mut self,
updated_attributes: HashMap<String, Bytes>,
deleted_attributes: HashSet<String>,
) -> Result<(), TransitionError<String>> {
) -> Result<(), TransitionError> {
let active_tick_update = updated_attributes
.get("tick")
.and_then(|updated_tick| {
Expand Down
2 changes: 1 addition & 1 deletion src/evm/protocol/ekubo_v3/pool/full_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl EkuboPool for FullRangePool {
&mut self,
_updated_attributes: HashMap<String, Bytes>,
_deleted_attributes: HashSet<String>,
) -> Result<(), TransitionError<String>> {
) -> Result<(), TransitionError> {
Ok(())
}
}
2 changes: 1 addition & 1 deletion src/evm/protocol/ekubo_v3/pool/mev_capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl EkuboPool for MevCapturePool {
&mut self,
updated_attributes: HashMap<String, Bytes>,
deleted_attributes: HashSet<String>,
) -> Result<(), TransitionError<String>> {
) -> Result<(), TransitionError> {
let active_tick_update = updated_attributes
.get("tick")
.and_then(|updated_tick| {
Expand Down
2 changes: 1 addition & 1 deletion src/evm/protocol/ekubo_v3/pool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub trait EkuboPool {
&mut self,
updated_attributes: HashMap<String, Bytes>,
deleted_attributes: HashSet<String>,
) -> Result<(), TransitionError<String>>;
) -> Result<(), TransitionError>;

fn quote(
&self,
Expand Down
2 changes: 1 addition & 1 deletion src/evm/protocol/ekubo_v3/pool/oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl EkuboPool for OraclePool {
&mut self,
_updated_attributes: HashMap<String, Bytes>,
_deleted_attributes: HashSet<String>,
) -> Result<(), TransitionError<String>> {
) -> Result<(), TransitionError> {
self.swapped_this_block = false;

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/evm/protocol/ekubo_v3/pool/stableswap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl EkuboPool for StableswapPool {
&mut self,
_updated_attributes: HashMap<String, Bytes>,
_deleted_attributes: HashSet<String>,
) -> Result<(), TransitionError<String>> {
) -> Result<(), TransitionError> {
Ok(())
}
}
2 changes: 1 addition & 1 deletion src/evm/protocol/ekubo_v3/pool/twamm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl EkuboPool for TwammPool {
&mut self,
updated_attributes: HashMap<String, Bytes>,
deleted_attributes: HashSet<String>,
) -> Result<(), TransitionError<String>> {
) -> Result<(), TransitionError> {
if let Some(token0_sale_rate) = updated_attributes.get("token0_sale_rate") {
self.state.token0_sale_rate = token0_sale_rate.clone().into();
}
Expand Down
2 changes: 1 addition & 1 deletion src/evm/protocol/ekubo_v3/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl ProtocolSim for EkuboV3State {
delta: ProtocolStateDelta,
_tokens: &HashMap<Bytes, Token>,
_balances: &Balances,
) -> Result<(), TransitionError<String>> {
) -> Result<(), TransitionError> {
if let Some(liquidity) = delta
.updated_attributes
.get("liquidity")
Expand Down
2 changes: 1 addition & 1 deletion src/evm/protocol/erc4626/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl ProtocolSim for ERC4626State {
_delta: ProtocolStateDelta,
_tokens: &HashMap<Bytes, Token>,
_balances: &Balances,
) -> Result<(), TransitionError<String>> {
) -> Result<(), TransitionError> {
let engine =
create_engine(SHARED_TYCHO_DB.clone(), false).expect("Failed to create engine");

Expand Down
2 changes: 1 addition & 1 deletion src/evm/protocol/fluid/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ impl ProtocolSim for FluidV1 {
_delta: ProtocolStateDelta,
_tokens: &HashMap<Bytes, Token>,
_balances: &Balances,
) -> Result<(), TransitionError<String>> {
) -> Result<(), TransitionError> {
let engine = create_engine(SHARED_TYCHO_DB.clone(), false).expect("Infallible");

let state = vm::decode_from_vm(
Expand Down
6 changes: 3 additions & 3 deletions src/evm/protocol/lido/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ impl LidoState {
fn st_eth_delta_transition(
&mut self,
delta: ProtocolStateDelta,
) -> Result<(), TransitionError<String>> {
) -> Result<(), TransitionError> {
self.total_shares = BigUint::from_bytes_be(
delta
.updated_attributes
Expand Down Expand Up @@ -356,7 +356,7 @@ impl LidoState {
fn wst_eth_delta_transition(
&mut self,
delta: ProtocolStateDelta,
) -> Result<(), TransitionError<String>> {
) -> Result<(), TransitionError> {
self.total_shares = BigUint::from_bytes_be(
delta
.updated_attributes
Expand Down Expand Up @@ -484,7 +484,7 @@ impl ProtocolSim for LidoState {
delta: ProtocolStateDelta,
_tokens: &HashMap<Bytes, Token>,
balances: &Balances,
) -> Result<(), TransitionError<String>> {
) -> Result<(), TransitionError> {
for (component_id, balances) in balances.component_balances.iter() {
if Bytes::from(component_id.as_str()) == self.id {
match self.pool_type {
Expand Down
Loading
Loading