Skip to content

Commit 728c9b4

Browse files
authored
add story (#556)
1 parent 41ffd91 commit 728c9b4

File tree

1 file changed

+39
-5
lines changed

1 file changed

+39
-5
lines changed

src/evm/onchain/endpoints.rs

+39-5
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ pub enum Chain {
5454
IOTEX,
5555
SCROLL,
5656
VANA,
57+
STORY,
5758
}
5859

5960
pub trait PriceOracle: Debug {
@@ -89,6 +90,7 @@ impl FromStr for Chain {
8990
"iotex" => Ok(Self::IOTEX),
9091
"scroll" => Ok(Self::SCROLL),
9192
"vana" => Ok(Self::VANA),
93+
"story" => Ok(Self::STORY),
9294
_ => Err(()),
9395
}
9496
}
@@ -155,6 +157,7 @@ impl Chain {
155157
4689 => Self::IOTEX,
156158
534352 => Self::SCROLL,
157159
1480 => Self::VANA,
160+
1514 => Self::STORY,
158161
31337 => Self::LOCAL,
159162
_ => return Err(anyhow!("Unknown chain id: {}", chain_id)),
160163
})
@@ -183,6 +186,7 @@ impl Chain {
183186
Chain::IOTEX => 4689,
184187
Chain::SCROLL => 534352,
185188
Chain::VANA => 1480,
189+
Chain::STORY => 1514,
186190
Chain::LOCAL => 31337,
187191
}
188192
}
@@ -211,6 +215,7 @@ impl Chain {
211215
Chain::IOTEX => "iotex",
212216
Chain::SCROLL => "scroll",
213217
Chain::VANA => "vana",
218+
Chain::STORY => "story",
214219
}
215220
.to_string()
216221
}
@@ -241,6 +246,7 @@ impl Chain {
241246
Chain::IOTEX => "https://rpc.ankr.com/iotex",
242247
Chain::SCROLL => "https://rpc.ankr.com/scroll",
243248
Chain::VANA => "https://rpc.vana.org",
249+
Chain::STORY => "https://mainnet.storyrpc.io",
244250
Chain::LOCAL => "http://localhost:8545",
245251
}
246252
.to_string()
@@ -270,6 +276,7 @@ impl Chain {
270276
Chain::IOTEX => "https://babel-api.mainnet.IoTeX.io",
271277
Chain::SCROLL => "https://api.scrollscan.com/api",
272278
Chain::VANA => "https://api.vanascan.io/api/v2",
279+
Chain::STORY => "https://www.storyscan.xyz/api/v2",
273280
}
274281
.to_string()
275282
}
@@ -401,6 +408,7 @@ impl ChainConfig for OnChainConfig {
401408
"bsc" => return pegged_token.get("WBNB").unwrap().to_string(),
402409
"polygon" => return pegged_token.get("WMATIC").unwrap().to_string(),
403410
"vana" => return pegged_token.get("WVANA").unwrap().to_string(),
411+
"story" => return pegged_token.get("WIP").unwrap().to_string(),
404412
"local" => return pegged_token.get("ZERO").unwrap().to_string(),
405413
// "mumbai" => panic!("Not supported"),
406414
_ => {
@@ -477,10 +485,29 @@ impl ChainConfig for OnChainConfig {
477485
.iter()
478486
.map(|(k, v)| (k.to_string(), v.to_string()))
479487
.collect(),
488+
489+
"story" => [
490+
("WETH", "0xBAb93B7ad7fE8692A878B95a8e689423437cc500"),
491+
("uWETH", "0x28B931354098D6863817dFDce7A2D7c52B25d76a"),
492+
("storyWETH", "0x2D08d948fC0BD2Db5411E8Ab3c49E0bB89A2B428"),
493+
("USDC.e", "0xF1815bd50389c46847f0Bda824eC8da914045D14"),
494+
("USDC", "0x49Fe4CbB645CfE997465CA9F70f03DD9c58d1acF"),
495+
("storyUSDC", "0x968B9a5603ddEb2A78Aa08182BC44Ece1D9E5bf0"),
496+
("uStoryUSDC", "0xa9651875651Ff7F303605C23EF5c20C8f7BE8266"),
497+
("sdaiUSDC", "0x06578bE47CF7D19784A07DB64DCF95B84EE88671"),
498+
("USDT", "0x6c9b999D33C612cCd8721b0e349adcAE151fcbBf"),
499+
("bridgedUSDT", "0x674843C06FF83502ddb4D37c2E09C01cdA38cbc8"),
500+
("WIP", "0x1514000000000000000000000000000000000000"),
501+
]
502+
.iter()
503+
.map(|(k, v)| (k.to_string(), v.to_string()))
504+
.collect(),
505+
480506
"local" => [("ZERO", "0x0000000000000000000000000000000000000000")]
481507
.iter()
482508
.map(|(k, v)| (k.to_string(), v.to_string()))
483509
.collect(),
510+
484511
_ => {
485512
warn!("[Flashloan] Network is not supported");
486513
HashMap::new()
@@ -714,8 +741,8 @@ impl OnChainConfig {
714741
}
715742

716743
pub fn fetch_abi_uncached(&self, address: EVMAddress) -> Option<String> {
717-
if self.chain_name == "vana" {
718-
return self.fetch_vana_abi_uncached(address);
744+
if self.is_blockscout_api() {
745+
return self.blockscout_fetch_abi_uncached(address);
719746
}
720747

721748
#[cfg(feature = "no_etherscan")]
@@ -760,7 +787,7 @@ impl OnChainConfig {
760787
}
761788
}
762789

763-
fn fetch_vana_abi_uncached(&self, address: EVMAddress) -> Option<String> {
790+
fn blockscout_fetch_abi_uncached(&self, address: EVMAddress) -> Option<String> {
764791
let endpoint = format!("{}/smart-contracts/{:?}", self.etherscan_base, address);
765792

766793
// info!(">> {}", endpoint);
@@ -771,17 +798,24 @@ impl OnChainConfig {
771798
json.get("abi").map(|abi| abi.to_string())
772799
}
773800
Err(_) => {
774-
error!("Failed to parse JSON response from Vana API");
801+
error!("Failed to parse JSON response from Blockscout API");
775802
None
776803
}
777804
},
778805
None => {
779-
error!("Failed to fetch ABI from Vana API: {}", endpoint);
806+
error!("Failed to fetch ABI from Blockscout API: {}", endpoint);
780807
None
781808
}
782809
}
783810
}
784811

812+
fn is_blockscout_api(&self) -> bool {
813+
match self.chain_name.as_str() {
814+
"vana" | "story" => true,
815+
_ => false,
816+
}
817+
}
818+
785819
pub fn fetch_abi(&mut self, address: EVMAddress) -> Option<String> {
786820
if self.abi_cache.contains_key(&address) {
787821
return self.abi_cache.get(&address).unwrap().clone();

0 commit comments

Comments
 (0)