feat: {Bounty Submission} Gearbox PoolServiceERC4626Wrapper and PoolServiceERC4626Factory#43
Open
tushargargght wants to merge 5 commits intoGearbox-protocol:mainfrom
Open
feat: {Bounty Submission} Gearbox PoolServiceERC4626Wrapper and PoolServiceERC4626Factory#43tushargargght wants to merge 5 commits intoGearbox-protocol:mainfrom
tushargargght wants to merge 5 commits intoGearbox-protocol:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bounty site: https://erc4626.info/
Bounty Spec: https://superform.notion.site/Gearbox-4626-Spec-0de0a498b171417e805759c896137bec
ERC 4626 spec: https://eips.ethereum.org/EIPS/eip-4626
Contracts Created
ERC4626Safe: ERC4626 implementation derived from solmate's ERC4626 with added prevention against Loss of precision vulnerabilityPoolServiceERC4626:ERC4626Safederived PoolService which is ERC4626 wrapper aroundPoolServicePoolERC4626Factory:PoolService4626 Wrapper factoryDesign Decisions
ERC4626Safe.constructor()mints100000shares toaddress(0)to protect against 'loss of precision' vulnerability. 100000 is a common acceptable amount notably used by UniswapAnother option could be to mint some shares to the wrapper contract itself.
convertToAssets(), convertToShares(), previewMint(), and previewWithdraw()modified to usetotalAssets()instead oftotalSupply()as totalSupply can never be zero because of DesignDecision-1.PoolServiceERC4626.totalAssets()andPoolServiceERC4626.beforeWithdraw()rounds Up the amount by 1 to account forfromDiesel()round down and adhere to ERC-4626 specTesting
run
yarn installto install the latest dependenciesCreate
.envfile in the root directory withand run
forge test --match-path contracts\test\pool\PoolServiceERC4626.t.solto fork-test thePoolERC4626FactoryandPoolServiceERC4626forWETH, WSTETH, USDC, DAI, and WBTCpoolsDeployment-Testing
DeployPoolServiceERC4626.s.solcontains the script to deploy all five Pool Services 4626 Wrapper as requested in specFor testing in the anvil mainnet fork
run
anvil --fork-url $MAINNET_RPC_URLand copy the first private key and paste into the.envfile so that the file looks likerun
forge script contracts/test/pool/script/DeployPoolServiceERC4626.s.sol:DeployPoolService4626Script --fork-url http://localhost:8545 --broadcast