Fix SL and slippage

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

View File

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