-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: format usd prices, add loading states (#3196)
* format usd prices, add loading states * remove tildes, collapse details by default * update swap deadline to use seconds * update syntax for loading states
- Loading branch information
Showing
8 changed files
with
52 additions
and
20 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
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,22 @@ | ||
import { BigNumber } from '@ethersproject/bignumber' | ||
import { L2_CHAIN_IDS } from 'constants/chains' | ||
import { L2_DEADLINE_FROM_NOW } from 'constants/misc' | ||
import useCurrentBlockTimestamp from 'hooks/useCurrentBlockTimestamp' | ||
import { useAtomValue } from 'jotai/utils' | ||
import { transactionTtlAtom } from 'lib/state/settings' | ||
import { useMemo } from 'react' | ||
|
||
import useActiveWeb3React from './useActiveWeb3React' | ||
|
||
// combines the block timestamp with the user setting to give the deadline that should be used for any submitted transaction | ||
export default function useTransactionDeadline(): BigNumber | undefined { | ||
const { chainId } = useActiveWeb3React() | ||
const userDeadline = useAtomValue(transactionTtlAtom) | ||
const blockTimestamp = useCurrentBlockTimestamp() | ||
return useMemo(() => { | ||
if (blockTimestamp && chainId && L2_CHAIN_IDS.includes(chainId)) return blockTimestamp.add(L2_DEADLINE_FROM_NOW) | ||
//@TODO(ianlapham): update this to be stored as seconds | ||
if (blockTimestamp && userDeadline) return blockTimestamp.add(userDeadline * 60) // adjust for seconds | ||
return undefined | ||
}, [blockTimestamp, chainId, userDeadline]) | ||
} |
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