Staking Workflows
Staking Workflows for Function Network
Below are detailed workflows for registering, staking, unstaking, claiming rewards, and winding down for both Gateways and Providers within the Function Network.
Gateway Staking Workflows
1. Registering a Gateway
Gateways must be registered before staking FUNC tokens. Registration associates metadata and allows the Gateway to participate in the network.
Steps
Call
register
inGatewayRegistry
:Provide a unique
id
(max 64 bytes) and optional metadata (max 1024 bytes).Metadata is intended for descriptive information about the Gateway, such as its role or identifier.
Auto-whitelisting (if enabled):
The gateway will automatically be whitelisted for participation.
Emit event:
GatewayRegistered
.
Example:
2. Staking FUNC for a Gateway
Once registered, the Gateway owner can stake FUNC tokens to participate in the network.
Steps
Determine Stake Amount:
Ensure you have enough FUNC tokens to stake.
Transfer FUNC tokens to the
GatewayRegistry
contract.
Call
registerAndStake
:Provide the
id
, metadata, and amount of FUNC tokens to stake.
Auto-update Staking Contract:
The FUNC tokens are approved and forwarded to the
GatewayStaking
contract.
Emit event:
GatewayRegisteredAndStaked
.
Example:
3. Wind Down a Gateway
Gateways must be wound down before they can be unstaked. This marks the gateway for eventual deactivation.
Steps
Call
windDownGateways
inGatewayStaking
:Provide a list of gateway IDs to wind down.
Wait for the wind-down delay:
A specified delay period (defined in
EpochController
) must pass before the gateway can be unstaked.
Emit event:
GatewayWoundDown
.
Example:
4. Unstaking a Gateway
To retrieve staked FUNC tokens, the gateway must complete the wind-down and lock periods defined by the system.
Steps
Ensure Wind-Down Delay is Complete:
Gateways must meet the wind-down delay requirement before unstaking.
Ensure Minimum Lock Period Elapsed:
Gateways must also meet the
minEpochsLocked
requirement.
Call
unstakeForGateway
inGatewayStaking
:Provide the
id
of the gateway to unstake FUNC.
FUNC Transfer:
The FUNC tokens are transferred back to the gateway owner.
Emit event:
GatewayUnstaked
.
Example:
5. Claiming Rewards
Gateways earn FUNC rewards based on compute usage and participation metrics.
Steps
Ensure Rewards Are Delayed:
Rewards can only be claimed for epochs up to
currentEpoch - epochRewardDelay
as defined inEpochController
.
Call
claimRewards
inGatewayStaking
:Provide the
id
and range of epochs for claiming rewards.
Emit event:
GatewayClaimedRewards
.
Provider Staking Workflows
1. Registering a Provider
Providers must be linked to a specific model and registered before staking.
Steps
Call
register
inProviderRegistry
:Provide a unique
id
(max 64 bytes),modelId
, and optional metadata.Metadata: The metadata field for a provider is intended to be the URL to access the provider's node, enabling connection to its services.
Auto-whitelisting (if enabled):
The provider will automatically be whitelisted for participation.
Emit event:
ProviderRegistered
.
2. Staking FUNC for a Provider
Providers must meet the required stake amount defined by the model.
Steps
Determine Stake Amount:
Check the model's required stake amount using
modelStakeAmount
.
Call
registerAndStake
:Provide the
id
,modelId
, metadata, and FUNC stake amount.
Emit event:
ProviderRegisteredAndStaked
.
Example:
3. Unstaking a Provider
To retrieve staked FUNC tokens, providers must ensure all lock periods and requirements are met.
Steps
Ensure Minimum Lock Period Elapsed:
Providers must meet the
minEpochsLocked
requirement.
Call
unstakeProvider
inProviderStaking
:Provide the
id
of the provider to unstake FUNC.
FUNC Transfer:
The FUNC tokens are transferred back to the provider owner.
Emit event:
ProviderUnstaked
.
Example:
4. Claiming Rewards
Providers earn FUNC rewards based on shard contributions and participation metrics.
Steps
Ensure Rewards Are Delayed:
Rewards can only be claimed for epochs up to
currentEpoch - epochRewardDelay
as defined inEpochController
.
Call
claimRewardsCluster
:Provide the range of epochs to claim rewards for all providers owned by the caller.
Emit event:
RewardClaimedForCluster
.
Example:
Common Notes
Wind-Down Delay: Gateways must wait a specified number of epochs after calling
windDownGateways
before unstaking.Minimum Epochs Locked: Applies to both Gateways and Providers. Check this value using
minEpochsLocked
inEpochController
.Reward Delay: Rewards can only be claimed for epochs up to
currentEpoch - epochRewardDelay
.Provider Metadata: The metadata for a provider is typically the URL to access its node, enabling external systems to connect and send inference requests.
FUNC Token Approvals: Always approve FUNC transfers before staking.
Provider and Gateway Active Status
Provider Active Status
A Provider is considered Active if the following conditions are met:
Registered: The provider has been registered in the Function Network.
Not Deactivated: The provider has not been explicitly deactivated.
Sufficiently Staked: The provider has staked an amount of FUNC tokens equal to or greater than the
modelStakeAmount
for the associated model.Whitelisted: The provider is whitelisted.
Model is Active: The model associated with the provider is enabled and functional.
Gateway Active Status
A Gateway is considered Active if the following conditions are met:
Registered: The gateway has been registered in the Function Network.
Not Deactivated: The gateway has not been explicitly deactivated.
Effective Stake Amount: The gateway has an effective stake balance that is not overdrawn.
Whitelisted: The gateway is whitelisted.
Last updated