Skip to main content

RegenStakerWithoutDelegateSurrogateVotes

Git Source

Inherits: RegenStakerBase

Title: RegenStakerWithoutDelegateSurrogateVotes

Author: Golem Foundation

Variant of RegenStakerBase for regular ERC20 tokens without delegation support.

Eliminates surrogate pattern; tokens are held directly by this contract.

DELEGATION LIMITATION: Delegatee is tracked for compatibility but has no effect on token delegation.

VARIANT COMPARISON: (See RegenStaker.sol for the delegation variant)

FeatureRegenStakerRegenStakerWithoutDelegateSurrogateVotes
Delegation SupportFull SupportNo Support
Surrogate DeploymentPer DelegateeContract as Surrogate
Token HolderSurrogatesContract Directly
Voting Capabilityvia SurrogateNot Available
Gas Cost (First Delegatee)HigherLower
Integration ComplexityHigherLower

VARIANT COMPARISON: See RegenStaker.sol for detailed comparison table.

KEY DIFFERENCES FROM RegenStaker:

  • No delegation support: delegatee parameter is informational only
  • Lower gas costs: no surrogate contract deployment
  • Simpler integration: contract holds tokens directly
  • No voting capabilities through delegation
  • Same security model: both variants use owner-centric allowset authorization

USE CASE: Choose this variant for simple ERC20 staking without governance requirements.

Notes:

Functions

constructor

Constructor for the RegenStakerWithoutDelegateSurrogateVotes contract.

constructor(
IERC20 _rewardsToken,
IERC20 _stakeToken,
IEarningPowerCalculator _earningPowerCalculator,
uint256 _maxBumpTip,
address _admin,
uint128 _rewardDuration,
uint128 _minimumStakeAmount,
IAddressSet _stakerAllowset,
IAddressSet _stakerBlockset,
AccessMode _stakerAccessMode,
IAddressSet _allocationMechanismAllowset
)
RegenStakerBase(
_rewardsToken,
_stakeToken,
_earningPowerCalculator,
_maxBumpTip,
_admin,
_rewardDuration,
_minimumStakeAmount,
_stakerAllowset,
_stakerBlockset,
_stakerAccessMode,
_allocationMechanismAllowset,
"RegenStakerWithoutDelegateSurrogateVotes"
);

Parameters

NameTypeDescription
_rewardsTokenIERC20Token distributed as staking rewards
_stakeTokenIERC20ERC20 token users stake (must implement IERC20Permit)
_earningPowerCalculatorIEarningPowerCalculatorContract calculating earning power from stakes
_maxBumpTipuint256Maximum tip for earning power bumps in reward token base units
_adminaddressAddress with admin permissions (TRUSTED)
_rewardDurationuint128Duration for reward distribution in seconds
_minimumStakeAmountuint128Minimum stake required in stake token base units
_stakerAllowsetIAddressSetAllowset for ALLOWSET mode (can be address(0))
_stakerBlocksetIAddressSetBlockset for BLOCKSET mode (can be address(0))
_stakerAccessModeAccessModeStaker access mode (NONE, ALLOWSET, or BLOCKSET)
_allocationMechanismAllowsetIAddressSetAllowset of approved allocation mechanisms (SECURITY CRITICAL) Only audited and trusted allocation mechanisms should be in the allowset. Users contribute funds to these mechanisms and may lose funds if mechanisms are malicious.

_validateAndGetRequiredBalance

Validates sufficient reward token balance and returns the required balance for this variant

Overrides base to include totalStaked for same-token scenarios since stakes are held in main contract

function _validateAndGetRequiredBalance(uint256 _amount) internal view override returns (uint256 required);

Parameters

NameTypeDescription
_amountuint256Reward amount being added in reward token base units

Returns

NameTypeDescription
requireduint256Required balance including appropriate obligations

surrogates

Returns this contract as the "surrogate" since we hold tokens directly

ARCHITECTURE: This variant uses address(this) as surrogate to eliminate delegation complexity while maintaining compatibility with base Staker contract logic. This allows reuse of all base functionality without deploying separate surrogate contracts.

WARNING: Deviates from standard surrogate pattern. Always returns address(this). Integrators expecting separate surrogate contracts will fail. Do not assume external surrogate contracts exist when integrating with this variant.

function surrogates(
address /* _delegatee */
)
public
view
override
returns (DelegationSurrogate);

_fetchOrDeploySurrogate

Returns this contract as the "surrogate" - no separate contracts needed

SIMPLIFICATION: Eliminates need for complex token transfer overrides

function _fetchOrDeploySurrogate(
address /* _delegatee */
)
internal
view
override
returns (DelegationSurrogate);

_stakeTokenSafeTransferFrom

Override to support withdrawals when this contract acts as its own surrogate

Since this contract uses address(this) as surrogate, use safeTransfer for contract-to-user paths.

function _stakeTokenSafeTransferFrom(address _from, address _to, uint256 _value) internal override;

_alterDelegatee

Delegation changes are not supported in this variant

Always reverts since this contract doesn't use delegation surrogates - always uses address(this)

Both alterDelegatee() and alterDelegateeOnBehalf() call this internal function

function _alterDelegatee(Deposit storage, DepositIdentifier, address) internal pure override;

Errors

DelegationNotSupported

error DelegationNotSupported();