Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abstract strategy gas improvements #1719

Merged

Conversation

naddison36
Copy link
Collaborator

@naddison36 naddison36 commented Jul 26, 2023

I've put this Balancer strategy gas improvement into a separate PR as it changes the base strategy contract hence impacts all contract that inherit from InitializableAbstractStrategy

The change is pretty simple, replace the storage variables platformAddress and vaultAddress with immutable variables.
This has significant knock on impacts being

  • to preserve the storage slots of existing contracts, private deprecated variables are introduced
  • a contractor is added to InitializableAbstractStrategy so the platformAddress and vaultAddress variables can be set
  • the _platformAddress and _vaultAddress properties are removed from the initialize function
  • The constructor on abstract contracts set their own immutable variables. They don't set the values in abstract contract higher up the tree. Its up to the final implementing contract to call the constructors of each abstract contract. For example, the BalancerMetaPoolStrategy constructor which inherits BaseAuraStrategy which inherits BaseBalancerStrategy which inherits InitializableAbstractStrategy.
constructor(
        BaseStrategyConfig memory _stratConfig,
        BaseBalancerConfig memory _balancerConfig,
        AuraConfig memory _auraConfig
    )
        InitializableAbstractStrategy(_stratConfig)
        BaseBalancerStrategy(_balancerConfig)
        BaseAuraStrategy(_auraConfig)
    {}

Note the BaseAuraStrategy constructor does not call BaseBalancerStrategy or InitializableAbstractStrategy.

    struct AuraConfig {
        address auraRewardPoolAddress; // Address of the Aura rewards pool
        address auraRewardStakerAddress; // Address of the Aura rewards staker
        uint256 auraDepositorPTokenId; // The Aura rewards staker
    }

    constructor(AuraConfig memory _auraConfig) {
        auraRewardPoolAddress = _auraConfig.auraRewardPoolAddress;
        auraRewardStakerAddress = _auraConfig.auraRewardStakerAddress;
        auraDepositorPTokenId = _auraConfig.auraDepositorPTokenId;
    }
  • Re-running any old strategy deploy scripts will fail as constructor params needs to be added and initialize params removed. If deploying a new strategy contract, a new deploy script is required which is standard practice.

Gas usage before the changes

|  Contract      ·  Method                   ·  Min        ·  Max        ·  Avg        ·  # calls      ·  eur (avg)  │
·················|···························|·············|·············|·············|···············|··············
|  AaveStrategy  ·  withdraw                 ·          -  ·          -  ·     828497  ·            1  ·          -  │
·················|···························|·············|·············|·············|···············|··············
|  ERC20         ·  approve                  ·      26174  ·      65286  ·      41186  ·           76  ·          -  │
·················|···························|·············|·············|·············|···············|··············
|  ERC20         ·  transfer                 ·      51427  ·      88327  ·      61066  ·           90  ·          -  │
·················|···························|·············|·············|·············|···············|··············
|  Flipper       ·  withdrawAll              ·          -  ·          -  ·     873101  ·            1  ·          -  │
·················|···························|·············|·············|·············|···············|··············
|  Harvester     ·  harvestAndSwap           ·          -  ·          -  ·     203484  ·            1  ·          -  │
·················|···························|·············|·············|·············|···············|··············
|  MockVault     ·  allocate                 ·     479090  ·    1595503  ·     705986  ·            8  ·          -  │
·················|···························|·············|·············|·············|···············|··············
|  MockVault     ·  checkBalance             ·      62403  ·     101859  ·      75555  ·            3  ·          -  │
·················|···························|·············|·············|·············|···············|··············
|  MockVault     ·  mint                     ·    1362682  ·    1427147  ·    1387348  ·            4  ·          -  │
·················|···························|·············|·············|·············|···············|··············
|  OETHVault     ·  setAssetDefaultStrategy  ·      55636  ·      75536  ·      65586  ·            4  ·          -  │

Gas usage after the changes

