$RARE Curation Staking

IRareStakingRegistry

Git Source

Author: SuperRare Labs, koloz

The Staking Registry interface containing all functions, events, etc.

Functions

increaseAmountStaked

Increase amount staked when a user stakes.

function increaseAmountStaked(address _staker, address _stakedOn, uint256 _amount) external;

Parameters

decreaseAmountStaked

Decrease the amount staked when a user unstakes.

function decreaseAmountStaked(address _staker, address _stakedOn, uint256 _amount) external;

Parameters

setStakingAddresses

Set staking addresses for a target.

function setStakingAddresses(address _user, address _stakingAddress, address _rewardSwapAddress) external;

Parameters

setDefaultPayee

Set the default payee.

function setDefaultPayee(address _payee) external;

Parameters

setDiscountPercentage

Set the reward swap discount percentage.

function setDiscountPercentage(uint256 _percentage) external;

Parameters

setDeflationaryPercentage

Set the unstake deflationary percentage.

function setDeflationaryPercentage(uint256 _percentage) external;

Parameters

setPeriodLength

Set the round period length time.

function setPeriodLength(uint256 _periodLength) external;

Parameters

setReverseRegistrar

Set the ENS reverse registrar address.

function setReverseRegistrar(address _reverseRegistrar) external;

Parameters

setResolver

Set the ENS resolver address.

function setResolver(address _resolver) external;

Parameters

setSwapPool

Set the uniswap pool address for the given ERC20 token.

function setSwapPool(address _uniswapPool, address _token) external;

Parameters

setStakeePercentage

Set stakee percentage.

function setStakeePercentage(uint256 _stakeePercentage) external;

Parameters

setClaimerPercentage

Set claimer percentage.

function setClaimerPercentage(uint256 _claimerPercentage) external;

Parameters

transferRareTo

Pools to transfer $RARE tokens, usually into pools. This is so users only need to approve the registry when staking or performing reward swaps.

function transferRareTo(address _from, address _to, uint256 _amount) external;

Parameters

getDefaultPayee

Get the address for sending rewards if there are no stakers.

function getDefaultPayee() external view returns (address);

Returns

getSwapPool

Get the swap pool address for the ERC20 token.

function getSwapPool(address _token) external view returns (address);

Returns

getRareAddress

Retrieve the address of $RARE.

function getRareAddress() external view returns (address);

Returns

getWethAddress

Retrieve the address of Wrapped Ethereum.

function getWethAddress() external view returns (address);

Returns

getDiscountPercentage

Get reward swap discount percentage.

function getDiscountPercentage() external view returns (uint256);

Returns

getDeflationaryPercentage

Get the unstake deflationary percentage.

function getDeflationaryPercentage() external view returns (uint256);

Returns

getStakeePercentage

Get the stakee percentage.

function getStakeePercentage(address _user) external view returns (uint256);

Parameters

Returns

getClaimerPercentage

Get the claimer percentage.

function getClaimerPercentage(address _user) external view returns (uint256);

Parameters

Returns

getPeriodLength

Get the round period length.

function getPeriodLength() external view returns (uint256);

Returns

getStakingInfoForUser

Retrieves the staking info for a given user.

function getStakingInfoForUser(address _user) external view returns (Info memory);

Parameters

Returns

getTotalAmountStakedByUser

Retrieves the total amount of rare staked by a given user.

function getTotalAmountStakedByUser(address _user) external view returns (uint256);

Parameters

Returns

getTotalAmountStakedOnUser

Retrieves the total amount of rare being staked on a given user.

function getTotalAmountStakedOnUser(address _user) external view returns (uint256);

Parameters

Returns

getAllStakingContracts

Retrieves a list of all the ERC20 staking contracts.

function getAllStakingContracts() external view returns (address[] memory);

Returns

getAllStakers

Retrieves a list of all the users participating in staking.

function getAllStakers() external view returns (address[] memory);

Returns

getAllStakedOn

Retrieves a list of all the users being staked on.

function getAllStakedOn() external view returns (address[] memory);

Returns

getUsersForStakingAddresses

Query the users for the following staking addresseses.

function getUsersForStakingAddresses(address[] calldata _stakingAddrs) external view returns (address[] memory);

Parameters

STAKING_INFO_SETTER_ROLE

Bytes32 representation of the role used for setting the staking address of a user.

function STAKING_INFO_SETTER_ROLE() external view returns (bytes32);

Returns

