Skip to content

fix: premature completion of buy DCA#1407

Merged
dmoka merged 8 commits intomasterfrom
fix/dca-rolling-buy
Apr 13, 2026
Merged

fix: premature completion of buy DCA#1407
dmoka merged 8 commits intomasterfrom
fix/dca-rolling-buy

Conversation

@dmoka
Copy link
Copy Markdown
Contributor

@dmoka dmoka commented Apr 2, 2026

We have an issue,namely a check for buy orders where we check if the remaining amount is smaller than the next trade amount. If so we complete the DCA.

But for rolling DCA, this remaining amount is always constant:

if remaining_amount < amount_for_next_trade {

So when the pair price changes a lot since schedule creation, this can lead to issue

the simplest solution could be to skip this check in case of rolling DCA.

dmoka added 2 commits April 1, 2026 13:26
Rolling DCA schedules (total_amount = 0) were being prematurely
terminated when the price of the bought asset increased after schedule
creation. The remaining_amount (set once at creation, never updated
for rolling schedules) would become smaller than the recalculated
amount_for_next_trade, triggering completion even though the user
had plenty of funds.

Skip both budget termination checks for rolling schedules since
their budget is infinite by definition.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

Crate versions that have been updated:

  • runtime-integration-tests: v1.77.1 -> v1.78.0
  • pallet-dca: v1.17.0 -> v1.18.0
  • hydradx-runtime: v409.0.0 -> v410.0.0

Runtime version has been increased.

@github-actions
Copy link
Copy Markdown

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

@dmoka dmoka changed the title fix: dca rolling buy fix: premature completion of buy DCA Apr 13, 2026
@dmoka dmoka merged commit e868254 into master Apr 13, 2026
11 checks passed
@dmoka dmoka deleted the fix/dca-rolling-buy branch April 13, 2026 10:11
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