include fees in tooltip

This commit is contained in:
mantikoros 2022-05-09 17:33:14 -04:00
parent 8a99f3772a
commit ef43e46153
2 changed files with 14 additions and 2 deletions

View File

@ -74,7 +74,7 @@ export function getCpmmLiquidityFee(
const totalFees = liquidityFee + platformFee + creatorFee
const remainingBet = bet - totalFees
return { remainingBet, fees }
return { remainingBet, totalFees, fees }
}
export function calculateCpmmSharesAfterFee(

View File

@ -27,7 +27,11 @@ import {
} from 'common/calculate'
import { useFocus } from 'web/hooks/use-focus'
import { useUserContractBets } from 'web/hooks/use-user-bets'
import { calculateCpmmSale, getCpmmProbability } from 'common/calculate-cpmm'
import {
calculateCpmmSale,
getCpmmProbability,
getCpmmLiquidityFee,
} from 'common/calculate-cpmm'
import { SellRow } from './sell-row'
import { useSaveShares } from './use-save-shares'
@ -281,6 +285,10 @@ function BuyPanel(props: {
const currentReturn = betAmount ? (currentPayout - betAmount) / betAmount : 0
const currentReturnPercent = formatPercent(currentReturn)
const cpmmFees =
contract.mechanism === 'cpmm-1' &&
getCpmmLiquidityFee(contract, betAmount ?? 0, betChoice ?? 'YES').totalFees
const dpmTooltip =
contract.mechanism === 'dpm-2'
? `Current payout for ${formatWithCommas(shares)} / ${formatWithCommas(
@ -335,6 +343,10 @@ function BuyPanel(props: {
)}
</div>
{cpmmFees !== false && (
<InfoTooltip text={`Includes ${formatMoney(cpmmFees)} in fees`} />
)}
{dpmTooltip && <InfoTooltip text={dpmTooltip} />}
</Row>
<Row className="flex-wrap items-end justify-end gap-2">