Skip to content

Commit

Permalink
Updte
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelSyntronic committed Mar 17, 2024
1 parent 3cf08fe commit f8b42bb
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion client/StateAggregator/ConsoleOutput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,9 @@ export async function onBuyResults(poolId: string, buyResults: BuyResult) {

export async function onTradingPNLChanged(poolId: string, newPNL: number) {
if (!dbIsInited) {
const date = new Date()
const isNegative = newPNL < 0
const logTxt = `PNL: ${(newPNL * 100).toFixed(2)}%`
const logTxt = `[${formatDate(date)}]: PNL - ${(newPNL * 100).toFixed(2)}%`
console.log(isNegative ? chalk.red(logTxt) : chalk.green(logTxt))
return
}
Expand Down
5 changes: 3 additions & 2 deletions client/Swap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ async function loopAndWaitForProfit(
const { currentAmountOut, profit } = calculationResult;
const profitChanges = Math.abs(profit - profitToTakeOrLose)
if (profitChanges >= 0.01) {
onTradingPNLChanged(poolKeys.id.toString(), profit - profitToTakeOrLose)
onTradingPNLChanged(poolKeys.id.toString(), profit)
}
profitToTakeOrLose = profit;
profitObject.profit = profit
Expand Down Expand Up @@ -241,7 +241,8 @@ export async function waitForProfitOrTimeout(
timeout(timeutInMillis, cancellationToken)
])
} catch (e) {
console.error(`Timeout happened ${chalk.bold('Profit to take: ')} ${profitObject.profit < 0 ? chalk.red(profitObject.profit) : chalk.green(profitObject.profit)}`);
const profitInPercent = (profitObject.profit * 100).toFixed(2) + '%'
console.error(`Timeout happened ${chalk.bold('Profit to take: ')} ${profitObject.profit < 0 ? chalk.red(profitInPercent) : chalk.green(profitInPercent)}`);
}
return { amountOut: profitObject.amountOut, profit: profitObject.profit }
}
Expand Down
4 changes: 2 additions & 2 deletions client/Trader/ExitStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const RED_TEST_EXIT_STRATEGY: ExitStrategy = {
}

export const TURBO_EXIT_STRATEGY: ExitStrategy = {
exitTimeoutInMillis: 30 * 1000, // 30 seconds for turbo
targetProfit: 91, // aim to 100% with 9% slippage
exitTimeoutInMillis: 2 * 60 * 1000, // 2 minutes for turbo
targetProfit: 89, // aim to 100% with 11% slippage
profitCalcIterationDelayMillis: 50 // 0.05 seconds
}
1 change: 1 addition & 0 deletions client/Trader/Trader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { SellResults, sellToken } from './SellToken'
import { Connection } from '@solana/web3.js'
import { onBuyResults } from '../StateAggregator/ConsoleOutput'
import { config } from '../Config'
import chalk from 'chalk'

export type TraderResults = {
boughtAmountInSOL: number | null,
Expand Down
6 changes: 6 additions & 0 deletions client/TurboBot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ export class TurboBot {

const tradeResults = await tryPerformTrading(this.connection, check.data.pool, 'TURBO')
console.log(chalk.yellow('Got trading results'))
console.log(`BUY at ${tradeResults.buyTime ?? 'null'}`)
if (tradeResults.kind === 'SUCCESS') {
console.log(`SELL at ${tradeResults.sellTime}`)
} else {
console.log(`Couldn't sell`)
}
this.updateWSOLBalance(tradeResults)
if (singleTrade) {
this.connection.removeOnLogsListener(this.onLogsSubscriptionId ?? 0)
Expand Down

0 comments on commit f8b42bb

Please sign in to comment.