Skip to content

Commit

Permalink
updat multiplier
Browse files Browse the repository at this point in the history
  • Loading branch information
GrandSchtroumpf committed Sep 10, 2024
1 parent 88d67ee commit 62f1206
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 14 deletions.
11 changes: 6 additions & 5 deletions src/components/strategies/common/StrategyChartLegend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ export const StrategyChartLegend = () => {
<footer className="font-14 flex flex-col gap-16">
<p className="flex items-center gap-8">
<IconLock className="size-16 shrink-0" />
The interactive features of this chart are available on the edit prices
page.
Strategy prices can only be modified when selecting "Edit Prices"
option.
</p>
<p className="text-warning flex items-center gap-8">
<p className="flex items-center gap-8">
<span
aria-hidden
className="bg-warning/10 size-16 shrink-0 rounded-full p-4"
className="size-16 shrink-0 rounded-full bg-white/10 p-4"
>
<IconWarning />
</span>
Need a disclaimer for the range of strategy, not from day 1 of strategy
The strategy prices shown on the chart reflect the current strategy
settings without considering historical price changes"
</p>
</footer>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/strategies/common/StrategyChartSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const StrategyChartSection: FC<Props> = ({ children }) => {
return (
<section
aria-labelledby="price-chart-title"
className="bg-background-900 sticky top-[80px] flex max-h-[600px] min-h-[400px] flex-col gap-20 rounded p-20"
className="bg-background-900 sticky top-[80px] flex h-[400px] flex-col gap-20 rounded p-20 md:h-[600px]"
>
<header className="flex items-center justify-between gap-20">
<h2 id="price-chart-title" className="text-18">
Expand Down
22 changes: 18 additions & 4 deletions src/pages/strategies/edit/prices/disposable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,27 @@ const getOrder = (
const price = isZero(defaultPrice) ? marketPrice : defaultPrice;

const defaultMin = () => {
if (settings === 'limit') return price?.toString();
const multiplier = isBuy ? 0.9 : 1;
const multiplier = (() => {
if (isZero(defaultPrice)) {
if (isBuy) return settings === 'limit' ? 0.9 : 0.8;
else return settings === 'limit' ? 1.1 : 1.1;
} else {
if (isBuy) return settings === 'limit' ? 1 : 0.9;
else return settings === 'limit' ? 1 : 1;
}
})();
return new SafeDecimal(price ?? 0).mul(multiplier).toString();
};
const defaultMax = () => {
if (settings === 'limit') return price?.toString();
const multiplier = isBuy ? 1 : 1.1;
const multiplier = (() => {
if (isZero(defaultPrice)) {
if (isBuy) return settings === 'limit' ? 0.9 : 0.9;
else return settings === 'limit' ? 1.1 : 1.2;
} else {
if (isBuy) return settings === 'limit' ? 1 : 1;
else return settings === 'limit' ? 1 : 1.1;
}
})();
return new SafeDecimal(price ?? 0).mul(multiplier).toString();
};
return {
Expand Down
22 changes: 18 additions & 4 deletions src/pages/strategies/edit/prices/recurring.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,15 @@ const getOrders = (
const isBuy = direction === 'buy';
const defaultPrice = isBuy ? order0.startRate : order1.endRate;
const price = isZero(defaultPrice) ? marketPrice : defaultPrice;
if (settings === 'limit') return price?.toString();
const multiplier = isBuy ? 0.9 : 1;
const multiplier = (() => {
if (isZero(defaultPrice)) {
if (isBuy) return settings === 'limit' ? 0.9 : 0.8;
else return settings === 'limit' ? 1.1 : 1.1;
} else {
if (isBuy) return settings === 'limit' ? 1 : 0.9;
else return settings === 'limit' ? 1 : 1;
}
})();
return new SafeDecimal(price ?? 0).mul(multiplier).toString();
};
const defaultMax = (
Expand All @@ -65,8 +72,15 @@ const getOrders = (
const isBuy = direction === 'buy';
const defaultPrice = isBuy ? order0.startRate : order1.endRate;
const price = isZero(defaultPrice) ? marketPrice : defaultPrice;
if (settings === 'limit') return price?.toString();
const multiplier = isBuy ? 1 : 1.1;
const multiplier = (() => {
if (isZero(defaultPrice)) {
if (isBuy) return settings === 'limit' ? 0.9 : 0.9;
else return settings === 'limit' ? 1.1 : 1.2;
} else {
if (isBuy) return settings === 'limit' ? 1 : 1;
else return settings === 'limit' ? 1 : 1.1;
}
})();
return new SafeDecimal(price ?? 0).mul(multiplier).toString();
};
return {
Expand Down

0 comments on commit 62f1206

Please sign in to comment.