@@ -15,7 +15,9 @@ import {
1515 TOKEN_G ,
1616 TOKEN_H ,
1717 FXSWAP ,
18+ NG_ASSET_TYPE ,
1819} from '@/dex/components/PageCreatePool/constants'
20+ import { useAutoDetectErc4626 } from '@/dex/components/PageCreatePool/hooks/useAutoDetectErc4626'
1921import SelectToken from '@/dex/components/PageCreatePool/TokensInPool/SelectToken'
2022import SetOracle from '@/dex/components/PageCreatePool/TokensInPool/SetOracle'
2123import { CreateToken , TokenId , TokensInPoolState } from '@/dex/components/PageCreatePool/types'
@@ -47,11 +49,12 @@ const TokensInPool = ({ curve, chainId, haveSigner }: Props) => {
4749 const updateTokensInPool = useStore ( ( state ) => state . createPool . updateTokensInPool )
4850 const updateTokenAmount = useStore ( ( state ) => state . createPool . updateTokenAmount )
4951 const updateSwapType = useStore ( ( state ) => state . createPool . updateSwapType )
52+ const updateNgAssetType = useStore ( ( state ) => state . createPool . updateNgAssetType )
5053 const basePools = useStore ( ( state ) => state . pools . basePools [ chainId ] ) ?? DEFAULT_POOLS
5154 const userBalances = useStore ( ( state ) => state . userBalances . userBalancesMapper )
5255 const { tokensMapper } = useTokensMapper ( chainId )
5356 const nativeToken = curve . getNetworkConstants ( ) . NATIVE_TOKEN
54-
57+ const { scheduleCheck : scheduleErc4626Check } = useAutoDetectErc4626 ( { tokensInPool } )
5558 const {
5659 data : { createDisabledTokens, stableswapFactory, tricryptoFactory, twocryptoFactory } ,
5760 } = useNetworkByChain ( { chainId } )
@@ -99,7 +102,15 @@ const TokensInPool = ({ curve, chainId, haveSigner }: Props) => {
99102
100103 const handleInpChange = useCallback (
101104 ( name : TokenId , value : string , tokensInPoolState : TokensInPoolState ) => {
102- if ( ! value . startsWith ( '0x' ) ) return
105+ const normalizedValue = value . toLowerCase ( )
106+
107+ if ( ! normalizedValue . startsWith ( '0x' ) ) return
108+ const previousAddress = tokensInPoolState [ name ] . address . toLowerCase ( )
109+
110+ if ( normalizedValue === previousAddress ) return
111+
112+ // reset the ngAssetType to Standard by default
113+ updateNgAssetType ( name , NG_ASSET_TYPE . STANDARD )
103114
104115 const basePoolCoins : string [ ] = getBasepoolCoins (
105116 value ,
@@ -144,7 +155,7 @@ const TokensInPool = ({ curve, chainId, haveSigner }: Props) => {
144155 ...updatedFormValues ,
145156 [ TOKEN_A ] : {
146157 ...updatedFormValues [ TOKEN_A ] ,
147- ngAssetType : 0 ,
158+ ngAssetType : NG_ASSET_TYPE . STANDARD ,
148159 address : value ,
149160 basePool : true ,
150161 } ,
@@ -163,7 +174,7 @@ const TokensInPool = ({ curve, chainId, haveSigner }: Props) => {
163174 ...updatedFormValues ,
164175 [ TOKEN_A ] : {
165176 ...updatedFormValues [ TOKEN_A ] ,
166- ngAssetType : 0 ,
177+ ngAssetType : NG_ASSET_TYPE . STANDARD ,
167178 symbol : findSymbol ( value ) ,
168179 address : value ,
169180 basePool : true ,
@@ -217,7 +228,7 @@ const TokensInPool = ({ curve, chainId, haveSigner }: Props) => {
217228 ...updatedFormValues ,
218229 [ TOKEN_B ] : {
219230 ...updatedFormValues [ TOKEN_B ] ,
220- ngAssetType : 0 ,
231+ ngAssetType : NG_ASSET_TYPE . STANDARD ,
221232 address : value ,
222233 symbol : findSymbol ( value ) ,
223234 basePool : true ,
@@ -237,7 +248,7 @@ const TokensInPool = ({ curve, chainId, haveSigner }: Props) => {
237248 ...updatedFormValues ,
238249 [ TOKEN_B ] : {
239250 ...updatedFormValues [ TOKEN_B ] ,
240- ngAssetType : 0 ,
251+ ngAssetType : NG_ASSET_TYPE . STANDARD ,
241252 address : value ,
242253 symbol : findSymbol ( value ) ,
243254 basePool : true ,
@@ -291,7 +302,7 @@ const TokensInPool = ({ curve, chainId, haveSigner }: Props) => {
291302 ...updatedFormValues ,
292303 [ TOKEN_A ] : {
293304 ...updatedFormValues [ TOKEN_A ] ,
294- ngAssetType : 0 ,
305+ ngAssetType : NG_ASSET_TYPE . STANDARD ,
295306 address : value ,
296307 symbol : findSymbol ( value ) ,
297308 basePool : true ,
@@ -327,7 +338,7 @@ const TokensInPool = ({ curve, chainId, haveSigner }: Props) => {
327338 ...updatedFormValues ,
328339 [ TOKEN_A ] : {
329340 ...updatedFormValues [ TOKEN_A ] ,
330- ngAssetType : 0 ,
341+ ngAssetType : NG_ASSET_TYPE . STANDARD ,
331342 address : value ,
332343 symbol : findSymbol ( value ) ,
333344 basePool : true ,
@@ -363,7 +374,7 @@ const TokensInPool = ({ curve, chainId, haveSigner }: Props) => {
363374 ...updatedFormValues ,
364375 [ TOKEN_A ] : {
365376 ...updatedFormValues [ TOKEN_A ] ,
366- ngAssetType : 0 ,
377+ ngAssetType : NG_ASSET_TYPE . STANDARD ,
367378 address : value ,
368379 symbol : findSymbol ( value ) ,
369380 basePool : true ,
@@ -399,7 +410,7 @@ const TokensInPool = ({ curve, chainId, haveSigner }: Props) => {
399410 ...updatedFormValues ,
400411 [ TOKEN_A ] : {
401412 ...updatedFormValues [ TOKEN_A ] ,
402- ngAssetType : 0 ,
413+ ngAssetType : NG_ASSET_TYPE . STANDARD ,
403414 address : value ,
404415 symbol : findSymbol ( value ) ,
405416 basePool : true ,
@@ -435,7 +446,7 @@ const TokensInPool = ({ curve, chainId, haveSigner }: Props) => {
435446 ...updatedFormValues ,
436447 [ TOKEN_A ] : {
437448 ...updatedFormValues [ TOKEN_A ] ,
438- ngAssetType : 0 ,
449+ ngAssetType : NG_ASSET_TYPE . STANDARD ,
439450 address : value ,
440451 symbol : findSymbol ( value ) ,
441452 basePool : true ,
@@ -471,7 +482,7 @@ const TokensInPool = ({ curve, chainId, haveSigner }: Props) => {
471482 ...updatedFormValues ,
472483 [ TOKEN_A ] : {
473484 ...updatedFormValues [ TOKEN_A ] ,
474- ngAssetType : 0 ,
485+ ngAssetType : NG_ASSET_TYPE . STANDARD ,
475486 address : value ,
476487 symbol : findSymbol ( value ) ,
477488 basePool : true ,
@@ -511,8 +522,12 @@ const TokensInPool = ({ curve, chainId, haveSigner }: Props) => {
511522 updatedFormValues [ TOKEN_G ] ,
512523 updatedFormValues [ TOKEN_H ] ,
513524 )
525+
526+ if ( updatedFormValues [ name ] . address . toLowerCase ( ) === normalizedValue ) {
527+ scheduleErc4626Check ( name , value )
528+ }
514529 } ,
515- [ tokensInPool , updateTokensInPool , curve , findSymbol , swapType , basePools ] ,
530+ [ tokensInPool , updateTokensInPool , curve , findSymbol , swapType , basePools , updateNgAssetType , scheduleErc4626Check ] ,
516531 )
517532
518533 const addToken = useCallback ( ( ) => {
@@ -538,7 +553,7 @@ const TokensInPool = ({ curve, chainId, haveSigner }: Props) => {
538553 ...tokensInPoolState [ token ] ,
539554 address : tokenId === token ? '' : tokensInPoolState [ token ] . address ,
540555 symbol : tokenId === token ? '' : tokensInPoolState [ token ] . symbol ,
541- ngAssetType : tokenId === token ? 0 : tokensInPoolState [ token ] . ngAssetType ,
556+ ngAssetType : tokenId === token ? NG_ASSET_TYPE . STANDARD : tokensInPoolState [ token ] . ngAssetType ,
542557 oracleAddress : tokenId === token ? '' : tokensInPoolState [ token ] . oracleAddress ,
543558 oracleFunction : tokenId === token ? '' : tokensInPoolState [ token ] . oracleFunction ,
544559 } )
0 commit comments