Swap tokens

This commit is contained in:
2025-07-06 14:00:44 +07:00
parent 8096db495a
commit c7dec76809
21 changed files with 1124 additions and 173 deletions

View File

@@ -1,4 +1,5 @@
using Managing.Application.Abstractions.Services;
using Managing.Api.Models.Requests;
using Managing.Application.Abstractions.Services;
using Managing.Domain.Accounts;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -89,6 +90,30 @@ namespace Managing.Api.Controllers
return Ok(result);
}
/// <summary>
/// Swaps tokens on GMX for a specific account.
/// </summary>
/// <param name="name">The name of the account to perform the swap for.</param>
/// <param name="request">The swap request containing ticker symbols, amount, and order parameters.</param>
/// <returns>The swap response with transaction details.</returns>
[HttpPost]
[Route("{name}/gmx-swap")]
public async Task<ActionResult<SwapInfos>> SwapGmxTokens(string name, [FromBody] SwapTokensRequest request)
{
var user = await GetUser();
var result = await _AccountService.SwapGmxTokensAsync(
user,
name,
request.FromTicker,
request.ToTicker,
request.Amount,
request.OrderType,
request.TriggerRatio,
request.AllowedSlippage
);
return Ok(result);
}
/// <summary>
/// Deletes a specific account by name for the authenticated user.
/// </summary>