|  Contract      ·  Method                   ·  Min        ·  Max        ·  Avg        ·  # calls      ·  eur (avg)  │
·················|···························|·············|·············|·············|···············|··············
|  AaveStrategy  ·  withdraw                 ·          -  ·          -  ·     817914  ·            1  ·          -  │
·················|···························|·············|·············|·············|···············|··············
|  ERC20         ·  approve                  ·      26174  ·      65286  ·      41186  ·           76  ·          -  │
·················|···························|·············|·············|·············|···············|··············
|  ERC20         ·  transfer                 ·      51427  ·      88327  ·      61066  ·           90  ·          -  │
·················|···························|·············|·············|·············|···············|··············
|  Flipper       ·  withdrawAll              ·          -  ·          -  ·     861302  ·            1  ·          -  │
·················|···························|·············|·············|·············|···············|··············
|  Harvester     ·  harvestAndSwap           ·          -  ·          -  ·     202476  ·            1  ·          -  │
·················|···························|·············|·············|·············|···············|··············
|  MockVault     ·  allocate                 ·     476791  ·    1599171  ·     703347  ·            8  ·          -  │
·················|···························|·············|·············|·············|···············|··············
|  MockVault     ·  checkBalance             ·      62295  ·     101768  ·      75453  ·            3  ·          -  │
·················|···························|·············|·············|·············|···············|··············
|  MockVault     ·  mint                     ·    1351501  ·    1416066  ·    1376192  ·            4  ·          -  │
·················|···························|·············|·············|·············|···············|··············
|  OETHVault     ·  setAssetDefaultStrategy  ·      55636  ·      75536  ·      65586  ·            4  ·          -  │

@naddison36 naddison36 self-assigned this Jul 26, 2023
@rafaelugolini rafaelugolini temporarily deployed to preview-oeth-nicka-abst-spqise July 26, 2023 04:57 Inactive
@rafaelugolini rafaelugolini temporarily deployed to preview-ousd-nicka-abst-5niedk July 26, 2023 04:57 Inactive
@naddison36 naddison36 added contracts Works related to contracts OETH OETH related things OUSD OUSD releated things labels Jul 26, 2023
@naddison36 naddison36 marked this pull request as draft July 26, 2023 05:27
@rafaelugolini rafaelugolini temporarily deployed to preview-oeth-nicka-abst-spqise July 26, 2023 05:53 Inactive
@rafaelugolini rafaelugolini temporarily deployed to preview-ousd-nicka-abst-yk6ru7 July 26, 2023 05:53 Inactive
@rafaelugolini rafaelugolini temporarily deployed to preview-oeth-nicka-abst-spqise July 26, 2023 07:24 Inactive
@rafaelugolini rafaelugolini temporarily deployed to preview-ousd-nicka-abst-hjodkp July 26, 2023 07:24 Inactive
@naddison36 naddison36 marked this pull request as ready for review July 26, 2023 13:09
@naddison36 naddison36 merged commit 732d60b into nicka/balancer-sfrxETH-stETH-rETH Jul 26, 2023
@naddison36 naddison36 deleted the nicka/abstract-strategy-gas branch July 26, 2023 22:52
naddison36 added a commit that referenced this pull request Jul 31, 2023
* Refactor base strategy to use immutables

* Fixed strategy deployments in 001_core and fixtures

* Generated new strategy diagrams
sparrowDom pushed a commit that referenced this pull request Jul 31, 2023
* Generated contract docs

* Refactor Balancer storage variables

* Small Balancer changes

* Natspec updates
Added missing licensing
getPoolAssets gas optimized

* Updated generated Balancer strategy contract diagrams

* fix contract linter

* Removed restrictions on tests

* Small gas improvements
Fixed Slither

* Change BalancerError version

* Updated constant names
Addresses to use checksum format

* JS lint tasks

* Updated Balancer and Aura pool id constants

* Removed getRateProviderRate as it wasn't being used
Refactored to remove poolAssetsMapped storage variable

* Updated OETH Contracts diagrams
Generated new Balancer contract diagrams

* Fix failing test

* Fix merge conflict

* Restored getRateProviderRate

* Natspec updates
Added toPoolAsset override

* Removed unused getRateProviderRate

* Natspec updates
Gas optimization of InitializableAbstractStrategy

