Skip to content

Commit

Permalink
fix: Roi crash when full range selected
Browse files Browse the repository at this point in the history
  • Loading branch information
memoyil committed Apr 22, 2023
1 parent 98a6dbe commit 05bb837
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ export function AprCalculator({
volume24H={volume24H}
priceUpper={priceUpper}
priceLower={priceLower}
fullRangeSelected={formState.rightRangeTypedValue === true && formState.leftRangeTypedValue === true}
priceSpan={priceSpan}
onPriceSpanChange={setPriceSpan}
onApply={onApply}
Expand Down
3 changes: 3 additions & 0 deletions packages/uikit/src/widgets/RoiCalculator/RoiCalculator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export type RoiCalculatorProps = {
price?: Price<Token, Token>;
priceLower?: Price<Token, Token>;
priceUpper?: Price<Token, Token>;
fullRangeSelected?: boolean;
currencyAUsdPrice?: number;
currencyBUsdPrice?: number;
depositAmountInUsd?: number | string;
Expand Down Expand Up @@ -94,6 +95,7 @@ export function RoiCalculator({
price,
priceLower,
priceUpper,
fullRangeSelected,
volume24H,
maxLabel,
max,
Expand Down Expand Up @@ -175,6 +177,7 @@ export function RoiCalculator({
quoteCurrency: currencyB,
priceLower,
priceUpper,
fullRangeSelected,
});
const { getDecrementLower, getIncrementLower, getDecrementUpper, getIncrementUpper } = useRangeHopCallbacks(
currencyA,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface Params {
quoteCurrency?: Currency;
priceLower?: Price<Currency, Currency>;
priceUpper?: Price<Currency, Currency>;
fullRangeSelected?: boolean;
}

interface PriceRangeInfo {
Expand All @@ -39,8 +40,9 @@ export function usePriceRange({
feeAmount,
priceLower: initialPriceLower,
priceUpper: initialPriceUpper,
fullRangeSelected,
}: Params): PriceRangeInfo | null {
const [fullRange, setFullRange] = useState(false);
const [fullRange, setFullRange] = useState(!!fullRangeSelected);
const [priceLower, setPriceLower] = useState<Price<Currency, Currency> | undefined>(initialPriceLower);
const [priceUpper, setPriceUpper] = useState<Price<Currency, Currency> | undefined>(initialPriceUpper);

Expand Down

0 comments on commit 05bb837

Please sign in to comment.