Skip to main content

Staking.sol

The security module contract is responsible for managing the pausing and unpausing of the protocol. It is a simple contract that inherits from the OpenZeppelin AccessControlUpgradeable and PausableUpgradeable contracts. The contract has a single role, PAUSE_ROLE, which is used to control who can pause and unpause the protocol.

Functions

depositAndLock

External function to deposit and lock tokens.

function depositAndLock(
address _subject,
uint256 _amount,
uint256 _lockPeriodInSec
)
external
whenNotPaused
onlyValidLockPeriod(_lockPeriodInSec)
returns (uint256 unlockTimeInSec_)

Parameters

NameTypeDescription
_subjectaddressThe subject of the Fan Token.
_amountuint256The amount of Fan Token to deposit.
_lockPeriodInSecuint256The lock period in seconds.

Return Values

NameTypeDescription
unlockTimeInSec_uint256Unlock times for the locks.

depositAndLockFor

External function to deposit and lock tokens for a beneficiary.

function depositAndLockFor(
address _subject,
uint256 _amount,
uint256 _lockPeriodInSec,
address _beneficiary
)
external
whenNotPaused
onlyValidLockPeriod(_lockPeriodInSec)
returns (uint256 unlockTimeInSec_)

Parameters

NameTypeDescription
_subjectaddressSubject address for which tokens are getting deposited.
_amountuint256amount of tokens getting deposited.
_lockPeriodInSecuint256lock period for the tokens.
_beneficiaryaddressAddress of the beneficiary for the lock.

Return Values

NameTypeDescription
unlockTimeInSec_boolUnlock times for the locks.

depositAndLockMultiple

External function to deposit and lock multiple tokens.

function depositAndLockMultiple(
address[] memory _subjects,
uint256[] memory _amounts,
uint256 _lockPeriodInSec
)
external
whenNotPaused
onlyValidLockPeriod(_lockPeriodInSec)
returns (uint256 unlockTimeInSec_)

Parameters

NameTypeDescription
_subjectsaddress[]Subject addresses for which tokens are getting deposited.
_amountsuint256[]Amounts of tokens getting deposited.
_lockPeriodInSecuint256Lock periods for the tokens.

Return Values

NameTypeDescription
unlockTimeInSec_uint256Unlock times for the locks.

depositAndLockMultipleFor

External function to deposit and lock multiple tokens.

function depositAndLockMultipleFor(
address[] memory _subjects,
uint256[] memory _amounts,
uint256 _lockPeriodInSec,
address _beneficiary
)
external
whenNotPaused
onlyValidLockPeriod(_lockPeriodInSec)
returns (uint256 unlockTimeInSec_)

Parameters

NameTypeDescription
_subjectsaddress[]Subject addresses for which tokens are getting deposited.
_amountsaddress[]Amounts of tokens getting deposited.
_lockPeriodInSecaddressLock periods for the tokens.
_beneficiaryaddressAddress of the beneficiary for the lock.

Return Values

NameTypeDescription
unlockTimeInSec_uint256Unlock times for the locks.

buyAndLock

External function to buy & lock tokens.

function buyAndLock(
address _subject,
uint256 _depositAmount,
uint256 _minReturnAmountAfterFee,
uint256 _lockPeriodInSec
)
external
whenNotPaused
onlyValidLockPeriod(_lockPeriodInSec)
returns (uint256 amount_, uint256 unlockTimeInSec_)

Parameters

NameTypeDescription
_subjectaddresSubject address for which tokens are getting bought & deposited.
_depositAmountuint256amount of moxie tokens getting deposited.
_minReturnAmountAfterFeeuint256Slippage setting which determines minimum amount of tokens after fee.
_lockPeriodInSecuint256Lock period for the tokens.

Return Values

NameTypeDescription
amount_uint256Amount of tokens bought & locked.
unlockTimeInSec_uint256Unlock times for the locks.

buyAndLockFor

External function to buy & lock tokens on behalf of another address.

function buyAndLockFor(
address _subject,
uint256 _depositAmount,
uint256 _minReturnAmountAfterFee,
uint256 _lockPeriodInSec,
address _beneficiary
)
external
whenNotPaused
onlyValidLockPeriod(_lockPeriodInSec)
returns (uint256 amount_, uint256 unlockTimeInSec_)

Parameters

NameTypeDescription
_subjectaddresSubject address for which tokens are getting bought & deposited.
_depositAmountuint256amount of moxie tokens getting deposited.
_minReturnAmountAfterFeeuint256Slippage setting which determines minimum amount of tokens after fee.
_lockPeriodInSecuint256Lock period for the tokens.
_beneficiaryaddressAddress of the beneficiary for the lock.

