OriginProtocol / OriginProtocol/origin-dollar

Balancer withdrawal fuzzing test

Open
#1,791 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

contracts OETH
Dominant language
Solidity
Stars
152
Forks
115
Avg merge
3d 20h
Merged PRs (30d)
17

Description

This is the main PR for creating a Balancer Metapool strategy. And when withdrawing from the strategy, the strategy contract withdraws funds from the Balancer Pool. We've identified an issue where the Balancer pool would under-deliver the funds requested by the exit pool request.

For that reason we leave the exit pool's request for min amount of tokens empty and only specify min amounts of tokens in the encoded user data request. As described in the linked issue above, if min expected token arrays on withdrawal are populated in both places the transaction reverts in some cases.

To mitigate the issue further, we also overshoot the required withdrawal amounts by 2 wei so that 1 WEI rounding error from Balancer doesn't revert the strategy's withdrawal transaction.

We would like to confirm that withdrawing rETH and stETH with different values don't cause the withdraw transaction to reverts. Withdrawing stETH could potentially be another source of problems since we are withdrawing wstETH from the pool and unwrapping it. Multiple rounding errors (Balancer pool + unwrapping) could cause larger than 2 WEI rounding error and revert the transaction.

We have some fork tests for withdrawing from wstETH pool and rETH pool. These are tests with hand-picked values, and if we could convert those to proper fuzzing tests we'd gain a lot greater amount of certainty that no combination of values would cause our transactions to revert.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the existing fork tests in contracts/test/strategies/balancerMetaStablePool.fork-test.js, especially the wstETH withdrawal around line 594 and the rETH withdrawal around line 186. Replace the hand-picked withdrawal values with fuzzing coverage for differing rETH and stETH amounts, including wstETH unwrapping. Done means the withdrawal transactions do not revert across the tested value combinations.

Written by the indexing model from the issue text.

Assessment

Tech stack
solidity
Domain
blockchain, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.