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

Feat: Implementing Staking V2 #2515

Merged
merged 135 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
2958d0f
Updated the staking dashboard
LeifuChen Jun 21, 2023
a6268ab
Updated the staking rewards
LeifuChen Jun 21, 2023
f4cb230
Merge branch 'dev' into feat/new-staking-v2
LeifuChen Jun 22, 2023
0c263fd
Fixed the lint
LeifuChen Jun 22, 2023
9435247
Merge branch 'dev' into feat/new-staking-v2
LeifuChen Jun 22, 2023
47ff9ca
Updated the staking section
LeifuChen Jun 22, 2023
5ee75dd
Updated the trading rewards
LeifuChen Jun 23, 2023
56de8e9
Updated the escrow tab
LeifuChen Jun 23, 2023
72e3f07
Merge branch 'dev' into feat/new-staking-v2
LeifuChen Jun 23, 2023
83beb02
Updated the pagination
LeifuChen Jun 23, 2023
66208dd
Update the migration page
LeifuChen Jun 23, 2023
272213f
Update the cards into staking dashboard
LeifuChen Jun 24, 2023
64054ef
Support customized pagination of the table
LeifuChen Jun 24, 2023
b22ce78
Optimize the table logic
LeifuChen Jun 25, 2023
7ded9f3
Hook V1 data
LeifuChen Jun 26, 2023
8afe750
Added v2 contract
LeifuChen Jun 26, 2023
d3913f2
Updated the new contract name
LeifuChen Jun 27, 2023
3a8feb6
Updated V2 actions
LeifuChen Jun 27, 2023
3581542
Merge branch 'dev' into feat/new-staking-v2
LeifuChen Jun 27, 2023
eed6cbc
Fixed the lint warning
LeifuChen Jun 27, 2023
6c8b979
Updated the mobile layout
LeifuChen Jun 27, 2023
d045b8d
Fixed the mobile layout of the migration page and drop the unnecessar…
LeifuChen Jun 27, 2023
f780829
Fixed the layout of the rewards tab
LeifuChen Jun 27, 2023
c89159e
Fixed the warning lint
LeifuChen Jun 27, 2023
edaa941
Updated the layout issue
LeifuChen Jun 27, 2023
2d6bdee
Fixed the lint error
LeifuChen Jun 27, 2023
9e5d224
Rename the button prop
LeifuChen Jun 27, 2023
39136f8
Added migration flow
LeifuChen Jun 28, 2023
9221f51
Added more v2 data
LeifuChen Jun 28, 2023
7a43170
Updated checkbox style
LeifuChen Jun 28, 2023
e290c0c
Merge branch 'dev' into feat/new-staking-v2
LeifuChen Jun 28, 2023
47bc8d4
Updated the checkbox style
LeifuChen Jun 29, 2023
4d53966
Merge branch 'dev' into feat/new-staking-v2
LeifuChen Jun 29, 2023
21ef47e
Updated the button style on escrow table
LeifuChen Jun 29, 2023
2362310
Updated the checkbox style in light theme
LeifuChen Jun 29, 2023
72c69c4
Fixed the trading rewards
LeifuChen Jun 29, 2023
6f01280
Updated the staking tab
LeifuChen Jun 29, 2023
54b7feb
Updated the data in escrow tab
LeifuChen Jun 29, 2023
21043b6
Added cooldown period
LeifuChen Jun 29, 2023
99f82ed
Corrected the staked kwenta balance and trading rewards logic
LeifuChen Jun 29, 2023
a82a839
Added epoch selector
LeifuChen Jun 29, 2023
de2aa1f
Fixed the epoch selector on mobile
LeifuChen Jun 29, 2023
c0833fd
Added v2 actions to UI
LeifuChen Jun 29, 2023
7c6b7aa
Rename the functions
LeifuChen Jun 29, 2023
78ec026
Fixed responsive layout
LeifuChen Jun 29, 2023
498fcc3
Merge branch 'dev' into feat/new-staking-v2
LeifuChen Jun 30, 2023
4f01e33
Fixed the lint
LeifuChen Jun 30, 2023
3101329
Fixed the lint
LeifuChen Jun 30, 2023
b8f95b2
Merge branch 'dev' into feat/new-staking-v2
LeifuChen Jun 30, 2023
2b3c8d1
Added some easy fixes accroding to the comments
LeifuChen Jul 2, 2023
486d7a7
Add a new variant to TabButton
LeifuChen Jul 2, 2023
84e115e
Fixed the missing i18n issue
LeifuChen Jul 2, 2023
e226627
Fixed tablet layout and tab button style
LeifuChen Jul 3, 2023
21488ef
Merge branch 'dev' into feat/new-staking-v2
LeifuChen Jul 3, 2023
bfc3d5f
Fixed the lint warning
LeifuChen Jul 3, 2023
2f54fe5
Added Escrow V2 data
LeifuChen Jul 3, 2023
fde04f0
Fixed the escrow v2 data
LeifuChen Jul 4, 2023
0d39beb
Removed the console log
LeifuChen Jul 4, 2023
c4ef788
Fixed the unstaked Escrowed Balance V2
LeifuChen Jul 4, 2023
7ac1cfa
Merge branch 'dev' into feat/new-staking-v2
LeifuChen Jul 4, 2023
6e44e1f
Fixed the stake escrow v2
LeifuChen Jul 4, 2023
64fd889
Merge branch 'dev' into feat/new-staking-v2
LeifuChen Jul 4, 2023
fd373fc
Removed the subtitle, disabled button and add cooldown warning to the…
LeifuChen Jul 4, 2023
fd97967
Updated the escrow table layout
LeifuChen Jul 4, 2023
43dd2e1
Show the migration page as needed
LeifuChen Jul 4, 2023
0e833e0
Fixed the table in smaller screen view
LeifuChen Jul 4, 2023
1b08bdf
Cleaned the code
LeifuChen Jul 4, 2023
fa2c36d
Merge branch 'dev' into feat/new-staking-v2
LeifuChen Jul 4, 2023
0d39358
Fixed the lint warning
LeifuChen Jul 4, 2023
23e8c0c
Fixed the button state
LeifuChen Jul 4, 2023
4636d9c
Optimized the button label
LeifuChen Jul 5, 2023
4138169
Optimized the data fetching
LeifuChen Jul 5, 2023
80b62f8
Move the order of the sidebar
LeifuChen Jul 5, 2023
a84adc0
Added link out icon
LeifuChen Jul 5, 2023
1eb1b07
Fixed the lint
LeifuChen Jul 5, 2023
287b842
Refactor the fee calculation logic
LeifuChen Jul 5, 2023
a4b50ef
Fixed the tablet layout and non-desktop pagintation layout
LeifuChen Jul 6, 2023
fb27898
Fixed the name issue and checkbox style in mobile escrow table
LeifuChen Jul 6, 2023
fcf1c77
Merge branch 'dev' into feat/new-staking-v2
LeifuChen Jul 6, 2023
ebdf57b
Revised a portion of the code based on feedback from Adam's comments
LeifuChen Jul 6, 2023
0b47df5
Fixed the sdk logic to map the correct contract
LeifuChen Jul 6, 2023
d173baa
Fixed the typo and layout issue
LeifuChen Jul 6, 2023
7a5e8b7
Fixed the padding of the warning view
LeifuChen Jul 6, 2023
ff5a0cf
Fixed the pagination border issue on mobile layout
LeifuChen Jul 6, 2023
d37838e
Fixed the staking dashboard in reponsive layout
LeifuChen Jul 6, 2023
b6551ff
Reduce the gap of staking portfolio on large screen
LeifuChen Jul 6, 2023
26bf8ce
Refactored the estimated reward query
LeifuChen Jul 7, 2023
5eb9a53
Removed the unnecessary function
LeifuChen Jul 7, 2023
fda6755
Fixed the lint warning
LeifuChen Jul 7, 2023
62a427e
Fixed the query status
LeifuChen Jul 7, 2023
6a724fd
Fixed the action name
LeifuChen Jul 7, 2023
52dfdd1
Merge branch 'dev' into feat/new-staking-v2
LeifuChen Jul 7, 2023
a51229c
Updated the kwenta rewards display, button label, table label and war…
LeifuChen Jul 7, 2023
d5279fd
Made the title of the section clickable on staking dashboard
LeifuChen Jul 7, 2023
d6db3b0
Added icon next to the label
LeifuChen Jul 7, 2023
31064d3
Added cooldown period into the unstake check
LeifuChen Jul 7, 2023
b6922e8
Merge branch 'dev' into feat/new-staking-v2
LeifuChen Jul 10, 2023
67ad02a
Use redux state to track if the migration page is required
LeifuChen Jul 10, 2023
e40b6ab
Added v1/v2 toggle into escrow table
LeifuChen Jul 10, 2023
9a763d4
Fixed the step3 copy
LeifuChen Jul 10, 2023
c29a695
Merge branch 'dev' into feat/new-staking-v2
LeifuChen Jul 10, 2023
9b5652c
Styled the dropdown menu
LeifuChen Jul 10, 2023
0bd7381
Add the row gap to the staking card
LeifuChen Jul 10, 2023
fd99a4e
Ccapitalized the status
LeifuChen Jul 10, 2023
050bcdd
Refactored the staking info state
LeifuChen Jul 10, 2023
36359b5
Added error handling and notification
LeifuChen Jul 10, 2023
b729168
Added the disabled rules for the data fetching
LeifuChen Jul 11, 2023
153c15d
Refactored the migration component
LeifuChen Jul 11, 2023
7da6edf
Merge branch 'dev' into feat/new-staking-v2
LeifuChen Jul 11, 2023
b11a2cf
Refactored the pagination logic and updated the contract in mainnet
LeifuChen Jul 11, 2023
10522bd
Removed the unnecessary props
LeifuChen Jul 11, 2023
648d3c2
Fixed the v1 escrow info for migration dashboard
LeifuChen Jul 11, 2023
911d32b
Merge branch 'dev' into feat/new-staking-v2
LeifuChen Jul 11, 2023
bb83fc6
Updated the state migration file
LeifuChen Jul 11, 2023
5922c56
Disabled the claim and compound button if no claimable rewards
LeifuChen Jul 11, 2023
914284e
Merge branch 'dev' into feat/new-staking-v2
LeifuChen Jul 11, 2023
9e2493a
Fixed the pnpm-lock file
LeifuChen Jul 11, 2023
f777666
Removed the unused packages
LeifuChen Jul 11, 2023
f7ab9e4
Fixed the lint warning
LeifuChen Jul 11, 2023
8a3a647
Fixed the page size
LeifuChen Jul 11, 2023
54ac0af
Fixed the escrow table style
LeifuChen Jul 12, 2023
00c9d48
Fixed APY and reorganized the help icons
LeifuChen Jul 12, 2023
96a05de
Added the tooltips
LeifuChen Jul 12, 2023
f63ac78
Fixed the Escrow Tab layout
LeifuChen Jul 12, 2023
38f6184
Showing V1 data in migration middle box
LeifuChen Jul 12, 2023
e284f68
Fixed the button variant and fetching status
LeifuChen Jul 12, 2023
5fb4b7d
Added loading state for button
LeifuChen Jul 12, 2023
2863845
Revised the code based on #2583
LeifuChen Jul 12, 2023
897b2ab
Update the new lock file
LeifuChen Jul 12, 2023
1b4130f
Added the loading state to the migration steps button and update the …
LeifuChen Jul 12, 2023
48ba478
Added the loading state for all the buttons
LeifuChen Jul 12, 2023
bb81080
Reset all the staking status
LeifuChen Jul 12, 2023
2712e80
fix: pnpm-lock
platschi Jul 12, 2023
b310a8a
fix: early vest fee tooltip
platschi Jul 12, 2023
9f0b232
fix: change onClick to early vest tab
platschi Jul 13, 2023
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
3 changes: 3 additions & 0 deletions packages/app/assets/svg/app/caret-down-color-slim.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 10 additions & 11 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
"@eth-optimism/contracts": "0.5.37",
"@ethersproject/bignumber": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@gnosis.pm/safe-apps-provider": "^0.14.0",
"@gnosis.pm/safe-apps-sdk": "^7.8.0",
"@kwenta/sdk": "workspace:*",
"@material-ui/core": "^4.12.4",
"@pythnetwork/pyth-evm-js": "1.17.0",
Expand All @@ -41,7 +39,7 @@
"date-fns": "2.21.3",
"date-fns-tz": "2.0.0",
"echarts": "5.4.2",
"eslint-config-next": "^13.4.6",
"eslint-config-next": "^13.4.8",
"ethcall": "4.7.2",
"ethers": "5.7.2",
"graphql-request": "3.4.0",
Expand All @@ -50,23 +48,24 @@
"lightweight-charts": "4.0.1",
"lodash": "4.17.21",
"moment-business-time": "2.0.0",
"next": "^13.3.4",
"next": "^13.4.8",
"next-compose-plugins": "2.2.1",
"next-connect": "^0.13.0",
"next-transpile-modules": "10.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-i18next": "12.1.1",
"react-infinite-scroll-component": "^6.1.0",
"react-is": "^18.0.0",
"react-is": "^18.2.0",
"react-query": "3.39.3",
"react-redux": "8.1.1",
"react-responsive": "^9.0.2",
"react-rnd": "^10.3.7",
"react-rnd": "^10.4.1",
"react-select": "4.3.1",
"react-slick": "0.29.0",
"react-toastify": "^9.0.4",
"recharts": "^2.5.0",
"react-table": "7.7.0",
"react-toastify": "^9.1.3",
"recharts": "^2.7.2",
"redux-logger": "^3.0.6",
"redux-persist": "^6.0.0",
"slick-carousel": "1.8.1",
Expand All @@ -89,8 +88,8 @@
"@testing-library/react": "14.0.0",
"@testing-library/react-hooks": "8.0.1",
"@testing-library/user-event": "14.4.3",
"@typechain/ethers-v5": "^10.1.0",
"@types/cors": "^2.8.12",
"@typechain/ethers-v5": "^10.2.1",
"@types/cors": "^2.8.13",
"@types/date-fns": "2.6.0",
"@types/ethereum-block-by-date": "^1.4.1",
"@types/jest": "27.0.2",
Expand All @@ -111,7 +110,7 @@
"jest": "28.1.0",
"jest-environment-jsdom": "28.1.0",
"jest-preview": "^0.3.1",
"jest-transformer-svg": "^2.0.0",
"jest-transformer-svg": "^2.0.1",
"next-router-mock": "0.9.3",
"pinst": "3.0.0",
"postcss": "^8.4.24",
Expand Down
11 changes: 9 additions & 2 deletions packages/app/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export type ButtonVariant =
| 'yellow'
| 'long'
| 'short'
| 'staking-button'

