From ef43e46153eee15345787a694744c44df13a53f0 Mon Sep 17 00:00:00 2001 From: mantikoros Date: Mon, 9 May 2022 17:33:14 -0400 Subject: [PATCH] include fees in tooltip --- common/calculate-cpmm.ts | 2 +- web/components/bet-panel.tsx | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/common/calculate-cpmm.ts b/common/calculate-cpmm.ts index 4c0d30eb..ffe04133 100644 --- a/common/calculate-cpmm.ts +++ b/common/calculate-cpmm.ts @@ -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( diff --git a/web/components/bet-panel.tsx b/web/components/bet-panel.tsx index 2f9064c7..679af415 100644 --- a/web/components/bet-panel.tsx +++ b/web/components/bet-panel.tsx @@ -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: { )} + {cpmmFees !== false && ( + + )} + {dpmTooltip && }