Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support scroll #531

Merged
merged 2 commits into from
Aug 9, 2024
Merged
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: 18 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 @@ -149,6 +151,7 @@ impl Chain {
81457 => Self::BLAST,
59144 => Self::LINEA,
4689 => Self::IOTEX,
534352 => Self::SCROLL,
31337 => Self::LOCAL,
_ => return Err(anyhow!("Unknown chain id: {}", chain_id)),
})
Expand All @@ -175,6 +178,7 @@ impl Chain {
Chain::BLAST => 81457,
Chain::LINEA => 59144,
Chain::IOTEX => 4689,
Chain::SCROLL => 534352,
Chain::LOCAL => 31337,
}
}
Expand All @@ -201,6 +205,7 @@ impl Chain {
Chain::LINEA => "linea",
Chain::LOCAL => "local",
Chain::IOTEX => "iotex",
Chain::SCROLL => "scroll",
}
.to_string()
}
Expand Down Expand Up @@ -229,6 +234,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 +262,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 +390,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 +451,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