Skip to content

Commit b0365d0

Browse files
foodakamgrabina
andauthored
Feat/sonic rewards [skip cypress] (#2381)
Co-authored-by: Martin Grabina <[email protected]>
1 parent ec2b8a2 commit b0365d0

File tree

11 files changed

+91
-12
lines changed

11 files changed

+91
-12
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"dependencies": {
3434
"@aave/contract-helpers": "1.32.1",
3535
"@aave/math-utils": "1.32.1",
36-
"@bgd-labs/aave-address-book": "4.13.1",
36+
"@bgd-labs/aave-address-book": "4.14.0",
3737
"@emotion/cache": "11.10.3",
3838
"@emotion/react": "11.10.4",
3939
"@emotion/server": "latest",

src/components/incentives/IncentivesButton.tsx

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Box, SvgIcon, Typography } from '@mui/material';
66
import { useState } from 'react';
77
import { useEthenaIncentives } from 'src/hooks/useEthenaIncentives';
88
import { useMeritIncentives } from 'src/hooks/useMeritIncentives';
9+
import { useSonicIncentives } from 'src/hooks/useSonicIncentives';
910
import { useZkSyncIgniteIncentives } from 'src/hooks/useZkSyncIgniteIncentives';
1011
import { useRootStore } from 'src/store/root';
1112
import { DASHBOARD } from 'src/utils/mixPanelEvents';
@@ -16,6 +17,7 @@ import { TokenIcon } from '../primitives/TokenIcon';
1617
import { EthenaAirdropTooltipContent } from './EthenaIncentivesTooltipContent';
1718
import { getSymbolMap, IncentivesTooltipContent } from './IncentivesTooltipContent';
1819
import { MeritIncentivesTooltipContent } from './MeritIncentivesTooltipContent';
20+
import { SonicAirdropTooltipContent } from './SonicIncentivesTooltipContent';
1921
import { ZkSyncIgniteIncentivesTooltipContent } from './ZkSyncIgniteIncentivesTooltipContent';
2022

2123
interface IncentivesButtonProps {
@@ -109,7 +111,27 @@ export const EthenaIncentivesButton = ({ rewardedAsset }: { rewardedAsset?: stri
109111
setOpen={setOpen}
110112
open={open}
111113
>
112-
<ContentEthenaButton points={points} />
114+
<ContentPointsButton points={points} icon={'/icons/other/ethena.svg'} />
115+
</ContentWithTooltip>
116+
);
117+
};
118+
119+
export const SonicIncentivesButton = ({ rewardedAsset }: { rewardedAsset?: string }) => {
120+
const [open, setOpen] = useState(false);
121+
const points = useSonicIncentives(rewardedAsset);
122+
123+
if (!points) {
124+
return null;
125+
}
126+
127+
return (
128+
<ContentWithTooltip
129+
tooltipContent={<SonicAirdropTooltipContent points={points} />}
130+
withoutHover
131+
setOpen={setOpen}
132+
open={open}
133+
>
134+
<ContentPointsButton points={points} icon={'/icons/networks/sonic.svg'} />
113135
</ContentWithTooltip>
114136
);
115137
};
@@ -294,7 +316,7 @@ const Content = ({
294316
);
295317
};
296318

297-
const ContentEthenaButton = ({ points }: { points: number }) => {
319+
const ContentPointsButton = ({ points, icon }: { points: number; icon: string }) => {
298320
const [open, setOpen] = useState(false);
299321
const trackEvent = useRootStore((store) => store.trackEvent);
300322

@@ -326,7 +348,7 @@ const ContentEthenaButton = ({ points }: { points: number }) => {
326348
</Typography>
327349
</Box>
328350
<Box sx={{ display: 'inline-flex' }}>
329-
<img src={'/icons/other/ethena.svg'} width={12} height={12} alt="ethena-icon" />
351+
<img src={icon} width={12} height={12} alt="ethena-icon" />
330352
</Box>
331353
</Box>
332354
);

src/components/incentives/IncentivesCard.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
EthenaIncentivesButton,
1010
IncentivesButton,
1111
MeritIncentivesButton,
12+
SonicIncentivesButton,
1213
ZkIgniteIncentivesButton,
1314
} from './IncentivesButton';
1415

@@ -87,6 +88,7 @@ export const IncentivesCard = ({
8788
protocolAction={protocolAction}
8889
/>
8990
<EthenaIncentivesButton rewardedAsset={address} />
91+
<SonicIncentivesButton rewardedAsset={address} />
9092
</Box>
9193
</Box>
9294
);
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { Trans } from '@lingui/macro';
2+
import { Box } from '@mui/material';
3+
4+
import { Link } from '../primitives/Link';
5+
6+
export const SonicAirdropTooltipContent = ({ points }: { points: number }) => {
7+
return (
8+
<Box>
9+
<Trans>{`This asset is eligible for ${(<b>{points}x</b>)} Sonic Rewards.\n`}</Trans>
10+
<br />
11+
<Trans>{'Learn more about Sonic Rewards program'}</Trans>{' '}
12+
<Link
13+
href="https://blog.soniclabs.com/sonic-points-simplified-how-to-qualify-for-200-million-s-airdrop/"
14+
sx={{ textDecoration: 'underline' }}
15+
variant="caption"
16+
color="text.secondary"
17+
>
18+
{'here'}
19+
</Link>
20+
{'.'}
21+
<br />
22+
<br />
23+
<Trans>
24+
{`Aave Labs does not
25+
guarantee the program and accepts no liability.\n`}
26+
</Trans>
27+
</Box>
28+
);
29+
};

src/hooks/useSonicIncentives.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// import { AaveV3Sonic } from '@bgd-labs/aave-address-book';
2+
3+
const getSonicData = (assetAddress: string): number | undefined => SONIC_DATA_MAP.get(assetAddress);
4+
5+
const SONIC_DATA_MAP: Map<string, number> = new Map([
6+
['0xe18Ab82c81E7Eecff32B8A82B1b7d2d23F1EcE96', 4], //AaveV3Sonic.ASSETS.WETH.A_TOKEN
7+
['0x578Ee1ca3a8E1b54554Da1Bf7C583506C4CD11c6', 10], // AaveV3Sonic.ASSETS.USDC.e.A_TOKEN
8+
['0x6C5E14A212c1C3e4Baf6f871ac9B1a969918c131', 8], // AaveV3Sonic.ASSETS.ws.A_TOKEN
9+
]);
10+
11+
export const useSonicIncentives = (rewardedAsset?: string) => {
12+
if (!rewardedAsset) {
13+
return undefined;
14+
}
15+
16+
return getSonicData(rewardedAsset);
17+
};

src/locales/el/messages.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/locales/en/messages.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/locales/en/messages.po

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ msgid "Receive (est.)"
2222
msgstr "Receive (est.)"
2323

2424
#: src/components/incentives/EthenaIncentivesTooltipContent.tsx
25+
#: src/components/incentives/SonicIncentivesTooltipContent.tsx
2526
msgid "Aave Labs does not guarantee the program and accepts no liability."
2627
msgstr "Aave Labs does not guarantee the program and accepts no liability."
2728

@@ -481,6 +482,10 @@ msgstr "Borrowing is unavailable because you’re using Isolation mode. To manag
481482
msgid "Share on Lens"
482483
msgstr "Share on Lens"
483484

485+
#: src/components/incentives/SonicIncentivesTooltipContent.tsx
486+
msgid "Learn more about Sonic Rewards program"
487+
msgstr "Learn more about Sonic Rewards program"
488+
484489
#: src/components/transactions/ClaimRewards/ClaimRewardsActions.tsx
485490
msgid "Claim all"
486491
msgstr "Claim all"
@@ -3251,6 +3256,10 @@ msgstr "With testnet Faucet you can get free assets to test the Aave Protocol. M
32513256
msgid "Get ABP v2 Token"
32523257
msgstr "Get ABP v2 Token"
32533258

3259+
#: src/components/incentives/SonicIncentivesTooltipContent.tsx
3260+
msgid "This asset is eligible for {0} Sonic Rewards."
3261+
msgstr "This asset is eligible for {0} Sonic Rewards."
3262+
32543263
#: pages/staking.staking.tsx
32553264
msgid "As a result of governance decisions, this ABPT staking pool is now deprecated. You have the flexibility to either migrate all of your tokens to v2 or unstake them without any cooldown period."
32563265
msgstr "As a result of governance decisions, this ABPT staking pool is now deprecated. You have the flexibility to either migrate all of your tokens to v2 or unstake them without any cooldown period."

src/locales/es/messages.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/locales/fr/messages.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)