@@ -253,9 +253,26 @@ class RaydiumSwap {
253253 currencyOutDecimals = poolInfo . baseDecimals
254254 }
255255
256- const currencyIn = new Token ( TOKEN_PROGRAM_ID , currencyInMint , currencyInDecimals )
256+ // Getting the metadata of the tokens
257+ const currencyInMeta = TOKEN_METADATA [ currencyInMint . toString ( ) ] || { symbol : 'UNKNOWN' , name : 'UNKNOWN' } ;
258+ const currencyOutMeta = TOKEN_METADATA [ currencyOutMint . toString ( ) ] || { symbol : 'UNKNOWN' , name : 'UNKNOWN' } ;
259+
260+ // Creating Token objects with a symbol and a name
261+ const currencyIn = new Token (
262+ TOKEN_PROGRAM_ID ,
263+ currencyInMint ,
264+ currencyInDecimals ,
265+ currencyInMeta . symbol ,
266+ currencyInMeta . name
267+ ) ;
257268 const amountIn = new TokenAmount ( currencyIn , rawAmountIn , false )
258- const currencyOut = new Token ( TOKEN_PROGRAM_ID , currencyOutMint , currencyOutDecimals )
269+ const currencyOut = new Token (
270+ TOKEN_PROGRAM_ID ,
271+ currencyOutMint ,
272+ currencyOutDecimals ,
273+ currencyOutMeta . symbol ,
274+ currencyOutMeta . name
275+ ) ;
259276 const slippage = new Percent ( 5 , 100 ) // 5% slippage
260277
261278 const { amountOut, minAmountOut, currentPrice, executionPrice, priceImpact, fee } = Liquidity . computeAmountOut ( {
@@ -278,4 +295,11 @@ class RaydiumSwap {
278295 }
279296}
280297
281- export default RaydiumSwap
298+ // Mapping tokens by addresses
299+ const TOKEN_METADATA : Record < string , { symbol : string ; name : string } > = {
300+ 'So11111111111111111111111111111111111111112' : { symbol : 'SOL' , name : 'Solana' } ,
301+ 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v' : { symbol : 'USDC' , name : 'USD Coin' } ,
302+ // Add other tokens if necessary. - mainnet.json
303+ } ;
304+
305+ export default RaydiumSwap
0 commit comments