Joey
    • 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 No publishing access yet

      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.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      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
    • Make a copy
    • 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 Make a copy 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 No publishing access yet

    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.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    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
    # Turbo Docs Tribe Turbo is an innovative mechanism for issuing stablecoins and earning yield. * [Announcement](https://medium.com/fei-protocol/the-tribe-dao-strongly-believes-that-a-healthy-and-thriving-defi-ecosystem-needs-a-robust-platform-b1faea700dfa) * [Audit Guide](https://hackmd.io/rYfLz--qTnW_4Ays5FL6zQ) * [Code](https://github.com/fei-protocol/tribe-turbo) * [Dili audit](https://consensys.net/diligence/audits/private/3wmfeucqds486i/) - password: `W|@Izw;e56` * [Code4rena Findings](https://github.com/code-423n4/2022-02-tribe-turbo-findings) This guide contains docs for turbo consumers, keepers, DAO Operators, and interface developers. # Turbo User Guide From a user perspective, Turbo is basically a wrapper (Safe) around a collaeralized Fuse lending position. The borrowed asset is FEI at 0% APR, and that FEI is then resupplied to earn yield into ERC-4626 strategies. Definitions: * [Fuse](https://v2.rari.capital/fuse) - a lending market platform where users can supply collateral and borrow any supported asset with liquidity. * Turbo Safe - an ERC-4626 Vault which can boost FEI and share revenue. Safe's have a single collateral but can support many yield strategies. * [ERC-4626](https://eips.ethereum.org/EIPS/eip-4626) - a new standard for Tokenized Vaults. It represents a strategy which is itself also tokenized. Supported collateral types and yield strategies need to be added by Tribe Governance. Initial Collaterals: * TRIBE * BAL * gOHM Initial yield strategies * Fuse FEI from approved pools Users of Turbo become joint issuers of FEI with the Tribe DAO, deciding which markets to supply newly minted FEI to and splitting the revenue. They generally want one or both of: 1. additional yield on tokens 2. Liquidity on FEI in a specific market Revenue splits are calculated as follows: 1. If the Safe has a custom revenue split set by governance, use that. 2. If the Collateral associated with the Safe has a custom revenue split, use that 3. Use the default revenue split. Safes are created with a default access control which allows the creator (user), router, and savior to access the safe. The router allows the user to perform multiple actions at once. The Savior allows any EOA to delever the vault when it exceeds a safe collateralization threshold. See advanced operations for how to override this access control. ## Basic Operations Turbo users can perform the following basic actions on their Safes: ### Deposit/Withdraw Add and remove collateral which can be used to boost or improve borrowing health factor. This is always denominated in a single token per Safe e.g. TRIBE or BAL. These follow the ERC-4626 interface and include mint/redeem as well. ### Boost/Less ``` /// @notice Borrow Fei from the Turbo Fuse Pool and deposit it into an authorized Vault. /// @param vault The Vault to deposit the borrowed Fei into. /// @param feiAmount The amount of Fei to borrow and supply into the Vault. function boost(ERC4626 vault, uint256 feiAmount) external ``` Boosting is borrowing FEI and depositing it into a yield strategy. ``` /// @notice Withdraw Fei from a deposited Vault and use it to repay debt in the Turbo Fuse Pool. /// @param vault The Vault to withdraw the Fei from. /// @param feiAmount The amount of Fei to withdraw from the Vault and repay in the Turbo Fuse Pool. function less(ERC4626 vault, uint256 feiAmount) external; ``` Lessing is the inverse of boosting. Note that Tribe governance can less any Safe at any time to contract the FEI supply. This would be a matter of monetary policy to protect the FEI peg in the event of a demand shock. ### Slurp/Sweep ``` /// @notice Accrue any interest earned by the Safe in the Vault. /// @param vault The Vault to accrue interest from, if any. /// @dev Sends a portion of the interest to the Master, as determined by the Clerk. function slurp(ERC4626 vault) external; ``` Slurp - accrues fees earned on the FEI yield strategies on the safe. This operation is done per safe. The Tribe governance share of the revenue split FEI is sent there. The Safe owner's share is withdrawn to the Safe where it can then be swept. NOTE Tribe Governance can slurp on a Safe at any time to claim its fees. ``` /// @notice Claim tokens sitting idly in the Safe. /// @param to The recipient of the sweeped tokens. /// @param token The token to sweep and send. /// @param amount The amount of the token to sweep. function sweep( address to, ERC20 token, uint256 amount ) external; ``` Sweep - withdraw fei accrued as interest or other tokens laying idle in a safe. To get FEI interest into the Safe, first less the entire balance. ([TODO](https://linear.app/fei/issue/DEV-2678/add-skim-to-turbo) consider adding a skim method to free up surplus FEI). ## Risks The risks of using Turbo are similar to a normal lending market, with some risks reduced and other unique Turbo-specific risks. There are two different types of risks to the Safe holder, collateral risk and yield strategy risk. ### Collateral Risk A collateral can be liquidated like a normal Fuse position. If this happens, all FEI debt would be repayed by the safe. This means the boosted amount becomes equity which the Safe holder can sweep. In other words, liquidation effectively means the user's collateral was force sold into the FEI yield strategies the Safe is holding. The revenue split will continue to apply to all interest. ### Yield Strategy Risk The yield strategy where FEI is deployed may become insolvent due to bad debt or some kind of vulnerability. Because the vault can no longer "less", the Turbo Safe begins to incur the risk of this bad debt. If the vault holder cannot repay, Tribe Governance can repay and sieze the collateral using the `gib` operation. ## Advanced Operations Safe holders can expose the basic operations to smart contracts or other users according to arbitrary logic by replacing the Safe's [Authority](https://github.com/Rari-Capital/solmate/blob/main/src/auth/Auth.sol) This would remove the Router and Savior's access unless it is re-granted in the new authority. Only replace the Authority if you are sure you know what you are doing, this operation can risk the user's collateral if done incorrectly. # Keepers Guide ## Savior The [Turbo Savior](https://github.com/fei-protocol/tribe-turbo/blob/main/src/modules/TurboSavior.sol) is an optional module which is included by default. It allows any EOA to deleverage a vault by calling `less` on any boosted strategy once the Safe hits 80% of its credit line (customizeable by governance, call `minDebtPercentageForSaving` to check). To save a vault, call ``` /// @notice Save a Safe (call less on owner's behalf to prevent liquidation). /// @param safe The Safe to be saved. /// @param vault The Vault to less from. /// @param feiAmount The amount of Fei to less from the Safe. function save( TurboSafe safe, ERC4626 vault, uint256 feiAmount ) external ``` and input the desired safe, vault, and fei amount. If the vault is over the 80%, it will be lessed by the input amount. ## Liquidator Liquidations on the turbo pool will use a custom liquidator, the [B Protocol BAMM](https://github.com/backstop-protocol/dev/blob/ctoken_as_backstop/packages/contracts/contracts/B.Protocol/BAMM.sol): To liquidate call ```function liquidateBorrow(address borrower, uint amount, ICToken collateral) external returns (uint)``` The borrower is the Safe and the collateral is the underlying asset of the Safe. Note: the code above currently holds cTokens not underlyings but this will be changed before it is implemented. TODO: Liquidator bots for this. # DAO Operators ## Adding new collaterals 1. `TurboAdmin.addCollateral()` 2. `TurboBooster.setBoostCapForCollateral()` 3. (Optional) `TurboClerk.setCustomFeePercentageForCollateral()` ## Adding new strategies 1. `TurboBooster.setBoostCapForVault()` ## Setting custom Safe revenue split 1. `TurboClerk.setCustomFeePercentageForSafe()` ## Executing Gibber 1. `TurboAdmin.schedule(gibber, abi.encodeWithSignature("impoundAll(address,address)",safe,to))`. Use https://ethtx.info/ to read tx data and save the salt. 2. Wait 15 day timelock 3. `TurboAdmin.execute(gibber,abi.encodeWithSignature("impoundAll(address,address)",safe,to), salt)` (get salt from tx data of 1.) ## Access Control Summary These are the roles which are in Tribe Turbo, their powers, and their default owners. ### GIBBER_ROLE HIGH CLEARANCE. capable of calling `gib` to impound collateral. Powers: * `TurboSafe.gib` Owners: * gibber ### ROUTER_ROLE HIGH CLEARANCE. Optional module which can interact with any user's vault by default. The router itself replicates access control so that other users can't interact Powers: * `TurboSafe.boost` * `TurboSafe.less` * `TurboSafe.slurp` * `TurboSafe.sweep` * `TurboSafe.deposit` * `TurboSafe.mint` * `TurboSafe.withdraw` * `TurboSafe.redeem` Owners: * router ### SAVIOR_ROLE Capable of lessing any vault. Exposed on optional TurboSavior module. Powers: * `TurboSafe.less` Owners: * savior ### TURBO_ADMIN_ROLE Operational admin of Turbo, can whitelist collaterals, strategies, and configure most parameters. Powers: * `TurboSafe.slurp` * `TurboSafe.less` * `TurboMaster.createSafe` * `TurboMaster.setBooster` * `TurboMaster.setDefaultSafeAuthority` * `TurboMaster.sweep` * `TurboClerk.setDefaultFeePercentage` * `TurboClerk.setCustomFeePercentageForCollateral` * `TurboClerk.setCustomFeePercentageForSafe` * `TurboBooster.setFreezeStatus` * `TurboBooster.setBoostCapForVault` * `TurboBooster.setBoostCapForCollateral` * `TurboSavior.setMinDebtPercentageForSaving` * `TurboAdmin._setMarketSupplyCaps` * `TurboAdmin._setMarketSupplyCapsByUnderlying` * `TurboAdmin._setMarketBorrowCaps` * `TurboAdmin._setMarketBorrowCapsByUnderlying` * `TurboAdmin._setMintPausedByUnderlying` * `TurboAdmin._setMintPaused` * `TurboAdmin._setBorrowPaused` * `TurboAdmin._setBorrowPausedByUnderlying` * `TurboAdmin.oracleAdd` * `TurboAdmin.addCollateral` * `TurboAdmin._deployMarket` * `TurboAdmin._addRewardsDistributor` * `TurboAdmin._setCloseFactor` * `TurboAdmin._setCollateralFactor` * `TurboAdmin._setLiquidationIncentive` * `TurboAdmin.schedule` Owners: * fei dao timelock * turbo pod if [FIP-82](https://tribe.fei.money/t/fip-82-governance-enhancements/3945/23) passes * master * admin ### GUARDIAN_ROLE Pause and security Guardian role. Powers: * `TurboSafe.less` * `TurboBooster.setFreezeStatus` * `TurboAdmin._setMarketSupplyCaps` * `TurboAdmin._setMarketSupplyCapsByUnderlying` * `TurboAdmin._setMarketBorrowCaps` * `TurboAdmin._setMarketBorrowCapsByUnderlying` * `TurboAdmin._setMintPausedByUnderlying` * `TurboAdmin._setMintPaused` * `TurboAdmin._setBorrowPaused` * `TurboAdmin._setBorrowPausedByUnderlying` * `TurboAdmin._setTransferPaused` * `TurboAdmin._setSeizePaused` Owners: * Tribe Security Guardian ### GOVERN_ROLE HIGH CLEARANCE. Capable of critical governance functionality on TurboAdmin such as oracle upgrades. Powers: * `TurboAdmin._setBorrowCapGuardian` * `TurboAdmin._setPauseGuardian` * `TurboAdmin.oracleChangeAdmin` * `TurboAdmin._setWhitelistEnforcement` * `TurboAdmin._setPriceOracle` * `TurboAdmin._setMintPaused` * `TurboAdmin._unsupportMarket` * `TurboAdmin._toggleAutoImplementations` * `TurboAdmin.scheduleSetPendingAdmin` * `TurboAdmin.schedule` * `TurboAdmin.cancel` Owners: * Fei DAO Timelock ### TURBO_STRATEGIST_ROLE Limited version of TURBO_ADMIN_ROLE which can manage collateral and vault parameters. Powers: * `TurboBooster.setBoostCapForVault` * `TurboBooster.setBoostCapForCollateral` * `TurboAdmin._setMarketSupplyCaps` * `TurboAdmin._setMarketSupplyCapsByUnderlying` * `TurboAdmin.addCollateral` Owners: * None initially # Interface Developent Docs ## ENS The tribe is the proud owner of `turbo.eth`. As such, important turbo contracts will be given an ens subdomain. TODO assign the ENS's `router.turbo.eth` - TurboRouter.sol `master.turbo.eth` - TurboMaster.sol `authority.turbo.eth` - default authority `timelock.turbo.eth` - Turbo Timelock `comptroller.turbo.eth` - Turbo Fuse Pool Comptroller `gibber.turbo.eth` - Turbo Gibber `booster.turbo.eth` - Turbo Booster `clerk.turbo.eth` - Turbo Clerk `savior.turbo.eth` - Turbo Savior `admin.turbo.eth` - TurboAdmin ## Turbo Router The Turbo Router allows users to perform multiple operations simultaneously using a multicall. The user must approve the router before interacting, this can be done atomically with an EIP-2612 permit using [SelfPermit](https://github.com/fei-protocol/ERC4626/blob/main/src/external/SelfPermit.sol). The router must have approved the Turbo Safe as well. This is done atomically in createSafeAndDeposit. [TODO](https://linear.app/fei/issue/DEV-2682/add-approvals-and-skim-to-router) fix approval bug. https://github.com/fei-protocol/tribe-turbo/issues/72 [PeripheryPayments](https://github.com/fei-protocol/ERC4626/blob/main/src/external/PeripheryPayments.sol) is used to pull in tokens for deposits, wrap/unwrap weth, or withdraw accrued fees and collateral. Common user flows: 1. "open position" Deposit + Boost 2. "accrue" Slurp all (all boosted safes) 3. "close vault" Slurp all + less + sweep + withdraw 4. "change strategy" Less + boost ## Turbo Lens struct StrategyInfo { /// @notice the fei strategy boosted by the safe ERC4626 strategy; /// @notice the amount of fei boosted by the safe to this strategy uint256 boostedAmount; /// @notice the amount of fei held by the safe in this strategy uint256 feiAmount; } struct SafeInfo { /// @notice the safe collateral ERC20 collateralAsset; /// @notice the balance of collateral assets held by the safe uint256 collateralAmount; /// @notice the collateral value of assets uint256 collateralValue; /// @notice the FEI debt held by safe uint256 debtAmount; /// @notice the value of FEI deby held by safe uint256 debtValue; /// @notice the total FEI boosted value uint256 boostedAmount; /// @notice the total amount of FEI held by all strategies in the Safe uint256 feiAmount; /// @notice fee split to TRIBE dao scaled by 1e18 uint256 tribeDAOFee; StrategyInfo[] strategyInfo; } function getAllUserSafes(address owner) external returns (SafeInfo[] memory) function getSafeInfo(TurboSafe safe) external returns(SafeInfo memory) User FEI owed = (boostedAmount - debtAmount) + ((feiAmount - boostedAmount) * (1 - fee split to tribe dao)) + fei.balanceOf(safe) Boosting cap for (safe,strategy): min(fei.balanceOf(fFEI), booster.getBoostCapForVault(strategy) - master.getTotalBoostedForVault(strategy), booster.getBoostCapForCollateral(safe.asset()) - master.getTotalBoostedAgainstCollateral(safe.asset())) Deployment steps: PR: https://github.com/fei-protocol/tribe-turbo/pull/80 After cloning tribe-turbo and running devnet on http://127.0.0.1:8545/ 1. git checkout feat/setup 2. sh scripts/setup.sh Output contains something like: master=0xd1328acdc70a9f4bb0aeccd1defc3e2bdfb209e6 router=0xdef5f531fbbd6122519899c8954caaeb05bd38d4 lens=0xefcf95fe6b297fe43ffd357145d94b25b2929d6b strategy=0x358307ad592d4577b9a2afc4681830ee017c7ccd booster=0x31249a4408b09d9af21dc3b5e92d81728d66b57b clerk=0xb1920e0fd2cf2402528118121727c7f9d1400c7a comptroller=0x07f01026738f35f0e0855a81335360e3d7d587d0 Can use these contracts to completely locally test UI.

    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
    Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    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