stkBPT

This contract handles the staking functionality for the Balancer Pool Tokens. Contracts are upgradable.

Contract: StakedTokenBPT.sol

Some functions of this token contract can only be called from a whitelisted smart contract. Please contract mStable directly if an integration should be whitelisted.

Functions Staked Token

function stake (uint256 _amount) external

Stake an _amount of STAKED_TOKEN in the system. This amount is added to the users stake andboosts their voting power.

Parameter

Type

Description

_amount

uint256

Units of STAKED_TOKEN to stake

stake()

function stake (uint256 _amount, bool _exitCooldown) external

Stake an _amount of STAKED_TOKEN in the system. This amount is added to the users stake andboosts their voting power.

Parameter

Type

Description

_amount

uint256

Units of STAKED_TOKEN to stake

_exitCooldown

bool

Bool signalling whether to take this opportunity to end any outstanding cooldown andreturn the user back to their full voting power

stake()

function stake (uint256 _amount, address _delegatee) external

Stake an _amount of STAKED_TOKEN in the system. This amount is added to the users stake andboosts their voting power. Take the opportunity to change delegatee.

Parameter

Type

Description

_amount

uint256

Units of STAKED_TOKEN to stake

_delegatee

address

Address of the user to whom the sender would like to delegate their voting power

withdraw()

function withdraw (uint256 _amount, address _recipient, bool _amountIncludesFee, bool _exitCooldown) external

Withdraw raw tokens from the system, following an elapsed cooldown period.Note - May be subject to a transfer fee, depending on the users weightedTimestamp

Parameter

Type

Description

_amount

uint256

Units of raw token to withdraw

_recipient

address

Address of beneficiary who will receive the raw tokens

_amountIncludesFee

bool

Is the _amount specified inclusive of any applicable redemption fee?

_exitCooldown

bool

Should we take this opportunity to exit the cooldown period?

startCooldown()

function startCooldown (uint256 _units) external

Enters a cooldown period, after which (and before the unstake window elapses) a user will be ableto withdraw part or all of their staked tokens. Note, during this period, a users voting power is significantly reduced.If a user already has a cooldown period, then it will reset to the current block timestamp, so use wisely.

Parameter

Type

Description

_units

uint256

Units of stake to cooldown for

endCooldown()

function endCooldown () external

Ends the cooldown of the sender and give them back their full voting power. This can be used to signal thatthe user no longer wishes to exit the system. Note, the cooldown can also be reset, more smoothly, as part of a stake orwithdraw transaction.

createLock()

function createLock (uint256 _value) external

Allows for backwards compatibility with createLock fn, giving basic args to stake

Parameter

Type

Description

_value

uint256

Units to stake

increaseLockAmount()

function increaseLockAmount (uint256 _value) external

Allows for backwards compatibility with increaseLockAmount fn by simply staking more

Parameter

Type

Description

_value

uint256

Units to stake

exit()

function exit () external

Backwards compatibility. Previously a lock would run out and a user would call this. Now, it will take 2 callsto exit in order to leave. The first will initiate the cooldown period, and the second will execute a full withdrawal.

calcRedemptionFeeRate()

function calcRedemptionFeeRate (uint32 _weightedTimestamp) public returns (uint256 _feeRate)

fee = sqrt(300/x)-2.5, where x = weeks since user has staked

Parameter

Type

Description

_weightedTimestamp

uint32

The users weightedTimestamp

convertFees()

function convertFees () external

Converts fees accrued in BPT into MTA, before depositing to the rewards contract

getProspectivePriceCoefficient()

function getProspectivePriceCoefficient () public returns (uint256 newPriceCoeff)

Fetches most recent priceCoeff from the balancer pool.

PriceCoeff = units of MTA per BPT, scaled to 1:1 = 10000Assuming an 80/20 BPT, it is possible to calculatePriceCoeff (p) = balanceOfMTA in pool (b) / bpt supply (s) / 0.8p = b * 1.25 / s

Functions Gamified Token

name()

function name () public returns (string)

symbol()

function symbol () public returns (string)

balanceOf()

function balanceOf () public returns (uint256)

Simply gets scaled balance

rawBalanceOf()

function rawBalanceOf () public returns (uint256, uint256)

Simply gets raw balance

balanceData()

function balanceData () external returns (struct Balance)

Raw staked balance without any multipliers

userPriceCoeff()

function userPriceCoeff () external returns (uint256)

Raw staked balance without any multipliers

reviewTimestamp()

function reviewTimestamp () external

Called by anyone to poke the timestamp of a given account. This allows users to effectively 'claim' any new time Multiplier but will revert if there is no change there.

Function Gamified Voting Token

checkpoints()

function checkpoints () public returns (struct GamifiedVotingToken.Checkpoint)

Get the pos-th checkpoint for account.

numCheckpoints()

function numCheckpoints () public returns (uint32)

Get number of checkpoints for account.

delegates()

function delegates (address delegator) public returns (address)

Get the address the delegator is currently delegating to. Return the delegator account if not delegating to anyone.

Parameter

Type

Description

delegator

address

the account that is delegating the votes from

getVotes()

function getVotes () public returns (uint256)

Gets the current votes balance for account

getPastVotes()

function getPastVotes () public returns (uint256)

Retrieve the number of votes for account at the end of blockNumber.Requirements:- blockNumber must have been already mined

getPastTotalSupply()

function getPastTotalSupply () public returns (uint256)

Retrieve the totalSupply at the end of blockNumber. Note, this value is the sum of all balances. It is but NOT the sum of all the delegated votes! Requirements:- blockNumber must have been already mined

totalSupply()

function totalSupply () public returns (uint256)

Total sum of all scaled balances

delegate()

function delegate (address delegatee) public

Delegate votes from the sender to delegatee.If delegatee is zero, the sender gets the voting power.

Parameter

Type

Description

delegatee

address

account that gets the voting power.

Function Headless Staking Reward

claimReward()

function claimReward () public

Claims outstanding rewards for the sender.First updates outstanding reward allocation and then transfers.

getRewardToken()

function getRewardToken () external returns (contract IERC20)

Gets the RewardsToken

lastTimeRewardApplicable()

function lastTimeRewardApplicable () public returns (uint256)

Gets the last applicable timestamp for this reward period

rewardPerToken()

function rewardPerToken () public returns (uint256)

Calculates the amount of unclaimed rewards per token since last update,and sums with stored to give the new cumulative reward per token

earned()

function earned (address _account) public returns (uint256)

Calculates the amount of unclaimed rewards a user has earned

Parameter

Type

Description

_account

address

User address

Last updated