Code Monkey home page Code Monkey logo

metavaults's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

metavaults's Issues

Move metavaults packages to public npm

Now that the metavaults repo is public, the packages can also be moved to a npm.
This applies for both the server-side and frontend packages published from the metavaults repository.

This should include changing the Defender repo to use the new public npm package.

Upgrade 3CRV Convex Meta Vault contract

The upgrade includes the following changes

  1. Fixed charging the performance to store assets per share with newly minted fee shares included for the next performance period.
  2. assets per share updated after removeVault.
  • Deploy new PeriodicAllocationPerfFeeMetaVault contract
  • Check no change to storage slots between implementation contracts
  • Check code differences between deployed implementation contracts
  • Raise Protocol DAO to upgrade the 3CRV Convex Meta Vault proxy contract 0x9614a4C61E45575b56c7e0251f63DCDe797d93C5
  • Execute Protocol DAO to upgrade the proxy
  • Update Immunefi contract list

`LiquidatorStreamAbstractVault` contract issues

  • There's a bug in calculating the amount of shares to burn when a transactions happens after the stream end time.
  • The preview functions do not account for the shares that will be burnt up to the current time. eg previewMint will under report how many assets are required when shares are being streamed after a liquidation.
  • The unit tests are missing a lot of functional coverage.

issue/scenario testing for metaVaults

Finding and implementing missing scenarios/tests for integration

Missing Scenarios

  • #68
  • update assetsPerShare in _afterAddVault hook for PeriodicAllocationAbstractVault
  • Create behavior for PerfFeesAbstractVault
  • PerdiodicAllocationPerfFeesMetaVault update assetsPerShare in following
    • after Rebalance
    • after settle
    • after charge Performmance fees
    • after removeVault
  • use PerfFeeAbstractVault behavior in PerdiodicAllocationPerfFeesMetaVault

Scenario analysis remaining for Convex3CrvLiquidatorVault

Reduce `donate` token gas costs

Problem

Donating small amounts of DAI back to the mUSD, FRAX and BUSD vaults is very expensive. For example, it cost 3,264,357 gas (70 USD) to donate 63 DAI back to the mUSD, FRAX and BUSD vaults. https://etherscan.io/tx/0xfb0042c2425a27f4705fc76b1810be015c2d4bf43565f5e3c66a1c78255c054a

Normally this will be held back until there is a significant reward but last week we ran through the liquidation cycle for testing purposes. It's also worth considering that if rewards are not streaming then the APY will close to 0.

Proposed solution

The donate function will convert DAI/USDC/USDT to 3Crv using the 3Pool, but will not add liquidity to the Curve Metapool and deposit the Metapool LP token to the Convex pool. This will be delayed until the next mint or deposit.

The 3Crv can sit in the vault but have no impact on the assets per share. This is effectively an unrealised gain like accrued rewards.

The next time a mint or deposit is done, it will check if the vault has a 3Crv balance. This balance will be added to the mint/deposit 3Crv that is added to the Metapool and LP deposited to the Convex pool. The resulting shares will be proportionally split between the minter/depositor and the vault. The existing streaming process will then work to burn the vault shares over the next week.

issue/sourceAssets for PeriodicAllocationAbstractVault

Issue: totalUnderlyingAssets < requiredAssets will lead to significant less assets returned to user in redeem call for PeriodicAllocationAbstractVault

Code changes for PR:

  • Added require check for enough assets available for redeem
  • Gas optimization by removing redundant _convertToAssets call for mint/redeem
  • Added test coverage for assetsWithdrawn > vaultBalance for redeem

Liquidator - Unable to retry CRV async swaps

Describe the bug
Liquidator is unable to re-try CRV async swaps, as CRV reverts while increasing the allowance when previous allowance is not zero

IERC20(rewardToken).safeIncreaseAllowance(address(asyncSwapper), rewards);

CRV Approve Token has the following restrictions :

   @notice Approve `_spender` to transfer `_value` tokens on behalf of `msg.sender`
    @dev Approval may only be from zero -> nonzero or from nonzero -> zero in order
        to mitigate the potential race condition described here:
        https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729

File and line
A link to the line containing the bug.

To Reproduce
Steps to reproduce the behavior:

  1. Invoke Liquidator.initiateSwap with rewardToken as CRV when the transfer flag is false
  2. Via hardhat task it would be
yarn task liq-init-swap --from CRV --to DAI --transfer false 
  1. Invoke again initiateSwap with rewardToken as CRV when the transfer flag is false or true.
    The transaction is reverted.

Expected behavior
As the process is async , it cannot be guaranteed that initiateSwap will be sucessful all the time , so it should be possible to re-try a swap order .

OneInch Dex Swapper

Is your feature request related to a problem? Please describe.
The implementation of the OneInch Dex swapper is not fully implemented, only the smart contract is done.
Things to do :

  • Hard hat task to get quotes
  • Hard hat task to trigger a swap via the liquidator
  • Utility function to calculate the enconded data sent to the swap function
  • Fork Test (liquidator via sync swaps)
  • Clean up unit test

Add visual diagram of the SingleSlotMapper structure

the data structure of the SingleSlotMapper can be complicated to understand as it uses bit operations against a single uint256 storage slot to map 62 index numbers to 4 bit values.

Adding a diagram of the structure to the README will help developers understand how this works.

Add removeIndex to SingleSlotMapper

SameAssetUnderlyingsAbstractVault.removeVault currently calls SingleSlotMapper.removeValue with the removedValue parameter being the index of the _activeUnderlyingVaults array.

It would be more gas efficient if SameAssetUnderlyingsAbstractVault.removeVault called a new SingleSlotMapper.removeIndex function padding in the vaultIndex that is passed to the SameAssetUnderlyingsAbstractVault.removeVault function.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.