-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6eac501
commit 705e76a
Showing
6 changed files
with
419 additions
and
3 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
97 changes: 97 additions & 0 deletions
97
apps/frontend/src/app/5_pages/LandingPage/components/QuickLaunch/QuickLaunch.tsx
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,97 @@ | ||
import React, { FC, useMemo } from 'react'; | ||
|
||
import { t } from 'i18next'; | ||
|
||
import { SupportedTokens } from '@sovryn/contracts'; | ||
import { Button, ButtonStyle, Paragraph } from '@sovryn/ui'; | ||
|
||
import borrowBg from '../../../../../assets/images/QuickLaunch/borrow_bg.svg'; | ||
import earnBg from '../../../../../assets/images/QuickLaunch/earn_bg.svg'; | ||
import stakeBg from '../../../../../assets/images/QuickLaunch/stake_bg.svg'; | ||
import { translations } from '../../../../../locales/i18n'; | ||
import { useGetNextSupplyInterestRate } from '../../../LendPage/hooks/useGetNextSupplyInterestRate'; | ||
import { useGetReturnRate } from '../../../MarketMakingPage/hooks/useGetReturnRate'; | ||
import { AmmLiquidityPoolDictionary } from '../../../MarketMakingPage/utils/AmmLiquidityPoolDictionary'; | ||
import { useGetStakingStatistics } from '../../../StakePage/components/StakingStatistics/hooks/useGetStakingStatistics'; | ||
|
||
const pageTranslations = translations.landingPage; | ||
const ammPools = AmmLiquidityPoolDictionary.list(); | ||
|
||
export const QuickLaunch: FC = () => { | ||
const sovPool = useMemo( | ||
() => | ||
ammPools.find(pool => pool.assetA === SupportedTokens.sov) || ammPools[0], | ||
[], | ||
); | ||
const { maxStakingApr } = useGetStakingStatistics(); | ||
const { interestRate } = useGetNextSupplyInterestRate(SupportedTokens.dllr); | ||
const { returnRates } = useGetReturnRate(sovPool.converter); | ||
|
||
const options = [ | ||
{ | ||
title: t(pageTranslations.quickLaunch.stake.title, { | ||
amount: maxStakingApr || 0, | ||
}), | ||
description: t(pageTranslations.quickLaunch.stake.description), | ||
action: t(pageTranslations.quickLaunch.stake.action), | ||
url: '/earn/staking', | ||
backgroundImage: stakeBg, | ||
}, | ||
{ | ||
title: t(pageTranslations.quickLaunch.earn.title, { | ||
amount: Number(returnRates.afterRewards).toFixed(2), | ||
}), | ||
description: t(pageTranslations.quickLaunch.earn.description), | ||
action: t(pageTranslations.quickLaunch.earn.action), | ||
url: '/earn/market-making', | ||
backgroundImage: earnBg, | ||
}, | ||
{ | ||
title: t(pageTranslations.quickLaunch.lend.title, { | ||
amount: Number(interestRate).toFixed(2), | ||
}), | ||
description: t(pageTranslations.quickLaunch.lend.description), | ||
action: t(pageTranslations.quickLaunch.lend.action), | ||
url: '/earn/lend', | ||
backgroundImage: earnBg, | ||
}, | ||
{ | ||
title: t(pageTranslations.quickLaunch.borrow.title), | ||
description: t(pageTranslations.quickLaunch.borrow.description), | ||
action: t(pageTranslations.quickLaunch.borrow.action), | ||
url: '/borrow/fixed-interest', | ||
backgroundImage: borrowBg, | ||
}, | ||
]; | ||
|
||
return ( | ||
<div className="bg-gray-80 rounded min-h-72 md:p-6 p-4 mb-10 grid md:grid-cols-2 xl:grid-cols-4 md:gap-6 gap-4"> | ||
{options.map((option, index) => ( | ||
<div | ||
key={index} | ||
className="relative p-4 md:p-6 bg-gray-70 rounded flex flex-col md:items-start justify-end md:min-h-60 min-h-40" | ||
> | ||
<img | ||
src={option.backgroundImage} | ||
alt={option.title} | ||
className="absolute top-0 right-0 md:max-w-none max-w-14" | ||
/> | ||
<Paragraph | ||
className="mb-6 font-medium text-sm xl:max-w-36 xl:pr-0 pr-12" | ||
children={option.title} | ||
/> | ||
<Paragraph | ||
className="mb-4 md:mb-6 font-medium xl:pr-0 pr-12" | ||
children={option.description} | ||
/> | ||
<Button | ||
className="w-full sm:w-auto" | ||
text={option.action} | ||
href={option.url} | ||
style={ButtonStyle.secondary} | ||
/> | ||
</div> | ||
))} | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.