Skip to content

Commit

Permalink
refactor: extract lp fee estimation utility
Browse files Browse the repository at this point in the history
  • Loading branch information
alexp3y committed Sep 26, 2024
1 parent 483f9ec commit f1cc29a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/app/pages/swap/bitflow-swap-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { useStacksBroadcastSwap } from './hooks/use-stacks-broadcast-swap';
import { SwapFormValues } from './hooks/use-swap-form';
import { useSwapNavigate } from './hooks/use-swap-navigate';
import { SwapContext, SwapProvider } from './swap.context';
import { estimateLiquidityFee } from './swap.utils';

export const bitflowSwapRoutes = generateSwapRoutes(<BitflowSwapContainer />);

Expand Down Expand Up @@ -71,7 +72,7 @@ function BitflowSwapContainer() {
fee: defaultSwapFee.amount.toString(),
feeCurrency: values.feeCurrency,
feeType: values.feeType,
liquidityFee: 0.3 * routeQuote.route.dex_path.length,
liquidityFee: estimateLiquidityFee(routeQuote.route.dex_path),
nonce: values.nonce,
protocol: 'Bitflow',
dexPath: routeQuote.route.dex_path || [],
Expand Down
4 changes: 4 additions & 0 deletions src/app/pages/swap/swap.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import {
unitToFractionalUnit,
} from '@leather.io/utils';

export function estimateLiquidityFee(dexPath: string[]) {
return 0.3 * dexPath.length;
}

export function convertInputAmountValueToFiat(balance: Money, price: MarketData, value: string) {
const valueAsMoney = createMoney(
unitToFractionalUnit(balance.decimals)(value),
Expand Down

0 comments on commit f1cc29a

Please sign in to comment.