Skip to content

Commit

Permalink
feat: revamp + improve LP dashboard (#883)
Browse files Browse the repository at this point in the history
* chore: upgrade vegaprotocol packages

* chore: port a whole bunch of stuff from monorepo

* Port healthbar

* Port announcement banner from monorepo

* bug: text for >2x target stake showing incorrectly

* feat: add dashed line to indicate trigger ratio on healthbar

* feat: change intent colour for healthbar depending on amount staked

* chore: add logging to see market content

* feat: add perpetual to query for market asset

* feat: set intent from liquidity staked rather than market status

* fix: tailwind classes properly generating & colour improvements for healthbar

* fix: remove spurious log

* feat: add liquidity SLA params to market query

* Feat: add column to lp dashboard showing liquidity SLA params

* chore: split SLA params out into multiple columns

* chore: add new keys for translating new lp dashboard copy

* feat: add pill showing market type

* chore: rename titles for sla columns

* fixup into pill change

* chore: update locale files

* feat: add buttons to filter by product type to lp dashboard

* feat: highlight selected filter nicely

* chore: move market type sticker to bottom of description block

* chore: update locales

* feat: use the amount in bond account for each party instead of committmentAmount
  • Loading branch information
ciaran- authored Nov 1, 2023
1 parent 1056205 commit 54c0629
Show file tree
Hide file tree
Showing 48 changed files with 4,654 additions and 3,341 deletions.
6 changes: 6 additions & 0 deletions locales/cn/component.healthbar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"Target stake": "",
"Auction Trigger stake": "",
"Fee": "",
"Providers greater than 2x target stake not shown": ""
}
5 changes: 4 additions & 1 deletion locales/cn/page.liquidity-provision.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"Does not operate or run the Vega Blockchain or any other blockchain": "不操作或运行 Vega 区块链或任何其他区块链",
"Does not create, generate or warrant the accuracy of the data": "不创建、生成或保证数据的准确性",
"Has no liability for any loss arising from the use of that data.": "对于因使用该数据而产生的任何损失不承担任何责任",
"Futures": "期货",
"Market": "市场",
"The market name, code and settlement asset": "市场名称、代码及结算资产",
"Mark Price": "市场价格",
Expand All @@ -17,6 +16,10 @@
"The current amount of liquidity supplied for this market.": "当前为该市场提供的流动性数量",
"Liquidity Fee": "流动性费用",
"The fee percentage (per trade) charged by liquidity providers on this market": "该市场上流动性提供者收取的费用百分比(每笔交易)",
"Min time on book": "",
"The minimum percentage of market time on book liquidity providers are expected to be available for this market": "",
"Liquidity price range": "",
"The minimum amount of volume liquidity providers are expected to have available for this market": "",
"Volume (24h)": "成交量(24小时)",
"The total number of contracts traded in the last 24 hours.": "最近24小时内交易的合约总数。",
"Market Status": "市场状况",
Expand Down
5 changes: 4 additions & 1 deletion locales/cn/page.liquidity-provision_old.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"Use Vega": "使用VEGA",
"Provide Liquidity": "提供流动性”"
"Provide Liquidity": "提供流动性”",
"SLA: Time on Book": "",
"SLA: Volume": "",
"Futures": "期货"
}
6 changes: 6 additions & 0 deletions locales/en/component.healthbar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"Target stake": "",
"Auction Trigger stake": "",
"Fee": "",
"Providers greater than 2x target stake not shown": ""
}
5 changes: 4 additions & 1 deletion locales/en/page.liquidity-provision.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"Does not operate or run the Vega Blockchain or any other blockchain": "Does not operate or run the Vega Blockchain or any other blockchain",
"Does not create, generate or warrant the accuracy of the data": "Does not create, generate or warrant the accuracy of the data",
"Has no liability for any loss arising from the use of that data.": "Has no liability for any loss arising from the use of that data.",
"Futures": "Futures",
"Market": "Market",
"The market name, code and settlement asset": "The market name, code and settlement asset",
"Mark Price": "Mark Price",
Expand All @@ -17,6 +16,10 @@
"The current amount of liquidity supplied for this market.": "The current amount of liquidity supplied for this market.",
"Liquidity Fee": "Liquidity Fee",
"The fee percentage (per trade) charged by liquidity providers on this market": "The fee percentage (per trade) charged by liquidity providers on this market",
"Min time on book": "",
"The minimum percentage of market time on book liquidity providers are expected to be available for this market": "",
"Liquidity price range": "",
"The minimum amount of volume liquidity providers are expected to have available for this market": "",
"Volume (24h)": "Volume (24h)",
"The total number of contracts traded in the last 24 hours.": "The total number of contracts traded in the last 24 hours.",
"Market Status": "Market Status",
Expand Down
5 changes: 4 additions & 1 deletion locales/en/page.liquidity-provision_old.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"Use Vega": "Use Vega",
"Provide Liquidity": "Provide Liquidity"
"Provide Liquidity": "Provide Liquidity",
"SLA: Time on Book": "",
"SLA: Volume": "",
"Futures": "Futures"
}
6 changes: 6 additions & 0 deletions locales/es/component.healthbar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"Target stake": "",
"Auction Trigger stake": "",
"Fee": "",
"Providers greater than 2x target stake not shown": ""
}
5 changes: 4 additions & 1 deletion locales/es/page.liquidity-provision.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"Does not operate or run the Vega Blockchain or any other blockchain": "No opera ni ejecuta Vega Blockchain ni ninguna otra cadena de bloques.",
"Does not create, generate or warrant the accuracy of the data": "No crea, genera ni garantiza la exactitud de los datos.",
"Has no liability for any loss arising from the use of that data.": "No tiene ninguna responsabilidad por cualquier pérdida que surja del uso de esos datos.",
"Futures": "Futuros",
"Market": "Mercado",
"The market name, code and settlement asset": "El nombre del mercado, código y activo de liquidación",
"Mark Price": "Marcar Precio",
Expand All @@ -17,6 +16,10 @@
"The current amount of liquidity supplied for this market.": "La cantidad actual de liquidez suministrada para este mercado.",
"Liquidity Fee": "Comisión de Liquidez",
"The fee percentage (per trade) charged by liquidity providers on this market": "El porcentaje de comisión (por operación) que cobran los proveedores de liquidez en este mercado",
"Min time on book": "",
"The minimum percentage of market time on book liquidity providers are expected to be available for this market": "",
"Liquidity price range": "",
"The minimum amount of volume liquidity providers are expected to have available for this market": "",
"Volume (24h)": "Volumen (24h)",
"The total number of contracts traded in the last 24 hours.": "El número total de contratos negociados en las últimas 24 horas.",
"Market Status": "Modo de comercio",
Expand Down
5 changes: 4 additions & 1 deletion locales/es/page.liquidity-provision_old.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"Use Vega": "Usa Vega",
"Provide Liquidity": "Proporcionar Liquidez"
"Provide Liquidity": "Proporcionar Liquidez",
"SLA: Time on Book": "",
"SLA: Volume": "",
"Futures": "Futuros"
}
6 changes: 6 additions & 0 deletions locales/ko/component.healthbar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"Target stake": "",
"Auction Trigger stake": "",
"Fee": "",
"Providers greater than 2x target stake not shown": ""
}
5 changes: 4 additions & 1 deletion locales/ko/page.liquidity-provision.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"Does not operate or run the Vega Blockchain or any other blockchain": "",
"Does not create, generate or warrant the accuracy of the data": "",
"Has no liability for any loss arising from the use of that data.": "",
"Futures": "",
"Market": "시장",
"The market name, code and settlement asset": "시장명, 코드 및 정산 자산",
"Mark Price": "시장평균가",
Expand All @@ -17,6 +16,10 @@
"The current amount of liquidity supplied for this market.": "현재 이 시장에 공급되는 유동성의 양입니다.",
"Liquidity Fee": "유동성 수수료",
"The fee percentage (per trade) charged by liquidity providers on this market": "이 시장에서 유동성 공급자가 부과하는 수수료 비율(거래당)",
"Min time on book": "",
"The minimum percentage of market time on book liquidity providers are expected to be available for this market": "",
"Liquidity price range": "",
"The minimum amount of volume liquidity providers are expected to have available for this market": "",
"Volume (24h)": "거래량 (24h)",
"The total number of contracts traded in the last 24 hours.": "지난 24시간 동안 거래된 총 계약 수입니다.",
"Market Status": "시장 상태",
Expand Down
5 changes: 4 additions & 1 deletion locales/ko/page.liquidity-provision_old.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"Use Vega": "Vega 사용하기",
"Provide Liquidity": "유동성 공급하기"
"Provide Liquidity": "유동성 공급하기",
"SLA: Time on Book": "",
"SLA: Volume": "",
"Futures": ""
}
6 changes: 6 additions & 0 deletions locales/ru/component.healthbar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"Target stake": "",
"Auction Trigger stake": "",
"Fee": "",
"Providers greater than 2x target stake not shown": ""
}
5 changes: 4 additions & 1 deletion locales/ru/page.liquidity-provision.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"Does not operate or run the Vega Blockchain or any other blockchain": "Не эксплуатирует и не запускает блокчейн Vega или любой другой блокчейн",
"Does not create, generate or warrant the accuracy of the data": "Не создает, не генерирует и не гарантирует точность данных",
"Has no liability for any loss arising from the use of that data.": "Не несет ответственности за любые убытки, связанные с использованием этих данных.",
"Futures": "Фьючерсы",
"Market": "Рынок",
"The market name, code and settlement asset": "Название рынка, код и расчетный актив",
"Mark Price": "Цена маркировки",
Expand All @@ -17,6 +16,10 @@
"The current amount of liquidity supplied for this market.": "Текущий объем ликвидности, поставляемой на данный рынок.",
"Liquidity Fee": "Комиссия за ликвидность",
"The fee percentage (per trade) charged by liquidity providers on this market": "Процент комиссии (за сделку), взимаемой поставщиками ликвидности на данном рынке",
"Min time on book": "",
"The minimum percentage of market time on book liquidity providers are expected to be available for this market": "",
"Liquidity price range": "",
"The minimum amount of volume liquidity providers are expected to have available for this market": "",
"Volume (24h)": "Объем (24 ч)",
"The total number of contracts traded in the last 24 hours.": "Общее количество контрактов, торгуемых за последние 24 часа.",
"Market Status": "Режим торговли",
Expand Down
5 changes: 4 additions & 1 deletion locales/ru/page.liquidity-provision_old.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"Use Vega": "Используйте Vega",
"Provide Liquidity": "Обеспечить ликвидность"
"Provide Liquidity": "Обеспечить ликвидность",
"SLA: Time on Book": "",
"SLA: Volume": "",
"Futures": "Фьючерсы"
}
6 changes: 6 additions & 0 deletions locales/vi/component.healthbar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"Target stake": "",
"Auction Trigger stake": "",
"Fee": "",
"Providers greater than 2x target stake not shown": ""
}
5 changes: 4 additions & 1 deletion locales/vi/page.liquidity-provision.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"Does not operate or run the Vega Blockchain or any other blockchain": "Không vận hành hoặc chạy Vega Blockchain hoặc bất kỳ chuỗi khối nào khác",
"Does not create, generate or warrant the accuracy of the data": "Không tạo, đưa ra hoặc đảm bảo tính chính xác của dữ liệu",
"Has no liability for any loss arising from the use of that data.": "Miễn trừ trách nhiệm cho bất kỳ tổn thất nào phát sinh từ việc sử dụng dữ liệu đó.",
"Futures": "Hợp đồng tương lai",
"Market": "Thị trường",
"The market name, code and settlement asset": "Tên thị trường, mã và tài sản thanh toán",
"Mark Price": "Giá đánh dấu",
Expand All @@ -17,6 +16,10 @@
"The current amount of liquidity supplied for this market.": "Lượng thanh khoản hiện tại được cung cấp cho thị trường này.",
"Liquidity Fee": "phí thanh khoản",
"The fee percentage (per trade) charged by liquidity providers on this market": "Phần trăm phí (trên mỗi giao dịch) được tính bởi các nhà cung cấp thanh khoản trên thị trường này",
"Min time on book": "",
"The minimum percentage of market time on book liquidity providers are expected to be available for this market": "",
"Liquidity price range": "",
"The minimum amount of volume liquidity providers are expected to have available for this market": "",
"Volume (24h)": "Khối lượng giao dịch (24h)",
"The total number of contracts traded in the last 24 hours.": "Tổng số hợp đồng được giao dịch trong 24 giờ qua.",
"Market Status": "Trạng thái thị trường",
Expand Down
5 changes: 4 additions & 1 deletion locales/vi/page.liquidity-provision_old.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"Use Vega": "Sử dụng Vega",
"Provide Liquidity": "Cung cấp thanh khoản"
"Provide Liquidity": "Cung cấp thanh khoản",
"SLA: Time on Book": "",
"SLA: Volume": "",
"Futures": "Hợp đồng tương lai"
}
17 changes: 6 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@
"@tailwindcss/aspect-ratio": "^0.4.0",
"@tailwindcss/typography": "^0.5.2",
"@tippyjs/react": "^4.2.6",
"@vegaprotocol/announcements": "^0.0.1",
"@vegaprotocol/i18n": "0.0.3",
"@vegaprotocol/react-helpers": "0.2.4",
"@vegaprotocol/tailwindcss-config": "0.0.3",
"@vegaprotocol/types": "0.0.3",
"@vegaprotocol/ui-toolkit": "0.12.6",
"@vegaprotocol/utils": "0.0.6",
"@radix-ui/react-tooltip": "^1.0.3",
"@vercel/analytics": "^1.0.1",
"@vercel/gatsby-plugin-vercel-analytics": "^1.0.10",
"@vercel/kv": "^0.2.2",
Expand All @@ -41,6 +35,7 @@
"aws-sdk": "^2.1188.0",
"babel-plugin-styled-components": "^2.0.7",
"bignumber.js": "^9.0.2",
"classnames": "^2.3.1",
"dotenv": "^16.0.1",
"ethers": "^5.6.0",
"framer-motion": "^6.3.11",
Expand Down Expand Up @@ -68,8 +63,8 @@
"openpgp": "^5.3.1",
"postcss": "^8.4.14",
"raw-loader": "^4.0.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-helmet": "^6.1.0",
"react-i18next": "^11.18.0",
"react-intersection-observer": "^9.3.3",
Expand All @@ -90,8 +85,8 @@
"@tailwindcss/line-clamp": "^0.4.0",
"@tippyjs/react": "^4.2.6",
"@types/node": "^18.11.9",
"@types/react": "^18.0.25",
"@types/react-dom": "^18.0.9",
"@types/react": "18.2.13",
"@types/react-dom": "18.2.6",
"@types/styled-components": "^5.1.26",
"@typescript-eslint/parser": "^5.42.1",
"add": "^2.0.6",
Expand Down
125 changes: 125 additions & 0 deletions src/components/AnnouncementRemote.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import React, { useEffect, useState } from 'react'
import type { ReactNode } from 'react'
import classnames from 'classnames'
import type { AppNameType, Announcement } from '../utils/announcements/schema'
import {
useAnnouncement,
useDismissedAnnouncement,
} from '../hooks/use-announcement'
import { ExternalLink } from './ExternalLink'

