IPRWAStaking
Inherits: UUPSUpgradeable, AccessControlUpgradeable, Pausable
Author: Aria Protocol
Staking contract for IPRWA token
State Variables
STAKE_LOCK_SLOT
STATE VARIABLES ///
Slot for the stake lock
bytes32 private constant STAKE_LOCK_SLOT = 0xe750219e856dc1045ee53321d6403a2f5fd45d5721d9656823eb6ce52a38051a;
iprwaToken
Address of the IPRWA token
IERC20 public iprwaToken;
stakedIPRWAToken
Address of the staked IPRWA token.
IStakedERC20 public stakedIPRWAToken;
legal
Address of the legal contract that checks blacklist and license.
address public legal;
UD60x18_SCALE_PRECISION
Scale precision for the stIPRWA:IPRWA ratio - scaled by 10^27
UD60x18 public UD60x18_SCALE_PRECISION;
usersNetIPRWADeposited
Amount of IPRWA solely deposited by users into the contract (not accounting for deposited rewards)
uint256 public usersNetIPRWADeposited;
Functions
stakelock
CONSTRUCTOR
Modifier to prevent staking/unstaking during the same transaction
modifier stakelock();
constructor
CONSTRUCTOR
to avoid parity hack
Note: oz-upgrades-unsafe-allow: constructor
constructor();
initialize
INITIALIZER
Initializer function needed to set values when called behind a proxy
function initialize(address _iprwaToken, address _stakedIPRWAToken, address _legal, address _owner)
external
initializer;
Parameters
_iprwaToken
address
Address of the IPRWA token
_stakedIPRWAToken
address
Address of the Staked IPRWA token
_legal
address
Address of the legal contract that checks blacklist and license.
_owner
address
Address of the initial owner of the contract
stake
STAKING FUNCTIONS
Stake IPRWA tokens
Assumes this contract has approval to move IPRWA tokens
function stake(uint256 _amount) external stakelock whenNotPaused;
Parameters
_amount
uint256
Number of IPRWA tokens to staking
unstake
Unstake stIPRWA token in exchange for IPRWA tokens
Assumes this contract has approval to move stIPRWA tokens
function unstake(uint256 _amount) external stakelock whenNotPaused;
Parameters
_amount
uint256
Number of stIPRWA tokens to unstake, a.k.a. net user deposit w/o rewards
stIPRWAperIPRWA
EXTERNAL FUNCTIONS ///
Returns the stIPRWA:IPRWA ratio - scaled by 10^27
function stIPRWAperIPRWA() external view returns (uint256);
iprwaPerStIPRWA
Returns the IPRWA:stIPRWA ratio - scaled by 10^27
function iprwaPerStIPRWA() external view returns (uint256);
_stIPRWAPerIPRWA
INTERNAL FUNCTIONS
stIPRWA:IPRWA ratio = (total stIPRWA supply - stIPRWA contract balance) / (IPRWA in contract)
function _stIPRWAPerIPRWA() internal view returns (UD60x18);
_iprwaPerStIPRWA
IPRWA:stIPRWA = (IPRWA in contract) / (total stIPRWA supply - stIPRWA contract balance)
function _iprwaPerStIPRWA() internal view returns (UD60x18);
_getIPRWAValue
function _getIPRWAValue(uint256 _stIPRWAAmount) internal view returns (uint256);
_getStiprwaValue
function _getStiprwaValue(uint256 _iprwaAmount) internal view returns (uint256);
withdraw
ADMIN FUNCTIONS
Withdraw tokens from the contract.
A _tokenAddress of address(0) denotes ETH
Only callable by the contract owner
function withdraw(address _tokenAddress, uint256 _amount) external onlyRole(DEFAULT_ADMIN_ROLE);
Parameters
_tokenAddress
address
Address of token to withdraw tokens for
_amount
uint256
Number of tokens to withdraw
setIPRWAToken
Sets the address for the IPRWA token
Only callable by the contract owner
function setIPRWAToken(address _iprwaToken) external onlyRole(DEFAULT_ADMIN_ROLE);
Parameters
_iprwaToken
address
Address for the IPRWA token
setStakedIPRWAToken
Sets the address for the stIPRWA token
Only callable by the contract owner
function setStakedIPRWAToken(address _stakedIPRWAToken) external onlyRole(DEFAULT_ADMIN_ROLE);
Parameters
_stakedIPRWAToken
address
Address for the stIPRWA token
setPauseState
function setPauseState(bool paused_) external;
_authorizeUpgrade
function _authorizeUpgrade(address newImplementation) internal virtual override onlyRole(DEFAULT_ADMIN_ROLE);
Events
IPRWAStaked
EVENTS
Event emitted when IPRWA tokens are staked
event IPRWAStaked(address indexed _user, uint256 _iprwaIn, uint256 _stIPRWAOut);
IPRWAUnstaked
Event emitted when IPRWA tokens are unstaked
event IPRWAUnstaked(address indexed _user, uint256 _stIPRWAIn, uint256 _iprwaOut);
FundsWithdrawn
Event emitted when funds are withdrawn
event FundsWithdrawn(address indexed _tokenAddress, uint256 indexed _amount);
Errors
EmptyAmount
CUSTOM ERRORS
Error thrown when trying to stake/unstake 0 tokens.
error EmptyAmount();
Unauthorized
Error thrown when msg sender is unauthorized
error Unauthorized();
BalanceTooLow
Error thrown when user does not have enough balance
error BalanceTooLow(uint256 _balance, uint256 _requiredAmount);
IncorrectSignatureLength
Error thrown when Signature length is incorrect
error IncorrectSignatureLength();