Skip to content

Commit

Permalink
CryptoExchange.Net v8.0.0, shared interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
JKorf authored Sep 27, 2024
1 parent 5efe6e2 commit 939ebcf
Show file tree
Hide file tree
Showing 20 changed files with 1,327 additions and 23 deletions.
23 changes: 23 additions & 0 deletions Bitfinex.Net.UnitTests/Endpoints/Spot/Account/WithdrawV2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
POST
/v2/auth/w/withdraw
true
[
1568742390999, //MTS
"acc_wd-req", //TYPE
null, //MESSAGE_ID
null, //PLACEHOLDER
[
13080092, //WITHDRAWAL_ID
null, //PLACEHOLDER
"ethereum", //METHOD
null, //PAYMENT_ID
"exchange", //WALLET
0.01, //AMOUNT
null, //PLACEHOLDER
null, //PLACEHOLDER
0.00135 //WITHDRAWAL_FEE
], //WITHDRAWAL_ARRAY
null, //CODE
"SUCCESS", //STATUS
"Your withdrawal request has been successfully submitted." //TEXT
]
1 change: 1 addition & 0 deletions Bitfinex.Net.UnitTests/RestRequestTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public async Task ValidateSpotAccountCalls()
await tester.ValidateAsync(client => client.SpotApi.Account.GetDepositAddressAsync("123", Enums.WithdrawWallet.Exchange), "GetDepositAddress");
await tester.ValidateAsync(client => client.SpotApi.Account.WalletTransferAsync("ETH", 1, Enums.WithdrawWallet.Exchange, Enums.WithdrawWallet.Exchange), "WalletTransfer");
await tester.ValidateAsync(client => client.SpotApi.Account.WithdrawAsync("ETH", Enums.WithdrawWallet.Exchange, 1), "Withdraw", useSingleArrayItem: true, ignoreProperties: new System.Collections.Generic.List<string> { "status" });
await tester.ValidateAsync(client => client.SpotApi.Account.WithdrawV2Async("BITCOIN", Enums.WithdrawWallet.Exchange, 1, "123"), "WithdrawV2");
await tester.ValidateAsync(client => client.SpotApi.Account.GetLoginHistoryAsync(), "GetLoginHistory");
await tester.ValidateAsync(client => client.SpotApi.Account.GetApiKeyPermissionsAsync(), "GetApiKeyPermissions");
await tester.ValidateAsync(client => client.SpotApi.Account.GetAccountChangeLogAsync(), "GetAccountChangeLog");
Expand Down
1 change: 1 addition & 0 deletions Bitfinex.Net.UnitTests/TestImplementations/TestSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class TestSocket: IWebsocket
public event Func<Task> OnReconnected;
public event Func<Task> OnReconnecting;
public event Func<int, Task> OnRequestRateLimited;
public event Func<Task> OnConnectRateLimited;
#pragma warning restore 0067
public event Func<int, Task> OnRequestSent;
public event Func<WebSocketMessageType, ReadOnlyMemory<byte>, Task> OnStreamMessage;
Expand Down
4 changes: 2 additions & 2 deletions Bitfinex.Net/Bitfinex.Net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>
<ItemGroup Label="Deterministic Build" Condition="'$(Configuration)' == 'Release'">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -55,6 +55,6 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="CryptoExchange.Net" Version="7.11.0" />
<PackageReference Include="CryptoExchange.Net" Version="8.0.0" />
</ItemGroup>
</Project>
120 changes: 114 additions & 6 deletions Bitfinex.Net/Bitfinex.Net.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using CryptoExchange.Net.Converters.MessageParsing;
using CryptoExchange.Net.Interfaces;
using CryptoExchange.Net.Objects;
using CryptoExchange.Net.SharedApis;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq;
using System;
Expand Down Expand Up @@ -62,7 +63,7 @@ internal Uri GetUrl(string endpoint, string version)
}

/// <inheritdoc />
public override string FormatSymbol(string baseAsset, string quoteAsset) => $"t{baseAsset.ToUpperInvariant()}{quoteAsset.ToUpperInvariant()}";
public override string FormatSymbol(string baseAsset, string quoteAsset, TradingMode tradingMode, DateTime? deliverTime = null) => $"t{baseAsset.ToUpperInvariant()}{quoteAsset.ToUpperInvariant()}";

/// <inheritdoc />
protected override Error ParseErrorResponse(int httpStatusCode, IEnumerable<KeyValuePair<string, IEnumerable<string>>> responseHeaders, IMessageAccessor accessor)
Expand Down
15 changes: 13 additions & 2 deletions Bitfinex.Net/Clients/SpotApi/BitfinexRestClientSpotApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using CryptoExchange.Net.Interfaces;
using CryptoExchange.Net.Interfaces.CommonClients;
using CryptoExchange.Net.Objects;
using CryptoExchange.Net.SharedApis;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq;
using System;
Expand All @@ -23,7 +24,7 @@
namespace Bitfinex.Net.Clients.SpotApi
{
/// <inheritdoc cref="IBitfinexRestClientSpotApi" />
internal class BitfinexRestClientSpotApi : RestApiClient, IBitfinexRestClientSpotApi, ISpotClient
internal partial class BitfinexRestClientSpotApi : RestApiClient, IBitfinexRestClientSpotApi, ISpotClient
{
#region fields
internal string? AffiliateCode { get; set; }
Expand Down Expand Up @@ -72,7 +73,16 @@ protected override AuthenticationProvider CreateAuthenticationProvider(ApiCreden
=> new BitfinexAuthenticationProvider(credentials, ClientOptions.NonceProvider ?? new BitfinexNonceProvider());

/// <inheritdoc />
public override string FormatSymbol(string baseAsset, string quoteAsset) => $"t{baseAsset.ToUpperInvariant()}{quoteAsset.ToUpperInvariant()}";
public override string FormatSymbol(string baseAsset, string quoteAsset, TradingMode tradingMode, DateTime? deliverTime = null)
{
if (baseAsset == "USDT")
baseAsset = "UST";

if (quoteAsset == "USDT")
quoteAsset = "UST";

return $"t{baseAsset.ToUpperInvariant()}{quoteAsset.ToUpperInvariant()}";
}

#region common interface

Expand Down Expand Up @@ -150,6 +160,7 @@ internal Uri GetUrl(string endpoint, string version)

/// <inheritdoc />
public ISpotClient CommonSpotClient => this;
public IBitfinexRestClientSpotApiShared SharedClient => this;

async Task<WebCallResult<OrderId>> ISpotClient.PlaceOrderAsync(string symbol, CommonOrderSide side, CommonOrderType type, decimal quantity, decimal? price, string? accountId, string? clientOrderId, CancellationToken ct)
{
Expand Down
Loading

0 comments on commit 939ebcf

Please sign in to comment.