Skip to content

Commit

Permalink
Add workaround to get actual web3 instance instead of dummy version (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinquaXD authored Nov 9, 2023
1 parent fd6b842 commit e00a732
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crates/driver/src/infra/blockchain/token.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use {
super::{Error, Ethereum},
crate::domain::{competition::order, eth},
contracts::{dummy_contract, BalancerV2Vault},
contracts::BalancerV2Vault,
futures::TryFutureExt,
};

Expand Down Expand Up @@ -151,6 +151,7 @@ impl Erc20 {
source: order::SellTokenBalance,
) -> Result<eth::TokenAmount, Error> {
use order::SellTokenBalance::*;
let web3 = self.token.raw_instance().web3();

let usable_balance = match source {
Erc20 => {
Expand All @@ -160,7 +161,7 @@ impl Erc20 {
std::cmp::min(balance.0, allowance.0.amount)
}
External => {
let vault = dummy_contract!(BalancerV2Vault, self.vault);
let vault = BalancerV2Vault::at(&web3, self.vault.0);
let balance = self.balance(trader);
let approved = vault
.methods()
Expand All @@ -176,7 +177,7 @@ impl Erc20 {
}
}
Internal => {
let vault = dummy_contract!(BalancerV2Vault, self.vault);
let vault = BalancerV2Vault::at(&web3, self.vault.0);
let balance = vault
.methods()
.get_internal_balance(trader.0, vec![self.token.address()])
Expand Down

0 comments on commit e00a732

Please sign in to comment.