Skip to content

Commit

Permalink
Step down DCA frequency unit when interval multiplier is lowered
Browse files Browse the repository at this point in the history
  • Loading branch information
jvonasek committed Oct 9, 2024
1 parent c846dcd commit dff2b92
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/perfect-turtles-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@galacticcouncil/apps': patch
---

Step down DCA frequency unit when interval multiplier is lowered
19 changes: 11 additions & 8 deletions packages/apps/src/app/dca/Form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,17 @@ export class DcaForm extends BaseElement {
this.dispatchEvent(new CustomEvent('interval-mul-change', options));

setTimeout(() => {
if (this.frequencyRanges[this.frequencyUnit] <= 1) {
this.setFrequencyUnit(this.maxFrequency, 'min');
if (multipliplier && this.frequencyRanges[this.frequencyUnit] <= 1) {
const units = Object.keys(this.frequencyRanges);
const unit =
(units[units.indexOf(this.frequencyUnit) - 1] as FrequencyUnit) ||
'min';
const values = {
min: this.maxFrequency,
hour: Math.floor(this.maxFrequency / HOUR_MIN),
day: Math.floor(this.maxFrequency / DAY_MIN),
};
this.setFrequencyUnit(values[unit], unit);
}
}, 0);
}
Expand Down Expand Up @@ -398,12 +407,6 @@ export class DcaForm extends BaseElement {
day: Math.floor(value / DAY_MIN),
};

const frequencyRanges = {
min: range,
hour: rangeInHours,
day: rangeInDays,
};

const units = [
'min',
this.frequencyRanges.hour > 0 && 'hour',
Expand Down

0 comments on commit dff2b92

Please sign in to comment.