File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
cms/src/app/(api)/tokenlist Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -175,8 +175,24 @@ export const GET = async (request: Request) => {
175175 underlyingTokens = foundUnderlyingTokens ;
176176 }
177177
178- // Combine all tokens
179- const allTokens = [ ...tokens , ...underlyingTokens ] ;
178+ // Combine all tokens and deduplicate by composite ID (chainId:address)
179+ const tokenMap = new Map < string , Token > ( ) ;
180+
181+ // Add initial tokens
182+ for ( const token of tokens ) {
183+ const key = `${ token . chainId } :${ token . address . toLowerCase ( ) } ` ;
184+ tokenMap . set ( key , token ) ;
185+ }
186+
187+ // Add underlying tokens (will not overwrite existing ones)
188+ for ( const token of underlyingTokens ) {
189+ const key = `${ token . chainId } :${ token . address . toLowerCase ( ) } ` ;
190+ if ( ! tokenMap . has ( key ) ) {
191+ tokenMap . set ( key , token ) ;
192+ }
193+ }
194+
195+ const allTokens = Array . from ( tokenMap . values ( ) ) ;
180196
181197 // Get testnet chain IDs programmatically from Superfluid metadata
182198 const testnetChainIds = new Set ( superfluidMetadata . testnets . map ( ( network ) => network . chainId ) ) ;
You can’t perform that action at this time.
0 commit comments