Return Values

NameTypeDescription
amount_uint256Amount of tokens bought & locked.
unlockTimeInSec_uint256Unlock times for the locks.

buyAndLockMultiple

External function to buy & lock multiple tokens.

function buyAndLockMultiple(
address[] memory _subjects,
uint256[] memory _depositAmounts,
uint256[] memory _minReturnAmountsAfterFee,
uint256 _lockPeriodInSec
)
external
whenNotPaused
onlyValidLockPeriod(_lockPeriodInSec)
returns (uint256[] memory amounts_, uint256 unlockTimeInSec_)

Parameters

NameTypeDescription
_subjectsaddres[]Subject addresses for which tokens are getting bought & deposited.
_depositAmountsuint256[]amount of moxie tokens getting deposited.
_minReturnAmountAfterFeesuint256[]Slippage setting which determines minimum amount of tokens after fee.
_lockPeriodInSecuint256Lock period for the tokens.

Return Values

NameTypeDescription
amount_uint256Amount of tokens bought & locked.
unlockTimeInSec_uint256Unlock times for the locks.

buyAndLockMultipleFor

External function to buy & lock multiple tokens on behalf of other wallet address.

function buyAndLockMultipleFor(
address[] memory _subjects,
uint256[] memory _depositAmounts,
uint256[] memory _minReturnAmountsAfterFee,
uint256 _lockPeriodInSec,
address _beneficiary
)
external
whenNotPaused
onlyValidLockPeriod(_lockPeriodInSec)
returns (uint256[] memory amounts_, uint256 unlockTimeInSec_)

Parameters

NameTypeDescription
_subjectsaddres[]Subject addresses for which tokens are getting bought & deposited.
_depositAmountsuint256[]amount of moxie tokens getting deposited.
_minReturnAmountAfterFeesuint256[]Slippage setting which determines minimum amount of tokens after fee.
_lockPeriodInSecuint256Lock period for the tokens.
_beneficiaryaddressAddress of the beneficiary for the lock.

Return Values

NameTypeDescription
amount_uint256Amount of tokens bought & locked.
unlockTimeInSec_uint256Unlock times for the locks.

withdraw

External function to withdraw locked tokens.

function withdraw(
address _subject,
uint256[] memory _indexes
) external whenNotPaused returns (uint256 totalAmount_)

Parameters

NameTypeDescription
_subjectaddressSubject address for which tokens are getting withdrawn.
_indexesuint256[]Indexes of the locks to be withdrawn.

Return Values

NameTypeDescription
totalAmount_uint256Total amount of tokens withdrawn.

extendLock

External function to extend the lock period of the tokens.

function extendLock(
address _subject,
uint256[] memory _indexes,
uint256 _lockPeriodInSec
)
external
whenNotPaused
onlyValidLockPeriod(_lockPeriodInSec)
returns (uint256 totalAmount_, uint256 unlockTimeInSec_)

Parameters

NameTypeDescription
_subjectaddressSubject address for which tokens are being extended.
_indexesuint256[]Indexes of the locks to be extended.
_lockPeriodInSecuint256Lock periods for the tokens.

Return Values

NameTypeDescription
totalAmount_uint256Total amount of tokens extended for lock.
unlockTimeInSec_uint256unlock time is the timestamp of the extended lock.

extendLockFor

External function to extend the lock period of the tokens on behalf of other wallet address.

function extendLockFor(
address _subject,
uint256[] memory _indexes,
uint256 _lockPeriodInSec,
address _beneficiary
)
external
whenNotPaused
onlyValidLockPeriod(_lockPeriodInSec)
returns (uint256 totalAmount_, uint256 unlockTimeInSec_)

Parameters

NameTypeDescription
_subjectaddressSubject address for which tokens are being extended.
_indexesuint256[]Indexes of the locks to be extended.
_lockPeriodInSecuint256Lock periods for the tokens.
_beneficiaryaddressAddress of the beneficiary for the lock.

Return Values

NameTypeDescription
totalAmount_uint256Total amount of tokens extended for lock.
unlockTimeInSec_uint256unlock time is the timestamp of the extended lock.

getTotalStakedAmount

External function to get the total staked amount for a user & subject token.

function getTotalStakedAmount(
address _user,
address _subject,
uint256[] calldata _indexes
) external view returns (uint256 totalAmount_)

Parameters

NameTypeDescription
_useraddressUser address for which total staked amount is being calculated.
_subjectaddressSubject address for which total staked amount is being calculated.
_indexesuint256[]Indexes of the locks for which total staked amount is being calculated.

Return Values

NameTypeDescription
totalAmount_uint256Total staked amount by the inputted user