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

Earn protocol WIP #17 #551

Merged
merged 5 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
41 changes: 2 additions & 39 deletions apps/earn-protocol/app/earn/[network]/position/[vaultId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ import { getVaultDetails } from '@/app/server-handlers/sdk/getVaultDetails'
import { getVaultsList } from '@/app/server-handlers/sdk/getVaultsList'
import { MockedLineChart } from '@/components/organisms/Charts/MockedLineChart'
import FormContainer from '@/components/organisms/Form/FormContainer'
import {
RebalancingActivity,
type RebalancingActivityRawData,
} from '@/components/organisms/RebalancingActivity/RebalancingActivity'
import { RebalancingActivity } from '@/components/organisms/RebalancingActivity/RebalancingActivity'
import {
UserActivity,
type UserActivityRawData,
Expand All @@ -25,6 +22,7 @@ import {
VaultExposure,
type VaultExposureRawData,
} from '@/components/organisms/VaultExposure/VaultExposure'
import { rebalancingActivityRawData } from '@/features/rebalance-activity/table/dummyData'
marcinciarka marked this conversation as resolved.
Show resolved Hide resolved
import type { FleetConfig } from '@/helpers/sdk/types'

type EarnVaultOpenManagePageProps = {
Expand Down Expand Up @@ -86,41 +84,6 @@ const vaultExposureRawData: VaultExposureRawData[] = [
},
]

const rebalancingActivityRawData: RebalancingActivityRawData[] = [
{
type: 'reduce',
action: {
from: 'USDC',
to: 'DAI',
},
amount: {
token: 'USDC',
value: '123123',
},
timestamp: '12321321',
provider: {
link: '/',
label: 'Summer.fi',
},
},
{
type: 'increase',
action: {
from: 'USDT',
to: 'USDC',
},
amount: {
token: 'USDT',
value: '123123',
},
timestamp: '1727385013506',
provider: {
link: '/',
label: 'Summer.fi',
},
},
]

const userActivityRawData: UserActivityRawData[] = [
{
balance: '120000',
Expand Down
8 changes: 8 additions & 0 deletions apps/earn-protocol/app/earn/rebalance-activity/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { RebalanceActivityView } from '@/features/rebalance-activity/components/RebalanceActivityView/RebalanceActivityView'
import { rebalancingActivityRawData } from '@/features/rebalance-activity/table/dummyData'

const RebalanceActivityPage = () => {
return <RebalanceActivityView rawData={rebalancingActivityRawData} />
}
marcinciarka marked this conversation as resolved.
Show resolved Hide resolved

export default RebalanceActivityPage
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
import { type FC, useMemo } from 'react'
import { Card, DataBlock, Table, Text, WithArrow } from '@summerfi/app-earn-ui'
import { type TokenSymbolsList } from '@summerfi/app-types'
import Link from 'next/link'

import { rebalancingActivityColumns } from '@/components/organisms/RebalancingActivity/columns'
import { rebalancingActivityMapper } from '@/components/organisms/RebalancingActivity/mapper'

export interface RebalancingActivityRawData {
type: string
action: { from: TokenSymbolsList; to: TokenSymbolsList }
amount: { token: TokenSymbolsList; value: string }
timestamp: string
provider: {
link: string
label: string
}
}
import { rebalancingActivityColumns } from '@/features/rebalance-activity/table/columns'
import { rebalancingActivityMapper } from '@/features/rebalance-activity/table/mapper'
import { type RebalancingActivityRawData } from '@/features/rebalance-activity/table/types'

interface RebalancingActivityProps {
rawData: RebalancingActivityRawData[]
Expand Down Expand Up @@ -54,7 +43,7 @@ export const RebalancingActivity: FC<RebalancingActivityProps> = ({ rawData }) =
for reallocating assets from lower performing strategies to higher performing ones, within
a threshold of risk.
</Text>
<Table rows={rows} columns={rebalancingActivityColumns} />
<Table rows={rows} columns={rebalancingActivityColumns} hiddenColumns={['strategy']} />
marcinciarka marked this conversation as resolved.
Show resolved Hide resolved
<Link href="/" style={{ marginTop: 'var(--spacing-space-large)', width: 'fit-content' }}>
<WithArrow as="p" variant="p4semi" style={{ color: 'var(--earn-protocol-primary-100)' }}>
View all rebalances
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.wrapper {
display: flex;
flex-direction: column;
padding: 0 var(--general-space-16);

@media screen and (min-width: 768px) {
padding: unset;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
'use client'

import { type FC, useMemo } from 'react'
import { HeadingWithCards, Table, TableCarousel } from '@summerfi/app-earn-ui'

import { rebalancingActivityColumns } from '@/features/rebalance-activity/table/columns'
import { rebalancingActivityMapper } from '@/features/rebalance-activity/table/mapper'
import { type RebalancingActivityRawData } from '@/features/rebalance-activity/table/types'

import classNames from './RebalanceActivityView.module.scss'

const carouselData = [
{
title: 'Reduced costs',
description:
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus luctus massa ac sapien eleifend.',
link: {
label: 'Add to position',
href: '/',
},
},
{
title: 'Optimized Yield',
description:
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus luctus massa ac sapien eleifend.',
link: {
label: 'Add to position',
href: '/',
},
},
{
title: 'Saved Time',
description:
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus luctus massa ac sapien eleifend.',
link: {
label: 'Add to position',
href: '/',
},
},
]
marcinciarka marked this conversation as resolved.
Show resolved Hide resolved

interface RebalanceActivityViewProps {
rawData: RebalancingActivityRawData[]
}

export const RebalanceActivityView: FC<RebalanceActivityViewProps> = ({ rawData }) => {
const rows = useMemo(() => rebalancingActivityMapper(rawData), [rawData])

return (
<div className={classNames.wrapper}>
<HeadingWithCards
title="Lazy Summer Global Rebalance Activity"
description="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean lacinia bibendum nulla sed consectetur. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Nullam quis risus eget."
cards={[
{
title: 'Rebalance actions',
value: '3,213',
description:
'Justo enim sollicitudin suspendisse lectus tellus tortor magna. Velit id nulla tempor arcu quis condimentum parturient.',
},
{
title: 'User saved time',
value: '2,184 hours',
description:
'Justo enim sollicitudin suspendisse lectus tellus tortor magna. Velit id nulla tempor arcu quis condimentum parturient.',
},
{
title: 'Gas cost savings',
value: '1.23m',
description:
'Justo enim sollicitudin suspendisse lectus tellus tortor magna. Velit id nulla tempor arcu quis condimentum parturient.',
},
]}
marcinciarka marked this conversation as resolved.
Show resolved Hide resolved
/>
<Table
rows={rows}
columns={rebalancingActivityColumns}
customRow={{
idx: 1,
content: <TableCarousel carouselData={carouselData} />,
}}
/>
marcinciarka marked this conversation as resolved.
Show resolved Hide resolved
</div>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ export const rebalancingActivityColumns = [
key: 'amount',
sortable: true,
},
{
title: 'Strategy',
key: 'strategy',
sortable: false,
},
{
title: 'Timestamp',
key: 'timestamp',
Expand Down
55 changes: 55 additions & 0 deletions apps/earn-protocol/features/rebalance-activity/table/dummyData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import type { RebalancingActivityRawData } from '@/features/rebalance-activity/table/types'

export const rebalancingActivityRawData: RebalancingActivityRawData[] = [
{
type: 'reduce',
action: {
from: 'USDC',
to: 'DAI',
},
amount: {
token: 'USDC',
value: '123123',
},
strategy: 'USDC Ethereum Lower Risk',
timestamp: '12321321',
marcinciarka marked this conversation as resolved.
Show resolved Hide resolved
provider: {
link: '/',
label: 'Summer.fi',
},
},
{
type: 'increase',
action: {
from: 'USDT',
to: 'USDC',
},
amount: {
token: 'USDT',
value: '123123',
},
strategy: 'USDC Ethereum Lower Risk',
timestamp: '1727385013506',
provider: {
link: '/',
label: 'Summer.fi',
},
},
{
type: 'increase',
action: {
from: 'DAI',
to: 'USDC',
},
amount: {
token: 'DAI',
value: '123123',
},
strategy: 'USDC Ethereum Lower Risk',
timestamp: '1727385013506',
provider: {
link: '/',
label: 'Summer.fi',
},
},
]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Icon, TableCellText, Text, WithArrow } from '@summerfi/app-earn-ui'
import { formatCryptoBalance, timeAgo } from '@summerfi/app-utils'
import Link from 'next/link'

import { type RebalancingActivityRawData } from '@/components/organisms/RebalancingActivity/RebalancingActivity'
import { type RebalancingActivityRawData } from '@/features/rebalance-activity/table/types'

export const rebalancingActivityMapper = (rawData: RebalancingActivityRawData[]) => {
return rawData.map((item) => {
Expand Down Expand Up @@ -37,6 +37,7 @@ export const rebalancingActivityMapper = (rawData: RebalancingActivityRawData[])
<TableCellText>{formatCryptoBalance(item.amount.value)}</TableCellText>
</div>
),
strategy: <TableCellText>{item.strategy}</TableCellText>,
marcinciarka marked this conversation as resolved.
Show resolved Hide resolved
timestamp: (
<TableCellText>
{timeAgo({ from: new Date(), to: new Date(Number(item.timestamp)) })}
Expand Down
13 changes: 13 additions & 0 deletions apps/earn-protocol/features/rebalance-activity/table/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { type TokenSymbolsList } from '@summerfi/app-types'

export interface RebalancingActivityRawData {
type: string
action: { from: TokenSymbolsList; to: TokenSymbolsList }
amount: { token: TokenSymbolsList; value: string }
strategy: string
timestamp: string
provider: {
link: string
label: string
}
}
marcinciarka marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
.wrapper {
display: flex;
flex-direction: column;
}

.heading {
display: flex;
justify-content: flex-start;
align-items: center;
margin-bottom: var(--general-space-16);
gap: var(--general-space-8);

.headingIcons {
display: flex;
gap: 10px;

button {
display: flex;
align-items: center;
justify-content: center;
}
}
}

.description {
color: var(--earn-protocol-secondary-60);
margin-bottom: var(--general-space-24);
}

.cardsWrapper {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
gap: var(--general-space-16);
margin-bottom: var(--general-space-40);

.card {
display: flex;
flex-direction: column;
gap: var(--general-space-4);
align-items: flex-start;
flex: 1;

.cardTitle {
color: var(--earn-protocol-secondary-40);
}

.cardDescription {
color: var(--earn-protocol-secondary-60);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export type Styles = {
card: string
cardDescription: string
cardsWrapper: string
cardTitle: string
description: string
heading: string
headingIcons: string
wrapper: string
}

export type ClassNames = keyof Styles

declare const styles: Styles

export default styles
Loading
Loading