Skip to content

Commit

Permalink
fix: ts compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyd-eth committed Dec 30, 2024
1 parent 0ec5223 commit 349bff8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/packages/v4/hooks/useETHReceivedFromTokens.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { getTokenCashOutQuoteEth } from 'juice-sdk-core'
import {
useJBContractContext,
useJBRulesetContext,
Expand All @@ -7,6 +6,8 @@ import {
useReadJbTokensTotalSupplyOf,
} from 'juice-sdk-react'

import { getTokenCashOutQuoteEth } from 'juice-sdk-core'

export function useETHReceivedFromTokens(
tokenAmountWei: bigint | undefined,
): bigint | undefined {
Expand Down Expand Up @@ -35,12 +36,14 @@ export function useETHReceivedFromTokens(
}

try {
return getTokenCashOutQuoteEth(tokenAmountWei, {
const eth = getTokenCashOutQuoteEth(tokenAmountWei, {
cashOutTaxRate: Number(cashOutTaxRate),
totalSupply,
tokensReserved,
overflowWei: nativeTokenSurplus,
})
// v4TODO: make SDK return 0n, not 0
return eth === 0 ? 0n : eth
} catch (e) {
// Division by zero can cause a RangeError
if (e instanceof RangeError) {
Expand Down

0 comments on commit 349bff8

Please sign in to comment.