Skip to content

Commit

Permalink
feat: add solana
Browse files Browse the repository at this point in the history
  • Loading branch information
CumpsD committed Sep 24, 2024
1 parent 21bc9d3 commit 6d88fef
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 21 deletions.
1 change: 1 addition & 0 deletions swappy-bot.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Chainflip/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Chainflip_0027s/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Polkadot/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=solana/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Swappy/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=usdc/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
31 changes: 30 additions & 1 deletion swappy-bot/Commands/Assets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public enum AllAssets
[ChoiceDisplay("ethUSDT (USDT)")] usdt,
[ChoiceDisplay("arbEthereum (ETH)")] arbeth,
[ChoiceDisplay("arbUSDC (USDC)")] arbusdc,
[ChoiceDisplay("Solana (SOL)")] sol,
[ChoiceDisplay("solUSDC (USDC)")] solusdc,
}

public static readonly Dictionary<string, AssetInfo> SupportedAssets = new()
Expand All @@ -31,7 +33,7 @@ public enum AllAssets
8,
0.0007m,
[0.005m, 0.01m, 0.02m, 0.05m, 0.1m, 0.2m, 0.5m, 1.0m, 2.0m],
BitcoinAddressValidator.IsValidAddress)
AddressValidator.IsValidBitcoinAddress)
},

{
Expand Down Expand Up @@ -142,6 +144,33 @@ public enum AllAssets
AddressUtil.Current.IsValidEthereumAddressHexFormat(x) &&
(AddressUtil.Current.IsChecksumAddress(x) || x == x.ToLower() || x[2..] == x[2..].ToUpper()))
},


{
"sol",
new AssetInfo(
"sol",
"SOL",
"Solana",
"Solana",
9,
0.01m,
[0.2m, 0.4m, 1m, 2m, 5m, 10m, 20m, 50m, 100m, 200m],
AddressValidator.IsValidSolanaAddress)
},

{
"solusdc",
new AssetInfo(
"solusdc",
"USDC",
"solUSDC",
"Solana",
6,
20m,
[100m, 500m, 1000m, 2500m, 5000m, 10000m, 25000m, 40000m],
AddressValidator.IsValidSolanaAddress)
},
};
}
}
34 changes: 34 additions & 0 deletions swappy-bot/Infrastructure/AddressValidator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
namespace SwappyBot.Infrastructure
{
using NBitcoin;
using SimpleBase;

public static class AddressValidator
{
public static bool IsValidBitcoinAddress(string address)
{
try
{
Network.Main.Parse(address);

return true;
}
catch
{
return false;
}
}

public static bool IsValidSolanaAddress(string address)
{
try
{
return Base58.Bitcoin.Decode(address).Length == 32;
}
catch
{
return false;
}
}
}
}
20 changes: 0 additions & 20 deletions swappy-bot/Infrastructure/BitcoinAddressValidator.cs

This file was deleted.

0 comments on commit 6d88fef

Please sign in to comment.