Skip to content

t0mcr8se/fuse-liquid-staking

Repository files navigation

Fuse Liquid Staking Pool - Hardhat Project

Overview

This repository contains the Fuse Liquid Staking Pool smart contract, an upgradeable implementation that allows users to stake Fuse tokens and receive liquid staking tokens in return. The protocol automatically delegates stakes to validators and distributes staking rewards.

Features

  • Liquid Staking: Users can stake Fuse tokens and receive liquid staking tokens representing their share of the staking pool.
  • Validator Management: The protocol supports multiple validators with automatic stake distribution.
  • Upgradeable: The contract uses UUPS (Universal Upgradeable Proxy Standard) for future upgrades.
  • Reward Distribution: Staking rewards are automatically compounded and distributed to token holders.
  • Protocol Fees: A configurable fee on staking rewards supports protocol development.
  • Safety Features: Includes staking limits, pause functionality, and reentrancy protection.

Contract Details

Key Functions

  • deposit(): Stake Fuse tokens and receive liquid staking tokens
  • withdraw(): Exchange liquid staking tokens for staked Fuse tokens
  • update(): Claim and restake rewards, update exchange rate
  • addValidator()/removeValidator(): Manage validator list (owner only)
  • setSystemStakeLimit(): Configure protocol staking limits (owner only)
  • changeProtocolFeeBasis(): Adjust protocol fee percentage (owner only)

Events

The contract emits events for key operations including:

  • Deposits and withdrawals
  • Validator management
  • Protocol fee distribution
  • System parameter changes
  • Pause/unpause operations

Development

Prerequisites

  • Node.js
  • Yarn or npm
  • Hardhat

Installation

  1. Clone the repository
  2. Install dependencies:
    yarn install

Testing

Run the test suite:

yarn test

Deployment

Configure your deployment parameters in hardhat.config.js and run:

yarn hardhat deploy

Usage

After deployment, users can interact with the contract through:

  1. Depositing Fuse tokens via the deposit() function or fallback
  2. Withdrawing by calling withdraw() with the amount of liquid tokens
  3. Managing validators and protocol parameters (owner only)

Security

The contract includes several security features:

  • Reentrancy protection
  • Upgradeability controlled by owner
  • Pause functionality
  • Input validation
  • SafeMath operations

Note

The Liquid Staking Pool was a customized fork of JinFinance contracts, comprehensive tests and deployments were added

License

MIT License - See SPDX identifier in contract source.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •