-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
218 changed files
with
3,072 additions
and
2,647 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,25 @@ | ||
import { useMemo } from 'react' | ||
|
||
import { useFeatureFlags } from '@cowprotocol/common-hooks' | ||
import { isLocal } from '@cowprotocol/common-utils' | ||
import { isLocal, isPr } from '@cowprotocol/common-utils' | ||
|
||
import { HOOKS_STORE_MENU_ITEM, MENU_ITEMS } from '../constants/routes' | ||
import { HOOKS_STORE_MENU_ITEM, MENU_ITEMS, YIELD_MENU_ITEM } from '../constants/routes' | ||
|
||
export function useMenuItems() { | ||
const { isHooksStoreEnabled } = useFeatureFlags() | ||
const { isYieldEnabled } = useFeatureFlags() | ||
|
||
return useMemo(() => { | ||
return isHooksStoreEnabled || isLocal ? MENU_ITEMS.concat(HOOKS_STORE_MENU_ITEM) : MENU_ITEMS | ||
const items = [...MENU_ITEMS] | ||
|
||
if (isHooksStoreEnabled || isLocal) { | ||
items.push(HOOKS_STORE_MENU_ITEM) | ||
} | ||
|
||
if (isYieldEnabled || isLocal || isPr) { | ||
items.push(YIELD_MENU_ITEM) | ||
} | ||
|
||
return items | ||
}, [isHooksStoreEnabled]) | ||
} |
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
71 changes: 71 additions & 0 deletions
71
apps/cowswap-frontend/src/common/utils/tradeSettingsTooltips.tsx
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,71 @@ | ||
import { | ||
INPUT_OUTPUT_EXPLANATION, | ||
MINIMUM_ETH_FLOW_DEADLINE_SECONDS, | ||
MINIMUM_ETH_FLOW_SLIPPAGE, | ||
PERCENTAGE_PRECISION, | ||
} from '@cowprotocol/common-const' | ||
import { SupportedChainId } from '@cowprotocol/cow-sdk' | ||
|
||
import { Trans } from '@lingui/macro' | ||
|
||
export function getNativeOrderDeadlineTooltip(symbols: (string | undefined)[] | undefined) { | ||
return ( | ||
<Trans> | ||
{symbols?.[0] || 'Native currency (e.g ETH)'} orders require a minimum transaction expiration time threshold of{' '} | ||
{MINIMUM_ETH_FLOW_DEADLINE_SECONDS / 60} minutes to ensure the best swapping experience. | ||
<br /> | ||
<br /> | ||
Orders not matched after the threshold time are automatically refunded. | ||
</Trans> | ||
) | ||
} | ||
|
||
export function getNonNativeOrderDeadlineTooltip() { | ||
return ( | ||
<Trans> | ||
Your swap expires and will not execute if it is pending for longer than the selected duration. | ||
<br /> | ||
<br /> | ||
{INPUT_OUTPUT_EXPLANATION} | ||
</Trans> | ||
) | ||
} | ||
|
||
export const getNativeSlippageTooltip = (chainId: SupportedChainId, symbols: (string | undefined)[] | undefined) => ( | ||
<Trans> | ||
When selling {symbols?.[0] || 'a native currency'}, the minimum slippage tolerance is set to{' '} | ||
{MINIMUM_ETH_FLOW_SLIPPAGE[chainId].toSignificant(PERCENTAGE_PRECISION)}% to ensure a high likelihood of order | ||
matching, even in volatile market conditions. | ||
<br /> | ||
<br /> | ||
{symbols?.[0] || 'Native currency'} orders can, in rare cases, be frontrun due to their on-chain component. For more | ||
robust MEV protection, consider wrapping your {symbols?.[0] || 'native currency'} before trading. | ||
</Trans> | ||
) | ||
|
||
export const getNonNativeSlippageTooltip = (params?: { isDynamic?: boolean; isSettingsModal?: boolean }) => ( | ||
<Trans> | ||
{params?.isDynamic ? ( | ||
<> | ||
CoW Swap dynamically adjusts your slippage tolerance to ensure your trade executes quickly while still getting | ||
the best price.{' '} | ||
{params?.isSettingsModal ? ( | ||
<> | ||
To override this, enter your desired slippage amount. | ||
<br /> | ||
<br /> | ||
Either way, your slippage is protected from MEV! | ||
</> | ||
) : ( | ||
<> | ||
<br /> | ||
<br /> | ||
Trades are protected from MEV, so your slippage can't be exploited! | ||
</> | ||
)} | ||
</> | ||
) : ( | ||
<>CoW Swap trades are protected from MEV, so your slippage can't be exploited!</> | ||
)} | ||
</Trans> | ||
) |
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
Oops, something went wrong.