Skip to content

Commit

Permalink
Added SetMultipleCollateralAssetsAsync
Browse files Browse the repository at this point in the history
  • Loading branch information
JKorf committed Jan 19, 2024
1 parent ce0a60d commit 74f628a
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ByBit.Net/Clients/V5/BybitRestClientApiAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,23 @@ public async Task<WebCallResult> SetCollateralAssetAsync(

#endregion

#region Set Multiple Collateral Assets

/// <inheritdoc />
public async Task<WebCallResult> SetMultipleCollateralAssetsAsync(
IEnumerable<BybitSetCollateralAssetRequest> assets,
CancellationToken ct = default)
{
var parameters = new Dictionary<string, object>()
{
{ "request", assets }
};

return await _baseClient.SendRequestAsync(_baseClient.GetUrl("v5/account/set-collateral-switch-batch"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false);
}

#endregion

#region Switch Cross Isolated Margin

/// <inheritdoc />
Expand Down
11 changes: 11 additions & 0 deletions ByBit.Net/Interfaces/Clients/V5/IBybitRestClientApiAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,17 @@ Task<WebCallResult> SetCollateralAssetAsync(
bool useForCollateral,
CancellationToken ct = default);

/// <summary>
/// Set whether assets should be used for collateral
/// <para><a href="https://bybit-exchange.github.io/docs/v5/account/batch-set-collateral" /></para>
/// </summary>
/// <param name="assets">The assets configuration</param>
/// <param name="ct">Cancellation token</param>
/// <returns></returns>
Task<WebCallResult> SetMultipleCollateralAssetsAsync(
IEnumerable<BybitSetCollateralAssetRequest> assets,
CancellationToken ct = default);

/// <summary>
/// Set the margin mode
/// <para><a href="https://bybit-exchange.github.io/docs/v5/account/set-margin-mode" /></para>
Expand Down
25 changes: 25 additions & 0 deletions ByBit.Net/Objects/Models/V5/BybitSetCollateralAssetRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Newtonsoft.Json;

namespace Bybit.Net.Objects.Models.V5
{
/// <summary>
/// Request info
/// </summary>
public class BybitSetCollateralAssetRequest
{
/// <summary>
/// The asset
/// </summary>
[JsonProperty("coin")]
public string Asset { get; set; } = string.Empty;

[JsonProperty("collateralSwitch")]
private string _useForCollateral => UseForCollateral ? "ON" : "OFF";

/// <summary>
/// Use this asset for collateral
/// </summary>
[JsonIgnore]
public bool UseForCollateral { get; set; }
}
}

0 comments on commit 74f628a

Please sign in to comment.