Skip to content

Commit

Permalink
fix: simplify quote number
Browse files Browse the repository at this point in the history
  • Loading branch information
CumpsD committed Feb 1, 2024
1 parent 83f8e06 commit 067d6bc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 84 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);
}
83 changes: 0 additions & 83 deletions swappy-bot/Commands/Swap/RoundTrip.cs

This file was deleted.

7 changes: 6 additions & 1 deletion swappy-bot/Commands/Swap/Swap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,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],
new string('0', 8),
x => AddressValidator.IsValidAddress(x, "btc"))
},

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

Expand All @@ -62,6 +64,7 @@ public class Swap : InteractionModuleBase<SocketInteractionContext>
0.01,
11,
[0.02, 0.04, 0.1, 0.2, 0.5, 1, 2, 5, 10],
new string('0', 18),
x => AddressUtil.Current.IsNotAnEmptyAddress(x) &&
AddressUtil.Current.IsValidAddressLength(x) &&
AddressUtil.Current.IsValidEthereumAddressHexFormat(x) &&
Expand All @@ -79,6 +82,7 @@ public class Swap : InteractionModuleBase<SocketInteractionContext>
4,
5_700,
[10, 20, 50, 150, 300, 1000, 2000, 4000, 5500],
new string('0', 18),
x => AddressUtil.Current.IsNotAnEmptyAddress(x) &&
AddressUtil.Current.IsValidAddressLength(x) &&
AddressUtil.Current.IsValidEthereumAddressHexFormat(x) &&
Expand All @@ -96,6 +100,7 @@ public class Swap : InteractionModuleBase<SocketInteractionContext>
20,
25_000,
[25, 50, 100, 500, 1000, 2500, 5000, 10000, 20000],
new string('0', 6),
x => AddressUtil.Current.IsNotAnEmptyAddress(x) &&
AddressUtil.Current.IsValidAddressLength(x) &&
AddressUtil.Current.IsValidEthereumAddressHexFormat(x) &&
Expand Down Expand Up @@ -947,7 +952,7 @@ private static MessageComponent BuildSelectedAssetSelect(
var ingressAmount = amount - commission;
var convertedAmount = ingressAmount * Math.Pow(10, assetFrom.Decimals);

var quoteRequest = $"quote?amount={convertedAmount.ToRoundTrip()}&srcAsset={assetFrom.Ticker}&destAsset={assetTo.Ticker}";
var quoteRequest = $"quote?amount={convertedAmount.ToString(assetFrom.FormatString)}&srcAsset={assetFrom.Ticker}&destAsset={assetTo.Ticker}";
var quoteResponse = await client.GetAsync(quoteRequest);

if (quoteResponse.IsSuccessStatusCode)
Expand Down

0 comments on commit 067d6bc

Please sign in to comment.