Skip to content

Commit a665b18

Browse files
authored
fix: add fee rebates (#1914)
1 parent eaddfa7 commit a665b18

File tree

3 files changed

+35
-15
lines changed

3 files changed

+35
-15
lines changed

src/hooks/rewards/hooks.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { DydxAddress } from '@/constants/wallets';
66
import { useAppSelector } from '@/state/appTypes';
77

88
import { wrapAndLogError } from '@/lib/asyncUtils';
9+
import { mapIfPresent } from '@/lib/do';
910

1011
import { useQueryChaosLabsIncentives } from '../useQueryChaosLabsIncentives';
1112
import {
@@ -110,10 +111,16 @@ export const useChaosLabsUsdRewards = ({
110111
});
111112

112113
return {
113-
data: pointsToEstimatedDollarRewards(
114-
points?.incentivePoints,
115-
totalPoints?.totalPoints,
116-
totalUsdRewards
114+
data: mapIfPresent(
115+
pointsToEstimatedDollarRewards(
116+
points?.incentivePoints,
117+
totalPoints?.totalPoints,
118+
totalUsdRewards
119+
),
120+
points?.totalFees,
121+
(pointRewards, feesPaid) => {
122+
return pointRewards + feesPaid;
123+
}
117124
),
118125
isLoading: totalPointsLoading || pointsLoading,
119126
};

src/hooks/useQueryChaosLabsIncentives.ts

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import { useQuery } from '@tanstack/react-query';
2+
import { DateTime } from 'luxon';
23

34
import type { DydxAddress } from '@/constants/wallets';
45

56
import { wrapAndLogError } from '@/lib/asyncUtils';
67
import { calc } from '@/lib/do';
78

89
type ChaosLabsIncentivesResponse = {
9-
dydxRewards: number;
1010
incentivePoints: number;
1111
marketMakingIncentivePoints: number;
12+
totalFees: number;
1213
};
1314

1415
export const useQueryChaosLabsIncentives = ({
@@ -18,11 +19,11 @@ export const useQueryChaosLabsIncentives = ({
1819
dydxAddress?: DydxAddress;
1920
season?: number;
2021
}) => {
21-
return useQuery<ChaosLabsIncentivesResponse | undefined, Error>({
22+
return useQuery({
2223
enabled: !!dydxAddress,
2324
queryKey: ['launch_incentives_rewards', dydxAddress, season],
2425
queryFn: wrapAndLogError(
25-
async () => {
26+
async (): Promise<ChaosLabsIncentivesResponse | undefined> => {
2627
if (!dydxAddress) return undefined;
2728

2829
// If season is defined, fetch for a specific season
@@ -42,17 +43,27 @@ export const useQueryChaosLabsIncentives = ({
4243
return undefined;
4344
}
4445

45-
const thisSeasonResponse = await calc(async () => {
46-
return (
47-
await fetch(
48-
`https://cloud.chaoslabs.co/query/api/dydx/points/${dydxAddress}?n=${currentSeason}`
49-
)
50-
).json();
51-
});
46+
const [thisSeasonResponse, thisSeasonFees] = await Promise.all([
47+
calc(async () => {
48+
return (
49+
await fetch(
50+
`https://cloud.chaoslabs.co/query/api/dydx/points/${dydxAddress}?n=${currentSeason}`
51+
)
52+
).json();
53+
}),
54+
calc(async () => {
55+
return (
56+
await fetch(
57+
`https://cloud.chaoslabs.co/query/api/dydx/fees/${dydxAddress}?month=${DateTime.utc().toFormat('yyyy-MM')}`
58+
)
59+
).json();
60+
}),
61+
]);
5262

5363
return {
5464
incentivePoints: thisSeasonResponse.incentivePoints ?? 0,
5565
marketMakingIncentivePoints: thisSeasonResponse.marketMakingIncentivePoints ?? 0,
66+
totalFees: thisSeasonFees.data?.[0]?.total_fees ?? 0,
5667
};
5768
},
5869
'LaunchIncentives/fetchPoints',

src/pages/token/LaunchIncentivesPanel.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import tw from 'twin.macro';
77
import { ButtonAction } from '@/constants/buttons';
88
import { DialogTypes } from '@/constants/dialogs';
99
import { STRING_KEYS } from '@/constants/localization';
10+
import { isDev } from '@/constants/networks';
1011
import { TOKEN_DECIMALS } from '@/constants/numbers';
1112
import { StatsigFlags } from '@/constants/statsig';
1213

@@ -43,7 +44,8 @@ export const LaunchIncentivesPanel = ({ className }: { className?: string }) =>
4344
dispatch(markLaunchIncentivesSeen());
4445
}, [dispatch]);
4546

46-
const isSept2025Rewards = useStatsigGateValue(StatsigFlags.ffSeptember2025Rewards);
47+
const isSept2025RewardsBase = useStatsigGateValue(StatsigFlags.ffSeptember2025Rewards);
48+
const isSept2025Rewards = isDev ? true : isSept2025RewardsBase;
4749
if (isSept2025Rewards) {
4850
return <September2025RewardsPanel />;
4951
}

0 commit comments

Comments
 (0)