* Abstract strategy gas improvements (#1719)

* Refactor base strategy to use immutables

* Fixed strategy deployments in 001_core and fixtures

* Generated new strategy diagrams

* Deploy rETH instead of the stETH Balancer MetaStable Pool

* removed unused Aura config

* Balancer fork tests

* Added check that BPT amount equals Aura LP amount
Added rETH conversion to ETH value

* Updated balancer strat fork tests

* Updated Balancer fork tests

* Added optional deposit with multiple assets to the strategy

* Single asset deposit to use multi asset deposit

* Added optional checkBalance to Balancer strategy

* Added checkBalance() to BaseBalancerStrategy

* Fix slither
Fix curve HH task

* Added multi-asset withdraw to balancer strategy

* Fix multi-asset withdraw

* Updated Balancer and Vault diagrams

* Fix js linter

* Fixed checkBalance of rETH asset in Balancer strategy

* Only wrap assets if amount > 0
Added depositAll fork test for Balancer strat

* Removed Vault changes for multi-asset strategy support

* Updated generated docs

* Add tests for wstETH/WETH Balancer pool (#1725)

* Split deployment and fix fixtures

* Deposit tests for wstETH/WETH pool

* Add withdraw test

* prettier

* remove .only in fork tests

---------

Co-authored-by: Shahul Hameed <[email protected]>
naddison36 added a commit that referenced this pull request Aug 1, 2023
* Abstract strategy gas improvements (#1719)
sparrowDom added a commit that referenced this pull request Sep 21, 2023
* initail commit

* intermediary commit

* commit research files

* balancer booster abi

* intermittent commit

* add base balancer contract that implements checkBalance functionality

* add some additional initial integration

* intermittent commit

* add deployment file

* add fork test fixture

* intermittent commit

* prettier

* add basic withdrawal / deposit functionality

* correct the BPT calculation

* prettier + lint

* simplify the BPT price calculation

* add read-only re-entrancy protection

* add some missing tests and adjust existing. Deparate deposit and withdrawal slippage

* fix check balance implementation

* Balancer review changes (#1726)

* Generated contract docs

* Refactor Balancer storage variables

* Small Balancer changes

* Natspec updates
Added missing licensing
getPoolAssets gas optimized

* Updated generated Balancer strategy contract diagrams

* fix contract linter

* Removed restrictions on tests

* Small gas improvements
Fixed Slither

* Change BalancerError version

* Updated constant names
Addresses to use checksum format

* JS lint tasks

* Updated Balancer and Aura pool id constants

* Removed getRateProviderRate as it wasn't being used
Refactored to remove poolAssetsMapped storage variable

* Updated OETH Contracts diagrams
Generated new Balancer contract diagrams

* Fix failing test

* Fix merge conflict

* Restored getRateProviderRate

* Natspec updates
Added toPoolAsset override

* Removed unused getRateProviderRate

* Natspec updates
Gas optimization of InitializableAbstractStrategy

* Abstract strategy gas improvements (#1719)

* Refactor base strategy to use immutables

* Fixed strategy deployments in 001_core and fixtures

* Generated new strategy diagrams

* Deploy rETH instead of the stETH Balancer MetaStable Pool

* removed unused Aura config

* Balancer fork tests

* Added check that BPT amount equals Aura LP amount
Added rETH conversion to ETH value

* Updated balancer strat fork tests

* Updated Balancer fork tests

* Added optional deposit with multiple assets to the strategy

* Single asset deposit to use multi asset deposit

* Added optional checkBalance to Balancer strategy

* Added checkBalance() to BaseBalancerStrategy

* Fix slither
Fix curve HH task

* Added multi-asset withdraw to balancer strategy

* Fix multi-asset withdraw

* Updated Balancer and Vault diagrams

* Fix js linter

* Fixed checkBalance of rETH asset in Balancer strategy

* Only wrap assets if amount > 0
Added depositAll fork test for Balancer strat

* Removed Vault changes for multi-asset strategy support

* Updated generated docs

* Add tests for wstETH/WETH Balancer pool (#1725)

* Split deployment and fix fixtures

* Deposit tests for wstETH/WETH pool

* Add withdraw test

* prettier

* remove .only in fork tests

---------

Co-authored-by: Shahul Hameed <[email protected]>

* [ DFD-1 ] Balancer's checkBalance (#1730)

* add alternative implementation of Balancer's checkBalance

* correct the checkBalance implementation

* Balancer fork tests (#1727)

* Added large withdraw tests for Balancer strategy

* fix test log

* Balancer withdraw to handle close to BPT limit

* Small change to Balancer withdraw fork test

* add some comments

* change implementation

---------

Co-authored-by: Domen Grabec <[email protected]>

* Add read-only reentrancy test (#1731)

* Added large withdraw tests for Balancer strategy

* fix test log

* Balancer withdraw to handle close to BPT limit

* Small change to Balancer withdraw fork test

* add some comments

* Add test for read-only reentrancy

* add reentrancy protection to checkBalance functions

* add documentation

* remove the only

---------

Co-authored-by: Nicholas Addison <[email protected]>
Co-authored-by: Domen Grabec <[email protected]>

* Balancer fixes (#1734)

* prettier

* adjust how checkBalance is calculated

* Balancer withdrawal fix (#1739)

* fix balancer withdrawals

* lint

* prettier

* use only 1 safeApprove when applicable

* some renames and more correct application of approves

* renames, additional requires, move initializer to a better location, slither

* bug fix

* Generated latest Balancer strategy diagrams

* re-deploy BPT tokens sitting in the strategy

* fix re-entrancy test

* fixture fix

* bug fix

* prettier

* L02 improve naming  (#1783)

* improve naming

* one more rename

* buf fix

* do a check that supported assets are being withdrawn (#1784)

* set uint256 max instead of magic number (#1782)

* remove unused files (#1785)

* fix renaming bug

* correct safe approve all tokens and adjust the documentation (#1776)

* prettier

* M04 - minBptFunction robustness (#1795)

* change bptExpected to ignore Oracle prices and assume assets are always pegged. (Vault value checker shall be used to mitigate issues with said assumption)

* fix all the tests

* add test for pool manipulation

* prettier & lint

* minor change

* add withdrawal test

* update documentation

* pick string error length that is smaller than 32 characters

* prettier

* correct comment

* better comments

* prettier

* M02 withdrawal fuzzing tests (#1801)

* add more withdrawal tests

* add more withdrawal cases

* N02 gas inefficiencies  (#1786)

* gas optimisation

* fix bad merge and prettier

* remove todo comments (#1796)

* use a more appropriate array initialisation length (#1800)

* more consistant function naming (#1797)

* fix typo (#1798)

* simplify the way we withdrawAll. no need to pass along min amonts (#1777)

* M03 - missing or misleading documentation (#1781)

* improve documentation

* add comma

* M01 More comprehensive test suite (#1780)

* add tests for approving tokens and harvesting rewards

* prettier and lint

* fix bad merge + prettier & lint

* fix fork tests remove .only

* remove only

* lint

* fix unit tests

* add more tests to see how checkBalance behaves

* remove console log

* improve checkBalance test by testing that checkBalance amount doesn't decrease after the attack comaring to the middle of the attack.

* confirm that yield gained by 3rd party tilting the pool can be extracted by withdrawing the funds

* rename internal functions by prepending them with underscore

* Generated latest Balancer strategy diagrams (#1805)

* bug fix

* bug fix

* Minor Balancer changes from final review (#1819)

* Removed unused imports

* Generated updated contract diagram

---------

Co-authored-by: Nick Addison <[email protected]>
Co-authored-by: Shahul Hameed <[email protected]>
sparrowDom added a commit that referenced this pull request Sep 27, 2023
* initail commit

* intermediary commit

* commit research files

* balancer booster abi

* intermittent commit

* add base balancer contract that implements checkBalance functionality

* add some additional initial integration

* intermittent commit

* add deployment file

* add fork test fixture

* intermittent commit

* prettier

* add basic withdrawal / deposit functionality

* correct the BPT calculation

* prettier + lint

* simplify the BPT price calculation

* add read-only re-entrancy protection

* add some missing tests and adjust existing. Deparate deposit and withdrawal slippage

* fix check balance implementation

* Balancer review changes (#1726)

* Generated contract docs

* Refactor Balancer storage variables

* Small Balancer changes

* Natspec updates
Added missing licensing
getPoolAssets gas optimized

* Updated generated Balancer strategy contract diagrams

* fix contract linter

* Removed restrictions on tests

* Small gas improvements
Fixed Slither

* Change BalancerError version

* Updated constant names
Addresses to use checksum format

* JS lint tasks

* Updated Balancer and Aura pool id constants

* Removed getRateProviderRate as it wasn't being used
Refactored to remove poolAssetsMapped storage variable

* Updated OETH Contracts diagrams
Generated new Balancer contract diagrams

* Fix failing test

* Fix merge conflict

* Restored getRateProviderRate

* Natspec updates
Added toPoolAsset override

* Removed unused getRateProviderRate

* Natspec updates
Gas optimization of InitializableAbstractStrategy

* Abstract strategy gas improvements (#1719)

* Refactor base strategy to use immutables

* Fixed strategy deployments in 001_core and fixtures

* Generated new strategy diagrams

* Deploy rETH instead of the stETH Balancer MetaStable Pool

* removed unused Aura config

* Balancer fork tests

* Added check that BPT amount equals Aura LP amount
Added rETH conversion to ETH value

* Updated balancer strat fork tests

* Updated Balancer fork tests

* Added optional deposit with multiple assets to the strategy

* Single asset deposit to use multi asset deposit

* Added optional checkBalance to Balancer strategy

* Added checkBalance() to BaseBalancerStrategy

* Fix slither
Fix curve HH task

* Added multi-asset withdraw to balancer strategy

* Fix multi-asset withdraw

* Updated Balancer and Vault diagrams

* Fix js linter

* Fixed checkBalance of rETH asset in Balancer strategy

* Only wrap assets if amount > 0
Added depositAll fork test for Balancer strat

* Removed Vault changes for multi-asset strategy support

* Updated generated docs

* Add tests for wstETH/WETH Balancer pool (#1725)

* Split deployment and fix fixtures

* Deposit tests for wstETH/WETH pool

* Add withdraw test

* prettier

* remove .only in fork tests

---------

Co-authored-by: Shahul Hameed <[email protected]>

* [ DFD-1 ] Balancer's checkBalance (#1730)

* add alternative implementation of Balancer's checkBalance

* correct the checkBalance implementation

* Balancer fork tests (#1727)

* Added large withdraw tests for Balancer strategy

* fix test log

* Balancer withdraw to handle close to BPT limit

* Small change to Balancer withdraw fork test

* add some comments

* change implementation

---------

Co-authored-by: Domen Grabec <[email protected]>

* Add read-only reentrancy test (#1731)

* Added large withdraw tests for Balancer strategy

* fix test log

* Balancer withdraw to handle close to BPT limit

* Small change to Balancer withdraw fork test

* add some comments

* Add test for read-only reentrancy

* add reentrancy protection to checkBalance functions

* add documentation

* remove the only

---------

Co-authored-by: Nicholas Addison <[email protected]>
Co-authored-by: Domen Grabec <[email protected]>

* Balancer fixes (#1734)

* prettier

* adjust how checkBalance is calculated

* Balancer withdrawal fix (#1739)

* fix balancer withdrawals

* lint

* prettier

* use only 1 safeApprove when applicable

* some renames and more correct application of approves

* renames, additional requires, move initializer to a better location, slither

* bug fix

* Generated latest Balancer strategy diagrams

* re-deploy BPT tokens sitting in the strategy

* fix re-entrancy test

* fixture fix

* bug fix

* prettier

* L02 improve naming  (#1783)

* improve naming

* one more rename

* buf fix

* do a check that supported assets are being withdrawn (#1784)

* set uint256 max instead of magic number (#1782)

* remove unused files (#1785)

* fix renaming bug

* correct safe approve all tokens and adjust the documentation (#1776)

* prettier

* M04 - minBptFunction robustness (#1795)

* change bptExpected to ignore Oracle prices and assume assets are always pegged. (Vault value checker shall be used to mitigate issues with said assumption)

* fix all the tests

* add test for pool manipulation

* prettier & lint

* minor change

* add withdrawal test

* update documentation

* pick string error length that is smaller than 32 characters

* prettier

* correct comment

* better comments

* prettier

* M02 withdrawal fuzzing tests (#1801)

* add more withdrawal tests

* add more withdrawal cases

* N02 gas inefficiencies  (#1786)

* gas optimisation

* fix bad merge and prettier

* remove todo comments (#1796)

* use a more appropriate array initialisation length (#1800)

* more consistant function naming (#1797)

* fix typo (#1798)

* simplify the way we withdrawAll. no need to pass along min amonts (#1777)

* M03 - missing or misleading documentation (#1781)

* improve documentation

* add comma

* M01 More comprehensive test suite (#1780)

* add tests for approving tokens and harvesting rewards

* prettier and lint

* fix bad merge + prettier & lint

* fix fork tests remove .only

* remove only

* lint

* fix unit tests

* add more tests to see how checkBalance behaves

* remove console log

* improve checkBalance test by testing that checkBalance amount doesn't decrease after the attack comaring to the middle of the attack.

* confirm that yield gained by 3rd party tilting the pool can be extracted by withdrawing the funds

* rename internal functions by prepending them with underscore

* Generated latest Balancer strategy diagrams (#1805)

* bug fix

* bug fix

* Minor Balancer changes from final review (#1819)

* Removed unused imports

* Generated updated contract diagram

* Deploy Balancer Meta stable pool RETH strategy

* update deploy description

* fix typo

* add proposal Id to deploy script

* prettier

---------

Co-authored-by: Nick Addison <[email protected]>
Co-authored-by: Shahul Hameed <[email protected]>
sparrowDom added a commit that referenced this pull request Sep 27, 2023
* initail commit

* intermediary commit

* commit research files

* balancer booster abi

* intermittent commit

* add base balancer contract that implements checkBalance functionality

* add some additional initial integration

* intermittent commit

* add deployment file

* add fork test fixture

* intermittent commit

* prettier

* add basic withdrawal / deposit functionality

* correct the BPT calculation

* prettier + lint

* simplify the BPT price calculation

* add read-only re-entrancy protection

* add some missing tests and adjust existing. Deparate deposit and withdrawal slippage

* fix check balance implementation

* Balancer review changes (#1726)

* Generated contract docs

* Refactor Balancer storage variables

* Small Balancer changes

* Natspec updates
Added missing licensing
getPoolAssets gas optimized

* Updated generated Balancer strategy contract diagrams

* fix contract linter

* Removed restrictions on tests

* Small gas improvements
Fixed Slither

* Change BalancerError version

* Updated constant names
Addresses to use checksum format

* JS lint tasks

* Updated Balancer and Aura pool id constants

* Removed getRateProviderRate as it wasn't being used
Refactored to remove poolAssetsMapped storage variable

* Updated OETH Contracts diagrams
Generated new Balancer contract diagrams

* Fix failing test

* Fix merge conflict

* Restored getRateProviderRate

* Natspec updates
Added toPoolAsset override

* Removed unused getRateProviderRate

* Natspec updates
Gas optimization of InitializableAbstractStrategy

* Abstract strategy gas improvements (#1719)

* Refactor base strategy to use immutables

* Fixed strategy deployments in 001_core and fixtures

* Generated new strategy diagrams

* Deploy rETH instead of the stETH Balancer MetaStable Pool

* removed unused Aura config

* Balancer fork tests

* Added check that BPT amount equals Aura LP amount
Added rETH conversion to ETH value

* Updated balancer strat fork tests

* Updated Balancer fork tests

* Added optional deposit with multiple assets to the strategy

* Single asset deposit to use multi asset deposit

* Added optional checkBalance to Balancer strategy

* Added checkBalance() to BaseBalancerStrategy

* Fix slither
Fix curve HH task

* Added multi-asset withdraw to balancer strategy

* Fix multi-asset withdraw

* Updated Balancer and Vault diagrams

* Fix js linter

* Fixed checkBalance of rETH asset in Balancer strategy

* Only wrap assets if amount > 0
Added depositAll fork test for Balancer strat

* Removed Vault changes for multi-asset strategy support

* Updated generated docs

* Add tests for wstETH/WETH Balancer pool (#1725)

* Split deployment and fix fixtures

* Deposit tests for wstETH/WETH pool

* Add withdraw test

* prettier

* remove .only in fork tests

---------

Co-authored-by: Shahul Hameed <[email protected]>

* [ DFD-1 ] Balancer's checkBalance (#1730)

* add alternative implementation of Balancer's checkBalance

* correct the checkBalance implementation

* Balancer fork tests (#1727)

* Added large withdraw tests for Balancer strategy

* fix test log

* Balancer withdraw to handle close to BPT limit

* Small change to Balancer withdraw fork test

* add some comments

* change implementation

---------

Co-authored-by: Domen Grabec <[email protected]>

* Add read-only reentrancy test (#1731)

* Added large withdraw tests for Balancer strategy

* fix test log

* Balancer withdraw to handle close to BPT limit

* Small change to Balancer withdraw fork test

* add some comments

* Add test for read-only reentrancy

* add reentrancy protection to checkBalance functions

* add documentation

* remove the only

---------

Co-authored-by: Nicholas Addison <[email protected]>
Co-authored-by: Domen Grabec <[email protected]>

* Balancer fixes (#1734)

* prettier

* adjust how checkBalance is calculated

* Balancer withdrawal fix (#1739)

* fix balancer withdrawals

* lint

* prettier

* use only 1 safeApprove when applicable

* some renames and more correct application of approves

* renames, additional requires, move initializer to a better location, slither

* bug fix

* Generated latest Balancer strategy diagrams

* re-deploy BPT tokens sitting in the strategy

* fix re-entrancy test

* fixture fix

* bug fix

* prettier

* L02 improve naming  (#1783)

* improve naming

* one more rename

* buf fix

* do a check that supported assets are being withdrawn (#1784)

* set uint256 max instead of magic number (#1782)

* remove unused files (#1785)

* fix renaming bug

* correct safe approve all tokens and adjust the documentation (#1776)

* prettier

* M04 - minBptFunction robustness (#1795)

* change bptExpected to ignore Oracle prices and assume assets are always pegged. (Vault value checker shall be used to mitigate issues with said assumption)

* fix all the tests

* add test for pool manipulation

* prettier & lint

* minor change

* add withdrawal test

* update documentation

* pick string error length that is smaller than 32 characters

* prettier

* correct comment

* better comments

* prettier

* M02 withdrawal fuzzing tests (#1801)

* add more withdrawal tests

* add more withdrawal cases

* N02 gas inefficiencies  (#1786)

* gas optimisation

* fix bad merge and prettier

* remove todo comments (#1796)

* use a more appropriate array initialisation length (#1800)

* more consistant function naming (#1797)

* fix typo (#1798)

* simplify the way we withdrawAll. no need to pass along min amonts (#1777)

* M03 - missing or misleading documentation (#1781)

* improve documentation

* add comma

* M01 More comprehensive test suite (#1780)

* add tests for approving tokens and harvesting rewards

* prettier and lint

* fix bad merge + prettier & lint

* fix fork tests remove .only

* remove only

* lint

* fix unit tests

* add more tests to see how checkBalance behaves

* remove console log

* improve checkBalance test by testing that checkBalance amount doesn't decrease after the attack comaring to the middle of the attack.

* confirm that yield gained by 3rd party tilting the pool can be extracted by withdrawing the funds

* rename internal functions by prepending them with underscore

* Generated latest Balancer strategy diagrams (#1805)

* bug fix

* bug fix

* Minor Balancer changes from final review (#1819)

* Removed unused imports

* Generated updated contract diagram

* Deploy Balancer Meta stable pool RETH strategy

* update deploy description

* fix typo

* add proposal Id to deploy script

* prettier

* create a deploy file

* file rename

* improve wording

* fix name redundancy

---------

Co-authored-by: Nick Addison <[email protected]>
Co-authored-by: Shahul Hameed <[email protected]>
sparrowDom added a commit that referenced this pull request Oct 3, 2023
* initail commit

* intermediary commit

* commit research files

* balancer booster abi

* intermittent commit

* add base balancer contract that implements checkBalance functionality

* add some additional initial integration

* intermittent commit

* add deployment file

* add fork test fixture

* intermittent commit

* prettier

* add basic withdrawal / deposit functionality

* correct the BPT calculation

* prettier + lint

* simplify the BPT price calculation

* add read-only re-entrancy protection

* add some missing tests and adjust existing. Deparate deposit and withdrawal slippage

* fix check balance implementation

* Balancer review changes (#1726)

* Generated contract docs

* Refactor Balancer storage variables

* Small Balancer changes

* Natspec updates
Added missing licensing
getPoolAssets gas optimized

* Updated generated Balancer strategy contract diagrams

* fix contract linter

* Removed restrictions on tests

* Small gas improvements
Fixed Slither

* Change BalancerError version

* Updated constant names
Addresses to use checksum format

* JS lint tasks

* Updated Balancer and Aura pool id constants

* Removed getRateProviderRate as it wasn't being used
Refactored to remove poolAssetsMapped storage variable

* Updated OETH Contracts diagrams
Generated new Balancer contract diagrams

* Fix failing test

* Fix merge conflict

* Restored getRateProviderRate

* Natspec updates
Added toPoolAsset override

* Removed unused getRateProviderRate

* Natspec updates
Gas optimization of InitializableAbstractStrategy

* Abstract strategy gas improvements (#1719)

* Refactor base strategy to use immutables

* Fixed strategy deployments in 001_core and fixtures

* Generated new strategy diagrams

* Deploy rETH instead of the stETH Balancer MetaStable Pool

* removed unused Aura config

* Balancer fork tests

* Added check that BPT amount equals Aura LP amount
Added rETH conversion to ETH value

* Updated balancer strat fork tests

* Updated Balancer fork tests

* Added optional deposit with multiple assets to the strategy

* Single asset deposit to use multi asset deposit

* Added optional checkBalance to Balancer strategy

* Added checkBalance() to BaseBalancerStrategy

* Fix slither
Fix curve HH task

* Added multi-asset withdraw to balancer strategy

* Fix multi-asset withdraw

* Updated Balancer and Vault diagrams

* Fix js linter

* Fixed checkBalance of rETH asset in Balancer strategy

* Only wrap assets if amount > 0
Added depositAll fork test for Balancer strat

* Removed Vault changes for multi-asset strategy support

* Updated generated docs

* Add tests for wstETH/WETH Balancer pool (#1725)

* Split deployment and fix fixtures

* Deposit tests for wstETH/WETH pool

* Add withdraw test

* prettier

* remove .only in fork tests

---------

Co-authored-by: Shahul Hameed <[email protected]>

* [ DFD-1 ] Balancer's checkBalance (#1730)

* add alternative implementation of Balancer's checkBalance

* correct the checkBalance implementation

* Balancer fork tests (#1727)

* Added large withdraw tests for Balancer strategy

* fix test log

* Balancer withdraw to handle close to BPT limit

* Small change to Balancer withdraw fork test

* add some comments

* change implementation

---------

Co-authored-by: Domen Grabec <[email protected]>

* Add read-only reentrancy test (#1731)

* Added large withdraw tests for Balancer strategy

* fix test log

* Balancer withdraw to handle close to BPT limit

* Small change to Balancer withdraw fork test

* add some comments

* Add test for read-only reentrancy

* add reentrancy protection to checkBalance functions

* add documentation

* remove the only

---------

Co-authored-by: Nicholas Addison <[email protected]>
Co-authored-by: Domen Grabec <[email protected]>

* Balancer fixes (#1734)

* prettier

* adjust how checkBalance is calculated

* Balancer withdrawal fix (#1739)

* fix balancer withdrawals

* lint

* prettier

* use only 1 safeApprove when applicable

* some renames and more correct application of approves

* renames, additional requires, move initializer to a better location, slither

* bug fix

* Generated latest Balancer strategy diagrams

* re-deploy BPT tokens sitting in the strategy

* fix re-entrancy test

* fixture fix

* bug fix

* prettier

* L02 improve naming  (#1783)

* improve naming

* one more rename

* buf fix

* do a check that supported assets are being withdrawn (#1784)

* set uint256 max instead of magic number (#1782)

* remove unused files (#1785)

* fix renaming bug

* correct safe approve all tokens and adjust the documentation (#1776)

* prettier

* M04 - minBptFunction robustness (#1795)

* change bptExpected to ignore Oracle prices and assume assets are always pegged. (Vault value checker shall be used to mitigate issues with said assumption)

* fix all the tests

* add test for pool manipulation

* prettier & lint

* minor change

* add withdrawal test

* update documentation

* pick string error length that is smaller than 32 characters

* prettier

* correct comment

* better comments

* prettier

* M02 withdrawal fuzzing tests (#1801)

* add more withdrawal tests

* add more withdrawal cases

* N02 gas inefficiencies  (#1786)

* gas optimisation

* fix bad merge and prettier

* remove todo comments (#1796)

* use a more appropriate array initialisation length (#1800)

* more consistant function naming (#1797)

* fix typo (#1798)

* simplify the way we withdrawAll. no need to pass along min amonts (#1777)

* M03 - missing or misleading documentation (#1781)

* improve documentation

* add comma

* M01 More comprehensive test suite (#1780)

* add tests for approving tokens and harvesting rewards

* prettier and lint

* fix bad merge + prettier & lint

* fix fork tests remove .only

* remove only

* lint

* fix unit tests

* add more tests to see how checkBalance behaves

* remove console log

* improve checkBalance test by testing that checkBalance amount doesn't decrease after the attack comaring to the middle of the attack.

* confirm that yield gained by 3rd party tilting the pool can be extracted by withdrawing the funds

* rename internal functions by prepending them with underscore

* Generated latest Balancer strategy diagrams (#1805)

* bug fix

* bug fix

* Minor Balancer changes from final review (#1819)

* Removed unused imports

* Generated updated contract diagram

* Deploy Balancer Meta stable pool RETH strategy

* update deploy description

* fix typo

* add proposal Id to deploy script

* prettier

* create a deploy file

* file rename

* improve wording

* fix name redundancy

* re-deploy Balancer rETH/WETH strategy

* add proposal id

* improve deploy proposal wording

* update proposal id

* Prettify

---------

Co-authored-by: Nick Addison <[email protected]>
Co-authored-by: Shahul Hameed <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contracts Works related to contracts OETH OETH related things OUSD OUSD releated things
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants