diff --git a/config/example.paraswap.toml b/config/example.paraswap.toml index b026716..32ffbcc 100644 --- a/config/example.paraswap.toml +++ b/config/example.paraswap.toml @@ -8,3 +8,4 @@ exclude-dexs = ["ParaSwapPool","ParaSwapLimitOrders"] # which dexs to ignore as address = "0xdd2e786980CD58ACc5F64807b354c981f4094936" # public address of the solver endpoint = "https://apiv5.paraswap.io" # paraswap API URL to use partner = "$YOUR_PARTNER_ID" +chain-id = 1 diff --git a/src/domain/eth/chain.rs b/src/domain/eth/chain.rs index 08aa75c..c4e4a02 100644 --- a/src/domain/eth/chain.rs +++ b/src/domain/eth/chain.rs @@ -6,6 +6,7 @@ pub enum ChainId { Mainnet = 1, Goerli = 5, Gnosis = 100, + ArbitrumOne = 42161, } impl ChainId { @@ -21,6 +22,7 @@ impl ChainId { 1 => Ok(Self::Mainnet), 5 => Ok(Self::Goerli), 100 => Ok(Self::Gnosis), + 42161 => Ok(Self::ArbitrumOne), _ => Err(UnsupportedChain), } } @@ -31,6 +33,7 @@ impl ChainId { ChainId::Mainnet => "1", ChainId::Goerli => "5", ChainId::Gnosis => "100", + ChainId::ArbitrumOne => "42161", } } diff --git a/src/infra/config/dex/paraswap/file.rs b/src/infra/config/dex/paraswap/file.rs index 468c741..2905e38 100644 --- a/src/infra/config/dex/paraswap/file.rs +++ b/src/infra/config/dex/paraswap/file.rs @@ -1,6 +1,6 @@ use { crate::{ - domain::eth, + domain::eth::{self, ChainId}, infra::{config::dex::file, dex::paraswap}, }, serde::Deserialize, @@ -25,6 +25,9 @@ struct Config { /// Which partner to identify as to the paraswap API. pub partner: String, + + /// Which chain the solver is serving. + pub chain_id: u64, } /// Load the ParaSwap solver configuration from a TOML file. @@ -43,6 +46,7 @@ pub async fn load(path: &Path) -> super::Config { exclude_dexs: config.exclude_dexs, address: config.address, partner: config.partner, + chain_id: ChainId::new(config.chain_id.into()).unwrap(), }, base, } diff --git a/src/infra/dex/paraswap/dto.rs b/src/infra/dex/paraswap/dto.rs index dd191cd..b09ca23 100644 --- a/src/infra/dex/paraswap/dto.rs +++ b/src/infra/dex/paraswap/dto.rs @@ -75,7 +75,7 @@ impl PriceQuery { }, amount: order.amount.get(), exclude_dexs: config.exclude_dexs.clone(), - network: "1".to_owned(), + network: config.chain_id.network_id().to_string(), partner: config.partner.clone(), max_impact: 100, }) diff --git a/src/infra/dex/paraswap/mod.rs b/src/infra/dex/paraswap/mod.rs index b0df797..7899280 100644 --- a/src/infra/dex/paraswap/mod.rs +++ b/src/infra/dex/paraswap/mod.rs @@ -29,6 +29,9 @@ pub struct Config { /// Our partner name. pub partner: String, + + /// For which chain the solver is configured. + pub chain_id: eth::ChainId, } impl ParaSwap { @@ -98,7 +101,7 @@ impl ParaSwap { self.client .post(util::url::join( &self.config.endpoint, - "transactions/1?ignoreChecks=true", + &format!("transactions/{}?ignoreChecks=true", self.config.chain_id.network_id()) )) .json(&body) ) diff --git a/src/tests/paraswap/mod.rs b/src/tests/paraswap/mod.rs index c14dfad..49173dc 100644 --- a/src/tests/paraswap/mod.rs +++ b/src/tests/paraswap/mod.rs @@ -14,6 +14,7 @@ endpoint = 'http://{solver_addr}' exclude-dexs = ['UniswapV2'] address = '0xE0B3700e0aadcb18ed8d4BFF648Bc99896a18ad1' partner = 'cow' +chain-id = 1 ", )) }