Skip to content

Commit 1e8904d

Browse files
foodakagrothemJoaquinBattilana
authored
feat: umbrella (#2321)
Co-authored-by: Mark Grothe <[email protected]> Co-authored-by: Joaquin Battilana <[email protected]>
1 parent ffc8108 commit 1e8904d

File tree

87 files changed

+7696
-275
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+7696
-275
lines changed

cypress/e2e/3-stake-governance/stake.cy.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,6 @@ import {
1010
} from '../../support/steps/stake.steps';
1111

1212
const testCases = [
13-
{
14-
asset: assets.staking.GHO,
15-
amount: 5,
16-
checkAmount: '5.00',
17-
checkAmountFinal: '10.00',
18-
tabValue: 'gho',
19-
changeApproval: false,
20-
},
2113
{
2214
asset: assets.staking.AAVE,
2315
amount: 5,
@@ -26,14 +18,6 @@ const testCases = [
2618
tabValue: 'aave',
2719
changeApproval: true,
2820
},
29-
// {
30-
// asset: assets.staking.ABPT,
31-
// amount: 5,
32-
// checkAmount: '5.00',
33-
// checkAmountFinal: '10.00',
34-
// tabValue: 'bpt',
35-
// changeApproval: false,
36-
// },
3721
];
3822

3923
testCases.forEach(

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
"test:coverage": "jest --coverage"
3232
},
3333
"dependencies": {
34-
"@aave/contract-helpers": "1.33.3",
35-
"@aave/math-utils": "1.33.3",
34+
"@aave/contract-helpers": "1.34.0",
35+
"@aave/math-utils": "1.34.0",
3636
"@amplitude/analytics-browser": "^2.13.0",
3737
"@bgd-labs/aave-address-book": "^4.22.1",
3838
"@cowprotocol/app-data": "^3.1.0",

pages/reserve-overview.page.tsx

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Trans } from '@lingui/macro';
22
import { Box, Typography } from '@mui/material';
3+
import dynamic from 'next/dynamic';
34
import { useRouter } from 'next/router';
45
import { useEffect, useState } from 'react';
56
import StyledToggleButton from 'src/components/StyledToggleButton';
@@ -17,6 +18,30 @@ import { useRootStore } from 'src/store/root';
1718

1819
import { ContentContainer } from '../src/components/ContentContainer';
1920

21+
const SavingsGhoDepositModal = dynamic(() =>
22+
import('../src/components/transactions/SavingsGho/SavingsGhoDepositModal').then(
23+
(module) => module.SavingsGhoDepositModal
24+
)
25+
);
26+
const SavingsGhoWithdrawModal = dynamic(() =>
27+
import('../src/components/transactions/SavingsGho/SavingsGhoWithdrawModal').then(
28+
(module) => module.SavingsGhoWithdrawModal
29+
)
30+
);
31+
const StakeModal = dynamic(() =>
32+
import('../src/components/transactions/Stake/StakeModal').then((module) => module.StakeModal)
33+
);
34+
const StakeCooldownModal = dynamic(() =>
35+
import('../src/components/transactions/StakeCooldown/StakeCooldownModal').then(
36+
(module) => module.StakeCooldownModal
37+
)
38+
);
39+
const UnStakeModal = dynamic(() =>
40+
import('../src/components/transactions/UnStake/UnStakeModal').then(
41+
(module) => module.UnStakeModal
42+
)
43+
);
44+
2045
export default function ReserveOverview() {
2146
const router = useRouter();
2247
const { reserves } = useAppDataContext();
@@ -104,5 +129,14 @@ export default function ReserveOverview() {
104129
}
105130

106131
ReserveOverview.getLayout = function getLayout(page: React.ReactElement) {
107-
return <MainLayout>{page}</MainLayout>;
132+
return (
133+
<MainLayout>
134+
{page}
135+
<StakeModal />
136+
<StakeCooldownModal />
137+
<UnStakeModal />
138+
<SavingsGhoDepositModal />
139+
<SavingsGhoWithdrawModal />
140+
</MainLayout>
141+
);
108142
};

pages/staking.staking.tsx renamed to pages/safety-module.page.tsx

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { useModalContext } from 'src/hooks/useModal';
1919
import { MainLayout } from 'src/layouts/MainLayout';
2020
import { GetABPToken } from 'src/modules/staking/GetABPToken';
2121
import { GhoDiscountProgram } from 'src/modules/staking/GhoDiscountProgram';
22+
import { GhoStakingPanel } from 'src/modules/staking/GhoStakingPanel';
2223
import { StakingHeader } from 'src/modules/staking/StakingHeader';
2324
import { StakingPanel } from 'src/modules/staking/StakingPanel';
2425
import { useRootStore } from 'src/store/root';
@@ -49,6 +50,16 @@ const UnStakeModal = dynamic(() =>
4950
(module) => module.UnStakeModal
5051
)
5152
);
53+
const SavingsGhoDepositModal = dynamic(() =>
54+
import('../src/components/transactions/SavingsGho/SavingsGhoDepositModal').then(
55+
(module) => module.SavingsGhoDepositModal
56+
)
57+
);
58+
const SavingsGhoWithdrawModal = dynamic(() =>
59+
import('../src/components/transactions/SavingsGho/SavingsGhoWithdrawModal').then(
60+
(module) => module.SavingsGhoWithdrawModal
61+
)
62+
);
5263

5364
export default function Staking() {
5465
const { currentAccount } = useWeb3Context();
@@ -83,6 +94,8 @@ export default function Staking() {
8394
openStakeRewardsClaim,
8495
openStakeRewardsRestakeClaim,
8596
openStakingMigrate,
97+
openSavingsGhoDeposit,
98+
openSavingsGhoWithdraw,
8699
} = useModalContext();
87100

88101
const [mode, setMode] = useState<Stake>(Stake.aave);
@@ -97,7 +110,7 @@ export default function Staking() {
97110

98111
const tvl = {
99112
'Staked Aave': Number(stkAave?.totalSupplyUSDFormatted || '0'),
100-
'Staked GHO': Number(stkGho?.totalSupplyUSDFormatted || '0'),
113+
// 'Staked GHO': Number(stkGho?.totalSupplyUSDFormatted || '0'),
101114
'Staked ABPT': Number(stkBpt?.totalSupplyUSDFormatted || '0'),
102115
'Staked ABPT V2': Number(stkBptV2?.totalSupplyUSDFormatted || '0'),
103116
};
@@ -149,7 +162,7 @@ export default function Staking() {
149162
</StyledToggleButton>
150163
<StyledToggleButton value="gho" disabled={mode === 'gho'}>
151164
<Typography variant="subheader1">
152-
<Trans>Stake GHO</Trans>
165+
<Trans>sGHO</Trans>
153166
</Typography>
154167
</StyledToggleButton>
155168
<StyledToggleButton value="bpt" disabled={mode === 'bpt'}>
@@ -213,16 +226,16 @@ export default function Staking() {
213226
lg={6}
214227
sx={{ display: { xs: !isStkGho ? 'none' : 'block', lg: 'block' } }}
215228
>
216-
<StakingPanel
217-
stakeTitle="GHO"
229+
<GhoStakingPanel
230+
stakeTitle="sGHO (formerly stkGHO)"
218231
stakedToken="GHO"
232+
icon="sgho"
219233
maxSlash={stkGho?.maxSlashablePercentageFormatted || '0'}
220-
icon="gho"
221234
stakeData={stkGho}
222235
stakeUserData={stkGhoUserData}
223-
onStakeAction={() => openStake(Stake.gho, 'GHO')}
224-
onCooldownAction={() => openStakeCooldown(Stake.gho, 'GHO')}
225-
onUnstakeAction={() => openUnstake(Stake.gho, 'GHO')}
236+
onStakeAction={() => openSavingsGhoDeposit()}
237+
onCooldownAction={() => openSavingsGhoWithdraw()}
238+
onUnstakeAction={() => openSavingsGhoWithdraw()}
226239
onStakeRewardClaimAction={() => openStakeRewardsClaim(Stake.gho, 'AAVE')}
227240
/>
228241
</Grid>
@@ -344,6 +357,8 @@ Staking.getLayout = function getLayout(page: React.ReactElement) {
344357
<UnStakeModal />
345358
<StakeRewardClaimModal />
346359
<StakeRewardClaimRestakeModal />
360+
<SavingsGhoDepositModal />
361+
<SavingsGhoWithdrawModal />
347362
{/** End of modals */}
348363
</MainLayout>
349364
);

pages/staking.page.tsx

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import dynamic from 'next/dynamic';
2+
import { ContentContainer } from 'src/components/ContentContainer';
3+
import { MainLayout } from 'src/layouts/MainLayout';
4+
import { UmbrellaAssetsListContainer } from 'src/modules/umbrella/StakeAssets/UmbrellaAssetsListContainer';
5+
import { UmrellaAssetsDefaultListContainer } from 'src/modules/umbrella/UmbrellaAssetsDefault';
6+
import { UmbrellaHeader } from 'src/modules/umbrella/UmbrellaHeader';
7+
8+
import { useWeb3Context } from '../src/libs/hooks/useWeb3Context';
9+
10+
const UmbrellaStakeModal = dynamic(() =>
11+
import('../src/modules/umbrella/UmbrellaModal').then((module) => module.UmbrellaModal)
12+
);
13+
const StakeCooldownModal = dynamic(() =>
14+
import('../src/modules/umbrella/StakeCooldownModal').then((module) => module.StakeCooldownModal)
15+
);
16+
const StakeRewardClaimModal = dynamic(() =>
17+
import('../src/components/transactions/StakeRewardClaim/StakeRewardClaimModal').then(
18+
(module) => module.StakeRewardClaimModal
19+
)
20+
);
21+
const StakeRewardClaimRestakeModal = dynamic(() =>
22+
import(
23+
'../src/components/transactions/StakeRewardClaimRestake/StakeRewardClaimRestakeModal'
24+
).then((module) => module.StakeRewardClaimRestakeModal)
25+
);
26+
const UnStakeModal = dynamic(() =>
27+
import('../src/modules/umbrella/UnstakeModal').then((module) => module.UnStakeModal)
28+
);
29+
const UmbrellaClaimModal = dynamic(() =>
30+
import('../src/modules/umbrella/UmbrellaClaimModal').then((module) => module.UmbrellaClaimModal)
31+
);
32+
33+
export default function UmbrellaStaking() {
34+
const { currentAccount } = useWeb3Context();
35+
36+
return (
37+
<>
38+
<UmbrellaHeader />
39+
<ContentContainer>
40+
{currentAccount ? <UmbrellaAssetsListContainer /> : <UmrellaAssetsDefaultListContainer />}
41+
</ContentContainer>
42+
</>
43+
);
44+
}
45+
46+
UmbrellaStaking.getLayout = function getLayout(page: React.ReactElement) {
47+
return (
48+
<MainLayout>
49+
{page}
50+
{/** Modals */}
51+
<UmbrellaStakeModal />
52+
<StakeCooldownModal />
53+
<UnStakeModal />
54+
<StakeRewardClaimModal />
55+
<StakeRewardClaimRestakeModal />
56+
<UmbrellaClaimModal />
57+
{/** End of modals */}
58+
</MainLayout>
59+
);
60+
};

public/icons/tokens/sgho.svg

Lines changed: 27 additions & 0 deletions
Loading

public/icons/tokens/stkgho.svg

Lines changed: 7 additions & 0 deletions
Loading

public/sgho-banner.svg

Lines changed: 27 additions & 0 deletions
Loading

src/components/SecondsToString.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { Trans } from '@lingui/macro';
2+
3+
function secondsToDHMS(seconds: number) {
4+
const d = Math.floor(seconds / (3600 * 24));
5+
const h = Math.floor((seconds % (3600 * 24)) / 3600);
6+
const m = Math.floor((seconds % 3600) / 60);
7+
const s = Math.floor(seconds % 60);
8+
return { d, h, m, s };
9+
}
10+
11+
export function SecondsToString({ seconds }: { seconds: number }) {
12+
const { d, h, m, s } = secondsToDHMS(seconds);
13+
return (
14+
<>
15+
{d !== 0 && (
16+
<span>
17+
<Trans>{d}d</Trans>
18+
</span>
19+
)}
20+
{h !== 0 && (
21+
<span>
22+
<Trans>{h}h</Trans>
23+
</span>
24+
)}
25+
{m !== 0 && (
26+
<span>
27+
<Trans>{m}m</Trans>
28+
</span>
29+
)}
30+
{s !== 0 && (
31+
<span>
32+
<Trans>{s}s</Trans>
33+
</span>
34+
)}
35+
</>
36+
);
37+
}

src/components/Warnings/CooldownWarning.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ import { GENERAL } from 'src/utils/events';
55

66
import { Link } from '../primitives/Link';
77
import { Warning } from '../primitives/Warning';
8+
import { SecondsToString } from '../SecondsToString';
9+
10+
const TWENTY_DAYS = 20 * 24 * 60 * 60;
11+
12+
export const CooldownWarning = ({ cooldownSeconds }: { cooldownSeconds?: number }) => {
13+
const cooldownTime = cooldownSeconds || TWENTY_DAYS;
814

9-
export const CooldownWarning = () => {
1015
const trackEvent = useRootStore((store) => store.trackEvent);
1116
return (
1217
<Warning severity="warning" sx={{ '.MuiAlert-message': { p: 0 }, mb: 6 }}>
@@ -15,9 +20,10 @@ export const CooldownWarning = () => {
1520
</Typography>
1621
<Typography variant="caption">
1722
<Trans>
18-
The cooldown period is the time required prior to unstaking your tokens (20 days). You can
19-
only withdraw your assets from the Security Module after the cooldown period and within
20-
the unstake window.
23+
The cooldown period is the time required prior to unstaking your tokens (
24+
<SecondsToString seconds={cooldownTime} />
25+
). You can only withdraw your assets from the Security Module after the cooldown period
26+
and within the unstake window.{' '}
2127
<Link
2228
href="https://docs.aave.com/faq/migration-and-staking"
2329
fontWeight={500}

0 commit comments

Comments
 (0)