-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: revamp + improve LP dashboard (#883)
* 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
Showing
48 changed files
with
4,654 additions
and
3,341 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
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": "" | ||
} |
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,4 +1,7 @@ | ||
{ | ||
"Use Vega": "使用VEGA", | ||
"Provide Liquidity": "提供流动性”" | ||
"Provide Liquidity": "提供流动性”", | ||
"SLA: Time on Book": "", | ||
"SLA: Volume": "", | ||
"Futures": "期货" | ||
} |
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,6 @@ | ||
{ | ||
"Target stake": "", | ||
"Auction Trigger stake": "", | ||
"Fee": "", | ||
"Providers greater than 2x target stake not shown": "" | ||
} |
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,4 +1,7 @@ | ||
{ | ||
"Use Vega": "Use Vega", | ||
"Provide Liquidity": "Provide Liquidity" | ||
"Provide Liquidity": "Provide Liquidity", | ||
"SLA: Time on Book": "", | ||
"SLA: Volume": "", | ||
"Futures": "Futures" | ||
} |
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,6 @@ | ||
{ | ||
"Target stake": "", | ||
"Auction Trigger stake": "", | ||
"Fee": "", | ||
"Providers greater than 2x target stake not shown": "" | ||
} |
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,4 +1,7 @@ | ||
{ | ||
"Use Vega": "Usa Vega", | ||
"Provide Liquidity": "Proporcionar Liquidez" | ||
"Provide Liquidity": "Proporcionar Liquidez", | ||
"SLA: Time on Book": "", | ||
"SLA: Volume": "", | ||
"Futures": "Futuros" | ||
} |
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,6 @@ | ||
{ | ||
"Target stake": "", | ||
"Auction Trigger stake": "", | ||
"Fee": "", | ||
"Providers greater than 2x target stake not shown": "" | ||
} |
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,4 +1,7 @@ | ||
{ | ||
"Use Vega": "Vega 사용하기", | ||
"Provide Liquidity": "유동성 공급하기" | ||
"Provide Liquidity": "유동성 공급하기", | ||
"SLA: Time on Book": "", | ||
"SLA: Volume": "", | ||
"Futures": "" | ||
} |
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,6 @@ | ||
{ | ||
"Target stake": "", | ||
"Auction Trigger stake": "", | ||
"Fee": "", | ||
"Providers greater than 2x target stake not shown": "" | ||
} |
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,4 +1,7 @@ | ||
{ | ||
"Use Vega": "Используйте Vega", | ||
"Provide Liquidity": "Обеспечить ликвидность" | ||
"Provide Liquidity": "Обеспечить ликвидность", | ||
"SLA: Time on Book": "", | ||
"SLA: Volume": "", | ||
"Futures": "Фьючерсы" | ||
} |
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,6 @@ | ||
{ | ||
"Target stake": "", | ||
"Auction Trigger stake": "", | ||
"Fee": "", | ||
"Providers greater than 2x target stake not shown": "" | ||
} |
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,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" | ||
} |
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,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> | ||
) | ||
} |
Oops, something went wrong.