Staking Functions
The Staking Functions in the sMATE contract enable users to stake MATE tokens through different access paths (administrative, presale, and public), process transactions securely with signature verification, manage cooldown periods, and distribute appropriate rewards while maintaining historical records of all operations.
Key Requirements:
- Minimum Holding: Users and services must possess 5083 MATE tokens in the EVVM system to initiate staking.
- Transaction Security: All nonce operations within the sMATE contract are processed asynchronously to ensure transaction integrity and prevent replay attacks.
goldenStaking
Function Type: external
Function Signature: goldenStaking(bool,uint256,bytes)
Function Selector: 0x475c31ff
The goldenStaking
function provides administrative control over staking operations. It is exclusively accessible to the goldenFisher
address, allowing privileged execution of stake/unstake actions that bypass standard verification (signature and nonce) requirements. This function operates under strict security parameters, prohibiting priority fees and processing payments via synchronous EVVM nonces.
Parameters
Parameter | Type | Description |
---|---|---|
_isStaking | bool | true = Stake, false = Unstake |
_amountOfSMate | uint256 | sMATE quantity (bypasses standard limits) |
_signature_Evvm | bytes | EVVM authorization signature. |
The EVVM payment signature (_signature_Evvm
) follows the Single Payment Signature Structure.
Workflow
Staking Process
- Authorization Validation: Verifies caller is the designated
goldenFisher
address - Process Execution: Invokes internal
stakingProcess
to:- Adjust staking balances
- Update historical records
- Handle unstaking cooldowns
- Manage re-staking restrictions
- Process payment via EVVM
- Distribute applicable rewards
For detailed information about the stakingProcess
implementation, refer to the Staking Process section.
Unstaking Process
- Authorization Validation: Verifies caller is the designated
goldenFisher
address - Process Execution: Invokes internal
stakingProcess
to:- Adjust staking balances
- Update historical records
- Manage unstaking cooldowns
- Handle re-staking restrictions
- Distribute applicable rewards
For detailed information about the stakingProcess
implementation, refer to the Staking Process section.
presaleStaking
Function Type: external
Function Signature: presaleStaking(bool,address,uint256,bytes,uint256,uint256,bool,bytes)
Function Selector: 0x6257deec
The presaleStaking
function enables presale participants to stake or unstake their MATE tokens under specific restrictions. This function ensures exclusive access for qualifying presale users while enforcing operational limits.
Restrictions
- Limited to one operation per transaction
- Maximum allocation of 2 sMATE tokens per user
- Requires active
allowPresaleStaking
flag - Not available when
allowPublicStaking
flag is active (presale users must usepublicStaking
instead)
Parameters
Parameter | Type | Description |
---|---|---|
_isStaking | bool | true = Stake, false = Unstake |
_user | address | Presale participant's wallet address |
_nonce | uint256 | sMATE contract nonce for replay protection |
_signature | bytes | User authorization signature |
_priorityFee_Evvm | uint256 | EVVM priority fee |
_nonce_Evvm | uint256 | EVVM payment operation nonce |
_priority_Evvm | bool | EVVM execution mode (true = async, false = sync) |
_signature_Evvm | bytes | EVVM payment authorization |
- If you want to know more about the signature structure, refer to the Staking/Unstaking Signature Structure.
- The EVVM payment signature (
_signature_Evvm
) follows the Single Payment Signature Structure.
Workflow
The function supports two execution paths:
- Fisher-Mediated: A designated fisher captures the transaction from the fishing spot and submits it to the contract
- Direct User Submission: The user directly submits the transaction to the contract
Staking Process
- Signature Verification: Validates the authenticity of the user signature
- Nonce Validation: Confirms the contract nonce is valid and unused
- Presale Eligibility Check: Verifies presale participation status and token limit compliance
- Presale Staking Status: Verifies
allowPresaleStaking.flag
is enabled - Process Execution: Calls the internal
stakingProcess
function to handle:- Historical record updates
- Unstaking cooldown management
- Re-staking restrictions
- EVVM payment processing
- Reward distribution
- Nonce Update: Increments the contract nonce for the user to prevent replay attacks
For detailed information about the stakingProcess
function, refer to the Staking Process section.
Unstaking Process
- Signature Verification: Validates the authenticity of the user signature
- Nonce Validation: Confirms the contract nonce is valid and unused
- Presale Eligibility Check: Verifies presale participation status and token limit compliance
- Presale Staking Status: Verifies
allowPresaleStaking.flag
is enabled - Process Execution: Calls the internal
stakingProcess
function to handle:- Historical record updates
- Unstaking cooldown management
- Re-staking restrictions
- EVVM payment processing
- Reward distribution
- Nonce Update: Increments the contract nonce for the user to prevent replay attacks
For detailed information about the stakingProcess
function, refer to the Staking Process section.
presaleClaims
Function Type: internal
The presaleClaims
function enforces participation rules for presale stakers by validating eligibility conditions before allowing staking or unstaking operations.
Parameters
Parameter | Type | Description |
---|---|---|
_isStaking | bool | true = Stake, false = Unstake |
_user | address | User address |
Workflow
- Public Staking Status: Verifies
allowPublicStaking.flag
is disabled (presale staking is only valid when public staking is not active) - Presale Participant Verification: Confirms the user is registered as a presale participant
- Token Limit Enforcement: Ensures the user has not exceeded the 2 sMATE maximum allocation
publicStaking
Function Type: external
Function Signature: publicStaking(bool,address,uint256,uint256,bytes,uint256,uint256,bool,bytes)
Function Selector: 0x21cc1749
The publicStaking
function enables universal access to MATE token staking when the allowPublicStaking.flag
is enabled, regardless of presale participation status or account type.
Parameters
Parameter | Type | Description |
---|---|---|
_isStaking | bool | true = Stake, false = Unstake |
_user | address | User address |
_nonce | uint256 | sMATE contract nonce for replay protection |
_amountOfSMate | uint256 | Amount of sMATE tokens to stake/unstake |
_signature | bytes | sMATE contract signature for replay protection |
_priorityFee_Evvm | uint256 | EVVM priority fee |
_nonce_Evvm | uint256 | EVVM payment operation nonce |
_priority_Evvm | bool | EVVM execution mode (true = async, false = sync) |
_signature_Evvm | bytes | EVVM payment authorization |
- If you want to know more about the signature structure, refer to the Staking/Unstaking Signature Structure.
- The EVVM payment signature (
_signature_Evvm
) follows the Single Payment Signature Structure.
Workflow
The function supports two execution paths:
- Fisher-Mediated: A designated fisher captures the transaction from the fishing spot and submits it to the contract
- Direct User Submission: The user directly submits the transaction to the contract
Staking Process
- Feature Status Verification: Confirms
allowPublicStaking.flag
is enabled - Signature Verification: Validates the authenticity of the user signature
- Nonce Validation: Confirms the contract nonce is valid and unused
- Process Execution: Calls the internal
stakingProcess
function to handle:- Historical record updates
- Unstaking cooldown management
- Re-staking restrictions
- EVVM payment processing
- Reward distribution
- Nonce Update: Increments the contract nonce for the user to prevent replay attacks
For detailed information about the stakingProcess
function, refer to the Staking Process section.
Unstaking Process
- Signature Verification: Validates the authenticity of the user signature
- Nonce Validation: Confirms the contract nonce is valid and unused
- Process Execution: Calls the internal
stakingProcess
function to handle:- Historical record updates
- Unstaking cooldown management
- Re-staking restrictions
- EVVM payment processing
- Reward distribution
- Nonce Update: Increments the contract nonce for the user to prevent replay attacks
For detailed information about the stakingProcess
function, refer to the Staking Process section.
stakingProcess
Function Type: internal
The stakingProcess
function implements the core staking and unstaking logic, serving as the central processing engine for all staking operations within the contract.
Parameters
Parameter | Type | Description |
---|---|---|
_isStaking | bool | true = Stake, false = Unstake |
_user | address | User address |
_amountOfSMate | uint256 | Amount of sMATE tokens to stake/unstake |
_priorityFee_Evvm | uint256 | EVVM priority fee |
_nonce_Evvm | uint256 | EVVM payment operation nonce |
_priority_Evvm | bool | EVVM execution mode (true = async, false = sync) |
_signature_Evvm | bytes | EVVM payment authorization |
Workflow
Staking Process
- Re-Staking Eligibility: Verifies the user can stake again after their last full unstaking using the
getTimeToUserUnlockStakingTime
function - Payment Processing: Calls the internal
makePay
function to process payments through EVVM - Staker Status Update: Sets the user's staking flag to
0x01
using thepointStaker
function in the EVVM contract - Historical Record Creation: Logs critical transaction data:
- Staking indicator
- Amount staked in this transaction
- Timestamp of operation
- Updated total stake amount
- Priority Fee Distribution: Distributes the priority fee to the transaction executor using the
makeCaPay
function - Reward Distribution: Allocates rewards to the transaction executor using the
makeCaPay
function with enhanced amounts for stakers
For detailed information about the getTimeToUserUnlockStakingTime
, makePay
, and makeCaPay
functions, refer to the getTimeToUserUnlockStakingTime, makePay, and makeCaPay sections.
Unstaking Process
- Full Unstaking Cooldown Verification: For complete unstaking, validates that the required cooldown period has elapsed using the
getTimeToUserUnlockFullUnstakingTime
function- If valid: Updates staking flag to
0x00
via thepointStaker
function - If invalid: Reverts the transaction
- If valid: Updates staking flag to
- Priority Fee Processing: For transactions with priority fees, calls the internal
makePay
function - Token Withdrawal: Processes the unstaking withdrawal using the
makeCaPay
function - Historical Record Creation: Logs critical transaction data:
- Unstaking indicator
- Amount unstaked in this transaction
- Timestamp of operation
- Updated total stake amount
- Priority Fee Distribution: Distributes the priority fee to the transaction executor
- Reward Distribution: Allocates rewards to the transaction executor with enhanced amounts for stakers
For detailed information about the getTimeToUserUnlockFullUnstakingTime
, makePay
, and makeCaPay
functions, refer to the getTimeToUserUnlockFullUnstakingTime, makePay, and makeCaPay sections.
makePay
Function Type: internal
The makePay
function facilitates payment processing through the EVVM contract, directing transactions to either synchronous or asynchronous processing paths based on specified parameters.
Parameters
Parameter | Type | Description |
---|---|---|
_user_Evvm | address | User address for the payment transaction |
_amount_Evvm | uint256 | Amount of sMATE tokens involved in the transaction |
_priorityFee_Evvm | uint256 | EVVM priority fee for transaction processing |
_priority_Evvm | bool | EVVM execution mode (true = async, false = sync) |
_nonce_Evvm | uint256 | EVVM payment operation nonce for replay protection |
_signature_Evvm | bytes | EVVM payment authorization signature |
Workflow
- Processing Mode Selection: Evaluates the
_priority_Evvm
parameter:- If
true
: InitiatespayMateStaking_async
for asynchronous processing - If
false
: InitiatespayMateStaking_sync
for synchronous processing
- If
- Payment Execution: Forwards parameters to the appropriate EVVM contract function for payment processing and staking management
makeCaPay
Function Type: internal
The makeCaPay
function provides a streamlined interface for contract-to-contract payment operations through the EVVM contract's caPay
function.
Parameters
Parameter | Type | Description |
---|---|---|
_tokenAddress_Evvm | address | Address of the token contract to be transferred |
_user_Evvm | address | Recipient address for the payment |
_amount_Evvm | uint256 | Amount of tokens to transfer |
Workflow
- Direct Payment Execution: Calls the EVVM contract's
caPay
function with the provided parameters, executing the token transfer without additional verification steps