Skip to content

Commit da52f40

Browse files
committed
Merge branch 'main' into pool-alert-banner
2 parents 1acfd5d + d4b908d commit da52f40

Some content is hidden

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

49 files changed

+1169
-403
lines changed

.github/copilot-instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ src/[domain]/
7373
- React 19 with TypeScript
7474
- TanStack Router for routing
7575
- TanStack Query for data fetching
76-
- Node.js 22 (required)
76+
- Node.js LTS version (required)
7777
- Yarn 4 workspaces
7878

7979
**State & Data:**

.github/workflows/prices-api.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Setup NPM registry in Yarn
1616
uses: actions/setup-node@v4
1717
with:
18-
node-version: '22'
18+
node-version: 22
1919
cache: yarn
2020
registry-url: 'https://registry.npmjs.org'
2121

apps/main/src/dex/components/PageCreatePool/Summary/OracleSummary.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { styled } from 'styled-components'
22
import { isAddress } from 'viem'
3+
import { NG_ASSET_TYPE } from '@/dex/components/PageCreatePool/constants'
34
import {
45
CategoryDataRow,
56
SummaryDataTitle,
@@ -39,28 +40,28 @@ const OracleSummary = ({ chainId }: Props) => {
3940

4041
return (
4142
<OraclesWrapper>
42-
{tokenA.ngAssetType === 1 && tokenA.address !== '' && (
43+
{tokenA.ngAssetType === NG_ASSET_TYPE.ORACLE && tokenA.address !== '' && (
4344
<OracleTokenSummary chainId={chainId} token={tokenA} title={t`Token A`} />
4445
)}
45-
{tokenB.ngAssetType === 1 && tokenB.address !== '' && (
46+
{tokenB.ngAssetType === NG_ASSET_TYPE.ORACLE && tokenB.address !== '' && (
4647
<OracleTokenSummary chainId={chainId} token={tokenB} title={t`Token B`} />
4748
)}
48-
{tokenC.ngAssetType === 1 && tokenC.address !== '' && (
49+
{tokenC.ngAssetType === NG_ASSET_TYPE.ORACLE && tokenC.address !== '' && (
4950
<OracleTokenSummary chainId={chainId} token={tokenC} title={t`Token C`} />
5051
)}
51-
{tokenD.ngAssetType === 1 && tokenD.address !== '' && (
52+
{tokenD.ngAssetType === NG_ASSET_TYPE.ORACLE && tokenD.address !== '' && (
5253
<OracleTokenSummary chainId={chainId} token={tokenD} title={t`Token D`} />
5354
)}
54-
{tokenD.ngAssetType === 1 && tokenE.address !== '' && (
55+
{tokenD.ngAssetType === NG_ASSET_TYPE.ORACLE && tokenE.address !== '' && (
5556
<OracleTokenSummary chainId={chainId} token={tokenE} title={t`Token E`} />
5657
)}
57-
{tokenD.ngAssetType === 1 && tokenF.address !== '' && (
58+
{tokenD.ngAssetType === NG_ASSET_TYPE.ORACLE && tokenF.address !== '' && (
5859
<OracleTokenSummary chainId={chainId} token={tokenF} title={t`Token F`} />
5960
)}
60-
{tokenD.ngAssetType === 1 && tokenG.address !== '' && (
61+
{tokenD.ngAssetType === NG_ASSET_TYPE.ORACLE && tokenG.address !== '' && (
6162
<OracleTokenSummary chainId={chainId} token={tokenG} title={t`Token G`} />
6263
)}
63-
{tokenD.ngAssetType === 1 && tokenH.address !== '' && (
64+
{tokenD.ngAssetType === NG_ASSET_TYPE.ORACLE && tokenH.address !== '' && (
6465
<OracleTokenSummary chainId={chainId} token={tokenH} title={t`Token H`} />
6566
)}
6667
</OraclesWrapper>

apps/main/src/dex/components/PageCreatePool/Summary/TokensInPoolSummary.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { styled } from 'styled-components'
2-
import { STABLESWAP } from '@/dex/components/PageCreatePool/constants'
32
import {
3+
STABLESWAP,
44
TOKEN_A,
55
TOKEN_B,
66
TOKEN_C,
@@ -9,6 +9,7 @@ import {
99
TOKEN_F,
1010
TOKEN_G,
1111
TOKEN_H,
12+
NG_ASSET_TYPE,
1213
} from '@/dex/components/PageCreatePool/constants'
1314
import OracleSummary from '@/dex/components/PageCreatePool/Summary/OracleSummary'
1415
import {
@@ -208,10 +209,10 @@ const TokenSummary = ({ blockchainId, token, chainId, swapType }: TokenSummary)
208209
</TokenSymbol>
209210
{swapType === STABLESWAP && network.stableswapFactory && (
210211
<TokenType>
211-
{token.ngAssetType === 0 && t`Standard`}
212-
{token.ngAssetType === 1 && t`Oracle`}
213-
{token.ngAssetType === 2 && t`Rebasing`}
214-
{token.ngAssetType === 3 && t`ERC4626`}
212+
{token.ngAssetType === NG_ASSET_TYPE.STANDARD && t`Standard`}
213+
{token.ngAssetType === NG_ASSET_TYPE.ORACLE && t`Oracle`}
214+
{token.ngAssetType === NG_ASSET_TYPE.REBASING && t`Rebasing`}
215+
{token.ngAssetType === NG_ASSET_TYPE.ERC4626 && t`ERC4626`}
215216
</TokenType>
216217
)}
217218
</Box>

apps/main/src/dex/components/PageCreatePool/TokensInPool/SelectToken.tsx

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Key } from 'react'
22
import { styled } from 'styled-components'
3+
import { type Address } from 'viem'
34
import {
45
STABLESWAP,
56
CRYPTOSWAP,
@@ -11,7 +12,9 @@ import {
1112
TOKEN_F,
1213
TOKEN_G,
1314
TOKEN_H,
15+
NG_ASSET_TYPE,
1416
} from '@/dex/components/PageCreatePool/constants'
17+
import { useAutoDetectErc4626 } from '@/dex/components/PageCreatePool/hooks/useAutoDetectErc4626'
1518
import {
1619
CreateToken,
1720
TokenState,
@@ -27,6 +30,7 @@ import Button from '@ui/Button'
2730
import Checkbox from '@ui/Checkbox'
2831
import Icon from '@ui/Icon'
2932
import { t } from '@ui-kit/lib/i18n'
33+
import WarningBox from '../components/WarningBox'
3034
import SelectTokenButton from './SelectTokenButton'
3135

3236
type Props = {
@@ -59,6 +63,10 @@ const SelectToken = ({
5963
const clearToken = useStore((state) => state.createPool.clearToken)
6064
const tokensInPool = useStore((state) => state.createPool.tokensInPool)
6165
const { data: network } = useNetworkByChain({ chainId })
66+
void useAutoDetectErc4626({
67+
tokenId,
68+
address: token.address as Address,
69+
})
6270

6371
const getTokenName = (tokenId: TokenId) => {
6472
if (tokenId === TOKEN_D) return t`Token D`
@@ -116,28 +124,31 @@ const SelectToken = ({
116124
onSelectionChange={(value: Key) => handleInpChange(tokenId, value as string, tokensInPool)}
117125
/>
118126
{swapType === STABLESWAP && (network.stableswapFactory || network.stableswapFactoryOld) && !token.basePool && (
119-
<StableSwapTogglesRow>
120-
<StyledCheckbox
121-
isSelected={token.ngAssetType === 0}
122-
onChange={() => updateNgAssetType(tokenId, 0)}
123-
isDisabled={false}
124-
>{t`Standard`}</StyledCheckbox>
125-
<StyledCheckbox
126-
isSelected={token.ngAssetType === 1}
127-
isDisabled={false}
128-
onChange={() => updateNgAssetType(tokenId, 1)}
129-
>{t`Oracle`}</StyledCheckbox>
130-
<StyledCheckbox
131-
isSelected={token.ngAssetType === 2}
132-
onChange={() => updateNgAssetType(tokenId, 2)}
133-
isDisabled={false}
134-
>{t`Rebasing`}</StyledCheckbox>
135-
<StyledCheckbox
136-
isSelected={token.ngAssetType === 3}
137-
isDisabled={false}
138-
onChange={() => updateNgAssetType(tokenId, 3)}
139-
>{t`ERC4626`}</StyledCheckbox>
140-
</StableSwapTogglesRow>
127+
<>
128+
<StableSwapTogglesRow>
129+
<StyledCheckbox
130+
isSelected={token.ngAssetType === NG_ASSET_TYPE.STANDARD}
131+
onChange={() => updateNgAssetType(tokenId, NG_ASSET_TYPE.STANDARD)}
132+
>{t`Standard`}</StyledCheckbox>
133+
<StyledCheckbox
134+
isSelected={token.ngAssetType === NG_ASSET_TYPE.ORACLE}
135+
onChange={() => updateNgAssetType(tokenId, NG_ASSET_TYPE.ORACLE)}
136+
>{t`Oracle`}</StyledCheckbox>
137+
<StyledCheckbox
138+
isSelected={token.ngAssetType === NG_ASSET_TYPE.REBASING}
139+
onChange={() => updateNgAssetType(tokenId, NG_ASSET_TYPE.REBASING)}
140+
>{t`Rebasing`}</StyledCheckbox>
141+
<StyledCheckbox
142+
isSelected={token.ngAssetType === NG_ASSET_TYPE.ERC4626}
143+
onChange={() => updateNgAssetType(tokenId, NG_ASSET_TYPE.ERC4626)}
144+
>{t`ERC4626`}</StyledCheckbox>
145+
</StableSwapTogglesRow>
146+
{token.erc4626.isErc4626 && token.ngAssetType !== NG_ASSET_TYPE.ERC4626 && (
147+
<WarningBox
148+
message={t`${token.symbol} is identified as an ERC4626 token, please select ERC4626 as the asset type.`}
149+
/>
150+
)}
151+
</>
141152
)}
142153
</TokenPickerContainer>
143154
)

apps/main/src/dex/components/PageCreatePool/TokensInPool/SetOracle.tsx

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
TOKEN_F,
1313
TOKEN_G,
1414
TOKEN_H,
15+
NG_ASSET_TYPE,
1516
} from '@/dex/components/PageCreatePool/constants'
1617
import type { TokenState, TokenId } from '@/dex/components/PageCreatePool/types'
1718
import { validateOracleFunction } from '@/dex/components/PageCreatePool/utils'
@@ -26,41 +27,24 @@ type OracleInputProps = {
2627
}
2728

2829
const SetOracle = () => {
29-
const tokenA = useStore((state) => state.createPool.tokensInPool.tokenA)
30-
const tokenB = useStore((state) => state.createPool.tokensInPool.tokenB)
31-
const tokenC = useStore((state) => state.createPool.tokensInPool.tokenC)
32-
const tokenD = useStore((state) => state.createPool.tokensInPool.tokenD)
33-
const tokenE = useStore((state) => state.createPool.tokensInPool.tokenE)
34-
const tokenF = useStore((state) => state.createPool.tokensInPool.tokenF)
35-
const tokenG = useStore((state) => state.createPool.tokensInPool.tokenG)
36-
const tokenH = useStore((state) => state.createPool.tokensInPool.tokenH)
30+
const tokens = useStore((state) => state.createPool.tokensInPool)
31+
32+
const oracleTokens: { token: TokenState; tokenId: TokenId; title: string }[] = [
33+
{ token: tokens.tokenA, tokenId: TOKEN_A as TokenId, title: t`Token A` },
34+
{ token: tokens.tokenB, tokenId: TOKEN_B as TokenId, title: t`Token B` },
35+
{ token: tokens.tokenC, tokenId: TOKEN_C as TokenId, title: t`Token C` },
36+
{ token: tokens.tokenD, tokenId: TOKEN_D as TokenId, title: t`Token D` },
37+
{ token: tokens.tokenE, tokenId: TOKEN_E as TokenId, title: t`Token E` },
38+
{ token: tokens.tokenF, tokenId: TOKEN_F as TokenId, title: t`Token F` },
39+
{ token: tokens.tokenG, tokenId: TOKEN_G as TokenId, title: t`Token G` },
40+
{ token: tokens.tokenH, tokenId: TOKEN_H as TokenId, title: t`Token H` },
41+
].filter(({ token }) => token.ngAssetType === NG_ASSET_TYPE.ORACLE && token.address !== '')
3742

3843
return (
3944
<OracleWrapper>
40-
{tokenA.ngAssetType === 1 && tokenA.address !== '' && (
41-
<OracleInputs token={tokenA} tokenId={TOKEN_A} title={t`Token A`} />
42-
)}
43-
{tokenB.ngAssetType === 1 && tokenB.address !== '' && (
44-
<OracleInputs token={tokenB} tokenId={TOKEN_B} title={t`Token B`} />
45-
)}
46-
{tokenC.ngAssetType === 1 && tokenC.address !== '' && (
47-
<OracleInputs token={tokenC} tokenId={TOKEN_C} title={t`Token C`} />
48-
)}
49-
{tokenD.ngAssetType === 1 && tokenD.address !== '' && (
50-
<OracleInputs token={tokenD} tokenId={TOKEN_D} title={t`Token D`} />
51-
)}
52-
{tokenD.ngAssetType === 1 && tokenD.address !== '' && (
53-
<OracleInputs token={tokenE} tokenId={TOKEN_E} title={t`Token E`} />
54-
)}
55-
{tokenD.ngAssetType === 1 && tokenD.address !== '' && (
56-
<OracleInputs token={tokenF} tokenId={TOKEN_F} title={t`Token F`} />
57-
)}
58-
{tokenD.ngAssetType === 1 && tokenD.address !== '' && (
59-
<OracleInputs token={tokenG} tokenId={TOKEN_G} title={t`Token G`} />
60-
)}
61-
{tokenD.ngAssetType === 1 && tokenD.address !== '' && (
62-
<OracleInputs token={tokenH} tokenId={TOKEN_H} title={t`Token H`} />
63-
)}
45+
{oracleTokens.map(({ token, tokenId, title }) => (
46+
<OracleInputs key={tokenId} token={token} tokenId={tokenId} title={title} />
47+
))}
6448
</OracleWrapper>
6549
)
6650
}

0 commit comments

Comments
 (0)