From f12392103e13ef11e3b86813fa1fc7b53352477b Mon Sep 17 00:00:00 2001 From: Jacob <61052369+jacob-chia@users.noreply.github.com> Date: Thu, 1 Aug 2024 16:40:30 +0800 Subject: [PATCH] Support arbitrum (#529) --- src/evm/onchain/endpoints.rs | 16 +++++++++++++++- src/evm/tokens/weth_transformer.rs | 5 +++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/evm/onchain/endpoints.rs b/src/evm/onchain/endpoints.rs index 0a6331f60..27608d3ca 100644 --- a/src/evm/onchain/endpoints.rs +++ b/src/evm/onchain/endpoints.rs @@ -386,6 +386,7 @@ impl ChainConfig for OnChainConfig { "eth" => return pegged_token.get("WETH").unwrap().to_string(), "bsc" => return pegged_token.get("WBNB").unwrap().to_string(), "polygon" => return pegged_token.get("WMATIC").unwrap().to_string(), + "arbitrum" => return pegged_token.get("WETH").unwrap().to_string(), "local" => return pegged_token.get("ZERO").unwrap().to_string(), // "mumbai" => panic!("Not supported"), _ => { @@ -432,6 +433,18 @@ impl ChainConfig for OnChainConfig { .iter() .map(|(k, v)| (k.to_string(), v.to_string())) .collect(), + "arbitrum" => [ + ("WETH", "0x82af49447d8a07e3bd95bd0d56f35241523fbab1"), + ("WBTC", "0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f"), + ("USDT", "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"), + ("USDC.e", "0xff970a61a04b1ca14834a43f5de4533ebddb5cc8"), + ("USDC", "0xaf88d065e77c8cc2239327c5edb3a432268e5831"), + ("DAI", "0xda10009cbd5d07dd0cecc66161fc93d7c9000da1"), + ("crvUSD", "0x498bf2b1e120fed3ad3d42ea2165e9b73f99c1e5"), + ] + .iter() + .map(|(k, v)| (k.to_string(), v.to_string())) + .collect(), "local" => [("ZERO", "0x0000000000000000000000000000000000000000")] .iter() .map(|(k, v)| (k.to_string(), v.to_string())) @@ -1107,10 +1120,11 @@ impl OnChainConfig { } info!("fetching pairs for {token}"); let url = if is_pegged { - format!("https://pairs.infra.fuzz.land/single_pair/{network}/{token}/{weth}") + format!("https://pairs-all.infra.fuzz.land/single_pair/{network}/{token}/{weth}") } else { format!("https://pairs-all.infra.fuzz.land/pairs/{network}/{token}") }; + // info!("{url}"); let resp: Value = reqwest::blocking::get(url).unwrap().json().unwrap(); let mut pairs: Vec = Vec::new(); if let Some(resp_pairs) = resp.as_array() { diff --git a/src/evm/tokens/weth_transformer.rs b/src/evm/tokens/weth_transformer.rs index 5c2c38717..2a4471414 100644 --- a/src/evm/tokens/weth_transformer.rs +++ b/src/evm/tokens/weth_transformer.rs @@ -26,8 +26,9 @@ pub struct WethContext { pub fn withdraw_bytes(amount: EVMU256) -> Bytes { let mut ret = Vec::new(); - ret.extend_from_slice(&[0xa9, 0x05, 0x9c, 0xbb]); // transfer to null - ret.extend_from_slice(&[0x00; 32]); // padding + ret.extend_from_slice(&[0xa9, 0x05, 0x9c, 0xbb]); // transfer to a dead address + ret.extend_from_slice(&[0x00; 30]); // 0x000...dead + ret.extend_from_slice(&[0xde, 0xad]); ret.extend_from_slice(&amount.to_be_bytes::<32>()); // amount Bytes::from(ret) }