Skip to main content

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

ParameterTypeDescription
_isStakingbooltrue = Stake, false = Unstake
_amountOfSMateuint256sMATE quantity (bypasses standard limits)
_signature_EvvmbytesEVVM authorization signature.
note

The EVVM payment signature (_signature_Evvm) follows the Single Payment Signature Structure.

Workflow

Staking Process

  1. Authorization Validation: Verifies caller is the designated goldenFisher address
  2. 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
info

For detailed information about the stakingProcess implementation, refer to the Staking Process section.

Golden Staking

Unstaking Process

  1. Authorization Validation: Verifies caller is the designated goldenFisher address
  2. Process Execution: Invokes internal stakingProcess to:
    • Adjust staking balances
    • Update historical records
    • Manage unstaking cooldowns
    • Handle re-staking restrictions
    • Distribute applicable rewards
info

For detailed information about the stakingProcess implementation, refer to the Staking Process section.

Golden Staking


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 use publicStaking instead)

Parameters

ParameterTypeDescription
_isStakingbooltrue = Stake, false = Unstake
_useraddressPresale participant's wallet address
_nonceuint256sMATE contract nonce for replay protection
_signaturebytesUser authorization signature
_priorityFee_Evvmuint256EVVM priority fee
_nonce_Evvmuint256EVVM payment operation nonce
_priority_EvvmboolEVVM execution mode (true = async, false = sync)
_signature_EvvmbytesEVVM payment authorization
note

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

  1. Signature Verification: Validates the authenticity of the user signature
  2. Nonce Validation: Confirms the contract nonce is valid and unused
  3. Presale Eligibility Check: Verifies presale participation status and token limit compliance
  4. Presale Staking Status: Verifies allowPresaleStaking.flag is enabled
  5. Process Execution: Calls the internal stakingProcess function to handle:
    • Historical record updates
    • Unstaking cooldown management
    • Re-staking restrictions
    • EVVM payment processing
    • Reward distribution
  6. Nonce Update: Increments the contract nonce for the user to prevent replay attacks
info

For detailed information about the stakingProcess function, refer to the Staking Process section.

Presale Staking

Presale Staking

Unstaking Process

  1. Signature Verification: Validates the authenticity of the user signature
  2. Nonce Validation: Confirms the contract nonce is valid and unused
  3. Presale Eligibility Check: Verifies presale participation status and token limit compliance
  4. Presale Staking Status: Verifies allowPresaleStaking.flag is enabled
  5. Process Execution: Calls the internal stakingProcess function to handle:
    • Historical record updates
    • Unstaking cooldown management
    • Re-staking restrictions
    • EVVM payment processing
    • Reward distribution
  6. Nonce Update: Increments the contract nonce for the user to prevent replay attacks
info

For detailed information about the stakingProcess function, refer to the Staking Process section.

Presale Staking

Presale Staking


presaleClaims

Function Type: internal

The presaleClaims function enforces participation rules for presale stakers by validating eligibility conditions before allowing staking or unstaking operations.

Parameters

ParameterTypeDescription
_isStakingbooltrue = Stake, false = Unstake
_useraddressUser address

Workflow

  1. Public Staking Status: Verifies allowPublicStaking.flag is disabled (presale staking is only valid when public staking is not active)
  2. Presale Participant Verification: Confirms the user is registered as a presale participant
  3. Token Limit Enforcement: Ensures the user has not exceeded the 2 sMATE maximum allocation

Presale Claims


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

ParameterTypeDescription
_isStakingbooltrue = Stake, false = Unstake
_useraddressUser address
_nonceuint256sMATE contract nonce for replay protection
_amountOfSMateuint256Amount of sMATE tokens to stake/unstake
_signaturebytessMATE contract signature for replay protection
_priorityFee_Evvmuint256EVVM priority fee
_nonce_Evvmuint256EVVM payment operation nonce
_priority_EvvmboolEVVM execution mode (true = async, false = sync)
_signature_EvvmbytesEVVM payment authorization
note

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

  1. Feature Status Verification: Confirms allowPublicStaking.flag is enabled
  2. Signature Verification: Validates the authenticity of the user signature
  3. Nonce Validation: Confirms the contract nonce is valid and unused
  4. Process Execution: Calls the internal stakingProcess function to handle:
    • Historical record updates
    • Unstaking cooldown management
    • Re-staking restrictions
    • EVVM payment processing
    • Reward distribution
  5. Nonce Update: Increments the contract nonce for the user to prevent replay attacks
