add tooltip to limit price difference

This commit is contained in:
saml33 2024-03-14 12:31:49 +11:00
parent 6a8ac4e676
commit 66a313bef2
8 changed files with 23 additions and 12 deletions

View File

@ -1,4 +1,6 @@
import { useMemo } from 'react'
import Tooltip from './Tooltip'
import { useTranslation } from 'react-i18next'
const TradePriceDifference = ({
currentPrice,
@ -7,6 +9,7 @@ const TradePriceDifference = ({
currentPrice: number | undefined
newPrice: number | undefined
}) => {
const { t } = useTranslation('trade')
const priceDifference = useMemo(() => {
if (!currentPrice || !newPrice) return 0
const difference = ((newPrice - currentPrice) / currentPrice) * 100
@ -14,16 +17,18 @@ const TradePriceDifference = ({
}, [currentPrice, newPrice])
return (
<p
className={`font-mono text-xs ${
priceDifference >= 0 ? 'text-th-up' : 'text-th-down'
}`}
>
{priceDifference
? (priceDifference > 0 ? '+' : '') + priceDifference.toFixed(2)
: '0.00'}
%
</p>
<Tooltip content={t('tooltip-limit-price-difference')}>
<p
className={`tooltip-underline font-mono text-xs ${
priceDifference >= 0 ? 'text-th-up' : 'text-th-down'
}`}
>
{priceDifference
? (priceDifference > 0 ? '+' : '') + priceDifference.toFixed(2)
: '0.00'}
%
</p>
</Tooltip>
)
}

View File

@ -130,6 +130,7 @@
"tooltip-ioc": "Immediate-Or-Cancel (IOC) orders are guaranteed to be the taker and must be executed immediately. Any portion of the order that can't be filled immediately will be cancelled",
"tooltip-insured": "Whether or not {{tokenOrMarket}} losses can be recovered from the insurance fund in the event of bankruptcies.",
"tooltip-lifetime-funding": "Total funding earned or paid in this market for your account. This value does not reset when you close and re-enter a position.",
"tooltip-limit-price-difference": "Percentage difference from the oracle price",
"tooltip-post": "Post orders are guaranteed to be the maker or they will be canceled",
"tooltip-size-base-quote": "Show size in {{token}}",
"tooltip-private-counterparty": "Counterparty has Private Account enabled",

View File

@ -130,6 +130,7 @@
"tooltip-ioc": "Immediate-Or-Cancel (IOC) orders are guaranteed to be the taker and must be executed immediately. Any portion of the order that can't be filled immediately will be cancelled",
"tooltip-insured": "Whether or not {{tokenOrMarket}} losses can be recovered from the insurance fund in the event of bankruptcies.",
"tooltip-lifetime-funding": "Total funding earned or paid in this market for your account. This value does not reset when you close and re-enter a position.",
"tooltip-limit-price-difference": "Percentage difference from the oracle price",
"tooltip-post": "Post orders are guaranteed to be the maker or they will be canceled",
"tooltip-size-base-quote": "Show size in {{token}}",
"tooltip-private-counterparty": "Counterparty has Private Account enabled",

View File

@ -130,6 +130,7 @@
"tooltip-ioc": "Ordens Immediate-Or-Cancel (IOC) são garantidas para serem taker e devem ser executadas imediatamente. Qualquer parte da ordem que não possa ser preenchida imediatamente será cancelada",
"tooltip-insured": "Se as perdas de {{tokenOrMarket}} podem ser recuperadas do fundo de seguro em caso de falências.",
"tooltip-lifetime-funding": "Total funding earned or paid in this market for your account. This value does not reset when you close and re-enter a position.",
"tooltip-limit-price-difference": "Percentage difference from the oracle price",
"tooltip-post": "Ordens post são garantidas para serem maker ou serão canceladas",
"tooltip-size-base-quote": "Mostrar tamanho em {{token}}",
"tooltip-private-counterparty": "Contraparte tem Conta Privada ativada",

View File

@ -130,6 +130,7 @@
"tooltip-ioc": "Immediate-Or-Cancel (IOC) orders are guaranteed to be the taker and must be executed immediately. Any portion of the order that can't be filled immediately will be cancelled",
"tooltip-insured": "Whether or not {{tokenOrMarket}} losses can be recovered from the insurance fund in the event of bankruptcies.",
"tooltip-lifetime-funding": "Total funding earned or paid in this market for your account. This value does not reset when you close and re-enter a position.",
"tooltip-limit-price-difference": "Percentage difference from the oracle price",
"tooltip-post": "Post orders are guaranteed to be the maker or they will be canceled",
"tooltip-size-base-quote": "Show size in {{token}}",
"tooltip-private-counterparty": "Counterparty has Private Account enabled",

View File

@ -130,6 +130,7 @@
"tooltip-insured": "如果发生破产,{{tokenOrMarket}}损失是否可以从保险基金中归还",
"tooltip-ioc": "IOC交易若不吃单就会被取消。任何无法立刻成交的部分将被取消",
"tooltip-lifetime-funding": "Total funding earned or paid in this market for your account. This value does not reset when you close and re-enter a position.",
"tooltip-limit-price-difference": "Percentage difference from the oracle price",
"tooltip-post": "Post交易若不挂单就会被取消。",
"tooltip-size-base-quote": "以{{token}}显示数量",
"tooltip-private-counterparty": "交易对手已启用私人帐户",

View File

@ -130,6 +130,7 @@
"tooltip-insured": "如果發生破產,{{tokenOrMarket}}損失是否可以從保險基金中歸還",
"tooltip-ioc": "IOC交易若不吃單就會被取消。任何無法立刻成交的部分將被取消",
"tooltip-lifetime-funding": "Total funding earned or paid in this market for your account. This value does not reset when you close and re-enter a position.",
"tooltip-limit-price-difference": "Percentage difference from the oracle price",
"tooltip-post": "Post交易若不掛單就會被取消。",
"tooltip-size-base-quote": "以{{token}}顯示數量",
"tooltip-private-counterparty": "交易對手已啟用私人帳戶",

View File

@ -2566,7 +2566,7 @@
dependencies:
"@solana/wallet-adapter-base" "^0.9.23"
"@solana/wallet-adapter-solflare@0.6.27", "@solana/wallet-adapter-solflare@^0.6.28":
"@solana/wallet-adapter-solflare@0.6.27":
version "0.6.27"
resolved "https://registry.yarnpkg.com/@solana/wallet-adapter-solflare/-/wallet-adapter-solflare-0.6.27.tgz#49ba2dfecca4bee048e65d302216d1b732d7e39e"
integrity sha512-MBBx9B1pI8ChCT70sgxrmeib1S7G9tRQzfMHqJPdGQ2jGtukY0Puzma2OBsIAsH5Aw9rUUUFZUK+8pzaE+mgAg==
@ -2577,7 +2577,7 @@
"@solflare-wallet/sdk" "^1.3.0"
"@wallet-standard/wallet" "^1.0.1"
"@solana/wallet-adapter-solflare@0.6.28":
"@solana/wallet-adapter-solflare@0.6.28", "@solana/wallet-adapter-solflare@^0.6.28":
version "0.6.28"
resolved "https://registry.yarnpkg.com/@solana/wallet-adapter-solflare/-/wallet-adapter-solflare-0.6.28.tgz#3de42a43220cca361050ebd1755078012a5b0fe2"
integrity sha512-iiUQtuXp8p4OdruDawsm1dRRnzUCcsu+lKo8OezESskHtbmZw2Ifej0P99AbJbBAcBw7q4GPI6987Vh05Si5rw==