Skip to content

0xduality/lava-staking

Repository files navigation

LAVA staking concept

The staking contract here implements revenue sharing among stakers of an asset. The stake of each staker is determined both by the amount of tokens they are staking as well as the amount of time they have been staking. The latter provides a bonus stake that accrues at 100% APR of the token stake. Depositing 100 tokens means a stake of 100 immediately, 200 after one year, 300 after two years and so on... Unstaking at any time, returns the original tokens to the staker and burns the bonus stake.

Revenue is distributed as WAVAX from the balance of the caller of distribute.

Users can compound their stake, add more tokens, and claim any rewards with deposit.

Users can unstake and receive any final rewards with withdrawAll.

Prerequisites

NodeJS and Yarn

First, install the LTS (long-term support) version of nodejs. This is 14.17.0 at the time of writing. NodeJS bundles npm.

Next, install yarn:

npm install -g yarn

Solidity and Avalanche

It is also helpful to have a basic understanding of Solidity and Avalanche.

Dependencies

Clone the repository and install the necessary packages via yarn.

$ yarn

Hardhat Config

Hardhat uses hardhat.config.js as the configuration file. You can define tasks, networks, compilers and more in that file. For more information see here.

In our repository we use a pre-configured file hardhat.config.ts. This file configures necessary network information to provide smooth interaction with Avalanche. There are also some pre-defined private keys for testing on a local test network.

Hardhat Tasks

You can define custom hardhat tasks in hardhat.config.ts

Documentation

There is a documentation under the Avalanche's official documentation repository: Using Hardhat with the Avalanche C-Chain

Running the tests

It's a bit of an unconventional setup to have Hardhat with Python tests. You need to have web3, requests, and tabulate packages installed; all of them can be installed via pip install.

Start a Hardhat fork of mainnet (the tests use the WAVAX contract address from mainnet):

$ npx hardhat node 

On another terminal deploy the contracts on the fork

$ npx hardhat run ./scripts/deploy.ts --network localhost

After the contracts are deployed run the python tests

$ python test/lava-staking-tests.py

About

staking contract concept

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published