Skip to content

Commit

Permalink
feat: add amount emojis
Browse files Browse the repository at this point in the history
  • Loading branch information
CumpsD committed Jan 30, 2024
1 parent 9c9dbce commit 00a9eff
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions chainflip-insights/Bot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ private async Task<double> GetLastSwapId(CancellationToken cancellationToken)
return double.Parse(await File.ReadAllTextAsync(_configuration.LastSwapIdLocation, cancellationToken));

await using var file = File.CreateText(_configuration.LastSwapIdLocation);
await file.WriteAsync("375");
return 375;
await file.WriteAsync("381");
return 381;
}

private async Task StoreLastSwapId(double swapId)
Expand Down Expand Up @@ -213,7 +213,7 @@ private async Task AnnounceSwap(
var infoChannel = (ITextChannel)_client.GetChannel(_configuration.SwapInfoChannelId.Value);

await infoChannel.SendMessageAsync(
$"💵 Swapped " +
$"{GetEmoji(swap.DepositValueUsd)} Swapped " +
$"**{Math.Round(swapInput, 8).ToString(inputString)} {swap.SourceAsset}** (*${swap.DepositValueUsd.ToString(dollarString)}*) → " +
$"**{Math.Round(swapOutput, 8).ToString(outputString)} {swap.DestinationAsset}** (*${swap.EgressValueUsd.ToString(dollarString)}*) in " +
$"**{HumanTime(swapTime)}** " +
Expand All @@ -231,6 +231,16 @@ await infoChannel.SendMessageAsync(
$"{_configuration.ExplorerUrl}{swap.Id}");
}

private static string GetEmoji(double amount) =>
amount switch
{
> 10000 => WHALE,
> 5000 => SUB10K,
> 2500 => SUB5K,
> 1000 => SUB2_5K,
_ => SUB1K
};

private static string HumanTime(TimeSpan span)
{
var time = new StringBuilder();
Expand Down

0 comments on commit 00a9eff

Please sign in to comment.