Skip to content

Commit

Permalink
feat: fix honeypot
Browse files Browse the repository at this point in the history
  • Loading branch information
JayArrowz committed Aug 31, 2021
1 parent e1d7dd2 commit ba10dae
Showing 1 changed file with 26 additions and 29 deletions.
55 changes: 26 additions & 29 deletions SniperService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,41 +124,38 @@ private async Task PairCreated(EventLog<PairCreatedEvent> pairCreated)
var honeypotCheck = _sniperConfig.HoneypotCheck;

Log.Logger.Information("Discovered Token Pair {0} Rug check Result: {1}", symbol, rugCheckPassed);
if (rugCheckPassed)
if (!rugCheckPassed)
{
Log.Logger.Information("Buying Token pair: {0}", symbol);

if (!honeypotCheck)
{
await _tradeHandler.Buy(otherPairAddress, otherTokenIdx, pair.Pair, _sniperConfig.AmountToSnipe);
}
else
{
Log.Logger.Information("Starting Honeypot check for {0} with amount {1}", symbol, _sniperConfig.HoneypotCheckAmount);
}
Log.Logger.Warning("Rug Check failed for {0}", symbol);
return;
}

if (honeypotCheck)
if (!honeypotCheck)
{
var buySuccess = await _tradeHandler.Buy(otherPairAddress, otherTokenIdx, pair.Pair, _sniperConfig.HoneypotCheckAmount);
if (!buySuccess)
{
Log.Logger.Fatal("Honeypot check failed could not buy token: {0}", pair.Symbol);
return;
}
var ownedToken = _tradeHandler.GetOwnedTokens(otherPairAddress);
var marketPrice = await _tradeHandler.GetMarketPrice(ownedToken);
var sellSuccess = await _tradeHandler.Sell(otherPairAddress, otherTokenIdx, ownedToken.Amount, marketPrice);
if (!sellSuccess)
{
Log.Logger.Fatal("Honeypot check DETECTED HONEYPOT could not sell token: {0}", pair.Symbol);
return;
}

Log.Logger.Fatal("Honeypot check PASSED buying token: {0}", pair.Symbol);
Log.Logger.Information("Buying Token pair: {0}", symbol);
await _tradeHandler.Buy(otherPairAddress, otherTokenIdx, pair.Pair, _sniperConfig.AmountToSnipe);
return;
}
Log.Logger.Information("Starting Honeypot check for {0} with amount {1}", symbol, _sniperConfig.HoneypotCheckAmount);
var buySuccess = await _tradeHandler.Buy(otherPairAddress, otherTokenIdx, pair.Pair, _sniperConfig.HoneypotCheckAmount);
if (!buySuccess)
{
Log.Logger.Fatal("Honeypot check failed could not buy token: {0}", pair.Symbol);
return;
}
} catch(Exception e)
var ownedToken = _tradeHandler.GetOwnedTokens(otherPairAddress);
var marketPrice = await _tradeHandler.GetMarketPrice(ownedToken);
var sellSuccess = await _tradeHandler.Sell(otherPairAddress, otherTokenIdx, ownedToken.Amount, marketPrice);
if (!sellSuccess)
{
Log.Logger.Fatal("Honeypot check DETECTED HONEYPOT could not sell token: {0}", pair.Symbol);
return;
}

Log.Logger.Fatal("Honeypot check PASSED buying token: {0}", pair.Symbol);
await _tradeHandler.Buy(otherPairAddress, otherTokenIdx, pair.Pair, _sniperConfig.AmountToSnipe);
}
catch (Exception e)
{
Log.Logger.Error(nameof(PairCreated), e);
}
Expand Down

0 comments on commit ba10dae

Please sign in to comment.