feat: {Bounty Submission} Gearbox PoolServiceERC4626Wrapper and PoolServiceERC4626Factory #43
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
:ERC4626Safe
derived PoolService which is ERC4626 wrapper aroundPoolService
PoolERC4626Factory
:PoolService
4626 Wrapper factoryDesign Decisions
ERC4626Safe.constructor()
mints100000
shares 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 install
to install the latest dependenciesCreate
.env
file in the root directory withand run
forge test --match-path contracts\test\pool\PoolServiceERC4626.t.sol
to fork-test thePoolERC4626Factory
andPoolServiceERC4626
forWETH, WSTETH, USDC, DAI, and WBTC
poolsDeployment-Testing
DeployPoolServiceERC4626.s.sol
contains 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_URL
and copy the first private key and paste into the.env
file so that the file looks likerun
forge script contracts/test/pool/script/DeployPoolServiceERC4626.s.sol:DeployPoolService4626Script --fork-url http://localhost:8545 --broadcast