Skip to content

AI: Explore architectural decomposition of FlowALP contracts#312

Closed
jordanschalm wants to merge 1 commit into
mainfrom
claude/review-flowalp-contracts-53X9U
Closed

AI: Explore architectural decomposition of FlowALP contracts#312
jordanschalm wants to merge 1 commit into
mainfrom
claude/review-flowalp-contracts-53X9U

Conversation

@jordanschalm

@jordanschalm jordanschalm commented Apr 9, 2026

Copy link
Copy Markdown
Member

No description provided.

Add architecture review document and sample interface definitions for
decomposing the monolithic Pool resource into specialized modules:

- ReserveVaultManager: purpose-specific vault withdrawal API with distinct
  entitlements per withdrawal reason (position, liquidation, fee)
- TokenLedger: effects-based balance mutations replacing hidden side effects
  in InternalBalance.recordDeposit/Withdrawal, colocated risk factors
- PositionRegistry: position lifecycle and balance tracking
- FeeCollector: separated fee calculation from execution
- LiquidationEngine: pure validation returning LiquidationPlan structs
- PoolCoordinator: thin orchestrator showing how modules compose

Key issues identified:
- Pool is a ~1200-line God Object handling 10+ concerns
- PoolState is a flat bag with single EImplementation entitlement for all access
- Reserves are directly borrowable by any internal code path
- InternalBalance.recordDeposit has hidden side effects on global TokenState
- Health/balance sheet logic duplicated across 4+ code paths
- Fee collection interleaved with core lending operations

https://claude.ai/code/session_01VfmgLV2Ev1eGFebdYMjaGz
@jordanschalm jordanschalm requested a review from a team as a code owner April 9, 2026 17:07
@jordanschalm jordanschalm changed the title Propose architectural decomposition of FlowALP contracts AI: Explore architectural decomposition of FlowALP contracts Apr 9, 2026
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.

2 participants