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

@@ -184,7 +184,9 @@ public class EvmManager : IEvmManager
var lastCandle = await GetCandle(Ticker.ETH); var lastCandle = await GetCandle(Ticker.ETH);
return new EvmBalance() 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) public async Task<List<EvmBalance>> GetAllBalances(Chain chain, string publicAddress)
@@ -499,7 +501,7 @@ public class EvmManager : IEvmManager
{ {
try try
{ {
var response = await _web3ProxyService.CallGmxServiceAsync<dynamic>("/cancel-orders", var response = await _web3ProxyService.CallGmxServiceAsync<Web3ProxyResponse>("/cancel-orders",
new new
{ {
account = account.Key, account = account.Key,
@@ -507,7 +509,7 @@ public class EvmManager : IEvmManager
ticker = ticker.ToString() ticker = ticker.ToString()
}); });
return response.success ?? false; return response.Success;
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

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

View File

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