Skip to content

Commit 8b4a0d5

Browse files
authored
Allow zero balances for solvers in trade simulation (#3750)
# Description This PR removes the need for solvers to hold balances in trade simulations.
1 parent 900ab2c commit 8b4a0d5

File tree

1 file changed

+10
-9
lines changed
  • crates/shared/src/price_estimation/trade_verifier

1 file changed

+10
-9
lines changed

crates/shared/src/price_estimation/trade_verifier/mod.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -378,22 +378,25 @@ impl TradeVerifier {
378378
);
379379

380380
// Set up mocked solver.
381-
let mut solver_override = StateOverride {
381+
let solver_override = StateOverride {
382382
code: Some(Solver::Solver::DEPLOYED_BYTECODE.clone().into()),
383+
// Allow solver simulations to proceed even if the real account holds no ETH.
384+
balance: Some(U256::exp10(18)),
383385
..Default::default()
384386
};
385387

386388
// If the trade requires a special tx.origin we also need to fake the
387-
// authenticator and tx origin balance.
389+
// authenticator.
388390
if trade
389391
.tx_origin()
390392
.is_some_and(|origin| origin != trade.solver())
391393
{
392-
let (authenticator, balance) = futures::join!(
393-
self.settlement.authenticator().call(),
394-
self.web3.eth().balance(trade.solver(), None)
395-
);
396-
let authenticator = authenticator.context("could not fetch authenticator")?;
394+
let authenticator = self
395+
.settlement
396+
.authenticator()
397+
.call()
398+
.await
399+
.context("could not fetch authenticator")?;
397400
overrides.insert(
398401
authenticator,
399402
StateOverride {
@@ -403,8 +406,6 @@ impl TradeVerifier {
403406
..Default::default()
404407
},
405408
);
406-
let balance = balance.context("could not fetch balance")?;
407-
solver_override.balance = Some(balance);
408409
}
409410
overrides.insert(trade.tx_origin().unwrap_or(trade.solver()), solver_override);
410411

0 commit comments

Comments
 (0)