Skip to main content

stakingBaseProcess

Function Type: internal

The stakingBaseProcess function implements the core staking and unstaking logic, serving as the central processing engine for all staking operations within the contract.

Parameters

ParameterTypeDescription
userAccountaddressAddress of the user paying for the transaction
stakingAccountaddressAddress that will receive the stake/unstake
isStakingbooltrue = Stake, false = Unstake
amountOfStakinguint256Amount of staking tokens to stake/unstake
priorityFee_EVVMuint256EVVM priority fee
nonce_EVVMuint256EVVM nonce
priorityFlag_EVVMboolEVVM priority flag
signature_EVVMbytesEVVM signature

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 helper functions, refer to:

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 helper functions, refer to:

Public Staking