Git Product home page Git Product logo

rebase-contracts's Introduction

Rebase Spec

Rebase is a staking protocol deployed on Base. Rebase gives holders of ERC-20 assets a safe, new way to put them to work across an emerging set of new apps and protocols powered by staking and restaking.

Staking and Restaking

Rebase enables you to stake your assets once (in Rebase), then restake them across a number of different apps and protocols. For instance, builders can build an app that issues a new token to users staking $DEGEN over time. The app can use the Rebase protocol for staking so that users can trust their assets are staked safely.

Neither the Rebase team nor the restaking apps ever control your funds: only you can withdraw staked assets from Rebase, and you can do so at any time.

Each token has corresponding reToken ERC-20 automatically deployed by Rebase. When you stake an ERC-20s on Rebase, you receive a corresponding amount that token's reTokens. In order to unstake, stakers need to hold the corresponding amount of reTokens in their wallet, which get subsequently burned.

Users can stake their tokens, obtain reTokens, and do various actions with those reTokens. Some use cases include:

  • Trading reTokens (liquidity)
  • Storing reTokens in a cold wallet (security)
  • Locking reTokens for additional functionality (eg $DEGEN tipping)

Write APIs

There are three main write methods when interacting with Rebase:


stake(address token, uint quantity, address app)

Stake quantity units of token into the Rebase contract. Restake those same tokens into app. Reverts if restaking fails. Transfer approval must be granted to the Rebase contract prior to calling this function. User received quantity units of reTokens, representing their staked assets.


stakeETH(address app)

Same implementation as stake; the contract converts sent ETH to WETH first.


unstake(address token, uint quantity, app)

Unstakes quantity of token token and transfers them back to the user. Unrestakes those same tokens from app. Proceeds even if unrestaking fails. The user must have quantity corresponding reTokens in their wallet. Remove the token from the user's app-stake-list if entire stake is unstaked. Remove the app from the user's app-list if no tokens are staked in app.

Read APIs

getApps(address user)

Returns an address[] array of apps the user currently has tokens staked in on Rebase.

getApp(address user, uint index)

Returns the address of the indexth app that the user currently has tokens staked in on Rebase.

getNumApps(address user)

Returns a uint of the total number of different apps the user has staked tokens in on Rebase.

getStake(address user, address app, address token)

Returns a uint quantity of token the user has staked in app on Rebase.

getTokensAndStakes(address user, address app)

Returns an (address[], uint[]) pair of tokens and stakes that the user has staked in app on Rebase.

getTokenAndStake(address user, address app, uint index)

Returns a pair (address, uint) of the indexth token and stake that the user has staked in app on Rebase.

getNumTokenStakes(address user, address app)

Returns a uint of the total number of different tokens the user has staked in app on Rebase.

getTokenReToken(address token)

Returns the reToken address for token.

Tests

Tests for the Rebase contract are written using Foundry.

Setup

forge install foundry-rs/forge-std
forge install OpenZeppelin/openzeppelin-foundry-upgrades
forge install OpenZeppelin/[email protected]
forge install OpenZeppelin/[email protected]

Build

$ forge build

Test

$ forge test

Format

$ forge fmt

Gas Snapshots

$ forge snapshot

Anvil

$ anvil

Deploy

$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>

Cast

$ cast <subcommand>

Help

$ forge --help
$ anvil --help
$ cast --help

rebase-contracts's People

Contributors

chejazi avatar

Watchers

 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.