@@ -8,7 +8,7 @@ import { a, useSpring, useTrail } from "@react-spring/web";
88import { Button , VFlex , ShellpointIcon , TokenIcon } from "@liquity2/uikit" ;
99import { useState , useMemo , useEffect } from "react" ;
1010import { useBalance } from "@/src/wagmi-utils" ;
11- import { useShellActivitiesOfHolders , useWeightedActivitySnapshots , usePrivacyPoolSnapshots } from "@/src/shell-hooks" ;
11+ import { useShellActivitiesOfHolders , useWeightedActivitySnapshots , usePrivacyPoolSnapshots , useTotalShells , useNeriTotalSupply , calculateNeriAllocation } from "@/src/shell-hooks" ;
1212import { CONTRACT_ADDRESSES } from "@/src/contracts" ;
1313import { getAddress , isAddress , isAddressEqual } from "viem" ;
1414import { getEnsAddress , normalize } from "viem/ens" ;
@@ -149,6 +149,19 @@ export function ClaimScreen() {
149149 // Fetch privacy pool snapshots (GoSlow NFT)
150150 const { data : privacyPoolSnapshots } = usePrivacyPoolSnapshots ( lookupAddress ) ;
151151
152+ // Fetch total shells for NERI calculation
153+ const { data : totalShells } = useTotalShells ( ) ;
154+
155+ // Fetch NERI total supply from contract
156+ const { data : neriTotalSupply } = useNeriTotalSupply ( ) ;
157+
158+ // Calculate NERI allocation based on user's shell balance, total shells, and NERI supply
159+ const neriAllocation = useMemo ( ( ) => {
160+ if ( ! shellBalance || ! totalShells || totalShells === 0n || ! neriTotalSupply ) return 0n ;
161+ const userShells = shellBalance [ 0 ] ;
162+ return calculateNeriAllocation ( userShells , totalShells , neriTotalSupply ) ;
163+ } , [ shellBalance , totalShells , neriTotalSupply ] ) ;
164+
152165 // Get aggregated stats from weighted snapshots
153166 const activityStats = useMemo ( ( ) => {
154167 if ( ! weightedSnapshots || weightedSnapshots . length === 0 ) return null ;
@@ -241,10 +254,10 @@ export function ClaimScreen() {
241254 config : { mass : 1 , tension : 80 , friction : 30 } ,
242255 } ) ;
243256
244- // NERI amount animation (proportional to shells - placeholder conversion)
257+ // NERI amount animation
245258 const neriAmountSpring = useSpring ( {
246259 from : { number : 0 } ,
247- to : { number : revealed && shellBalance ? Number ( format ( shellBalance , 0 ) . replace ( / , / g , '' ) ) * 0.1 : 0 } ,
260+ to : { number : revealed && neriAllocation ? Number ( neriAllocation / 10n ** 18n ) : 0 } ,
248261 delay : revealed ? 400 : 0 ,
249262 config : { mass : 1 , tension : 80 , friction : 30 } ,
250263 } ) ;
0 commit comments