Skip to content

Commit 3b7f42d

Browse files
committed
updated RUSD to use faucet rather than token
- don't blow up if we fail to withdraw, we've prob just reached our limit
1 parent 41ecd8d commit 3b7f42d

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

onlysubs-solidity

src/eth.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use alloy::sol;
33
sol!(
44
#[derive(Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
55
#[sol(rpc)]
6-
ERC20Token,
7-
"onlysubs-solidity/out/ERC20Token.sol/ERC20Token.json"
6+
ERC20FaucetToken,
7+
"onlysubs-solidity/out/ERC20FaucetToken.sol/ERC20FaucetToken.json"
88
);
99

1010
sol!(

src/executor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
use crate::eth::ERC20Token::ERC20TokenInstance;
21
use crate::eth::Router::RouterInstance;
32
use crate::model::Trade;
43
use crate::network::Network;
54
use crate::util::normalise_chain_id;
65
use alloy::primitives::TxHash;
76
use alloy::providers::Provider;
87
use std::collections::HashMap;
8+
use crate::eth::ERC20FaucetToken::ERC20FaucetTokenInstance;
99

1010
pub(crate) struct TradeExecutor<'a, P> {
1111
routers: HashMap<u64, &'a RouterInstance<P>>,
12-
tokens: HashMap<u64, &'a ERC20TokenInstance<P>>,
12+
tokens: HashMap<u64, &'a ERC20FaucetTokenInstance<P>>,
1313
}
1414

1515
impl<'a, P: Provider> TradeExecutor<'a, P> {

src/network.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crate::config::NetworkConfig;
2-
use crate::eth::ERC20Token::ERC20TokenInstance;
32
use crate::eth::Router::RouterInstance;
43
use crate::model::{BlockEvent, ChainState, Transfer};
54
use crate::solver::ChainStateProvider;
@@ -15,12 +14,14 @@ use std::pin::Pin;
1514
use std::str::FromStr;
1615
use async_trait::async_trait;
1716
use futures::StreamExt;
17+
use crate::eth::ERC20FaucetToken;
18+
use crate::eth::ERC20FaucetToken::ERC20FaucetTokenInstance;
1819

1920
pub(crate) struct Network<P> {
2021
pub chain_id: u64,
2122
pub provider: P,
2223
pub own_addr: Address,
23-
pub token: ERC20TokenInstance<P>,
24+
pub token: ERC20FaucetTokenInstance<P>,
2425
pub router: RouterInstance<P>,
2526
}
2627

@@ -31,7 +32,12 @@ impl Network<DynProvider> {
3132

3233
for config in network_configs.iter() {
3334
let network = Network::new(&signer, config).await?;
34-
network.withdraw_tokens().await?;
35+
match network.withdraw_tokens().await {
36+
Ok(()) => {}
37+
Err(e) => {
38+
println!("failed to withdraw from faucet - probably already done: {}", e)
39+
}
40+
};
3541

3642
networks.insert(config.chain_id, network);
3743
}
@@ -53,7 +59,7 @@ impl Network<DynProvider> {
5359

5460
println!("own addr: {}", own_addr);
5561
Ok(Self {
56-
token: ERC20TokenInstance::new(config.rusd_address.parse()?, provider.clone()),
62+
token: ERC20FaucetToken::new(config.rusd_address.parse()?, provider.clone()),
5763
router: RouterInstance::new(config.router_address.parse()?, provider.clone()),
5864
chain_id,
5965
provider,
@@ -73,7 +79,7 @@ impl<P: Provider> Network<P> {
7379
return Ok(());
7480
}
7581

76-
let tx = self.token.mint(self.own_addr, min_balance).send().await?;
82+
let tx = self.token.mint().send().await?;
7783
let hash = tx.watch().await?;
7884
println!("withdrew tokens for chain_id {}: {}", &self.chain_id, hash);
7985
Ok(())

0 commit comments

Comments
 (0)