Try to fix proxy
This commit is contained in:
@@ -9,10 +9,8 @@ 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 "../../..";
|
||||||
import {DEFAULT_UI_FEE_RECEIVER_ACCOUNT} from "../../utils/utils.js";
|
|
||||||
|
|
||||||
export type SwapOrderParams = {
|
export type SwapOrderParams = {
|
||||||
fromTokenAddress: string;
|
fromTokenAddress: string;
|
||||||
@@ -32,15 +30,7 @@ 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);
|
||||||
|
|
||||||
const skipSimulation = true;
|
|
||||||
if (p.orderType !== OrderType.LimitSwap && skipSimulation !== true) {
|
|
||||||
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"),
|
||||||
@@ -78,7 +68,7 @@ async function getParams(sdk: GmxSdk, p: SwapOrderParams) {
|
|||||||
callbackContract: zeroAddress,
|
callbackContract: zeroAddress,
|
||||||
market: zeroAddress,
|
market: zeroAddress,
|
||||||
swapPath: p.swapPath,
|
swapPath: p.swapPath,
|
||||||
uiFeeReceiver: DEFAULT_UI_FEE_RECEIVER_ACCOUNT,
|
uiFeeReceiver: sdk.config.settings?.uiFeeReceiverAccount ?? zeroAddress,
|
||||||
},
|
},
|
||||||
numbers: {
|
numbers: {
|
||||||
sizeDeltaUsd: 0n,
|
sizeDeltaUsd: 0n,
|
||||||
|
|||||||
@@ -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,16 +31,16 @@ 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";
|
||||||
|
|
||||||
import {Module} from "../base.js";
|
import {Module} from "../base.js";
|
||||||
|
|
||||||
export const DEFAULT_UI_FEE_RECEIVER_ACCOUNT = "0xF9f04a745Db54B25bB8B345a1da74D4E3c38c8aB";
|
const DEFAULT_UI_FEE_RECEIVER_ACCOUNT = "0xff00000000000000000000000000000000000001";
|
||||||
|
|
||||||
export class Utils extends Module {
|
export class Utils extends Module {
|
||||||
private _gasLimits: GasLimitsConfig | null = null;
|
private _gasLimits: GasLimitsConfig | null = null;
|
||||||
@@ -265,7 +265,7 @@ export class Utils extends Module {
|
|||||||
return this._uiFeeFactor;
|
return this._uiFeeFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uiFeeReceiverAccount = DEFAULT_UI_FEE_RECEIVER_ACCOUNT;
|
const uiFeeReceiverAccount = this.sdk.config.settings?.uiFeeReceiverAccount ?? DEFAULT_UI_FEE_RECEIVER_ACCOUNT;
|
||||||
|
|
||||||
const uiFeeFactor = await this.sdk
|
const uiFeeFactor = await this.sdk
|
||||||
.executeMulticall({
|
.executeMulticall({
|
||||||
|
|||||||
@@ -2,11 +2,7 @@ import fp from 'fastify-plugin'
|
|||||||
import {FastifyReply, FastifyRequest} from 'fastify'
|
import {FastifyReply, FastifyRequest} from 'fastify'
|
||||||
import {z} from 'zod'
|
import {z} from 'zod'
|
||||||
import {GmxSdk} from '../../generated/gmxsdk/index.js'
|
import {GmxSdk} from '../../generated/gmxsdk/index.js'
|
||||||
import {ApolloClient} from '@apollo/client/core/ApolloClient.js'
|
|
||||||
import {InMemoryCache} from '@apollo/client/cache/inmemory/inMemoryCache.js'
|
|
||||||
import {gql} from 'graphql-tag'
|
|
||||||
import {HttpLink} from '@apollo/client/link/http/HttpLink.js'
|
|
||||||
import 'cross-fetch/dist/node-polyfill.js' // Required for Apollo Client in Node.js
|
|
||||||
import {arbitrum} from 'viem/chains';
|
import {arbitrum} from 'viem/chains';
|
||||||
import {getTokenBySymbol} from '../../generated/gmxsdk/configs/tokens.js';
|
import {getTokenBySymbol} from '../../generated/gmxsdk/configs/tokens.js';
|
||||||
import {
|
import {
|
||||||
@@ -37,15 +33,17 @@ import {formatUsd} from '../../generated/gmxsdk/utils/numbers/formatting.js';
|
|||||||
import {calculateDisplayDecimals} from '../../generated/gmxsdk/utils/numbers/index.js';
|
import {calculateDisplayDecimals} from '../../generated/gmxsdk/utils/numbers/index.js';
|
||||||
import {handleError} from '../../utils/errorHandler.js';
|
import {handleError} from '../../utils/errorHandler.js';
|
||||||
import {getContract} from '../../generated/gmxsdk/configs/contracts.js';
|
import {getContract} from '../../generated/gmxsdk/configs/contracts.js';
|
||||||
|
import {CLAIMABLE_FUNDING_AMOUNT} from '../../generated/gmxsdk/configs/dataStore.js';
|
||||||
import {Abi, zeroHash} from 'viem';
|
import {Abi, zeroHash} from 'viem';
|
||||||
import {hashDataMap, hashString} from '../../generated/gmxsdk/utils/hash.js';
|
import {hashDataMap, hashString} from '../../generated/gmxsdk/utils/hash.js';
|
||||||
import {CLAIMABLE_FUNDING_AMOUNT} from '../../generated/gmxsdk/configs/dataStore.js';
|
|
||||||
import {abis} from '../../generated/gmxsdk/abis/index.js';
|
import {abis} from '../../generated/gmxsdk/abis/index.js';
|
||||||
import {DEFAULT_UI_FEE_RECEIVER_ACCOUNT} from '../../generated/gmxsdk/modules/utils/utils.js'
|
|
||||||
import {approveContractImpl, getTokenAllowance} from './privy.js';
|
|
||||||
|
|
||||||
// Add the missing CLAIMABLE_UI_FEE_AMOUNT constant based on the pattern
|
import {ApolloClient} from '@apollo/client/core/ApolloClient.js'
|
||||||
export const CLAIMABLE_UI_FEE_AMOUNT = hashString("CLAIMABLE_UI_FEE_AMOUNT");
|
import {InMemoryCache} from '@apollo/client/cache/inmemory/inMemoryCache.js'
|
||||||
|
import {gql} from 'graphql-tag'
|
||||||
|
import {HttpLink} from '@apollo/client/link/http/HttpLink.js'
|
||||||
|
import 'cross-fetch/dist/node-polyfill.js' // Required for Apollo Client in Node.js
|
||||||
|
import {approveContractImpl, getTokenAllowance} from './privy.js';
|
||||||
|
|
||||||
// Cache implementation for markets info data
|
// Cache implementation for markets info data
|
||||||
interface CacheEntry {
|
interface CacheEntry {
|
||||||
@@ -90,6 +88,9 @@ async function getMarketsInfoWithCache(sdk: GmxSdk): Promise<{ marketsInfoData:
|
|||||||
return data as { marketsInfoData: MarketsInfoData; tokensData: TokensData };
|
return data as { marketsInfoData: MarketsInfoData; tokensData: TokensData };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CLAIMABLE_UI_FEE_AMOUNT = hashString("CLAIMABLE_UI_FEE_AMOUNT");
|
||||||
|
const UI_FEE_RECEIVER_ACCOUNT = "0xF9f04a745Db54B25bB8B345a1da74D4E3c38c8aB";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a GraphQL client for the GMX synthetics subgraph
|
* Creates a GraphQL client for the GMX synthetics subgraph
|
||||||
* @param chainId The chain ID to get the client for
|
* @param chainId The chain ID to get the client for
|
||||||
@@ -226,7 +227,9 @@ export async function getClientForAddress(
|
|||||||
rpcUrl: "https://arb1.arbitrum.io/rpc",
|
rpcUrl: "https://arb1.arbitrum.io/rpc",
|
||||||
subsquidUrl: "https://gmx.squids.live/gmx-synthetics-arbitrum:prod/api/graphql",
|
subsquidUrl: "https://gmx.squids.live/gmx-synthetics-arbitrum:prod/api/graphql",
|
||||||
subgraphUrl: "https://subgraph.satsuma-prod.com/3b2ced13c8d9/gmx/synthetics-arbitrum-stats/api",
|
subgraphUrl: "https://subgraph.satsuma-prod.com/3b2ced13c8d9/gmx/synthetics-arbitrum-stats/api",
|
||||||
|
settings: {
|
||||||
|
uiFeeReceiverAccount: UI_FEE_RECEIVER_ACCOUNT
|
||||||
|
},
|
||||||
markets: {
|
markets: {
|
||||||
"0x4D3Eb91efd36C2b74181F34B111bc1E91a0d0cb4": {
|
"0x4D3Eb91efd36C2b74181F34B111bc1E91a0d0cb4": {
|
||||||
isListed: false,
|
isListed: false,
|
||||||
@@ -1627,7 +1630,7 @@ export const getClaimableUiFeesImpl = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get UI fee receiver from SDK config
|
// Get UI fee receiver from SDK config
|
||||||
const uiFeeReceiver = DEFAULT_UI_FEE_RECEIVER_ACCOUNT;
|
const uiFeeReceiver = UI_FEE_RECEIVER_ACCOUNT;
|
||||||
|
|
||||||
// Build multicall request for all markets
|
// Build multicall request for all markets
|
||||||
const multicallRequest = marketAddresses.reduce((request, marketAddress) => {
|
const multicallRequest = marketAddresses.reduce((request, marketAddress) => {
|
||||||
|
|||||||
@@ -149,37 +149,6 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
|
|||||||
account
|
account
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Define route to get rebate stats
|
|
||||||
fastify.get('/rebate-stats', {
|
|
||||||
schema: {
|
|
||||||
querystring: Type.Object({
|
|
||||||
account: Type.String()
|
|
||||||
}),
|
|
||||||
response: {
|
|
||||||
200: Type.Object({
|
|
||||||
success: Type.Boolean(),
|
|
||||||
rebateStats: Type.Optional(Type.Object({
|
|
||||||
totalRebateUsd: Type.Number(),
|
|
||||||
discountUsd: Type.Number(),
|
|
||||||
volume: Type.Number(),
|
|
||||||
tier: Type.Number(),
|
|
||||||
rebateFactor: Type.Number(),
|
|
||||||
discountFactor: Type.Number()
|
|
||||||
})),
|
|
||||||
error: Type.Optional(Type.String())
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, async (request, reply) => {
|
|
||||||
const { account } = request.query
|
|
||||||
|
|
||||||
// Call the getGmxRebateStats method from the GMX plugin
|
|
||||||
return request.getGmxRebateStats(
|
|
||||||
reply,
|
|
||||||
account
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default plugin
|
export default plugin
|
||||||
Reference in New Issue
Block a user