working proxy?

This commit is contained in:
2025-06-10 16:48:51 +07:00
parent 3674783946
commit 6c4cf940d4
4 changed files with 40 additions and 1187 deletions

View File

@@ -15,10 +15,10 @@ import {getOrderInfo, isOrderForPositionByData, isVisibleOrder} from "../../util
import {createDecreaseOrderTxn} from "./transactions/createDecreaseOrderTxn.js"; import {createDecreaseOrderTxn} from "./transactions/createDecreaseOrderTxn.js";
import {createIncreaseOrderTxn} from "./transactions/createIncreaseOrderTxn.js"; import {createIncreaseOrderTxn} from "./transactions/createIncreaseOrderTxn.js";
import { import {
buildGetOrdersMulticall, buildGetOrdersMulticall,
getExecutionFeeAmountForEntry, getExecutionFeeAmountForEntry,
matchByMarket, matchByMarket,
parseGetOrdersResponse parseGetOrdersResponse
} from "./utils.js"; } from "./utils.js";
import {Module} from "../base.js"; import {Module} from "../base.js";
import {createSwapOrderTxn} from "./transactions/createSwapOrderTxn.js"; import {createSwapOrderTxn} from "./transactions/createSwapOrderTxn.js";

View File

@@ -9,6 +9,7 @@ import {TokensData} from "../../../types/tokens.js";
import {isMarketOrderType} from "../../../utils/orders.js"; import {isMarketOrderType} from "../../../utils/orders.js";
import {applySlippageToMinOut} from "../../../utils/trade/index.js"; import {applySlippageToMinOut} from "../../../utils/trade/index.js";
import {simulateExecuteOrder} from "../../../utils/simulateExecuteOrder.js";
import type {GmxSdk} from "../../.."; import type {GmxSdk} from "../../..";
@@ -30,7 +31,14 @@ export async function createSwapOrderTxn(sdk: GmxSdk, p: SwapOrderParams) {
const { encodedPayload, totalWntAmount } = await getParams(sdk, p); const { encodedPayload, totalWntAmount } = await getParams(sdk, p);
const { encodedPayload: simulationEncodedPayload, totalWntAmount: sumaltionTotalWntAmount } = await getParams(sdk, p); const { encodedPayload: simulationEncodedPayload, totalWntAmount: sumaltionTotalWntAmount } = await getParams(sdk, p);
if (p.orderType !== OrderType.LimitSwap) {
await simulateExecuteOrder(sdk, {
primaryPriceOverrides: {},
createMulticallPayload: simulationEncodedPayload,
value: sumaltionTotalWntAmount,
tokensData: p.tokensData,
});
}
await sdk.callContract( await sdk.callContract(
getContract(sdk.chainId, "ExchangeRouter"), getContract(sdk.chainId, "ExchangeRouter"),
@@ -68,7 +76,7 @@ async function getParams(sdk: GmxSdk, p: SwapOrderParams) {
callbackContract: zeroAddress, callbackContract: zeroAddress,
market: zeroAddress, market: zeroAddress,
swapPath: p.swapPath, swapPath: p.swapPath,
uiFeeReceiver: sdk.config.settings?.uiFeeReceiverAccount ?? zeroAddress, uiFeeReceiver: zeroAddress,
}, },
numbers: { numbers: {
sizeDeltaUsd: 0n, sizeDeltaUsd: 0n,

View File

@@ -1,27 +1,27 @@
import {withRetry} from "viem"; import {withRetry} from "viem";
import { import {
EXECUTION_FEE_CONFIG_V2, EXECUTION_FEE_CONFIG_V2,
GAS_PRICE_PREMIUM_MAP, GAS_PRICE_PREMIUM_MAP,
getChain, getChain,
MAX_PRIORITY_FEE_PER_GAS_MAP MAX_PRIORITY_FEE_PER_GAS_MAP
} from "../../configs/chains.js"; } from "../../configs/chains.js";
import {getContract} from "../../configs/contracts.js"; import {getContract} from "../../configs/contracts.js";
import { import {
decreaseOrderGasLimitKey, decreaseOrderGasLimitKey,
depositGasLimitKey, depositGasLimitKey,
ESTIMATED_GAS_FEE_BASE_AMOUNT_V2_1, ESTIMATED_GAS_FEE_BASE_AMOUNT_V2_1,
ESTIMATED_GAS_FEE_MULTIPLIER_FACTOR, ESTIMATED_GAS_FEE_MULTIPLIER_FACTOR,
ESTIMATED_GAS_FEE_PER_ORACLE_PRICE, ESTIMATED_GAS_FEE_PER_ORACLE_PRICE,
GLV_DEPOSIT_GAS_LIMIT, GLV_DEPOSIT_GAS_LIMIT,
GLV_PER_MARKET_GAS_LIMIT, GLV_PER_MARKET_GAS_LIMIT,
GLV_WITHDRAWAL_GAS_LIMIT, GLV_WITHDRAWAL_GAS_LIMIT,
increaseOrderGasLimitKey, increaseOrderGasLimitKey,
shiftGasLimitKey, shiftGasLimitKey,
singleSwapGasLimitKey, singleSwapGasLimitKey,
swapOrderGasLimitKey, swapOrderGasLimitKey,
uiFeeFactorKey, uiFeeFactorKey,
withdrawalGasLimitKey, withdrawalGasLimitKey,
} from "../../configs/dataStore.js"; } from "../../configs/dataStore.js";
import type {DecreasePositionAmounts, IncreasePositionAmounts, SwapAmounts, TradeFeesType} from "../../types/trade.js"; import type {DecreasePositionAmounts, IncreasePositionAmounts, SwapAmounts, TradeFeesType} from "../../types/trade.js";
@@ -31,10 +31,10 @@ import {TokensData} from "../../types/tokens.js";
import {bigMath} from "../../utils/bigmath.js"; import {bigMath} from "../../utils/bigmath.js";
import {estimateOrderOraclePriceCount} from "../../utils/fees/estimateOraclePriceCount.js"; import {estimateOrderOraclePriceCount} from "../../utils/fees/estimateOraclePriceCount.js";
import { import {
estimateExecuteDecreaseOrderGasLimit, estimateExecuteDecreaseOrderGasLimit,
estimateExecuteIncreaseOrderGasLimit, estimateExecuteIncreaseOrderGasLimit,
estimateExecuteSwapOrderGasLimit, estimateExecuteSwapOrderGasLimit,
getExecutionFee, getExecutionFee,
} from "../../utils/fees/executionFee.js"; } from "../../utils/fees/executionFee.js";
import {getSwapCount} from "../../utils/trade/index.js"; import {getSwapCount} from "../../utils/trade/index.js";

File diff suppressed because it is too large Load Diff