Skip to content

Commit

Permalink
Added restClient.SpotApi.Account.GetRateLimitsAsync endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
JKorf committed Oct 21, 2024
1 parent aa4f6a2 commit 393094a
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 0 deletions.
19 changes: 19 additions & 0 deletions GateIo.Net.UnitTests/Endpoints/Spot/Account/GetRateLimits.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
GET
/api/v4/account/rate_limit
true
[
{
"type": "spot",
"tier": "1",
"ratio": "0",
"main_ratio": "0",
"updated_at": "1728230400"
},
{
"type": "futures",
"tier": "1",
"ratio": "0",
"main_ratio": "0",
"updated_at": "1728230400"
}
]
1 change: 1 addition & 0 deletions GateIo.Net.UnitTests/RestRequestTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public async Task ValidateSpotAccountCalls()
await tester.ValidateAsync(client => client.SpotApi.Account.GetGTDeductionStatusAsync(), "GetGTDeductionStatus");
await tester.ValidateAsync(client => client.SpotApi.Account.SetGTDeductionStatusAsync(true), "SetGTDeductionStatus");
await tester.ValidateAsync(client => client.SpotApi.Account.TransferToAccountAsync(123, "123", 0.1m), "TransferToAccount");
await tester.ValidateAsync(client => client.SpotApi.Account.GetRateLimitsAsync(), "GetRateLimits");
}

[Test]
Expand Down
14 changes: 14 additions & 0 deletions GateIo.Net/Clients/SpotApi/GateIoRestClientSpotApiAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -957,5 +957,19 @@ public async Task<WebCallResult> SetGTDeductionStatusAsync(bool enabled, Cancell
}

#endregion

#region Get Rate Limits

/// <inheritdoc />
public async Task<WebCallResult<IEnumerable<GateIoUserRateLimit>>> GetRateLimitsAsync(CancellationToken ct = default)
{
var parameters = new ParameterCollection();
var request = _definitions.GetOrCreate(HttpMethod.Get, "/api/v4/account/rate_limit", GateIoExchange.RateLimiter.RestSpotOther, 1, true);
var result = await _baseClient.SendAsync<IEnumerable<GateIoUserRateLimit>>(request, parameters, ct).ConfigureAwait(false);
return result;
}

#endregion

}
}
24 changes: 24 additions & 0 deletions GateIo.Net/Enums/RateLimitType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using CryptoExchange.Net.Attributes;
using System;
using System.Collections.Generic;
using System.Text;

namespace GateIo.Net.Enums
{
/// <summary>
/// Rate limit type
/// </summary>
public enum RateLimitType
{
/// <summary>
/// Spot
/// </summary>
[Map("spot")]
Spot,
/// <summary>
/// Futures
/// </summary>
[Map("futures")]
Futures
}
}
55 changes: 55 additions & 0 deletions GateIo.Net/GateIo.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 @@ -727,5 +727,12 @@ Task<WebCallResult<GateIoMarginMaxBorrowable>> GetMarginMaxBorrowableAsync(
/// <param name="ct">Cancellation token</param>
Task<WebCallResult<GateIoId>> TransferToAccountAsync(long receiveAccountId, string asset, decimal quantity, CancellationToken ct = default);

/// <summary>
/// Get rate limit ratios for the user
/// <para><a href="https://www.gate.io/docs/developers/apiv4/en/#get-user-transaction-rate-limit-information" /></para>
/// </summary>
/// <param name="ct">Cancellation token</param>
Task<WebCallResult<IEnumerable<GateIoUserRateLimit>>> GetRateLimitsAsync(CancellationToken ct = default);

}
}
42 changes: 42 additions & 0 deletions GateIo.Net/Objects/Models/GateIoUserRateLimit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using GateIo.Net.Enums;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json.Serialization;

namespace GateIo.Net.Objects.Models
{
/// <summary>
/// User rate limits
/// </summary>
public record GateIoUserRateLimit
{
/// <summary>
/// Type
/// </summary>
[JsonPropertyName("type")]
public RateLimitType RateLimitType { get; set; }
/// <summary>
/// Tier
/// </summary>
[JsonPropertyName("tier")]
public string Tier { get; set; } = string.Empty;
/// <summary>
/// Ratio
/// </summary>
[JsonPropertyName("ratio")]
public decimal Ratio { get; set; }
/// <summary>
/// Main ratio
/// </summary>
[JsonPropertyName("main_ratio")]
public decimal MainRatio { get; set; }
/// <summary>
/// Update time
/// </summary>
[JsonPropertyName("updated_at")]
public DateTime UpdatedAt { get; set; }
}


}

0 comments on commit 393094a

Please sign in to comment.