@gmx-io/sdk 2.3.2 → 2.6.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/scripts/generate-synthetics-abis.js +17 -2
- package/build/cjs/src/abis/CustomErrors.js +98 -0
- package/build/cjs/src/abis/CustomErrorsV2_2_1.js +5565 -0
- package/build/cjs/src/abis/ExchangeRouterV2_2_1.js +1462 -0
- package/build/cjs/src/abis/GelatoRelayRouterV2_2_1.js +1945 -0
- package/build/cjs/src/abis/GlvReaderV2_2_1.js +1681 -0
- package/build/cjs/src/abis/MultichainClaimsRouterV2_2_1.js +1281 -0
- package/build/cjs/src/abis/MultichainGlvRouterV2_2_1.js +1176 -0
- package/build/cjs/src/abis/MultichainGmRouterV2_2_1.js +1480 -0
- package/build/cjs/src/abis/MultichainOrderRouterV2_2_1.js +2065 -0
- package/build/cjs/src/abis/MultichainSubaccountRouterV2_2_1.js +2160 -0
- package/build/cjs/src/abis/MultichainTransferRouterV2_2_1.js +1033 -0
- package/build/cjs/src/abis/RelayParamsV2_2_1.js +56 -0
- package/build/cjs/src/abis/RewardRouterV3.js +675 -0
- package/build/cjs/src/abis/SubaccountGelatoRelayRouterV2_2_1.js +2502 -0
- package/build/cjs/src/abis/SyntheticsReaderV2_2_1.js +5279 -0
- package/build/cjs/src/abis/__tests__/fixtures/arbitrumSepoliaReaders.json +8 -0
- package/build/cjs/src/abis/__tests__/getAbi.spec.js +84 -0
- package/build/cjs/src/abis/getAbi.js +42 -0
- package/build/cjs/src/abis/index.js +4 -1
- package/build/cjs/src/clients/v1/modules/orders/orders.js +5 -3
- package/build/cjs/src/clients/v1/modules/orders/transactions/createIncreaseOrderTxn.js +3 -1
- package/build/cjs/src/clients/v1/modules/orders/transactions/updateOrderTxn.js +21 -25
- package/build/cjs/src/clients/v1/modules/orders/utils.js +6 -7
- package/build/cjs/src/clients/v1/modules/trades/trades.js +4 -3
- package/build/cjs/src/clients/v1/multicall.js +2 -1
- package/build/cjs/src/clients/v2/__tests__/decrease.spec.js +0 -2
- package/build/cjs/src/clients/v2/__tests__/editCancel.spec.js +0 -3
- package/build/cjs/src/clients/v2/__tests__/globalCleanup.js +0 -1
- package/build/cjs/src/clients/v2/__tests__/increase.spec.js +0 -2
- package/build/cjs/src/clients/v2/__tests__/subaccountLifecycle.spec.js +0 -1
- package/build/cjs/src/clients/v2/__tests__/testUtil.js +0 -1
- package/build/cjs/src/configs/__tests__/markets.spec.js +8 -1
- package/build/cjs/src/configs/chains.js +16 -1
- package/build/cjs/src/configs/contracts.js +27 -18
- package/build/cjs/src/configs/dataStore.js +13 -3
- package/build/cjs/src/configs/markets.js +12 -7
- package/build/cjs/src/configs/tokens.js +12 -7
- package/build/cjs/src/utils/__tests__/address.spec.js +50 -0
- package/build/cjs/src/utils/__tests__/numbers.spec.js +24 -0
- package/build/cjs/src/utils/__tests__/orderTransactions/exchangeRouterMulticall.spec.js +41 -4
- package/build/cjs/src/utils/__tests__/orderTransactions/updateOrder.spec.js +4 -0
- package/build/cjs/src/utils/__tests__/parseError.spec.js +61 -0
- package/build/cjs/src/utils/__tests__/referrals.spec.js +36 -4
- package/build/cjs/src/utils/address/index.js +17 -0
- package/build/cjs/src/utils/address/utils.js +32 -0
- package/build/cjs/src/utils/errors/parseError.js +10 -0
- package/build/cjs/src/utils/errors/transactionsErrors.js +23 -0
- package/build/cjs/src/utils/express/utils/batchOrderUtils.js +14 -9
- package/build/cjs/src/utils/express/utils/bridgeOutUtils.js +52 -17
- package/build/cjs/src/utils/express/utils/referralUtils.js +38 -25
- package/build/cjs/src/utils/express/utils/relayParamsUtils.js +11 -3
- package/build/cjs/src/utils/markets/__tests__/multicall.spec.js +27 -0
- package/build/cjs/src/utils/markets/multicall.js +5 -7
- package/build/cjs/src/utils/multichain/api.js +17 -8
- package/build/cjs/src/utils/numbers/utils.js +7 -1
- package/build/cjs/src/utils/orderTransactions/api.js +3 -4
- package/build/cjs/src/utils/orderTransactions/utils.js +8 -7
- package/build/cjs/src/utils/orders/utils.js +8 -1
- package/build/cjs/src/utils/paxos/__tests__/api.spec.js +23 -3
- package/build/cjs/src/utils/paxos/api.js +6 -0
- package/build/cjs/src/utils/referrals/utils.js +24 -15
- package/build/cjs/src/utils/subaccount/getEmptySubaccountApproval.js +2 -0
- package/build/cjs/src/utils/subaccount/getSubaccountApprovalTypedData.js +37 -15
- package/build/cjs/src/utils/subaccount/hashSubaccountApproval.js +32 -18
- package/build/cjs/src/utils/subaccount/index.js +4 -1
- package/build/cjs/src/utils/subaccount/sdkClient.js +1 -1
- package/build/cjs/src/utils/subaccount/state.js +10 -1
- package/build/cjs/src/utils/swap/preparedSwapData.js +6 -4
- package/build/cjs/src/utils/swap/swapPath.js +1 -1
- package/build/cjs/src/utils/trade/__tests__/decreaseMarginCheck.spec.js +224 -0
- package/build/cjs/src/utils/trade/__tests__/getMaxWithdrawAmount.spec.js +128 -9
- package/build/cjs/src/utils/trade/decrease.js +198 -33
- package/build/cjs/src/utils/trade/decreaseMarginCheck.js +157 -0
- package/build/cjs/src/utils/trade/increaseMarginCheck.js +27 -15
- package/build/cjs/src/utils/trade/index.js +1 -0
- package/build/cjs/src/utils/tradeHistory/utils.js +6 -6
- package/build/esm/scripts/generate-synthetics-abis.js +17 -2
- package/build/esm/src/abis/CustomErrors.js +98 -0
- package/build/esm/src/abis/CustomErrorsV2_2_1.js +5563 -0
- package/build/esm/src/abis/ExchangeRouterV2_2_1.js +1460 -0
- package/build/esm/src/abis/GelatoRelayRouterV2_2_1.js +1943 -0
- package/build/esm/src/abis/GlvReaderV2_2_1.js +1679 -0
- package/build/esm/src/abis/MultichainClaimsRouterV2_2_1.js +1279 -0
- package/build/esm/src/abis/MultichainGlvRouterV2_2_1.js +1174 -0
- package/build/esm/src/abis/MultichainGmRouterV2_2_1.js +1478 -0
- package/build/esm/src/abis/MultichainOrderRouterV2_2_1.js +2063 -0
- package/build/esm/src/abis/MultichainSubaccountRouterV2_2_1.js +2158 -0
- package/build/esm/src/abis/MultichainTransferRouterV2_2_1.js +1031 -0
- package/build/esm/src/abis/RelayParamsV2_2_1.js +54 -0
- package/build/esm/src/abis/RewardRouterV3.js +673 -0
- package/build/esm/src/abis/SubaccountGelatoRelayRouterV2_2_1.js +2500 -0
- package/build/esm/src/abis/SyntheticsReaderV2_2_1.js +5277 -0
- package/build/esm/src/abis/__tests__/fixtures/arbitrumSepoliaReaders.json +8 -0
- package/build/esm/src/abis/__tests__/getAbi.spec.js +79 -0
- package/build/esm/src/abis/getAbi.js +35 -0
- package/build/esm/src/abis/index.js +4 -1
- package/build/esm/src/clients/v1/modules/orders/orders.js +5 -3
- package/build/esm/src/clients/v1/modules/orders/transactions/createIncreaseOrderTxn.js +3 -1
- package/build/esm/src/clients/v1/modules/orders/transactions/updateOrderTxn.js +21 -25
- package/build/esm/src/clients/v1/modules/orders/utils.js +6 -7
- package/build/esm/src/clients/v1/modules/trades/trades.js +4 -3
- package/build/esm/src/clients/v1/multicall.js +2 -1
- package/build/esm/src/clients/v2/__tests__/decrease.spec.js +0 -2
- package/build/esm/src/clients/v2/__tests__/editCancel.spec.js +0 -3
- package/build/esm/src/clients/v2/__tests__/globalCleanup.js +0 -1
- package/build/esm/src/clients/v2/__tests__/increase.spec.js +0 -2
- package/build/esm/src/clients/v2/__tests__/subaccountLifecycle.spec.js +0 -1
- package/build/esm/src/clients/v2/__tests__/testUtil.js +0 -1
- package/build/esm/src/configs/__tests__/markets.spec.js +9 -2
- package/build/esm/src/configs/chains.js +14 -0
- package/build/esm/src/configs/contracts.js +25 -17
- package/build/esm/src/configs/dataStore.js +8 -0
- package/build/esm/src/configs/markets.js +13 -8
- package/build/esm/src/configs/tokens.js +13 -8
- package/build/esm/src/utils/__tests__/address.spec.js +48 -0
- package/build/esm/src/utils/__tests__/numbers.spec.js +25 -1
- package/build/esm/src/utils/__tests__/orderTransactions/exchangeRouterMulticall.spec.js +43 -6
- package/build/esm/src/utils/__tests__/orderTransactions/updateOrder.spec.js +5 -1
- package/build/esm/src/utils/__tests__/parseError.spec.js +62 -1
- package/build/esm/src/utils/__tests__/referrals.spec.js +37 -5
- package/build/esm/src/utils/address/index.js +1 -0
- package/build/esm/src/utils/address/utils.js +25 -0
- package/build/esm/src/utils/errors/parseError.js +11 -1
- package/build/esm/src/utils/errors/transactionsErrors.js +23 -0
- package/build/esm/src/utils/express/utils/batchOrderUtils.js +14 -9
- package/build/esm/src/utils/express/utils/bridgeOutUtils.js +53 -18
- package/build/esm/src/utils/express/utils/referralUtils.js +37 -25
- package/build/esm/src/utils/express/utils/relayParamsUtils.js +10 -5
- package/build/esm/src/utils/markets/__tests__/multicall.spec.js +25 -0
- package/build/esm/src/utils/markets/multicall.js +5 -7
- package/build/esm/src/utils/multichain/api.js +15 -7
- package/build/esm/src/utils/numbers/utils.js +5 -0
- package/build/esm/src/utils/orderTransactions/api.js +3 -4
- package/build/esm/src/utils/orderTransactions/utils.js +9 -8
- package/build/esm/src/utils/orders/utils.js +6 -0
- package/build/esm/src/utils/paxos/__tests__/api.spec.js +23 -3
- package/build/esm/src/utils/paxos/api.js +6 -0
- package/build/esm/src/utils/referrals/utils.js +23 -15
- package/build/esm/src/utils/subaccount/getEmptySubaccountApproval.js +2 -0
- package/build/esm/src/utils/subaccount/getSubaccountApprovalTypedData.js +36 -14
- package/build/esm/src/utils/subaccount/hashSubaccountApproval.js +32 -18
- package/build/esm/src/utils/subaccount/index.js +2 -2
- package/build/esm/src/utils/subaccount/sdkClient.js +2 -2
- package/build/esm/src/utils/subaccount/state.js +8 -0
- package/build/esm/src/utils/swap/preparedSwapData.js +6 -4
- package/build/esm/src/utils/swap/swapPath.js +2 -2
- package/build/esm/src/utils/trade/__tests__/decreaseMarginCheck.spec.js +222 -0
- package/build/esm/src/utils/trade/__tests__/getMaxWithdrawAmount.spec.js +129 -10
- package/build/esm/src/utils/trade/decrease.js +195 -32
- package/build/esm/src/utils/trade/decreaseMarginCheck.js +152 -0
- package/build/esm/src/utils/trade/increaseMarginCheck.js +25 -14
- package/build/esm/src/utils/trade/index.js +1 -0
- package/build/esm/src/utils/tradeHistory/utils.js +6 -6
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/types/scripts/generate-synthetics-abis.d.ts +6 -0
- package/build/types/src/abis/CustomErrors.d.ts +160 -0
- package/build/types/src/abis/CustomErrorsV2_2_1.d.ts +4174 -0
- package/build/types/src/abis/ExchangeRouterV2_2_1.d.ts +1128 -0
- package/build/types/src/abis/GelatoRelayRouterV2_2_1.d.ts +1508 -0
- package/build/types/src/abis/GlvReaderV2_2_1.d.ts +1293 -0
- package/build/types/src/abis/MultichainClaimsRouterV2_2_1.d.ts +985 -0
- package/build/types/src/abis/MultichainGlvRouterV2_2_1.d.ts +906 -0
- package/build/types/src/abis/MultichainGmRouterV2_2_1.d.ts +1142 -0
- package/build/types/src/abis/MultichainOrderRouterV2_2_1.d.ts +1601 -0
- package/build/types/src/abis/MultichainSubaccountRouterV2_2_1.d.ts +1678 -0
- package/build/types/src/abis/MultichainTransferRouterV2_2_1.d.ts +793 -0
- package/build/types/src/abis/RelayParamsV2_2_1.d.ts +118 -0
- package/build/types/src/abis/RewardRouterV3.d.ts +1129 -0
- package/build/types/src/abis/SubaccountGelatoRelayRouterV2_2_1.d.ts +1946 -0
- package/build/types/src/abis/SyntheticsReaderV2_2_1.d.ts +4075 -0
- package/build/types/src/abis/__tests__/getAbi.spec.d.ts +1 -0
- package/build/types/src/abis/getAbi.d.ts +17051 -0
- package/build/types/src/abis/index.d.ts +6700 -4744
- package/build/types/src/clients/v1/modules/orders/transactions/createIncreaseOrderTxn.d.ts +2 -1
- package/build/types/src/clients/v1/modules/orders/transactions/updateOrderTxn.d.ts +8 -3
- package/build/types/src/configs/chains.d.ts +6 -2
- package/build/types/src/configs/contracts.d.ts +6 -0
- package/build/types/src/configs/dataStore.d.ts +4 -0
- package/build/types/src/configs/markets.d.ts +4 -4
- package/build/types/src/utils/__tests__/address.spec.d.ts +1 -0
- package/build/types/src/utils/address/index.d.ts +1 -0
- package/build/types/src/utils/address/utils.d.ts +11 -0
- package/build/types/src/utils/errors/transactionsErrors.d.ts +18 -1
- package/build/types/src/utils/express/types.d.ts +1 -0
- package/build/types/src/utils/express/utils/batchOrderUtils.d.ts +4 -3
- package/build/types/src/utils/express/utils/bridgeOutUtils.d.ts +8 -2
- package/build/types/src/utils/express/utils/referralUtils.d.ts +21 -0
- package/build/types/src/utils/markets/__tests__/multicall.spec.d.ts +1 -0
- package/build/types/src/utils/multichain/api.d.ts +8 -0
- package/build/types/src/utils/numbers/utils.d.ts +1 -0
- package/build/types/src/utils/orderTransactions/api.d.ts +1 -3
- package/build/types/src/utils/orderTransactions/utils.d.ts +5 -2
- package/build/types/src/utils/orders/utils.d.ts +1 -0
- package/build/types/src/utils/paxos/types.d.ts +2 -0
- package/build/types/src/utils/referrals/utils.d.ts +7 -1
- package/build/types/src/utils/subaccount/api.d.ts +1 -0
- package/build/types/src/utils/subaccount/getSubaccountApprovalTypedData.d.ts +4 -0
- package/build/types/src/utils/subaccount/hashSubaccountApproval.d.ts +2 -1
- package/build/types/src/utils/subaccount/index.d.ts +2 -2
- package/build/types/src/utils/subaccount/state.d.ts +2 -1
- package/build/types/src/utils/subaccount/types.d.ts +3 -1
- package/build/types/src/utils/trade/__tests__/decreaseMarginCheck.spec.d.ts +1 -0
- package/build/types/src/utils/trade/decrease.d.ts +18 -0
- package/build/types/src/utils/trade/decreaseMarginCheck.d.ts +52 -0
- package/build/types/src/utils/trade/increaseMarginCheck.d.ts +11 -1
- package/build/types/src/utils/trade/index.d.ts +1 -0
- package/build/types/src/utils/trade/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"source": "gmx-synthetics-private release_2.2.1 deployed Arbitrum Sepolia reader ABIs; synthetic position and market values",
|
|
3
|
+
"getAccountPositions": "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000011111111111111111111111111111111111111110000000000000000000000002222222222222222222222222222222222222222000000000000000000000000333333333333333333333333333333333333333300000000000000000000000000000000000000327cb2734119d3b7a90000000000000000000000000000000000000000000000000000000000052f8cfd32658800000000000000000000000000000000000000000000000000000000001e7b23fffffffffffffffffffffffffffffffffffffffffffffffffffffee1d99c66fdfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000b0000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000006ab12a2f0000000000000000000000000000000000000000000000000000000000000000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff300000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000",
|
|
4
|
+
"getPositionInfoList": "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111111111111111111111111110000000000000000000000002222222222222222222222222222222222222222000000000000000000000000333333333333333333333333333333333333333300000000000000000000000000000000000000327cb2734119d3b7a90000000000000000000000000000000000000000000000000000000000052f8cfd32658800000000000000000000000000000000000000000000000000000000001e7b23fffffffffffffffffffffffffffffffffffffffffffffffffffffee1d99c66fdfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000b0000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000006ab12a2f0000000000000000000000000000000000000000000000000000000000000000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff3000000000000000000000000000000000000000000000000000000000000001100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000444444444444444444444444444444444444444400000000000000000000000044444444444444444444444444444444444444440000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000900000000000000000000000044444444444444444444444444444444444444440000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000009ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000009",
|
|
5
|
+
"getMarketInfoList": "0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000004444444444444444444444444444444444444444000000000000000000000000444444444444444444444444444444444444444400000000000000000000000044444444444444444444444444444444444444440000000000000000000000004444444444444444444444444444444444444444000000000000000000000000000000000000000000000000000000000000001b000000000000000000000000000000000000000000000000000000000000000d0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000000",
|
|
6
|
+
"getAccountGlvDeposits": "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000007b000000000000000000000000000000000000000000000000000000006ab12a2f00000000000000000000000000000000000000000000000000000000075bcd1500000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000066eee0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000003600000000000000000000000004444444444444444444444444444444444444444000000000000000000000000111111111111111111111111111111111111111100000000000000000000000044444444444444444444444444444444444444440000000000000000000000004444444444444444444444444444444444444444000000000000000000000000444444444444444444444444444444444444444400000000000000000000000022222222222222222222222222222222222222220000000000000000000000004444444444444444444444444444444444444444000000000000000000000000444444444444444444444444444444444444444400000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000000100000000000000000000000044444444444444444444444444444444444444440000000000000000000000000000000000000000000000000000000000000001000000000000000000000000444444444444444444444444444444444444444400000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000",
|
|
7
|
+
"getAccountGlvWithdrawals": "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000007b000000000000000000000000000000000000000000000000000000006ab12a2f00000000000000000000000000000000000000000000000000000000075bcd1500000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000066eee000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000002e000000000000000000000000044444444444444444444444444444444444444440000000000000000000000002222222222222222222222222222222222222222000000000000000000000000111111111111111111111111111111111111111100000000000000000000000044444444444444444444444444444444444444440000000000000000000000004444444444444444444444444444444444444444000000000000000000000000444444444444444444444444444444444444444400000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000100000000000000000000000044444444444444444444444444444444444444440000000000000000000000000000000000000000000000000000000000000001000000000000000000000000444444444444444444444444444444444444444400000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000"
|
|
8
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { decodeFunctionResult } from "viem";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { ARBITRUM_SEPOLIA } from "../../configs/chainIds";
|
|
4
|
+
import { getAbi } from "../getAbi";
|
|
5
|
+
import responses from "./fixtures/arbitrumSepoliaReaders.json";
|
|
6
|
+
describe("Arbitrum Sepolia reader responses", () => {
|
|
7
|
+
it("decodes an existing short position with the deployed position layout", () => {
|
|
8
|
+
const data = responses.getAccountPositions;
|
|
9
|
+
const positions = decodeFunctionResult({
|
|
10
|
+
abi: getAbi(ARBITRUM_SEPOLIA, "SyntheticsReader"),
|
|
11
|
+
functionName: "getAccountPositions",
|
|
12
|
+
data,
|
|
13
|
+
});
|
|
14
|
+
expect(positions).toMatchObject([
|
|
15
|
+
{
|
|
16
|
+
addresses: { account: "0x1111111111111111111111111111111111111111" },
|
|
17
|
+
numbers: {
|
|
18
|
+
sizeInUsd: 4000000000000000000000000000000n,
|
|
19
|
+
collateralAmount: 1997603n,
|
|
20
|
+
realizedUncappedPnlUsd: -7n,
|
|
21
|
+
realizedPnlUsd: 3n,
|
|
22
|
+
cappedPnlPoolTokenAmount: 11n,
|
|
23
|
+
increasedAtTime: 1789995567n,
|
|
24
|
+
decreasedAtTime: 0n,
|
|
25
|
+
cappedPnlReferencePoolPnlUsd: -13n,
|
|
26
|
+
cappedPnlAllowancePerPrice: 17n,
|
|
27
|
+
},
|
|
28
|
+
flags: { isLong: false },
|
|
29
|
+
},
|
|
30
|
+
]);
|
|
31
|
+
});
|
|
32
|
+
it("decodes position details and fees after the added position fields", () => {
|
|
33
|
+
const positions = decodeFunctionResult({
|
|
34
|
+
abi: getAbi(ARBITRUM_SEPOLIA, "SyntheticsReader"),
|
|
35
|
+
functionName: "getPositionInfoList",
|
|
36
|
+
data: responses.getPositionInfoList,
|
|
37
|
+
});
|
|
38
|
+
expect(positions).toMatchObject([
|
|
39
|
+
{
|
|
40
|
+
position: { numbers: { increasedAtTime: 1789995567n }, flags: { isLong: false } },
|
|
41
|
+
fees: { positionFeeAmount: 5n, balanceWasImproved: true },
|
|
42
|
+
basePnlUsd: -25n,
|
|
43
|
+
},
|
|
44
|
+
]);
|
|
45
|
+
});
|
|
46
|
+
it("decodes market information with borrowing availability flags", () => {
|
|
47
|
+
const markets = decodeFunctionResult({
|
|
48
|
+
abi: getAbi(ARBITRUM_SEPOLIA, "SyntheticsReader"),
|
|
49
|
+
functionName: "getMarketInfoList",
|
|
50
|
+
data: responses.getMarketInfoList,
|
|
51
|
+
});
|
|
52
|
+
expect(markets).toMatchObject([
|
|
53
|
+
{
|
|
54
|
+
borrowingFactorPerSecondForLongs: 27n,
|
|
55
|
+
borrowingFactorPerSecondForShorts: 13n,
|
|
56
|
+
borrowingFactorForLongsAvailable: true,
|
|
57
|
+
borrowingFactorForShortsAvailable: false,
|
|
58
|
+
isDisabled: false,
|
|
59
|
+
},
|
|
60
|
+
]);
|
|
61
|
+
});
|
|
62
|
+
it.each(["getAccountGlvDeposits", "getAccountGlvWithdrawals"])("decodes %s with the added UI fee factor", (functionName) => {
|
|
63
|
+
const orders = decodeFunctionResult({
|
|
64
|
+
abi: getAbi(ARBITRUM_SEPOLIA, "GlvReader"),
|
|
65
|
+
functionName,
|
|
66
|
+
data: responses[functionName],
|
|
67
|
+
});
|
|
68
|
+
expect(orders).toMatchObject([
|
|
69
|
+
{
|
|
70
|
+
numbers: {
|
|
71
|
+
uiFeeFactor: 123n,
|
|
72
|
+
updatedAtTime: 1789995567n,
|
|
73
|
+
executionFee: 123456789n,
|
|
74
|
+
srcChainId: 421614n,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
]);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import ExchangeRouterV2_2_1 from "./ExchangeRouterV2_2_1";
|
|
2
|
+
import GelatoRelayRouterV2_2_1 from "./GelatoRelayRouterV2_2_1";
|
|
3
|
+
import GlvReaderV2_2_1 from "./GlvReaderV2_2_1";
|
|
4
|
+
import { abis } from "./index";
|
|
5
|
+
import MultichainClaimsRouterV2_2_1 from "./MultichainClaimsRouterV2_2_1";
|
|
6
|
+
import MultichainGlvRouterV2_2_1 from "./MultichainGlvRouterV2_2_1";
|
|
7
|
+
import MultichainGmRouterV2_2_1 from "./MultichainGmRouterV2_2_1";
|
|
8
|
+
import MultichainOrderRouterV2_2_1 from "./MultichainOrderRouterV2_2_1";
|
|
9
|
+
import MultichainSubaccountRouterV2_2_1 from "./MultichainSubaccountRouterV2_2_1";
|
|
10
|
+
import MultichainTransferRouterV2_2_1 from "./MultichainTransferRouterV2_2_1";
|
|
11
|
+
import SubaccountGelatoRelayRouterV2_2_1 from "./SubaccountGelatoRelayRouterV2_2_1";
|
|
12
|
+
import SyntheticsReaderV2_2_1 from "./SyntheticsReaderV2_2_1";
|
|
13
|
+
import { isContractsV2_2_1 } from "../configs/contracts";
|
|
14
|
+
const contractsV2_2_1Abis = {
|
|
15
|
+
ExchangeRouter: ExchangeRouterV2_2_1,
|
|
16
|
+
GelatoRelayRouter: GelatoRelayRouterV2_2_1,
|
|
17
|
+
GlvReader: GlvReaderV2_2_1,
|
|
18
|
+
MultichainClaimsRouter: MultichainClaimsRouterV2_2_1,
|
|
19
|
+
MultichainGlvRouter: MultichainGlvRouterV2_2_1,
|
|
20
|
+
MultichainGmRouter: MultichainGmRouterV2_2_1,
|
|
21
|
+
MultichainOrderRouter: MultichainOrderRouterV2_2_1,
|
|
22
|
+
MultichainSubaccountRouter: MultichainSubaccountRouterV2_2_1,
|
|
23
|
+
MultichainTransferRouter: MultichainTransferRouterV2_2_1,
|
|
24
|
+
SubaccountGelatoRelayRouter: SubaccountGelatoRelayRouterV2_2_1,
|
|
25
|
+
SyntheticsReader: SyntheticsReaderV2_2_1,
|
|
26
|
+
};
|
|
27
|
+
function isContractsV2_2_1AbiId(abiId) {
|
|
28
|
+
return abiId in contractsV2_2_1Abis;
|
|
29
|
+
}
|
|
30
|
+
export function getAbi(chainId, abiId) {
|
|
31
|
+
if (isContractsV2_2_1(chainId) && isContractsV2_2_1AbiId(abiId)) {
|
|
32
|
+
return contractsV2_2_1Abis[abiId];
|
|
33
|
+
}
|
|
34
|
+
return abis[abiId];
|
|
35
|
+
}
|
|
@@ -4,6 +4,7 @@ import ArbitrumNodeInterface from "./ArbitrumNodeInterface";
|
|
|
4
4
|
import ArbSys from "./ArbSys";
|
|
5
5
|
import ClaimHandler from "./ClaimHandler";
|
|
6
6
|
import CustomErrors from "./CustomErrors";
|
|
7
|
+
import CustomErrorsV2_2_1 from "./CustomErrorsV2_2_1";
|
|
7
8
|
import DataStore from "./DataStore";
|
|
8
9
|
import ERC20PermitInterface from "./ERC20PermitInterface";
|
|
9
10
|
import ERC721 from "./ERC721";
|
|
@@ -32,6 +33,7 @@ import ReferralStorage from "./ReferralStorage";
|
|
|
32
33
|
import RelayParams from "./RelayParams";
|
|
33
34
|
import RewardReader from "./RewardReader";
|
|
34
35
|
import RewardRouter from "./RewardRouter";
|
|
36
|
+
import RewardRouterV3 from "./RewardRouterV3";
|
|
35
37
|
import RewardTracker from "./RewardTracker";
|
|
36
38
|
import SimulationRouter from "./SimulationRouter";
|
|
37
39
|
import SmartAccount from "./SmartAccount";
|
|
@@ -60,7 +62,7 @@ export const abis = {
|
|
|
60
62
|
ArbitrumNodeInterface,
|
|
61
63
|
ArbSys,
|
|
62
64
|
ClaimHandler,
|
|
63
|
-
CustomErrors,
|
|
65
|
+
CustomErrors: [...CustomErrors, ...CustomErrorsV2_2_1],
|
|
64
66
|
DataStore,
|
|
65
67
|
ERC20: erc20Abi,
|
|
66
68
|
ERC20PermitInterface,
|
|
@@ -87,6 +89,7 @@ export const abis = {
|
|
|
87
89
|
RelayParams,
|
|
88
90
|
RewardReader,
|
|
89
91
|
RewardRouter,
|
|
92
|
+
RewardRouterV3,
|
|
90
93
|
RewardTracker,
|
|
91
94
|
SimulationRouter,
|
|
92
95
|
SmartAccount,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Module } from "../base";
|
|
2
2
|
import { getWrappedToken } from "../../../../configs/tokens";
|
|
3
|
+
import { getAddressKey } from "../../../../utils/address";
|
|
3
4
|
import { getByKey } from "../../../../utils/objects";
|
|
4
5
|
import { getOrderInfo, isOrderForPositionByData, isVisibleOrder } from "../../../../utils/orders";
|
|
5
6
|
import { OrderType } from "../../../../utils/orders/types";
|
|
@@ -22,9 +23,9 @@ export class Orders extends Module {
|
|
|
22
23
|
const nonSwapRelevantDefinedFiltersLowercased = marketsDirectionsFilter
|
|
23
24
|
.filter((filter) => filter.direction !== "swap" && filter.marketAddress !== "any")
|
|
24
25
|
.map((filter) => ({
|
|
25
|
-
marketAddress: filter.marketAddress
|
|
26
|
+
marketAddress: getAddressKey(filter.marketAddress),
|
|
26
27
|
direction: filter.direction,
|
|
27
|
-
collateralAddress: filter.collateralAddress
|
|
28
|
+
collateralAddress: filter.collateralAddress ? getAddressKey(filter.collateralAddress) : undefined,
|
|
28
29
|
}));
|
|
29
30
|
const hasNonSwapRelevantDefinedMarkets = nonSwapRelevantDefinedFiltersLowercased.length > 0;
|
|
30
31
|
const pureDirectionFilters = marketsDirectionsFilter
|
|
@@ -33,7 +34,7 @@ export class Orders extends Module {
|
|
|
33
34
|
const hasPureDirectionFilters = pureDirectionFilters.length > 0;
|
|
34
35
|
const swapRelevantDefinedMarketsLowercased = marketsDirectionsFilter
|
|
35
36
|
.filter((filter) => (filter.direction === "any" || filter.direction === "swap") && filter.marketAddress !== "any")
|
|
36
|
-
.map((filter) => filter.marketAddress
|
|
37
|
+
.map((filter) => getAddressKey(filter.marketAddress));
|
|
37
38
|
const hasSwapRelevantDefinedMarkets = swapRelevantDefinedMarketsLowercased.length > 0;
|
|
38
39
|
const orders = await this.sdk
|
|
39
40
|
.executeMulticall(buildGetOrdersMulticall(this.chainId, account))
|
|
@@ -192,6 +193,7 @@ export class Orders extends Module {
|
|
|
192
193
|
txnType: entry.txnType,
|
|
193
194
|
initialCollateralDeltaAmount: entry.order?.initialCollateralDeltaAmount ?? 0n,
|
|
194
195
|
autoCancel: entry.order.autoCancel,
|
|
196
|
+
decreasePositionSwapType: entry.order.decreasePositionSwapType,
|
|
195
197
|
})),
|
|
196
198
|
});
|
|
197
199
|
}
|
|
@@ -50,12 +50,13 @@ export async function createIncreaseOrderTxn({ sdk, createIncreaseOrderParams: p
|
|
|
50
50
|
ps: createDecreaseOrderParams || [],
|
|
51
51
|
});
|
|
52
52
|
const cancelEncodedPayload = createCancelEncodedPayload(cancelOrderParams?.map(({ orderKey }) => orderKey) || []);
|
|
53
|
-
const updateEncodedPayload = updateOrderParams?.reduce((acc, { orderKey, sizeDeltaUsd, executionFee, indexToken, acceptablePrice, triggerPrice, minOutputAmount, autoCancel }) => {
|
|
53
|
+
const updateEncodedPayload = updateOrderParams?.reduce((acc, { orderKey, orderType, sizeDeltaUsd, executionFee, indexToken, acceptablePrice, triggerPrice, minOutputAmount, autoCancel, decreasePositionSwapType, }) => {
|
|
54
54
|
return [
|
|
55
55
|
...acc,
|
|
56
56
|
...createUpdateEncodedPayload({
|
|
57
57
|
sdk,
|
|
58
58
|
orderKey,
|
|
59
|
+
orderType,
|
|
59
60
|
sizeDeltaUsd,
|
|
60
61
|
executionFee,
|
|
61
62
|
indexToken,
|
|
@@ -63,6 +64,7 @@ export async function createIncreaseOrderTxn({ sdk, createIncreaseOrderParams: p
|
|
|
63
64
|
triggerPrice,
|
|
64
65
|
minOutputAmount,
|
|
65
66
|
autoCancel,
|
|
67
|
+
decreasePositionSwapType,
|
|
66
68
|
}),
|
|
67
69
|
];
|
|
68
70
|
}, []) ?? [];
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { encodeFunctionData } from "viem";
|
|
2
1
|
import { abis } from "../../../../../abis";
|
|
3
2
|
import { getContract } from "../../../../../configs/contracts";
|
|
4
|
-
import {
|
|
3
|
+
import { buildUpdateOrderMulticall, buildUpdateOrderPayload, encodeExchangeRouterMulticall, } from "../../../../../utils/orderTransactions/utils";
|
|
5
4
|
export function updateOrderTxn(sdk, p) {
|
|
6
|
-
const { orderKey, sizeDeltaUsd, triggerPrice, acceptablePrice, minOutputAmount, executionFee, indexToken, autoCancel, } = p;
|
|
5
|
+
const { orderKey, orderType, sizeDeltaUsd, triggerPrice, acceptablePrice, minOutputAmount, executionFee, indexToken, autoCancel, decreasePositionSwapType, } = p;
|
|
7
6
|
const router = getContract(sdk.chainId, "ExchangeRouter");
|
|
8
7
|
const encodedPayload = createUpdateEncodedPayload({
|
|
9
8
|
sdk,
|
|
10
9
|
orderKey,
|
|
10
|
+
orderType,
|
|
11
11
|
sizeDeltaUsd,
|
|
12
12
|
executionFee,
|
|
13
13
|
indexToken,
|
|
@@ -15,32 +15,28 @@ export function updateOrderTxn(sdk, p) {
|
|
|
15
15
|
triggerPrice,
|
|
16
16
|
minOutputAmount,
|
|
17
17
|
autoCancel,
|
|
18
|
+
decreasePositionSwapType,
|
|
18
19
|
});
|
|
19
20
|
return sdk.callContract(router, abis.ExchangeRouter, "multicall", [encodedPayload], {
|
|
20
21
|
value: executionFee != undefined && executionFee > 0 ? executionFee : undefined,
|
|
21
22
|
});
|
|
22
23
|
}
|
|
23
|
-
export function createUpdateEncodedPayload({ sdk, orderKey, sizeDeltaUsd, executionFee, indexToken, acceptablePrice, triggerPrice, autoCancel, minOutputAmount, }) {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
0n,
|
|
38
|
-
autoCancel,
|
|
39
|
-
],
|
|
24
|
+
export function createUpdateEncodedPayload({ sdk, orderKey, orderType, sizeDeltaUsd, executionFee, indexToken, acceptablePrice, triggerPrice, autoCancel, minOutputAmount, decreasePositionSwapType, }) {
|
|
25
|
+
const updateTxn = buildUpdateOrderPayload({
|
|
26
|
+
chainId: sdk.chainId,
|
|
27
|
+
indexTokenAddress: indexToken.address,
|
|
28
|
+
orderKey,
|
|
29
|
+
orderType,
|
|
30
|
+
sizeDeltaUsd,
|
|
31
|
+
triggerPrice,
|
|
32
|
+
acceptablePrice,
|
|
33
|
+
minOutputAmount,
|
|
34
|
+
autoCancel,
|
|
35
|
+
validFromTime: 0n,
|
|
36
|
+
decreasePositionSwapType,
|
|
37
|
+
executionFeeTopUp: executionFee ?? 0n,
|
|
40
38
|
});
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
args: call.params,
|
|
45
|
-
}));
|
|
39
|
+
const { multicall } = buildUpdateOrderMulticall(updateTxn);
|
|
40
|
+
const { encodedMulticall } = encodeExchangeRouterMulticall(sdk.chainId, multicall);
|
|
41
|
+
return encodedMulticall;
|
|
46
42
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { isAddressEqual } from "viem";
|
|
2
1
|
import { getContract } from "../../../../configs/contracts";
|
|
3
2
|
import { accountOrderListKey } from "../../../../configs/dataStore";
|
|
4
3
|
import { getWrappedToken } from "../../../../configs/tokens";
|
|
4
|
+
import { getAddressKey, isSameAddress } from "../../../../utils/address";
|
|
5
5
|
import { estimateOrderOraclePriceCount } from "../../../../utils/fees/estimateOraclePriceCount";
|
|
6
6
|
import { estimateExecuteDecreaseOrderGasLimit, getExecutionFee } from "../../../../utils/fees/executionFee";
|
|
7
7
|
import { isIncreaseOrderType, isLimitOrderType, isSwapOrderType, isTriggerDecreaseOrderType } from "../../../../utils/orders";
|
|
@@ -42,13 +42,13 @@ export function matchByMarket({ order, nonSwapRelevantDefinedFiltersLowercased,
|
|
|
42
42
|
return true;
|
|
43
43
|
}
|
|
44
44
|
if (isSwapOrder) {
|
|
45
|
-
const sourceMarketInSwapPath = swapRelevantDefinedMarketsLowercased.includes(order.swapPath.at(0)
|
|
46
|
-
const destinationMarketInSwapPath = swapRelevantDefinedMarketsLowercased.includes(order.swapPath.at(-1)
|
|
45
|
+
const sourceMarketInSwapPath = swapRelevantDefinedMarketsLowercased.includes(getAddressKey(order.swapPath.at(0)));
|
|
46
|
+
const destinationMarketInSwapPath = swapRelevantDefinedMarketsLowercased.includes(getAddressKey(order.swapPath.at(-1)));
|
|
47
47
|
return sourceMarketInSwapPath || destinationMarketInSwapPath;
|
|
48
48
|
}
|
|
49
49
|
else if (!isSwapOrder) {
|
|
50
50
|
return nonSwapRelevantDefinedFiltersLowercased.some((filter) => {
|
|
51
|
-
const marketMatch = filter.marketAddress === "any" || filter.marketAddress === order.marketAddress
|
|
51
|
+
const marketMatch = filter.marketAddress === "any" || filter.marketAddress === getAddressKey(order.marketAddress);
|
|
52
52
|
const directionMath = filter.direction === "any" || filter.direction === (order.isLong ? "long" : "short");
|
|
53
53
|
const initialCollateralAddress = order.initialCollateralTokenAddress;
|
|
54
54
|
let collateralMatch = true;
|
|
@@ -69,12 +69,11 @@ export function matchByMarket({ order, nonSwapRelevantDefinedFiltersLowercased,
|
|
|
69
69
|
swapPath: order.swapPath,
|
|
70
70
|
wrappedNativeTokenAddress: wrappedToken.address,
|
|
71
71
|
});
|
|
72
|
-
collateralMatch =
|
|
73
|
-
outTokenAddress !== undefined && isAddressEqual(outTokenAddress, filter.collateralAddress);
|
|
72
|
+
collateralMatch = outTokenAddress !== undefined && isSameAddress(outTokenAddress, filter.collateralAddress);
|
|
74
73
|
}
|
|
75
74
|
}
|
|
76
75
|
else if (isTriggerDecreaseOrderType(order.orderType)) {
|
|
77
|
-
collateralMatch =
|
|
76
|
+
collateralMatch = isSameAddress(order.initialCollateralTokenAddress, filter.collateralAddress);
|
|
78
77
|
}
|
|
79
78
|
return marketMatch && directionMath && collateralMatch;
|
|
80
79
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import merge from "lodash/merge";
|
|
2
2
|
import { Module } from "../base";
|
|
3
3
|
import { getWrappedToken } from "../../../../configs/tokens";
|
|
4
|
+
import { getAddressKey } from "../../../../utils/address";
|
|
4
5
|
import graphqlFetcher from "../../../../utils/graphqlFetcher";
|
|
5
6
|
import { buildFiltersBody } from "../../../../utils/indexers";
|
|
6
7
|
import { isIncreaseOrderType, isLimitOrderType, isSwapOrderType, isTriggerDecreaseOrderType } from "../../../../utils/orders";
|
|
@@ -39,9 +40,9 @@ export async function fetchTradeActions({ sdk, pageIndex, pageSize, marketsDirec
|
|
|
39
40
|
const nonSwapRelevantDefinedFiltersLowercased = marketsDirectionsFilter
|
|
40
41
|
.filter((filter) => filter.direction !== "swap" && filter.marketAddress !== "any")
|
|
41
42
|
.map((filter) => ({
|
|
42
|
-
marketAddress: filter.marketAddress
|
|
43
|
+
marketAddress: getAddressKey(filter.marketAddress),
|
|
43
44
|
direction: filter.direction,
|
|
44
|
-
collateralAddress: filter.collateralAddress
|
|
45
|
+
collateralAddress: filter.collateralAddress ? getAddressKey(filter.collateralAddress) : undefined,
|
|
45
46
|
}));
|
|
46
47
|
const hasNonSwapRelevantDefinedMarkets = nonSwapRelevantDefinedFiltersLowercased.length > 0;
|
|
47
48
|
const pureDirectionFilters = marketsDirectionsFilter
|
|
@@ -53,7 +54,7 @@ export async function fetchTradeActions({ sdk, pageIndex, pageSize, marketsDirec
|
|
|
53
54
|
const hasPureDirectionFilters = pureDirectionFilters.length > 0;
|
|
54
55
|
const swapRelevantDefinedMarketsLowercased = marketsDirectionsFilter
|
|
55
56
|
.filter((filter) => (filter.direction === "any" || filter.direction === "swap") && filter.marketAddress !== "any")
|
|
56
|
-
.map((filter) => filter.marketAddress
|
|
57
|
+
.map((filter) => getAddressKey(filter.marketAddress));
|
|
57
58
|
const hasSwapRelevantDefinedMarkets = swapRelevantDefinedMarketsLowercased.length > 0;
|
|
58
59
|
const filtersStr = buildFiltersBody({
|
|
59
60
|
AND: [
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { abis as allAbis } from "../../abis";
|
|
2
|
+
import { getAbi } from "../../abis/getAbi";
|
|
2
3
|
import { sleep } from "../../utils/common";
|
|
3
4
|
export const MAX_TIMEOUT = 40000;
|
|
4
5
|
export const MAX_CALLS_PER_BATCH = 1000;
|
|
@@ -40,7 +41,7 @@ export class Multicall {
|
|
|
40
41
|
}
|
|
41
42
|
// Add Errors ABI to each contract ABI to correctly parse errors
|
|
42
43
|
abis[contractCallConfig.contractAddress] = abis[contractCallConfig.contractAddress] || [
|
|
43
|
-
...
|
|
44
|
+
...getAbi(this.chainId, contractCallConfig.abiId),
|
|
44
45
|
...allAbis.CustomErrors,
|
|
45
46
|
];
|
|
46
47
|
const abi = abis[contractCallConfig.contractAddress];
|
|
@@ -199,7 +199,6 @@ describe("decrease orders", () => {
|
|
|
199
199
|
requestId: prepared.requestId,
|
|
200
200
|
signature: sig,
|
|
201
201
|
from: account,
|
|
202
|
-
idempotencyKey: prepared.idempotencyKey,
|
|
203
202
|
eip712Data: {
|
|
204
203
|
batchParams: prepared.payload.batchParams,
|
|
205
204
|
relayParams: prepared.payload.relayParams,
|
|
@@ -291,7 +290,6 @@ describe("decrease orders", () => {
|
|
|
291
290
|
requestId: prepared.requestId,
|
|
292
291
|
signature: sig,
|
|
293
292
|
from: account,
|
|
294
|
-
idempotencyKey: prepared.idempotencyKey,
|
|
295
293
|
eip712Data: {
|
|
296
294
|
batchParams: prepared.payload.batchParams,
|
|
297
295
|
relayParams: prepared.payload.relayParams,
|
|
@@ -12,7 +12,6 @@ async function signAndSubmit(sdk, prepared) {
|
|
|
12
12
|
requestId: prepared.requestId,
|
|
13
13
|
signature: sig,
|
|
14
14
|
from: account,
|
|
15
|
-
idempotencyKey: prepared.idempotencyKey,
|
|
16
15
|
eip712Data: {
|
|
17
16
|
batchParams: prepared.payload.batchParams,
|
|
18
17
|
relayParams: prepared.payload.relayParams,
|
|
@@ -168,7 +167,6 @@ describe("edit & cancel orders", () => {
|
|
|
168
167
|
requestId: prepared.requestId,
|
|
169
168
|
signature,
|
|
170
169
|
from: account,
|
|
171
|
-
idempotencyKey: prepared.idempotencyKey,
|
|
172
170
|
eip712Data: {
|
|
173
171
|
batchParams: prepared.payload.batchParams,
|
|
174
172
|
relayParams: prepared.payload.relayParams,
|
|
@@ -209,7 +207,6 @@ describe("edit & cancel orders", () => {
|
|
|
209
207
|
requestId: prepared.requestId,
|
|
210
208
|
signature,
|
|
211
209
|
from: account,
|
|
212
|
-
idempotencyKey: prepared.idempotencyKey,
|
|
213
210
|
eip712Data: {
|
|
214
211
|
batchParams: prepared.payload.batchParams,
|
|
215
212
|
relayParams: prepared.payload.relayParams,
|
|
@@ -13,7 +13,6 @@ async function cancelAllOrders() {
|
|
|
13
13
|
requestId: prepared.requestId,
|
|
14
14
|
signature: sig,
|
|
15
15
|
from: account,
|
|
16
|
-
idempotencyKey: prepared.idempotencyKey,
|
|
17
16
|
eip712Data: {
|
|
18
17
|
batchParams: prepared.payload.batchParams,
|
|
19
18
|
relayParams: prepared.payload.relayParams,
|
|
@@ -666,7 +665,6 @@ describe("increase orders", () => {
|
|
|
666
665
|
requestId: prepared.requestId,
|
|
667
666
|
signature,
|
|
668
667
|
from: account,
|
|
669
|
-
idempotencyKey: prepared.idempotencyKey,
|
|
670
668
|
eip712Data: {
|
|
671
669
|
batchParams: prepared.payload.batchParams,
|
|
672
670
|
relayParams: prepared.payload.relayParams,
|
|
@@ -90,7 +90,6 @@ describe("GmxApiSdk — subaccount (1CT) live flow", () => {
|
|
|
90
90
|
requestId: prepared.requestId,
|
|
91
91
|
signature: cancelSignature,
|
|
92
92
|
from: account,
|
|
93
|
-
idempotencyKey: prepared.idempotencyKey,
|
|
94
93
|
eip712Data: {
|
|
95
94
|
batchParams: prepared.payload.batchParams,
|
|
96
95
|
relayParams: prepared.payload.relayParams,
|
|
@@ -193,7 +193,6 @@ export async function expressFlow(sdk, signer, request) {
|
|
|
193
193
|
requestId: prepared.requestId,
|
|
194
194
|
signature,
|
|
195
195
|
from: signer.address,
|
|
196
|
-
idempotencyKey: prepared.idempotencyKey,
|
|
197
196
|
eip712Data: {
|
|
198
197
|
batchParams: prepared.payload.batchParams,
|
|
199
198
|
relayParams: prepared.payload.relayParams,
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { withRetry } from "viem";
|
|
2
2
|
import { describe, expect, it } from "vitest";
|
|
3
|
-
import { CONTRACTS_CHAIN_IDS_DEV } from "../chains";
|
|
3
|
+
import { CONTRACTS_CHAIN_IDS_DEV, isTestnetChain } from "../chains";
|
|
4
4
|
import { MARKETS } from "../markets";
|
|
5
5
|
import { getOracleKeeperUrl } from "../oracleKeeper";
|
|
6
6
|
const SKIPPED_KEEPER_MARKETS = {};
|
|
7
7
|
const getKeeperMarkets = async (chainId) => {
|
|
8
8
|
const res = await fetch(`${getOracleKeeperUrl(chainId)}/markets`);
|
|
9
|
+
if (!res.ok)
|
|
10
|
+
throw Error(`Keeper responded with ${res.status}`);
|
|
9
11
|
const data = (await res.json());
|
|
10
12
|
if (!data || !data.markets || data.markets.length === 0)
|
|
11
13
|
throw Error("No markets in response");
|
|
@@ -13,9 +15,14 @@ const getKeeperMarkets = async (chainId) => {
|
|
|
13
15
|
};
|
|
14
16
|
describe("markets config", () => {
|
|
15
17
|
CONTRACTS_CHAIN_IDS_DEV.forEach(async (chainId) => {
|
|
16
|
-
it(`markets should be consistent with keeper for ${chainId}`, async () => {
|
|
18
|
+
it(`markets should be consistent with keeper for ${chainId}`, async ({ skip }) => {
|
|
17
19
|
const keeperMarkets = await withRetry(() => getKeeperMarkets(chainId), {
|
|
18
20
|
retryCount: 2,
|
|
21
|
+
}).catch((error) => {
|
|
22
|
+
// A testnet keeper outage is not config drift; mainnet keepers must answer
|
|
23
|
+
if (isTestnetChain(chainId))
|
|
24
|
+
skip(`Keeper is unavailable: ${error.message}`);
|
|
25
|
+
throw error;
|
|
19
26
|
});
|
|
20
27
|
Object.entries(MARKETS[chainId]).forEach(([marketAddress, market]) => {
|
|
21
28
|
if (SKIPPED_KEEPER_MARKETS[chainId]?.has(marketAddress)) {
|
|
@@ -18,6 +18,8 @@ export const SOURCE_CHAIN_IDS = [
|
|
|
18
18
|
AVALANCHE_FUJI,
|
|
19
19
|
];
|
|
20
20
|
export const GMX_ACCOUNT_PSEUDO_CHAIN_ID = 0;
|
|
21
|
+
// Solana has no EVM chain id: this id stays out of the EVM chain lists and types in this file
|
|
22
|
+
export const SOLANA_NETWORK_ID = -501;
|
|
21
23
|
const CONTRACTS_CHAIN_CONFIGS = {
|
|
22
24
|
[ARBITRUM]: {
|
|
23
25
|
chainId: ARBITRUM,
|
|
@@ -233,10 +235,19 @@ export const VIEM_CHAIN_BY_CHAIN_ID = {
|
|
|
233
235
|
[SOURCE_BASE_MAINNET]: base,
|
|
234
236
|
[SOURCE_BSC_MAINNET]: bsc,
|
|
235
237
|
};
|
|
238
|
+
export function isSolanaNetwork(networkId) {
|
|
239
|
+
return networkId === SOLANA_NETWORK_ID;
|
|
240
|
+
}
|
|
236
241
|
export function getChainName(chainId) {
|
|
242
|
+
if (isSolanaNetwork(chainId)) {
|
|
243
|
+
return "Solana";
|
|
244
|
+
}
|
|
237
245
|
return ALL_CHAIN_CONFIGS[chainId]?.name ?? "Unknown";
|
|
238
246
|
}
|
|
239
247
|
export function getChainSlug(chainId) {
|
|
248
|
+
if (isSolanaNetwork(chainId)) {
|
|
249
|
+
return "solana";
|
|
250
|
+
}
|
|
240
251
|
return ALL_CHAIN_CONFIGS[chainId]?.slug ?? "unknown";
|
|
241
252
|
}
|
|
242
253
|
export function getChainIdBySlug(slug) {
|
|
@@ -297,6 +308,9 @@ export function getChainDefaultCollateralSymbol(chainId) {
|
|
|
297
308
|
return CONTRACTS_CHAIN_CONFIGS[chainId]?.defaultCollateralSymbol;
|
|
298
309
|
}
|
|
299
310
|
export function getExplorerUrl(chainId) {
|
|
311
|
+
if (typeof chainId === "number" && isSolanaNetwork(chainId)) {
|
|
312
|
+
return "https://solscan.io/";
|
|
313
|
+
}
|
|
300
314
|
switch (chainId) {
|
|
301
315
|
case "layerzero":
|
|
302
316
|
return "https://layerzeroscan.com/";
|