From 9a7c21a9803d84d580d058097ff84c7950da6a85 Mon Sep 17 00:00:00 2001 From: Dmitry Lobachevsky Date: Thu, 9 Oct 2025 08:42:00 +0200 Subject: [PATCH] fix: handle edge cases in referral program logic for zero address and vault address comparison --- .../hooks/referral/use-referral-program.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/core-kit/hooks/referral/use-referral-program.ts b/src/core-kit/hooks/referral/use-referral-program.ts index b8f78089..2f6bc948 100644 --- a/src/core-kit/hooks/referral/use-referral-program.ts +++ b/src/core-kit/hooks/referral/use-referral-program.ts @@ -3,6 +3,7 @@ import { useEffect } from 'react' import { LOCAL_STORAGE_KEYS } from 'core-kit/const' import { useBrowserStorage } from 'core-kit/hooks/utils' import type { UseReferralProgramProps } from 'core-kit/types' +import { isZeroAddress } from 'core-kit/utils' const REFERRAL_QUERY = 'ref' @@ -26,18 +27,28 @@ export const useReferralProgram = ({ const refQuery = query[REFERRAL_QUERY] useEffect(() => { - if (!refQuery || typeof refQuery !== 'string') return + if ( + !refQuery || + typeof refQuery !== 'string' || + isZeroAddress(vaultAddress) + ) + return if (localStorage.getItem(LOCAL_STORAGE_KEYS.REFERRER)) { return } - logEvent?.() setReferredBy(refQuery) setRefPool(vaultAddress) + logEvent?.() }, [vaultAddress, refQuery, setRefPool, setReferredBy, logEvent]) useEffect(() => { - if (!userAddress || !referredBy || refPool !== vaultAddress) return + if ( + !userAddress || + !referredBy || + refPool.toLowerCase() !== vaultAddress.toLowerCase() + ) + return const tagInvestor = async () => { try {