Skip to content

Commit

Permalink
fix(swap): disable swap when limit 0
Browse files Browse the repository at this point in the history
  • Loading branch information
banklesss committed Oct 20, 2023
1 parent 1cf980f commit 7154654
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export const SwapFormProvider = ({
const {tokenId: buyTokenId, quantity: buyQuantity} = orderData.amounts.buy
const {tokenId: sellTokenId, quantity: sellQuantity} = orderData.amounts.sell

const buyTokenInfo = useTokenInfo({wallet, tokenId: orderData.amounts.buy.tokenId})
const sellTokenInfo = useTokenInfo({wallet, tokenId: orderData.amounts.sell.tokenId})
const buyTokenInfo = useTokenInfo({wallet, tokenId: buyTokenId})
const sellTokenInfo = useTokenInfo({wallet, tokenId: sellTokenId})

const balances = useBalances(wallet)
const sellbalance = Amounts.getAmount(balances, sellTokenId).quantity
Expand Down Expand Up @@ -99,10 +99,11 @@ export const SwapFormProvider = ({
state.sellQuantity.isTouched &&
!Quantities.isZero(buyQuantity) &&
!Quantities.isZero(sellQuantity) &&
!Quantities.isZero(sellQuantity) &&
state.buyQuantity.error === undefined &&
state.sellQuantity.error === undefined &&
((orderData.type === 'limit' && orderData.limitPrice !== undefined && !Quantities.isZero(orderData.limitPrice)) ||
orderData.selectedPoolCalculation !== undefined)
(orderData.type === 'market' && orderData.selectedPoolCalculation !== undefined))

const actions = React.useRef<SwapFormActions>({
sellTouched: () => dispatch({type: SwapFormActionType.SellTouched}),
Expand Down

0 comments on commit 7154654

Please sign in to comment.