Skip to content

Commit

Permalink
feat: tweak announcing final swap
Browse files Browse the repository at this point in the history
  • Loading branch information
CumpsD committed Feb 1, 2024
1 parent d743808 commit d571507
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions swappy-bot/Commands/Swap/AssetInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ public record AssetInfo(
double MinimumAmount,
double MaximumAmount,
double[] SuggestedAmounts,
string FormatString,
Func<string, bool> AddressValidator);
}
11 changes: 9 additions & 2 deletions swappy-bot/Commands/Swap/Swap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class Swap : InteractionModuleBase<SocketInteractionContext>
0.0007,
0.65,
[0.001, 0.002, 0.005, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5],
$"0.00{new string('#', 6)}",
x => AddressValidator.IsValidAddress(x, "btc"))
},

Expand All @@ -47,6 +48,7 @@ public class Swap : InteractionModuleBase<SocketInteractionContext>
4,
4_100,
[10, 20, 50, 150, 300, 700, 1000, 2000, 4000],
$"0.00{new string('#', 8)}",
x => true)
},

Expand All @@ -61,6 +63,7 @@ public class Swap : InteractionModuleBase<SocketInteractionContext>
0.01,
11,
[0.02, 0.04, 0.1, 0.2, 0.5, 1, 2, 5, 10],
$"0.00{new string('#', 16)}",
x => AddressUtil.Current.IsNotAnEmptyAddress(x) &&
AddressUtil.Current.IsValidAddressLength(x) &&
AddressUtil.Current.IsValidEthereumAddressHexFormat(x) &&
Expand All @@ -78,6 +81,7 @@ public class Swap : InteractionModuleBase<SocketInteractionContext>
4,
5_700,
[10, 20, 50, 150, 300, 1000, 2000, 4000, 5500],
$"0.00{new string('#', 16)}",
x => AddressUtil.Current.IsNotAnEmptyAddress(x) &&
AddressUtil.Current.IsValidAddressLength(x) &&
AddressUtil.Current.IsValidEthereumAddressHexFormat(x) &&
Expand All @@ -95,6 +99,7 @@ public class Swap : InteractionModuleBase<SocketInteractionContext>
20,
25_000,
[25, 50, 100, 500, 1000, 2500, 5000, 10000, 20000],
$"0.00{new string('#', 4)}",
x => AddressUtil.Current.IsNotAnEmptyAddress(x) &&
AddressUtil.Current.IsValidAddressLength(x) &&
AddressUtil.Current.IsValidEthereumAddressHexFormat(x) &&
Expand Down Expand Up @@ -726,6 +731,7 @@ await threadChannel.ModifyAsync(x =>

await NotifySwap(
swapState.Amount.Value,
swapState.QuoteReceive.Value,
assetFrom,
assetTo);

Expand All @@ -741,15 +747,16 @@ await NotifySwap(
}

private async Task NotifySwap(
double amount,
double amountFrom,
double amountTo,
AssetInfo assetFrom,
AssetInfo assetTo)
{
var notificationChannel =
(ITextChannel)Context.Client.GetChannel(_configuration.NotificationChannelId.Value);

await notificationChannel.SendMessageAsync(
$"I have just started a swap from **{amount} {assetFrom.Name} ({assetFrom.Ticker})** to **{assetTo.Name} ({assetTo.Ticker})**! 🎉 \n" +
$"I have just started a swap from **{amountFrom.ToString(assetFrom.FormatString)} {assetFrom.Name} ({assetFrom.Ticker})** to **{amountTo.ToString(assetTo.FormatString)} {assetTo.Name} ({assetTo.Ticker})**! 🎉 \n" +
$"Use `/swap` to use my services as well. 😎");
}

Expand Down

0 comments on commit d571507

Please sign in to comment.