-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add Zapper for LidoARM #31
Conversation
src/contracts/ZapperLidoARM.sol
Outdated
IWETH public immutable weth; | ||
ILidoARM public immutable lidoArm; | ||
|
||
event Zap(address indexed sender, uint256 shares); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should also include the amount of ETH (assets) deposited
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've pushed the change to add the amount of assets (WETH) deposited
src/contracts/Interfaces.sol
Outdated
@@ -255,3 +255,8 @@ interface IStETHWithdrawal { | |||
function getWithdrawalRequests(address _owner) external view returns (uint256[] memory requestsIds); | |||
function getLastRequestId() external view returns (uint256); | |||
} | |||
|
|||
interface ILidoARM { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a ILiquidityProviderARM interface that already has deposit. We can extend IERC20 so we also get transfer.
import {IERC20} from "./Interfaces.sol"; | ||
import {ILidoARM} from "./Interfaces.sol"; | ||
|
||
contract ZapperLidoARM is Ownable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need the Zapper to be Ownable
. I see that is used for rescueERC20
but there shouldn't be any tokens in this contract. I see the OETH Zapper doesn't have this.
If we do want the Zapper to be Ownerable, we need to decide who the owner should be. Options are:
- 5/8 multisig
- Strategist 2/9 multisig
- ARM Defender Relayer
My preference would be the Strategist
@DanielVF what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I completely agree, it was just in case someone mistakenly send token to it (like people sending wETH to wETH contract).
I have no problem removing it.
However if we want to keep it, I think Strategist or Relayer is enough.
* WIP MultiLP * forge install: openzeppelin-contracts v5.0.2 * WIP * forge install: openzeppelin-contracts-upgradeable v5.0.2 * WIP redeem queue * PeggedARM now support one sided and double sided trades Made the AbstractARM more generic Improved OETH ARM tests * Added Lido ARM * Added Lido ARM fork tests * Added a Multi LP version of the Lido ARM * Updated diagrams * Added convertToShares and convertToAssets to MultiLP Added donation attack protection to MultiLP * Added performance fee to MultiLP * Changed implementation of the performance fee * Add support for multiple tranches * Added admin functions to update tranche prices and allocations * Generated latest diagrams * Add _claimHook to add liquidity back * Added AccessControlLP Made it clear the deposit and withdraw hooks are post function * Added AccessControlShares * Split performance fee logic into PerformanceFee contract Moved calc of perf fee to LP deposit and withdraw instead of swaps * Fixed saving of new total assets to after asset transfers * Natspec updates * Generated new contract diagrams * Added _gap in inherited contracts * Changed timestamp that was storing the request time in WithdrawalRequest to claimTimestamp Fixed compilation of contracts using PerformanceFee * Refactor PerformanceFee Renamed liquidityToken to liquidityAsset Renamed _assetsInWithdrawalQueue to _externalWithdrawQueue * Generated latest contract diagrams * Fixed OETH ARM fork tests * Refactor MultiPriceARM Started LidoMultiPriceMultiLpARM fork test * Updated contract diagrams * Fixes to MultiPriceARM * More LidoMultiPriceMultiLpARM fork tests * Added whitelist controls to LidoFixedPriceMultiLpARM Started LidoFixedPriceMultiLpARM fork tests * Updated Natspec * Generated latest contract code * Removed minimumFunds logic for LP version * Fix Napspec * changed setLiquidityProviderCaps to bulk set lp caps Removed increasing the LP's cap on withdrawals * Added LiquidityProviderCap event when decrementing the lp cap * Moved the Liquidity Provider Controller out of the ARM * Refactor test structure (#16) * refactor test structur. * feat: adjust tests for liquidityProviderController. * forge fmt * feat: add asOwner modifier * bump forge version. * feat: use random address. * Switch from gitmodules to Soldeer. (#17) * chore: switch from gitmodules to soldeer. * chore: update Makefile. * try to fix CI * chore: use rpc_endpoints for forking. * Added Lido ARM deploy script * Changed the Lido ARM owner to be the mainnet 5/8 multisig * Anyone can now call collectFees * Updated README * Added operator to LiquidityProviderController which will be a Defender Relayer * Add test for Swaps in LidoFixedPriceMultiLpARM.sol. (#18) * fix: rename `lidoARM` in `lidoFixedPriceMulltiLpARM` for tests. * feat: add badToken. * [WIP] test: add tests for `SwapExactTokensForTokens`. * test: finalize `swapExactTokensForTokens()`. * chore: set fuzz runs in config. * fix: transfer to address dead steth when dealing 0. * test: add tests for `swapTokensForExactTokens()`. * fix: adjust `swapExactTokensForTokens()` tests. * Refactor setPrices for FixedPriceARM * Renamed MAX_FEE to FEE_SCALE * Removed old Make upgrade actions * Changed the _gap's so each contract uses 50 slots * Updated Lido ARM deploy script * Updated deploy script * Added postDeploy Hardhat task * Merge latest tests (#19) * [WIP] test: add reverting test for `deposit()`. * fix: update `lastTotalAssets` before checking caps. * [WIP] test: add more test for deposit. * fix: cleanup tests. * test: add failing test. * test: add failling test. --------- Co-authored-by: Clément <[email protected]> * Added address of ARMBuyback * Moved initializing lastTotalAssets to _initPerformanceFee * Moved burn of shares down in requestRedeem * Fixed applying the performance fee twice on deposits * fix: increase global queued amount when requestRedeem. * [WIP] test: add tests for `requestRedeem()`. * Fixed applying the performance fee twice on deposits * test: add tests for `requestRedeem()` when ARM profit/loss. * Updated deposit assertions * Fix requestRedeem which now stored the updated queued amount * Updated deploy script * Added Lido smoke test that uses the deploy script * Removed experimentation code * generated contract docs * Add more tests. (#21) * chore: add coverage files to gitignore. * test: add tests for claimRedeem and TotalAssets. * test: add more tests for setters. * forge fmt * Deposit now adds to the withdrawal queue Added test of deposit with outstanding withdrawal request * Changed requestRedeem to use convertToAssets instead of previewRedeem * Add more tests. (#22) * test: add more test for `totalAssets()`. * feat: add modifiers to simulate gain or loss assets in ARM. * fix: use boolean instead of int256. * fix: use Foundry stdError lib for expectRevert. * test: add setter test for LCP. * chore: fix lcov name in .gitignore * test: add tests for collectFees(). * Fix performance fee calc not removing new perf fee from lastTotalAssets * Write to storage once in requestStETHWithdrawalForETH * Changed the preview functions to be external now that are no longer being used internally * Generated latest contract diagram * Added more detail to the invalid token error * Fix compile warning in test * Ensure swaps don't use withdrawal queue liquidity (#23) * Ensure swaps don't use WETH reserved for the withdrawal queue * Fund the withdrawal queue when WETH is swapped into the ARM * More refactoring of MultiLP deposit and swap not longer add to the withdrawal queue. Its only need on claim * Refactor withdrawal queue storage to optimize swap gas usage * Generated latest contract diagrams * Removed _postClaimHook as it's no longer needed * Added more Natspec * Add more Natspec * Changed the _postWithdrawHook to _postRequestRedeemHook * Generated latest contract diagrams * Minor change to constructor param * Don't allow prices to cross 1 * Bring in the latest tests (#24) * test: add test for requestStETHWithdrawamForETH. * chore: use last version of forge for `mockFunction()`. * feat: create a fake Lido Withdraw to mock it when testing. * [WIP] test: add test for `claimStETHWithdrawalForWETH()`. * fix: tests for claimWithdrawals. * fix: typo on variable name. --------- Co-authored-by: Clément <[email protected]> * Flatten the LidoARM inheritance (#25) * Flatten LidoARM's inheritance * Renamed LidoARM contract * Changed to LidoARM name in tests * Generated new contract diagrams * Minor changes to the LidoARM * Renamed lidoARM variable in tests * Updated deposit test comments * Updated setPrice tests * Small change to setPrices test * test: add extra tests for deposit while lido withdraw. * test: add extra test for swap with withdrawQueue full. * Added switch to LiquidityProviderController so the account level caps can be disabled * Changed setAccountCapEnabled to only be called by Owner * fix: use approx eq for steth balance. * Added accountCapEnabled tests * fix: use approx eq for steth balance (again). * More setter tests * Added setTotalAssetsCap tests * Added setLiquidityProviderCaps tests * Updated assertions of initial deploy * Generated latest contract diagrams * feat: return true when running test against tenderly testnet. * Added parseDeployedAddress * Updated postDeploy Hardhat task * WIP Broadcast fork section of deploy script * Added liquidity provider Hardhat tasks * Fixed setting of token0 and token1 in LidoARM (#27) * Restore deploy script so fork section uses prank * Fix hardhat postDeploy task * Added HH task to snap Lido ARM * Add Hardhat tasks snapLido, swapLido, submitLido Renamed the depositLido task * Added Deposit event LidoARM was setting token0 and token1 the wrong way around Used PRICE_SCALE in setPrices Improved smoke tests * Generated latest LidoARM contract diagram * Handler Tenderly testnet (#26) * fix: handler better tenderly testnet * fix: use -unlocked keywork to broadcast & impersonate * feat: add initial deployer test address. * fix: give enough gas to deployer for Tenderly test. --------- Co-authored-by: Nicholas Addison <[email protected]> * Fixed ARM acronym in Natspec * Removed postDeploy Hardhat task now the forge script is working * Simplified deposit to WETH * Fixed deploy script when run as a fork * Removed approveStETH as its in the initializer * changes to setPrices to make it easier to understand * Fix bug in _rawTotalAssets not checking feesAccrued before subtraction * Renamed total assets to available assets (#28) * Renamed _rawTotalAssets to _availableAssets Renamed lastTotalAssets to lastAvailableAssets * Generated new LidoARM diagrams * Update Natspec * Added Lido contract dependency diagram * Added Hardhat tasks requestRedeemLido and claimRedeemLido * Adjust lastAvailableAssets post deposit and redeem so lastAvailableAssets is up only * Reordered the storage slots for fee variables * Save gas on WETH balanceOf call on swaps of WETH out if no outstanding withdrawals * Only accrued fees when they are collected (#30) * Only accrue fees when the fees are collected * packed fee and lastAvailableAssets back into a single slot * Generated latest LidoARM contract diagram * Simplification of claimRedeem * Generated latest LidoARM contract diagram * Aligned the storage slot gap * Changed isClaimable to claimable * Limit performance fee to 50% * Fixed visibility of fee functions * Natspec update * Return 0 on early exit * emit at end of the function * Collapsed LidoLiquidityManager into LidoARM * Fixed claimRedeem tests with new event order * Removed LidoLiquidityManager as it's now in LidoARM * Generated latest contract diagrams * Clean up _availableAssets * cleanup claimRedeem * Renamed LiquidityProviderController to CapManager * Renamed outstandingEther to lidoWithdrawalQueueAmount * Updated contract diagram * Updated _transferAsset to use seth * simplified _transferAsset * Fixed collectFees so it doesn't use WETH reserved for the withdrawal queue * changed _liquidityAvailable to _requireLiquidityAvailable * Limited prices to crossing 2 basis point past 1.0 * Changed so buy price has to be below 1 * Increases initial total cap * Made claim delay immutable and only 1 minute for Testnet * Generate latest LidoARM diagram * Add Zapper for LidoARM (#31) * feat: create Zapper contract. * test: add tests for Zapper. * test: add extra test for rescue tokens. * Added assets (ETH) to Zapper's Zap event * Added ZapperLidoARM to deploy script * Updated deploy script for Testnet --------- Co-authored-by: Nicholas Addison <[email protected]> * updated snapLido Hardhat task * Added collectFees Hardhat task * Update Natspec * Updated contract diagrams * Added crossPrice to check when Operator sets prices * Set cross price in fork section fo deploy script * Safety check in setCrossPrice so no stETH in ARM when cross price reduced * Allow the cross price to be 20 basis points below 1 * totalAssets returns MIN_TOTAL_SUPPLY if fees > available assets setPrice enforcement of crossPrice also applies to Owner to ensure no asset losses remove old Price cross check as that's replaced by the crossPrice check * Generated latest LidoARM contract diagram * Updated Natspec * Now pricing the base assets, stETH, using the crossPrice * fix: make proxy falback payable. * Price stETH in the withdrawal queue at 1.0 as it can't be sold for any less * Fixed when fees = available assets in totalAssets * Natspec updates * Add Zap compliant with Liquidity Provider Cap (#32) * feat: add zap to deposit. * Updated Natspec --------- Co-authored-by: Nicholas Addison <[email protected]> * Generated latest contract diagrams * standardizes deal in smoke tests * Renamed request and claim Lido withdrawals * Natspec update * More info to snapLido Hardhat task * Added requestLidoWithdrawals, lidoClaimWithdraw and lidoWithdrawStatus Hardhat tasks * Added setZap to deploy script * depositLido now supports depositing ETH using the Zapper Added setZapper Hardhat task * fix deploy script * Added more logs to the deploy script * Made claimable external as it's not used internally * Renamed withdrawalQueue to lidoWithdrawalQueue so its not confused with the ARM withdrawal queue * Updated contract dependency diagram * Removed te extra logic that transfers and extra 2 wei for stETH * snapLido now compares against 1Inch, Curve and Uniswap * Change Zap integration in ARM. (#33) * fix: remove zap restricted method.. * style: change liquidity provider param name. * fix: change state then write call. * fix: state change then transfer token. * fix: use `fees` instead of `fee` when collecting fees. * fix: move up `nextWithdrawalIndex` increase. * fix: avoid code duplication. * fix: pack variable action (read & write). * Added gas costs to lidoSnap * Added RequestLidoWithdrawals and ClaimLidoWithdrawals events * put nextWithdrawalIndex into its own slot * Updated comments for setCrossPrice * Clearer setPrices comments Fixed comment typos * Generated latest LidoARM contract diagrams * Pre launch changes (#34) * Set buy and sell prices in initialize function setCrossPrice also validates buy and sell prices against the new cross price * fix: use `newCrossPrice` instead of `crossPrice`. * fix: use `<=` instead of `<` for `setCrossPrice`. * test: add reverting test for `setCrossPrice`. * fix: revert commit `a7947f3`. * fix: move `setCrossPrice` test to new file. * test: add more test for `setCrossPrice`. * feat: allow anyone to call claimLidoWithdrawals. * fix: adjust failing test * fix: remove testing stuff. --------- Co-authored-by: Clément <[email protected]> --------- Co-authored-by: Clément <[email protected]> Co-authored-by: Clément <[email protected]> Co-authored-by: Daniel Von Fange <[email protected]>
General
Zapper to deposit liquidity in ARM with raw ETH instead of wETH in a single transaction.
Constraint for
claimRedeem
At the moment, as only the msg.sender can be the withdrawer, it is not possible for the zapper to withdraw for someone and then unwrap wETH for ETH.