HackMD
  • Prime
    Prime  Full-text search on all paid plans
    Search anywhere and reach everything in a Workspace with Prime plan.
    Got it
      • Create new note
      • Create a note from template
    • Prime  Full-text search on all paid plans
      Prime  Full-text search on all paid plans
      Search anywhere and reach everything in a Workspace with Prime plan.
      Got it
      • Sharing Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • 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
      • More (Comment, Invitee)
      • Publishing
        Everyone on the web can find and read all notes of this public team.
        After the note is published, everyone on the web can find and read this note.
        See all published notes on profile page.
      • Commenting Enable
        Disabled Forbidden Owners Signed-in users Everyone
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
        • Everyone
      • Invitee
      • No invitee
      • Options
      • Versions and GitHub Sync
      • Transfer ownership
      • Delete this note
      • Template
      • Save as template
      • Insert from template
      • Export
      • Dropbox
      • Google Drive
      • Gist
      • Import
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
      • Download
      • Markdown
      • HTML
      • Raw HTML
    Menu Sharing Create Help
    Create Create new note Create a note from template
    Menu
    Options
    Versions and GitHub Sync Transfer ownership Delete this note
    Export
    Dropbox Google Drive Gist
    Import
    Dropbox Google Drive Gist Clipboard
    Download
    Markdown HTML Raw HTML
    Back
    Sharing
    Sharing Link copied
    /edit
    View mode
    • Edit mode
    • View mode
    • Book mode
    • Slide mode
    Edit mode View mode Book mode Slide mode
    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
    More (Comment, Invitee)
    Publishing
    Everyone on the web can find and read all notes of this public team.
    After the note is published, everyone on the web can find and read this note.
    See all published notes on profile page.
    More (Comment, Invitee)
    Commenting Enable
    Disabled Forbidden Owners Signed-in users Everyone
    Permission
    Owners
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Invitee
    No invitee
       owned this note    owned this note      
    Published Linked with GitHub
    Like BookmarkBookmarked
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    ### 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

    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 lost their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template is not available.


    Upgrade

    All
    • All
    • Team
    No template found.

    Create custom template


    Upgrade

    Delete template

    Do you really want to delete this template?

    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

    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

    Tutorials

    Book Mode Tutorial

    Slide Mode Tutorial

    YAML Metadata

    Contacts

    Facebook

    Twitter

    Feedback

    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

    Versions and GitHub Sync

    Sign in to link this note to GitHub Learn more
    This note is not linked with GitHub Learn more
     
    Add badge Pull Push GitHub Link Settings
    Upgrade now

    Version named by    

    More Less
    • Edit
    • Delete

    Note content is identical to the latest version.
    Compare with
      Choose a version
      No search result
      Version not found

    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. Learn more

         Sign in to GitHub

        HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.

        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
        Available push count

        Upgrade

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Upgrade

        Danger Zone

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

        Syncing

        Push failed

        Push successfully