presaleStaking
presaleStaking uses Core.sol's centralized verification via validateAndConsumeNonce() with StakingHashUtils.hashDataForPresaleStake(). Includes dual-executor parameters: senderExecutor (msg.sender restriction) and originExecutor (tx.origin restriction).
Function Type: external
Function Signature: presaleStaking(address user, bool isStaking, address senderExecutor, address originExecutor, uint256 nonce, bytes signature, uint256 priorityFeePay, uint256 noncePay, bytes signaturePay)
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
- Fixed amount of 1 staking token per operation
- Maximum allocation of 2 staking tokens per user
- Requires active
allowPresaleStakingflag - Not available when
allowPublicStakingflag is active (presale users must usepublicStakinginstead)
Note: In this repository's contract implementation the constructor enables allowPublicStaking.flag by default and leaves allowPresaleStaking.flag disabled. Deployments and testnets may use different defaults; consult the deployed contract metadata for runtime flag values.
Parameters
| Parameter | Type | Description |
|---|---|---|
user | address | Presale participant's wallet address |
isStaking | bool | true = Stake, false = Unstake |
senderExecutor | address | Optional msg.sender restriction. Use address(0) for any service, or specify address to restrict execution. |
originExecutor | address | EOA that will execute the transaction (verified with tx.origin) |
nonce | uint256 | Core nonce for this signature (prevents replay attacks) |
signature | bytes | User authorization signature |
Note: For presale staking the function enforces a fixed amount of
1token; therefore the signed message must include_amountOfStaking = 1.|priorityFeePay| uint256 | Optional priority fee for faster processing | |noncePay| uint256 | Core nonce for the payment operation | |signaturePay| bytes | User's signature authorizing the payment |
- If you want to know more about the signature structure, refer to the Standard 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
-
Presale Staking Status: Verifies
allowPresaleStaking.flagis enabled andallowPublicStaking.flagis disabled, reverts withPresaleStakingDisabled()otherwise -
Centralized Verification: Validates signature and consumes nonce via Core.sol:
core.validateAndConsumeNonce(
user,
senderExecutor,
Hash.hashDataForPresaleStake(isStaking, 1), // Fixed amount = 1
originExecutor,
nonce,
true, // Always async
signature
);
Validates:
- Signature authenticity via EIP-191
- Nonce hasn't been consumed
msg.sendermatchessenderExecutor(if specified)- Executor is the specified EOA (via
tx.origin)
On Failure:
Core__InvalidSignature()- Invalid signatureCore__NonceAlreadyUsed()- Nonce consumedCore__InvalidExecutor()- Executing EOA doesn't match originExecutor
- Presale Participant Verification: Confirms the user is registered as a presale participant using
userPresaleStaker[user].isAllow, reverts withUserIsNotPresaleStaker()if not authorized - Limit Check: Ensures
userPresaleStaker[user].stakingAmount < 2, reverts withUserPresaleStakerLimitExceeded()if limit reached - Counter Update: Increments
userPresaleStaker[user].stakingAmount - Process Execution: Calls the internal
stakingBaseProcessfunction with:- User address and IsAService=false in AccountMetadata
- Fixed amount of 1 staking token
- Standard EVVM payment processing
- Historical record updates and reward distribution
For detailed information about the stakingBaseProcess function, refer to the stakingBaseProcess.
Unstaking Process
-
Presale Staking Status: Verifies
allowPresaleStaking.flagis enabled andallowPublicStaking.flagis disabled, reverts withPresaleStakingDisabled()otherwise -
Centralized Verification: Validates signature and consumes nonce via Core.sol (same as staking)
-
Presale Participant Verification: Confirms the user is registered as a presale participant using
userPresaleStaker[user].isAllow, reverts withUserIsNotPresaleStaker()if not authorized -
Balance Check: Ensures
userPresaleStaker[user].stakingAmount > 0, reverts withUserPresaleStakerLimitExceeded()if no stakes to unstake -
Counter Decrement: Decrements
userPresaleStaker[user].stakingAmount -
Process Execution: Calls the internal
stakingBaseProcessfunction with:- User address and IsAService=false in AccountMetadata
- Fixed amount of 1 staking token
- Standard EVVM payment processing
- Historical record updates and reward distribution
For detailed information about the stakingBaseProcess function, refer to the stakingBaseProcess.