Skip to content
Open
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
36 changes: 35 additions & 1 deletion src/containers/ProtocolOverview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,22 @@ export const ProtocolOverview = (props: IProtocolOverviewPageData) => {
return formattedNum(value, true)
}

const compareProtocolsUrl = useMemo(() => {
// If this is a combined protocol with child versions, compare the child protocols
if (props.otherProtocols && props.otherProtocols.length > 1) {
const childProtocols = props.otherProtocols
.slice(1, 4)
.map((p) => `protocol=${encodeURIComponent(p)}`)
.join('&')
return `/compare-protocols?${childProtocols}`
}
// Otherwise, compare with top competitor if available
if (props.competitors?.length) {
return `/compare-protocols?protocol=${encodeURIComponent(props.name)}&protocol=${encodeURIComponent(props.competitors[0].name)}`
}
return `/compare-protocols?protocol=${encodeURIComponent(props.name)}`
}, [props.otherProtocols, props.competitors, props.name])

return (
<ProtocolOverviewLayout
isCEX={props.isCEX}
Expand Down Expand Up @@ -122,7 +138,17 @@ export const ProtocolOverview = (props: IProtocolOverviewPageData) => {
{props.token.symbol && props.token.symbol !== '-' ? (
<span className="mr-auto font-normal">({props.token.symbol})</span>
) : null}
<Bookmark readableName={props.name} />
<div className="flex items-center gap-2">
<BasicLink
href={compareProtocolsUrl}
className="flex cursor-pointer flex-nowrap items-center gap-2 rounded-md bg-(--btn-bg) px-3 py-2 text-xs text-(--text-primary) hover:bg-(--btn-hover-bg) focus-visible:bg-(--btn-hover-bg)"
aria-label="Compare protocols"
>
<Icon name="repeat" className="h-3 w-3" />
<span className="hidden sm:inline">Compare</span>
</BasicLink>
<Bookmark readableName={props.name} />
</div>
</h1>
<ProtocolTVL
hasTvl={props.metrics.tvl}
Expand All @@ -146,6 +172,14 @@ export const ProtocolOverview = (props: IProtocolOverviewPageData) => {
{props.token.symbol && props.token.symbol !== '-' ? (
<span className="mr-auto font-normal">({props.token.symbol})</span>
) : null}
<BasicLink
href={compareProtocolsUrl}
className="flex cursor-pointer flex-nowrap items-center gap-2 rounded-md bg-(--btn-bg) px-3 py-2 text-xs text-(--text-primary) hover:bg-(--btn-hover-bg) focus-visible:bg-(--btn-hover-bg)"
aria-label="Compare protocols"
>
<Icon name="repeat" className="h-3 w-3" />
<span className="hidden sm:inline">Compare</span>
</BasicLink>
<Bookmark readableName={props.name} />
</h1>
<ProtocolTVL
Expand Down