# StakeManager

The StakeManager implementation

An IStakeManager instance that accepts stakes in any ERC-20 token.

Single StakeInfo of a single RelayManager can only have one token address assigned to it.

It cannot be changed after the first time 'stakeForRelayManager' is called as it is equivalent to withdrawal.

# Functions

# getStakeInfo(address relayManager)

→ struct IStakeManager.StakeInfo stakeInfo, bool isSenderAuthorizedHub (external)

Get the stake details information for the given Relay Manager.

relayManager: The address of a Relay Manager.

# Return values

The StakeInfo structure.

true if the msg.sender for this call was a RelayHub that is authorized now. false if the msg.sender for this call is not authorized.


# setBurnAddress(address _burnAddress)

(public)

Change the address that will receive the 'burned' part of the penalized stake. This is done to prevent malicious Relay Server from penalizing itself and breaking even.


# getBurnAddress()

→ address (external)

# Return values

address that will receive the 'burned' part of the penalized stake.


# setDevAddress(address _devAddress)

(public)

Change the address that will receive the 'abandoned' stake. This is done to prevent Relay Servers that lost their keys from losing access to funds.


# getAbandonedRelayServerConfig()

→ struct IStakeManager.AbandonedRelayServerConfig (external)

# Return values

structure that contains all configuration values for the 'abandoned' stake.


# getMaxUnstakeDelay()

→ uint256 (external)

# Return values

maximum unstake delay this StakeManger allows. This is to prevent locking money forever by mistake.


# constructor(uint256 _maxUnstakeDelay, uint256 _abandonmentDelay, uint256 _escheatmentDelay, address _burnAddress, address _devAddress)

(public)


# supportsInterface(bytes4 interfaceId)

→ bool (public)

Returns true if this contract implements the interface defined by interfaceId. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.


# getCreationBlock()

→ uint256 (external)

# Return values

block number in which the contract has been deployed.


# setRelayManagerOwner(address owner)

(external)

Set the owner of a Relay Manager. Called only by the RelayManager itself. Note that owners cannot transfer ownership - if the entry already exists, reverts.

owner: - owner of the relay (as configured off-chain)


# stakeForRelayManager(contract IERC20 token, address relayManager, uint256 unstakeDelay, uint256 amount)

(external)

Put a stake for a relayManager and set its unstake delay. Only the owner can call this function. If the entry does not exist, reverts. The owner must give allowance of the ERC-20 token to the StakeManager before calling this method. It is the RelayHub who has a configurable list of minimum stakes per token. StakeManager accepts all tokens.

token: The address of an ERC-20 token that is used by the relayManager as a stake

relayManager: The address that represents a stake entry and controls relay registrations on relay hubs

unstakeDelay: The number of seconds to elapse before an owner can retrieve the stake after calling unlock

amount: The amount of tokens to be taken from the relayOwner and locked in the StakeManager as a stake


# unlockStake(address relayManager)

(external)

Schedule the unlocking of the stake. The unstakeDelay must pass before owner can call withdrawStake.

relayManager: The address of a Relay Manager whose stake is to be unlocked.


# withdrawStake(address relayManager)

(external)

Withdraw the unlocked stake.

relayManager: The address of a Relay Manager whose stake is to be withdrawn.


# authorizeHubByOwner(address relayManager, address relayHub)

(external)

Add the RelayHub to a list of authorized by this Relay Manager. This allows the RelayHub to penalize this Relay Manager. The RelayHub cannot trust a Relay it cannot penalize.

relayManager: The address of a Relay Manager whose stake is to be authorized for the new RelayHub.

relayHub: The address of a RelayHub to be authorized.


# authorizeHubByManager(address relayHub)

(external)

Same as authorizeHubByOwner but can be called by the RelayManager itself.


# _authorizeHub(address relayManager, address relayHub)

(internal)


# unauthorizeHubByOwner(address relayManager, address relayHub)

(external)

Remove the RelayHub from a list of authorized by this Relay Manager.

relayManager: The address of a Relay Manager.

relayHub: The address of a RelayHub to be unauthorized.


# unauthorizeHubByManager(address relayHub)

(external)

Same as unauthorizeHubByOwner but can be called by the RelayManager itself.


# _unauthorizeHub(address relayManager, address relayHub)

(internal)


# penalizeRelayManager(address relayManager, address beneficiary, uint256 amount)

(external)

Slash the stake of the relay relayManager. In order to prevent stake kidnapping, burns part of stake on the way.

relayManager: The address of a Relay Manager to be penalized.

beneficiary: The address that receives part of the penalty amount.

amount: A total amount of penalty to be withdrawn from stake.


# isRelayEscheatable(address relayManager)

→ bool (public)

Check if the Relay Manager can be considered abandoned or not. Returns true if the stake's abandonment time is in the past including the escheatment delay, false otherwise.


# markRelayAbandoned(address relayManager)

(external)

Allows the contract owner to set the given relayManager as abandoned after a configurable delay. Its entire stake and balance will be taken from a relay if it does not respond to being marked as abandoned.


# escheatAbandonedRelayStake(address relayManager)

(external)

If more than abandonmentDelay has passed since the last Keepalive transaction, and relay manager has been marked as abandoned, and after that more that escheatmentDelay have passed, entire stake and balance will be taken from this relay.


# updateRelayKeepaliveTime(address relayManager)

(external)

Sets a new keepaliveTime for the given relayManager, preventing it from being marked as abandoned. Can be called by an authorized RelayHub or by the relayOwner address.


# Modifiers

# relayOwnerOnly(address relayManager)

Prevents any address other than a registered Relay Owner from calling this method.


# managerOnly()

Prevents any address other than a registered Relay Manager from calling this method.