Fix: Do not let user specify the native/wrapped token

This puts too much burden on the user. Instead, specify native and wrapped tokens as methods which return hardcoded values.
This commit is contained in:
TAMARA LIPOWSKI
2025-02-06 11:08:06 -05:00
parent e83b8d9aef
commit 1a07c7dc61
7 changed files with 41 additions and 93 deletions

View File

@@ -164,6 +164,7 @@ mod tests {
use alloy_primitives::Uint;
use num_bigint::BigUint;
use tycho_core::dto::Chain as TychoCoreChain;
use super::*;
@@ -198,21 +199,8 @@ mod tests {
}
}
fn eth() -> Bytes {
Bytes::from_str("0x0000000000000000000000000000000000000000").unwrap()
}
fn weth() -> Bytes {
Bytes::from_str("0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2").unwrap()
}
fn eth_chain() -> Chain {
Chain {
id: ChainId(1),
name: String::from("ethereum"),
native_token: eth(),
wrapped_token: weth(),
}
TychoCoreChain::Ethereum.into()
}
#[test]

View File

@@ -76,8 +76,8 @@ impl SplitSwapStrategyEncoder {
permit2: Permit2::new(signer_pk, chain.clone())?,
selector,
swap_encoder_registry,
native_address: chain.native_token.clone(),
wrapped_address: chain.wrapped_token.clone(),
native_address: chain.native_token()?,
wrapped_address: chain.wrapped_token()?,
})
}
@@ -440,15 +440,10 @@ mod tests {
};
use super::*;
use crate::encoding::models::{ChainId, Swap};
use crate::encoding::models::Swap;
fn eth_chain() -> Chain {
Chain {
id: ChainId(1),
name: TychoCoreChain::Ethereum.to_string(),
native_token: eth(),
wrapped_token: weth(),
}
TychoCoreChain::Ethereum.into()
}
fn eth() -> Bytes {

View File

@@ -33,8 +33,8 @@ impl<S: StrategyEncoderRegistry> EVMTychoEncoder<S> {
Ok(EVMTychoEncoder {
strategy_selector,
router_address,
native_address: chain.native_token,
wrapped_address: chain.wrapped_token,
native_address: chain.native_token()?,
wrapped_address: chain.wrapped_token()?,
})
}
}
@@ -125,9 +125,7 @@ mod tests {
use super::*;
use crate::encoding::{
models::{ChainId, Swap},
strategy_encoder::StrategyEncoder,
swap_encoder::SwapEncoder,
models::Swap, strategy_encoder::StrategyEncoder, swap_encoder::SwapEncoder,
};
struct MockStrategyRegistry {
@@ -135,12 +133,7 @@ mod tests {
}
fn eth_chain() -> Chain {
Chain {
id: ChainId(1),
name: TychoCoreChain::Ethereum.to_string(),
native_token: eth(),
wrapped_token: weth(),
}
TychoCoreChain::Ethereum.into()
}
fn dai() -> Bytes {