Skip to content

Latest commit

 

History

History
2542 lines (1827 loc) · 59.4 KB

IStaking.md

File metadata and controls

2542 lines (1827 loc) · 59.4 KB

Interface for Staking modules governance/Staking/modules (IStaking.sol)

View Source: contracts/governance/Staking/interfaces/IStaking.sol

IStaking contract

Structs

Checkpoint

struct Checkpoint {
 uint32 fromBlock,
 uint96 stake
}

Events

event VestingStakeSet(uint256  lockedTS, uint96  value);

Functions


addAdmin

Add account to Admins ACL.

function addAdmin(address _admin) external nonpayable

Arguments

Name Type Description
_admin address The addresses of the account to grant permissions.
Source Code
function addAdmin(address _admin) external;

removeAdmin

Remove account from Admins ACL.

function removeAdmin(address _admin) external nonpayable

Arguments

Name Type Description
_admin address The addresses of the account to revoke permissions.
Source Code
function removeAdmin(address _admin) external;

addPauser

Add account to pausers ACL.

function addPauser(address _pauser) external nonpayable

Arguments

Name Type Description
_pauser address The address to grant pauser permissions.
Source Code
function addPauser(address _pauser) external;

removePauser

Remove account from pausers ACL.

function removePauser(address _pauser) external nonpayable

Arguments

Name Type Description
_pauser address The address to grant pauser permissions.
Source Code
function removePauser(address _pauser) external;

pauseUnpause

Pause/unpause contract

function pauseUnpause(bool _pause) external nonpayable

Arguments

Name Type Description
_pause bool true when pausing, false when unpausing
Source Code
function pauseUnpause(bool _pause) external;

freezeUnfreeze

Freeze contract - disable all functions

function freezeUnfreeze(bool _freeze) external nonpayable

Arguments

Name Type Description
_freeze bool true when freezing, false when unfreezing
Source Code
function freezeUnfreeze(bool _freeze) external;

setFeeSharing

Allows the owner to set a fee sharing proxy contract. We need it for unstaking with slashing.

function setFeeSharing(address _feeSharing) external nonpayable

Arguments

Name Type Description
_feeSharing address The address of FeeSharingCollectorProxy contract.
Source Code
function setFeeSharing(address _feeSharing) external;

setWeightScaling

Allow the owner to set weight scaling. We need it for unstaking with slashing.

function setWeightScaling(uint96 _weightScaling) external nonpayable

Arguments

Name Type Description
_weightScaling uint96 The weight scaling.
Source Code
function setWeightScaling(uint96 _weightScaling) external;

setNewStakingContract

Allow the owner to set a new staking contract. As a consequence it allows the stakers to migrate their positions to the new contract.

function setNewStakingContract(address _newStakingContract) external nonpayable

Arguments

Name Type Description
_newStakingContract address The address of the new staking contract.
Source Code
function setNewStakingContract(address _newStakingContract) external;

migrateToNewStakingContract

Allow a staker to migrate his positions to the new staking contract.

function migrateToNewStakingContract() external nonpayable
Source Code
function migrateToNewStakingContract() external;

getPriorTotalVotingPower

Compute the total voting power at a given time.

function getPriorTotalVotingPower(uint32 blockNumber, uint256 time) external view
returns(uint96)

Arguments

Name Type Description
blockNumber uint32 The block number, needed for checkpointing.
time uint256 The timestamp for which to calculate the total voting power.

Returns

The total voting power at the given time.

Source Code
function getPriorTotalVotingPower(uint32 blockNumber, uint256 time)
        external
        view
        returns (uint96);

getCurrentVotes

Get the current votes balance for a user account.

function getCurrentVotes(address account) external view
returns(uint96)

Arguments

Name Type Description
account address The address to get votes balance.

Returns

The number of current votes for a user account.

Source Code
function getCurrentVotes(address account) external view returns (uint96);

getPriorVotes

Determine the prior number of votes for a delegatee as of a block number. Iterate through checkpoints adding up voting power.

function getPriorVotes(address account, uint256 blockNumber, uint256 date) external view
returns(uint96)

Arguments

Name Type Description
account address The address of the account to check.
blockNumber uint256 The block number to get the vote balance at.
date uint256 The staking date to compute the power for.

