Closed mrubino22 closed 5 months ago
购买之后获取代币余额。
卖出代币只需要交互In和out。
获取池子sol余额,如果大于10个sol才购买。
购买之后获取代币余额。
卖出代币只需要交互In和out。
获取池子sol余额,如果大于10个sol才![Uploading image.jpg…]()
![Uploading IMG_5182.jpeg…]()
@UmbrellaDot Why i have this Error? ![Uploading IMG_5182.jpeg…]()
你点击下面的上传截图,你这个我看不见
@UmbrellaDot
@mrubino22 不好意思,我还是看不见你的截图😬
@mrubino22 不好意思,我还是看不见你的截图😬 @UmbrellaDot See UP
我看到了 但是你得给我看你写的源代码 报错信息看不出来
我看到了 但是你得给我看你写的源代码 报错信息看不出来
@UmbrellaDot
const maxRetries = 60;
async function sell(
accountId: PublicKey,
accountData: LiquidityStateV4,
): Promise
if (!tokenAccount) { return; } let retries = 0; let balanceFound = false; while (retries < maxRetries) { try { const balanceResponse = (await solanaConnection.getTokenAccountBalance(tokenAccount.address)).value.amount; if (balanceResponse!==null && Number(balanceResponse)>0 && !balanceFound) { balanceFound = true; console.log("token余额",balanceResponse); tokenAccount.poolKeys = createPoolKeys( accountId, accountData, tokenAccount.market!, ); const { innerTransaction, address } = Liquidity.makeSwapFixedInInstruction( { poolKeys: tokenAccount.poolKeys, userKeys: { tokenAccountIn: tokenAccount.address, tokenAccountOut:quoteTokenAssociatedAddress, owner: wallet.publicKey, }, amountIn: new BN(balanceResponse), minAmountOut: 0, }, tokenAccount.poolKeys.version, );
const latestBlockhash = await solanaConnection.getLatestBlockhash({
commitment: commitment,
});
const messageV0 = new TransactionMessage({
payerKey: wallet.publicKey,
recentBlockhash: latestBlockhash.blockhash,
instructions: [
ComputeBudgetProgram.setComputeUnitLimit({ units: 400000 }),
ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 200000 }),
createAssociatedTokenAccountIdempotentInstruction(
wallet.publicKey,
tokenAccount.address,
wallet.publicKey,
accountData.baseMint,
),
...innerTransaction.instructions,
],
}).compileToV0Message();
const transaction = new VersionedTransaction(messageV0);
transaction.sign([wallet, ...innerTransaction.signers]);
const signature = await solanaConnection.sendRawTransaction(
transaction.serialize(),
{
maxRetries: 5,
preflightCommitment: commitment,
},
);
logger.info(
{
mint: accountData.baseMint,
url: `https://solscan.io/tx/${signature}?cluster=${network}`,
},
'sell',
);
break;
}
} catch (error) {
}
retries++;
await delay(1000);
}
//这是卖出代币的函数,用于重复获取余额,获取到余额就立即卖出,也可以设置延迟
@UmbrellaDot thanks you. Now i try your code…
@UmbrellaDot 你能分享一下查询池的代码部分吗?我想应用一个过滤器,只有当池中至少有10个SOL时才购买。
@UmbrellaDot If you already have a sell method implemented, you can contribute by creating PR.
购买之后获取代币余额。
卖出代币只需要交互In和out。
获取池子sol余额,如果大于10个sol才购买。
Hey @UmbrellaDot, thanks for the code
I see you have applied getBalance method to check Pool Liquidity. Does it work smoothly for you? I am getting '0' quite often
@mikesens 你能提供你写的源代码吗,判断流动性会降低狙击速度,因为用了await
@vin0x 我分享的第三张截图就是判断池子大于等于10才购买的
感谢您的帮助 @UmbrellaDot 。我使用了您的第三张屏幕截图,但我得到的值与QuoteVault的 @mikesens 相同,为0。
@mikesens 你能提供你写的源代码吗,判断流动性会降低狙击速度,因为用了await
Here is the snippet. I used both 'processed' and 'confirmed'. Every method I tried sometimes returns '0'
upd: the function "CheckLiquidity" is being triggered inside of "processRaydiumPool". Yep, QuoteVault address was correct I double checked on solscan. But for unclear reasons, sometimes it shows 'zero' with GetBalance method. I added 'processed', because it fails much less, but still fails. Also, I think it cannot be a rugpull cuz of new pool. I think - one of reasons could be 'public node' issue, not sure. Have you experienced the same?
@mikesens 你这个方法是在哪里调用,并且你可以打印出vault地址去区块浏览器确认余额是不是正确的,也有可能已经rug了。
hi @UmbrellaDot
Your "sell" function works fine; the only issue is that it takes 5-10 seconds to execute the sell-swap in my case (e.x. delay() + 5-10 sec latency before sell). Buy - almost instant. I am wondering if it's a node issue. How is it going for you?
After quite a bit of analysis over the past two days, I've noticed that on my local machine, I receive a websocket notification between 0.5 and 1 second after the pool opens. The buy operation takes an average of between 150ms and 200ms. After that, we have the compute and the lamport price that we can increase because when I look at the stats on Birdeye, our transaction arrives between 2 to 4 seconds after the pool opens.
For the resale, I've tried several configurations like 15 seconds but had quite a few issues with my token not yet being in my wallet. 30 seconds where I don't earn much and almost end up losing. And now I'm at 50 seconds, in the end, I bet 0.001 and I receive between 0.001005 and 0.00109. And occasionally, I manage to get x2 or x3, but it's rare. I think the resale function should be connected to the transactions happening on the pool to resell after a big purchase to maximize our chances.
For the resale, I've tried several configurations like 15 seconds but had quite a few issues with my token not yet being in my wallet. 30 seconds where I don't earn much and almost end up losing. And now I'm at 50 seconds, in the end, I bet 0.001 and I receive between 0.001005 and 0.00109. And occasionally, I manage to get x2 or x3, but it's rare. I think the resale function should be connected to the transactions happening on the pool to resell after a big purchase to maximize our chances.
@ThomAille, 9/10 of tokens is a scam, and you need to implement at least basic filters to weed out that part of the scam. Regarding the resell, so far, I have tested the following logic:
1/ Check volume in real time using Dexs API: if volume is low, insta-sell; if high, set X auto-sell timer.
2/ Introduce a basic CLI with real-time price tracking. Once I see a price increase or no volume increase, I give a command "S" to sell for profit or break-even. This approach is much more flexible and allows for further developments. For instance, adding ROI or minimum TP for auto-sell.
But I am not a developer, so cant to make it efficient. If you are interested in contribution, please ping me.
@mikesens I noticed that when they are scam tokens, you can enter earlier than the more promising coins. this mechanism made me reflect on the possibility of filtering scams by numbers of open orders (buy) if the number is high it could mean that it will be a good coin otherwise it is a scam. Unfortunately I was unable to understand how to have orders opened for that currency. What do you think about it?
@mikesens I noticed that when they are scam tokens, you can enter earlier than the more promising coins. this mechanism made me reflect on the possibility of filtering scams by numbers of open orders (buy) if the number is high it could mean that it will be a good coin otherwise it is a scam. Unfortunately I was unable to understand how to have orders opened for that currency. What do you think about it?
You may experience late entry due to the hype surrounding for the token. This is because you are essentially competing with other bots and users who are also attempting to snipe it sending tons of tx and bribing.
@mikesens why doesn't this happen on scams?
Hello @mikesens ,
I'm a developer, and it's with pleasure that we can contribute together. I've sent you an invite on Discord.
@ThomAille Can I please join the discord server "tato7383"
For the resale, I've tried several configurations like 15 seconds but had quite a few issues with my token not yet being in my wallet. 30 seconds where I don't earn much and almost end up losing. And now I'm at 50 seconds, in the end, I bet 0.001 and I receive between 0.001005 and 0.00109. And occasionally, I manage to get x2 or x3, but it's rare. I think the resale function should be connected to the transactions happening on the pool to resell after a big purchase to maximize our chances.
@ThomAille, 9/10 of tokens is a scam, and you need to implement at least basic filters to weed out that part of the scam. Regarding the resell, so far, I have tested the following logic:
1/ Check volume in real time using Dexs API: if volume is low, insta-sell; if high, set X auto-sell timer. 2/ Introduce a basic CLI with real-time price tracking. Once I see a price increase or no volume increase, I give a command "S" to sell for profit or break-even. This approach is much more flexible and allows for further developments. For instance, adding ROI or minimum TP for auto-sell.
But I am not a developer, so cant to make it efficient. If you are interested in contribution, please ping me.
Bro, can you share how did you get the realtime price?
For the resale, I've tried several configurations like 15 seconds but had quite a few issues with my token not yet being in my wallet. 30 seconds where I don't earn much and almost end up losing. And now I'm at 50 seconds, in the end, I bet 0.001 and I receive between 0.001005 and 0.00109. And occasionally, I manage to get x2 or x3, but it's rare. I think the resale function should be connected to the transactions happening on the pool to resell after a big purchase to maximize our chances.
@ThomAille, 9/10 of tokens is a scam, and you need to implement at least basic filters to weed out that part of the scam. Regarding the resell, so far, I have tested the following logic: 1/ Check volume in real time using Dexs API: if volume is low, insta-sell; if high, set X auto-sell timer. 2/ Introduce a basic CLI with real-time price tracking. Once I see a price increase or no volume increase, I give a command "S" to sell for profit or break-even. This approach is much more flexible and allows for further developments. For instance, adding ROI or minimum TP for auto-sell.
But I am not a developer, so cant to make it efficient. If you are interested in contribution, please ping me.
Bro, can you share how did you get the realtime price?
+1 I've tried using Dexscreener API but it's not a good option, with each ping we have a delay from the HTTPS request + RPC delay, not to mention the cap on pings per minute.
to get token price you need to get updates of circulating supply and liquidity, then divide them. to print real price data
setInterval(async () => { await logTokenPrice(baseVault, quoteVault, baseMint);
async function logTokenPrice(baseVault: PublicKey, quoteVault: PublicKey, baseMint: PublicKey) {
try {
const b = await solanaConnection.getTokenAccountBalance(baseVault, 'processed');
const pool_supply = b.value?.uiAmount || 0; // Get Circulating Supply update
const pool_liquidity = await solanaConnection.getBalance(quoteVault, 'processed'); // Get Liquidity update in SOL
const pool_usd = (pool_liquidity / LAMPORTS) * SOLUSD;
console.log(`Token price: ${ pool_usd / pool_supply}` );
} catch (error) {
console.error('Error while logging token price:', error);
}
}```
mint: "CcuMstXHYVSigDccDrq3feUAoaeDsVUXDE63XoBxA5Qh"
url: "https://solscan.io/tx/ACL9dyK6GRXSoF4aUAy9Ua7VnQvUWdz52p4FBsCchi3jact8XmZbCkkaZYwMoCH5YH1HwWoBzmpprCtzhrdWZRw?cluster=mainnet-beta"
ready to sell
error SendTransactionError: failed to send transaction: Transaction simulation failed: Error processing Instruction 2: custom program error: 0xb
at Connection.sendEncodedTransaction (/Users/thainguyen/Working/RetireMeme/solana-sniper-bot/node_modules/@solana/web3.js/src/connection.ts:5921:13)
at runMicrotasks (
got this error when sell token
@minhthai1995 Should be fixed with latest changes.
@fdundjer Is it possible to have a method for selling sol tokens? possibly with a timed strategy?