@gmx-io/sdk 1.7.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/clients/v2/index.js +4 -0
- 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/cjs/src/utils/yield/api.js +13 -0
- package/build/cjs/src/utils/yield/types.js +2 -0
- package/build/esm/src/clients/v2/index.js +4 -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/esm/src/utils/yield/api.js +9 -0
- package/build/esm/src/utils/yield/types.js +1 -0
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/types/src/clients/v2/index.d.ts +3 -0
- 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/build/types/src/utils/yield/api.d.ts +5 -0
- package/build/types/src/utils/yield/types.d.ts +29 -0
- package/package.json +1 -1
|
@@ -26,6 +26,7 @@ const api_15 = require("../../utils/subaccount/api");
|
|
|
26
26
|
const sdkClient_1 = require("../../utils/subaccount/sdkClient");
|
|
27
27
|
const api_16 = require("../../utils/tokens/api");
|
|
28
28
|
const api_17 = require("../../utils/trades/api");
|
|
29
|
+
const api_18 = require("../../utils/yield/api");
|
|
29
30
|
var signer_1 = require("../../utils/signer");
|
|
30
31
|
Object.defineProperty(exports, "PrivateKeySigner", { enumerable: true, get: function () { return signer_1.PrivateKeySigner; } });
|
|
31
32
|
var http_2 = require("../../utils/http/http");
|
|
@@ -129,6 +130,9 @@ class GmxApiSdk {
|
|
|
129
130
|
fetchPerformanceSnapshots(params) {
|
|
130
131
|
return (0, api_10.fetchApiPerformanceSnapshots)(this.ctx, params);
|
|
131
132
|
}
|
|
133
|
+
fetchGmPoolYieldPnl(params) {
|
|
134
|
+
return (0, api_18.fetchApiGmPoolYieldPnl)(this.ctx, params);
|
|
135
|
+
}
|
|
132
136
|
fetchBuybackWeeklyStats() {
|
|
133
137
|
return (0, api_4.fetchApiBuybackWeeklyStats)(this.ctx);
|
|
134
138
|
}
|
|
@@ -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",
|
|
@@ -12,6 +12,7 @@ exports.DEFAULT_SUBACCOUNT_MAX_ALLOWED_COUNT = 90;
|
|
|
12
12
|
exports.DEFAULT_PERMIT_DEADLINE_DURATION = (0, time_1.periodToSeconds)(1, "1h");
|
|
13
13
|
exports.DEFAULT_EXPRESS_ORDER_DEADLINE_DURATION = (0, time_1.periodToSeconds)(1, "1h");
|
|
14
14
|
exports.MIN_RELAYER_FEE_USD = 5n ** BigInt(numbers_1.USD_DECIMALS - 1); // 0.5$
|
|
15
|
+
/** @deprecated Gelato shuts its relay services down on 2026-09-01; use GMX Relay (`sendToGmxRelay`). */
|
|
15
16
|
exports.GELATO_API_KEYS = {
|
|
16
17
|
[chains_1.ARBITRUM]: "6dE6kOa9pc1ap4dQQC2iaK9i6nBFp8eYxQlm00VreWc_",
|
|
17
18
|
[chains_1.AVALANCHE]: "FalsQh9loL6V0rwPy4gWgnQPR6uTHfWjSVT2qlTzUq4_",
|
|
@@ -949,6 +949,20 @@ exports.MARKETS = {
|
|
|
949
949
|
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
|
|
950
950
|
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
951
951
|
},
|
|
952
|
+
// QQQ/USD [WETH-USDC]
|
|
953
|
+
"0x1C132E43029efCd57435eE79ceA98006C6227A6f": {
|
|
954
|
+
marketTokenAddress: "0x1C132E43029efCd57435eE79ceA98006C6227A6f",
|
|
955
|
+
indexTokenAddress: "0xfe71D55D0080b6995Ec2C3f48b7702c86e200766",
|
|
956
|
+
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
|
|
957
|
+
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
958
|
+
},
|
|
959
|
+
// SPY/USD [WETH-USDC]
|
|
960
|
+
"0xcBd4c1b0c89D50793c5A3e8d96d98FcB4f1B1c47": {
|
|
961
|
+
marketTokenAddress: "0xcBd4c1b0c89D50793c5A3e8d96d98FcB4f1B1c47",
|
|
962
|
+
indexTokenAddress: "0x0315441076FF6d3eA09814a2F90a1f980cF03e9e",
|
|
963
|
+
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
|
|
964
|
+
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
965
|
+
},
|
|
952
966
|
// MEGA/USD [WETH-USDC]
|
|
953
967
|
"0xE26E7b91143f367445f1c0a5dCf4f4aC8EaDcDb1": {
|
|
954
968
|
marketTokenAddress: "0xE26E7b91143f367445f1c0a5dCf4f4aC8EaDcDb1",
|
|
@@ -1250,6 +1250,26 @@ exports.TOKENS = {
|
|
|
1250
1250
|
searchAliases: ["Space", "X"],
|
|
1251
1251
|
explorerUrl: "https://arbiscan.io/token/0x8CBd0d5d81e7957123E6D8fFaE657a40bDC5691b",
|
|
1252
1252
|
},
|
|
1253
|
+
{
|
|
1254
|
+
name: "Invesco QQQ Trust",
|
|
1255
|
+
symbol: "QQQ",
|
|
1256
|
+
address: "0xfe71D55D0080b6995Ec2C3f48b7702c86e200766",
|
|
1257
|
+
isSynthetic: true,
|
|
1258
|
+
decimals: 18,
|
|
1259
|
+
categories: ["tradfi", "indices"],
|
|
1260
|
+
searchAliases: ["Nasdaq", "Nasdaq-100", "NDX", "Invesco"],
|
|
1261
|
+
explorerUrl: "https://arbiscan.io/token/0xfe71D55D0080b6995Ec2C3f48b7702c86e200766",
|
|
1262
|
+
},
|
|
1263
|
+
{
|
|
1264
|
+
name: "SPDR S&P 500 ETF",
|
|
1265
|
+
symbol: "SPY",
|
|
1266
|
+
address: "0x0315441076FF6d3eA09814a2F90a1f980cF03e9e",
|
|
1267
|
+
isSynthetic: true,
|
|
1268
|
+
decimals: 18,
|
|
1269
|
+
categories: ["tradfi", "indices"],
|
|
1270
|
+
searchAliases: ["S&P", "S&P 500", "SPX", "SPDR"],
|
|
1271
|
+
explorerUrl: "https://arbiscan.io/token/0x0315441076FF6d3eA09814a2F90a1f980cF03e9e",
|
|
1272
|
+
},
|
|
1253
1273
|
{
|
|
1254
1274
|
name: "MegaETH",
|
|
1255
1275
|
symbol: "MEGA",
|
|
@@ -1998,6 +2018,8 @@ exports.TOKEN_COLOR_MAP = {
|
|
|
1998
2018
|
GOLD: "#D69A00",
|
|
1999
2019
|
SILVER: "#ADABB8",
|
|
2000
2020
|
SPCX: "#1A1E21",
|
|
2021
|
+
QQQ: "#000AD2",
|
|
2022
|
+
SPY: "#273F33",
|
|
2001
2023
|
XPT: "#C2B8AB",
|
|
2002
2024
|
XPD: "#A9ACB6",
|
|
2003
2025
|
default: "#6062a6",
|
|
@@ -13,6 +13,7 @@ class GelatoRelayError extends Error {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
exports.GelatoRelayError = GelatoRelayError;
|
|
16
|
+
/** @deprecated Gelato shuts its relay services down on 2026-09-01; use `sendToGmxRelay`. */
|
|
16
17
|
async function sendToGelatoRelay({ chainId, txnData, }) {
|
|
17
18
|
const data = (0, viem_1.encodePacked)(["bytes", "address", "address", "uint256"], [txnData.callData, txnData.to, txnData.feeToken, txnData.feeAmount]);
|
|
18
19
|
const apiKey = express_1.GELATO_API_KEYS[chainId];
|
|
@@ -37,6 +38,7 @@ async function sendToGelatoRelay({ chainId, txnData, }) {
|
|
|
37
38
|
return { taskId, relayerClient };
|
|
38
39
|
}
|
|
39
40
|
exports.sendToGelatoRelay = sendToGelatoRelay;
|
|
41
|
+
/** @deprecated Gelato shuts its relay services down on 2026-09-01; use `waitForGmxRelayTask`. */
|
|
40
42
|
async function waitForGelatoTask(relayerClient, taskId, options) {
|
|
41
43
|
try {
|
|
42
44
|
const receipt = await relayerClient.waitForReceipt({
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.waitForGmxRelayTask = exports.getGmxRelayTaskStatus = exports.sendToGmxRelay = exports.isPermanentRelayError = exports.GmxRelayError = void 0;
|
|
4
|
+
const api_1 = require("../../../configs/api");
|
|
5
|
+
const buildUrl_1 = require("../../buildUrl");
|
|
6
|
+
const common_1 = require("../../common");
|
|
7
|
+
const http_1 = require("../../http/http");
|
|
8
|
+
const SUBMIT_TIMEOUT_MS = 15000;
|
|
9
|
+
const STATUS_TIMEOUT_MS = 10000;
|
|
10
|
+
const WAIT_TIMEOUT_MS = 120000;
|
|
11
|
+
const POLLING_INTERVAL_MS = 1000;
|
|
12
|
+
class GmxRelayError extends http_1.HttpError {
|
|
13
|
+
constructor(message, httpStatus, cause) {
|
|
14
|
+
// statusCode 0 marks a transport failure that never got an HTTP answer
|
|
15
|
+
super(httpStatus ?? 0, message);
|
|
16
|
+
this.cause = cause;
|
|
17
|
+
this.name = "GmxRelayError";
|
|
18
|
+
}
|
|
19
|
+
get isPermanent() {
|
|
20
|
+
return this.statusCode >= 400 && this.statusCode < 500 && this.statusCode !== 429;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.GmxRelayError = GmxRelayError;
|
|
24
|
+
function isPermanentRelayError(error) {
|
|
25
|
+
return error instanceof GmxRelayError && error.isPermanent;
|
|
26
|
+
}
|
|
27
|
+
exports.isPermanentRelayError = isPermanentRelayError;
|
|
28
|
+
async function sendToGmxRelay({ chainId, txnData, apiUrl, }) {
|
|
29
|
+
// bare relay-router calldata: the fee is computed on-chain, so no Gelato fee suffix is appended
|
|
30
|
+
const result = await post(resolveApiUrl(chainId, apiUrl), "/v1/relay/submit", { to: txnData.to, data: txnData.callData }, SUBMIT_TIMEOUT_MS);
|
|
31
|
+
if (!result.taskId) {
|
|
32
|
+
throw new GmxRelayError("GMX Relay returned no taskId");
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
exports.sendToGmxRelay = sendToGmxRelay;
|
|
37
|
+
function getGmxRelayTaskStatus({ chainId, taskId, apiUrl, }) {
|
|
38
|
+
return post(resolveApiUrl(chainId, apiUrl), "/v1/relay/status", { taskId }, STATUS_TIMEOUT_MS);
|
|
39
|
+
}
|
|
40
|
+
exports.getGmxRelayTaskStatus = getGmxRelayTaskStatus;
|
|
41
|
+
async function waitForGmxRelayTask({ chainId, taskId, apiUrl, timeout = WAIT_TIMEOUT_MS, pollingInterval = POLLING_INTERVAL_MS, }) {
|
|
42
|
+
const deadline = Date.now() + timeout;
|
|
43
|
+
// eslint-disable-next-line no-constant-condition
|
|
44
|
+
while (true) {
|
|
45
|
+
let view;
|
|
46
|
+
try {
|
|
47
|
+
view = await getGmxRelayTaskStatus({ chainId, taskId, apiUrl });
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
// a 404 is transient here: the task can be accepted a moment before its status becomes readable
|
|
51
|
+
const error = e instanceof GmxRelayError ? e : new GmxRelayError(String(e));
|
|
52
|
+
if (error.isPermanent && error.statusCode !== 404) {
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
if (Date.now() + pollingInterval >= deadline) {
|
|
56
|
+
return {
|
|
57
|
+
transactionHash: undefined,
|
|
58
|
+
status: "pending",
|
|
59
|
+
relayStatus: "unknown",
|
|
60
|
+
message: `Could not read the relay operation's status: ${error.message}`,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
await (0, common_1.sleep)(pollingInterval);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (view.status !== "pending") {
|
|
67
|
+
return {
|
|
68
|
+
transactionHash: view.txHash,
|
|
69
|
+
// relay `unknown` means it could not determine the outcome, so it must not map to failure
|
|
70
|
+
status: view.status === "executed" ? "success" : view.status === "unknown" ? "pending" : "failed",
|
|
71
|
+
relayStatus: view.status,
|
|
72
|
+
message: view.reason,
|
|
73
|
+
revertData: view.revertData,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
if (Date.now() + pollingInterval >= deadline) {
|
|
77
|
+
return {
|
|
78
|
+
transactionHash: view.txHash,
|
|
79
|
+
status: "pending",
|
|
80
|
+
relayStatus: view.status,
|
|
81
|
+
message: "Timed out waiting for the relay operation to land",
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
await (0, common_1.sleep)(pollingInterval);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.waitForGmxRelayTask = waitForGmxRelayTask;
|
|
88
|
+
function resolveApiUrl(chainId, apiUrl) {
|
|
89
|
+
const url = apiUrl ?? (0, api_1.getApiUrl)(chainId);
|
|
90
|
+
if (!url) {
|
|
91
|
+
throw new GmxRelayError(`GMX API url is not configured for chain ${chainId}`);
|
|
92
|
+
}
|
|
93
|
+
return url;
|
|
94
|
+
}
|
|
95
|
+
async function post(baseUrl, path, body, timeout) {
|
|
96
|
+
const controller = new AbortController();
|
|
97
|
+
const timer = setTimeout(() => controller.abort(), timeout);
|
|
98
|
+
// bespoke fetch rather than postJson: the trace id arrives in a response header on refusals,
|
|
99
|
+
// and the shared client only surfaces parsed bodies
|
|
100
|
+
// the timer must also cover the body read: a response that stalls after its headers would hang forever
|
|
101
|
+
try {
|
|
102
|
+
const response = await fetch((0, buildUrl_1.buildUrl)(baseUrl, path), {
|
|
103
|
+
method: "POST",
|
|
104
|
+
headers: { "Content-Type": "application/json" },
|
|
105
|
+
body: JSON.stringify(body),
|
|
106
|
+
signal: controller.signal,
|
|
107
|
+
});
|
|
108
|
+
if (!response.ok) {
|
|
109
|
+
const text = await response.text().catch(() => "");
|
|
110
|
+
const error = new GmxRelayError(`GMX Relay ${path} failed: ${extractMessage(text) ?? response.statusText}`, response.status);
|
|
111
|
+
// a request refused before it was relayed never gets a taskId; the trace id is the only handle left
|
|
112
|
+
const traceId = response.headers.get("X-Trace-Id");
|
|
113
|
+
if (traceId) {
|
|
114
|
+
error.traceId = traceId;
|
|
115
|
+
error.data = { traceId };
|
|
116
|
+
}
|
|
117
|
+
throw error;
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
return (await response.json());
|
|
121
|
+
}
|
|
122
|
+
catch (e) {
|
|
123
|
+
throw new GmxRelayError(`GMX Relay ${path} returned an unreadable body`, response.status, e);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
catch (e) {
|
|
127
|
+
if (e instanceof GmxRelayError) {
|
|
128
|
+
throw e;
|
|
129
|
+
}
|
|
130
|
+
throw new GmxRelayError(`GMX Relay request failed: ${e?.message ?? String(e)}`, undefined, e);
|
|
131
|
+
}
|
|
132
|
+
finally {
|
|
133
|
+
clearTimeout(timer);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function extractMessage(text) {
|
|
137
|
+
try {
|
|
138
|
+
const parsed = JSON.parse(text);
|
|
139
|
+
return parsed?.message ?? parsed?.error;
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
// a non-JSON body is an edge's HTML error page, not a message to surface to a user
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const chains_1 = require("../../../configs/chains");
|
|
5
|
+
const gmxRelayUtils_1 = require("./gmxRelayUtils");
|
|
6
|
+
const TASK_ID = `0x${"ab".repeat(32)}`;
|
|
7
|
+
const TXN_DATA = {
|
|
8
|
+
callData: "0xdeadbeef",
|
|
9
|
+
to: "0x0000000000000000000000000000000000000001",
|
|
10
|
+
feeToken: "0x0000000000000000000000000000000000000002",
|
|
11
|
+
feeAmount: 123n,
|
|
12
|
+
};
|
|
13
|
+
function jsonResponse(body, status = 200) {
|
|
14
|
+
return new Response(JSON.stringify(body), { status, headers: { "Content-Type": "application/json" } });
|
|
15
|
+
}
|
|
16
|
+
(0, vitest_1.describe)("sendToGmxRelay", () => {
|
|
17
|
+
(0, vitest_1.afterEach)(() => {
|
|
18
|
+
vitest_1.vi.unstubAllGlobals();
|
|
19
|
+
});
|
|
20
|
+
(0, vitest_1.it)("carries the API's trace id on a refusal", async () => {
|
|
21
|
+
vitest_1.vi.stubGlobal("fetch", vitest_1.vi.fn(async () => new Response(JSON.stringify({ message: "nope" }), {
|
|
22
|
+
status: 400,
|
|
23
|
+
headers: { "Content-Type": "application/json", "X-Trace-Id": "tr-1" },
|
|
24
|
+
})));
|
|
25
|
+
const error = await (0, gmxRelayUtils_1.sendToGmxRelay)({ chainId: chains_1.ARBITRUM, txnData: TXN_DATA }).catch((e) => e);
|
|
26
|
+
(0, vitest_1.expect)(error).toBeInstanceOf(gmxRelayUtils_1.GmxRelayError);
|
|
27
|
+
(0, vitest_1.expect)(error.data).toEqual({ traceId: "tr-1" });
|
|
28
|
+
});
|
|
29
|
+
(0, vitest_1.it)("posts bare calldata without the Gelato fee suffix", async () => {
|
|
30
|
+
const fetchMock = vitest_1.vi.fn(async () => jsonResponse({ taskId: TASK_ID, status: "pending" }));
|
|
31
|
+
vitest_1.vi.stubGlobal("fetch", fetchMock);
|
|
32
|
+
const result = await (0, gmxRelayUtils_1.sendToGmxRelay)({ chainId: chains_1.ARBITRUM, txnData: TXN_DATA });
|
|
33
|
+
(0, vitest_1.expect)(result).toEqual({ taskId: TASK_ID, status: "pending" });
|
|
34
|
+
const [url, init] = fetchMock.mock.calls[0];
|
|
35
|
+
(0, vitest_1.expect)(url).toContain("/v1/relay/submit");
|
|
36
|
+
(0, vitest_1.expect)(JSON.parse(String(init.body))).toEqual({ to: TXN_DATA.to, data: TXN_DATA.callData });
|
|
37
|
+
});
|
|
38
|
+
(0, vitest_1.it)("honours an explicit api url", async () => {
|
|
39
|
+
const fetchMock = vitest_1.vi.fn(async () => jsonResponse({ taskId: TASK_ID, status: "pending" }));
|
|
40
|
+
vitest_1.vi.stubGlobal("fetch", fetchMock);
|
|
41
|
+
await (0, gmxRelayUtils_1.sendToGmxRelay)({ chainId: chains_1.ARBITRUM, txnData: TXN_DATA, apiUrl: "https://api.example.com/" });
|
|
42
|
+
const [url] = fetchMock.mock.calls[0];
|
|
43
|
+
(0, vitest_1.expect)(url).toBe("https://api.example.com/v1/relay/submit");
|
|
44
|
+
});
|
|
45
|
+
(0, vitest_1.it)("raises a permanent error when the api rejects the operation", async () => {
|
|
46
|
+
vitest_1.vi.stubGlobal("fetch", vitest_1.vi.fn(async () => jsonResponse({ message: "to is not an allowlisted relay router" }, 400)));
|
|
47
|
+
const error = await (0, gmxRelayUtils_1.sendToGmxRelay)({ chainId: chains_1.ARBITRUM, txnData: TXN_DATA }).catch((e) => e);
|
|
48
|
+
(0, vitest_1.expect)(error).toBeInstanceOf(gmxRelayUtils_1.GmxRelayError);
|
|
49
|
+
(0, vitest_1.expect)(error.message).toContain("allowlisted relay router");
|
|
50
|
+
(0, vitest_1.expect)((0, gmxRelayUtils_1.isPermanentRelayError)(error)).toBe(true);
|
|
51
|
+
});
|
|
52
|
+
(0, vitest_1.it)("treats a rate-limited response as retryable rather than permanent", async () => {
|
|
53
|
+
vitest_1.vi.stubGlobal("fetch", vitest_1.vi.fn(async () => jsonResponse({ message: "slow down" }, 429)));
|
|
54
|
+
const error = await (0, gmxRelayUtils_1.sendToGmxRelay)({ chainId: chains_1.ARBITRUM, txnData: TXN_DATA }).catch((e) => e);
|
|
55
|
+
(0, vitest_1.expect)((0, gmxRelayUtils_1.isPermanentRelayError)(error)).toBe(false);
|
|
56
|
+
});
|
|
57
|
+
(0, vitest_1.it)("keeps a transport failure retryable", async () => {
|
|
58
|
+
vitest_1.vi.stubGlobal("fetch", vitest_1.vi.fn(async () => {
|
|
59
|
+
throw new Error("network down");
|
|
60
|
+
}));
|
|
61
|
+
const error = await (0, gmxRelayUtils_1.sendToGmxRelay)({ chainId: chains_1.ARBITRUM, txnData: TXN_DATA }).catch((e) => e);
|
|
62
|
+
(0, vitest_1.expect)(error).toBeInstanceOf(gmxRelayUtils_1.GmxRelayError);
|
|
63
|
+
(0, vitest_1.expect)((0, gmxRelayUtils_1.isPermanentRelayError)(error)).toBe(false);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
(0, vitest_1.describe)("getGmxRelayTaskStatus", () => {
|
|
67
|
+
(0, vitest_1.afterEach)(() => {
|
|
68
|
+
vitest_1.vi.unstubAllGlobals();
|
|
69
|
+
});
|
|
70
|
+
(0, vitest_1.it)("posts the taskId and returns the status view", async () => {
|
|
71
|
+
const fetchMock = vitest_1.vi.fn(async () => jsonResponse({ taskId: TASK_ID, status: "executed", txHash: "0xhash" }));
|
|
72
|
+
vitest_1.vi.stubGlobal("fetch", fetchMock);
|
|
73
|
+
const view = await (0, gmxRelayUtils_1.getGmxRelayTaskStatus)({ chainId: chains_1.ARBITRUM, taskId: TASK_ID });
|
|
74
|
+
(0, vitest_1.expect)(view.status).toBe("executed");
|
|
75
|
+
const [url, init] = fetchMock.mock.calls[0];
|
|
76
|
+
(0, vitest_1.expect)(url).toContain("/v1/relay/status");
|
|
77
|
+
(0, vitest_1.expect)(JSON.parse(String(init.body))).toEqual({ taskId: TASK_ID });
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
(0, vitest_1.describe)("waitForGmxRelayTask", () => {
|
|
81
|
+
(0, vitest_1.afterEach)(() => {
|
|
82
|
+
vitest_1.vi.unstubAllGlobals();
|
|
83
|
+
});
|
|
84
|
+
(0, vitest_1.it)("polls until the operation leaves the pending state", async () => {
|
|
85
|
+
let call = 0;
|
|
86
|
+
vitest_1.vi.stubGlobal("fetch", vitest_1.vi.fn(async () => {
|
|
87
|
+
call++;
|
|
88
|
+
return call < 3
|
|
89
|
+
? jsonResponse({ taskId: TASK_ID, status: "pending" })
|
|
90
|
+
: jsonResponse({ taskId: TASK_ID, status: "executed", txHash: "0xhash" });
|
|
91
|
+
}));
|
|
92
|
+
const result = await (0, gmxRelayUtils_1.waitForGmxRelayTask)({ chainId: chains_1.ARBITRUM, taskId: TASK_ID, pollingInterval: 1 });
|
|
93
|
+
(0, vitest_1.expect)(result.status).toBe("success");
|
|
94
|
+
(0, vitest_1.expect)(result.transactionHash).toBe("0xhash");
|
|
95
|
+
(0, vitest_1.expect)(call).toBe(3);
|
|
96
|
+
});
|
|
97
|
+
(0, vitest_1.it)("keeps polling through a transient status failure", async () => {
|
|
98
|
+
let call = 0;
|
|
99
|
+
vitest_1.vi.stubGlobal("fetch", vitest_1.vi.fn(async () => {
|
|
100
|
+
call++;
|
|
101
|
+
if (call === 1)
|
|
102
|
+
throw new Error("network blip");
|
|
103
|
+
if (call === 2)
|
|
104
|
+
return jsonResponse({ message: "upstream" }, 503);
|
|
105
|
+
if (call === 3)
|
|
106
|
+
return jsonResponse({ message: "no relay operation" }, 404);
|
|
107
|
+
return jsonResponse({ taskId: TASK_ID, status: "executed", txHash: "0xhash" });
|
|
108
|
+
}));
|
|
109
|
+
const result = await (0, gmxRelayUtils_1.waitForGmxRelayTask)({ chainId: chains_1.ARBITRUM, taskId: TASK_ID, pollingInterval: 1 });
|
|
110
|
+
(0, vitest_1.expect)(result.status).toBe("success");
|
|
111
|
+
(0, vitest_1.expect)(result.transactionHash).toBe("0xhash");
|
|
112
|
+
(0, vitest_1.expect)(call).toBe(4);
|
|
113
|
+
});
|
|
114
|
+
(0, vitest_1.it)("gives up immediately when the status request itself is rejected", async () => {
|
|
115
|
+
const fetchMock = vitest_1.vi.fn(async () => jsonResponse({ message: "taskId must be a 32-byte hex string" }, 400));
|
|
116
|
+
vitest_1.vi.stubGlobal("fetch", fetchMock);
|
|
117
|
+
const error = await (0, gmxRelayUtils_1.waitForGmxRelayTask)({ chainId: chains_1.ARBITRUM, taskId: TASK_ID, pollingInterval: 1 }).catch((e) => e);
|
|
118
|
+
(0, vitest_1.expect)(error).toBeInstanceOf(gmxRelayUtils_1.GmxRelayError);
|
|
119
|
+
(0, vitest_1.expect)(fetchMock).toHaveBeenCalledTimes(1);
|
|
120
|
+
});
|
|
121
|
+
(0, vitest_1.it)("reports an unresolved status rather than a failure when the window closes on errors", async () => {
|
|
122
|
+
vitest_1.vi.stubGlobal("fetch", vitest_1.vi.fn(async () => jsonResponse({ message: "upstream" }, 503)));
|
|
123
|
+
const result = await (0, gmxRelayUtils_1.waitForGmxRelayTask)({
|
|
124
|
+
chainId: chains_1.ARBITRUM,
|
|
125
|
+
taskId: TASK_ID,
|
|
126
|
+
pollingInterval: 1,
|
|
127
|
+
timeout: 5,
|
|
128
|
+
});
|
|
129
|
+
(0, vitest_1.expect)(result.status).toBe("pending");
|
|
130
|
+
(0, vitest_1.expect)(result.message).toContain("Could not read");
|
|
131
|
+
});
|
|
132
|
+
(0, vitest_1.it)("reports a revert as a failure carrying the reason and the raw revert bytes", async () => {
|
|
133
|
+
vitest_1.vi.stubGlobal("fetch", vitest_1.vi.fn(async () => jsonResponse({
|
|
134
|
+
taskId: TASK_ID,
|
|
135
|
+
status: "reverted",
|
|
136
|
+
txHash: "0xhash",
|
|
137
|
+
reason: "InsufficientRelayFee",
|
|
138
|
+
revertData: "0x08c379a0deadbeef",
|
|
139
|
+
})));
|
|
140
|
+
const result = await (0, gmxRelayUtils_1.waitForGmxRelayTask)({ chainId: chains_1.ARBITRUM, taskId: TASK_ID, pollingInterval: 1 });
|
|
141
|
+
(0, vitest_1.expect)(result.status).toBe("failed");
|
|
142
|
+
(0, vitest_1.expect)(result.relayStatus).toBe("reverted");
|
|
143
|
+
(0, vitest_1.expect)(result.message).toBe("InsufficientRelayFee");
|
|
144
|
+
(0, vitest_1.expect)(result.revertData).toBe("0x08c379a0deadbeef");
|
|
145
|
+
});
|
|
146
|
+
(0, vitest_1.it)("never resolves an undetermined outcome as success or failure", async () => {
|
|
147
|
+
vitest_1.vi.stubGlobal("fetch", vitest_1.vi.fn(async () => jsonResponse({ taskId: TASK_ID, status: "unknown", txHash: "0xhash" })));
|
|
148
|
+
const result = await (0, gmxRelayUtils_1.waitForGmxRelayTask)({ chainId: chains_1.ARBITRUM, taskId: TASK_ID, pollingInterval: 1 });
|
|
149
|
+
(0, vitest_1.expect)(result.status).toBe("pending");
|
|
150
|
+
(0, vitest_1.expect)(result.relayStatus).toBe("unknown");
|
|
151
|
+
});
|
|
152
|
+
(0, vitest_1.it)("gives up as pending once the wait window elapses", async () => {
|
|
153
|
+
vitest_1.vi.stubGlobal("fetch", vitest_1.vi.fn(async () => jsonResponse({ taskId: TASK_ID, status: "pending" })));
|
|
154
|
+
const result = await (0, gmxRelayUtils_1.waitForGmxRelayTask)({
|
|
155
|
+
chainId: chains_1.ARBITRUM,
|
|
156
|
+
taskId: TASK_ID,
|
|
157
|
+
timeout: 5,
|
|
158
|
+
pollingInterval: 10,
|
|
159
|
+
});
|
|
160
|
+
(0, vitest_1.expect)(result.status).toBe("pending");
|
|
161
|
+
(0, vitest_1.expect)(result.message).toMatch(/Timed out/);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
@@ -19,6 +19,7 @@ __exportStar(require("./oracleParamsUtils"), exports);
|
|
|
19
19
|
__exportStar(require("./relayParamsUtils"), exports);
|
|
20
20
|
__exportStar(require("./batchOrderUtils"), exports);
|
|
21
21
|
__exportStar(require("./gelatoRelayUtils"), exports);
|
|
22
|
+
__exportStar(require("./gmxRelayUtils"), exports);
|
|
22
23
|
__exportStar(require("./globalExpressParams"), exports);
|
|
23
24
|
__exportStar(require("./expressParamsUtils"), exports);
|
|
24
25
|
__exportStar(require("./estimateExpressParams"), exports);
|