Fix position

This commit is contained in:
2025-04-25 01:16:48 +07:00
parent af89121c40
commit 6c385ea309
4 changed files with 18 additions and 16 deletions

File diff suppressed because one or more lines are too long

View File

@@ -182,9 +182,11 @@ public class EvmManager : IEvmManager
var web3 = new Web3(chain.RpcUrl);
var etherBalance = Web3.Convert.FromWei(await web3.Eth.GetBalance.SendRequestAsync(account));
var lastCandle = await GetCandle(Ticker.ETH);
return new EvmBalance()
{ Balance = etherBalance, Price = lastCandle.Close, TokenName = "ETH", Value = etherBalance * lastCandle.Close };
{
Balance = etherBalance, Price = lastCandle.Close, TokenName = "ETH", Value = etherBalance * lastCandle.Close
};
}
public async Task<List<EvmBalance>> GetAllBalances(Chain chain, string publicAddress)
@@ -401,10 +403,10 @@ public class EvmManager : IEvmManager
var lastCandles = await GetCandles(ticker, DateTime.UtcNow.AddMinutes(-5),
Timeframe.OneMinute);
cachedCandle = lastCandles.Last();
_cacheService.SaveValue(key, cachedCandle, TimeSpan.FromMinutes(5));
}
return cachedCandle;
}
@@ -499,7 +501,7 @@ public class EvmManager : IEvmManager
{
try
{
var response = await _web3ProxyService.CallGmxServiceAsync<dynamic>("/cancel-orders",
var response = await _web3ProxyService.CallGmxServiceAsync<Web3ProxyResponse>("/cancel-orders",
new
{
account = account.Key,
@@ -507,7 +509,7 @@ public class EvmManager : IEvmManager
ticker = ticker.ToString()
});
return response.success ?? false;
return response.Success;
}
catch (Exception ex)
{
@@ -727,11 +729,11 @@ public class EvmManager : IEvmManager
var result = await _web3ProxyService.GetGmxServiceAsync<GetGmxPositionsResponse>(
"/positions",
new { account = account.Key });
return GmxV2Mappers.Map(result.Positions);
}
throw new NotImplementedException();
}

View File

@@ -357,7 +357,7 @@ export class Orders extends Module {
skipSimulation: true,
indexToken: marketInfo.indexToken,
tokensData,
autoCancel: autoCancelOrdersLimit > 0,
autoCancel: autoCancelOrdersLimit > 0
});
}

View File

@@ -161,7 +161,7 @@ export const openGmxPositionImpl = async (
allowedSlippageBps: 100, // 1% slippage
leverage: leverageBps,
skipSimulation: true,
limitPrice: limitPrice,
limitPrice: null,
referralCodeForTxn: encodeReferralCode("kaigen_ai"),
stopLossPrice: stopLossPrice ? numberToBigint(stopLossPrice, 30) : undefined,
takeProfitPrice: takeProfitPrice ? numberToBigint(takeProfitPrice, 30) : undefined
@@ -440,7 +440,7 @@ export const closeGmxPositionImpl = async (
sizeDeltaInTokens: position.sizeInTokens,
collateralDeltaUsd: position.remainingCollateralAmount,
collateralDeltaAmount: position.remainingCollateralAmount,
acceptablePriceDeltaBps: 0n,
acceptablePriceDeltaBps: 30n,
recommendedAcceptablePriceDeltaBps: 0n,
estimatedPnl: 0n,
estimatedPnlPercentage: 0n,
@@ -464,7 +464,7 @@ export const closeGmxPositionImpl = async (
indexPrice: 0n,
collateralPrice: 0n,
acceptablePrice: position.markPrice,
triggerOrderType: OrderType.MarketDecrease,
triggerOrderType: OrderType.LimitDecrease,
triggerPrice: position.markPrice,
}
@@ -475,7 +475,7 @@ export const closeGmxPositionImpl = async (
marketsInfoData,
tokensData,
isLong: direction === TradeDirection.Short,
allowedSlippage: 0,
allowedSlippage: 30,
decreaseAmounts,
collateralToken: position.marketInfo.shortToken,
referralCodeForTxn: encodeReferralCode("kaigen_ai"),