Returns

The number of votes the delegatee had as of the given block.

Source Code
function getPriorVotes(
        address account,
        uint256 blockNumber,
        uint256 date
    ) external view returns (uint96);

getPriorStakeByDateForDelegatee

Determine the prior number of stake for an account as of a block number.

function getPriorStakeByDateForDelegatee(address account, uint256 date, uint256 blockNumber) external view
returns(uint96)

Arguments

Name Type Description
account address The address of the account to check.
date uint256 The staking date to compute the power for.
blockNumber uint256 The block number to get the vote balance at.

Returns

The number of votes the account had as of the given block.

Source Code
function getPriorStakeByDateForDelegatee(
        address account,
        uint256 date,
        uint256 blockNumber
    ) external view returns (uint96);

getPriorTotalStakesForDate

Determine the prior number of stake for an unlocking date as of a block number.

function getPriorTotalStakesForDate(uint256 date, uint256 blockNumber) external view
returns(uint96)

Arguments

Name Type Description
date uint256 The date to check the stakes for.
blockNumber uint256 The block number to get the vote balance at.

Returns

The number of votes the account had as of the given block.

Source Code
function getPriorTotalStakesForDate(uint256 date, uint256 blockNumber)
        external
        view
        returns (uint96);

delegate

Delegate votes from msg.sender which are locked until lockDate to delegatee.

function delegate(address delegatee, uint256 lockDate) external nonpayable

Arguments

Name Type Description
delegatee address The address to delegate votes to.
lockDate uint256 the date if the position to delegate.
Source Code
function delegate(address delegatee, uint256 lockDate) external;

delegateBySig

Delegates votes from signatory to a delegatee account. Voting with EIP-712 Signatures. * Voting power can be delegated to any address, and then can be used to vote on proposals. A key benefit to users of by-signature functionality is that they can create a signed vote transaction for free, and have a trusted third-party spend rBTC(or ETH) on gas fees and write it to the blockchain for them. * The third party in this scenario, submitting the SOV-holder’s signed transaction holds a voting power that is for only a single proposal. The signatory still holds the power to vote on their own behalf in the proposal if the third party has not yet published the signed transaction that was given to them. *

function delegateBySig(address delegatee, uint256 lockDate, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) external nonpayable

Arguments

