IPremiaStaking

Git Source

Inherits: IERC2612, IOFT

Functions

getRewardToken

Returns the reward token address

function getRewardToken() external view returns (address);

Returns

NameTypeDescription
<none>addressThe reward token address

addRewards

add premia tokens as available tokens to be distributed as rewards

function addRewards(uint256 amount) external;

Parameters

NameTypeDescription
amountuint256amount of premia tokens to add as rewards

getAvailableRewards

get amount of tokens that have not yet been distributed as rewards

function getAvailableRewards() external view returns (uint256 rewards, uint256 unstakeRewards);

Returns

NameTypeDescription
rewardsuint256amount of tokens not yet distributed as rewards
unstakeRewardsuint256amount of PREMIA not yet claimed from early unstake fees

getPendingRewards

get pending amount of tokens to be distributed as rewards to stakers

function getPendingRewards() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256amount of tokens pending to be distributed as rewards

getPendingWithdrawals

Return the total amount of premia pending withdrawal

function getPendingWithdrawals() external view returns (uint256);

getPendingWithdrawal

get pending withdrawal data of a user

function getPendingWithdrawal(address user)
    external
    view
    returns (uint256 amount, uint256 startDate, uint256 unlockDate);

Returns

NameTypeDescription
amountuint256pending withdrawal amount
startDateuint256start timestamp of withdrawal
unlockDateuint256timestamp at which withdrawal becomes available

getAvailablePremiaAmount

get the amount of PREMIA available for withdrawal

function getAvailablePremiaAmount() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256amount of PREMIA available for withdrawal

stakeWithPermit

Stake using IERC2612 permit

function stakeWithPermit(uint256 amount, uint64 period, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external;

Parameters

NameTypeDescription
amountuint256The amount of xPremia to stake
perioduint64The lockup period (in seconds)
deadlineuint256Deadline after which permit will fail
vuint8V
rbytes32R
sbytes32S

stake

Lockup xPremia for protocol fee discounts Longer period of locking will apply a multiplier on the amount staked, in the fee discount calculation

function stake(uint256 amount, uint64 period) external;

Parameters

NameTypeDescription
amountuint256The amount of xPremia to stake
perioduint64The lockup period (in seconds)

updateLock

update vxPremia lock

function updateLock(uint64 period) external;

Parameters

NameTypeDescription
perioduint64The new lockup period (in seconds)

harvestAndStake

harvest rewards, convert to PREMIA using exchange helper, and stake

function harvestAndStake(IPremiaStaking.SwapArgs calldata s, uint64 stakePeriod) external;

Parameters

NameTypeDescription
sIPremiaStaking.SwapArgsswap arguments
stakePerioduint64The lockup period (in seconds)

harvest

Harvest rewards directly to user wallet

function harvest() external;

getPendingUserRewards

Get pending rewards amount, including pending pool update

function getPendingUserRewards(address user) external view returns (uint256 reward, uint256 unstakeReward);

Parameters

NameTypeDescription
useraddressUser for which to calculate pending rewards

Returns

NameTypeDescription
rewarduint256amount of pending rewards from protocol fees (in REWARD_TOKEN)
unstakeRewarduint256amount of pending rewards from early unstake fees (in PREMIA)

earlyUnstake

unstake tokens before end of the lock period, for a fee

function earlyUnstake(uint256 amount) external;

Parameters

NameTypeDescription
amountuint256the amount of vxPremia to unstake

getEarlyUnstakeFee

get early unstake fee for given user

function getEarlyUnstakeFee(address user) external view returns (uint256 feePercentage);

Parameters

NameTypeDescription
useraddressaddress of the user

Returns

NameTypeDescription
feePercentageuint256% fee to pay for early unstake (1e18 = 100%)

startWithdraw

Initiate the withdrawal process by burning xPremia, starting the delay period

function startWithdraw(uint256 amount) external;

Parameters

NameTypeDescription
amountuint256quantity of xPremia to unstake

withdraw

Withdraw underlying premia

function withdraw() external;

getUserPower

Calculate the stake amount of a user, after applying the bonus from the lockup period chosen

function getUserPower(address user) external view returns (uint256);

Parameters

NameTypeDescription
useraddressThe user from which to query the stake amount

Returns

NameTypeDescription
<none>uint256The user stake amount after applying the bonus

getTotalPower

Return the total power across all users (applying the bonus from lockup period chosen)

function getTotalPower() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The total power across all users

getDiscount

Calculate the % of fee discount for user, based on his stake

function getDiscount(address user) external view returns (uint256);

Parameters

NameTypeDescription
useraddressThe _user for which the discount is for

Returns

NameTypeDescription
<none>uint256Percentage of protocol fee discount Ex : 1e17 = 10% fee discount

getStakeLevels

Get stake levels

function getStakeLevels() external pure returns (StakeLevel[] memory);

Returns

NameTypeDescription
<none>StakeLevel[]Stake levels Ex : 25e16 = -25%

getStakePeriodMultiplier

Get stake period multiplier

function getStakePeriodMultiplier(uint256 period) external pure returns (uint256);

Parameters

NameTypeDescription
perioduint256The duration (in seconds) for which tokens are locked

Returns

NameTypeDescription
<none>uint256The multiplier for this staking period Ex : 2e18 = x2

getUserInfo

Get staking infos of a user

function getUserInfo(address user) external view returns (PremiaStakingStorage.UserInfo memory);

Parameters

NameTypeDescription
useraddressThe user address for which to get staking infos

Returns

NameTypeDescription
<none>PremiaStakingStorage.UserInfoThe staking infos of the user

Events

Stake

event Stake(address indexed user, uint256 amount, uint64 stakePeriod, uint64 lockedUntil);

Unstake

event Unstake(address indexed user, uint256 amount, uint256 fee, uint256 startDate);

Harvest

event Harvest(address indexed user, uint256 amount);

EarlyUnstakeRewardCollected

event EarlyUnstakeRewardCollected(address indexed user, uint256 amount);

Withdraw

event Withdraw(address indexed user, uint256 amount);

RewardsAdded

event RewardsAdded(uint256 amount);

BridgeLock

event BridgeLock(address indexed user, uint64 stakePeriod, uint64 lockedUntil);

UpdateLock

event UpdateLock(address indexed user, uint64 oldStakePeriod, uint64 newStakePeriod);

Errors

PremiaStaking__CantTransfer

error PremiaStaking__CantTransfer();

PremiaStaking__ExcessiveStakePeriod

error PremiaStaking__ExcessiveStakePeriod();

PremiaStaking__InsufficientSwapOutput

error PremiaStaking__InsufficientSwapOutput();

PremiaStaking__NoPendingWithdrawal

error PremiaStaking__NoPendingWithdrawal();

PremiaStaking__NotEnoughLiquidity

error PremiaStaking__NotEnoughLiquidity();

PremiaStaking__PeriodTooShort

error PremiaStaking__PeriodTooShort();

PremiaStaking__StakeLocked

error PremiaStaking__StakeLocked();

PremiaStaking__StakeNotLocked

error PremiaStaking__StakeNotLocked();

PremiaStaking__WithdrawalStillPending

error PremiaStaking__WithdrawalStillPending();

Structs

StakeLevel

struct StakeLevel {
    uint256 amount;
    uint256 discount;
}

SwapArgs

struct SwapArgs {
    uint256 amountOutMin;
    address callee;
    address allowanceTarget;
    bytes data;
    address refundAddress;
}