Skip to content

Commit

Permalink
Merge pull request #125 from propeller-heads/zz/balancer-v3/hack-bala…
Browse files Browse the repository at this point in the history
…ncer-vault-token-overwrite

feat(balancer-v3): add a specific overwrite case for BalancerV3 vault
  • Loading branch information
zizou0x authored Jan 21, 2025
2 parents 1168a20 + 5618e3e commit 1743ef1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/evm/protocol/vm/state_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ where
) -> Result<Address, SimulationError> {
let method_name = decoded
.split(':')
.last()
.next_back()
.ok_or_else(|| {
SimulationError::FatalError(
"Failed to get address from call: Could not decode method name from call"
Expand Down
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 1743ef1

Please sign in to comment.