-
position_lifecycle_happy_test.cdc(Line 64)- TODO: Implement test for closing position when
close_positiontransaction exists - Currently missing: Repay and close position functionality
- TODO: Implement test for closing position when
-
reserve_withdrawal_test.cdc(Line 28)- TODO: Once contract exposes direct mint-to-reserve path
- Currently skipping balance assertion due to missing functionality
-
repay_and_close_position.cdc(Line 13)- TODO: Implement when
FlowALPv0.Poolexposes position info and repayAndClosePosition - Currently just a placeholder that panics
- TODO: Implement when
-
withdraw_reserve.cdc(Lines 16, 22)- TODO: Implement proper governance control
- TODO: Once
FlowALPv0.Poolexposes a withdrawReserve function - Currently using a workaround that creates empty vaults
-
FlowALPv0.cdc(Line 1389)- TODO: In production, asyncUpdate() should only process limited positions per callback
- TODO: Schedule each update in its own callback for error isolation
-
FlowALPv0.cdc(Line 1452)- TODO: Consider making Position a resource given its critical role
Based on FlowALPv0_TestPlan.md, all planned tests have been implemented:
- ✅ Pool Creation Workflow
- ✅ Supported Token Governance Addition
- ✅ Position Lifecycle Happy Path (partial - missing close)
- ✅ Rebalance Undercollateralised
- ✅ Rebalance Overcollateralised
- ✅ Reserve Withdrawal Governance Control
-
Functional Sink/Source Hooks (Critical)
- Tests E-1: Push to sink on surplus
- Tests E-2: Pull from source on shortfall
-
Basic Oracle Integration
- Oracle price updates
- Stale price handling
- Price manipulation protection
-
Multi-Token Support
- Deposit multiple token types
- Borrow against multi-token collateral
- Token-specific thresholds
-
Advanced Position Management
- YieldVault resource creation/management
- Position tracking and metadata
- IRR calculations
-
Automated Rebalancing
- Automatic rebalance triggers
- Collateral accumulation
-
Access Control & Limits
- User whitelisting
- Per-user collateral limits
-
Production Oracle Integration
- Multi-oracle aggregation
- Oracle failover
-
Advanced Interest Curves
- Interest accrual over time
- Dynamic rate adjustment
-
Position Close/Repay functionality
- Contract method:
repayAndClosePosition() - Transaction:
repay_and_close_position.cdc - Test completion:
position_lifecycle_happy_test.cdc
- Contract method:
-
Reserve Management
- Contract method:
withdrawReserve()with governance - Direct mint-to-reserve capability
- Complete test assertions in
reserve_withdrawal_test.cdc
- Contract method:
-
Async Update Improvements
- Batch processing limits
- Error isolation per position update
-
Position as Resource
- Architectural change for better security
- Sink/Source integration tests
- Oracle integration tests
- Multi-token support tests
- Access control tests
Current tests cover:
- Basic pool operations
- Position creation and rebalancing
- Auto-borrowing behavior
- Token governance
Missing test coverage for:
- Position closing/repayment
- Error scenarios and edge cases
- Multi-position scenarios
- Concurrent operations
- Gas optimization scenarios
- Integration with real DeFi protocols
Status: Partially implemented - repayment works but collateral return blocked
Issue: No way to fully close a position and return collateral to user
Location: FlowALPv0.cdc - Pool contract missing helper method
Current State (Demonstrated in Tests):
- Created
repay_and_close_position.cdctransaction that repays MOET debt successfully - Transaction includes detailed logging showing position state before/after
- Before repayment: MOET: 615.38 Debit, Flow: 1000.00 Credit
- After repayment: MOET: 0.00 (cleared ✅), Flow: 1000.00 Credit (still locked ❌)
- Cannot return collateral because
Position.withdraw()requiresFungibleToken.Withdrawauthorization - User's Flow collateral remains locked in position after full debt repayment
What's Needed:
- Contract method like
repayAndClosePosition()that handles both repayment and collateral return internally - OR expose a way to grant transactions
FungibleToken.Withdrawaccess to Position methods - Current workaround leaves collateral stranded - users can repay but cannot recover their assets
Test Coverage:
position_lifecycle_happy_test.cdctests repayment (passes)- Test includes logging that clearly demonstrates the issue
- Collateral return test commented out pending contract support