@gmx-io/sdk 1.8.0 → 1.8.2
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/src/codegen/prebuilt/hashedKinkModelMarketRatesKeys.json +16 -0
- package/build/cjs/src/codegen/prebuilt/hashedMarketConfigKeys.json +136 -0
- package/build/cjs/src/codegen/prebuilt/hashedMarketValuesKeys.json +30 -0
- package/build/cjs/src/configs/express.js +1 -0
- package/build/cjs/src/configs/markets.js +14 -0
- package/build/cjs/src/configs/tokens.js +22 -0
- package/build/cjs/src/utils/express/utils/gelatoRelayUtils.js +2 -0
- package/build/cjs/src/utils/express/utils/gmxRelayUtils.js +145 -0
- package/build/cjs/src/utils/express/utils/gmxRelayUtils.spec.js +163 -0
- package/build/cjs/src/utils/express/utils/index.js +1 -0
- package/build/cjs/src/utils/tradeHistory/utils.js +3 -0
- package/build/esm/src/codegen/prebuilt/hashedKinkModelMarketRatesKeys.json +16 -0
- package/build/esm/src/codegen/prebuilt/hashedMarketConfigKeys.json +136 -0
- package/build/esm/src/codegen/prebuilt/hashedMarketValuesKeys.json +30 -0
- package/build/esm/src/configs/express.js +1 -0
- package/build/esm/src/configs/markets.js +14 -0
- package/build/esm/src/configs/tokens.js +22 -0
- package/build/esm/src/utils/express/utils/gelatoRelayUtils.js +2 -0
- package/build/esm/src/utils/express/utils/gmxRelayUtils.js +137 -0
- package/build/esm/src/utils/express/utils/gmxRelayUtils.spec.js +161 -0
- package/build/esm/src/utils/express/utils/index.js +1 -0
- package/build/esm/src/utils/tradeHistory/utils.js +3 -0
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/types/src/codegen/prebuilt/index.d.ts +182 -0
- package/build/types/src/configs/express.d.ts +1 -0
- package/build/types/src/utils/express/utils/gelatoRelayUtils.d.ts +2 -0
- package/build/types/src/utils/express/utils/gmxRelayUtils.d.ts +61 -0
- package/build/types/src/utils/express/utils/gmxRelayUtils.spec.d.ts +1 -0
- package/build/types/src/utils/express/utils/index.d.ts +1 -0
- package/build/types/src/utils/tradeHistory/types.d.ts +2 -1
- package/package.json +1 -1
|
@@ -1106,6 +1106,22 @@
|
|
|
1106
1106
|
"aboveOptimalUsageBorrowingFactorLong": "0x7e034f066736dca0c85aaf2dfb4c64048d34fce3c932085d783794ba2024df9d",
|
|
1107
1107
|
"aboveOptimalUsageBorrowingFactorShort": "0xbc8b7b4174c18250b8cbe2bc9b23b678695089afbe2cf61ed4b90643cefc050e"
|
|
1108
1108
|
},
|
|
1109
|
+
"0x1C132E43029efCd57435eE79ceA98006C6227A6f": {
|
|
1110
|
+
"optimalUsageFactorLong": "0x00abb59b34b998f13f7f2096ca92a249f3481be4fb03a256c16aafef03ab0500",
|
|
1111
|
+
"optimalUsageFactorShort": "0xa9c965a86a17c259d43baa8e002fc748edcb648136d59914b6ea79f8f56f9d5b",
|
|
1112
|
+
"baseBorrowingFactorLong": "0x2e413ff5ea3d2ce62744f23dffe17ff2902eac0172ae0e37fffd979a5a256eb6",
|
|
1113
|
+
"baseBorrowingFactorShort": "0x821f23cd4c269efa9f3e60f580a7b206745640b91e25a39d2fd08c214910c51a",
|
|
1114
|
+
"aboveOptimalUsageBorrowingFactorLong": "0x15b5d66d3f0b54a90d4692d9588c610cbbb6115b58433c32fea006187baf8463",
|
|
1115
|
+
"aboveOptimalUsageBorrowingFactorShort": "0x89c234febd22acc64b7aa71b095310b1f135556c44af6a7aefb81faf1525e4e7"
|
|
1116
|
+
},
|
|
1117
|
+
"0xcBd4c1b0c89D50793c5A3e8d96d98FcB4f1B1c47": {
|
|
1118
|
+
"optimalUsageFactorLong": "0x41c6ebae17f74a8e02e1eeaa7a2717f75de692bbfbda2723bf62dc9af9b68a36",
|
|
1119
|
+
"optimalUsageFactorShort": "0x3a528648365d6dc09d2972560f7a1d42dd7ffc5a267843cbbd0c2f88dae0bcb8",
|
|
1120
|
+
"baseBorrowingFactorLong": "0x6d87c6b80765652cdc2702042ac165a15457453e04e9d32dcf01fcecd30e5277",
|
|
1121
|
+
"baseBorrowingFactorShort": "0xfa9bed1825224b6c6f6e1cd51ffcd06c9c7e4a60c21c07b9e76647a4399c9d23",
|
|
1122
|
+
"aboveOptimalUsageBorrowingFactorLong": "0xa4d6bb6d66221090f9290c4c2f1271b03b3e4154e89e938f94cf7603253aa430",
|
|
1123
|
+
"aboveOptimalUsageBorrowingFactorShort": "0x6e47338f0a9790e653c371d71b32358e07b01c24e544317f74d2fedb264638d6"
|
|
1124
|
+
},
|
|
1109
1125
|
"0xE26E7b91143f367445f1c0a5dCf4f4aC8EaDcDb1": {
|
|
1110
1126
|
"optimalUsageFactorLong": "0x7dd92ed8d2f972a0bedc134931f1ce1257fdc1ba4ebc043c270e81880efee700",
|
|
1111
1127
|
"optimalUsageFactorShort": "0xec58abc0c1c902e8df7ed4f6968dbfd88228e741bfd63bf3efc635e0d7c9bb9d",
|
|
@@ -9386,6 +9386,142 @@
|
|
|
9386
9386
|
"virtualLongTokenId": "0xaab37f889b9680dda34f58a689de3023cb22f7ae14d32a3c1d45798a973db1f5",
|
|
9387
9387
|
"virtualShortTokenId": "0xd5258cb84f0039be58306488e8df941c05f3cf4f219e92aacb6561c736bbb960"
|
|
9388
9388
|
},
|
|
9389
|
+
"0x1C132E43029efCd57435eE79ceA98006C6227A6f": {
|
|
9390
|
+
"isDisabled": "0xbe70359055c796f979de98581b3ac29b4b979707c276e4fb6c315fc8800f936a",
|
|
9391
|
+
"maxLongPoolAmount": "0x68fee9d0a0461fdd234d76a63d96545ed2856b4e514780f1a38365c75ad2f4cb",
|
|
9392
|
+
"maxShortPoolAmount": "0xafe3404843acf5244fdf9caa46b9533e16a096bcaef4556a1bc74faeebe14fed",
|
|
9393
|
+
"maxLongPoolUsdForDeposit": "0x72d9b526ab49c459baf8ec61d78dcd98dd8a1d30bd26998c5a483beffda6391a",
|
|
9394
|
+
"maxShortPoolUsdForDeposit": "0x2b1a0e7d20200a33b770accbc7c6ac01313086b771d65d884163da6b91a651ae",
|
|
9395
|
+
"reserveFactorLong": "0x4d9e7a545fd319806545b15f84d003c6c11a2ad38910bc8fafdb1ecb3a977bec",
|
|
9396
|
+
"reserveFactorShort": "0xea4749335e180a4930b228cf83fb857b60f4a773455ee1dac3f3e70363c06202",
|
|
9397
|
+
"openInterestReserveFactorLong": "0xa5e48d5d663ab82846d2e87b4f5bad7dfaf214c08942765d1a35eb3ac753b236",
|
|
9398
|
+
"openInterestReserveFactorShort": "0x978afda7a89c862db9c920e2d91afee94c93fe6e8ab8d42c51d03c686ee4423f",
|
|
9399
|
+
"maxOpenInterestLong": "0x594a1e421ff23d54e167e7699b7046959834a826f6dc459af7069e41d50af3ab",
|
|
9400
|
+
"maxOpenInterestShort": "0x7d339db57cd533a972c2986d08b55ef1b418e2694c4d5f522a9ad8c7f7b08b03",
|
|
9401
|
+
"maxCollateralSumLongTokenLong": "0x4378b5877fea3635cacd5dcae7ba63717cbec400c4ab8f7ce6f6d9031e1038e6",
|
|
9402
|
+
"maxCollateralSumLongTokenShort": "0xbfb0ceba92c73e128016f05d3d9a9c0ddab82637f18a998d2a7f83c065a5d691",
|
|
9403
|
+
"maxCollateralSumShortTokenLong": "0xdd0f8942a5d80202d1962df700e0f5dcc5b10da8afee71a042fc032fa8e36ab3",
|
|
9404
|
+
"maxCollateralSumShortTokenShort": "0x25e40f873d3946e5653feae65f323bbf95ae161685778f63b0d3d09d658f899c",
|
|
9405
|
+
"minPositionImpactPoolAmount": "0xca8f886c59fd03b65e0f33a16e85f2cee10431e3138a50a9bfaf1c2e4815c12b",
|
|
9406
|
+
"positionImpactPoolDistributionRate": "0x83d63d91b17c3561702a7d4216e858f54ddc9cd5bb2d51b9ceb2222dcebfe8ff",
|
|
9407
|
+
"borrowingFactorLong": "0x05fc6ada5c0edbff2558a31db24b4f6e4ce6e47cd97343abd29fa65b462164f4",
|
|
9408
|
+
"borrowingFactorShort": "0xe5ed32f358acae73ee97dcf41ea62ac9a0a69c54642229fd7a14c6d55d0d7492",
|
|
9409
|
+
"borrowingExponentFactorLong": "0xcce7f77b22819ed8386a262a0f4b788d6fb057d939dfd0acf0e5337ab2a193f0",
|
|
9410
|
+
"borrowingExponentFactorShort": "0xc2ace70d8e13e4871d5b5d5d0975fb3cf7b1107252371918a3fb60e4179d5d38",
|
|
9411
|
+
"fundingFactor": "0x86bb6ab868fdc8add928ea2844bd86bd81e4203b7938e23ca5e404f9c2442b52",
|
|
9412
|
+
"fundingExponentFactor": "0xfb3122fc032e25fdebbe3bbbc1d21c67e1c116ab8d634419a13b2cd3a43e088f",
|
|
9413
|
+
"fundingIncreaseFactorPerSecond": "0x69dba55937a82229fae8dbaf5179a4fb52e4fe8c125eb6395981b37d9e7eb2ca",
|
|
9414
|
+
"minFundingIncreaseRatePerSecond": "0x833462537f8664dec4fb7c34911d457fa7bd915899b61375ba673f34939c60d3",
|
|
9415
|
+
"fundingDecreaseFactorPerSecond": "0x662ee65ed00753fae50ac5600019668a6bcbad168390899c8f5725eb5284c9e2",
|
|
9416
|
+
"thresholdForStableFunding": "0x20e6c7e2526ff14527e1b3c140e558dc3db006a8d5ccf0d76b9ee76fdef14fb3",
|
|
9417
|
+
"thresholdForDecreaseFunding": "0x62dfe43759a916592ae7f32c70086219c8fc46d69ca83a9d6f565307ebf5c92b",
|
|
9418
|
+
"minFundingFactorPerSecondLong": "0xfd4fd67c30ed0e0b53dda1db548fe0a983942e1d118148f5303b09153a8b96aa",
|
|
9419
|
+
"minFundingFactorPerSecondShort": "0x3c0131fde67b01d0b4c7c8f654745d2d9337c069f55c43576cd94a241ee35040",
|
|
9420
|
+
"maxFundingFactorPerSecondLong": "0x7b452222d12756f57aa54dbcae83658a20dfbe5da9133028c9e20b6b91a8b85b",
|
|
9421
|
+
"maxFundingFactorPerSecondShort": "0x7f7f65b16e6354d98ba5d965b35181d5eabce9cfac66a918ca275ca716c02e37",
|
|
9422
|
+
"maxPnlFactorForTradersLong": "0x818044a6a80636bc4d2a970ff8a282b438ac597a2421f006cc3e72340ce6cfd2",
|
|
9423
|
+
"maxPnlFactorForTradersShort": "0x5b36add2c4c124f4be4ea3e140bf35b16a63796caf8fd245f6f98987144747fa",
|
|
9424
|
+
"maxPnlFactorForDepositsLong": "0xc0f9535617673b7d8ad468ff3d509fad539aa8fb74e60e36f98e12f82dd635f9",
|
|
9425
|
+
"maxPnlFactorForDepositsShort": "0x71d666a95a41f177113abb8895b8e4ab3bd1c1ce7d09aa2db1969213b887d94a",
|
|
9426
|
+
"maxPnlFactorForWithdrawalsLong": "0x13bf12688ed5fa466c91987da78fea63b258e834eae0d4369b8514e546f186ed",
|
|
9427
|
+
"maxPnlFactorForWithdrawalsShort": "0x521de3d6331abce31fd0fcba636413c1663cf920c353a62a041907d634670d8a",
|
|
9428
|
+
"positionFeeFactorForBalanceWasImproved": "0x43164f207d23010c8660ff3dba907a505890c1505c71ab1116073b08580c286f",
|
|
9429
|
+
"positionFeeFactorForBalanceWasNotImproved": "0xb81430683cb033b19627cafb049bff5a66f5ba96e471b4f09b80dad3efed2f1d",
|
|
9430
|
+
"positionImpactFactorPositive": "0x1b4990b0b68b089bbc6a5289c70eac4d825c8b2cbdff31f65c0b0ec7fab638fe",
|
|
9431
|
+
"positionImpactFactorNegative": "0x9923519ae5b9734400ae7de8de261d91dd2c70b1fac0b2846ca608b4462f441b",
|
|
9432
|
+
"maxPositionImpactFactorPositive": "0x4743d57d48e780ad3535d467249391e5c4d0b7ab8f63950d1889a677077a834a",
|
|
9433
|
+
"maxPositionImpactFactorNegative": "0x33952cbb69873d2e71eb24167615cb19838b39b043a77761460ebe0269fb7ced",
|
|
9434
|
+
"maxPositionImpactFactorForLiquidations": "0x7c9596d39f634af34f0b578f557db17d7fffa504a72450a57f2a8f41bf7d44d5",
|
|
9435
|
+
"maxLendableImpactFactor": "0x287485446c91fb00a3d705b3a7225f9db476a1708134efaaf1dd4c74e39a5378",
|
|
9436
|
+
"maxLendableImpactFactorForWithdrawals": "0x2d09d8ee41694c9d732ccd5f0e756f64b82d5608cab93ca1163b80bf17c57158",
|
|
9437
|
+
"maxLendableImpactUsd": "0x9de184a64cebf480e0aac4c55d1eccfd91e9bb90891e35f868e9e7598346c588",
|
|
9438
|
+
"lentPositionImpactPoolAmount": "0x846f45b035a22087f67804cedd792b47214ec54e3764de629afb384c91693cff",
|
|
9439
|
+
"minCollateralFactor": "0xb5f98c0e1373986f8fc653f0c5c6c8923e328ceadfdd39c5d9ece7245d32294b",
|
|
9440
|
+
"minCollateralFactorForLiquidation": "0x84b12a69cfaecec62634b4c64c28ee425519df90041250963675e00d13fef5eb",
|
|
9441
|
+
"minCollateralFactorForOpenInterestLong": "0xefdc459c31cea6d654c33ca60eda4fef616bf688cb0edc5ff9a8d8c89f30a5d6",
|
|
9442
|
+
"minCollateralFactorForOpenInterestShort": "0x95991c271d628f3a8c711967d4017ddf46127ed33823fda81fe7839f5423ca98",
|
|
9443
|
+
"positionImpactExponentFactorPositive": "0xd343266bc9fcc6b625b519ba0241018bcf0c2c454eadc7ed77db7fc3a22b02d9",
|
|
9444
|
+
"positionImpactExponentFactorNegative": "0x7f7ce35777a1e17534015307b19285e46ca722b0c4634cd9ca7326029533bbf3",
|
|
9445
|
+
"swapFeeFactorForBalanceWasImproved": "0x75b08d2dd57ca76571a6a3e3cdf50ce355fd58fce5c34d011cd59dddfb1d990c",
|
|
9446
|
+
"swapFeeFactorForBalanceWasNotImproved": "0x98f15089424d9dd4794f41b1e938d6e7a1ccbb8f54a409d4a07c029cd7d16804",
|
|
9447
|
+
"atomicSwapFeeFactor": "0x09a2b805cc9e32cef48e1ee3a0dbc81845f26d1923bdd3ea17068554c97d924a",
|
|
9448
|
+
"swapImpactFactorPositive": "0xcdacb07c489f71f4d3d24ebb908073b2eef9c5ccf0d3f03e5f2ed84fca08e263",
|
|
9449
|
+
"swapImpactFactorNegative": "0x2fc53945d4b86a3d202362c4daa3a2e0797ed9d8def65ee7257e06b1bd7cb4be",
|
|
9450
|
+
"swapImpactExponentFactor": "0x2e7b36dbbaa0d7abc7042cf82be036222418a720c85f4558d8efe75f4ccc78c5",
|
|
9451
|
+
"withdrawalFeeFactorBalanceWasImproved": "0x7fcede1536913179c3b029bd4a53bcfd0ddad0ed0119f71e0a5bf0294825535a",
|
|
9452
|
+
"withdrawalFeeFactorBalanceWasNotImproved": "0x2b32c9894e93154e1f5e51bfa62fc9a65ad1af9e248f0108396300342ddd8dee",
|
|
9453
|
+
"virtualMarketId": "0x2f05d3175ec7f6695b8fc63700c9b9c82fac3bc13687af20b3061d37df2a4255",
|
|
9454
|
+
"virtualLongTokenId": "0xaab37f889b9680dda34f58a689de3023cb22f7ae14d32a3c1d45798a973db1f5",
|
|
9455
|
+
"virtualShortTokenId": "0xd5258cb84f0039be58306488e8df941c05f3cf4f219e92aacb6561c736bbb960"
|
|
9456
|
+
},
|
|
9457
|
+
"0xcBd4c1b0c89D50793c5A3e8d96d98FcB4f1B1c47": {
|
|
9458
|
+
"isDisabled": "0x16ee957433bca525641bceca4503f31e60928fb8c1b164800a02c96682acafcb",
|
|
9459
|
+
"maxLongPoolAmount": "0x376d7c33424bfcf26fdb12c7b33739079aeb7938befda9d9b3117b0237b79681",
|
|
9460
|
+
"maxShortPoolAmount": "0x8fca1983e3ae361c121f8233f9ece2ee78b76e19331e4ea2afa35f201f63a1e0",
|
|
9461
|
+
"maxLongPoolUsdForDeposit": "0x2294566914531b0f8b43bb785bb0b77145c28dca4267e33ca39eee986861177c",
|
|
9462
|
+
"maxShortPoolUsdForDeposit": "0xcc235b4a1b1e481dc095760e93a0c9b74e793ac2ad7c0291a5807bb12b3df713",
|
|
9463
|
+
"reserveFactorLong": "0xc60d94f45a9554d9eb4c63feae3e6b5a7d6313daccf4038f4bb938984aa69a97",
|
|
9464
|
+
"reserveFactorShort": "0xe606e3e47fd4c4bd29e3f61fdd9301f1cf7396e023147a563023c16da06f1083",
|
|
9465
|
+
"openInterestReserveFactorLong": "0xe60a4b0e3705ed0402a03682f59ae1809ec5d2d679edf594eaa1155942d728de",
|
|
9466
|
+
"openInterestReserveFactorShort": "0x712b7bf1d495a61857c51e8c23ccdd06d052b3a2e9686df0215d71f7c9c552da",
|
|
9467
|
+
"maxOpenInterestLong": "0x7388761fd0d12fb1f8b0f31f473caae60a9df600f9659fa15c7bd8e540509966",
|
|
9468
|
+
"maxOpenInterestShort": "0x67f1bedca41d26c3ae76c7f89010d1f84930e5575c232f494c329d203c7eae4f",
|
|
9469
|
+
"maxCollateralSumLongTokenLong": "0xfe8668a848c70540e1200faa33e4fe34babf9e8438c34163ded8ec053c9e952f",
|
|
9470
|
+
"maxCollateralSumLongTokenShort": "0x9dd93fcec5831c9a4675985bad30a72614f4706228c819bbb5d74e86ba15ae1b",
|
|
9471
|
+
"maxCollateralSumShortTokenLong": "0x3d20745153e2b27701b16d142ad7128f6849b127b97b2140918234f62ce76797",
|
|
9472
|
+
"maxCollateralSumShortTokenShort": "0x2f3ce33b3979347bf93ae85fd34b492bf9c08b48b3f3fb0c9c4ffb72aebceffd",
|
|
9473
|
+
"minPositionImpactPoolAmount": "0xcf92f1178e276481c40c1e23faebf1c6509c6575ba415caa9a5c9bb7c8273487",
|
|
9474
|
+
"positionImpactPoolDistributionRate": "0xbec4ca1013993c4498b54625199fa85decadcf1520a07d1d3b08692e6688676a",
|
|
9475
|
+
"borrowingFactorLong": "0x232593027d68e45ddca4f99d55307a76cdc9df12c7778eaf8613f53ab7c0d011",
|
|
9476
|
+
"borrowingFactorShort": "0x3130fb7c1897ccbfdd761ccd071b6a9d75f31477390192e0a9c7fd5083adb1de",
|
|
9477
|
+
"borrowingExponentFactorLong": "0x3d64c8fae99ea0228c56086dbaf7096d40bf9054726b2c47c89ec180366a32c9",
|
|
9478
|
+
"borrowingExponentFactorShort": "0x81a0226774e54b1a0ad5aa90a92b72d154aabfbb20fc8600b524273b52b92a29",
|
|
9479
|
+
"fundingFactor": "0xfc228379b876cebaaeaa2cbfb8d488565a8232c4406f4419790c33eb8d8df79d",
|
|
9480
|
+
"fundingExponentFactor": "0xe7a297e4a41f6961db895227d406b2576059b730b767728c4acb62f817c3066d",
|
|
9481
|
+
"fundingIncreaseFactorPerSecond": "0x09090c4c25f07eecd8c2d23ed6c38398780cd4d5978792001ba7553cab2878ee",
|
|
9482
|
+
"minFundingIncreaseRatePerSecond": "0x464dc07f1cff6d4be3e6dbfd877e95cf6fbad39e33e15a3c8f3f0183f0e1a224",
|
|
9483
|
+
"fundingDecreaseFactorPerSecond": "0x31e0c305e101d81befec502185cbf8110a60d14f2a650eb63dd9e78fdd20d9ed",
|
|
9484
|
+
"thresholdForStableFunding": "0x5339e655149e0cb8fb649e70a50fc515c17d285192a84e03fa6ae24c1dadb7ca",
|
|
9485
|
+
"thresholdForDecreaseFunding": "0x80fc3bde4f933e9c6689cabddf44ee1418d30a96f8681a9e181e96078ad04102",
|
|
9486
|
+
"minFundingFactorPerSecondLong": "0x12c546b722234ebc76bed584d6f75aa3ef03c2d952673e57e0e3f4eb6ef26670",
|
|
9487
|
+
"minFundingFactorPerSecondShort": "0x77fc71543a14e054ce5a9bba437920976d5fcf3db31f9333cb38f807e29e8b1c",
|
|
9488
|
+
"maxFundingFactorPerSecondLong": "0x762944c2cbe7c310aa539f9f08e13c222b3aa0ac4c38dbb549752998810c8f72",
|
|
9489
|
+
"maxFundingFactorPerSecondShort": "0xde090b3ccc73416607d34111d91713dac7d779186957095fb761b06e05c82656",
|
|
9490
|
+
"maxPnlFactorForTradersLong": "0x2b0071abdbe1c7839031c4813b35a8274f27e574be8af291a6a14f5ffb033016",
|
|
9491
|
+
"maxPnlFactorForTradersShort": "0x5daecde43e36b5d919e82244e365ca9a36ec8f9b9ac75044fa8626f58839a771",
|
|
9492
|
+
"maxPnlFactorForDepositsLong": "0xf8851ba6b6b4b87dd9402cd32422bcee649f3c27258f14e361ed9e9a912263bf",
|
|
9493
|
+
"maxPnlFactorForDepositsShort": "0x17b49cda5f46fe93e09b1e6b0a8d4fb460baa58554f83503a4456c31d6ffac93",
|
|
9494
|
+
"maxPnlFactorForWithdrawalsLong": "0xe3399caf96bdc52357e739dac413bfcb824b28ecfb69aa442d5230a3cdda9fca",
|
|
9495
|
+
"maxPnlFactorForWithdrawalsShort": "0xb7fa2fbb0a2a0328a8fb27cb060adea69f738d43d2ad7971727566e98e7657f8",
|
|
9496
|
+
"positionFeeFactorForBalanceWasImproved": "0xee992fe943c8ca91f38830cf68ea346eb7556b72a49bd3b60d959c4f33b5cd77",
|
|
9497
|
+
"positionFeeFactorForBalanceWasNotImproved": "0x0e6d11d25daf124acdce5aa112a6add2c497a5ac9f7e7eb3849ddc6a06c474d1",
|
|
9498
|
+
"positionImpactFactorPositive": "0x270a120255dc81a31bf43df710fcd7c3957bdd3d1b4adf235686e2ae7ecf6ee3",
|
|
9499
|
+
"positionImpactFactorNegative": "0xe2c56eff6ee9c12e305b71d3cdfa57daf21d9671650e0403ba415d8b905017b1",
|
|
9500
|
+
"maxPositionImpactFactorPositive": "0x4ab4b59ba73a674ece8029fc954943fe8fe5053765566cda936081fc74154f3f",
|
|
9501
|
+
"maxPositionImpactFactorNegative": "0x4a284e6070b7dd90d89f5b973ccc988bb8064cdbd97ffea2228cf59f89da0af3",
|
|
9502
|
+
"maxPositionImpactFactorForLiquidations": "0xd3b6f5e2724dd685bc21999de0848e3af5c4e63b06465e4ad6cffd37a6c7aaef",
|
|
9503
|
+
"maxLendableImpactFactor": "0x074ec243e313d8779e8eae068cb6ea8c49d140cfcf1f2a6dfee4c189e0c9d5c7",
|
|
9504
|
+
"maxLendableImpactFactorForWithdrawals": "0x6f04c2189a390b4447c20416c5c309ed32973c9efd3926f7a98dd2bdfe055c12",
|
|
9505
|
+
"maxLendableImpactUsd": "0x2cc05bf42de392bacfe00c0c2f71e60af9e449b3b1ce4da740e7aa9ff349a600",
|
|
9506
|
+
"lentPositionImpactPoolAmount": "0x5bdaf9d541d561f1f81152af6532372ce42caec91d26e74cba755fbb542cc814",
|
|
9507
|
+
"minCollateralFactor": "0xabfa8a283c95ceaa4b99f1b9a535b4bab7fc0725dc3e30a5b48ae5fb074ed85f",
|
|
9508
|
+
"minCollateralFactorForLiquidation": "0x0a7cbfeda1d88520fb47544c6336734f57ffb81ea9c1f8e335e131b9715a7cab",
|
|
9509
|
+
"minCollateralFactorForOpenInterestLong": "0x7088af735400d7042617ee64e46ba59b47cdcb81111ce78575e031300e734ae4",
|
|
9510
|
+
"minCollateralFactorForOpenInterestShort": "0xabc8dc4ff0302dba1ccfc0f8921327817bd0959f40efae01c80ce1de266bf710",
|
|
9511
|
+
"positionImpactExponentFactorPositive": "0x0d13eb47d3ef6617595a8d8fe68992ffce60f9f3ea0a5f2535c7022be19158bf",
|
|
9512
|
+
"positionImpactExponentFactorNegative": "0x44dd6e9027f0a72812eac5e2ca72a6326573c81603ded78419cfb6b5c669e2f8",
|
|
9513
|
+
"swapFeeFactorForBalanceWasImproved": "0xd62e40fa262a7b152c36f1f4f08ce40f29199496dd386bedcb2c169702d65a0e",
|
|
9514
|
+
"swapFeeFactorForBalanceWasNotImproved": "0x1a3e078d4ffe74f215e82da2774e64ce0c950e7e7cf836a58ebb09118684698c",
|
|
9515
|
+
"atomicSwapFeeFactor": "0xec61ecb3c4dac9aa01ef508fcac38c706075e9c16bc631e3c8aeb38782756c64",
|
|
9516
|
+
"swapImpactFactorPositive": "0x93528c1091c2e92c44c53fbf04357a0a82828aba233f18c628f87b98236fa19a",
|
|
9517
|
+
"swapImpactFactorNegative": "0x395f32019c9b3b961ae75a289b0c8d0d1e51ddedc7857e712c7a34c55a0207aa",
|
|
9518
|
+
"swapImpactExponentFactor": "0xf03397ced88afe5c9723f5041a693ff255db7fb199e9ee7ac0ab918f711c941f",
|
|
9519
|
+
"withdrawalFeeFactorBalanceWasImproved": "0x2643dd19d862d9973b45627f7c41faa987f6b36b6e62ac9779bced7a237869ec",
|
|
9520
|
+
"withdrawalFeeFactorBalanceWasNotImproved": "0x6ed50ac3b42d359a194a054aa42680c5dfa739bd127438d9dfc847aba162cd67",
|
|
9521
|
+
"virtualMarketId": "0x5a8e68985e3bad4035c7e275adf4d71706160f1d2a73a2daa48139bf9ece8891",
|
|
9522
|
+
"virtualLongTokenId": "0xaab37f889b9680dda34f58a689de3023cb22f7ae14d32a3c1d45798a973db1f5",
|
|
9523
|
+
"virtualShortTokenId": "0xd5258cb84f0039be58306488e8df941c05f3cf4f219e92aacb6561c736bbb960"
|
|
9524
|
+
},
|
|
9389
9525
|
"0xE26E7b91143f367445f1c0a5dCf4f4aC8EaDcDb1": {
|
|
9390
9526
|
"isDisabled": "0x89d68641baa8443dcff05c06834a08f6a7c1edef759f2e89505fe251b6411cb5",
|
|
9391
9527
|
"maxLongPoolAmount": "0x5c7eb3fb9940700a0eb6d0bc4b2efcec205e4bcd85611f2e63a40fb71b48a68b",
|
|
@@ -2072,6 +2072,36 @@
|
|
|
2072
2072
|
"shortInterestInTokensUsingLongToken": "0x2bdcec38c2d0016c12d50e0ac27709d4856c2d27ffe78e58753e58d3f1ce7570",
|
|
2073
2073
|
"shortInterestInTokensUsingShortToken": "0x8695147e4efe6f8ad95dee38bd50f33fb632c55e6119ee65d8716e8bf683dacd"
|
|
2074
2074
|
},
|
|
2075
|
+
"0x1C132E43029efCd57435eE79ceA98006C6227A6f": {
|
|
2076
|
+
"longPoolAmount": "0x04ba28c1d428785ca8d559f4c65bba05f6161f7dc7958e1ff3a0df890905a72e",
|
|
2077
|
+
"shortPoolAmount": "0xd4a47150ce31a15f022d758a047cf6d8b3c6aceb74437daae43803226bab074d",
|
|
2078
|
+
"positionImpactPoolAmount": "0x4f997c29cc527cf304106ff0903bced0655526ac2df98fa8192f8746ec50f462",
|
|
2079
|
+
"swapImpactPoolAmountLong": "0xd554b3f62ab7aaebbfe68636a413aeb59a6e2fbe4809acef84235ed53ba53a5c",
|
|
2080
|
+
"swapImpactPoolAmountShort": "0x69664a77aad4e26a8e352fc68c9680a3e663daf87282ad49b237c1b99875fc54",
|
|
2081
|
+
"longInterestUsingLongToken": "0xd8cb5755efb2d90d3403d160f2a8caa2b11d977afbb6c890a6d545f22cb7b39a",
|
|
2082
|
+
"longInterestUsingShortToken": "0x3005a9261e358bdc1ca36dabeeb5483985bb94ce71c6f750236aa546c25f0afe",
|
|
2083
|
+
"shortInterestUsingLongToken": "0x3f5dc4bb359a09f1e3409a323b390c9a197aea00d94eaedf6cf30dd1809ecfd9",
|
|
2084
|
+
"shortInterestUsingShortToken": "0x0044f5c9783a74ee4cba0472609718500309e4852eb9f0cf2787017ef9bd06f0",
|
|
2085
|
+
"longInterestInTokensUsingLongToken": "0xb2eacce2fe90a3a5a526230d8e3850e127b3d23a9f008e390323eaa4a895078c",
|
|
2086
|
+
"longInterestInTokensUsingShortToken": "0x5b0ad3fd8de57c88043c7f7b4fa6c5f0efb2f892eb253c7cc521af0667082221",
|
|
2087
|
+
"shortInterestInTokensUsingLongToken": "0xa45dbf6fdb6ba5ad4ff6540224ce765ce2f1541566e25248e2838df6bd659f8a",
|
|
2088
|
+
"shortInterestInTokensUsingShortToken": "0xe87739b6ba68ae3083e1feb5e65bfdae2d1385877ef200fac7e8d09ce37267f4"
|
|
2089
|
+
},
|
|
2090
|
+
"0xcBd4c1b0c89D50793c5A3e8d96d98FcB4f1B1c47": {
|
|
2091
|
+
"longPoolAmount": "0x21c300622c857740cf8a1f319be07b34a1c2a8e3716b842d0e61ddb4de882691",
|
|
2092
|
+
"shortPoolAmount": "0x937d0c760fb4468b954dc9d0cb125a484ab3e5633f7dac271743a5076dd4c6f8",
|
|
2093
|
+
"positionImpactPoolAmount": "0x7e9834d4551dd40bbb82871b26ef7b3dbe829957021f60584b7e39128e824ae4",
|
|
2094
|
+
"swapImpactPoolAmountLong": "0x57144f158bc50b9bbd12758050686be066bcc727f134538e798c2182c51c6d42",
|
|
2095
|
+
"swapImpactPoolAmountShort": "0x7669f2cf4a1f0ce1efbea920e743f19c26ab687e46bf8813af1510f04af3c0d2",
|
|
2096
|
+
"longInterestUsingLongToken": "0x5efe8d6475f96229c37a178a891d8655c0ea9c04462b130ff0cabfa6592da605",
|
|
2097
|
+
"longInterestUsingShortToken": "0x0b0adac4bd44e82b2de9684906a68272282f415a794f5a49ff3d913c72993183",
|
|
2098
|
+
"shortInterestUsingLongToken": "0x14e85b654d64f5aa143e37fea0819dc368f56c326916f2a3c33804c4d8fbb448",
|
|
2099
|
+
"shortInterestUsingShortToken": "0x381d813ff82e2f5baee1ee364a029d13ced94f2b6b33af405bfa3bf09ef46548",
|
|
2100
|
+
"longInterestInTokensUsingLongToken": "0x04480faed28cd2f6f45616ef4560f875108caf003a7b8fcf76210ca6579b6da1",
|
|
2101
|
+
"longInterestInTokensUsingShortToken": "0x1021a26812ae0cd8bc36f8b1aafce4bacdbfb9b28b4f1f716e772ef02bd1a0ea",
|
|
2102
|
+
"shortInterestInTokensUsingLongToken": "0xfaf10fdae0820360c9a66c6055e0122f4eb59d93af838e3bb0f741a82aabf695",
|
|
2103
|
+
"shortInterestInTokensUsingShortToken": "0x65ad9cf74745de0de4ee7c5cef91cbb13cb093a61d1e1642c359f2db0fc313b5"
|
|
2104
|
+
},
|
|
2075
2105
|
"0xE26E7b91143f367445f1c0a5dCf4f4aC8EaDcDb1": {
|
|
2076
2106
|
"longPoolAmount": "0x265452d70a411300a2535b1c9c212a3dcea8eb2793c66aec2fcd595776ba2c0b",
|
|
2077
2107
|
"shortPoolAmount": "0x24f88d54e73a74c9c029fff00404272e44a15d9f931be2df1433f43ef5e5e428",
|
|
@@ -9,6 +9,7 @@ export const DEFAULT_SUBACCOUNT_MAX_ALLOWED_COUNT = 90;
|
|
|
9
9
|
export const DEFAULT_PERMIT_DEADLINE_DURATION = periodToSeconds(1, "1h");
|
|
10
10
|
export const DEFAULT_EXPRESS_ORDER_DEADLINE_DURATION = periodToSeconds(1, "1h");
|
|
11
11
|
export const MIN_RELAYER_FEE_USD = 5n ** BigInt(USD_DECIMALS - 1); // 0.5$
|
|
12
|
+
/** @deprecated Gelato shuts its relay services down on 2026-09-01; use GMX Relay (`sendToGmxRelay`). */
|
|
12
13
|
export const GELATO_API_KEYS = {
|
|
13
14
|
[ARBITRUM]: "6dE6kOa9pc1ap4dQQC2iaK9i6nBFp8eYxQlm00VreWc_",
|
|
14
15
|
[AVALANCHE]: "FalsQh9loL6V0rwPy4gWgnQPR6uTHfWjSVT2qlTzUq4_",
|
|
@@ -946,6 +946,20 @@ export const MARKETS = {
|
|
|
946
946
|
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
|
|
947
947
|
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
948
948
|
},
|
|
949
|
+
// QQQ/USD [WETH-USDC]
|
|
950
|
+
"0x1C132E43029efCd57435eE79ceA98006C6227A6f": {
|
|
951
|
+
marketTokenAddress: "0x1C132E43029efCd57435eE79ceA98006C6227A6f",
|
|
952
|
+
indexTokenAddress: "0xfe71D55D0080b6995Ec2C3f48b7702c86e200766",
|
|
953
|
+
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
|
|
954
|
+
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
955
|
+
},
|
|
956
|
+
// SPY/USD [WETH-USDC]
|
|
957
|
+
"0xcBd4c1b0c89D50793c5A3e8d96d98FcB4f1B1c47": {
|
|
958
|
+
marketTokenAddress: "0xcBd4c1b0c89D50793c5A3e8d96d98FcB4f1B1c47",
|
|
959
|
+
indexTokenAddress: "0x0315441076FF6d3eA09814a2F90a1f980cF03e9e",
|
|
960
|
+
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
|
|
961
|
+
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
962
|
+
},
|
|
949
963
|
// MEGA/USD [WETH-USDC]
|
|
950
964
|
"0xE26E7b91143f367445f1c0a5dCf4f4aC8EaDcDb1": {
|
|
951
965
|
marketTokenAddress: "0xE26E7b91143f367445f1c0a5dCf4f4aC8EaDcDb1",
|
|
@@ -1247,6 +1247,26 @@ export const TOKENS = {
|
|
|
1247
1247
|
searchAliases: ["Space", "X"],
|
|
1248
1248
|
explorerUrl: "https://arbiscan.io/token/0x8CBd0d5d81e7957123E6D8fFaE657a40bDC5691b",
|
|
1249
1249
|
},
|
|
1250
|
+
{
|
|
1251
|
+
name: "Invesco QQQ Trust",
|
|
1252
|
+
symbol: "QQQ",
|
|
1253
|
+
address: "0xfe71D55D0080b6995Ec2C3f48b7702c86e200766",
|
|
1254
|
+
isSynthetic: true,
|
|
1255
|
+
decimals: 18,
|
|
1256
|
+
categories: ["tradfi", "indices"],
|
|
1257
|
+
searchAliases: ["Nasdaq", "Nasdaq-100", "NDX", "Invesco"],
|
|
1258
|
+
explorerUrl: "https://arbiscan.io/token/0xfe71D55D0080b6995Ec2C3f48b7702c86e200766",
|
|
1259
|
+
},
|
|
1260
|
+
{
|
|
1261
|
+
name: "SPDR S&P 500 ETF",
|
|
1262
|
+
symbol: "SPY",
|
|
1263
|
+
address: "0x0315441076FF6d3eA09814a2F90a1f980cF03e9e",
|
|
1264
|
+
isSynthetic: true,
|
|
1265
|
+
decimals: 18,
|
|
1266
|
+
categories: ["tradfi", "indices"],
|
|
1267
|
+
searchAliases: ["S&P", "S&P 500", "SPX", "SPDR"],
|
|
1268
|
+
explorerUrl: "https://arbiscan.io/token/0x0315441076FF6d3eA09814a2F90a1f980cF03e9e",
|
|
1269
|
+
},
|
|
1250
1270
|
{
|
|
1251
1271
|
name: "MegaETH",
|
|
1252
1272
|
symbol: "MEGA",
|
|
@@ -1995,6 +2015,8 @@ export const TOKEN_COLOR_MAP = {
|
|
|
1995
2015
|
GOLD: "#D69A00",
|
|
1996
2016
|
SILVER: "#ADABB8",
|
|
1997
2017
|
SPCX: "#1A1E21",
|
|
2018
|
+
QQQ: "#000AD2",
|
|
2019
|
+
SPY: "#273F33",
|
|
1998
2020
|
XPT: "#C2B8AB",
|
|
1999
2021
|
XPD: "#A9ACB6",
|
|
2000
2022
|
default: "#6062a6",
|
|
@@ -9,6 +9,7 @@ export class GelatoRelayError extends Error {
|
|
|
9
9
|
this.name = "GelatoRelayError";
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
+
/** @deprecated Gelato shuts its relay services down on 2026-09-01; use `sendToGmxRelay`. */
|
|
12
13
|
export async function sendToGelatoRelay({ chainId, txnData, }) {
|
|
13
14
|
const data = encodePacked(["bytes", "address", "address", "uint256"], [txnData.callData, txnData.to, txnData.feeToken, txnData.feeAmount]);
|
|
14
15
|
const apiKey = GELATO_API_KEYS[chainId];
|
|
@@ -32,6 +33,7 @@ export async function sendToGelatoRelay({ chainId, txnData, }) {
|
|
|
32
33
|
}
|
|
33
34
|
return { taskId, relayerClient };
|
|
34
35
|
}
|
|
36
|
+
/** @deprecated Gelato shuts its relay services down on 2026-09-01; use `waitForGmxRelayTask`. */
|
|
35
37
|
export async function waitForGelatoTask(relayerClient, taskId, options) {
|
|
36
38
|
try {
|
|
37
39
|
const receipt = await relayerClient.waitForReceipt({
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { getApiUrl } from "../../../configs/api";
|
|
2
|
+
import { buildUrl } from "../../buildUrl";
|
|
3
|
+
import { sleep } from "../../common";
|
|
4
|
+
import { HttpError } from "../../http/http";
|
|
5
|
+
const SUBMIT_TIMEOUT_MS = 15000;
|
|
6
|
+
const STATUS_TIMEOUT_MS = 10000;
|
|
7
|
+
const WAIT_TIMEOUT_MS = 120000;
|
|
8
|
+
const POLLING_INTERVAL_MS = 1000;
|
|
9
|
+
export class GmxRelayError extends HttpError {
|
|
10
|
+
constructor(message, httpStatus, cause) {
|
|
11
|
+
// statusCode 0 marks a transport failure that never got an HTTP answer
|
|
12
|
+
super(httpStatus ?? 0, message);
|
|
13
|
+
this.cause = cause;
|
|
14
|
+
this.name = "GmxRelayError";
|
|
15
|
+
}
|
|
16
|
+
get isPermanent() {
|
|
17
|
+
return this.statusCode >= 400 && this.statusCode < 500 && this.statusCode !== 429;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export function isPermanentRelayError(error) {
|
|
21
|
+
return error instanceof GmxRelayError && error.isPermanent;
|
|
22
|
+
}
|
|
23
|
+
export async function sendToGmxRelay({ chainId, txnData, apiUrl, }) {
|
|
24
|
+
// bare relay-router calldata: the fee is computed on-chain, so no Gelato fee suffix is appended
|
|
25
|
+
const result = await post(resolveApiUrl(chainId, apiUrl), "/v1/relay/submit", { to: txnData.to, data: txnData.callData }, SUBMIT_TIMEOUT_MS);
|
|
26
|
+
if (!result.taskId) {
|
|
27
|
+
throw new GmxRelayError("GMX Relay returned no taskId");
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
export function getGmxRelayTaskStatus({ chainId, taskId, apiUrl, }) {
|
|
32
|
+
return post(resolveApiUrl(chainId, apiUrl), "/v1/relay/status", { taskId }, STATUS_TIMEOUT_MS);
|
|
33
|
+
}
|
|
34
|
+
export async function waitForGmxRelayTask({ chainId, taskId, apiUrl, timeout = WAIT_TIMEOUT_MS, pollingInterval = POLLING_INTERVAL_MS, }) {
|
|
35
|
+
const deadline = Date.now() + timeout;
|
|
36
|
+
// eslint-disable-next-line no-constant-condition
|
|
37
|
+
while (true) {
|
|
38
|
+
let view;
|
|
39
|
+
try {
|
|
40
|
+
view = await getGmxRelayTaskStatus({ chainId, taskId, apiUrl });
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
// a 404 is transient here: the task can be accepted a moment before its status becomes readable
|
|
44
|
+
const error = e instanceof GmxRelayError ? e : new GmxRelayError(String(e));
|
|
45
|
+
if (error.isPermanent && error.statusCode !== 404) {
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
if (Date.now() + pollingInterval >= deadline) {
|
|
49
|
+
return {
|
|
50
|
+
transactionHash: undefined,
|
|
51
|
+
status: "pending",
|
|
52
|
+
relayStatus: "unknown",
|
|
53
|
+
message: `Could not read the relay operation's status: ${error.message}`,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
await sleep(pollingInterval);
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (view.status !== "pending") {
|
|
60
|
+
return {
|
|
61
|
+
transactionHash: view.txHash,
|
|
62
|
+
// relay `unknown` means it could not determine the outcome, so it must not map to failure
|
|
63
|
+
status: view.status === "executed" ? "success" : view.status === "unknown" ? "pending" : "failed",
|
|
64
|
+
relayStatus: view.status,
|
|
65
|
+
message: view.reason,
|
|
66
|
+
revertData: view.revertData,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
if (Date.now() + pollingInterval >= deadline) {
|
|
70
|
+
return {
|
|
71
|
+
transactionHash: view.txHash,
|
|
72
|
+
status: "pending",
|
|
73
|
+
relayStatus: view.status,
|
|
74
|
+
message: "Timed out waiting for the relay operation to land",
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
await sleep(pollingInterval);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function resolveApiUrl(chainId, apiUrl) {
|
|
81
|
+
const url = apiUrl ?? getApiUrl(chainId);
|
|
82
|
+
if (!url) {
|
|
83
|
+
throw new GmxRelayError(`GMX API url is not configured for chain ${chainId}`);
|
|
84
|
+
}
|
|
85
|
+
return url;
|
|
86
|
+
}
|
|
87
|
+
async function post(baseUrl, path, body, timeout) {
|
|
88
|
+
const controller = new AbortController();
|
|
89
|
+
const timer = setTimeout(() => controller.abort(), timeout);
|
|
90
|
+
// bespoke fetch rather than postJson: the trace id arrives in a response header on refusals,
|
|
91
|
+
// and the shared client only surfaces parsed bodies
|
|
92
|
+
// the timer must also cover the body read: a response that stalls after its headers would hang forever
|
|
93
|
+
try {
|
|
94
|
+
const response = await fetch(buildUrl(baseUrl, path), {
|
|
95
|
+
method: "POST",
|
|
96
|
+
headers: { "Content-Type": "application/json" },
|
|
97
|
+
body: JSON.stringify(body),
|
|
98
|
+
signal: controller.signal,
|
|
99
|
+
});
|
|
100
|
+
if (!response.ok) {
|
|
101
|
+
const text = await response.text().catch(() => "");
|
|
102
|
+
const error = new GmxRelayError(`GMX Relay ${path} failed: ${extractMessage(text) ?? response.statusText}`, response.status);
|
|
103
|
+
// a request refused before it was relayed never gets a taskId; the trace id is the only handle left
|
|
104
|
+
const traceId = response.headers.get("X-Trace-Id");
|
|
105
|
+
if (traceId) {
|
|
106
|
+
error.traceId = traceId;
|
|
107
|
+
error.data = { traceId };
|
|
108
|
+
}
|
|
109
|
+
throw error;
|
|
110
|
+
}
|
|
111
|
+
try {
|
|
112
|
+
return (await response.json());
|
|
113
|
+
}
|
|
114
|
+
catch (e) {
|
|
115
|
+
throw new GmxRelayError(`GMX Relay ${path} returned an unreadable body`, response.status, e);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
catch (e) {
|
|
119
|
+
if (e instanceof GmxRelayError) {
|
|
120
|
+
throw e;
|
|
121
|
+
}
|
|
122
|
+
throw new GmxRelayError(`GMX Relay request failed: ${e?.message ?? String(e)}`, undefined, e);
|
|
123
|
+
}
|
|
124
|
+
finally {
|
|
125
|
+
clearTimeout(timer);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function extractMessage(text) {
|
|
129
|
+
try {
|
|
130
|
+
const parsed = JSON.parse(text);
|
|
131
|
+
return parsed?.message ?? parsed?.error;
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
// a non-JSON body is an edge's HTML error page, not a message to surface to a user
|
|
135
|
+
return undefined;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { ARBITRUM } from "../../../configs/chains";
|
|
3
|
+
import { GmxRelayError, getGmxRelayTaskStatus, isPermanentRelayError, sendToGmxRelay, waitForGmxRelayTask, } from "./gmxRelayUtils";
|
|
4
|
+
const TASK_ID = `0x${"ab".repeat(32)}`;
|
|
5
|
+
const TXN_DATA = {
|
|
6
|
+
callData: "0xdeadbeef",
|
|
7
|
+
to: "0x0000000000000000000000000000000000000001",
|
|
8
|
+
feeToken: "0x0000000000000000000000000000000000000002",
|
|
9
|
+
feeAmount: 123n,
|
|
10
|
+
};
|
|
11
|
+
function jsonResponse(body, status = 200) {
|
|
12
|
+
return new Response(JSON.stringify(body), { status, headers: { "Content-Type": "application/json" } });
|
|
13
|
+
}
|
|
14
|
+
describe("sendToGmxRelay", () => {
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
vi.unstubAllGlobals();
|
|
17
|
+
});
|
|
18
|
+
it("carries the API's trace id on a refusal", async () => {
|
|
19
|
+
vi.stubGlobal("fetch", vi.fn(async () => new Response(JSON.stringify({ message: "nope" }), {
|
|
20
|
+
status: 400,
|
|
21
|
+
headers: { "Content-Type": "application/json", "X-Trace-Id": "tr-1" },
|
|
22
|
+
})));
|
|
23
|
+
const error = await sendToGmxRelay({ chainId: ARBITRUM, txnData: TXN_DATA }).catch((e) => e);
|
|
24
|
+
expect(error).toBeInstanceOf(GmxRelayError);
|
|
25
|
+
expect(error.data).toEqual({ traceId: "tr-1" });
|
|
26
|
+
});
|
|
27
|
+
it("posts bare calldata without the Gelato fee suffix", async () => {
|
|
28
|
+
const fetchMock = vi.fn(async () => jsonResponse({ taskId: TASK_ID, status: "pending" }));
|
|
29
|
+
vi.stubGlobal("fetch", fetchMock);
|
|
30
|
+
const result = await sendToGmxRelay({ chainId: ARBITRUM, txnData: TXN_DATA });
|
|
31
|
+
expect(result).toEqual({ taskId: TASK_ID, status: "pending" });
|
|
32
|
+
const [url, init] = fetchMock.mock.calls[0];
|
|
33
|
+
expect(url).toContain("/v1/relay/submit");
|
|
34
|
+
expect(JSON.parse(String(init.body))).toEqual({ to: TXN_DATA.to, data: TXN_DATA.callData });
|
|
35
|
+
});
|
|
36
|
+
it("honours an explicit api url", async () => {
|
|
37
|
+
const fetchMock = vi.fn(async () => jsonResponse({ taskId: TASK_ID, status: "pending" }));
|
|
38
|
+
vi.stubGlobal("fetch", fetchMock);
|
|
39
|
+
await sendToGmxRelay({ chainId: ARBITRUM, txnData: TXN_DATA, apiUrl: "https://api.example.com/" });
|
|
40
|
+
const [url] = fetchMock.mock.calls[0];
|
|
41
|
+
expect(url).toBe("https://api.example.com/v1/relay/submit");
|
|
42
|
+
});
|
|
43
|
+
it("raises a permanent error when the api rejects the operation", async () => {
|
|
44
|
+
vi.stubGlobal("fetch", vi.fn(async () => jsonResponse({ message: "to is not an allowlisted relay router" }, 400)));
|
|
45
|
+
const error = await sendToGmxRelay({ chainId: ARBITRUM, txnData: TXN_DATA }).catch((e) => e);
|
|
46
|
+
expect(error).toBeInstanceOf(GmxRelayError);
|
|
47
|
+
expect(error.message).toContain("allowlisted relay router");
|
|
48
|
+
expect(isPermanentRelayError(error)).toBe(true);
|
|
49
|
+
});
|
|
50
|
+
it("treats a rate-limited response as retryable rather than permanent", async () => {
|
|
51
|
+
vi.stubGlobal("fetch", vi.fn(async () => jsonResponse({ message: "slow down" }, 429)));
|
|
52
|
+
const error = await sendToGmxRelay({ chainId: ARBITRUM, txnData: TXN_DATA }).catch((e) => e);
|
|
53
|
+
expect(isPermanentRelayError(error)).toBe(false);
|
|
54
|
+
});
|
|
55
|
+
it("keeps a transport failure retryable", async () => {
|
|
56
|
+
vi.stubGlobal("fetch", vi.fn(async () => {
|
|
57
|
+
throw new Error("network down");
|
|
58
|
+
}));
|
|
59
|
+
const error = await sendToGmxRelay({ chainId: ARBITRUM, txnData: TXN_DATA }).catch((e) => e);
|
|
60
|
+
expect(error).toBeInstanceOf(GmxRelayError);
|
|
61
|
+
expect(isPermanentRelayError(error)).toBe(false);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
describe("getGmxRelayTaskStatus", () => {
|
|
65
|
+
afterEach(() => {
|
|
66
|
+
vi.unstubAllGlobals();
|
|
67
|
+
});
|
|
68
|
+
it("posts the taskId and returns the status view", async () => {
|
|
69
|
+
const fetchMock = vi.fn(async () => jsonResponse({ taskId: TASK_ID, status: "executed", txHash: "0xhash" }));
|
|
70
|
+
vi.stubGlobal("fetch", fetchMock);
|
|
71
|
+
const view = await getGmxRelayTaskStatus({ chainId: ARBITRUM, taskId: TASK_ID });
|
|
72
|
+
expect(view.status).toBe("executed");
|
|
73
|
+
const [url, init] = fetchMock.mock.calls[0];
|
|
74
|
+
expect(url).toContain("/v1/relay/status");
|
|
75
|
+
expect(JSON.parse(String(init.body))).toEqual({ taskId: TASK_ID });
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
describe("waitForGmxRelayTask", () => {
|
|
79
|
+
afterEach(() => {
|
|
80
|
+
vi.unstubAllGlobals();
|
|
81
|
+
});
|
|
82
|
+
it("polls until the operation leaves the pending state", async () => {
|
|
83
|
+
let call = 0;
|
|
84
|
+
vi.stubGlobal("fetch", vi.fn(async () => {
|
|
85
|
+
call++;
|
|
86
|
+
return call < 3
|
|
87
|
+
? jsonResponse({ taskId: TASK_ID, status: "pending" })
|
|
88
|
+
: jsonResponse({ taskId: TASK_ID, status: "executed", txHash: "0xhash" });
|
|
89
|
+
}));
|
|
90
|
+
const result = await waitForGmxRelayTask({ chainId: ARBITRUM, taskId: TASK_ID, pollingInterval: 1 });
|
|
91
|
+
expect(result.status).toBe("success");
|
|
92
|
+
expect(result.transactionHash).toBe("0xhash");
|
|
93
|
+
expect(call).toBe(3);
|
|
94
|
+
});
|
|
95
|
+
it("keeps polling through a transient status failure", async () => {
|
|
96
|
+
let call = 0;
|
|
97
|
+
vi.stubGlobal("fetch", vi.fn(async () => {
|
|
98
|
+
call++;
|
|
99
|
+
if (call === 1)
|
|
100
|
+
throw new Error("network blip");
|
|
101
|
+
if (call === 2)
|
|
102
|
+
return jsonResponse({ message: "upstream" }, 503);
|
|
103
|
+
if (call === 3)
|
|
104
|
+
return jsonResponse({ message: "no relay operation" }, 404);
|
|
105
|
+
return jsonResponse({ taskId: TASK_ID, status: "executed", txHash: "0xhash" });
|
|
106
|
+
}));
|
|
107
|
+
const result = await waitForGmxRelayTask({ chainId: ARBITRUM, taskId: TASK_ID, pollingInterval: 1 });
|
|
108
|
+
expect(result.status).toBe("success");
|
|
109
|
+
expect(result.transactionHash).toBe("0xhash");
|
|
110
|
+
expect(call).toBe(4);
|
|
111
|
+
});
|
|
112
|
+
it("gives up immediately when the status request itself is rejected", async () => {
|
|
113
|
+
const fetchMock = vi.fn(async () => jsonResponse({ message: "taskId must be a 32-byte hex string" }, 400));
|
|
114
|
+
vi.stubGlobal("fetch", fetchMock);
|
|
115
|
+
const error = await waitForGmxRelayTask({ chainId: ARBITRUM, taskId: TASK_ID, pollingInterval: 1 }).catch((e) => e);
|
|
116
|
+
expect(error).toBeInstanceOf(GmxRelayError);
|
|
117
|
+
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
118
|
+
});
|
|
119
|
+
it("reports an unresolved status rather than a failure when the window closes on errors", async () => {
|
|
120
|
+
vi.stubGlobal("fetch", vi.fn(async () => jsonResponse({ message: "upstream" }, 503)));
|
|
121
|
+
const result = await waitForGmxRelayTask({
|
|
122
|
+
chainId: ARBITRUM,
|
|
123
|
+
taskId: TASK_ID,
|
|
124
|
+
pollingInterval: 1,
|
|
125
|
+
timeout: 5,
|
|
126
|
+
});
|
|
127
|
+
expect(result.status).toBe("pending");
|
|
128
|
+
expect(result.message).toContain("Could not read");
|
|
129
|
+
});
|
|
130
|
+
it("reports a revert as a failure carrying the reason and the raw revert bytes", async () => {
|
|
131
|
+
vi.stubGlobal("fetch", vi.fn(async () => jsonResponse({
|
|
132
|
+
taskId: TASK_ID,
|
|
133
|
+
status: "reverted",
|
|
134
|
+
txHash: "0xhash",
|
|
135
|
+
reason: "InsufficientRelayFee",
|
|
136
|
+
revertData: "0x08c379a0deadbeef",
|
|
137
|
+
})));
|
|
138
|
+
const result = await waitForGmxRelayTask({ chainId: ARBITRUM, taskId: TASK_ID, pollingInterval: 1 });
|
|
139
|
+
expect(result.status).toBe("failed");
|
|
140
|
+
expect(result.relayStatus).toBe("reverted");
|
|
141
|
+
expect(result.message).toBe("InsufficientRelayFee");
|
|
142
|
+
expect(result.revertData).toBe("0x08c379a0deadbeef");
|
|
143
|
+
});
|
|
144
|
+
it("never resolves an undetermined outcome as success or failure", async () => {
|
|
145
|
+
vi.stubGlobal("fetch", vi.fn(async () => jsonResponse({ taskId: TASK_ID, status: "unknown", txHash: "0xhash" })));
|
|
146
|
+
const result = await waitForGmxRelayTask({ chainId: ARBITRUM, taskId: TASK_ID, pollingInterval: 1 });
|
|
147
|
+
expect(result.status).toBe("pending");
|
|
148
|
+
expect(result.relayStatus).toBe("unknown");
|
|
149
|
+
});
|
|
150
|
+
it("gives up as pending once the wait window elapses", async () => {
|
|
151
|
+
vi.stubGlobal("fetch", vi.fn(async () => jsonResponse({ taskId: TASK_ID, status: "pending" })));
|
|
152
|
+
const result = await waitForGmxRelayTask({
|
|
153
|
+
chainId: ARBITRUM,
|
|
154
|
+
taskId: TASK_ID,
|
|
155
|
+
timeout: 5,
|
|
156
|
+
pollingInterval: 10,
|
|
157
|
+
});
|
|
158
|
+
expect(result.status).toBe("pending");
|
|
159
|
+
expect(result.message).toMatch(/Timed out/);
|
|
160
|
+
});
|
|
161
|
+
});
|
|
@@ -3,6 +3,7 @@ export * from "./oracleParamsUtils";
|
|
|
3
3
|
export * from "./relayParamsUtils";
|
|
4
4
|
export * from "./batchOrderUtils";
|
|
5
5
|
export * from "./gelatoRelayUtils";
|
|
6
|
+
export * from "./gmxRelayUtils";
|
|
6
7
|
export * from "./globalExpressParams";
|
|
7
8
|
export * from "./expressParamsUtils";
|
|
8
9
|
export * from "./estimateExpressParams";
|
|
@@ -114,6 +114,9 @@ export function createRawTradeActionTransformer(marketsInfoData, wrappedToken, t
|
|
|
114
114
|
? parseContractPrice(BigInt(rawAction.indexTokenPriceMax), indexToken.decimals)
|
|
115
115
|
: undefined,
|
|
116
116
|
orderType,
|
|
117
|
+
decreasePositionSwapType: rawAction.decreasePositionSwapType === null || rawAction.decreasePositionSwapType === undefined
|
|
118
|
+
? undefined
|
|
119
|
+
: Number(rawAction.decreasePositionSwapType),
|
|
117
120
|
orderKey: rawAction.orderKey,
|
|
118
121
|
isLong: rawAction.isLong,
|
|
119
122
|
pnlUsd: rawAction.pnlUsd ? BigInt(rawAction.pnlUsd) : undefined,
|