EncodableSettings
UNUSED_SPACE_RIGHT_UINT8
uint256 UNUSED_SPACE_RIGHT_UINT8
UNUSED_SPACE_RIGHT_UINT16
uint256 UNUSED_SPACE_RIGHT_UINT16
UNUSED_SPACE_RIGHT_UINT64
uint256 UNUSED_SPACE_RIGHT_UINT64
INDEX_RIGHT_HEDRON_TIP
uint256 INDEX_RIGHT_HEDRON_TIP
INDEX_RIGHT_TARGET_TIP
uint256 INDEX_RIGHT_TARGET_TIP
INDEX_LEFT_TARGET_TIP
uint256 INDEX_LEFT_TARGET_TIP
INDEX_RIGHT_NEW_STAKE
uint256 INDEX_RIGHT_NEW_STAKE
INDEX_LEFT_NEW_STAKE
uint256 INDEX_LEFT_NEW_STAKE
INDEX_RIGHT_NEW_STAKE_DAYS_METHOD
uint256 INDEX_RIGHT_NEW_STAKE_DAYS_METHOD
INDEX_RIGHT_NEW_STAKE_DAYS_MAGNITUDE
uint256 INDEX_RIGHT_NEW_STAKE_DAYS_MAGNITUDE
INDEX_RIGHT_COPY_ITERATIONS
uint256 INDEX_RIGHT_COPY_ITERATIONS
INDEX_RIGHT_HAS_EXTERNAL_TIPS
uint256 INDEX_RIGHT_HAS_EXTERNAL_TIPS
INDEX_RIGHT_COPY_EXTERNAL_TIPS
uint256 INDEX_RIGHT_COPY_EXTERNAL_TIPS
INDEX_RIGHT_STAKE_IS_TRANSFERABLE
uint256 INDEX_RIGHT_STAKE_IS_TRANSFERABLE
INDEX_LEFT_STAKE_IS_TRANSFERABLE
uint256 INDEX_LEFT_STAKE_IS_TRANSFERABLE
INDEX_RIGHT_SHOULD_SEND_TOKENS_TO_STAKER
uint256 INDEX_RIGHT_SHOULD_SEND_TOKENS_TO_STAKER
INDEX_RIGHT_CAN_MINT_HEDRON_AT_END
uint256 INDEX_RIGHT_CAN_MINT_HEDRON_AT_END
INDEX_RIGHT_CAN_MINT_HEDRON
uint256 INDEX_RIGHT_CAN_MINT_HEDRON
INDEX_RIGHT_CAN_EARLY_STAKE_END
uint256 INDEX_RIGHT_CAN_EARLY_STAKE_END
INDEX_RIGHT_CAN_STAKE_END
uint256 INDEX_RIGHT_CAN_STAKE_END
ConsentAbilities
struct ConsentAbilities {
bool canStakeEnd;
bool canEarlyStakeEnd;
bool canMintHedron;
bool canMintHedronAtEnd;
bool shouldSendTokensToStaker;
bool stakeIsTransferable;
bool copyExternalTips;
bool hasExternalTips;
}
Settings
struct Settings {
struct Magnitude.Linear hedronTip;
struct Magnitude.Linear targetTip;
struct Magnitude.Linear newStake;
uint256 newStakeDaysMethod;
uint256 newStakeDaysMagnitude;
uint256 copyIterations;
struct EncodableSettings.ConsentAbilities consentAbilities;
}
stakeIdToSettings
mapping(uint256 => uint256) stakeIdToSettings
UpdateSettings
event UpdateSettings(uint256 stakeId, uint256 settings)
an event to signal that settings to direct funds
at the end of a stake have been updated
Parameters
Name |
Type |
Description |
stakeId |
uint256 |
the stake id that was updated |
settings |
uint256 |
the newly updated settings |
defaultEncodedSettings
function defaultEncodedSettings() external pure virtual returns (uint256)
Return Values
Name |
Type |
Description |
[0] |
uint256 |
the default encoded settings used by end stakers to tip and end stakes |
stakeIdSettings
function stakeIdSettings(uint256 stakeId) external view returns (struct EncodableSettings.Settings)
access settings of a stake id and decode it, returning the decoded settings struct
Parameters
Name |
Type |
Description |
stakeId |
uint256 |
the stake id to access and decode |
Return Values
Name |
Type |
Description |
[0] |
struct EncodableSettings.Settings |
decoded settings struct that holds all configuration by owner |
decodeConsentAbilities
function decodeConsentAbilities(uint256 abilities) external pure returns (struct EncodableSettings.ConsentAbilities)
decode a uint's first byte as consent abilities struct
Parameters
Name |
Type |
Description |
abilities |
uint256 |
encoded consent abilities to decode |
Return Values
Name |
Type |
Description |
[0] |
struct EncodableSettings.ConsentAbilities |
a ConsentAbilities struct with flags appropriately set |
_decodeConsentAbilities
function _decodeConsentAbilities(uint256 abilities) internal pure returns (struct EncodableSettings.ConsentAbilities)
decode a uint's first byte as consent abilities struct
Parameters
Name |
Type |
Description |
abilities |
uint256 |
encoded consent abilities to decode |
Return Values
Name |
Type |
Description |
[0] |
struct EncodableSettings.ConsentAbilities |
a ConsentAbilities struct with flags appropriately set |
updateSettings
function updateSettings(uint256 stakeId, struct EncodableSettings.Settings settings) external payable virtual
updates settings under a stake id to the provided settings struct
payable is only available to reduce costs, any native token
sent to this method will be unattributed and claimable by anyone
Parameters
Name |
Type |
Description |
stakeId |
uint256 |
the stake id to update |
settings |
struct EncodableSettings.Settings |
the settings to update the stake id to |
updateSettingsEncoded
function updateSettingsEncoded(uint256 stakeId, uint256 settings) external payable virtual
update a stake's settings by providing a new, encoded value
Parameters
Name |
Type |
Description |
stakeId |
uint256 |
the stake id to update settings for |
settings |
uint256 |
the settings value to update settings for |
_updateSettingsEncoded
function _updateSettingsEncoded(uint256 stakeId, uint256 settings) internal
update a stake's setting by providing a uint256 encoded settings
This method will validate that the msg.sender owns the stake
Parameters
Name |
Type |
Description |
stakeId |
uint256 |
the stake id to update settings for |
settings |
uint256 |
the encoded settings to update to (7th index is maintained) |
_logPreservedSettingsUpdate
function _logPreservedSettingsUpdate(uint256 stakeId, uint256 settings) internal
updates a stake id's settings
Parameters
Name |
Type |
Description |
stakeId |
uint256 |
the stake id to update settings for |
settings |
uint256 |
the settings to update against a provided stakeId. 7th index will be ignored as it is controlled by the contract |
_logSettingsUpdate
function _logSettingsUpdate(uint256 stakeId, uint256 settings) internal
update the settings for a stake id
Parameters
Name |
Type |
Description |
stakeId |
uint256 |
the stake id to update settings for |
settings |
uint256 |
an object that holds settings values to inform end stakers how to handle the stake |
readEncodedSettings
function readEncodedSettings(uint256 settings, uint256 fromEnd, uint256 length) external pure returns (uint256)
read a single property from encoded settings
most useful for other contracts to pull out 1 property without
needing logic for parsing
Parameters
Name |
Type |
Description |
settings |
uint256 |
the settings number to read 1 property from |
fromEnd |
uint256 |
the index from the end to start at |
length |
uint256 |
the number of bits to read |
_readEncodedSettings
function _readEncodedSettings(uint256 settings, uint256 fromEnd, uint256 length) internal pure returns (uint256)
parse out a single value from an encoded settings uint Only useful
if you do not want the whole settings struct to be decoded
Parameters
Name |
Type |
Description |
settings |
uint256 |
the settings value to parse out |
fromEnd |
uint256 |
the index (from left) to start at. Left most is 0 |
length |
uint256 |
the number of bits to retain after the fromEnd param |
Return Values
Name |
Type |
Description |
[0] |
uint256 |
the uint retained by the fromEnd and length arguments of settings |
encodeSettings
function encodeSettings(struct EncodableSettings.Settings settings) external pure returns (uint256 encoded)
encode a settings struct into it's number
Parameters
Name |
Type |
Description |
settings |
struct EncodableSettings.Settings |
the settings struct to be encoded into a number |
Return Values
Name |
Type |
Description |
encoded |
uint256 |
a uint256 expression of settings struct |
_encodeSettings
function _encodeSettings(struct EncodableSettings.Settings settings) internal pure returns (uint256 encoded)
encode a settings struct as a uint value to fit it within 1 word
Parameters
Name |
Type |
Description |
settings |
struct EncodableSettings.Settings |
the settings struct to encode as a uint |
Return Values
Name |
Type |
Description |
encoded |
uint256 |
a uint256 expression of settings struct |
decodeSettings
function decodeSettings(uint256 encoded) external pure returns (struct EncodableSettings.Settings settings)
decode an encoded setting into it's settings struct
Parameters
Name |
Type |
Description |
encoded |
uint256 |
the encoded setting to decode |
Return Values
Name |
Type |
Description |
settings |
struct EncodableSettings.Settings |
the decoded settings struct |
_decodeSettings
function _decodeSettings(uint256 encoded) internal pure returns (struct EncodableSettings.Settings settings)
decode a settings struct (2 words minimum) from a single uint256
Parameters
Name |
Type |
Description |
encoded |
uint256 |
a number that represents all data needed for an encoded settings struct |
encodeConsentAbilities
function encodeConsentAbilities(struct EncodableSettings.ConsentAbilities consentAbilities) external pure returns (uint256)
encode a ConsentAbilities struct to fit in 1 byte
Parameters
Name |
Type |
Description |
consentAbilities |
struct EncodableSettings.ConsentAbilities |
the consent abilities struct to encode as a uint |
Return Values
Name |
Type |
Description |
[0] |
uint256 |
the encoded list of consetn abilities as a uint |
_encodeConsentAbilities
function _encodeConsentAbilities(struct EncodableSettings.ConsentAbilities consentAbilities) internal pure returns (uint256)
encode a struct of consent abilities to fit in 1 byte
Parameters
Name |
Type |
Description |
consentAbilities |
struct EncodableSettings.ConsentAbilities |
encodes a struct of 8 booleans as a uint to fit in 1 byte |
Return Values
Name |
Type |
Description |
[0] |
uint256 |
the encoded list of consent abilities as a uint |
_defaultSettings
function _defaultSettings() internal pure virtual returns (struct EncodableSettings.Settings settings)
gets default settings struct
Return Values
Name |
Type |
Description |
settings |
struct EncodableSettings.Settings |
struct with default settings |
decrementCopyIterations
function decrementCopyIterations(uint256 settings) external pure returns (uint256)
modify the second byteword from the right to appropriately decrement
the number of times that these settings should be copied
Parameters
Name |
Type |
Description |
settings |
uint256 |
the settings to start with - only the 2nd byte from the right is modified |
_decrementCopyIterations
function _decrementCopyIterations(uint256 settings) internal pure returns (uint256)
decrement the 2nd byte from the right if the value is < 255
Parameters
Name |
Type |
Description |
settings |
uint256 |
the settings to start with - only the 2nd byte from the right is modified |
Return Values
Name |
Type |
Description |
[0] |
uint256 |
updated encoded settings with appropriately decremented value |
defaultSettings
function defaultSettings() external pure virtual returns (struct EncodableSettings.Settings)
exposes the default settings to external for ease of access
Return Values
Name |
Type |
Description |
[0] |
struct EncodableSettings.Settings |
a settings struct with default values |