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.
UD60x18_SCALE_PRECISION
Scale precision for the stIPRWA:IPRWA ratio - scaled by 10^27
usersNetIPRWADeposited
Amount of IPRWA solely deposited by users into the contract (not accounting for deposited rewards)
Functions
stakelock
CONSTRUCTOR
Modifier to prevent staking/unstaking during the same transaction
constructor
CONSTRUCTOR
to avoid parity hack
Note: oz-upgrades-unsafe-allow: constructor
initialize
INITIALIZER
Initializer function needed to set values when called behind a proxy
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
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
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
iprwaPerStIPRWA
Returns the IPRWA:stIPRWA ratio - scaled by 10^27
_stIPRWAPerIPRWA
INTERNAL FUNCTIONS
stIPRWA:IPRWA ratio = (total stIPRWA supply - stIPRWA contract balance) / (IPRWA in contract)
_iprwaPerStIPRWA
IPRWA:stIPRWA = (IPRWA in contract) / (total stIPRWA supply - stIPRWA contract balance)
_getIPRWAValue
_getStiprwaValue
withdraw
ADMIN FUNCTIONS
Withdraw tokens from the contract.
A _tokenAddress of address(0) denotes ETH
Only callable by the contract owner
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
Parameters
_iprwaToken
address
Address for the IPRWA token
setStakedIPRWAToken
Sets the address for the stIPRWA token
Only callable by the contract owner
Parameters
_stakedIPRWAToken
address
Address for the stIPRWA token
setPauseState
_authorizeUpgrade
Events
IPRWAStaked
EVENTS
Event emitted when IPRWA tokens are staked
IPRWAUnstaked
Event emitted when IPRWA tokens are unstaked
FundsWithdrawn
Event emitted when funds are withdrawn
Errors
EmptyAmount
CUSTOM ERRORS
Error thrown when trying to stake/unstake 0 tokens.
Unauthorized
Error thrown when msg sender is unauthorized
BalanceTooLow
Error thrown when user does not have enough balance
IncorrectSignatureLength
Error thrown when Signature length is incorrect