Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(twap): add missing tooltips #2843

Merged
merged 6 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/modules/ordersTable/pure/ReceiptModal/fields/SafeTxFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,28 @@ export function SafeTxFields(props: SafeTxFieldsProps) {
return (
<>
<Field>
<FieldLabel label="Safe transaction" tooltip="TODO: set tooltip" prefix={safeLogoImg} />
<FieldLabel label="Safe transaction" tooltip="The hash for this Safe transaction." prefix={safeLogoImg} />
<div>
<span>{safeTxHash.slice(0, 8)}</span> {' - '}
<SafeWalletLink chainId={chainId} safeTransaction={safeTransaction} />
</div>
</Field>

<Field>
<FieldLabel label="Safe nonce" tooltip="TODO: set tooltip" prefix={safeLogoImg} />
<FieldLabel
label="Safe nonce"
tooltip='Safe contracts have a so-called "nonce." This is to ensure that each transaction can be executed only once so no replay attacks are possible.'
prefix={safeLogoImg}
/>
<span>{nonce}</span>
</Field>

<Field>
<FieldLabel label="Safe confirmed signatures" tooltip="TODO: set tooltip" prefix={safeLogoImg} />
<FieldLabel
label="Safe confirmed signatures"
tooltip="The number of signers who have confirmed this transaction versus the number of signer confirmations needed."
prefix={safeLogoImg}
/>
<span>
{confirmations} / {confirmationsRequired}
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ import { RateWrapper } from 'common/pure/RateInfo'
type Props = {
price: Nullish<Price<Currency, Currency>>
isInvertedState: [boolean, Dispatch<SetStateAction<boolean>>]
limitPriceLabel?: React.ReactNode
limitPriceTooltip?: React.ReactNode
}

export function LimitPriceRow(props: Props) {
const { price, isInvertedState } = props
const { price, isInvertedState, limitPriceLabel = 'Limit price', limitPriceTooltip = 'The limit price' } = props
const [isInverted, setIsInverted] = isInvertedState

return (
<RateWrapper onClick={() => setIsInverted((curr) => !curr)}>
<ConfirmDetailsItem tooltip="TODO: limit price tooltip text" label="Limit price (incl fee/slippage)">
<ConfirmDetailsItem label={limitPriceLabel} tooltip={limitPriceTooltip}>
{price ? (
<ExecutionPrice executionPrice={price} isInverted={isInverted} showBaseCurrency separatorSymbol="=" />
) : (
Expand Down
14 changes: 10 additions & 4 deletions src/modules/trade/containers/TradeBasicConfirmDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,20 @@ type Props = {
}

type AdditionalProps = {
priceLabel?: string | undefined
priceLabel?: React.ReactNode
minReceivedLabel?: React.ReactNode
minReceivedTooltip?: React.ReactNode
limitPriceLabel?: React.ReactNode
limitPriceTooltip?: React.ReactNode
}

export function TradeBasicConfirmDetails(props: Props) {
const { rateInfoParams, minReceiveAmount, isInvertedState, slippage, additionalProps } = props
const { inputCurrencyAmount } = rateInfoParams

const priceLabel = additionalProps?.priceLabel || 'Price'
const minReceivedLabel = additionalProps?.minReceivedLabel || 'Min received (incl. fee)'
const minReceivedTooltip = additionalProps?.minReceivedTooltip || 'This is the minimum amount that you will receive.'

const minReceivedUsdAmount = useHigherUSDValue(minReceiveAmount)

Expand All @@ -53,14 +59,14 @@ export function TradeBasicConfirmDetails(props: Props) {
<SlippageRow slippage={slippage} />

{/* Limit Price */}
<LimitPriceRow price={limitPrice} isInvertedState={isInvertedState} />
<LimitPriceRow price={limitPrice} isInvertedState={isInvertedState} {...additionalProps} />

{/* Min received */}
<ReviewOrderModalAmountRow
amount={minReceiveAmount}
fiatAmount={minReceivedUsdAmount}
tooltip="TODO: Min received tooltip"
label="Min received (incl. fee/slippage)"
tooltip={minReceivedTooltip}
label={minReceivedLabel}
/>
</styledEl.Wrapper>
)
Expand Down
2 changes: 1 addition & 1 deletion src/modules/trade/pure/ConfirmDetailsItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Content, Row, Wrapper } from './styled'

export type ConfirmDetailsItemProps = {
children: ReactNode
label?: string
label?: ReactNode
tooltip?: ReactNode
withArrow?: boolean
fiatAmount?: string
Expand Down
2 changes: 1 addition & 1 deletion src/modules/trade/pure/ReviewOrderModalAmountRow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export type ReviewOrderAmountRowProps = {
amount: Nullish<CurrencyAmount<Currency>>
fiatAmount?: Nullish<CurrencyAmount<Currency>>
tooltip?: ReactNode
label: string
label: ReactNode
isAmountAccurate?: boolean
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,31 +47,43 @@ export const TwapConfirmDetails = React.memo(function TwapConfirmDetails(props:
<ReviewOrderModalAmountRow
amount={inputPartAmount}
fiatAmount={inputFiatAmount}
tooltip="TODO: add tooltip"
tooltip="This is the amount that will be sold in each part of the TWAP order."
label={'Sell' + amountLabelSuffix}
/>

{/* Buy amount per part */}
<ReviewOrderModalAmountRow
amount={outputPartAmount}
fiatAmount={outputFiatAmount}
tooltip="TODO: add tooltip"
tooltip="This is the estimated amount you will receive for each part of the TWAP order."
label={'Buy' + amountLabelSuffix}
isAmountAccurate={false}
/>

{/* Start time */}
<ConfirmDetailsItem tooltip="TODO: add tooltip" label={'Start time first' + partsSuffix} withArrow={false}>
<ConfirmDetailsItem
tooltip="The first part of your TWAP order will become active as soon as you confirm the order below."
label={'Start time first' + partsSuffix}
withArrow={false}
>
Now
</ConfirmDetailsItem>

{/* Part duration */}
<ConfirmDetailsItem tooltip="TODO: add tooltip" label="Part duration" withArrow={false}>
<ConfirmDetailsItem
tooltip="The time each part of your TWAP order will remain active."
label="Part duration"
withArrow={false}
>
{partDurationDisplay}
</ConfirmDetailsItem>

{/* Total duration */}
<ConfirmDetailsItem tooltip="TODO: add tooltip" label="Total duration" withArrow={false}>
<ConfirmDetailsItem
tooltip="The time before your total TWAP order ends."
label="Total duration"
withArrow={false}
>
{totalDurationDisplay}
</ConfirmDetailsItem>
</Wrapper>
Expand Down
14 changes: 13 additions & 1 deletion src/modules/twap/containers/TwapConfirmModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,19 @@ export function TwapConfirmModal({ fallbackHandlerIsNotSet }: TwapConfirmModalPr
minReceiveAmount={minReceivedAmount}
isInvertedState={isInvertedState}
slippage={slippage}
additionalProps={{ priceLabel: 'Price (incl. fee)' }}
additionalProps={{
priceLabel: 'Price (incl. fee)',
minReceivedLabel: 'Min received (incl. fee/slippage)',
minReceivedTooltip:
'This is the minimum amount that you will receive across your entire TWAP order, assuming all parts of the order execute.',
limitPriceLabel: 'Limit price (incl fee/slippage)',
limitPriceTooltip: (
<>
If CoW Swap cannot get this price or better after fees and slippage are taken into account, your TWAP
will not execute. CoW Swap will <strong>always</strong> improve on this price if possible.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MindyCoW maybe this one can be a bit more positive? in the other part we were taking about price protection, so maybe we should mention sth like "CoW Swap will protect your order from executing at an unfavorable price"...

</>
),
}}
/>
<TwapConfirmDetails
startTime={twapOrder?.startTime}
Expand Down
Loading