Strategic Proposal: BASE-NETWORK Optimization#5
Open
arawrdn wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces a strategic shift from fully push-based recipient payouts to a pull-based cumulative index distribution model for pool revenue distribution.
Instead of iterating over every recipient during each distribution cycle, pools now track a high-precision cumulative accumulator,
accUSDCPerShare, and recipients claim their accrued USDC based on their assigned shares andrewardDebt.This approach significantly improves scalability, gas predictability, and operational liveness as pool participation grows.
Motivation
The previous push-based distribution model required processing recipient payouts during each cycle, resulting in O(n) execution cost relative to the number of recipients.
As pools grow, this pattern becomes increasingly expensive and operationally fragile:
This PR adopts a pull-based accrual and claim model, where funding updates remain near O(1) and payout execution is moved to recipients or delegated claim bots.
What Changed
Cumulative Pool Index
Each pool now maintains a high-precision cumulative USDC-per-share accumulator:
The accumulator uses a precision scalar, such as
1e27, to safely account for fractional allocations.When revenue enters a pool, the pool accumulator is incremented once based on the incoming amount and the total active shares.
Recipient Accounting
Each recipient is tracked using:
Claimable rewards are calculated as:
On claim, the recipient receives the owed USDC and their
rewardDebtis updated to reflect the latest accumulator checkpoint.Pull-Based Claims
Recipients can now claim accrued USDC directly.
This enables:
Checkpointing on Mutations
Before recipient state is changed, the recipient is force-settled/checkpointed.
This applies to changes such as:
Checkpointing before mutation ensures accrued rewards remain correct and prevents allocation drift across share changes.
Strategic Benefits
Predictable Gas at Scale
Distribution updates no longer require iterating through every recipient.
Incoming revenue updates are near O(1), making costs more predictable even as the number of recipients grows.
Improved Liveness
A single problematic recipient payout can no longer block a full distribution cycle.
Each recipient claim is isolated, improving reliability and reducing operational risk.
Better Automation
The model supports claim bots, delegated execution, and subaccount-based workflows.
This makes recurring treasury operations easier to automate without requiring full-pool payout transactions.
Preserved Auditability
The model preserves on-chain auditability through accumulator updates, recipient checkpoints, and claim events.
Revenue can still be attributed by source, bucket, pool, or distribution checkpoint through emitted events.
High-Level Flow
Revenue Accrual
accUSDCPerShare.Recipient Claim
claim().rewardDebtis updated.Share Mutation
rewardDebtis reset against the current accumulator.Impact
This change replaces a gas-intensive, cycle-based payout model with a scalable accrual model that is better suited for larger pools and frequent treasury activity.
The result is:
Notes for Reviewers
Please pay particular attention to:
rewardDebtupdates on claim and share mutation