STAKING_STAT_SETTER_ADMIN_ROLE

Bytes32 representation of the admin role for granting the ability to set amount staked for a single user/total amount staked on a user.

function STAKING_STAT_SETTER_ADMIN_ROLE() external view returns (bytes32);

Returns

STAKING_STAT_SETTER_ROLE

Bytes32 representation of the role used for updating the amount being staked on a user/amount a user is staking globally.

function STAKING_STAT_SETTER_ROLE() external view returns (bytes32);

Returns

STAKING_CONFIG_SETTER_ROLE

Bytes32 representation of the role used for period length, deflationary percentages, and the default payee.

function STAKING_CONFIG_SETTER_ROLE() external view returns (bytes32);

Returns

ENS_SETTER_ROLE

Bytes32 representation of the role used for updating the ENS resolvers.

function ENS_SETTER_ROLE() external view returns (bytes32);

Returns

SWAP_POOL_SETTER_ROLE

Bytes32 representation of the role used for updating uniswap pools.

function SWAP_POOL_SETTER_ROLE() external view returns (bytes32);

Returns

Events

StakeePercentageUpdated

Emitted via {setStakeePercentage} when the stakee update's their percentage.

event StakeePercentageUpdated(address indexed _user, uint256 _percentage);

ClaimerPercentageUpdated

Emitted via {setClaimerPercentage} when the stakee update's their percentage.

event ClaimerPercentageUpdated(address indexed _user, uint256 _percentage);

DefaultPayeeUpdated

Emitted via {setDefaultPayee} when the defaultPayee is updated.

event DefaultPayeeUpdated(address _payee);

DeflationaryPercentageUpdated

Emitted via {setDeflationaryPercentage} when the deflationaryPercentage is updated.

event DeflationaryPercentageUpdated(uint256 _percentage);

DiscountPercentageUpdated

Emitted via {setDiscountPercentage} when the discountedPercent is updated.

event DiscountPercentageUpdated(uint256 _percentage);

PeriodLengthUpdated

Emitted via {setPeriodLength} when the periodLength is updated.

event PeriodLengthUpdated(uint256 _periodLength);

ReverseRegistrarUpdated

Emitted via {setReverseRegistrar} when the ENS reverse registrar is updated.

event ReverseRegistrarUpdated(address _percentage);

ResolverUpdated

Emitted via {setResolver} when the ENS resolver is updated.

event ResolverUpdated(address _resolver);

SetSwapPool

Emitted via {setSwapPool} when a new swap pool has been set.

event SetSwapPool(address _uniswapPool, address _token);

Errors

Unauthorized

Emitted when guarded functions are called by users without the necessary permissions.

error Unauthorized();

InvalidPool

Emitted via {setSwapPool} if the pool doesn't match the token and pairs with WETH.

error InvalidPool();

StakingContractAlreadyExists

Emitted via {setStakingAddress} if the user already has a staking address.

error StakingContractAlreadyExists();

ZeroAddressUnsupported

Emitted when Zero address provided where it is not allowed.

error ZeroAddressUnsupported();

InsufficientRareAllowance

Error emitted in {transferRareTo} when a user performs an action that requires moving $RARE but has not made enough allowance for the registry.

error InsufficientRareAllowance();

PercentageBeyondLimit

Emitted when a percentage is beyond the specified limit.

error PercentageBeyondLimit();

PeriodLengthBeyondLimit

Emitted when a Period Length is beyond the specified limit.

error PeriodLengthBeyondLimit();

Structs

Info

A struct holding the information about the target's staking contract.

Target being staked on is omitted as it's the key in the mapping used.

struct Info {
    string name;
    string symbol;
    address stakingAddress;
    address rewardSwapAddress;
}

IRewardAccumulator

Git Source

Author: SuperRare Labs, Koloz

The reward accumulator interface containing all functions, events, etc. for accumulating and swapping rewards.

Functions

initialize

function initialize(address _stakingRegistry, address _stakingPool) external;

rewardSwap

Swap RARE for a discounted price on tokens stored

function rewardSwap(address _tokenOut, uint256 _minAmountOut, uint128 _rareIn) external;

Parameters

estimateRarePrice

Estimate the discounted $RARE price for a given token.

function estimateRarePrice(address _tokenOut, uint128 _rareAmountIn) external view returns (uint256);

Parameters

Returns

Events

RewardAccumulator

event RewardAccumulator(address indexed _msgSender, address indexed _tokenOut, uint256 _amountOut, uint256 _rareIn);

Errors

Unauthorized

Error emitted when user doesnt meet the criteria for call.

error Unauthorized();

InsufficientFunds

Error emitted via {rewardSwap} if reward swap doesn't have enough funds to perform the swap.

error InsufficientFunds();

RarePriceTooLow

Error emitted via {rewardSwap} if the rare price is too low to handle the _minAmountOut requirement.

error RarePriceTooLow();

CannotSwapRareForRare

Error emitted via {rewardSwap} if _tokenOut is the $RARE address.

error CannotSwapRareForRare();

UnsupportedERC20Token

Emitted when an unsupported ERC20 token for reward swapping.

error UnsupportedERC20Token();

IRarityPool

Git Source

Inherits: IERC20Upgradeable

Author: SuperRare Labs, koloz

The Rare Staking Pool ERC20 (Rarity Pool) interface containing all functions, events, etc.

Functions

initialize

function initialize(address _rare, address _userStakedTo, address _stakingRegistry, address _creator) external;

addRewards

Allocates rewards for the current round with the given amount.

function addRewards(address _donor, uint256 _amount) external;

Parameters

takeSnapshot

Snapshots the rewards for the current round. Anyone can call this.

function takeSnapshot() external;

stake

Stake $RARE tokens to the target associated with the contract and receive synthetic tokens in return.

function stake(uint256 _amount) external;

Parameters

unstake

Unstake by returning synthetic tokens and receiving previously staked $RARE in return.

function unstake(uint256 _amount) external;

Parameters

claimRewardsForRounds

Claim rewards due to the _user for the supplied rounds. Rewards are proportional to the synthetic tokens held during the snapshot associated with each round. Throws if user has already claimed for a given round. Throws if current round is being claimed.

function claimRewardsForRounds(address _user, uint256[] memory _rounds) external;

Parameters

stakerHasClaimedForRound

Query if a user has claimed their reward for a given round.

function stakerHasClaimedForRound(address _staker, uint256 _round) external view returns (bool);

Parameters

getAmountStakedByUser

Query total amount of $RARE a user has staked on this contract.

function getAmountStakedByUser(address _user) external view returns (uint256);

Parameters

Returns

getCurrentRound

Query current round. The current round is accumulating rewards.

function getCurrentRound() external view returns (uint256);

Returns

name

Name of the synthetic asset.

function name() external view returns (string memory);

Returns

symbol

Symbol of the synthetic asset.

function symbol() external view returns (string memory);

Returns

getTargetBeingStakedOn

Query the target being staked on by this contract.

function getTargetBeingStakedOn() external view returns (address);

Returns

getAllStakers

Retrieves a list of all the users that have staked.

function getAllStakers() external view returns (address[] memory);

Returns

getRoundRewards

Total rewards available for the supplied round.

function getRoundRewards(uint256 _round) external view returns (uint256);

Returns

getHistoricalRewardsForUserForRounds

Query rewards for the supplied user address for the round supplied rounds. Does not omit rewards for rounds that have already been claimed. Allows for easier historical lookups.

function getHistoricalRewardsForUserForRounds(address _user, uint256[] memory _rounds)
    external
    view
    returns (uint256);

Parameters

Returns

getClaimableRewardsForUserForRounds

Query rewards for the supplied user address for the round supplied rounds. Throws if any round has already been claimed.

function getClaimableRewardsForUserForRounds(address _user, uint256[] memory _rounds) external view returns (uint256);

Parameters

Returns

calculatePurchaseReturn

Calculates the number of sRare yielded from staking.

function calculatePurchaseReturn(uint256 _totalSRare, uint256 _stakedAmount) external pure returns (uint256);

Parameters

Returns

calculateSaleReturn

Calculates the number of rare yielded from unstaking.

function calculateSaleReturn(uint256 _totalSRareByUser, uint256 _totalRareStakedByUser, uint256 _unstakeAmount)
    external
    pure
    returns (uint256);

Parameters

Returns

getAllTimeRewards

Total rewards snapshotted since con.

function getAllTimeRewards() external view returns (uint256);

Returns

getClaimRounds

List of all rounds with claim associated with them.

function getClaimRounds() external view returns (uint256[] memory);

Returns

getCreationTime

Get the unix creation time of the staking contract.

function getCreationTime() external view returns (uint256);

Returns

getLastSnapshotTimestamp

Get the unix time of the most recent snapshot.

