Severity: Medium
Files Affected
cadence/contracts/FlowALPv1.cdc
Description
The protocol uses the boolean flags pullFromTopUpSource and pushToDrawDownSink to allow users to trigger automated rebalancing via their configured sources and sinks during withdrawals and deposits. However, these flags exhibit inconsistent operational behaviors. In depositAndPush(), setting pushToDrawDownSink to true forcefully invokes _rebalancePositionNoLock(), instantly extracting value to rebalance the position to its targetHealth regardless of whether it breached its maxHealth threshold. Conversely, in withdrawAndPull(), setting pullFromTopUpSource to true only evaluates if the position breaches its minHealth limit. If the withdrawal drops the health anywhere between minHealth and targetHealth, the flag is completely ignored, the top-up source is bypassed, and the position is not rebalanced. This asymmetric design prevents users from consistently maintaining their desired targetHealth across operations.
Recommendation
Unify the behavior of the source and sink flags to ensure consistent user expectations. Update withdrawAndPull() to actively trigger a rebalance if pullFromTopUpSource is true and the post-withdrawal health falls anywhere below targetHealth, rather than only triggering as a rescue mechanism when breaching minHealth.
Parent Issue: #209
Severity: Medium
Files Affected
cadence/contracts/FlowALPv1.cdcDescription
The protocol uses the boolean flags pullFromTopUpSource and pushToDrawDownSink to allow users to trigger automated rebalancing via their configured sources and sinks during withdrawals and deposits. However, these flags exhibit inconsistent operational behaviors. In depositAndPush(), setting pushToDrawDownSink to true forcefully invokes _rebalancePositionNoLock(), instantly extracting value to rebalance the position to its targetHealth regardless of whether it breached its maxHealth threshold. Conversely, in withdrawAndPull(), setting pullFromTopUpSource to true only evaluates if the position breaches its minHealth limit. If the withdrawal drops the health anywhere between minHealth and targetHealth, the flag is completely ignored, the top-up source is bypassed, and the position is not rebalanced. This asymmetric design prevents users from consistently maintaining their desired targetHealth across operations.
Recommendation
Unify the behavior of the source and sink flags to ensure consistent user expectations. Update withdrawAndPull() to actively trigger a rebalance if pullFromTopUpSource is true and the post-withdrawal health falls anywhere below targetHealth, rather than only triggering as a rescue mechanism when breaching minHealth.
Parent Issue: #209