Skip to content

Commit

Permalink
Added SetCollateralAssetAsync
Browse files Browse the repository at this point in the history
  • Loading branch information
JKorf committed Jan 16, 2024
1 parent 7bd32c2 commit c0486ed
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
19 changes: 19 additions & 0 deletions ByBit.Net/Clients/V5/BybitRestClientApiAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,25 @@ public async Task<WebCallResult> SetLeverageAsync(

#endregion

#region Set Collateral Asset

/// <inheritdoc />
public async Task<WebCallResult> SetCollateralAssetAsync(
string asset,
bool useForCollateral,
CancellationToken ct = default)
{
var parameters = new Dictionary<string, object>()
{
{ "coin", asset },
{ "collateralSwitch", useForCollateral ? "ON" : "OFF" },
};

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

#endregion

#region Switch Cross Isolated Margin

/// <inheritdoc />
Expand Down
13 changes: 13 additions & 0 deletions ByBit.Net/Interfaces/Clients/V5/IBybitRestClientApiAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,19 @@ Task<WebCallResult<BybitApiKeyInfo>> EditApiKeyAsync(
/// <returns></returns>
Task<WebCallResult> SetLeverageAsync(Category category, string symbol, decimal buyLeverage, decimal sellLeverage, CancellationToken ct = default);

/// <summary>
/// Set whether an asset should be used for collateral
/// <para><a href="https://bybit-exchange.github.io/docs/v5/account/set-collateral" /></para>
/// </summary>
/// <param name="asset">The asset. USDT and USDC can't be switched off</param>
/// <param name="useForCollateral">Use the asset for collateral</param>
/// <param name="ct">Cancellation token</param>
/// <returns></returns>
Task<WebCallResult> SetCollateralAssetAsync(
string asset,
bool useForCollateral,
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

0 comments on commit c0486ed

Please sign in to comment.