Skip to content

FLO-5: Consistent behaviour in withdrawAndPull/depositAndPush#286

Draft
jordanschalm wants to merge 4 commits intomainfrom
jord/flo-5
Draft

FLO-5: Consistent behaviour in withdrawAndPull/depositAndPush#286
jordanschalm wants to merge 4 commits intomainfrom
jord/flo-5

Conversation

@jordanschalm
Copy link
Member

@jordanschalm jordanschalm commented Mar 20, 2026

Closes #214

Previously, withdrawAndPull only triggered the top-up source when health dropped below minHealth, while depositAndPush always rebalanced to targetHealth. This asymmetry left positions between minHealth and targetHealth without rebalancing. Now both operations consistently rebalance to targetHealth when their respective flags are set.

jordanschalm and others added 4 commits March 19, 2026 19:23
…rce is true

Previously, withdrawAndPull only triggered the top-up source when health
dropped below minHealth, while depositAndPush always rebalanced to
targetHealth. This asymmetry left positions between minHealth and
targetHealth without rebalancing. Now both operations consistently
rebalance to targetHealth when their respective flags are set.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move test_withdrawAndPull_rebalancesToTargetHealth into
rebalance_undercollateralised_test.cdc and add the symmetric
testDepositAndPush_rebalancesToTargetHealth to
rebalance_overcollateralised_test.cdc.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…thinVariance

Update docstrings for withdrawAndPull and depositAndPush across
FlowALPv0, FlowALPPositionResources, and FlowALPModels to state that
the push/pull always occurs at withdraw/deposit time and always
attempts to restore targetHealth. Switch tests to equalWithinVariance
for rounding-safe comparisons.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…-source bug

Add 13 scenario tests covering all combinations of pull/push flags,
health thresholds, and source/sink availability. Move the two earlier
tests into the new file and remove them from the rebalance test files.

Fix bug where withdrawAndPull panicked when pullFromTopUpSource=true,
health was between minHealth and targetHealth, but no topUpSource was
configured. The withdrawal now succeeds since the position is still
above minHealth (best-effort semantics).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

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

1 participant