Skip to content

Commit 337bf2d

Browse files
committed
feat: unknown token filter pair
1 parent 7762a7a commit 337bf2d

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

next.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @type {import('next').NextConfig} */
22
const nextConfig = {
3-
// output: 'standalone',
3+
output: 'standalone',
44
images: {
55
remotePatterns: [
66
{

src/features/liquidityPool/utils.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import type {
1313
} from '@/features/liquidityPool/types'
1414
import type { TTradeableTokenProps } from '@/features/tokens/types'
1515
import { getTradeableTokenByAddress, getBBAFromDaltons, isNativeBBA } from '@/lib/token'
16+
import StaticTradeableTokens from '@/staticData/tokens'
1617

1718
const publicKey = (property: string = 'publicKey') => {
1819
return blob(32, property)
@@ -231,6 +232,11 @@ export function calculatePoolMetrics(
231232
}
232233
}
233234

235+
const isUnknownTokenBySymbol = (symbol: string) => {
236+
const knownSymbol = StaticTradeableTokens.map((token) => token.symbol)
237+
return !knownSymbol.includes(symbol)
238+
}
239+
234240
export async function processPoolAccount(
235241
connection: Connection,
236242
pubkey: PublicKey,
@@ -268,6 +274,9 @@ export async function processPoolAccount(
268274
getTokenMintInfo(connection, mintBKey)
269275
])
270276

277+
// to prevent any token pair that is not valid anymore
278+
if (isUnknownTokenBySymbol(mintA.symbol) || isUnknownTokenBySymbol(mintB.symbol)) return null
279+
271280
// Get token account balances (reserves)
272281
const [reserveA, reserveB] = await Promise.all([
273282
getTokenAccountBalance(connection, tokenAccountAKey),

0 commit comments

Comments
 (0)