IPremiaStaking
Inherits: IERC2612, IOFT
Functions
getRewardToken
Returns the reward token address
function getRewardToken() external view returns (address);
Returns
Name | Type | Description |
---|---|---|
<none> | address | The reward token address |
addRewards
add premia tokens as available tokens to be distributed as rewards
function addRewards(uint256 amount) external;
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | amount 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
Name | Type | Description |
---|---|---|
rewards | uint256 | amount of tokens not yet distributed as rewards |
unstakeRewards | uint256 | amount 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
Name | Type | Description |
---|---|---|
<none> | uint256 | amount 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
Name | Type | Description |
---|---|---|
amount | uint256 | pending withdrawal amount |
startDate | uint256 | start timestamp of withdrawal |
unlockDate | uint256 | timestamp at which withdrawal becomes available |
getAvailablePremiaAmount
get the amount of PREMIA available for withdrawal
function getAvailablePremiaAmount() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | amount 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
Name | Type | Description |
---|---|---|
amount | uint256 | The amount of xPremia to stake |
period | uint64 | The lockup period (in seconds) |
deadline | uint256 | Deadline after which permit will fail |
v | uint8 | V |
r | bytes32 | R |
s | bytes32 | S |
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
Name | Type | Description |
---|---|---|
amount | uint256 | The amount of xPremia to stake |
period | uint64 | The lockup period (in seconds) |
updateLock
update vxPremia lock
function updateLock(uint64 period) external;
Parameters
Name | Type | Description |
---|---|---|
period | uint64 | The 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
Name | Type | Description |
---|---|---|
s | IPremiaStaking.SwapArgs | swap arguments |
stakePeriod | uint64 | The 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
Name | Type | Description |
---|---|---|
user | address | User for which to calculate pending rewards |
Returns
Name | Type | Description |
---|---|---|
reward | uint256 | amount of pending rewards from protocol fees (in REWARD_TOKEN) |
unstakeReward | uint256 | amount 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
Name | Type | Description |
---|---|---|
amount | uint256 | the amount of vxPremia to unstake |
getEarlyUnstakeFee
get early unstake fee for given user
function getEarlyUnstakeFee(address user) external view returns (uint256 feePercentage);
Parameters
Name | Type | Description |
---|---|---|
user | address | address of the user |
Returns
Name | Type | Description |
---|---|---|
feePercentage | uint256 | % 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
Name | Type | Description |
---|---|---|
amount | uint256 | quantity 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
Name | Type | Description |
---|---|---|
user | address | The user from which to query the stake amount |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The 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
Name | Type | Description |
---|---|---|
<none> | uint256 | The 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
Name | Type | Description |
---|---|---|
user | address | The _user for which the discount is for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Percentage of protocol fee discount Ex : 1e17 = 10% fee discount |
getStakeLevels
Get stake levels
function getStakeLevels() external pure returns (StakeLevel[] memory);
Returns
Name | Type | Description |
---|---|---|
<none> | StakeLevel[] | Stake levels Ex : 25e16 = -25% |
getStakePeriodMultiplier
Get stake period multiplier
function getStakePeriodMultiplier(uint256 period) external pure returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
period | uint256 | The duration (in seconds) for which tokens are locked |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The 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
Name | Type | Description |
---|---|---|
user | address | The user address for which to get staking infos |
Returns
Name | Type | Description |
---|---|---|
<none> | PremiaStakingStorage.UserInfo | The 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;
}