From bf6ef65db5a5c8c5199cb3e1ec31dd0b04d1f51d Mon Sep 17 00:00:00 2001 From: vladislav <103254648+vkidik@users.noreply.github.com> Date: Mon, 2 Jun 2025 17:43:58 +0300 Subject: [PATCH] addition to the swap description of Tokens --- src/RaydiumSwap.ts | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/RaydiumSwap.ts b/src/RaydiumSwap.ts index 3625be1..d1991c4 100644 --- a/src/RaydiumSwap.ts +++ b/src/RaydiumSwap.ts @@ -253,9 +253,26 @@ class RaydiumSwap { currencyOutDecimals = poolInfo.baseDecimals } - const currencyIn = new Token(TOKEN_PROGRAM_ID, currencyInMint, currencyInDecimals) + // Getting the metadata of the tokens + const currencyInMeta = TOKEN_METADATA[currencyInMint.toString()] || { symbol: 'UNKNOWN', name: 'UNKNOWN' }; + const currencyOutMeta = TOKEN_METADATA[currencyOutMint.toString()] || { symbol: 'UNKNOWN', name: 'UNKNOWN' }; + + // Creating Token objects with a symbol and a name + const currencyIn = new Token( + TOKEN_PROGRAM_ID, + currencyInMint, + currencyInDecimals, + currencyInMeta.symbol, + currencyInMeta.name + ); const amountIn = new TokenAmount(currencyIn, rawAmountIn, false) - const currencyOut = new Token(TOKEN_PROGRAM_ID, currencyOutMint, currencyOutDecimals) + const currencyOut = new Token( + TOKEN_PROGRAM_ID, + currencyOutMint, + currencyOutDecimals, + currencyOutMeta.symbol, + currencyOutMeta.name + ); const slippage = new Percent(5, 100) // 5% slippage const { amountOut, minAmountOut, currentPrice, executionPrice, priceImpact, fee } = Liquidity.computeAmountOut({ @@ -278,4 +295,11 @@ class RaydiumSwap { } } -export default RaydiumSwap \ No newline at end of file +// Mapping tokens by addresses +const TOKEN_METADATA: Record = { + 'So11111111111111111111111111111111111111112': { symbol: 'SOL', name: 'Solana' }, + 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v': { symbol: 'USDC', name: 'USD Coin' }, + // Add other tokens if necessary. - mainnet.json +}; + +export default RaydiumSwap