https://docs.shyft.to/ You acting like a Professional developer typescript on trading bot rayduim. You have access to all documentation Rayduim for building snipper bot . Your goal is to create the entire process skeleton logic implemented for final production script.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Ask user to input ticker like ELONSPLtokenThescriptcheckWhennewELON LP SPL token on rayduim is create inside list the first second he appears with less the 1second old created, immediately buy 0.001SOL one time quickly.(Do not use others old ticker only latest created. It's required to wait until the ticker appears and immediately buy)
Wait 2 min and Sell 100% all SPL Token acquired before.
Restart Loop to ask
Logic swap , logic quantity token , logic monitoring.Et pour un environnement de production réel, rédiger les structures nécessaires pour l'implémentation de la logique de tout les composants nécessaires, en mémoire. Maintenant remettre de l'ordre dans tes idées. Suis mon objectif final. Utilisation de toutes ta connaissance et de tout les token en ta possession . Sois calme, respiration profonde, tu es prêt pour l'écriture final de la version production en utilisant toutes les informations depuis le début.
please, elaborate complete Implementation and expand the utility functions referenced in all above. This a récapitulatif : You acting like a Professional developer typescript on trading bot rayduim. You have access to all documentation Rayduim Shyft for building snipper bot . Your goal is to create the entire process skeleton logic implemented for final production script. For example what the script do : Ask user to input ticker like ELONSPLtoken.ThescriptcheckWhennewELON LP SPL token on rayduim is create inside list the first second he appears New Pool Liquidity List with less the 1second old created, immediately buy 0.001SOL one time quickly.(Do not use others old ticker only latest created. It's required to wait until the ticker appears and immediately buy)
Wait 2 min and Sell 100% all SPL Token acquired before.
Restart Loop to ask
Logic swap , logic quantity token , logic monitoring.Et pour un environnement de production réel, rédiger les structures nécessaires pour l'implémentation de la logique de tout les composants nécessaires, en mémoire. Maintenant remettre de l'ordre dans tes idées. Suis mon objectif final. Utilisation de toutes ta connaissance et de tout les token en ta possession . Sois calme, respiration profonde, tu es prêt pour l'écriture final de la version production en utilisant toutes les informations depuis le début.
Assistant
To develop a production-ready TypeScript trading bot for Raydium that monitors the creation of new liquidity pools for a specified SPL token and executes buy and sell orders accordingly, follow the structured approach below.
1. Project Setup
Initialize the Project: Create a new TypeScript project and set up the necessary dependencies.
Implement a function to monitor the creation of new liquidity pools for the specified SPL token.
typescript
async function monitorLiquidityPools(tokenMint: PublicKey): Promise<publickey null="" |=""> {
const pools = await raydium.api.getPoolList({});
const newPool = pools.find(pool => pool.baseMint.equals(tokenMint) || pool.quoteMint.equals(tokenMint));
if (newPool) {
const poolCreationTime = new Date(newPool.creationTime * 1000);
const currentTime = new Date();
const timeDifference = (currentTime.getTime() - poolCreationTime.getTime()) / 1000;
if (timeDifference < 1) {
return new PublicKey(newPool.id);
}
}
return null;
}
6. Execute Swap Transactions
Implement functions to perform buy and sell transactions.
Buy Token:
typescript
async function buyToken(poolId: PublicKey, amountInSol: number): Promise<void> {
// Implement the logic to create and send a transaction to buy the token
// This involves constructing the swap instruction and sending the transaction
}
Sell Token:
typescript
async function sellToken(poolId: PublicKey, tokenMint: PublicKey): Promise<void> {
// Implement the logic to create and send a transaction to sell the token
// This involves constructing the swap instruction and sending the transaction
}
7. Main Execution Loop
Implement the main loop to continuously monitor for new pools and execute trades.
typescript
async function main() {
const tokenSymbol = prompt('Enter the token symbol (e.g., $ELON): ');
const tokenInfo = raydium.token.tokenList.find(token => token.symbol === tokenSymbol);
if (!tokenInfo) {
console.log('Token not found.');
return;
}
const tokenMint = new PublicKey(tokenInfo.mint);
while (true) {
const poolId = await monitorLiquidityPools(tokenMint);
if (poolId) {
await buyToken(poolId, 0.001);
await sleep(120000); // Wait for 2 minutes
await sellToken(poolId, tokenMint);
}
await sleep(1000); // Check every second
}
}
8. Utility Functions
Implement utility functions such as sleep for delays.
typescript
export function sleep(ms: number): Promise<void> {
return new Promise(resolve => setTimeout(resolve, ms));
}
9. Error Handling and Logging
Ensure to include error handling and logging throughout the code to handle exceptions and monitor the bot's activity.
10. Security Considerations
Private Key Management: Ensure the wallet's private key is stored securely and not hardcoded in the source code.
Rate Limiting: Implement rate limiting to avoid being rate-limited by the Solana RPC or Raydium API.
Testing: Thoroughly test the bot in a controlled environment before deploying it to production.
11. Deployment
Once tested, deploy the bot on a secure server with a stable internet connection to ensure continuous operation.
Note: This implementation provides a skeleton for the trading bot. The functions buyToken and sellToken need to be implemented with the appropriate logic to create and send transactions on the Solana blockchain using Raydium's SDK. Additionally, ensure compliance with all relevant regulations and best practices when deploying trading bots.