-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: show eth denominated value for legacy users
- Loading branch information
1 parent
f3f166b
commit ba0aec9
Showing
5 changed files
with
73 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { useState } from 'react' | ||
|
||
import { useUserCrabV2TxHistory } from './useUserCrabV2TxHistory' | ||
import useAppEffect from './useAppEffect' | ||
import { CrabStrategyV2TxType, CrabStrategyTxType } from 'src/types' | ||
|
||
// legacy as in users who deposited before ETH deposit was removed | ||
export const useCheckLegacyCrabV2User = (address: string) => { | ||
const [isLegacyUser, setLegacyUser] = useState(false) | ||
|
||
const { data } = useUserCrabV2TxHistory(address ?? '') | ||
|
||
useAppEffect(() => { | ||
// launch date of new design, when we removed ETH deposit / withdraw | ||
const launchDate = new Date('2022-12-28T00:00:00.000Z').getTime() / 1000 | ||
|
||
const isLegacy = | ||
data?.some((tx) => { | ||
const isDepositTx = | ||
tx.type === CrabStrategyV2TxType.FLASH_DEPOSIT || | ||
tx.type === CrabStrategyV2TxType.DEPOSIT || | ||
tx.type === CrabStrategyV2TxType.DEPOSIT_V1 || | ||
tx.type === CrabStrategyTxType.DEPOSIT || | ||
tx.type === CrabStrategyV2TxType.OTC_DEPOSIT | ||
|
||
return isDepositTx && tx.timestamp < launchDate | ||
}) ?? false | ||
|
||
setLegacyUser(isLegacy) | ||
}, [data]) | ||
|
||
return isLegacyUser | ||
} |