@rabbitholegg/questdk-plugin-gmx
v1.0.0-alpha.73
Published
Currently we only support swaps on Arbitrum and do not support derivatives.
Downloads
31
Readme
Currently we only support swaps on Arbitrum and do not support derivatives.
Limitations with V2 swap filtering
We've identified some limitations in the current version of the GMX swap filter:
Protocol Fee with Raw Ether Transactions:
- There is a small protocol fee of approximately 0.001 ETH included in the payable amount for transactions using raw Ether as the input token.
- This additional fee may lead to discrepancies when comparing amounts, especially in cases where exact equality (
==
) or less-than-or-equal-to (<=
) operators are used.
Behavior with
amountIn
andtokenIn
Parameters:- When
amountIn
is specified andtokenIn
is set toany
, transactions involving any token will pass the filter, but ETH will not. This is due to the way the amount is compared when using ETH vs tokens. WhenamountIn
is set toany
, andtokenIn
is set toany
, both ETH and tokens will pass the filter.
- When
Token Filtering with
tokenOut
Parameter:- If
tokenIn
is set toany
andtokenOut
is specified as USDC, transactions involving any token (excluding ETH) as input will pass the filter. This occurs because the MarketToken for USDC check depends on thetokenIn
being explicitly provided.
- If
V2 Notes
MultiCall calls several functions - the main one we're concerned with is createOrder.
This function takes this struct as a param: https://github.com/gmx-io/gmx-synthetics/blob/77a2ff39f1414a105e8589d622bdb09ac3dd97d8/contracts/order/BaseOrderUtils.sol#L36
struct CreateOrderParams {
CreateOrderParamsAddresses addresses;
CreateOrderParamsNumbers numbers;
Order.OrderType orderType;
Order.DecreasePositionSwapType decreasePositionSwapType;
bool isLong;
bool shouldUnwrapNativeToken;
bytes32 referralCode;
}
We want to confirm swapPath inside of the CreateOrderParamsAddresses
matches our expected tokens and received
in that same struct matches recipient
.
We want to make sure that minOutputAmount
and either triggerPrice
or acceptablePrice
match amountOut and amountIn respectively
We want to confirm orderType is a MarketSwap
enum OrderType {
// @dev MarketSwap: swap token A to token B at the current market price
// the order will be cancelled if the minOutputAmount cannot be fulfilled
MarketSwap,
// @dev LimitSwap: swap token A to token B if the minOutputAmount can be fulfilled
LimitSwap,
// @dev MarketIncrease: increase position at the current market price
// the order will be cancelled if the position cannot be increased at the acceptablePrice
MarketIncrease,
// @dev LimitIncrease: increase position if the triggerPrice is reached and the acceptablePrice can be fulfilled
LimitIncrease,
// @dev MarketDecrease: decrease position at the current market price
// the order will be cancelled if the position cannot be decreased at the acceptablePrice
MarketDecrease,
// @dev LimitDecrease: decrease position if the triggerPrice is reached and the acceptablePrice can be fulfilled
LimitDecrease,
// @dev StopLossDecrease: decrease position if the triggerPrice is reached and the acceptablePrice can be fulfilled
StopLossDecrease,
// @dev Liquidation: allows liquidation of positions if the criteria for liquidation are met
Liquidation
}
Options Transaction Info