Skip to content

fix: dca rounding error from omnipool - #1449

Merged
enthusiastmartin merged 3 commits into
masterfrom
fix/dca-rounding-error-from-omnipool
May 9, 2026
Merged

fix: dca rounding error from omnipool#1449
enthusiastmartin merged 3 commits into
masterfrom
fix/dca-rounding-error-from-omnipool

Conversation

@dmoka

@dmoka dmoka commented May 9, 2026

Copy link
Copy Markdown
Contributor

aave returns balance with off by one, leading to this.

https://hydration.subscan.io/block/12309735?tab=event&event=12309735-8
image

image

dmoka and others added 2 commits May 9, 2026 15:53
Aave aTokens are rebasing — `balanceOf` returns `rayMul(scaledBalance,
liquidityIndex)`, which can round below the amount that was just
transferred in. That trips the omnipool's pre-trade `ensure_can_withdraw`
during a DCA execution and previously terminated the schedule.

Add `pallet_omnipool::Error::InsufficientBalance` to `RetryOnErrorForDca`
so the schedule is retried on a later block instead. Aave's
`getReserveNormalizedIncome` is timestamp-dependent, so the rounding
boundary moves between blocks and a later attempt succeeds.

Test `dca_omni_should_succeed_after_retry_with_timestamp_drift` covers
the full flow: first attempt fails with `InsufficientBalance`, retry is
scheduled, timestamp drift moves the index, retry succeeds, counter
resets. Snapshot replaced with a 16 MB slim version (vs. 385 MB).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Rename SNAPSHOT to SNAPSHOT_12309734 to make the captured block explicit,
and add the exact scraper invocation as a comment above PATH_TO_SNAPSHOT
so the snapshot can be reproduced deterministically.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented May 9, 2026

Copy link
Copy Markdown

Crate versions that have been updated:

  • runtime-integration-tests: v1.81.1 -> v1.82.0
  • hydradx-runtime: v415.0.0 -> v416.0.0

Runtime version has been increased.

@enthusiastmartin
enthusiastmartin merged commit e3aed13 into master May 9, 2026
9 of 10 checks passed
@enthusiastmartin
enthusiastmartin deleted the fix/dca-rounding-error-from-omnipool branch May 9, 2026 15:12
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