Skip to content

Conversation

ianhe8x
Copy link
Contributor

@ianhe8x ianhe8x commented Oct 1, 2025


Description

This pull request introduces a quota-based instant delegation feature with configurable limits to enhance staking security and efficiency. Key features include:

  • Per-wallet, per-era quotas for instant delegation, auto-resetting with each era transition.
  • 70% era window restriction to prevent last-minute sniping.
  • Automatic splitting of large delegations into instant and pending parts.
  • Reuse of existing applyRedelegation() for instant rewards processing.
  • Configurable parameters for quota limits and era window percentage.

Key Changes

  • Staking.sol: Implements quota tracking, token transfers, and configuration options.
  • StakingManager.sol: Refactored delegate() logic with era progress and quota handling.
  • IStaking.sol: Introduces new interface methods supporting instant delegation.
  • Comprehensive test coverage for various instant delegation scenarios.

Checklist

  • Tests added for all new functionalities
  • Documentation updated as needed
  • Code formatting and linting check passes
  • All previous unit tests pass

Add support for instant delegation with per-wallet, per-era quota limits to encourage delegation while preventing attacks:

- Add quota tracking with auto-reset on era change using storage-efficient struct
- Implement 70% era window restriction to prevent last-minute sniping
- Support automatic splitting of large delegations into instant + pending portions
- Reuse existing applyRedelegation() for instant rewards distribution
- Add configuration parameters for quota amount and era window percentage

Changes:
- Staking.sol: Add instant quota tracking, token transfer, and parameter configuration
- StakingManager.sol: Refactor delegate() with era progress calculation and quota logic
- IStaking.sol: Add new interface methods for instant delegation
- Test coverage for all instant delegation scenarios
- Move InstantQuotaUsage struct to IStaking interface for better organization
- Remove delegateToIndexer function, use transferDelegationTokens + addDelegation instead
- Extract common transferDelegationTokens call in delegate() to reduce code duplication
Fix YN0078 invalid resolution warning for @ethersproject/abi and other packages
Remove invalid resolution entry that pointed 5.0.7 to 5.1.2, let yarn regenerate the correct resolution
Fix TypeScript compilation errors caused by multiple versions of @ethersproject packages.
Force all @ethersproject dependencies to use 5.5.x versions to match ethers 5.5.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant