Skip to content

Commit

Permalink
feat(balancer-v3): add a specific overwrite case for BalancerV3 vault.
Browse files Browse the repository at this point in the history
This is a hack and it is needed because of an assertion in BalancerV3 Vault contract that can't pass with how we currently overwrite tokens. There is a plan to fix this properly in the future
  • Loading branch information
zizou0x committed Jan 20, 2025
1 parent 7e0b35f commit e973e68
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,16 @@ def _get_balance_overwrites(self) -> dict[Address, dict[int, int]]:
if t.address in self.involved_contracts:
slots, compiler = self.token_storage_slots.get(t.address)
overwrites = ERC20OverwriteFactory(t, token_slots=slots, compiler=compiler)
# This is a hack made for BalancerV3. We need to find a way to properly handle this.
# Context: we need this to be true when we try to simulate _reservesOf[token] <= token.balanceOf(vault).
# But with how we currently overwrite balances (pool balance only) it's false.
# Proposed solution would be to index a per account token balance and use it for overwrite instead of TVL balances.
if address.lower() == "0xba1333333333a1ba1108e8412f11850a5c319ba9":
amount = 2**150 - 1 # Big amount but not too close to 2**256 to avoid overflows
else:
amount = t.to_onchain_amount(self.balances[t.address])
overwrites.set_balance(
t.to_onchain_amount(self.balances[t.address]), address
amount, address
)
balance_overwrites.update(overwrites.get_tycho_overwrites())
return balance_overwrites
Expand Down

0 comments on commit e973e68

Please sign in to comment.