Ryan Miller
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    ### Description of Strategy This strategy has been designed using one of the highest TVL strategies from Yearn Finance: [Generic-Lender](https://github.com/Grandthrax/yearnV2-generic-lender-strat). This strategy uses a lender-agnostic approach to optimize the routing of new deposits withdraws across an arbitrary number of lending platforms according to best-APY. This is done by using "plug-in" contracts which map the various platform APIs back to the common Generic Lender strategy API (shown in the diagram below). Although RAI only exists on limited lending platforms today, there are pre-written plugins that exist for the following lending platforms that can be leveraged immediately if RAI were to be added: - Compound - Aave - Fuse - Alpha Homora - Cream - DyDx This codebase has been both reviewed and formally audited, and is utilized on just about every production v2 vault that Yearn has. ![](https://i.imgur.com/P0qyI8e.png) #### Generic Lender Overview and Key Advantages The Generic Lender strategy contract is designed to allow a vault to lend funds to multiple lending platforms and autobalances in order to achieve the best APY. This strategy offers a highly omptimized, gas efficient methodology for allowing RAI holders to maximize the yield on their assets over time. Whenever the `harvest` function is called (e.g. once daily), depending on the conditions of the vault, funds may be added to the strategy or removed from the strategy. In both cases, the Generic Lender optimizes which lenders to remove or add funds to. It does this by cycling through the available lenders and rebalance by: 1. Identifying the lowest yielding platform and determining the amount that should be withdrawn from that platform 2. Identifying the highest yielding platform and determining the amount that should be deposited into it Importantly, the expected yield on the platform that is being deposited is calculated _post-deposit_ ensuring that if large deposits are being made, the strategy is properly accounting for any downward pressure on yields that this could create. If ever necessary, a function is made available to authorized users to define a custom allocation across available lenders, effectively overriding the strategy's default behavior. Similar to how we optimize allocation of inbound funds, there are efficiencies realized on outbound funds. Whenever a user calls `withdraw`, the strategy will similarly cycle through the various platforms and identify the lowest yielding one and selectively withdraw funds from that one. If not enough funds are available from the lowest yielding platform to fulfill the withdrawal, the process repeats. The net effect of these features is that every time funds are deposited, they are allocated to the highest yielding option, and when funds are withdrawn they are withdrawn from the lowest yielding option. This results in the overall vault APY increasing each time a user withdraws from the vault. One additional feature of this strategy is that it implements `tend` function that identifies whether the yield gains of rebalancing outweight gas costs. There is also a `tendTrigger` function which automates this decision and signals to keepers when it makes sense to call `tend`. # RAI Strategy ## Links - [Gitcoin Bounty](https://gitcoin.co/issue/reflexer-labs/geb-safe-saviours/3/100025561) ### Code resources - [GenLender](https://github.com/Grandthrax/yearnV2-generic-lender-strat/blob/master/contracts/Strategy.sol) - Sam's generic lender strategy - [Generic Cream](https://etherscan.io/address/0xC53a7A7bEB51141b750b2752cD1276150a511daa#code) - [Generic DyDx](https://etherscan.io/address/0xed2F20ACbb4809BB2F62da75cbE3A0Df557d955E#code) - [Brownie-strategy-mix](https://github.com/yearn/brownie-strategy-mix) - This is the template used to begin work on a strategy. Comes with basic dependencies and tests. - [Yearn BaseStrategy](https://github.com/yearn/yearn-vaults/blob/master/contracts/BaseStrategy.sol) - Reference for BaseStrategy, which is inhereited by all strategiest - [Yearn Vault.vy](https://github.com/yearn/yearn-vaults/blob/master/contracts/Vault.vy) - Reference for how the vault works - [Deployment Process](https://github.com/yearn/yearn-vaults/tree/master/docs) - Use this when it comes time to deploy ## Write Up - Price per share on deposit/withdraw #### Platform-Specific Plugins The plugin contracts allow our Generic Lender to inferface with lending platforms. For the purposes of this submission, plugins for Cream and Fuse have been implemented. A major benefit of the approach taken is that adding new lending platforms such as Aave or Compound can be easily achieved, plugins can be updated as needed and also removed if they are no longer desired. ## Questions - Strategist rewards on live vault - Funding for keepers - Expectation that this goes live on Yearn.finance - Expected APY + expected deposits - Any guidance/preference on post-save CRatio (if user is liquidated for being <145%, we need to assign a value to how much debt should be repaid by the keeper) - Is Compound out of scope? Is there already existing saviour for this. - How should tests be delivered? Preferred testing suite? Yearn strategy - Kovan requirement... requires FUSE/Cream/Yearn - Will standard Yearn 2/20 fee structure be used ## To-do list - [ ] Genlender strategy study - How the optimization works - Any shortcomings to highlight? - - [ ] Fully integrated test in brownie - [ ] Test saviour using Stefan tests - [ ] Write-up - make the case for our submission - flow diagram with Yearn vault management? # Write up outline ### How the strategy works - -

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully