Skip to content

Commit

Permalink
support scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-chia committed Aug 9, 2024
1 parent f123921 commit 724fb93
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/evm/onchain/endpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub enum Chain {
LINEA,
LOCAL,
IOTEX,
SCROLL,
}

pub trait PriceOracle: Debug {
Expand Down Expand Up @@ -85,6 +86,7 @@ impl FromStr for Chain {
"linea" => Ok(Self::LINEA),
"local" => Ok(Self::LOCAL),
"iotex" => Ok(Self::IOTEX),
"scroll" => Ok(Self::SCROLL),
_ => Err(()),
}
}
Expand Down Expand Up @@ -201,6 +203,7 @@ impl Chain {
Chain::LINEA => "linea",
Chain::LOCAL => "local",
Chain::IOTEX => "iotex",
Chain::SCROLL => "scroll",
}
.to_string()
}
Expand Down Expand Up @@ -229,6 +232,7 @@ impl Chain {
Chain::BLAST => "https://rpc.ankr.com/blast",
Chain::LINEA => "https://rpc.ankr.com/linea",
Chain::IOTEX => "https://rpc.ankr.com/iotex",
Chain::SCROLL => "https://rpc.ankr.com/scroll",
Chain::LOCAL => "http://localhost:8545",
}
.to_string()
Expand Down Expand Up @@ -256,6 +260,7 @@ impl Chain {
Chain::LINEA => "https://api.lineascan.build/api",
Chain::LOCAL => "http://localhost:8080/abi/",
Chain::IOTEX => "https://babel-api.mainnet.IoTeX.io",
Chain::SCROLL => "https://api.scrollscan.com/api",
}
.to_string()
}
Expand Down Expand Up @@ -383,10 +388,9 @@ impl ChainConfig for OnChainConfig {
let pegged_token = self.get_pegged_token();

match self.chain_name.as_str() {
"eth" => return pegged_token.get("WETH").unwrap().to_string(),
"eth" | "arbitrum" | "scroll" => 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"),
_ => {
Expand Down Expand Up @@ -445,6 +449,16 @@ impl ChainConfig for OnChainConfig {
.iter()
.map(|(k, v)| (k.to_string(), v.to_string()))
.collect(),
"scroll" => [
("WETH", "0x5300000000000000000000000000000000000004"),
("WBTC", "0x3C1BCa5a656e69edCD0D4E36BEbb3FcDAcA60Cf1"),
("USDT", "0xf55BEC9cafDbE8730f096Aa55dad6D22d44099Df"),
("USDC", "0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4"),
("DAI", "0xcA77eB3fEFe3725Dc33bccB54eDEFc3D9f764f97"),
]
.iter()
.map(|(k, v)| (k.to_string(), v.to_string()))
.collect(),
"local" => [("ZERO", "0x0000000000000000000000000000000000000000")]
.iter()
.map(|(k, v)| (k.to_string(), v.to_string()))
Expand Down

0 comments on commit 724fb93

Please sign in to comment.