export type AnnouncementBannerProps = {
app: AppNameType
configUrl: string
}

export interface BannerProps {
children?: ReactNode
className?: string
}

export const Banner = ({ className, children }: BannerProps) => {
const bannerClasses = classnames(
"bg-[url('https://static.vega.xyz/assets/img/banner-bg.jpg')] bg-cover bg-center bg-no-repeat",
'p-4',
className
)

return <div className={bannerClasses}>{children}</div>
}

// run only if below the allowed maximum delay ~24.8 days (https://developer.mozilla.org/en-US/docs/Web/API/setTimeout#maximum_delay_value)
const MAX_DELAY = 2147483648

const doesStartInTheFuture = (now: Date, data: Announcement) => {
return data.timing?.from
? now < data.timing.from &&
data.timing.from.valueOf() - now.valueOf() < MAX_DELAY
: false
}

const doesEndInTheFuture = (now: Date, data: Announcement) => {
return data.timing?.to
? now < data.timing.to &&
data.timing.to.valueOf() - now.valueOf() < MAX_DELAY
: false
}

export const AnnouncementBanner = ({
app,
configUrl,
}: AnnouncementBannerProps) => {
const [isVisible, setVisible] = useState(false)
const { data, reload } = useAnnouncement(app, configUrl)
const [, setDismissed] = useDismissedAnnouncement()

useEffect(() => {
const now = new Date()
let stampFrom: NodeJS.Timeout
let stampTo: NodeJS.Timeout

if (data) {
const startsInTheFuture = doesStartInTheFuture(now, data)
const endsInTheFuture = doesEndInTheFuture(now, data)

if (!startsInTheFuture) {
setVisible(true)
}

if (data.timing?.from && startsInTheFuture) {
stampFrom = setTimeout(() => {
setVisible(true)
}, data.timing.from.valueOf() - now.valueOf())
}

if (data.timing?.to && endsInTheFuture) {
stampTo = setTimeout(() => {
setVisible(false)
reload()
}, data.timing.to.valueOf() - now.valueOf())
}
}

return () => {
clearTimeout(stampFrom)
clearTimeout(stampTo)
}
}, [data, reload, setVisible])

if (!data || !isVisible) {
return <div />
}

return (
<Banner className="relative px-10">
<div
data-testid="app-announcement"
className="font-alpha relative flex justify-center gap-2 text-center text-lg text-white"
>
<span>{data.text}</span>{' '}
{data.urlText && data.url && (
<ExternalLink href={data.url}>{data.urlText}</ExternalLink>
)}
</div>
<button
className="absolute right-0 top-0 flex h-full w-10 items-center justify-center p-4 text-white"
data-testid="app-announcement-close"
onClick={() => {
setVisible(false)
setDismissed(data)
}}
>
<IconCross size={24} />
</button>
</Banner>
)
}

export const IconCross = ({ size = 16 }: { size: number }) => {
return (
<svg width={size} height={size} viewBox="0 0 16 16">
<path d="M13.3745 3.37476L3.37453 13.3748L2.625 12.6252L12.625 2.62523L13.3745 3.37476Z" />
<path d="M3.37453 2.62523L13.3745 12.6252L12.625 13.3748L2.625 3.37476L3.37453 2.62523Z" />
</svg>
)
}
Loading

0 comments on commit 54c0629

Please sign in to comment.