Skip to content

Commit

Permalink
fix(apps/earn): no liquidity edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
chillichelli committed Mar 23, 2023
1 parent 9806e3d commit 87d2d42
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions apps/earn/components/AddSection/AddSectionTrident.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { FC, useCallback, useMemo, useState } from 'react'
import { useTokensFromPool } from '../../lib/hooks'
import { AddSectionReviewModalTrident } from './AddSectionReviewModalTrident'
import { AddSectionWidget } from './AddSectionWidget'
import { ZERO } from '@sushiswap/math'

export const AddSectionTrident: FC<{ pool: Pool }> = ({ pool: _pool }) => {
const isMounted = useIsMounted()
Expand Down Expand Up @@ -52,7 +53,11 @@ export const AddSectionTrident: FC<{ pool: Pool }> = ({ pool: _pool }) => {

const onChangeToken0TypedAmount = useCallback(
(value: string) => {
if (poolState === ConstantProductPoolState.NOT_EXISTS || poolState === StablePoolState.NOT_EXISTS) {
if (
poolState === ConstantProductPoolState.NOT_EXISTS ||
poolState === StablePoolState.NOT_EXISTS ||
(pool?.reserve0.equalTo(ZERO) && pool?.reserve1.equalTo(ZERO))
) {
setTypedAmounts((prev) => ({
...prev,
input0: value,
Expand All @@ -70,7 +75,11 @@ export const AddSectionTrident: FC<{ pool: Pool }> = ({ pool: _pool }) => {

const onChangeToken1TypedAmount = useCallback(
(value: string) => {
if (poolState === ConstantProductPoolState.NOT_EXISTS || poolState === StablePoolState.NOT_EXISTS) {
if (
poolState === ConstantProductPoolState.NOT_EXISTS ||
poolState === StablePoolState.NOT_EXISTS ||
(pool?.reserve0.equalTo(ZERO) && pool?.reserve1.equalTo(ZERO))
) {
setTypedAmounts((prev) => ({
...prev,
input1: value,
Expand Down

0 comments on commit 87d2d42

Please sign in to comment.