Name Type Description
delegatee address The address to delegate votes to.
lockDate uint256 The date until which the position is locked.
nonce uint256 The contract state required to match the signature.
expiry uint256 The time at which to expire the signature.
v uint8 The recovery byte of the signature.
r bytes32 Half of the ECDSA signature pair.
s bytes32 Half of the ECDSA signature pair.
Source Code
nction delegateBySig(
        address delegatee,
        uint256 lockDate,
        uint256 nonce,
        uint256 expiry,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

stake

Stake the given amount for the given duration of time.

function stake(uint96 amount, uint256 until, address stakeFor, address delegatee) external nonpayable

Arguments

Name Type Description
amount uint96 The number of tokens to stake.
until uint256 Timestamp indicating the date until which to stake.
stakeFor address The address to stake the tokens for or 0x0 if staking for oneself.
delegatee address The address of the delegatee or 0x0 if there is none.
Source Code
nction stake(
        uint96 amount,
        uint256 until,
        address stakeFor,
        address delegatee
    ) external;

stakeWithApproval

Stake the given amount for the given duration of time.

function stakeWithApproval(address sender, uint96 amount, uint256 until, address stakeFor, address delegatee) external nonpayable

Arguments

Name Type Description
sender address The sender of SOV.approveAndCall
amount uint96 The number of tokens to stake.
until uint256 Timestamp indicating the date until which to stake.
stakeFor address The address to stake the tokens for or 0x0 if staking for oneself.
delegatee address The address of the delegatee or 0x0 if there is none.
Source Code
nction stakeWithApproval(
        address sender,
        uint96 amount,
        uint256 until,
        address stakeFor,
        address delegatee
    ) external;

receiveApproval

Receives approval from SOV token.

function receiveApproval(address _sender, uint256 _amount, address _token, bytes _data) external nonpayable

Arguments

Name Type Description
_sender address
_amount uint256
_token address
_data bytes The data will be used for low level call.
Source Code
nction receiveApproval(
        address _sender,
        uint256 _amount,
        address _token,
        bytes calldata _data
    ) external;

extendStakingDuration

Extend the staking duration until the specified date.

function extendStakingDuration(uint256 previousLock, uint256 until) external nonpayable

Arguments

Name Type Description
previousLock uint256 The old unlocking timestamp.
until uint256 The new unlocking timestamp in seconds.
Source Code
nction extendStakingDuration(uint256 previousLock, uint256 until) external;

stakesBySchedule

DO NOT USE this misspelled function. Use stakeBySchedule function instead. This function cannot be deprecated while we have non-upgradeable vesting contracts.

function stakesBySchedule(uint256 amount, uint256 cliff, uint256 duration, uint256 intervalLength, address stakeFor, address delegatee) external nonpayable

Arguments

Name Type Description
amount uint256
cliff uint256
duration uint256
intervalLength uint256
stakeFor address
delegatee address
Source Code
nction stakesBySchedule(
        uint256 amount,
        uint256 cliff,
        uint256 duration,
        uint256 intervalLength,
        address stakeFor,
        address delegatee
    ) external;

stakeBySchedule

Stake tokens according to the vesting schedule.

function stakeBySchedule(uint256 amount, uint256 cliff, uint256 duration, uint256 intervalLength, address stakeFor, address delegatee) external nonpayable

Arguments

Name Type Description
amount uint256 The amount of tokens to stake.
cliff uint256 The time interval to the first withdraw.
duration uint256 The staking duration.
intervalLength uint256 The length of each staking interval when cliff passed.
stakeFor address The address to stake the tokens for or 0x0 if staking for oneself.
delegatee address The address of the delegatee or 0x0 if there is none.
Source Code
nction stakeBySchedule(
        uint256 amount,
        uint256 cliff,
        uint256 duration,
        uint256 intervalLength,
        address stakeFor,
        address delegatee
    ) external;

balanceOf

Get the number of staked tokens held by the user account.

function balanceOf(address account) external view
returns(balance uint96)

Arguments

Name Type Description
account address The address of the account to get the balance of.

Returns

The number of tokens held.

Source Code
nction balanceOf(address account) external view returns (uint96 balance);

getCurrentStakedUntil

Get the current number of tokens staked for a day.

function getCurrentStakedUntil(uint256 lockedTS) external view
returns(uint96)

Arguments

Name Type Description
lockedTS uint256 The timestamp to get the staked tokens for.
Source Code
nction getCurrentStakedUntil(uint256 lockedTS) external view returns (uint96);

getStakes

Get list of stakes for a user account.

function getStakes(address account) external view
returns(dates uint256[], stakes uint96[])

Arguments

Name Type Description
account address The address to get stakes.

Returns

The arrays of dates and stakes.

Source Code
nction getStakes(address account)
        external
        view
        returns (uint256[] memory dates, uint96[] memory stakes);

timestampToLockDate

Unstaking is possible every 2 weeks only. This means, to calculate the key value for the staking checkpoints, we need to map the intended timestamp to the closest available date.

function timestampToLockDate(uint256 timestamp) external view
returns(uint256)

Arguments

Name Type Description
timestamp uint256 The unlocking timestamp.

Returns

The actual unlocking date (might be up to 2 weeks shorter than intended).

Source Code
nction timestampToLockDate(uint256 timestamp) external view returns (uint256);

getStorageMaxDurationToStakeTokens

The maximum duration to stake tokens

function getStorageMaxDurationToStakeTokens() external pure
returns(uint256)
Source Code
nction getStorageMaxDurationToStakeTokens() external pure returns (uint256);

getStorageMaxVotingWeight

The maximum possible voting weight before adding +1 (actually 10, but need 9 for computation).

function getStorageMaxVotingWeight() external pure
returns(uint256)
Source Code
nction getStorageMaxVotingWeight() external pure returns (uint256);

getStorageWeightFactor

weight is multiplied with this factor (for allowing decimals, like 1.2x).

function getStorageWeightFactor() external pure
returns(uint256)
Source Code
nction getStorageWeightFactor() external pure returns (uint256);

getStorageDefaultWeightScaling

function getStorageDefaultWeightScaling() external pure
returns(uint256)
Source Code
nction getStorageDefaultWeightScaling() external pure returns (uint256);

getStorageRangeForWeightScaling

return (uint256(MIN_WEIGHT_SCALING), uint256(MAX_WEIGHT_SCALING))

function getStorageRangeForWeightScaling() external pure
returns(minWeightScaling uint256, maxWeightScaling uint256)
Source Code
nction getStorageRangeForWeightScaling()
        external
        pure
        returns (uint256 minWeightScaling, uint256 maxWeightScaling);

getStorageDomainTypehash

The EIP-712 typehash for the contract's domain.

function getStorageDomainTypehash() external pure
returns(uint256)
Source Code
nction getStorageDomainTypehash() external pure returns (uint256);

getStorageDelegationTypehash

The EIP-712 typehash for the delegation struct used by the contract.

function getStorageDelegationTypehash() external pure
returns(uint256)
Source Code
nction getStorageDelegationTypehash() external pure returns (uint256);

getStorageName

function getStorageName() external view
returns(string)
Source Code
nction getStorageName() external view returns (string memory);

kickoffTS

The timestamp of contract creation. Base for the staking period calculation.

function kickoffTS() external view
returns(uint256)
Source Code
nction kickoffTS() external view returns (uint256);

SOVToken

The token to be staked

function SOVToken() external view
returns(address)
Source Code
nction SOVToken() external view returns (address);

delegates

Stakers delegated voting power

function delegates(address staker, uint256 until) external view
returns(_delegate address)

Arguments

Name Type Description
staker address - the delegating address
until uint256 - delegated voting

Returns

_delegate - voting power delegated to address

Source Code
nction delegates(address staker, uint256 until) external view returns (address _delegate);

allUnlocked

If this flag is set to true, all tokens are unlocked immediately see function unlockAllTokens() for details

function allUnlocked() external view
returns(bool)
Source Code
nction allUnlocked() external view returns (bool);

newStakingContract

Used for stake migrations to a new staking contract with a different storage structure

function newStakingContract() external view
returns(address)
Source Code
nction newStakingContract() external view returns (address);

totalStakingCheckpoints

A record of tokens to be unstaked at a given time in total. For total voting power computation. Voting weights get adjusted bi-weekly.

function totalStakingCheckpoints(uint256 date, uint32 index) external view
returns(struct IStaking.Checkpoint)

Arguments

Name Type Description
date uint256
index uint32
Source Code
nction totalStakingCheckpoints(uint256 date, uint32 index)
        external
        view
        returns (Checkpoint memory);

numTotalStakingCheckpoints

The number of total staking checkpoints for each date.

function numTotalStakingCheckpoints(uint256 date) external view
returns(checkpointsQty bytes32)

Arguments

Name Type Description
date uint256
Source Code
nction numTotalStakingCheckpoints(uint256 date)
        external
        view
        returns (bytes32 checkpointsQty);

delegateStakingCheckpoints

A record of tokens to be unstaked at a given time which were delegated to a certain address. For delegatee voting power computation. Voting weights get adjusted bi-weekly.

function delegateStakingCheckpoints(address delagatee, uint256 date, uint32 index) external view
returns(struct IStaking.Checkpoint)

Arguments

Name Type Description
delagatee address
date uint256
index uint32
Source Code
nction delegateStakingCheckpoints(
        address delagatee,
        uint256 date,
        uint32 index
    ) external view returns (Checkpoint memory);

numDelegateStakingCheckpoints

The number of total staking checkpoints for each date per delegate.

function numDelegateStakingCheckpoints(address delegatee, uint256 date) external view
returns(checkpointsQty bytes32)

Arguments

Name Type Description
delegatee address
date uint256
Source Code
nction numDelegateStakingCheckpoints(address delegatee, uint256 date)
        external
        view
        returns (bytes32 checkpointsQty);

userStakingCheckpoints

A record of tokens to be unstaked at a given time which per user address (address -> lockDate -> stake checkpoint)

function userStakingCheckpoints(address user, uint256 date, uint32 index) external view
returns(struct IStaking.Checkpoint)

Arguments

Name Type Description
user address
date uint256
index uint32
Source Code
nction userStakingCheckpoints(
        address user,
        uint256 date,
        uint32 index
    ) external view returns (Checkpoint memory);

numUserStakingCheckpoints

The number of total staking checkpoints for each date per user.

function numUserStakingCheckpoints(address user, uint256 date) external view
returns(checkpointsQty uint32)

Arguments

Name Type Description
user address
date uint256
Source Code
nction numUserStakingCheckpoints(address user, uint256 date)
        external
        view
        returns (uint32 checkpointsQty);

nonces

A record of states for signing / validating signatures

function nonces(address user) external view
returns(nonce uint256)

Arguments

Name Type Description
user address
Source Code
nction nonces(address user) external view returns (uint256 nonce);

feeSharing

the address of FeeSharingCollectorProxy contract, we need it for unstaking with slashing.

function feeSharing() external view
returns(address)
Source Code
nction feeSharing() external view returns (address);

weightScaling

used for weight scaling when unstaking with slashing.

function weightScaling() external view
returns(uint96)
Source Code
nction weightScaling() external view returns (uint96);

vestingWhitelist

List of vesting contracts, tokens for these contracts won't be slashed if unstaked by governance.

function vestingWhitelist(address isWhitelisted) external view
returns(bool)

Arguments

Name Type Description
isWhitelisted address
Source Code
nction vestingWhitelist(address isWhitelisted) external view returns (bool);

admins

user => flag whether user has admin role.

function admins(address isAdmin) external view
returns(bool)

Arguments

Name Type Description
isAdmin address
Source Code
nction admins(address isAdmin) external view returns (bool);

vestingCodeHashes

vesting contract code hash => flag whether it's registered code hash

function vestingCodeHashes(bytes32 vestingLogicCodeHash) external view
returns(bool)

Arguments

Name Type Description
vestingLogicCodeHash bytes32
Source Code
nction vestingCodeHashes(bytes32 vestingLogicCodeHash) external view returns (bool);

vestingCheckpoints

A record of tokens to be unstaked from vesting contract at a given time (lockDate -> vest checkpoint)

function vestingCheckpoints(uint256 date, uint32 index) external view
returns(struct IStaking.Checkpoint)

Arguments

Name Type Description
date uint256
index uint32
Source Code
nction vestingCheckpoints(uint256 date, uint32 index)
        external
        view
        returns (Checkpoint memory);

numVestingCheckpoints

The number of total vesting checkpoints for each date.

function numVestingCheckpoints(uint256 date) external view
returns(checkpointsQty uint32)

Arguments

Name Type Description
date uint256
Source Code
nction numVestingCheckpoints(uint256 date) external view returns (uint32 checkpointsQty);

vestingRegistryLogic

vesting registry contract PROXY address

function vestingRegistryLogic() external view
returns(address)
Source Code
nction vestingRegistryLogic() external view returns (address);

pausers

user => flag whether user has pauser role.

function pausers(address isPauser) external view
returns(bool)

Arguments

Name Type Description
isPauser address
Source Code
nction pausers(address isPauser) external view returns (bool);

paused

Staking contract is paused

function paused() external view
returns(bool)
Source Code
nction paused() external view returns (bool);

frozen

Staking contract is frozen

function frozen() external view
returns(bool)
Source Code
nction frozen() external view returns (bool);

isVestingContract

Return flag whether the given address is a registered vesting contract.

function isVestingContract(address stakerAddress) external view
returns(bool)

Arguments

Name Type Description
stakerAddress address the address to check
Source Code
nction isVestingContract(address stakerAddress) external view returns (bool);

removeContractCodeHash

Remove vesting contract's code hash to a map of code hashes.

function removeContractCodeHash(address vesting) external nonpayable

Arguments

Name Type Description
vesting address The address of Vesting contract.
Source Code
nction removeContractCodeHash(address vesting) external;

addContractCodeHash

Add vesting contract's code hash to a map of code hashes.

function addContractCodeHash(address vesting) external nonpayable

Arguments

Name Type Description
vesting address The address of Vesting contract.
Source Code
nction addContractCodeHash(address vesting) external;

getPriorVestingStakeByDate

Determine the prior number of vested stake for an account until a certain lock date as of a block number.

function getPriorVestingStakeByDate(uint256 date, uint256 blockNumber) external view
returns(uint96)

Arguments

Name Type Description
date uint256 The lock date.
blockNumber uint256 The block number to get the vote balance at.

Returns

The number of votes the account had as of the given block.

Source Code
nction getPriorVestingStakeByDate(uint256 date, uint256 blockNumber)
        external
        view
        returns (uint96);

weightedVestingStakeByDate

Compute the voting power for a specific date. Power = stake * weight

function weightedVestingStakeByDate(uint256 date, uint256 startDate, uint256 blockNumber) external view
returns(power uint96)

Arguments

Name Type Description
date uint256 The staking date to compute the power for. Adjusted to the next valid lock date, if necessary.
startDate uint256 The date for which we need to know the power of the stake.
blockNumber uint256 The block number, needed for checkpointing.

Returns

The stacking power.

Source Code
nction weightedVestingStakeByDate(
        uint256 date,
        uint256 startDate,
        uint256 blockNumber
    ) external view returns (uint96 power);

getPriorVestingWeightedStake

Determine the prior weighted vested amount for an account as of a block number. Iterate through checkpoints adding up voting power.

function getPriorVestingWeightedStake(uint256 blockNumber, uint256 date) external view
returns(votes uint96)

Arguments

Name Type Description
blockNumber uint256 The block number to get the vote balance at.
date uint256 The staking date to compute the power for.

Returns

The weighted stake the account had as of the given block.

Source Code
nction getPriorVestingWeightedStake(uint256 blockNumber, uint256 date)
        external
        view
        returns (uint96 votes);

getPriorUserStakeByDate

Determine the prior number of stake for an account until a certain lock date as of a block number.

function getPriorUserStakeByDate(address account, uint256 date, uint256 blockNumber) external view
returns(uint96)

Arguments

Name Type Description
account address The address of the account to check.
date uint256 The lock date.
blockNumber uint256 The block number to get the vote balance at.

Returns

The number of votes the account had as of the given block.

Source Code
nction getPriorUserStakeByDate(
        address account,
        uint256 date,
        uint256 blockNumber
    ) external view returns (uint96);

setVestingStakes

Sets the users' vesting stakes for a giving lock dates and writes checkpoints.

function setVestingStakes(uint256[] lockedDates, uint96[] values) external nonpayable

Arguments

Name Type Description
lockedDates uint256[] The arrays of lock dates.
values uint96[] The array of values to add to the staked balance.
Source Code
nction setVestingStakes(uint256[] calldata lockedDates, uint96[] calldata values) external;

setVestingRegistry

sets vesting registry

function setVestingRegistry(address _vestingRegistryProxy) external nonpayable

Arguments

Name Type Description
_vestingRegistryProxy address the address of vesting registry proxy contract
Source Code
nction setVestingRegistry(address _vestingRegistryProxy) external;

withdraw

Withdraw the given amount of tokens if they are unlocked.

function withdraw(uint96 amount, uint256 until, address receiver) external nonpayable

Arguments

Name Type Description
amount uint96 The number of tokens to withdraw.
until uint256 The date until which the tokens were staked.
receiver address The receiver of the tokens. If not specified, send to the msg.sender
Source Code
nction withdraw(
        uint96 amount,
        uint256 until,
        address receiver
    ) external;

governanceWithdraw

Withdraw the given amount of tokens.

function governanceWithdraw(uint96 amount, uint256 until, address receiver) external nonpayable

Arguments

Name Type Description
amount uint96 The number of tokens to withdraw.
until uint256 The date until which the tokens were staked.
receiver address The receiver of the tokens. If not specified, send to the msg.sender
Source Code
nction governanceWithdraw(
        uint96 amount,
        uint256 until,
        address receiver
    ) external;

governanceWithdrawVesting

Withdraw tokens for vesting contract.

function governanceWithdrawVesting(address vesting, address receiver) external nonpayable

Arguments

Name Type Description
vesting address The address of Vesting contract.
receiver address The receiver of the tokens. If not specified, send to the msg.sender
Source Code
nction governanceWithdrawVesting(address vesting, address receiver) external;

getWithdrawAmounts

Get available and punished amount for withdrawing.

function getWithdrawAmounts(uint96 amount, uint256 until) external view
returns(uint96, uint96)

Arguments

Name Type Description
amount uint96 The number of tokens to withdraw.
until uint256 The date until which the tokens were staked.
Source Code
nction getWithdrawAmounts(uint96 amount, uint256 until)
        external
        view
        returns (uint96, uint96);

unlockAllTokens

Allow the owner to unlock all tokens in case the staking contract is going to be replaced Note: Not reversible on purpose. once unlocked, everything is unlocked. The owner should not be able to just quickly unlock to withdraw his own tokens and lock again.

function unlockAllTokens() external nonpayable
Source Code
nction unlockAllTokens() external;

getPriorWeightedStake

Determine the prior weighted stake for an account as of a block number. Iterate through checkpoints adding up voting power.

function getPriorWeightedStake(address account, uint256 blockNumber, uint256 date) external view
returns(priorWeightedStake uint96)

Arguments

Name Type Description
account address The address of the account to check.
blockNumber uint256 The block number to get the vote balance at.
date uint256 The date/timestamp of the unstaking time.

Returns

The weighted stake the account had as of the given block.

Source Code
nction getPriorWeightedStake(
        address account,
        uint256 blockNumber,
        uint256 date
    ) external view returns (uint96 priorWeightedStake);

weightedStakeByDate

Compute the voting power for a specific date. Power = stake * weight TODO: WeightedStaking::weightedStakeByDate should probably better be internal instead of a public function.

function weightedStakeByDate(address account, uint256 date, uint256 startDate, uint256 blockNumber) external view
returns(power uint96)

Arguments

Name Type Description
account address The user address.
date uint256 The staking date to compute the power for.
startDate uint256 The date for which we need to know the power of the stake.
blockNumber uint256 The block number, needed for checkpointing.

Returns

The stacking power.

Source Code
nction weightedStakeByDate(
        address account,
        uint256 date,
        uint256 startDate,
        uint256 blockNumber
    ) external view returns (uint96 power);

computeWeightByDate

Compute the weight for a specific date.

function computeWeightByDate(uint256 date, uint256 startDate) external pure
returns(weight uint96)

Arguments

Name Type Description
date uint256 The unlocking date.
startDate uint256 We compute the weight for the tokens staked until 'date' on 'startDate'.

Returns

The weighted stake the account had as of the given block.

Source Code
nction computeWeightByDate(uint256 date, uint256 startDate)
        external
        pure
        returns (uint96 weight);

MAX_DURATION

Returns public constant MAX_DURATION preserved for backwards compatibility Use getStorageMaxDurationToStakeTokens()

function MAX_DURATION() external view
returns(uint256)
Source Code
nction MAX_DURATION() external view returns (uint256);

owner

Returns the address of the current owner.

function owner() external view
returns(address)
Source Code
nction owner() external view returns (address);

isOwner

Returns true if the caller is the current owner.

function isOwner() external view
returns(bool)
Source Code
nction isOwner() external view returns (bool);

transferOwnership

Transfers ownership of the contract to a new account (newOwner). Can only be called by the current owner.

function transferOwnership(address newOwner) external nonpayable

Arguments

Name Type Description
newOwner address
Source Code
nction transferOwnership(address newOwner) external;

cancelTeamVesting

Governance withdraw vesting directly through staking contract. This direct withdraw vesting solves the out of gas issue when there are too many iterations when withdrawing. This function only allows cancelling vesting contract of the TeamVesting type. *

function cancelTeamVesting(address vesting, address receiver, uint256 startFrom) external nonpayable

Arguments

Name Type Description
vesting address The vesting address.
receiver address The receiving address.
startFrom uint256 The start value for the iterations.
Source Code
nction cancelTeamVesting(
        address vesting,
        address receiver,
        uint256 startFrom
    ) external;

getMaxVestingWithdrawIterations

Max iteration for direct withdrawal from staking to prevent out of gas issue. *

function getMaxVestingWithdrawIterations() external view
returns(uint256)
Source Code
nction getMaxVestingWithdrawIterations() external view returns (uint256);

setMaxVestingWithdrawIterations

set max withdraw iterations. *

function setMaxVestingWithdrawIterations(uint256 maxIterations) external nonpayable

Arguments

Name Type Description
maxIterations uint256 new max iterations value.
Source Code
nction setMaxVestingWithdrawIterations(uint256 maxIterations) external;
}

Contracts