Fix SL and slippage

This commit is contained in:
2025-05-14 12:54:00 +07:00
parent 503a442c6b
commit 15190a0516

View File

@@ -1,7 +1,7 @@
import {MarketsInfoData} from "../../types/markets.js"; import {MarketsInfoData} from "../../types/markets.js";
import {DecreasePositionSwapType, OrderType} from "../../types/orders.js"; import {DecreasePositionSwapType, OrderType} from "../../types/orders.js";
import {TokenData, TokensData, TokensRatio} from "../../types/tokens.js"; import {TokenData, TokensData, TokensRatio} from "../../types/tokens.js";
import { DecreasePositionAmounts, FindSwapPath, SwapAmounts, TriggerThresholdType } from "../../types/trade.js"; import {DecreasePositionAmounts, FindSwapPath, SwapAmounts} from "../../types/trade.js";
import {getByKey} from "../../utils/objects.js"; import {getByKey} from "../../utils/objects.js";
import {createFindSwapPath, findAllSwapPaths, getWrappedAddress} from "../../utils/swap/swapPath.js"; import {createFindSwapPath, findAllSwapPaths, getWrappedAddress} from "../../utils/swap/swapPath.js";
import {convertToUsd, getIsUnwrap, getIsWrap, getTokensRatioByPrice} from "../../utils/tokens.js"; import {convertToUsd, getIsUnwrap, getIsWrap, getTokensRatioByPrice} from "../../utils/tokens.js";
@@ -12,7 +12,6 @@ import type { GmxSdk } from "../..";
import {createSwapEstimator, getMarketsGraph} from "../../utils/swap/swapRouting.js"; import {createSwapEstimator, getMarketsGraph} from "../../utils/swap/swapRouting.js";
import {getSwapAmountsByFromValue, getSwapAmountsByToValue} from "../../utils/swap/index.js"; import {getSwapAmountsByFromValue, getSwapAmountsByToValue} from "../../utils/swap/index.js";
import {EntryField, SidecarSlTpOrderEntryValid} from "../../types/sidecarOrders.js"; import {EntryField, SidecarSlTpOrderEntryValid} from "../../types/sidecarOrders.js";
import { bigMath } from "../../utils/bigmath.js";
/** Base Optional params for helpers, allows to avoid calling markets, tokens and uiFeeFactor methods if they are already passed */ /** Base Optional params for helpers, allows to avoid calling markets, tokens and uiFeeFactor methods if they are already passed */
interface BaseOptionalParams { interface BaseOptionalParams {
@@ -183,7 +182,7 @@ export async function increaseOrderHelper(
collateralDeltaAmount: increaseAmounts.collateralDeltaAmount, collateralDeltaAmount: increaseAmounts.collateralDeltaAmount,
indexPrice: params.stopLossPrice, indexPrice: params.stopLossPrice,
collateralPrice: 0n, collateralPrice: 0n,
acceptablePrice: acceptablePriceInfo.acceptablePrice, acceptablePrice: params.isLong ? 2n ** 256n - 1n : 0n,
acceptablePriceDeltaBps: acceptablePriceInfo.acceptablePriceDeltaBps, acceptablePriceDeltaBps: acceptablePriceInfo.acceptablePriceDeltaBps,
recommendedAcceptablePriceDeltaBps: 0n, recommendedAcceptablePriceDeltaBps: 0n,
estimatedPnl: 0n, estimatedPnl: 0n,