Skip to content

Commit

Permalink
chore: fix profit taking
Browse files Browse the repository at this point in the history
  • Loading branch information
JayArrowz committed Sep 1, 2021
1 parent 5eba183 commit 7fba7ac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Handlers/TradeHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ private void MonitorPrices()
{
continue;
}
var pricePerLiquidityToken = ownedToken.TokenIdx == 1 ? new Fraction(price.Reserve1).Divide(price.Reserve0).ToDouble() : new Fraction(price.Reserve0).Divide(price.Reserve1).ToDouble();
var pricePerLiquidityToken = ownedToken.TokenIdx == 1 ? new Fraction(price.Reserve0).Divide(price.Reserve1).ToDouble() : new Fraction(price.Reserve1).Divide(price.Reserve0).ToDouble();
var profitPerc = ((100.0 / ownedToken.SinglePrice) * pricePerLiquidityToken) - 100.0;
Log.Logger.Information("Token: {0} Price bought: {1} Current Price: {2} Current Profit: {3}%",
ownedToken.Address, ownedToken.SinglePrice, pricePerLiquidityToken, profitPerc);
Expand Down
11 changes: 8 additions & 3 deletions SniperService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,15 @@ private async Task SubscribeEvent(string wssPath, IWeb3 web3, Action<EventLog<Pa

private void KeepAliveClient(StreamingWebSocketClient client)
{
while(!_disposed)
while (!_disposed)
{
var handler = new EthBlockNumberObservableHandler(client);
var disposable = handler.GetResponseAsObservable().Subscribe(x => Log.Logger.Information("Current block: {0}", x.Value));
handler.SendRequestAsync().Wait(TimeSpan.FromMinutes(5));
try
{
handler.SendRequestAsync().Wait(TimeSpan.FromMinutes(5));
}
catch (Exception _){ }
Thread.Sleep(30000);
}
}
Expand Down Expand Up @@ -127,7 +131,8 @@ private async Task PairCreated(EventLog<PairCreatedEvent> pairCreated)
try
{
sellSuccess = await _tradeHandler.Sell(otherPairAddress, ownedToken.Amount - 1, marketPrice, _sniperConfig.SellSlippage);
} catch(Exception e)
}
catch (Exception e)
{
Serilog.Log.Error("Error Sell", e);
}
Expand Down

0 comments on commit 7fba7ac

Please sign in to comment.