function getLastSnapshotTimestamp() external view returns (uint256);

Returns

getSumOfAllClaimed

Total amount of Rewards claimed.

function getSumOfAllClaimed() external view returns (uint256);

Returns

Events

RewardClaimed

event RewardClaimed(
    address indexed _msgSender,
    address indexed _claimer,
    uint256 _amountToStaker,
    uint256 _amountToClaimer,
    uint256 _amountToStakee
);

Stake

event Stake(address indexed _staker, uint256 _amountStaking, uint256 _totalAmountStaked, uint256 _amountSRareReceived);

Unstake

event Unstake(
    address indexed _staker,
    uint256 _amountUnstaking,
    uint256 _totalAmountStaked,
    uint256 _amountRareBurned,
    uint256 _amountSRareSold
);

StakingSnapshot

event StakingSnapshot(uint256 _lastSnapshotTimestamp, uint256 _currentSnapshotTimestamp, uint256 _round);

AddRewards

event AddRewards(
    address indexed _donor,
    uint256 indexed _round,
    uint256 _amount,
    uint256 _totalAmountAdded,
    uint256 _newRoundRewardAmount
);

Errors

Unauthorized

Error emitted when user doesnt meet the criteria for call.

error Unauthorized();

RewardAlreadyClaimed

Error emitted via {claimRewardsForRounds} if sender has already claimed their reward one of the supplied rounds.

error RewardAlreadyClaimed();

ClaimingTooManyRounds

Error emitted via {claimRewardsForRounds} if too many rounds are supplied.

error ClaimingTooManyRounds();

CannotClaimCurrentRound

Error emitted via {claimRewardsForRounds} if claiming current round.

error CannotClaimCurrentRound();

ClaimingZeroRounds

Error emitted via {claimRewardsForRounds} if claiming no rounds.

error ClaimingZeroRounds();

InsufficientSyntheticRare

Error emitted via {unstake} when unstaking more synthetic tokens than is in their balance.

error InsufficientSyntheticRare();

InsufficientStakedRare

Error emitted via {unstake} when the sale return proves greater than the amount staked. This should be impossible.

error InsufficientStakedRare();

CannotAddZeroRewards

Error emitted via {addRewards} if adding 0 rewards.

error CannotAddZeroRewards();

IRewardAccumulatorFactory

Git Source

Author: charlescrain

The RewardAccumulator Factory interface containing all functions, events, etc.

Functions

deployRewardSwap

Deploys a RewardAccumulator contract.

function deployRewardSwap(address _stakingAddress) external returns (address payable);

Parameters

Returns

setStakingRegistry

Set the staking registry address field to be used.

function setStakingRegistry(address _stakingRegistry) external;

Parameters

setRewardSwapTemplate

Set the RewardAccumulator template address to be used.

function setRewardSwapTemplate(address _rewardTemplate) external;

Parameters

getStakingRegistryAddress

Retrieve the currently used staking registry address.

function getStakingRegistryAddress() external view returns (address);

Returns

getRewardSwapTemplateAddress

Retrieve the template contract

function getRewardSwapTemplateAddress() external view returns (address);

Returns

Events

RewardSwapContractCreated

Emitted via {deployRewardSwap} when a new RewardAccumulator contract is deployed.

event RewardSwapContractCreated(address indexed _stakingAddress);

IRarityPoolFactory

Git Source

Author: SuperRare Labs, koloz

The Staking Factory interface containing all functions, events, etc.

Functions

deployStaking

Deploys a staking contract for the supplied target address. Reverts if address exists.

function deployStaking(address _user) external returns (address);

Parameters

Returns

setStakingRegistry

Set the staking registry address field to be used.

function setStakingRegistry(address _stakingRegistry) external;

Parameters

setRareStakingTemplate

Set the rare staking ERC20 template address to be used.

function setRareStakingTemplate(address _rareStakingTemplate) external;

Parameters

getStakingRegistryAddress

Retrieve the currently used staking registry address.

function getStakingRegistryAddress() external view returns (address);

Returns

getRareStakingTemplateAddress

Retrieve the currently template of the staking ERC20 contract.

function getRareStakingTemplateAddress() external view returns (address);

Returns

Events

StakingContractCreated

Emitted via {deployStaking} when a new staking contract is deployed.

event StakingContractCreated(
    address indexed _deployingUser, address indexed _userStakedOn, address indexed _stakingAddress
);

Last updated