Skip to main content

AStaking

Overview​

License: MIT​

abstract contract AStaking is AValueDistributor, Initializable

The Staking module

Contract module for staking tokens and earning rewards based on shares.

Structs info​

AStakingStorage​

struct AStakingStorage {
address sharesToken;
address rewardsToken;
uint256 rate;
uint256 stakingStartTime;
}

Errors info​

RewardsTokenIsZeroAddress​

error RewardsTokenIsZeroAddress()

SharesTokenIsZeroAddress​

error SharesTokenIsZeroAddress()

StakingHasNotStarted​

error StakingHasNotStarted(uint256 currentTimestamp, uint256 stakingStartTime)

Modifiers info​

stakingStarted​

modifier stakingStarted()

Throws if the staking has not started yet.

Functions info​

stake (0xa694fc3a)​

function stake(uint256 amount_) public stakingStarted

Stakes the specified amount of tokens.

Parameters:

NameTypeDescription
amount_uint256The amount of tokens to stake.

unstake (0x2e17de78)​

function unstake(uint256 amount_) public stakingStarted

Unstakes the specified amount of tokens.

Parameters:

NameTypeDescription
amount_uint256The amount of tokens to unstake.

claim (0x379607f5)​

function claim(uint256 amount_) public stakingStarted

Claims the specified amount of rewards.

Parameters:

NameTypeDescription
amount_uint256The amount of rewards to claim.

claimAll (0xd1058e59)​

function claimAll() public stakingStarted returns (uint256)

Claims all the available rewards.

Return values:

NameTypeDescription
[0]uint256The total value of the rewards claimed.

withdraw (0x3ccfd60b)​

function withdraw()
public
stakingStarted
returns (uint256 shares_, uint256 owedValue_)

Withdraws all the staked tokens together with rewards.

Note: All the rewards are claimed after the shares are removed.

Return values:

NameTypeDescription
shares_uint256The amount of shares being withdrawn.
owedValue_uint256The total value of the rewards owed to the user.

sharesToken (0x8009ba1f)​

function sharesToken() public view returns (address)

Returns the shares token.

Return values:

NameTypeDescription
[0]addressThe address of the shares token contract.

rewardsToken (0xd1af0c7d)​

function rewardsToken() public view returns (address)

Returns the rewards token.

Return values:

NameTypeDescription
[0]addressThe address of the rewards token contract.

stakingStartTime (0x6abfd183)​

function stakingStartTime() public view returns (uint256)

Returns the staking start time.

Return values:

NameTypeDescription
[0]uint256The timestamp when staking starts.

rate (0x2c4e722e)​

function rate() public view returns (uint256)

Returns the rate of rewards distribution.

Return values:

NameTypeDescription
[0]uint256The rate of rewards distribution per second.