info

For detailed information about the stakingProcess function, refer to the Staking Process section.

Public Staking

Public Staking

Unstaking Process

  1. Signature Verification: Validates the authenticity of the user signature
  2. Nonce Validation: Confirms the contract nonce is valid and unused
  3. Process Execution: Calls the internal stakingProcess function to handle:
    • Historical record updates
    • Unstaking cooldown management
    • Re-staking restrictions
    • EVVM payment processing
    • Reward distribution
  4. Nonce Update: Increments the contract nonce for the user to prevent replay attacks
info

For detailed information about the stakingProcess function, refer to the Staking Process section.

Public Staking Public Staking


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

ParameterTypeDescription
_isStakingbooltrue = Stake, false = Unstake
_useraddressUser address
_amountOfSMateuint256Amount of sMATE tokens to stake/unstake
_priorityFee_Evvmuint256EVVM priority fee
_nonce_Evvmuint256EVVM payment operation nonce
_priority_EvvmboolEVVM execution mode (true = async, false = sync)
_signature_EvvmbytesEVVM payment authorization

Workflow

Staking Process

  1. Re-Staking Eligibility: Verifies the user can stake again after their last full unstaking using the getTimeToUserUnlockStakingTime function
  2. Payment Processing: Calls the internal makePay function to process payments through EVVM
  3. Staker Status Update: Sets the user's staking flag to 0x01 using the pointStaker function in the EVVM contract
  4. Historical Record Creation: Logs critical transaction data:
    • Staking indicator
    • Amount staked in this transaction
    • Timestamp of operation
    • Updated total stake amount
  5. Priority Fee Distribution: Distributes the priority fee to the transaction executor using the makeCaPay function
  6. Reward Distribution: Allocates rewards to the transaction executor using the makeCaPay function with enhanced amounts for stakers
info

For detailed information about the getTimeToUserUnlockStakingTime, makePay, and makeCaPay functions, refer to the getTimeToUserUnlockStakingTime, makePay, and makeCaPay sections.

Public Staking

Unstaking Process

  1. 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 the pointStaker function
    • If invalid: Reverts the transaction
  2. Priority Fee Processing: For transactions with priority fees, calls the internal makePay function
  3. Token Withdrawal: Processes the unstaking withdrawal using the makeCaPay function
  4. Historical Record Creation: Logs critical transaction data:
    • Unstaking indicator
    • Amount unstaked in this transaction
    • Timestamp of operation
    • Updated total stake amount
  5. Priority Fee Distribution: Distributes the priority fee to the transaction executor
  6. Reward Distribution: Allocates rewards to the transaction executor with enhanced amounts for stakers
info

For detailed information about the getTimeToUserUnlockFullUnstakingTime, makePay, and makeCaPay functions, refer to the getTimeToUserUnlockFullUnstakingTime, makePay, and makeCaPay sections.

Public Staking


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

ParameterTypeDescription
_user_EvvmaddressUser address for the payment transaction
_amount_Evvmuint256Amount of sMATE tokens involved in the transaction
_priorityFee_Evvmuint256EVVM priority fee for transaction processing
_priority_EvvmboolEVVM execution mode (true = async, false = sync)
_nonce_Evvmuint256EVVM payment operation nonce for replay protection
_signature_EvvmbytesEVVM payment authorization signature

Workflow

  1. Processing Mode Selection: Evaluates the _priority_Evvm parameter:
    • If true: Initiates payMateStaking_async for asynchronous processing
    • If false: Initiates payMateStaking_sync for synchronous processing
  2. 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

ParameterTypeDescription
_tokenAddress_EvvmaddressAddress of the token contract to be transferred
_user_EvvmaddressRecipient address for the payment
_amount_Evvmuint256Amount of tokens to transfer

Workflow

  1. Direct Payment Execution: Calls the EVVM contract's caPay function with the provided parameters, executing the token transfer without additional verification steps