@gmx-io/sdk 1.6.1 → 1.6.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 +8 -0
- package/build/cjs/src/codegen/prebuilt/hashedMarketConfigKeys.json +61 -0
- package/build/cjs/src/codegen/prebuilt/hashedMarketValuesKeys.json +15 -0
- package/build/cjs/src/configs/markets.js +11 -1
- package/build/cjs/src/configs/tokens.js +11 -0
- package/build/cjs/src/utils/__tests__/markets.spec.js +30 -0
- package/build/cjs/src/utils/markets/utils.js +16 -12
- package/build/cjs/src/utils/positions/utils.js +1 -0
- package/build/esm/src/codegen/prebuilt/hashedKinkModelMarketRatesKeys.json +8 -0
- package/build/esm/src/codegen/prebuilt/hashedMarketConfigKeys.json +61 -0
- package/build/esm/src/codegen/prebuilt/hashedMarketValuesKeys.json +15 -0
- package/build/esm/src/configs/markets.js +10 -0
- package/build/esm/src/configs/tokens.js +11 -0
- package/build/esm/src/utils/__tests__/markets.spec.js +30 -0
- package/build/esm/src/utils/markets/utils.js +16 -12
- package/build/esm/src/utils/positions/utils.js +1 -0
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/types/src/codegen/prebuilt/index.d.ts +84 -0
- package/build/types/src/configs/markets.d.ts +1 -0
- package/build/types/src/utils/markets/utils.d.ts +4 -3
- package/build/types/src/utils/tokens/types.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1124,6 +1124,14 @@
|
|
|
1124
1124
|
"aboveOptimalUsageBorrowingFactorLong": "0xfdc145dc5c86925a834513f0c78ef57f8da0f095253e561506b6367106d5caac",
|
|
1125
1125
|
"aboveOptimalUsageBorrowingFactorShort": "0xc961a42b4a07b7f63f14fbd2a3c14c41643eb80dd5a8fdcde32ad1365bcb51a7"
|
|
1126
1126
|
},
|
|
1127
|
+
"0x470128853D74dab7423904a20eA5AA230e9e561B": {
|
|
1128
|
+
"optimalUsageFactorLong": "0xea04ac5384e4e3d5ba65acf6c8e6d030d7363b1a23b8c11bb58ae3ac16f4d6ef",
|
|
1129
|
+
"optimalUsageFactorShort": "0xf5ee87e53fffcadf24faa470f02b3bb0330cd9831045be7607787069de177b1b",
|
|
1130
|
+
"baseBorrowingFactorLong": "0xc288943efb3c238de85008769939b3b7def08f466702f497bc733c8b1c85ef3a",
|
|
1131
|
+
"baseBorrowingFactorShort": "0x92d89abb98ad384bea84894361789e7c950c1298246e71c24fc0883e953a1ede",
|
|
1132
|
+
"aboveOptimalUsageBorrowingFactorLong": "0x7e034f066736dca0c85aaf2dfb4c64048d34fce3c932085d783794ba2024df9d",
|
|
1133
|
+
"aboveOptimalUsageBorrowingFactorShort": "0xbc8b7b4174c18250b8cbe2bc9b23b678695089afbe2cf61ed4b90643cefc050e"
|
|
1134
|
+
},
|
|
1127
1135
|
"0xE26E7b91143f367445f1c0a5dCf4f4aC8EaDcDb1": {
|
|
1128
1136
|
"optimalUsageFactorLong": "0x7dd92ed8d2f972a0bedc134931f1ce1257fdc1ba4ebc043c270e81880efee700",
|
|
1129
1137
|
"optimalUsageFactorShort": "0xec58abc0c1c902e8df7ed4f6968dbfd88228e741bfd63bf3efc635e0d7c9bb9d",
|
|
@@ -8544,6 +8544,67 @@
|
|
|
8544
8544
|
"virtualLongTokenId": "0xaab37f889b9680dda34f58a689de3023cb22f7ae14d32a3c1d45798a973db1f5",
|
|
8545
8545
|
"virtualShortTokenId": "0xd5258cb84f0039be58306488e8df941c05f3cf4f219e92aacb6561c736bbb960"
|
|
8546
8546
|
},
|
|
8547
|
+
"0x470128853D74dab7423904a20eA5AA230e9e561B": {
|
|
8548
|
+
"isDisabled": "0xfe243a54564541c534d5eeae5e63c2d5db84aa8bd25a4a754408efc202e8d6e5",
|
|
8549
|
+
"maxLongPoolAmount": "0x39205af116753605d966898b83c4ec7df6aeb18e02c8380c9369f5d6bbfff636",
|
|
8550
|
+
"maxShortPoolAmount": "0xe069ff8a01ec920ec3918881607fbf87ee82fac4fe4419588bd04ecb25e86c5f",
|
|
8551
|
+
"maxLongPoolUsdForDeposit": "0x5fed054a389bf855aaf752f849f9aec169c13add29412126eb973982caac30dc",
|
|
8552
|
+
"maxShortPoolUsdForDeposit": "0x9874ece30abf39e18219153b11ae45ee25422096f35af32bdeaec681d6ec1522",
|
|
8553
|
+
"reserveFactorLong": "0x8005b75fdbad97e030d8cd27d3e8bc3fa07cb49500876115217e8bec4e8f210d",
|
|
8554
|
+
"reserveFactorShort": "0xa5140d82a4b20acf9ba665b133a8eb3003b8e9339b94bc4a561530da63ea6cfe",
|
|
8555
|
+
"openInterestReserveFactorLong": "0xade22aa01e5e5f10f593163ab9f956e8c43c01c3406ce610c5dad851032503a0",
|
|
8556
|
+
"openInterestReserveFactorShort": "0x9e51713a0dc904a819b3998da79b49709420b7d1796e7d98345113da92641ba7",
|
|
8557
|
+
"maxOpenInterestLong": "0xdb04bf3c179c1a2b89441879b9e6b198c0e29cf99a1195594fedb171e0f848ca",
|
|
8558
|
+
"maxOpenInterestShort": "0x9546febaa71b4e976ef4cf635076cc14f5dc68a4bfb784bd4ae39cfbdc3b9a75",
|
|
8559
|
+
"minPositionImpactPoolAmount": "0xe4262c3a746be3506435094aa18433081dcce819b6eef64578363b89f8af0018",
|
|
8560
|
+
"positionImpactPoolDistributionRate": "0x0e4c6c4ba31a6e94f6df0ee037f7884d369cc59f05698e2be943843b541b3b2f",
|
|
8561
|
+
"borrowingFactorLong": "0x8d0f57b99783d2c5ad53fe6fdc31bbc29a725f843e247b7a72ff3f79f045596b",
|
|
8562
|
+
"borrowingFactorShort": "0xe6c31c713cf022d3d662f04700861119efa2dea5a1691a3eb4cfdf75c28d1f6d",
|
|
8563
|
+
"borrowingExponentFactorLong": "0x53056a4ac567795f4d9885f20706ee74ec6993440a7b43439e72c02379f3e878",
|
|
8564
|
+
"borrowingExponentFactorShort": "0xa2bdcb3141e0770697a392944e1bd583a3c851e2ba72e59d65b99617b38b4fc0",
|
|
8565
|
+
"fundingFactor": "0x2a86348096e5a76bc46ab7286f3012cc403a4da5a63a5a78ccaa4ec24732fedb",
|
|
8566
|
+
"fundingExponentFactor": "0xd4828665a6d6b9ab81d76dd9d7bf38ed221e2d4bcc6f35a851e42f0f48f98e92",
|
|
8567
|
+
"fundingIncreaseFactorPerSecond": "0x7c35ce6e2417fcf8fa19bc8f6862e395aacd0eb546821f8164d046f9224c7dc1",
|
|
8568
|
+
"fundingDecreaseFactorPerSecond": "0x3d5d433151ae449ca355115a730d52ce1c945e36cb340a408329e0fa6fd677b0",
|
|
8569
|
+
"thresholdForStableFunding": "0x3785587cc950cb348063323c282242b14be9421fc64fdfe79cb8c71de2371289",
|
|
8570
|
+
"thresholdForDecreaseFunding": "0xe535526955c78fed5c4dc454eb1a4b931396e4e4a861461e43ba9ca660175338",
|
|
8571
|
+
"minFundingFactorPerSecond": "0x7d9bd63fb8d9db9345f89da4323130937c15142f30c52cf0c2c3f61965554b8c",
|
|
8572
|
+
"maxFundingFactorPerSecond": "0xc3583272b45beb068172fe8b0c428e9ba5a9d90513d11e2e7f9d3f50c4891175",
|
|
8573
|
+
"maxPnlFactorForTradersLong": "0xfc827e8022bb9470e4b6e80625af561298a89a21349a7f28002227d104aaa340",
|
|
8574
|
+
"maxPnlFactorForTradersShort": "0x72cf2f1f4d28a7a7bc591871fb733976b9b5be06131fba40ea272163ee1b4a5b",
|
|
8575
|
+
"maxPnlFactorForDepositsLong": "0xd605366e5a7ff3abd0d76cf57e1788446fae68b7ed21ab3279c430855414e3e7",
|
|
8576
|
+
"maxPnlFactorForDepositsShort": "0xdba9cc56b9ccfff70ce0f5269915cd4a9e3d467f0fbcd1572f245005cb9d0b00",
|
|
8577
|
+
"maxPnlFactorForWithdrawalsLong": "0x3b0c3e6d816414ad07c367167c68c43c4fed6b1190d72db03807bfa4dfae2911",
|
|
8578
|
+
"maxPnlFactorForWithdrawalsShort": "0x735cc2452ca08e74dd09ff1fa52e7ff6ab35da3e14fc103cc8a43d87395b5976",
|
|
8579
|
+
"positionFeeFactorForBalanceWasImproved": "0x087f8ffb10b80b5ac2140d51a16cf6e3b993673569626d8384d899ca1768fb6e",
|
|
8580
|
+
"positionFeeFactorForBalanceWasNotImproved": "0x93db7fe18681e1033baa91aadd2fbed9c821cdd016c8f0e3b2f79c7873cb9592",
|
|
8581
|
+
"positionImpactFactorPositive": "0x297fa7e7b636003945b564c16070b2659d71a80fd6f74165c5ff7a458a9ddcf5",
|
|
8582
|
+
"positionImpactFactorNegative": "0xd373bf8c89b270fe6b011b4cc5aa9f1cd0efe86f67b4a5640c20c07ebb5866f0",
|
|
8583
|
+
"maxPositionImpactFactorPositive": "0xb95147c91cfefc2b5bc56478bc89acc250c96be349117daf81f3c7163c659cb3",
|
|
8584
|
+
"maxPositionImpactFactorNegative": "0xc050b04300e901112d441469127596785a8cf7504117260dc7f7704a1fa36e06",
|
|
8585
|
+
"maxPositionImpactFactorForLiquidations": "0xf131c7d0f04481d0b47003445bc3343174376c0b885c4128b1e4c1b8fd0ce0fb",
|
|
8586
|
+
"maxLendableImpactFactor": "0x8c4ff7114d4241b28aae17fbb4c399f01e86af274560a212dc383e06e9981f1d",
|
|
8587
|
+
"maxLendableImpactFactorForWithdrawals": "0xef5bfd25b3655d058bea6025948abf09ea95b1b3d3b183880f5dc5c077498a1b",
|
|
8588
|
+
"maxLendableImpactUsd": "0x61a580a5e5382029facb4c776a0335d4034130e87e2f788db8151d89918eeb64",
|
|
8589
|
+
"lentPositionImpactPoolAmount": "0x6553c99fe8bc2a2a2ee509acd790a9075a4d6c1bfc29f84ec1aa88e5def086fb",
|
|
8590
|
+
"minCollateralFactor": "0x708f3743ff03fa69e9aa5d4038c8f2984477e2169f30ef2f145c53ca83e33db7",
|
|
8591
|
+
"minCollateralFactorForLiquidation": "0xe47c118c844f1da524087647c205fdca711510edc9768c00187156fbedcb9a4e",
|
|
8592
|
+
"minCollateralFactorForOpenInterestLong": "0x461b23d60d80970a3d0218cfc4530a7e4a2a2531c792d2c2781a546feebefa03",
|
|
8593
|
+
"minCollateralFactorForOpenInterestShort": "0xf087f5a1e94da17538546bbd6bbd1d7cfc938715d5cfad263c16c7065ee7f2a0",
|
|
8594
|
+
"positionImpactExponentFactorPositive": "0xdab3143b127c611e5bdf62e6eceeb69b795d6b3e643c1fca8e25d0176548c6b4",
|
|
8595
|
+
"positionImpactExponentFactorNegative": "0x2347c2bad621059109cbf2f2d0241ac3a3fa717816e749dc2d8b2e666bff4b57",
|
|
8596
|
+
"swapFeeFactorForBalanceWasImproved": "0x956d64be84e25d83f19a191d3115bd426b554b9d884d075625b1998a440c1ac0",
|
|
8597
|
+
"swapFeeFactorForBalanceWasNotImproved": "0x1dbf423caf962d3c39350ae346b277db997d2c140da420b24c0bebd603477593",
|
|
8598
|
+
"atomicSwapFeeFactor": "0xff91ee6de493812a25d525efa1e67ff47d2df0a0f59fda1f8f805cbff6ad884d",
|
|
8599
|
+
"swapImpactFactorPositive": "0x040389937579e93803e4eef90e2e524d1ea01e6890fcc62058801758d67a549f",
|
|
8600
|
+
"swapImpactFactorNegative": "0x31f9bba4c1cfcde524a5a73add46d38d57f362a36cbd5b216b5bb96d34297e22",
|
|
8601
|
+
"swapImpactExponentFactor": "0xf438467b2ca2e25ad577f3ea39caf610ef21d0ee0f1aa3e633044cc6b9fd8d72",
|
|
8602
|
+
"withdrawalFeeFactorBalanceWasImproved": "0x45a9a93feb42de4392939fff459c0ba3a2513a3f750865ed68e8f118d7c20203",
|
|
8603
|
+
"withdrawalFeeFactorBalanceWasNotImproved": "0xd5fea53fb1348b694edc1fe97f87da9923b847a73874774a9d6236e1a9f989f5",
|
|
8604
|
+
"virtualMarketId": "0xced49eb3d9ebb85529707d3b67a0fd9a3c6a749bbb1934f0888f51b564f11c57",
|
|
8605
|
+
"virtualLongTokenId": "0xaab37f889b9680dda34f58a689de3023cb22f7ae14d32a3c1d45798a973db1f5",
|
|
8606
|
+
"virtualShortTokenId": "0xd5258cb84f0039be58306488e8df941c05f3cf4f219e92aacb6561c736bbb960"
|
|
8607
|
+
},
|
|
8547
8608
|
"0xE26E7b91143f367445f1c0a5dCf4f4aC8EaDcDb1": {
|
|
8548
8609
|
"isDisabled": "0x89d68641baa8443dcff05c06834a08f6a7c1edef759f2e89505fe251b6411cb5",
|
|
8549
8610
|
"maxLongPoolAmount": "0x5c7eb3fb9940700a0eb6d0bc4b2efcec205e4bcd85611f2e63a40fb71b48a68b",
|
|
@@ -2104,6 +2104,21 @@
|
|
|
2104
2104
|
"shortInterestInTokensUsingLongToken": "0xccb072d4c5cf74a4a1d0e6f80b7628dba861d6c95037409fc42800e72a935d7c",
|
|
2105
2105
|
"shortInterestInTokensUsingShortToken": "0x3e1a9a944352a0080a281988fbf04a6b9c44a82767c10d16eb11ad80b1fb5d65"
|
|
2106
2106
|
},
|
|
2107
|
+
"0x470128853D74dab7423904a20eA5AA230e9e561B": {
|
|
2108
|
+
"longPoolAmount": "0x42bb5e8d4ca514798b21267763eeb4d3b35a623bd89689ef66ec1f007087b161",
|
|
2109
|
+
"shortPoolAmount": "0x8158632c1d7b805bbf9edba3e15fde98b5cd4d32ed70009ac3f6224ec47fc5ae",
|
|
2110
|
+
"positionImpactPoolAmount": "0xde24f47762b924ccb93b3434c4dec1224b581cae29eb84def00e25707f0598b3",
|
|
2111
|
+
"swapImpactPoolAmountLong": "0x9cce19aabd82c41d0b6b7df7e456057c78870b31379d4a7b1dab5a4e1c4975ff",
|
|
2112
|
+
"swapImpactPoolAmountShort": "0x1c76620a18e8abb145e352f6d7a618510e4da180beeb764f18294a47ff109ff4",
|
|
2113
|
+
"longInterestUsingLongToken": "0x27c74bd1c225f15925642df8ccae6a49d75cddc7d9365133a54ce3af9898876e",
|
|
2114
|
+
"longInterestUsingShortToken": "0xa2d438ebe99ba84f775d7c2c1c8e40a3aafdde88ed68c9d9b5bdf4fdac544b6e",
|
|
2115
|
+
"shortInterestUsingLongToken": "0x7587ab70dd363bcf4c60377a304b9fe072b73aa131f0d195c4f069e95ba1919d",
|
|
2116
|
+
"shortInterestUsingShortToken": "0xed61a26c939934abf69c8688610fe123ecc1b927522671d4056d0c1fb77feb65",
|
|
2117
|
+
"longInterestInTokensUsingLongToken": "0x892c0dd3d5da401bb0dd0822ca5e5acc861ce6842a3c3500512f89102e419529",
|
|
2118
|
+
"longInterestInTokensUsingShortToken": "0x51d2161b7c40b9f680a8d510dedab14fbc49a3415d1b7fce425ce455b8f44e92",
|
|
2119
|
+
"shortInterestInTokensUsingLongToken": "0x2bdcec38c2d0016c12d50e0ac27709d4856c2d27ffe78e58753e58d3f1ce7570",
|
|
2120
|
+
"shortInterestInTokensUsingShortToken": "0x8695147e4efe6f8ad95dee38bd50f33fb632c55e6119ee65d8716e8bf683dacd"
|
|
2121
|
+
},
|
|
2107
2122
|
"0xE26E7b91143f367445f1c0a5dCf4f4aC8EaDcDb1": {
|
|
2108
2123
|
"longPoolAmount": "0x265452d70a411300a2535b1c9c212a3dcea8eb2793c66aec2fcd595776ba2c0b",
|
|
2109
2124
|
"shortPoolAmount": "0x24f88d54e73a74c9c029fff00404272e44a15d9f931be2df1433f43ef5e5e428",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getMarketIsSameCollaterals = exports.getIsSpotOnlyMarket = exports.getTokenSymbolByMarket = exports.getMarketIndexToken = exports.getTokenAddressByMarket = exports.isMarketTokenAddress = exports.fixTokenSymbolFromMarketLabel = exports.getMarketByLabel = exports.getMarketsByChainId = exports.MARKETS = exports.SWAP_GRAPH_MAX_MARKETS_PER_TOKEN = void 0;
|
|
3
|
+
exports.getMarketIsSameCollaterals = exports.getIsSpotOnlyMarket = exports.getTokenSymbolByMarket = exports.getMarketIndexToken = exports.getTokenAddressByMarket = exports.isMarketTokenAddress = exports.fixTokenSymbolFromMarketLabel = exports.getMarketByLabel = exports.getMarketsByChainId = exports.MARKETS = exports.UI_MAX_LEVERAGE_BY_MARKET = exports.SWAP_GRAPH_MAX_MARKETS_PER_TOKEN = void 0;
|
|
4
4
|
/*
|
|
5
5
|
This files is used to pre-build data during the build process.
|
|
6
6
|
Avoid adding client-side code here, as it can break the build process.
|
|
@@ -9,6 +9,9 @@ const viem_1 = require("viem");
|
|
|
9
9
|
const chains_1 = require("./chains");
|
|
10
10
|
const tokens_1 = require("./tokens");
|
|
11
11
|
exports.SWAP_GRAPH_MAX_MARKETS_PER_TOKEN = 5;
|
|
12
|
+
exports.UI_MAX_LEVERAGE_BY_MARKET = {
|
|
13
|
+
"0x470128853D74dab7423904a20eA5AA230e9e561B": 10,
|
|
14
|
+
};
|
|
12
15
|
/*
|
|
13
16
|
ATTENTION
|
|
14
17
|
When adding new markets, please add them also to the end of the list in ./src/configs/static/sortedMarkets.ts
|
|
@@ -939,6 +942,13 @@ exports.MARKETS = {
|
|
|
939
942
|
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
|
|
940
943
|
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
941
944
|
},
|
|
945
|
+
// SPCX/USD [WETH-USDC]
|
|
946
|
+
"0x470128853D74dab7423904a20eA5AA230e9e561B": {
|
|
947
|
+
marketTokenAddress: "0x470128853D74dab7423904a20eA5AA230e9e561B",
|
|
948
|
+
indexTokenAddress: "0x8CBd0d5d81e7957123E6D8fFaE657a40bDC5691b",
|
|
949
|
+
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
|
|
950
|
+
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
951
|
+
},
|
|
942
952
|
// MEGA/USD [WETH-USDC]
|
|
943
953
|
"0xE26E7b91143f367445f1c0a5dCf4f4aC8EaDcDb1": {
|
|
944
954
|
marketTokenAddress: "0xE26E7b91143f367445f1c0a5dCf4f4aC8EaDcDb1",
|
|
@@ -1240,6 +1240,16 @@ exports.TOKENS = {
|
|
|
1240
1240
|
imageUrl: "https://s2.coinmarketcap.com/static/img/coins/64x64/39464.png",
|
|
1241
1241
|
explorerUrl: "https://arbiscan.io/token/0x620aC65BE29066Bb9D1E92C65b35B9fD321Fb963",
|
|
1242
1242
|
},
|
|
1243
|
+
{
|
|
1244
|
+
name: "SpaceX",
|
|
1245
|
+
symbol: "SPCX",
|
|
1246
|
+
address: "0x8CBd0d5d81e7957123E6D8fFaE657a40bDC5691b",
|
|
1247
|
+
isSynthetic: true,
|
|
1248
|
+
decimals: 18,
|
|
1249
|
+
categories: ["tradfi", "pre-ipo"],
|
|
1250
|
+
searchAliases: ["Space", "X"],
|
|
1251
|
+
explorerUrl: "https://arbiscan.io/token/0x8CBd0d5d81e7957123E6D8fFaE657a40bDC5691b",
|
|
1252
|
+
},
|
|
1243
1253
|
{
|
|
1244
1254
|
name: "MegaETH",
|
|
1245
1255
|
symbol: "MEGA",
|
|
@@ -2086,6 +2096,7 @@ exports.TOKEN_COLOR_MAP = {
|
|
|
2086
2096
|
XAG: "#ADABB8",
|
|
2087
2097
|
GOLD: "#D69A00",
|
|
2088
2098
|
SILVER: "#ADABB8",
|
|
2099
|
+
SPCX: "#1A1E21",
|
|
2089
2100
|
XPT: "#C2B8AB",
|
|
2090
2101
|
XPD: "#A9ACB6",
|
|
2091
2102
|
default: "#6062a6",
|
|
@@ -140,6 +140,12 @@ function getToken(symbol) {
|
|
|
140
140
|
(0, vitest_1.it)("returns correct leverage for a given factor", () => {
|
|
141
141
|
(0, vitest_1.expect)((0, markets_1.getMaxLeverageByMinCollateralFactor)(1000000000000000000n)).toBe(10000000000000000);
|
|
142
142
|
});
|
|
143
|
+
(0, vitest_1.it)("caps SPCX min-collateral-factor leverage at 10x", () => {
|
|
144
|
+
(0, vitest_1.expect)((0, markets_1.getMaxLeverageByMinCollateralFactor)(1000000000000000000n, "0x470128853D74dab7423904a20eA5AA230e9e561B")).toBe(100000);
|
|
145
|
+
});
|
|
146
|
+
(0, vitest_1.it)("caps SPCX default min-collateral-factor leverage at 10x", () => {
|
|
147
|
+
(0, vitest_1.expect)((0, markets_1.getMaxLeverageByMinCollateralFactor)(undefined, "0x470128853D74dab7423904a20eA5AA230e9e561B")).toBe(100000);
|
|
148
|
+
});
|
|
143
149
|
});
|
|
144
150
|
(0, vitest_1.describe)("getMaxAllowedLeverage", () => {
|
|
145
151
|
// Factors are expressed in PRECISION units (1e30 == 100%).
|
|
@@ -230,6 +236,30 @@ function getToken(symbol) {
|
|
|
230
236
|
positionFeeFactorForBalanceWasNotImproved: pct(0.05),
|
|
231
237
|
})).toBe(bps(25));
|
|
232
238
|
});
|
|
239
|
+
(0, vitest_1.it)("caps SPCX UI max leverage at 10x", () => {
|
|
240
|
+
(0, vitest_1.expect)((0, markets_1.getMaxAllowedLeverage)({
|
|
241
|
+
marketAddress: "0x470128853D74dab7423904a20eA5AA230e9e561B",
|
|
242
|
+
minCollateralFactor: pct(0.5),
|
|
243
|
+
minCollateralFactorForLiquidation: pct(0.5),
|
|
244
|
+
positionFeeFactorForBalanceWasNotImproved: pct(0.05),
|
|
245
|
+
})).toBe(bps(10));
|
|
246
|
+
});
|
|
247
|
+
(0, vitest_1.it)("does not cap other markets with matching factors", () => {
|
|
248
|
+
(0, vitest_1.expect)((0, markets_1.getMaxAllowedLeverage)({
|
|
249
|
+
marketAddress: "0x0000000000000000000000000000000000000000",
|
|
250
|
+
minCollateralFactor: pct(0.5),
|
|
251
|
+
minCollateralFactorForLiquidation: pct(0.5),
|
|
252
|
+
positionFeeFactorForBalanceWasNotImproved: pct(0.05),
|
|
253
|
+
})).toBe(bps(100));
|
|
254
|
+
});
|
|
255
|
+
(0, vitest_1.it)("keeps lower dynamic max leverage for SPCX when factors require it", () => {
|
|
256
|
+
(0, vitest_1.expect)((0, markets_1.getMaxAllowedLeverage)({
|
|
257
|
+
marketAddress: "0x470128853D74dab7423904a20eA5AA230e9e561B",
|
|
258
|
+
minCollateralFactor: pct(10),
|
|
259
|
+
minCollateralFactorForLiquidation: pct(10),
|
|
260
|
+
positionFeeFactorForBalanceWasNotImproved: pct(0.05),
|
|
261
|
+
})).toBe(bps(5));
|
|
262
|
+
});
|
|
233
263
|
});
|
|
234
264
|
(0, vitest_1.describe)("getOppositeCollateral", () => {
|
|
235
265
|
const marketInfo = {
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getMarketAddressByName = exports.getMarketWithTiers = exports.composeFullMarketsInfoData = exports.hydrateMarketInfo = exports.composeRawMarketsInfoData = exports.composeRawMarketInfo = exports.getMarketTicker = exports.getMarket24Stats = exports.getIsMarketDeprecated = exports.getIsMarketAvailableForExpressSwaps = exports.getPriceForPnl = exports.getOpenInterestForBalance = exports.getOpenInterestInTokens = exports.getOpenInterestUsd = exports.getMarketPnl = exports.getOiInTokensFromRawValues = exports.getOiUsdFromRawValues = exports.getMarketDivisor = exports.getReservedUsd = exports.getAvailableUsdLiquidityForCollateral = exports.getOppositeCollateralFromConfig = exports.getOppositeCollateral = exports.getMaxAllowedLeverage = exports.getMaxLeverageByMinCollateralFactor = exports.getCappedPoolPnl = exports.getPoolUsdWithoutPnl = exports.getTokenPoolType = exports.getContractMarketPrices = exports.getMarketPoolName = exports.getMarketBaseName = exports.getMarketIndexName = exports.getMarketFullName = void 0;
|
|
4
4
|
const viem_1 = require("viem");
|
|
5
5
|
const factors_1 = require("../../configs/factors");
|
|
6
|
+
const markets_1 = require("../../configs/markets");
|
|
6
7
|
const tokens_1 = require("../../configs/tokens");
|
|
7
8
|
const bigmath_1 = require("../bigmath");
|
|
8
9
|
const fees_1 = require("../fees");
|
|
@@ -59,12 +60,10 @@ function getTokenPoolType(marketInfo, tokenAddress) {
|
|
|
59
60
|
if (longToken.address === shortToken.address && tokenAddress === longToken.address) {
|
|
60
61
|
return "long";
|
|
61
62
|
}
|
|
62
|
-
if (tokenAddress === longToken.address ||
|
|
63
|
-
(tokenAddress === tokens_1.NATIVE_TOKEN_ADDRESS && longToken.isWrapped)) {
|
|
63
|
+
if (tokenAddress === longToken.address || (tokenAddress === tokens_1.NATIVE_TOKEN_ADDRESS && longToken.isWrapped)) {
|
|
64
64
|
return "long";
|
|
65
65
|
}
|
|
66
|
-
if (tokenAddress === shortToken.address ||
|
|
67
|
-
(tokenAddress === tokens_1.NATIVE_TOKEN_ADDRESS && shortToken.isWrapped)) {
|
|
66
|
+
if (tokenAddress === shortToken.address || (tokenAddress === tokens_1.NATIVE_TOKEN_ADDRESS && shortToken.isWrapped)) {
|
|
68
67
|
return "short";
|
|
69
68
|
}
|
|
70
69
|
return undefined;
|
|
@@ -102,31 +101,36 @@ exports.getCappedPoolPnl = getCappedPoolPnl;
|
|
|
102
101
|
* user is not opening a new size.
|
|
103
102
|
*/
|
|
104
103
|
const ROUNDING_VALUE = 10000;
|
|
105
|
-
function
|
|
104
|
+
function capByUiMaxLeverageOverride(value, marketAddress) {
|
|
105
|
+
const uiMaxLeverageOverride = marketAddress ? markets_1.UI_MAX_LEVERAGE_BY_MARKET[marketAddress] : undefined;
|
|
106
|
+
return uiMaxLeverageOverride === undefined ? value : Math.min(value, uiMaxLeverageOverride * factors_1.BASIS_POINTS_DIVISOR);
|
|
107
|
+
}
|
|
108
|
+
function getMaxLeverageByMinCollateralFactor(minCollateralFactor, marketAddress) {
|
|
106
109
|
if (minCollateralFactor === undefined)
|
|
107
|
-
return 100 * factors_1.BASIS_POINTS_DIVISOR;
|
|
110
|
+
return capByUiMaxLeverageOverride(100 * factors_1.BASIS_POINTS_DIVISOR, marketAddress);
|
|
108
111
|
if (minCollateralFactor === 0n)
|
|
109
|
-
return 100 * factors_1.BASIS_POINTS_DIVISOR;
|
|
112
|
+
return capByUiMaxLeverageOverride(100 * factors_1.BASIS_POINTS_DIVISOR, marketAddress);
|
|
110
113
|
const x = bigmath_1.bigMath.mulDiv(numbers_1.PRECISION, factors_1.BASIS_POINTS_DIVISOR_BIGINT, minCollateralFactor);
|
|
111
114
|
const rounded = Math.round(Number(x) / ROUNDING_VALUE) * ROUNDING_VALUE;
|
|
112
|
-
return rounded;
|
|
115
|
+
return capByUiMaxLeverageOverride(rounded, marketAddress);
|
|
113
116
|
}
|
|
114
117
|
exports.getMaxLeverageByMinCollateralFactor = getMaxLeverageByMinCollateralFactor;
|
|
115
118
|
const MAX_ALLOWED_LEVERAGE_STEP_BP = 5 * factors_1.BASIS_POINTS_DIVISOR;
|
|
116
|
-
function getMaxAllowedLeverage({ minCollateralFactor, minCollateralFactorForLiquidation, positionFeeFactorForBalanceWasNotImproved, }) {
|
|
119
|
+
function getMaxAllowedLeverage({ marketAddress, minCollateralFactor, minCollateralFactorForLiquidation, positionFeeFactorForBalanceWasNotImproved, }) {
|
|
117
120
|
if (minCollateralFactor === undefined ||
|
|
118
121
|
minCollateralFactor === 0n ||
|
|
119
122
|
minCollateralFactorForLiquidation === undefined ||
|
|
120
123
|
minCollateralFactorForLiquidation === 0n ||
|
|
121
124
|
positionFeeFactorForBalanceWasNotImproved === undefined) {
|
|
122
|
-
return 100 * factors_1.BASIS_POINTS_DIVISOR;
|
|
125
|
+
return capByUiMaxLeverageOverride(100 * factors_1.BASIS_POINTS_DIVISOR, marketAddress);
|
|
123
126
|
}
|
|
124
127
|
const openingDenominator = minCollateralFactor + 2n * positionFeeFactorForBalanceWasNotImproved;
|
|
125
128
|
const openingMaxBp = bigmath_1.bigMath.mulDiv(numbers_1.PRECISION, factors_1.BASIS_POINTS_DIVISOR_BIGINT, openingDenominator);
|
|
126
129
|
const liquidationDenominator = 2n * minCollateralFactorForLiquidation;
|
|
127
130
|
const liquidationMaxBp = bigmath_1.bigMath.mulDiv(numbers_1.PRECISION, factors_1.BASIS_POINTS_DIVISOR_BIGINT, liquidationDenominator);
|
|
128
131
|
const rawMaxBp = bigmath_1.bigMath.min(openingMaxBp, liquidationMaxBp);
|
|
129
|
-
|
|
132
|
+
const maxAllowedLeverage = Math.floor(Number(rawMaxBp) / MAX_ALLOWED_LEVERAGE_STEP_BP) * MAX_ALLOWED_LEVERAGE_STEP_BP;
|
|
133
|
+
return capByUiMaxLeverageOverride(maxAllowedLeverage, marketAddress);
|
|
130
134
|
}
|
|
131
135
|
exports.getMaxAllowedLeverage = getMaxAllowedLeverage;
|
|
132
136
|
function getOppositeCollateral(marketInfo, tokenAddress) {
|
|
@@ -377,7 +381,7 @@ function composeFullMarketsInfoData({ chainId, marketsAddresses, rawMarketsInfoD
|
|
|
377
381
|
}
|
|
378
382
|
exports.composeFullMarketsInfoData = composeFullMarketsInfoData;
|
|
379
383
|
function getMarketWithTiers(marketInfo, constants) {
|
|
380
|
-
const maxLeverage = getMaxLeverageByMinCollateralFactor(marketInfo.minCollateralFactor);
|
|
384
|
+
const maxLeverage = getMaxLeverageByMinCollateralFactor(marketInfo.minCollateralFactor, marketInfo.marketTokenAddress);
|
|
381
385
|
const maxLeverageBigint = BigInt(maxLeverage);
|
|
382
386
|
const leverageTiers = [
|
|
383
387
|
{
|
|
@@ -400,6 +400,7 @@ function getPositionInfo(p) {
|
|
|
400
400
|
pnl: undefined,
|
|
401
401
|
});
|
|
402
402
|
const maxAllowedLeverage = (0, markets_1.getMaxAllowedLeverage)({
|
|
403
|
+
marketAddress: marketInfo.marketTokenAddress,
|
|
403
404
|
minCollateralFactor: marketInfo.minCollateralFactor,
|
|
404
405
|
minCollateralFactorForLiquidation: marketInfo.minCollateralFactorForLiquidation,
|
|
405
406
|
positionFeeFactorForBalanceWasNotImproved: marketInfo.positionFeeFactorForBalanceWasNotImproved,
|
|
@@ -1124,6 +1124,14 @@
|
|
|
1124
1124
|
"aboveOptimalUsageBorrowingFactorLong": "0xfdc145dc5c86925a834513f0c78ef57f8da0f095253e561506b6367106d5caac",
|
|
1125
1125
|
"aboveOptimalUsageBorrowingFactorShort": "0xc961a42b4a07b7f63f14fbd2a3c14c41643eb80dd5a8fdcde32ad1365bcb51a7"
|
|
1126
1126
|
},
|
|
1127
|
+
"0x470128853D74dab7423904a20eA5AA230e9e561B": {
|
|
1128
|
+
"optimalUsageFactorLong": "0xea04ac5384e4e3d5ba65acf6c8e6d030d7363b1a23b8c11bb58ae3ac16f4d6ef",
|
|
1129
|
+
"optimalUsageFactorShort": "0xf5ee87e53fffcadf24faa470f02b3bb0330cd9831045be7607787069de177b1b",
|
|
1130
|
+
"baseBorrowingFactorLong": "0xc288943efb3c238de85008769939b3b7def08f466702f497bc733c8b1c85ef3a",
|
|
1131
|
+
"baseBorrowingFactorShort": "0x92d89abb98ad384bea84894361789e7c950c1298246e71c24fc0883e953a1ede",
|
|
1132
|
+
"aboveOptimalUsageBorrowingFactorLong": "0x7e034f066736dca0c85aaf2dfb4c64048d34fce3c932085d783794ba2024df9d",
|
|
1133
|
+
"aboveOptimalUsageBorrowingFactorShort": "0xbc8b7b4174c18250b8cbe2bc9b23b678695089afbe2cf61ed4b90643cefc050e"
|
|
1134
|
+
},
|
|
1127
1135
|
"0xE26E7b91143f367445f1c0a5dCf4f4aC8EaDcDb1": {
|
|
1128
1136
|
"optimalUsageFactorLong": "0x7dd92ed8d2f972a0bedc134931f1ce1257fdc1ba4ebc043c270e81880efee700",
|
|
1129
1137
|
"optimalUsageFactorShort": "0xec58abc0c1c902e8df7ed4f6968dbfd88228e741bfd63bf3efc635e0d7c9bb9d",
|
|
@@ -8544,6 +8544,67 @@
|
|
|
8544
8544
|
"virtualLongTokenId": "0xaab37f889b9680dda34f58a689de3023cb22f7ae14d32a3c1d45798a973db1f5",
|
|
8545
8545
|
"virtualShortTokenId": "0xd5258cb84f0039be58306488e8df941c05f3cf4f219e92aacb6561c736bbb960"
|
|
8546
8546
|
},
|
|
8547
|
+
"0x470128853D74dab7423904a20eA5AA230e9e561B": {
|
|
8548
|
+
"isDisabled": "0xfe243a54564541c534d5eeae5e63c2d5db84aa8bd25a4a754408efc202e8d6e5",
|
|
8549
|
+
"maxLongPoolAmount": "0x39205af116753605d966898b83c4ec7df6aeb18e02c8380c9369f5d6bbfff636",
|
|
8550
|
+
"maxShortPoolAmount": "0xe069ff8a01ec920ec3918881607fbf87ee82fac4fe4419588bd04ecb25e86c5f",
|
|
8551
|
+
"maxLongPoolUsdForDeposit": "0x5fed054a389bf855aaf752f849f9aec169c13add29412126eb973982caac30dc",
|
|
8552
|
+
"maxShortPoolUsdForDeposit": "0x9874ece30abf39e18219153b11ae45ee25422096f35af32bdeaec681d6ec1522",
|
|
8553
|
+
"reserveFactorLong": "0x8005b75fdbad97e030d8cd27d3e8bc3fa07cb49500876115217e8bec4e8f210d",
|
|
8554
|
+
"reserveFactorShort": "0xa5140d82a4b20acf9ba665b133a8eb3003b8e9339b94bc4a561530da63ea6cfe",
|
|
8555
|
+
"openInterestReserveFactorLong": "0xade22aa01e5e5f10f593163ab9f956e8c43c01c3406ce610c5dad851032503a0",
|
|
8556
|
+
"openInterestReserveFactorShort": "0x9e51713a0dc904a819b3998da79b49709420b7d1796e7d98345113da92641ba7",
|
|
8557
|
+
"maxOpenInterestLong": "0xdb04bf3c179c1a2b89441879b9e6b198c0e29cf99a1195594fedb171e0f848ca",
|
|
8558
|
+
"maxOpenInterestShort": "0x9546febaa71b4e976ef4cf635076cc14f5dc68a4bfb784bd4ae39cfbdc3b9a75",
|
|
8559
|
+
"minPositionImpactPoolAmount": "0xe4262c3a746be3506435094aa18433081dcce819b6eef64578363b89f8af0018",
|
|
8560
|
+
"positionImpactPoolDistributionRate": "0x0e4c6c4ba31a6e94f6df0ee037f7884d369cc59f05698e2be943843b541b3b2f",
|
|
8561
|
+
"borrowingFactorLong": "0x8d0f57b99783d2c5ad53fe6fdc31bbc29a725f843e247b7a72ff3f79f045596b",
|
|
8562
|
+
"borrowingFactorShort": "0xe6c31c713cf022d3d662f04700861119efa2dea5a1691a3eb4cfdf75c28d1f6d",
|
|
8563
|
+
"borrowingExponentFactorLong": "0x53056a4ac567795f4d9885f20706ee74ec6993440a7b43439e72c02379f3e878",
|
|
8564
|
+
"borrowingExponentFactorShort": "0xa2bdcb3141e0770697a392944e1bd583a3c851e2ba72e59d65b99617b38b4fc0",
|
|
8565
|
+
"fundingFactor": "0x2a86348096e5a76bc46ab7286f3012cc403a4da5a63a5a78ccaa4ec24732fedb",
|
|
8566
|
+
"fundingExponentFactor": "0xd4828665a6d6b9ab81d76dd9d7bf38ed221e2d4bcc6f35a851e42f0f48f98e92",
|
|
8567
|
+
"fundingIncreaseFactorPerSecond": "0x7c35ce6e2417fcf8fa19bc8f6862e395aacd0eb546821f8164d046f9224c7dc1",
|
|
8568
|
+
"fundingDecreaseFactorPerSecond": "0x3d5d433151ae449ca355115a730d52ce1c945e36cb340a408329e0fa6fd677b0",
|
|
8569
|
+
"thresholdForStableFunding": "0x3785587cc950cb348063323c282242b14be9421fc64fdfe79cb8c71de2371289",
|
|
8570
|
+
"thresholdForDecreaseFunding": "0xe535526955c78fed5c4dc454eb1a4b931396e4e4a861461e43ba9ca660175338",
|
|
8571
|
+
"minFundingFactorPerSecond": "0x7d9bd63fb8d9db9345f89da4323130937c15142f30c52cf0c2c3f61965554b8c",
|
|
8572
|
+
"maxFundingFactorPerSecond": "0xc3583272b45beb068172fe8b0c428e9ba5a9d90513d11e2e7f9d3f50c4891175",
|
|
8573
|
+
"maxPnlFactorForTradersLong": "0xfc827e8022bb9470e4b6e80625af561298a89a21349a7f28002227d104aaa340",
|
|
8574
|
+
"maxPnlFactorForTradersShort": "0x72cf2f1f4d28a7a7bc591871fb733976b9b5be06131fba40ea272163ee1b4a5b",
|
|
8575
|
+
"maxPnlFactorForDepositsLong": "0xd605366e5a7ff3abd0d76cf57e1788446fae68b7ed21ab3279c430855414e3e7",
|
|
8576
|
+
"maxPnlFactorForDepositsShort": "0xdba9cc56b9ccfff70ce0f5269915cd4a9e3d467f0fbcd1572f245005cb9d0b00",
|
|
8577
|
+
"maxPnlFactorForWithdrawalsLong": "0x3b0c3e6d816414ad07c367167c68c43c4fed6b1190d72db03807bfa4dfae2911",
|
|
8578
|
+
"maxPnlFactorForWithdrawalsShort": "0x735cc2452ca08e74dd09ff1fa52e7ff6ab35da3e14fc103cc8a43d87395b5976",
|
|
8579
|
+
"positionFeeFactorForBalanceWasImproved": "0x087f8ffb10b80b5ac2140d51a16cf6e3b993673569626d8384d899ca1768fb6e",
|
|
8580
|
+
"positionFeeFactorForBalanceWasNotImproved": "0x93db7fe18681e1033baa91aadd2fbed9c821cdd016c8f0e3b2f79c7873cb9592",
|
|
8581
|
+
"positionImpactFactorPositive": "0x297fa7e7b636003945b564c16070b2659d71a80fd6f74165c5ff7a458a9ddcf5",
|
|
8582
|
+
"positionImpactFactorNegative": "0xd373bf8c89b270fe6b011b4cc5aa9f1cd0efe86f67b4a5640c20c07ebb5866f0",
|
|
8583
|
+
"maxPositionImpactFactorPositive": "0xb95147c91cfefc2b5bc56478bc89acc250c96be349117daf81f3c7163c659cb3",
|
|
8584
|
+
"maxPositionImpactFactorNegative": "0xc050b04300e901112d441469127596785a8cf7504117260dc7f7704a1fa36e06",
|
|
8585
|
+
"maxPositionImpactFactorForLiquidations": "0xf131c7d0f04481d0b47003445bc3343174376c0b885c4128b1e4c1b8fd0ce0fb",
|
|
8586
|
+
"maxLendableImpactFactor": "0x8c4ff7114d4241b28aae17fbb4c399f01e86af274560a212dc383e06e9981f1d",
|
|
8587
|
+
"maxLendableImpactFactorForWithdrawals": "0xef5bfd25b3655d058bea6025948abf09ea95b1b3d3b183880f5dc5c077498a1b",
|
|
8588
|
+
"maxLendableImpactUsd": "0x61a580a5e5382029facb4c776a0335d4034130e87e2f788db8151d89918eeb64",
|
|
8589
|
+
"lentPositionImpactPoolAmount": "0x6553c99fe8bc2a2a2ee509acd790a9075a4d6c1bfc29f84ec1aa88e5def086fb",
|
|
8590
|
+
"minCollateralFactor": "0x708f3743ff03fa69e9aa5d4038c8f2984477e2169f30ef2f145c53ca83e33db7",
|
|
8591
|
+
"minCollateralFactorForLiquidation": "0xe47c118c844f1da524087647c205fdca711510edc9768c00187156fbedcb9a4e",
|
|
8592
|
+
"minCollateralFactorForOpenInterestLong": "0x461b23d60d80970a3d0218cfc4530a7e4a2a2531c792d2c2781a546feebefa03",
|
|
8593
|
+
"minCollateralFactorForOpenInterestShort": "0xf087f5a1e94da17538546bbd6bbd1d7cfc938715d5cfad263c16c7065ee7f2a0",
|
|
8594
|
+
"positionImpactExponentFactorPositive": "0xdab3143b127c611e5bdf62e6eceeb69b795d6b3e643c1fca8e25d0176548c6b4",
|
|
8595
|
+
"positionImpactExponentFactorNegative": "0x2347c2bad621059109cbf2f2d0241ac3a3fa717816e749dc2d8b2e666bff4b57",
|
|
8596
|
+
"swapFeeFactorForBalanceWasImproved": "0x956d64be84e25d83f19a191d3115bd426b554b9d884d075625b1998a440c1ac0",
|
|
8597
|
+
"swapFeeFactorForBalanceWasNotImproved": "0x1dbf423caf962d3c39350ae346b277db997d2c140da420b24c0bebd603477593",
|
|
8598
|
+
"atomicSwapFeeFactor": "0xff91ee6de493812a25d525efa1e67ff47d2df0a0f59fda1f8f805cbff6ad884d",
|
|
8599
|
+
"swapImpactFactorPositive": "0x040389937579e93803e4eef90e2e524d1ea01e6890fcc62058801758d67a549f",
|
|
8600
|
+
"swapImpactFactorNegative": "0x31f9bba4c1cfcde524a5a73add46d38d57f362a36cbd5b216b5bb96d34297e22",
|
|
8601
|
+
"swapImpactExponentFactor": "0xf438467b2ca2e25ad577f3ea39caf610ef21d0ee0f1aa3e633044cc6b9fd8d72",
|
|
8602
|
+
"withdrawalFeeFactorBalanceWasImproved": "0x45a9a93feb42de4392939fff459c0ba3a2513a3f750865ed68e8f118d7c20203",
|
|
8603
|
+
"withdrawalFeeFactorBalanceWasNotImproved": "0xd5fea53fb1348b694edc1fe97f87da9923b847a73874774a9d6236e1a9f989f5",
|
|
8604
|
+
"virtualMarketId": "0xced49eb3d9ebb85529707d3b67a0fd9a3c6a749bbb1934f0888f51b564f11c57",
|
|
8605
|
+
"virtualLongTokenId": "0xaab37f889b9680dda34f58a689de3023cb22f7ae14d32a3c1d45798a973db1f5",
|
|
8606
|
+
"virtualShortTokenId": "0xd5258cb84f0039be58306488e8df941c05f3cf4f219e92aacb6561c736bbb960"
|
|
8607
|
+
},
|
|
8547
8608
|
"0xE26E7b91143f367445f1c0a5dCf4f4aC8EaDcDb1": {
|
|
8548
8609
|
"isDisabled": "0x89d68641baa8443dcff05c06834a08f6a7c1edef759f2e89505fe251b6411cb5",
|
|
8549
8610
|
"maxLongPoolAmount": "0x5c7eb3fb9940700a0eb6d0bc4b2efcec205e4bcd85611f2e63a40fb71b48a68b",
|
|
@@ -2104,6 +2104,21 @@
|
|
|
2104
2104
|
"shortInterestInTokensUsingLongToken": "0xccb072d4c5cf74a4a1d0e6f80b7628dba861d6c95037409fc42800e72a935d7c",
|
|
2105
2105
|
"shortInterestInTokensUsingShortToken": "0x3e1a9a944352a0080a281988fbf04a6b9c44a82767c10d16eb11ad80b1fb5d65"
|
|
2106
2106
|
},
|
|
2107
|
+
"0x470128853D74dab7423904a20eA5AA230e9e561B": {
|
|
2108
|
+
"longPoolAmount": "0x42bb5e8d4ca514798b21267763eeb4d3b35a623bd89689ef66ec1f007087b161",
|
|
2109
|
+
"shortPoolAmount": "0x8158632c1d7b805bbf9edba3e15fde98b5cd4d32ed70009ac3f6224ec47fc5ae",
|
|
2110
|
+
"positionImpactPoolAmount": "0xde24f47762b924ccb93b3434c4dec1224b581cae29eb84def00e25707f0598b3",
|
|
2111
|
+
"swapImpactPoolAmountLong": "0x9cce19aabd82c41d0b6b7df7e456057c78870b31379d4a7b1dab5a4e1c4975ff",
|
|
2112
|
+
"swapImpactPoolAmountShort": "0x1c76620a18e8abb145e352f6d7a618510e4da180beeb764f18294a47ff109ff4",
|
|
2113
|
+
"longInterestUsingLongToken": "0x27c74bd1c225f15925642df8ccae6a49d75cddc7d9365133a54ce3af9898876e",
|
|
2114
|
+
"longInterestUsingShortToken": "0xa2d438ebe99ba84f775d7c2c1c8e40a3aafdde88ed68c9d9b5bdf4fdac544b6e",
|
|
2115
|
+
"shortInterestUsingLongToken": "0x7587ab70dd363bcf4c60377a304b9fe072b73aa131f0d195c4f069e95ba1919d",
|
|
2116
|
+
"shortInterestUsingShortToken": "0xed61a26c939934abf69c8688610fe123ecc1b927522671d4056d0c1fb77feb65",
|
|
2117
|
+
"longInterestInTokensUsingLongToken": "0x892c0dd3d5da401bb0dd0822ca5e5acc861ce6842a3c3500512f89102e419529",
|
|
2118
|
+
"longInterestInTokensUsingShortToken": "0x51d2161b7c40b9f680a8d510dedab14fbc49a3415d1b7fce425ce455b8f44e92",
|
|
2119
|
+
"shortInterestInTokensUsingLongToken": "0x2bdcec38c2d0016c12d50e0ac27709d4856c2d27ffe78e58753e58d3f1ce7570",
|
|
2120
|
+
"shortInterestInTokensUsingShortToken": "0x8695147e4efe6f8ad95dee38bd50f33fb632c55e6119ee65d8716e8bf683dacd"
|
|
2121
|
+
},
|
|
2107
2122
|
"0xE26E7b91143f367445f1c0a5dCf4f4aC8EaDcDb1": {
|
|
2108
2123
|
"longPoolAmount": "0x265452d70a411300a2535b1c9c212a3dcea8eb2793c66aec2fcd595776ba2c0b",
|
|
2109
2124
|
"shortPoolAmount": "0x24f88d54e73a74c9c029fff00404272e44a15d9f931be2df1433f43ef5e5e428",
|
|
@@ -6,6 +6,9 @@ import { zeroAddress } from "viem";
|
|
|
6
6
|
import { ARBITRUM, ARBITRUM_SEPOLIA, AVALANCHE, AVALANCHE_FUJI, BOTANIX, MEGAETH } from "./chains";
|
|
7
7
|
import { convertTokenAddress, getToken, getTokenBySymbol } from "./tokens";
|
|
8
8
|
export const SWAP_GRAPH_MAX_MARKETS_PER_TOKEN = 5;
|
|
9
|
+
export const UI_MAX_LEVERAGE_BY_MARKET = {
|
|
10
|
+
"0x470128853D74dab7423904a20eA5AA230e9e561B": 10,
|
|
11
|
+
};
|
|
9
12
|
/*
|
|
10
13
|
ATTENTION
|
|
11
14
|
When adding new markets, please add them also to the end of the list in ./src/configs/static/sortedMarkets.ts
|
|
@@ -936,6 +939,13 @@ export const MARKETS = {
|
|
|
936
939
|
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
|
|
937
940
|
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
938
941
|
},
|
|
942
|
+
// SPCX/USD [WETH-USDC]
|
|
943
|
+
"0x470128853D74dab7423904a20eA5AA230e9e561B": {
|
|
944
|
+
marketTokenAddress: "0x470128853D74dab7423904a20eA5AA230e9e561B",
|
|
945
|
+
indexTokenAddress: "0x8CBd0d5d81e7957123E6D8fFaE657a40bDC5691b",
|
|
946
|
+
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
|
|
947
|
+
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
948
|
+
},
|
|
939
949
|
// MEGA/USD [WETH-USDC]
|
|
940
950
|
"0xE26E7b91143f367445f1c0a5dCf4f4aC8EaDcDb1": {
|
|
941
951
|
marketTokenAddress: "0xE26E7b91143f367445f1c0a5dCf4f4aC8EaDcDb1",
|
|
@@ -1237,6 +1237,16 @@ export const TOKENS = {
|
|
|
1237
1237
|
imageUrl: "https://s2.coinmarketcap.com/static/img/coins/64x64/39464.png",
|
|
1238
1238
|
explorerUrl: "https://arbiscan.io/token/0x620aC65BE29066Bb9D1E92C65b35B9fD321Fb963",
|
|
1239
1239
|
},
|
|
1240
|
+
{
|
|
1241
|
+
name: "SpaceX",
|
|
1242
|
+
symbol: "SPCX",
|
|
1243
|
+
address: "0x8CBd0d5d81e7957123E6D8fFaE657a40bDC5691b",
|
|
1244
|
+
isSynthetic: true,
|
|
1245
|
+
decimals: 18,
|
|
1246
|
+
categories: ["tradfi", "pre-ipo"],
|
|
1247
|
+
searchAliases: ["Space", "X"],
|
|
1248
|
+
explorerUrl: "https://arbiscan.io/token/0x8CBd0d5d81e7957123E6D8fFaE657a40bDC5691b",
|
|
1249
|
+
},
|
|
1240
1250
|
{
|
|
1241
1251
|
name: "MegaETH",
|
|
1242
1252
|
symbol: "MEGA",
|
|
@@ -2083,6 +2093,7 @@ export const TOKEN_COLOR_MAP = {
|
|
|
2083
2093
|
XAG: "#ADABB8",
|
|
2084
2094
|
GOLD: "#D69A00",
|
|
2085
2095
|
SILVER: "#ADABB8",
|
|
2096
|
+
SPCX: "#1A1E21",
|
|
2086
2097
|
XPT: "#C2B8AB",
|
|
2087
2098
|
XPD: "#A9ACB6",
|
|
2088
2099
|
default: "#6062a6",
|
|
@@ -138,6 +138,12 @@ describe("getMaxLeverageByMinCollateralFactor", () => {
|
|
|
138
138
|
it("returns correct leverage for a given factor", () => {
|
|
139
139
|
expect(getMaxLeverageByMinCollateralFactor(1000000000000000000n)).toBe(10000000000000000);
|
|
140
140
|
});
|
|
141
|
+
it("caps SPCX min-collateral-factor leverage at 10x", () => {
|
|
142
|
+
expect(getMaxLeverageByMinCollateralFactor(1000000000000000000n, "0x470128853D74dab7423904a20eA5AA230e9e561B")).toBe(100000);
|
|
143
|
+
});
|
|
144
|
+
it("caps SPCX default min-collateral-factor leverage at 10x", () => {
|
|
145
|
+
expect(getMaxLeverageByMinCollateralFactor(undefined, "0x470128853D74dab7423904a20eA5AA230e9e561B")).toBe(100000);
|
|
146
|
+
});
|
|
141
147
|
});
|
|
142
148
|
describe("getMaxAllowedLeverage", () => {
|
|
143
149
|
// Factors are expressed in PRECISION units (1e30 == 100%).
|
|
@@ -228,6 +234,30 @@ describe("getMaxAllowedLeverage", () => {
|
|
|
228
234
|
positionFeeFactorForBalanceWasNotImproved: pct(0.05),
|
|
229
235
|
})).toBe(bps(25));
|
|
230
236
|
});
|
|
237
|
+
it("caps SPCX UI max leverage at 10x", () => {
|
|
238
|
+
expect(getMaxAllowedLeverage({
|
|
239
|
+
marketAddress: "0x470128853D74dab7423904a20eA5AA230e9e561B",
|
|
240
|
+
minCollateralFactor: pct(0.5),
|
|
241
|
+
minCollateralFactorForLiquidation: pct(0.5),
|
|
242
|
+
positionFeeFactorForBalanceWasNotImproved: pct(0.05),
|
|
243
|
+
})).toBe(bps(10));
|
|
244
|
+
});
|
|
245
|
+
it("does not cap other markets with matching factors", () => {
|
|
246
|
+
expect(getMaxAllowedLeverage({
|
|
247
|
+
marketAddress: "0x0000000000000000000000000000000000000000",
|
|
248
|
+
minCollateralFactor: pct(0.5),
|
|
249
|
+
minCollateralFactorForLiquidation: pct(0.5),
|
|
250
|
+
positionFeeFactorForBalanceWasNotImproved: pct(0.05),
|
|
251
|
+
})).toBe(bps(100));
|
|
252
|
+
});
|
|
253
|
+
it("keeps lower dynamic max leverage for SPCX when factors require it", () => {
|
|
254
|
+
expect(getMaxAllowedLeverage({
|
|
255
|
+
marketAddress: "0x470128853D74dab7423904a20eA5AA230e9e561B",
|
|
256
|
+
minCollateralFactor: pct(10),
|
|
257
|
+
minCollateralFactorForLiquidation: pct(10),
|
|
258
|
+
positionFeeFactorForBalanceWasNotImproved: pct(0.05),
|
|
259
|
+
})).toBe(bps(5));
|
|
260
|
+
});
|
|
231
261
|
});
|
|
232
262
|
describe("getOppositeCollateral", () => {
|
|
233
263
|
const marketInfo = {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { zeroAddress } from "viem";
|
|
2
2
|
import { BASIS_POINTS_DIVISOR, BASIS_POINTS_DIVISOR_BIGINT } from "../../configs/factors";
|
|
3
|
+
import { UI_MAX_LEVERAGE_BY_MARKET } from "../../configs/markets";
|
|
3
4
|
import { convertTokenAddress, getTokenVisualMultiplier, NATIVE_TOKEN_ADDRESS } from "../../configs/tokens";
|
|
4
5
|
import { bigMath } from "../bigmath";
|
|
5
6
|
import { getBorrowingFactorPerPeriod, getFundingFactorPerPeriod } from "../fees";
|
|
@@ -51,12 +52,10 @@ export function getTokenPoolType(marketInfo, tokenAddress) {
|
|
|
51
52
|
if (longToken.address === shortToken.address && tokenAddress === longToken.address) {
|
|
52
53
|
return "long";
|
|
53
54
|
}
|
|
54
|
-
if (tokenAddress === longToken.address ||
|
|
55
|
-
(tokenAddress === NATIVE_TOKEN_ADDRESS && longToken.isWrapped)) {
|
|
55
|
+
if (tokenAddress === longToken.address || (tokenAddress === NATIVE_TOKEN_ADDRESS && longToken.isWrapped)) {
|
|
56
56
|
return "long";
|
|
57
57
|
}
|
|
58
|
-
if (tokenAddress === shortToken.address ||
|
|
59
|
-
(tokenAddress === NATIVE_TOKEN_ADDRESS && shortToken.isWrapped)) {
|
|
58
|
+
if (tokenAddress === shortToken.address || (tokenAddress === NATIVE_TOKEN_ADDRESS && shortToken.isWrapped)) {
|
|
60
59
|
return "short";
|
|
61
60
|
}
|
|
62
61
|
return undefined;
|
|
@@ -91,30 +90,35 @@ export function getCappedPoolPnl(p) {
|
|
|
91
90
|
* user is not opening a new size.
|
|
92
91
|
*/
|
|
93
92
|
const ROUNDING_VALUE = 10000;
|
|
94
|
-
|
|
93
|
+
function capByUiMaxLeverageOverride(value, marketAddress) {
|
|
94
|
+
const uiMaxLeverageOverride = marketAddress ? UI_MAX_LEVERAGE_BY_MARKET[marketAddress] : undefined;
|
|
95
|
+
return uiMaxLeverageOverride === undefined ? value : Math.min(value, uiMaxLeverageOverride * BASIS_POINTS_DIVISOR);
|
|
96
|
+
}
|
|
97
|
+
export function getMaxLeverageByMinCollateralFactor(minCollateralFactor, marketAddress) {
|
|
95
98
|
if (minCollateralFactor === undefined)
|
|
96
|
-
return 100 * BASIS_POINTS_DIVISOR;
|
|
99
|
+
return capByUiMaxLeverageOverride(100 * BASIS_POINTS_DIVISOR, marketAddress);
|
|
97
100
|
if (minCollateralFactor === 0n)
|
|
98
|
-
return 100 * BASIS_POINTS_DIVISOR;
|
|
101
|
+
return capByUiMaxLeverageOverride(100 * BASIS_POINTS_DIVISOR, marketAddress);
|
|
99
102
|
const x = bigMath.mulDiv(PRECISION, BASIS_POINTS_DIVISOR_BIGINT, minCollateralFactor);
|
|
100
103
|
const rounded = Math.round(Number(x) / ROUNDING_VALUE) * ROUNDING_VALUE;
|
|
101
|
-
return rounded;
|
|
104
|
+
return capByUiMaxLeverageOverride(rounded, marketAddress);
|
|
102
105
|
}
|
|
103
106
|
const MAX_ALLOWED_LEVERAGE_STEP_BP = 5 * BASIS_POINTS_DIVISOR;
|
|
104
|
-
export function getMaxAllowedLeverage({ minCollateralFactor, minCollateralFactorForLiquidation, positionFeeFactorForBalanceWasNotImproved, }) {
|
|
107
|
+
export function getMaxAllowedLeverage({ marketAddress, minCollateralFactor, minCollateralFactorForLiquidation, positionFeeFactorForBalanceWasNotImproved, }) {
|
|
105
108
|
if (minCollateralFactor === undefined ||
|
|
106
109
|
minCollateralFactor === 0n ||
|
|
107
110
|
minCollateralFactorForLiquidation === undefined ||
|
|
108
111
|
minCollateralFactorForLiquidation === 0n ||
|
|
109
112
|
positionFeeFactorForBalanceWasNotImproved === undefined) {
|
|
110
|
-
return 100 * BASIS_POINTS_DIVISOR;
|
|
113
|
+
return capByUiMaxLeverageOverride(100 * BASIS_POINTS_DIVISOR, marketAddress);
|
|
111
114
|
}
|
|
112
115
|
const openingDenominator = minCollateralFactor + 2n * positionFeeFactorForBalanceWasNotImproved;
|
|
113
116
|
const openingMaxBp = bigMath.mulDiv(PRECISION, BASIS_POINTS_DIVISOR_BIGINT, openingDenominator);
|
|
114
117
|
const liquidationDenominator = 2n * minCollateralFactorForLiquidation;
|
|
115
118
|
const liquidationMaxBp = bigMath.mulDiv(PRECISION, BASIS_POINTS_DIVISOR_BIGINT, liquidationDenominator);
|
|
116
119
|
const rawMaxBp = bigMath.min(openingMaxBp, liquidationMaxBp);
|
|
117
|
-
|
|
120
|
+
const maxAllowedLeverage = Math.floor(Number(rawMaxBp) / MAX_ALLOWED_LEVERAGE_STEP_BP) * MAX_ALLOWED_LEVERAGE_STEP_BP;
|
|
121
|
+
return capByUiMaxLeverageOverride(maxAllowedLeverage, marketAddress);
|
|
118
122
|
}
|
|
119
123
|
export function getOppositeCollateral(marketInfo, tokenAddress) {
|
|
120
124
|
const poolType = getTokenPoolType(marketInfo, tokenAddress);
|
|
@@ -344,7 +348,7 @@ export function composeFullMarketsInfoData({ chainId, marketsAddresses, rawMarke
|
|
|
344
348
|
return data;
|
|
345
349
|
}
|
|
346
350
|
export function getMarketWithTiers(marketInfo, constants) {
|
|
347
|
-
const maxLeverage = getMaxLeverageByMinCollateralFactor(marketInfo.minCollateralFactor);
|
|
351
|
+
const maxLeverage = getMaxLeverageByMinCollateralFactor(marketInfo.minCollateralFactor, marketInfo.marketTokenAddress);
|
|
348
352
|
const maxLeverageBigint = BigInt(maxLeverage);
|
|
349
353
|
const leverageTiers = [
|
|
350
354
|
{
|
|
@@ -380,6 +380,7 @@ export function getPositionInfo(p) {
|
|
|
380
380
|
pnl: undefined,
|
|
381
381
|
});
|
|
382
382
|
const maxAllowedLeverage = getMaxAllowedLeverage({
|
|
383
|
+
marketAddress: marketInfo.marketTokenAddress,
|
|
383
384
|
minCollateralFactor: marketInfo.minCollateralFactor,
|
|
384
385
|
minCollateralFactorForLiquidation: marketInfo.minCollateralFactorForLiquidation,
|
|
385
386
|
positionFeeFactorForBalanceWasNotImproved: marketInfo.positionFeeFactorForBalanceWasNotImproved,
|