type BaseButtonProps = {
$size: 'xsmall' | 'small' | 'medium' | 'large'
Expand All @@ -25,6 +26,7 @@ type BaseButtonProps = {
fullWidth?: boolean
noOutline?: boolean
textColor?: 'yellow'
outlineColor?: 'yellow'
textTransform?: 'none' | 'uppercase' | 'capitalize' | 'lowercase'
$active?: boolean
$mono?: boolean
Expand Down Expand Up @@ -151,9 +153,8 @@ const BaseButton = styled.button<BaseButtonProps>`
}
`}


${(props) =>
props.$variant === 'yellow' &&
(props.$variant === 'yellow' || props.$variant === 'staking-button') &&
css`
background: ${props.theme.colors.selectedTheme.button.yellow.fill};
border: 1px solid ${props.theme.colors.selectedTheme.button.yellow.border};
Expand All @@ -166,6 +167,11 @@ const BaseButton = styled.button<BaseButtonProps>`
&::before {
display: none;
}

${props.$variant === 'staking-button' &&
css`
border: 1px solid ${props.theme.colors.selectedTheme.button.yellow.text};
`}
`}

font-family: ${(props) =>
Expand Down Expand Up @@ -233,6 +239,7 @@ type ButtonProps = {
fullWidth?: boolean
noOutline?: boolean
textColor?: 'yellow'
outlineColor?: 'yellow'
textTransform?: 'none' | 'uppercase' | 'capitalize' | 'lowercase'
style?: React.CSSProperties
disabled?: boolean
Expand Down
13 changes: 13 additions & 0 deletions packages/app/src/components/Button/TabButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type TabButtonProps = {
isRounded?: boolean
onClick?: () => any
flat?: boolean
variant?: 'noOutline'
}

const InnerButton: React.FC<TabButtonProps> = React.memo(
Expand Down Expand Up @@ -63,6 +64,7 @@ const TabButton: React.FC<TabButtonProps> = React.memo(
$nofill={props.nofill}
$flat={flat}
onClick={onClick}
$variant={props.variant}
>
<InnerButton {...props} />
</StyledButton>
Expand Down Expand Up @@ -127,6 +129,7 @@ const sharedStyle = css<{
&:hover {
background: ${(props) =>
props.theme.colors.selectedTheme.newTheme.button.default.hover.background};
border-width: 1px;
}

.title {
Expand Down Expand Up @@ -184,6 +187,7 @@ const StyledButton = styled(Button).attrs({ size: 'small' })<{
$nofill?: boolean
$flat?: boolean
active?: boolean
$variant?: 'noOutline' | undefined
}>`
p {
text-align: left;
Expand All @@ -194,6 +198,15 @@ const StyledButton = styled(Button).attrs({ size: 'small' })<{
border-radius: ${props.isRounded ? '100px' : '8px'};
`}
${sharedStyle}

${(props) =>
props.$variant === 'noOutline' &&
css`
border: none;
border-radius: 100px;
padding: 10px 15px;
width: 75px;
`}
`

export default TabButton
45 changes: 40 additions & 5 deletions packages/app/src/components/Checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FC, memo } from 'react'
import styled from 'styled-components'
import styled, { css } from 'styled-components'

import { Body } from 'components/Text'

Expand All @@ -8,18 +8,35 @@ type CheckboxProps = {
label: string
checked: boolean
checkSide?: 'left' | 'right'
variant?: 'item' | 'table'
onChange: () => void
}

export const Checkbox: FC<CheckboxProps> = memo(
({ id, label, checked, onChange, checkSide = 'left', ...props }) => (
({ id, label, checked, onChange, checkSide = 'left', variant = 'item', ...props }) => (
<CheckboxContainer>
{checkSide === 'left' && (
<Input type="checkbox" id={id} name={id} checked={checked} onChange={onChange} {...props} />
<Input
type="checkbox"
id={id}
name={id}
checked={checked}
onChange={onChange}
variant={variant}
{...props}
/>
)}
<Label htmlFor={id}>{<Body color="secondary">{label}</Body>}</Label>
{checkSide === 'right' && (
<Input type="checkbox" id={id} name={id} checked={checked} onChange={onChange} {...props} />
<Input
type="checkbox"
id={id}
name={id}
checked={checked}
onChange={onChange}
variant={variant}
{...props}
/>
)}
</CheckboxContainer>
)
Expand All @@ -34,7 +51,7 @@ const CheckboxContainer = styled.div`
gap: 8px;
`

const Input = styled.input`
const Input = styled.input<{ variant: 'item' | 'table' }>`
-webkit-appearance: none;
-moz-appearance: none;
-o-appearance: none;
Expand Down Expand Up @@ -66,9 +83,27 @@ const Input = styled.input`
box-shadow: inset 1em 1em var(--form-control-color);
background-color: ${(props) => props.theme.colors.selectedTheme.newTheme.text.primary};
}

&:checked::before {
transform: scale(1);
}

${(props) =>
props.variant === 'table' &&
css`
background-color: ${(props) => props.theme.colors.selectedTheme.newTheme.checkBox.background};
width: 13px;
height: 13px;
border-radius: 4px;

&::before {
clip-path: none;
}
&:checked::before {
background-color: ${props.theme.colors.selectedTheme.newTheme.checkBox.checked};
border-radius: 4px;
}
`}
`

const Label = styled.label`
Expand Down
8 changes: 8 additions & 0 deletions packages/app/src/components/Media.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ export const DesktopOnlyView: FC<MediaProps> = memo(({ children }) => (
<MediaQuery minWidth={BREAKPOINTS.md}>{children}</MediaQuery>
))

export const DesktopLargeOnlyView: FC<MediaProps> = memo(({ children }) => (
<MediaQuery minWidth={BREAKPOINTS.lg}>{children}</MediaQuery>
))

export const DesktopSmallOnlyView: FC<MediaProps> = memo(({ children }) => (
<MediaQuery maxWidth={BREAKPOINTS.lg}>{children}</MediaQuery>
))

export const TabletOnlyView: FC<MediaProps> = memo(({ children }) => (
<MediaQuery minWidth={BREAKPOINTS.sm} maxWidth={BREAKPOINTS.md - 1}>
{children}
Expand Down
20 changes: 16 additions & 4 deletions packages/app/src/components/Nav/NavLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import Link from 'next/link'
import React, { ReactNode } from 'react'
import styled from 'styled-components'

import LinkIconLight from 'assets/svg/app/link-light.svg'
import { FlexDivRowCentered } from 'components/layout/flex'
import { linkCSS } from 'styles/common'

type NavButtonProps = {
Expand All @@ -16,15 +18,25 @@ type NavButtonProps = {
const NavButton: React.FC<NavButtonProps> = ({ title, href, external, disabled, ...props }) => {
return (
<div>
<Link href={href} passHref>
{external ? (
<StyledLink
target={external ? '_blank' : '_self'}
href={href}
target="_blank"
rel="noopener noreferrer"
className={disabled ? 'disabled' : undefined}
{...props}
>
{title}
<FlexDivRowCentered columnGap="5px">
{title} <LinkIconLight />
</FlexDivRowCentered>
</StyledLink>
</Link>
) : (
<Link href={href} passHref>
<StyledLink className={disabled ? 'disabled' : undefined} {...props}>
{title}
</StyledLink>
</Link>
)}
</div>
)
}
Expand Down
29 changes: 0 additions & 29 deletions packages/app/src/components/Rainbowkit/Gnosis/Gnosis.ts

This file was deleted.

Loading
Loading