Skip to content

FLO-5: Inconsistent Flag Behavior: pullFromTopUpSource Bypasses Rebalancing While pushToDrawDownSink Forces It #214

Description

@liobrasil

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions