Skip to content

Dev#25

Merged
olujimiAdebakin merged 2 commits intomainfrom
dev
Dec 28, 2025
Merged

Dev#25
olujimiAdebakin merged 2 commits intomainfrom
dev

Conversation

@olujimiAdebakin
Copy link
Copy Markdown
Owner

No description provided.

Implements Accumulated Funding Per Unit (AFPU) model with lazy settlement
pattern, replacing O(n) batch updates with O(1) per-position settlement.

Changes:
- Add lastCumulativeFunding field to Position struct for AFPU snapshots
- Implement settlePositionFunding() for lazy funding settlement
- Integrate automatic funding settlement into all position modifications
- Initialize AFPU snapshot on position opening
- Remove dependencies on legacy batch funding updates

Breaking Changes:
- Position struct modified (added lastCumulativeFunding field)
- Requires FundingRateEngine with AFPU support (companion PR)
- Legacy _applyToPositions() calls no longer supported

Performance:
- 99% gas reduction at scale (10M → 50K gas for 1,000 traders)
- Removes theoretical limit on concurrent positions

Related: (FundingRateEngine AFPU implementation)
feat: integrate AFPU lazy settlement into PositionManager
@olujimiAdebakin olujimiAdebakin merged commit dd71c9c into main Dec 28, 2025
0 of 2 checks passed
@openzeppelin-code
Copy link
Copy Markdown

Dev

Generated at commit: 4f085bef881b4aa0f3a32f4098f6f3ce7cd583f3

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
1
0
0
2
9
12
Dependencies Critical
High
Medium
Low
Note
Total
0
0
0
0
0
0

For more details view the full report in OpenZeppelin Code Inspector

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