Add manual close for bot positions
This commit is contained in:
@@ -29,8 +29,6 @@ using BalanceOfFunction = Nethereum.Contracts.Standards.ERC20.ContractDefinition
|
||||
using BalanceOfOutputDTO = Nethereum.Contracts.Standards.ERC20.ContractDefinition.BalanceOfOutputDTO;
|
||||
using Chain = Managing.Domain.Evm.Chain;
|
||||
using TransferEventDTO = Nethereum.Contracts.Standards.ERC721.ContractDefinition.TransferEventDTO;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Managing.Infrastructure.Evm;
|
||||
|
||||
@@ -750,11 +748,25 @@ public class EvmManager : IEvmManager
|
||||
return await _web3ProxyService.CallGmxServiceAsync<List<FundingRate>>("/gmx/funding-rates", new { });
|
||||
}
|
||||
|
||||
public async Task<decimal> QuantityInPosition(string chainName, string publicAddress, Ticker ticker)
|
||||
public async Task<decimal> QuantityInPosition(string chainName, Account account, Ticker ticker)
|
||||
{
|
||||
if (account.IsPrivyWallet)
|
||||
{
|
||||
var positions = await GetPositions(account);
|
||||
var positionForTicker = positions.FirstOrDefault(p => p.Ticker == ticker);
|
||||
if (positionForTicker != null)
|
||||
{
|
||||
return positionForTicker.Open.Quantity;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
var chain = ChainService.GetChain(chainName);
|
||||
var web3 = new Web3(chain.RpcUrl);
|
||||
var quantity = await _gmxV2Service.QuantityInPosition(web3, publicAddress, ticker);
|
||||
var quantity = await _gmxV2Service.QuantityInPosition(web3, account.Key, ticker);
|
||||
return quantity;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user