Skip to content

fix: retry dca on router trading limit reached - #1498

Merged
enthusiastmartin merged 2 commits into
masterfrom
dca-retry-router-trading-limit
Jul 29, 2026
Merged

fix: retry dca on router trading limit reached#1498
enthusiastmartin merged 2 commits into
masterfrom
dca-retry-router-trading-limit

Conversation

@mrq1911

@mrq1911 mrq1911 commented Jul 24, 2026

Copy link
Copy Markdown
Member

Fixes #1497

  • adds pallet_route_executor::Error::TradingLimitReached to the RetryOnErrorForDca whitelist → retried with backoff instead of instant termination
  • when the user min limit binds, dca passes the exact dry-run output as the router min limit → erc20/aToken rounding shortfall surfaces as the router error (semantically same as dca's own retriable TradeLimitReached)
  • killed HSM wind-down schedules 33794/33795 on mainnet, 2026-07-21 (blocks 13260777 / 13260976)

Tests:

  • mainnet replay: new snapshot at block 13260776 (SNAPSHOT_13260776, scraper --slim), replays block 13260777 — schedule 33812's pool-111 liquidity removal, then 33794 fails with router TradingLimitReached exactly like mainnet; asserts it is retried (verified red without the fix → terminates like mainnet)
  • pallet unit test: whitelisted error → retry with backoff → MaxRetryReached termination after retries exhausted
  • whitelist membership assertion for the runtime config

Versions: hydradx-runtime 434.0.0 + spec_version 434, pallet-dca 1.18.2, integration-tests 1.105.0

@github-actions

github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown

Crate versions that have been updated:

  • runtime-integration-tests: v1.104.0 -> v1.105.0
  • pallet-dca: v1.18.1 -> v1.18.2
  • hydradx-runtime: v433.0.0 -> v434.0.0

Runtime version has been increased.

@mrq1911 mrq1911 changed the title dca: retry on router TradingLimitReached fix: retry dca on router trading limit reached Jul 24, 2026
@github-actions

Copy link
Copy Markdown

Quick benchmark at commit a9bc627 has been executed successfully.
View results

@mrq1911
mrq1911 marked this pull request as ready for review July 24, 2026 17:54
Copilot AI review requested due to automatic review settings July 24, 2026 17:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Ensures DCA schedules treat pallet_route_executor::Error::TradingLimitReached as a retriable failure (with backoff) to prevent immediate termination on expected ERC20/aToken rounding shortfalls observed on mainnet.

Changes:

  • Whitelist pallet_route_executor::Error::TradingLimitReached in the runtime’s RetryOnErrorForDca configuration.
  • Add unit + integration coverage verifying the error is retried (with exponential backoff) and eventually terminates with MaxRetryReached once retries are exhausted.
  • Bump runtime / crate versions and lockfile to reflect the runtime behavior change.

Reviewed changes

Copilot reviewed 8 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
runtime/hydradx/src/lib.rs Bumps spec_version to 434 for the runtime behavior change.
runtime/hydradx/src/assets.rs Adds router TradingLimitReached to RetryOnErrorForDca whitelist.
runtime/hydradx/Cargo.toml Bumps hydradx-runtime crate version to 434.0.0.
pallets/dca/src/tests/on_initialize.rs Adds a unit test asserting retry/backoff behavior and MaxRetryReached termination.
pallets/dca/src/tests/mock.rs Extends the test router mock to emit TradingLimitReached and wires a RetryOnError mock.
pallets/dca/Cargo.toml Bumps pallet-dca crate version to 1.18.2.
integration-tests/src/dca.rs Adds runtime whitelist assertion + mainnet replay integration test for schedule 33794.
integration-tests/Cargo.toml Bumps runtime-integration-tests version to 1.105.0.
Cargo.lock Updates locked versions for the bumped crates.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +945 to +947
// same class as dca's own retriable TradeLimitReached — erc20/aToken rounding
// can undershoot the dry-run output passed as router min limit
pallet_route_executor::Error::<Runtime>::TradingLimitReached.into(),
asset_out: 222,
}]
.try_into()
.unwrap(),
@enthusiastmartin
enthusiastmartin merged commit cea16d1 into master Jul 29, 2026
11 of 13 checks passed
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.

DCA: router TradingLimitReached is not retriable — terminated HSM wind-down schedules on first rounding shortfall

3 participants