diff --git a/.env b/.env new file mode 100644 index 0000000..c9b18d7 --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +RPC_URL="https://api.devnet.solana.com" +WALLET_PRIVATE_KEY="43EeRipwq7QZurfASn7CnYuJ14pVaCEv7KWav9vknt1bFR6qspYXC2DbaC2gGydrVx4TFtWfyCFkEaLLLMB2bZoT" \ No newline at end of file diff --git a/.env.example b/.env.example deleted file mode 100644 index 7de6565..0000000 --- a/.env.example +++ /dev/null @@ -1,2 +0,0 @@ -RPC_URL=YOUR_RPC_URL -WALLET_PRIVATE_KEY=YOUR_PRIVATE_KEY \ No newline at end of file diff --git a/package.json b/package.json index 06169a9..6a5d585 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "license": "MIT", "dependencies": { "@coral-xyz/anchor": "^0.29.0", + "@project-serum/anchor": "^0.26.0", "@raydium-io/raydium-sdk": "^1.3.1-beta.50", "@solana/spl-token": "^0.4.1", "bs58": "^5.0.0", diff --git a/src/index.ts b/src/index.ts index 98531b1..8e88fee 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,6 +3,12 @@ import { Transaction, VersionedTransaction } from '@solana/web3.js'; import 'dotenv/config'; import { swapConfig } from './swapConfig'; // Import the configuration +////////////ayad////////// +import { + LiquidityPoolKeys, +} from '@raydium-io/raydium-sdk'; +import { web3 } from "@project-serum/anchor"; + /** * Performs a token swap on the Raydium protocol. * Depending on the configuration, it can execute the swap or simulate it. @@ -21,11 +27,50 @@ const swap = async () => { await raydiumSwap.loadPoolKeys(swapConfig.liquidityFile); console.log(`Loaded pool keys`); + + + /////////ayad///////////// /** * Find pool information for the given token pair. */ - const poolInfo = raydiumSwap.findPoolInfoForTokens(swapConfig.tokenAAddress, swapConfig.tokenBAddress); - console.log('Found pool info'); + // const poolInfo = raydiumSwap.findPoolInfoForTokens(swapConfig.tokenAAddress, swapConfig.tokenBAddress); + // console.log('Found pool info'); + + const poolInfo : LiquidityPoolKeys = { + // "_id":"6641bf8d7fdfe653a776471b", + // id:"2viGyp1hY8PGw7GEPzJvLdPAQpe7zL745oHp1C6a3jcJ", + id: new web3.PublicKey("2viGyp1hY8PGw7GEPzJvLdPAQpe7zL745oHp1C6a3jcJ"), + baseMint: new web3.PublicKey("Duqm5K5U1H8KfsSqwyWwWNWY5TLB9WseqNEAQMhS78hb"), + quoteMint: new web3.PublicKey("So11111111111111111111111111111111111111112"), + lpMint: new web3.PublicKey("89ZKE4aoyfLBe2RuV6jM3JGNhaV18Nxh8eNtjRcndBip"), + baseDecimals:9, + quoteDecimals:9, + lpDecimals:6, + version:4, + programId: new web3.PublicKey("HWy1jotHpo6UqeQxx49dpYYdQB8wj9Qk9MdxwjLvDHB8"), + authority: new web3.PublicKey("5Q544fKrFoe6tsEbD7S8EmxGTJYAKtTVhAW5Q5pge4j1"), + openOrders: new web3.PublicKey("6Su6Ea97dBxecd5W92KcVvv6SzCurE2BXGgFe9LNGMpE"), + targetOrders: new web3.PublicKey("5hATcCfvhVwAjNExvrg8rRkXmYyksHhVajWLa46iRsmE"), + baseVault: new web3.PublicKey("Em6rHi68trYgBFyJ5261A2nhwuQWfLcirgzZZYoRcrkX"), + quoteVault: new web3.PublicKey("3mEFzHsJyu2Cpjrz6zPmTzP7uoLFj9SbbecGVzzkL1mJ"), + withdrawQueue: new web3.PublicKey("11111111111111111111111111111111"), + lpVault: new web3.PublicKey("11111111111111111111111111111111"), + marketVersion:3, + marketProgramId: new web3.PublicKey("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX"), + marketId: new web3.PublicKey("BzcDHvKWD4LyW4X1NUEaWLBaNmyiCUKqcd3jXDRhwwAG"), + marketAuthority: new web3.PublicKey("7SdieGqwPJo5rMmSQM9JmntSEMoimM4dQn7NkGbNFcrd"), + marketBaseVault: new web3.PublicKey("6U6U59zmFWrPSzm9sLX7kVkaK78Kz7XJYkrhP1DjF3uF"), + marketQuoteVault: new web3.PublicKey("4YEx21yeUAZxUL9Fs7YU9Gm3u45GWoPFs8vcJiHga2eQ"), + marketBids: new web3.PublicKey("C1nEbACFaHMUiKAUsXVYPWZsuxunJeBkqXHPFr8QgSj9"), + marketAsks: new web3.PublicKey("4DNBdnTw6wmrK4NmdSTTxs1kEz47yjqLGuoqsMeHvkMF"), + marketEventQueue: new web3.PublicKey("4HGvdannxvmAhszVVig9auH6HsqVH17qoavDiNcnm9nj"), + lookupTableAccount: new web3.PublicKey("73mV3Cihr7vMUHeoS2KfQ12gaPur8Zf9BGxmuDtQaG6p"), + // createdAt:"2024-05-13T07:21:49.907Z", + // updatedAt:"2024-05-13T07:21:49.907Z", + // __v:0 + } + + /** * Prepare the swap transaction with the given parameters. diff --git a/src/swapConfig.ts b/src/swapConfig.ts index 9d89a1f..cdb5d57 100644 --- a/src/swapConfig.ts +++ b/src/swapConfig.ts @@ -1,11 +1,17 @@ export const swapConfig = { executeSwap: false, // Send tx when true, simulate tx when false useVersionedTransaction: true, - tokenAAmount: 0.01, // Swap 0.01 SOL for USDT in this example + tokenAAmount: 0.5, // Swap 0.01 SOL for USDT in this example tokenAAddress: "So11111111111111111111111111111111111111112", // Token to swap for the other, SOL in this case - tokenBAddress: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", // USDC address + // tokenBAddress: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", // USDC address + + tokenBAddress: "Duqm5K5U1H8KfsSqwyWwWNWY5TLB9WseqNEAQMhS78hb", // SALD address + maxLamports: 1500000, // Micro lamports for priority fee direction: "in" as "in" | "out", // Swap direction: 'in' or 'out' - liquidityFile: "https://api.raydium.io/v2/sdk/liquidity/mainnet.json", + // liquidityFile: "https://api.raydium.io/v2/sdk/liquidity/mainnet.json", + + liquidityFile: "https://simple-crud-app-backend.onrender.com/v2/sdk/liquidity/mint", + maxRetries: 20, };