fix(trading): fees page issues (#5217)
This commit is contained in:
parent
f780013846
commit
0776332ba7
@ -36,6 +36,22 @@ query Fees(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
referrer: referralSets(referrer: $partyId) {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
id
|
||||||
|
referrer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
referee: referralSets(referee: $partyId) {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
id
|
||||||
|
referrer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
referralSetReferees(referee: $partyId) {
|
referralSetReferees(referee: $partyId) {
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
|
@ -15,7 +15,7 @@ export type FeesQueryVariables = Types.Exact<{
|
|||||||
}>;
|
}>;
|
||||||
|
|
||||||
|
|
||||||
export type FeesQuery = { __typename?: 'Query', epoch: { __typename?: 'Epoch', id: string }, volumeDiscountStats: { __typename?: 'VolumeDiscountStatsConnection', edges: Array<{ __typename?: 'VolumeDiscountStatsEdge', node: { __typename?: 'VolumeDiscountStats', atEpoch: number, discountFactor: string, runningVolume: string } } | null> }, referralSetReferees: { __typename?: 'ReferralSetRefereeConnection', edges: Array<{ __typename?: 'ReferralSetRefereeEdge', node: { __typename?: 'ReferralSetReferee', atEpoch: number } } | null> }, referralSetStats: { __typename?: 'ReferralSetStatsConnection', edges: Array<{ __typename?: 'ReferralSetStatsEdge', node: { __typename?: 'ReferralSetStats', atEpoch: number, discountFactor: string, referralSetRunningNotionalTakerVolume: string } } | null> } };
|
export type FeesQuery = { __typename?: 'Query', epoch: { __typename?: 'Epoch', id: string }, volumeDiscountStats: { __typename?: 'VolumeDiscountStatsConnection', edges: Array<{ __typename?: 'VolumeDiscountStatsEdge', node: { __typename?: 'VolumeDiscountStats', atEpoch: number, discountFactor: string, runningVolume: string } } | null> }, referrer: { __typename?: 'ReferralSetConnection', edges: Array<{ __typename?: 'ReferralSetEdge', node: { __typename?: 'ReferralSet', id: string, referrer: string } } | null> }, referee: { __typename?: 'ReferralSetConnection', edges: Array<{ __typename?: 'ReferralSetEdge', node: { __typename?: 'ReferralSet', id: string, referrer: string } } | null> }, referralSetReferees: { __typename?: 'ReferralSetRefereeConnection', edges: Array<{ __typename?: 'ReferralSetRefereeEdge', node: { __typename?: 'ReferralSetReferee', atEpoch: number } } | null> }, referralSetStats: { __typename?: 'ReferralSetStatsConnection', edges: Array<{ __typename?: 'ReferralSetStatsEdge', node: { __typename?: 'ReferralSetStats', atEpoch: number, discountFactor: string, referralSetRunningNotionalTakerVolume: string } } | null> } };
|
||||||
|
|
||||||
|
|
||||||
export const DiscountProgramsDocument = gql`
|
export const DiscountProgramsDocument = gql`
|
||||||
@ -81,6 +81,22 @@ export const FeesDocument = gql`
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
referrer: referralSets(referrer: $partyId) {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
id
|
||||||
|
referrer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
referee: referralSets(referee: $partyId) {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
id
|
||||||
|
referrer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
referralSetReferees(referee: $partyId) {
|
referralSetReferees(referee: $partyId) {
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
|
@ -17,6 +17,14 @@ import { useReferralStats } from './use-referral-stats';
|
|||||||
import { formatPercentage, getAdjustedFee } from './utils';
|
import { formatPercentage, getAdjustedFee } from './utils';
|
||||||
import { Table, Td, Th, THead, Tr } from './table';
|
import { Table, Td, Th, THead, Tr } from './table';
|
||||||
import BigNumber from 'bignumber.js';
|
import BigNumber from 'bignumber.js';
|
||||||
|
import { Links } from '../../lib/links';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
import {
|
||||||
|
Tooltip,
|
||||||
|
VegaIcon,
|
||||||
|
VegaIconNames,
|
||||||
|
truncateMiddle,
|
||||||
|
} from '@vegaprotocol/ui-toolkit';
|
||||||
|
|
||||||
export const FeesContainer = () => {
|
export const FeesContainer = () => {
|
||||||
const { pubKey } = useVegaWallet();
|
const { pubKey } = useVegaWallet();
|
||||||
@ -56,16 +64,25 @@ export const FeesContainer = () => {
|
|||||||
referralTierIndex,
|
referralTierIndex,
|
||||||
referralTiers,
|
referralTiers,
|
||||||
epochsInSet,
|
epochsInSet,
|
||||||
|
code,
|
||||||
|
isReferrer,
|
||||||
} = useReferralStats(
|
} = useReferralStats(
|
||||||
feesData?.referralSetStats,
|
feesData?.referralSetStats,
|
||||||
feesData?.referralSetReferees,
|
feesData?.referralSetReferees,
|
||||||
programData?.currentReferralProgram,
|
programData?.currentReferralProgram,
|
||||||
feesData?.epoch
|
feesData?.epoch,
|
||||||
|
feesData?.referrer,
|
||||||
|
feesData?.referee
|
||||||
);
|
);
|
||||||
|
|
||||||
const loading = paramsLoading || feesLoading || programLoading;
|
const loading = paramsLoading || feesLoading || programLoading;
|
||||||
const isConnected = Boolean(pubKey);
|
const isConnected = Boolean(pubKey);
|
||||||
|
|
||||||
|
const isReferralProgramRunning = Boolean(programData?.currentReferralProgram);
|
||||||
|
const isVolumeDiscountProgramRunning = Boolean(
|
||||||
|
programData?.currentVolumeDiscountProgram
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="grid auto-rows-min grid-cols-4 gap-3">
|
<div className="grid auto-rows-min grid-cols-4 gap-3">
|
||||||
{isConnected && (
|
{isConnected && (
|
||||||
@ -90,6 +107,8 @@ export const FeesContainer = () => {
|
|||||||
<TotalDiscount
|
<TotalDiscount
|
||||||
referralDiscount={referralDiscount}
|
referralDiscount={referralDiscount}
|
||||||
volumeDiscount={volumeDiscount}
|
volumeDiscount={volumeDiscount}
|
||||||
|
isReferralProgramRunning={isReferralProgramRunning}
|
||||||
|
isVolumeDiscountProgramRunning={isVolumeDiscountProgramRunning}
|
||||||
/>
|
/>
|
||||||
</FeeCard>
|
</FeeCard>
|
||||||
<FeeCard
|
<FeeCard
|
||||||
@ -97,23 +116,37 @@ export const FeesContainer = () => {
|
|||||||
className="sm:col-span-2"
|
className="sm:col-span-2"
|
||||||
loading={loading}
|
loading={loading}
|
||||||
>
|
>
|
||||||
<CurrentVolume
|
{isVolumeDiscountProgramRunning ? (
|
||||||
tiers={volumeTiers}
|
<CurrentVolume
|
||||||
tierIndex={volumeTierIndex}
|
tiers={volumeTiers}
|
||||||
windowLengthVolume={volumeInWindow}
|
tierIndex={volumeTierIndex}
|
||||||
windowLength={volumeDiscountWindowLength}
|
windowLengthVolume={volumeInWindow}
|
||||||
/>
|
windowLength={volumeDiscountWindowLength}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<p className="pt-3 text-sm text-muted">
|
||||||
|
{t('No volume discount program active')}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
</FeeCard>
|
</FeeCard>
|
||||||
<FeeCard
|
<FeeCard
|
||||||
title={t('Referral benefits')}
|
title={t('Referral benefits')}
|
||||||
className="sm:col-span-2"
|
className="sm:col-span-2"
|
||||||
loading={loading}
|
loading={loading}
|
||||||
>
|
>
|
||||||
<ReferralBenefits
|
{isReferrer ? (
|
||||||
setRunningNotionalTakerVolume={referralVolumeInWindow}
|
<ReferrerInfo code={code} />
|
||||||
epochsInSet={epochsInSet}
|
) : isReferralProgramRunning ? (
|
||||||
epochs={referralDiscountWindowLength}
|
<ReferralBenefits
|
||||||
/>
|
setRunningNotionalTakerVolume={referralVolumeInWindow}
|
||||||
|
epochsInSet={epochsInSet}
|
||||||
|
epochs={referralDiscountWindowLength}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<p className="pt-3 text-sm text-muted">
|
||||||
|
{t('No referral program active')}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
</FeeCard>
|
</FeeCard>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
@ -142,7 +175,7 @@ export const FeesContainer = () => {
|
|||||||
/>
|
/>
|
||||||
</FeeCard>
|
</FeeCard>
|
||||||
<FeeCard
|
<FeeCard
|
||||||
title={t('Liquidity fees')}
|
title={t('Fees by market')}
|
||||||
className="lg:col-span-full"
|
className="lg:col-span-full"
|
||||||
loading={marketsLoading}
|
loading={marketsLoading}
|
||||||
>
|
>
|
||||||
@ -325,26 +358,64 @@ const ReferralBenefits = ({
|
|||||||
const TotalDiscount = ({
|
const TotalDiscount = ({
|
||||||
referralDiscount,
|
referralDiscount,
|
||||||
volumeDiscount,
|
volumeDiscount,
|
||||||
|
isReferralProgramRunning,
|
||||||
|
isVolumeDiscountProgramRunning,
|
||||||
}: {
|
}: {
|
||||||
referralDiscount: number;
|
referralDiscount: number;
|
||||||
volumeDiscount: number;
|
volumeDiscount: number;
|
||||||
|
isReferralProgramRunning: boolean;
|
||||||
|
isVolumeDiscountProgramRunning: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
|
const totalDiscount = 1 - (1 - volumeDiscount) * (1 - referralDiscount);
|
||||||
|
const totalDiscountDescription = t(
|
||||||
|
'The total discount is calculated according to the following formula: '
|
||||||
|
);
|
||||||
|
const formula = (
|
||||||
|
<span className="italic">
|
||||||
|
1 - (1 - d<sub>volume</sub>) ⋇ (1 - d<sub>referral</sub>)
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Stat
|
<Stat
|
||||||
value={formatPercentage(referralDiscount + volumeDiscount) + '%'}
|
description={
|
||||||
|
<>
|
||||||
|
{totalDiscountDescription}
|
||||||
|
{formula}
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
value={formatPercentage(totalDiscount) + '%'}
|
||||||
highlight={true}
|
highlight={true}
|
||||||
/>
|
/>
|
||||||
<table className="w-full mt-0.5 text-xs text-muted">
|
<table className="w-full mt-0.5 text-xs text-muted">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<th className="font-normal text-left">{t('Volume discount')}</th>
|
<th className="font-normal text-left">{t('Volume discount')}</th>
|
||||||
<td className="text-right">{formatPercentage(volumeDiscount)}%</td>
|
<td className="text-right">
|
||||||
|
{formatPercentage(volumeDiscount)}%
|
||||||
|
{!isVolumeDiscountProgramRunning && (
|
||||||
|
<Tooltip description={t('No active volume discount programme')}>
|
||||||
|
<span className="cursor-help">
|
||||||
|
{' '}
|
||||||
|
<VegaIcon name={VegaIconNames.INFO} size={12} />
|
||||||
|
</span>
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th className="font-normal text-left ">{t('Referral discount')}</th>
|
<th className="font-normal text-left ">{t('Referral discount')}</th>
|
||||||
<td className="text-right">
|
<td className="text-right">
|
||||||
{formatPercentage(referralDiscount)}%
|
{formatPercentage(referralDiscount)}%
|
||||||
|
{!isReferralProgramRunning && (
|
||||||
|
<Tooltip description={t('No active referral programme')}>
|
||||||
|
<span className="cursor-help">
|
||||||
|
{' '}
|
||||||
|
<VegaIcon name={VegaIconNames.INFO} size={12} />
|
||||||
|
</span>
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -491,3 +562,31 @@ const YourTier = () => {
|
|||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const ReferrerInfo = ({ code }: { code?: string }) => (
|
||||||
|
<div className="pt-3 text-sm text-vega-clight-200 dark:vega-cdark-200">
|
||||||
|
<p className="mb-1">
|
||||||
|
{t('Connected key is owner of the referral set')}
|
||||||
|
{code && (
|
||||||
|
<>
|
||||||
|
{' '}
|
||||||
|
<span className="text-transparent bg-rainbow bg-clip-text">
|
||||||
|
{truncateMiddle(code)}
|
||||||
|
</span>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{'. '}
|
||||||
|
{t('As owner, it is eligible for commission not fee discounts.')}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
{t('See')}{' '}
|
||||||
|
<Link
|
||||||
|
className="underline text-black dark:text-white"
|
||||||
|
to={Links.REFERRALS()}
|
||||||
|
>
|
||||||
|
{t('Referrals')}
|
||||||
|
</Link>{' '}
|
||||||
|
{t('for more information.')}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
@ -1,23 +1,31 @@
|
|||||||
|
import { Tooltip } from '@vegaprotocol/ui-toolkit';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
import type { ReactNode } from 'react';
|
||||||
|
|
||||||
export const Stat = ({
|
export const Stat = ({
|
||||||
value,
|
value,
|
||||||
text,
|
text,
|
||||||
highlight,
|
highlight,
|
||||||
|
description,
|
||||||
}: {
|
}: {
|
||||||
value: string | number;
|
value: string | number;
|
||||||
text?: string;
|
text?: string;
|
||||||
highlight?: boolean;
|
highlight?: boolean;
|
||||||
|
description?: ReactNode;
|
||||||
}) => {
|
}) => {
|
||||||
|
const val = (
|
||||||
|
<span
|
||||||
|
className={classNames('inline-block text-3xl leading-none', {
|
||||||
|
'text-transparent bg-rainbow bg-clip-text': highlight,
|
||||||
|
'cursor-help': description,
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
{value}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
return (
|
return (
|
||||||
<p className="pt-3 leading-none first:pt-6">
|
<p className="pt-3 leading-none first:pt-6">
|
||||||
<span
|
{description ? <Tooltip description={description}>{val}</Tooltip> : val}
|
||||||
className={classNames('inline-block text-3xl leading-none', {
|
|
||||||
'text-transparent bg-rainbow bg-clip-text': highlight,
|
|
||||||
})}
|
|
||||||
>
|
|
||||||
{value}
|
|
||||||
</span>
|
|
||||||
{text && (
|
{text && (
|
||||||
<small className="block mt-0.5 text-xs text-muted">{text}</small>
|
<small className="block mt-0.5 text-xs text-muted">{text}</small>
|
||||||
)}
|
)}
|
||||||
|
@ -73,6 +73,8 @@ describe('useReferralStats', () => {
|
|||||||
referralTierIndex: -1,
|
referralTierIndex: -1,
|
||||||
referralTiers: [],
|
referralTiers: [],
|
||||||
epochsInSet: 0,
|
epochsInSet: 0,
|
||||||
|
code: undefined,
|
||||||
|
isReferrer: false,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -93,6 +95,8 @@ describe('useReferralStats', () => {
|
|||||||
referralTierIndex: 1,
|
referralTierIndex: 1,
|
||||||
referralTiers: program.benefitTiers,
|
referralTiers: program.benefitTiers,
|
||||||
epochsInSet: Number(epoch.id) - set.atEpoch,
|
epochsInSet: Number(epoch.id) - set.atEpoch,
|
||||||
|
code: undefined,
|
||||||
|
isReferrer: false,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2,12 +2,15 @@ import compact from 'lodash/compact';
|
|||||||
import maxBy from 'lodash/maxBy';
|
import maxBy from 'lodash/maxBy';
|
||||||
import { getReferralBenefitTier } from './utils';
|
import { getReferralBenefitTier } from './utils';
|
||||||
import type { DiscountProgramsQuery, FeesQuery } from './__generated__/Fees';
|
import type { DiscountProgramsQuery, FeesQuery } from './__generated__/Fees';
|
||||||
|
import { first } from 'lodash';
|
||||||
|
|
||||||
export const useReferralStats = (
|
export const useReferralStats = (
|
||||||
setStats?: FeesQuery['referralSetStats'],
|
setStats?: FeesQuery['referralSetStats'],
|
||||||
setReferees?: FeesQuery['referralSetReferees'],
|
setReferees?: FeesQuery['referralSetReferees'],
|
||||||
program?: DiscountProgramsQuery['currentReferralProgram'],
|
program?: DiscountProgramsQuery['currentReferralProgram'],
|
||||||
epoch?: FeesQuery['epoch']
|
epoch?: FeesQuery['epoch'],
|
||||||
|
setIfReferrer?: FeesQuery['referrer'],
|
||||||
|
setIfReferee?: FeesQuery['referee']
|
||||||
) => {
|
) => {
|
||||||
const referralTiers = program?.benefitTiers || [];
|
const referralTiers = program?.benefitTiers || [];
|
||||||
|
|
||||||
@ -18,9 +21,18 @@ export const useReferralStats = (
|
|||||||
referralTierIndex: -1,
|
referralTierIndex: -1,
|
||||||
referralTiers,
|
referralTiers,
|
||||||
epochsInSet: 0,
|
epochsInSet: 0,
|
||||||
|
code: undefined,
|
||||||
|
isReferrer: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const setIfReferrerData = first(
|
||||||
|
compact(setIfReferrer?.edges).map((e) => e.node)
|
||||||
|
);
|
||||||
|
const setIfRefereeData = first(
|
||||||
|
compact(setIfReferee?.edges).map((e) => e.node)
|
||||||
|
);
|
||||||
|
|
||||||
const referralSetsStats = compact(setStats.edges).map((e) => e.node);
|
const referralSetsStats = compact(setStats.edges).map((e) => e.node);
|
||||||
const referralSets = compact(setReferees.edges).map((e) => e.node);
|
const referralSets = compact(setReferees.edges).map((e) => e.node);
|
||||||
|
|
||||||
@ -48,5 +60,7 @@ export const useReferralStats = (
|
|||||||
referralTierIndex,
|
referralTierIndex,
|
||||||
referralTiers,
|
referralTiers,
|
||||||
epochsInSet,
|
epochsInSet,
|
||||||
|
code: (setIfReferrerData || setIfRefereeData)?.id,
|
||||||
|
isReferrer: Boolean(setIfReferrerData),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -21,7 +21,7 @@ describe('getAdjustedFee', () => {
|
|||||||
new BigNumber(referralDiscount),
|
new BigNumber(referralDiscount),
|
||||||
];
|
];
|
||||||
|
|
||||||
// 1 - 0.5 - 0.5
|
// 1 - 0.5 = 0.5
|
||||||
const v = new BigNumber(1).minus(new BigNumber(volumeDiscount));
|
const v = new BigNumber(1).minus(new BigNumber(volumeDiscount));
|
||||||
|
|
||||||
// 1 - 0.5 = 0.5
|
// 1 - 0.5 = 0.5
|
||||||
@ -34,13 +34,15 @@ describe('getAdjustedFee', () => {
|
|||||||
// 0.1 + 0.1 + 0.1 = 0.3
|
// 0.1 + 0.1 + 0.1 = 0.3
|
||||||
const totalFees = fees.reduce((sum, x) => sum.plus(x), new BigNumber(0));
|
const totalFees = fees.reduce((sum, x) => sum.plus(x), new BigNumber(0));
|
||||||
|
|
||||||
// 0.3 * 0.75 = 0.225
|
// (1 - 0.3) * 0.75 = 0.525
|
||||||
const expected = new BigNumber(totalFees).times(factor).toNumber();
|
const expected = new BigNumber(totalFees)
|
||||||
|
.times(new BigNumber(1).minus(factor))
|
||||||
|
.toNumber();
|
||||||
|
|
||||||
expect(getAdjustedFee(fees, discounts)).toBe(expected);
|
expect(getAdjustedFee(fees, discounts)).toBe(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('combines discount factors multiplicativly', () => {
|
it('combines discount factors multiplicatively', () => {
|
||||||
const volumeDiscount = 0.4;
|
const volumeDiscount = 0.4;
|
||||||
const referralDiscount = 0.1;
|
const referralDiscount = 0.1;
|
||||||
|
|
||||||
@ -67,7 +69,9 @@ describe('getAdjustedFee', () => {
|
|||||||
// summed fees
|
// summed fees
|
||||||
const totalFees = fees.reduce((sum, x) => sum.plus(x), new BigNumber(0));
|
const totalFees = fees.reduce((sum, x) => sum.plus(x), new BigNumber(0));
|
||||||
|
|
||||||
const expected = new BigNumber(totalFees).times(factor).toNumber();
|
const expected = new BigNumber(totalFees)
|
||||||
|
.times(new BigNumber(1).minus(factor))
|
||||||
|
.toNumber();
|
||||||
|
|
||||||
expect(getAdjustedFee(fees, discounts)).toBe(expected);
|
expect(getAdjustedFee(fees, discounts)).toBe(expected);
|
||||||
});
|
});
|
||||||
|
@ -12,7 +12,9 @@ export const formatPercentage = (num: number) => {
|
|||||||
const pct = new BigNumber(num).times(100);
|
const pct = new BigNumber(num).times(100);
|
||||||
const dps = pct.decimalPlaces();
|
const dps = pct.decimalPlaces();
|
||||||
const formatter = new Intl.NumberFormat(getUserLocale(), {
|
const formatter = new Intl.NumberFormat(getUserLocale(), {
|
||||||
minimumFractionDigits: dps || 0,
|
// set to 0 in order to remove the "trailing zeroes" for numbers such as:
|
||||||
|
// 0.123456789 -non-zero-min-> 12.3456800% -zero-min-> 12.34568%
|
||||||
|
minimumFractionDigits: 0,
|
||||||
maximumFractionDigits: dps || 0,
|
maximumFractionDigits: dps || 0,
|
||||||
});
|
});
|
||||||
return formatter.format(parseFloat(pct.toFixed(5)));
|
return formatter.format(parseFloat(pct.toFixed(5)));
|
||||||
@ -101,5 +103,7 @@ export const getAdjustedFee = (fees: BigNumber[], discounts: BigNumber[]) => {
|
|||||||
|
|
||||||
const totalFactor = new BigNumber(1).minus(combinedFactors);
|
const totalFactor = new BigNumber(1).minus(combinedFactors);
|
||||||
|
|
||||||
return totalFee.times(BigNumber.max(0, totalFactor)).toNumber();
|
return totalFee
|
||||||
|
.times(new BigNumber(1).minus(BigNumber.max(0, totalFactor)))
|
||||||
|
.toNumber();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user