Skip to content

Commit 9d5f739

Browse files
mgrabinafoodaka
andauthored
feat: swaps on sonic (#2537)
Co-authored-by: Mark Hinschberger <[email protected]>
1 parent 8ec0393 commit 9d5f739

File tree

6 files changed

+119
-28
lines changed

6 files changed

+119
-28
lines changed

src/components/transactions/Switch/switch.constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export const ParaswapSupportedNetworks = [
1313
ChainId.optimism,
1414
ChainId.xdai,
1515
ChainId.bnb,
16+
ChainId.sonic,
1617
];
1718

1819
SupportedChainId;

src/layouts/MainLayout.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { ChainId } from '@aave/contract-helpers';
12
import { Box } from '@mui/material';
23
import React, { ReactNode } from 'react';
34
import AnalyticsConsent from 'src/components/Analytics/AnalyticsConsent';
4-
import { ROUTES } from 'src/components/primitives/Link';
5+
import { useModalContext } from 'src/hooks/useModal';
56
import { FeedbackModal } from 'src/layouts/FeedbackDialog';
67
import { FORK_ENABLED } from 'src/utils/marketsAndNetworksConfig';
78

@@ -27,13 +28,18 @@ import TopBarNotify from './TopBarNotify';
2728
// );
2829

2930
export function MainLayout({ children }: { children: ReactNode }) {
30-
const APP_BANNER_VERSION = '7.0.0';
31-
// const currentMarket = useRootStore((state) => state.currentMarket);
31+
const APP_BANNER_VERSION = '8.0.0';
32+
const { openSwitch } = useModalContext();
33+
34+
const handleLearnMore = () => {
35+
openSwitch('', ChainId.sonic);
36+
};
37+
3238
return (
3339
<>
3440
<TopBarNotify
35-
learnMoreLink={ROUTES.staking}
36-
notifyText="Aave Safety Module has been upgraded to Umbrella"
41+
learnMoreLink={handleLearnMore}
42+
notifyText="Swaps are now live on Sonic"
3743
bannerVersion={APP_BANNER_VERSION}
3844
/>
3945

src/layouts/TopBarNotify.tsx

Lines changed: 57 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { useRootStore } from 'src/store/root';
1313

1414
interface TopBarNotifyProps {
1515
notifyText: ReactNode;
16-
learnMoreLink?: string;
16+
learnMoreLink?: string | (() => void);
1717
buttonText?: string;
1818
bannerVersion: string;
1919
icon?: string;
@@ -99,34 +99,68 @@ export default function TopBarNotify({
9999
{icon && !sm ? <MarketLogo sx={{ ml: 2 }} size={32} logo={icon} /> : ''}
100100

101101
{learnMoreLink && md ? (
102-
<Link
103-
sx={{ color: 'white', textDecoration: 'underline', paddingLeft: 2 }}
104-
// target={'_blank'} Todo option to pass as prop
105-
href={learnMoreLink}
106-
>
107-
<Trans>{buttonText ? buttonText : `Learn more`}</Trans>
108-
</Link>
102+
typeof learnMoreLink === 'string' ? (
103+
<Link
104+
sx={{ color: 'white', textDecoration: 'underline', paddingLeft: 2 }}
105+
// target={'_blank'} Todo option to pass as prop
106+
href={learnMoreLink}
107+
>
108+
<Trans>{buttonText ? buttonText : `Learn more`}</Trans>
109+
</Link>
110+
) : (
111+
<Button
112+
sx={{
113+
color: 'white',
114+
textDecoration: 'underline',
115+
paddingLeft: 2,
116+
background: 'none',
117+
textTransform: 'none',
118+
minWidth: 'auto',
119+
padding: 0,
120+
marginLeft: 2,
121+
}}
122+
onClick={learnMoreLink}
123+
>
124+
<Trans>{buttonText ? buttonText : `Swap Now`}</Trans>
125+
</Button>
126+
)
109127
) : null}
110128
</Typography>
111129
</Box>
112130

113131
<Box>
114132
{!md && learnMoreLink ? (
115-
<Button
116-
component="a"
117-
// target={'_blank'} Todo option to pass as prop
118-
size="small"
119-
href={learnMoreLink}
120-
sx={{
121-
minWidth: '90px',
122-
marginLeft: 5,
123-
height: '24px',
124-
background: '#383D51',
125-
color: '#EAEBEF',
126-
}}
127-
>
128-
<Trans> {buttonText ? buttonText.toUpperCase() : `LEARN MORE`}</Trans>
129-
</Button>
133+
typeof learnMoreLink === 'string' ? (
134+
<Button
135+
component="a"
136+
// target={'_blank'} Todo option to pass as prop
137+
size="small"
138+
href={learnMoreLink}
139+
sx={{
140+
minWidth: '90px',
141+
marginLeft: 5,
142+
height: '24px',
143+
background: '#383D51',
144+
color: '#EAEBEF',
145+
}}
146+
>
147+
<Trans> {buttonText ? buttonText.toUpperCase() : `LEARN MORE`}</Trans>
148+
</Button>
149+
) : (
150+
<Button
151+
size="small"
152+
onClick={learnMoreLink}
153+
sx={{
154+
minWidth: '90px',
155+
marginLeft: 5,
156+
height: '24px',
157+
background: '#383D51',
158+
color: '#EAEBEF',
159+
}}
160+
>
161+
<Trans> {buttonText ? buttonText.toUpperCase() : `Swap Now`}</Trans>
162+
</Button>
163+
)
130164
) : null}
131165
</Box>
132166
<Button

src/locales/en/messages.po

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,8 @@ msgstr "deposited"
11391139
#: src/components/transactions/Switch/SwitchAssetInput.tsx
11401140
#: src/layouts/TopBarNotify.tsx
11411141
#: src/layouts/TopBarNotify.tsx
1142+
#: src/layouts/TopBarNotify.tsx
1143+
#: src/layouts/TopBarNotify.tsx
11421144
#: src/modules/dashboard/DashboardEModeButton.tsx
11431145
#: src/modules/reserve-overview/ReserveTopDetailsWrapper.tsx
11441146
#: src/modules/staking/SavingsGhoProgram.tsx

src/ui-config/TokenList.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,18 @@ const NETWORK_ASSETS: TokenInfo[] = [
160160
isNative: true,
161161
},
162162
},
163+
{
164+
name: 'Sonic',
165+
symbol: 'S',
166+
decimals: 18,
167+
address: API_ETH_MOCK_ADDRESS,
168+
chainId: 146,
169+
logoURI:
170+
'https://assets.coingecko.com/coins/images/38108/standard/200x200_Sonic_Logo.png?1734679256',
171+
extensions: {
172+
isNative: true,
173+
},
174+
},
163175
];
164176

165177
export const TOKEN_LIST: TokenList = {
@@ -12977,6 +12989,41 @@ export const TOKEN_LIST: TokenList = {
1297712989
chainId: 1,
1297812990
logoURI: 'https://assets.coingecko.com/coins/images/32254/standard/sdai.png?1697015278',
1297912991
},
12992+
// Sonic
12993+
{
12994+
name: 'USDC',
12995+
address: '0x29219dd400f2Bf60E5a23d13Be72B486D4038894',
12996+
symbol: 'USDC',
12997+
decimals: 6,
12998+
chainId: 146,
12999+
logoURI: 'https://assets.coingecko.com/coins/images/6319/thumb/USD_Coin_icon.png?1547042389',
13000+
},
13001+
{
13002+
name: 'Wrapped Sonic',
13003+
address: '0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38',
13004+
symbol: 'wS',
13005+
decimals: 18,
13006+
chainId: 146,
13007+
logoURI:
13008+
'https://assets.coingecko.com/coins/images/52857/standard/wrapped_sonic.png?1734536585',
13009+
},
13010+
{
13011+
name: 'Wrapped ETH',
13012+
address: '0x50c42dEAcD8Fc9773493ED674b675bE577f2634b',
13013+
symbol: 'WETH',
13014+
decimals: 18,
13015+
chainId: 146,
13016+
logoURI: 'https://assets.coingecko.com/coins/images/2518/standard/weth.png?1696503332',
13017+
},
13018+
{
13019+
name: 'Beets Staked Sonic',
13020+
address: '0xE5DA20F15420aD15DE0fa650600aFc998bbE3955',
13021+
symbol: 'stS',
13022+
decimals: 18,
13023+
chainId: 146,
13024+
logoURI:
13025+
'https://assets.coingecko.com/coins/images/52937/standard/token-beets-staked-sonic.png?1734712659',
13026+
},
1298013027
],
1298113028
};
1298213029

src/ui-config/marketsConfig.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ export const marketsData: {
491491
liquiditySwap: true,
492492
debtSwitch: true,
493493
withdrawAndSwitch: true,
494+
switch: true,
494495
},
495496
addresses: {
496497
LENDING_POOL_ADDRESS_PROVIDER: AaveV3Sonic.POOL_ADDRESSES_PROVIDER,

0 commit comments

Comments
 (0)