Giter VIP home page Giter VIP logo

flywheel-v2's Introduction

Flywheel v2

Flywheel is a suite of open source token incentives and governance infrastructure using modern and modular solidity patterns to easily interface with other platforms.

It is built by the Tribe DAO using Foundry and Solmate.

Flywheel is completely on-chain and composable, for maximum compatibility with smart contract systems.

Coming Soon

  • xERC4626 - single sided staking
  • ERC20Gauges/FlywheelGaugeRewards - allow token holders to direct rewards
  • ERC20MultiVotes - GovernorBravo voting with multi-delegation capabilities

Overview

Flywheel has two major components, the core incentives engine (including a suite of rewards modules and boosters) and ERC20 token utilities (xERC4626, ERC20MultiVotes, ERC20Gauges).

Production examples of the incentives engine:

  • fuse-flywheel used to reward depositors to Fuse lending markets.

FlywheelCore Incentives Engine

The incentives engine is used to reward users for holding tokens in strategies. This can be as simple as vanilla liquidity mining or involve complex vote-escrow and boosting mechanics. Some common strategies include:

The core incentives engine supports a single reward token, and multiple reward tokens can easily be supported by adding multiple flywheels.

The rewards accrue to each strategy via a rewards module. By default, the rewards are distributed pro rata to users holding the strategy over time, but this can be transformed via a booster module.

Rewards Module

The rewards module determines how many tokens go to each strategy over time. Assume a single constant or variable reward stream of tokens which needs to be divided amongst all the strategies.

The rewards can be divided according to any algorithm, some examples:

  • constant reward stream per second/block
  • proportional according to weights. Weights could be determined via liquid governance like Curve gauges.
  • dynamically pass through rewards from an upstream plugin. For example passing through convex or balancer rewards to stakers. Convex Fuse Pool example.

Boosting Module

Normally, rewards for users are calulated by dividing the user's balanceOf on the strategy divided by the totalSupply of the strategy.

However, some strategies require additional logic to boost or otherwise transform the user's balance. This is where the boosting module can do just that. If added to the incentives engine, it calculates a users rewards by dividing their boosted balance by the bosoted total supply.

ERC20 Token Utilities

Coming Soon

Adding Flywheel to Your Smart Contracts

To add flywheel to a forge compatible repository, simply run:

forge install fei-protocol/flywheel-v2

Alternatively, fork the flywheel-v2 repository to build directly using the repo.

Flywheel Core

The FlywheelCore contract maintains all reward amounts for all user,strategy pairs. In order to have fully accurate accounting, the flywheel core needs to be updated every time the composition of the strategy changes. When the strategy is an ERC-20 or ERC-4626, this means that on mint/burn/transfer the accrue function needs to be called atomically for all affected users.

Example: on Fuse the flywheelPre* hooks.

FlywheelRewards Modules

The flywheel rewards needs to approve rewardToken to the FlywheelCore contract so that when users claim their rewards can be transferred from the rewards module to the user. The flywheelRewards must then eventually hold custody over all claimable tokens.

Every time flywheelCore calls getAccruedRewards(), the returned amount needs to be added to (or already held by) the flywheel rewards module.

flywheel-v2's People

Contributors

joeysantoro avatar kryptoklob avatar sriyantra avatar

Stargazers

 avatar

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.