@gmx-io/sdk 0.0.1-alpha-1

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.
Files changed (237) hide show
  1. package/LICENSE +40 -0
  2. package/README.md +79 -0
  3. package/build/abis/CustomErrors.json +3254 -0
  4. package/build/abis/DataStore.json +1440 -0
  5. package/build/abis/ERC721.json +442 -0
  6. package/build/abis/EventEmitter.json +2065 -0
  7. package/build/abis/ExchangeRouter.json +1598 -0
  8. package/build/abis/GMT.json +522 -0
  9. package/build/abis/GlpManager.json +592 -0
  10. package/build/abis/GlvReader.json +1425 -0
  11. package/build/abis/GlvRouter.json +613 -0
  12. package/build/abis/GmxMigrator.json +657 -0
  13. package/build/abis/GovToken.json +1121 -0
  14. package/build/abis/MintableBaseToken.json +696 -0
  15. package/build/abis/Multicall.json +333 -0
  16. package/build/abis/OrderBook.json +1997 -0
  17. package/build/abis/OrderBookReader.json +111 -0
  18. package/build/abis/OrderExecutor.json +122 -0
  19. package/build/abis/PositionManager.json +1165 -0
  20. package/build/abis/PositionRouter.json +2030 -0
  21. package/build/abis/Reader.json +355 -0
  22. package/build/abis/ReaderV2.json +630 -0
  23. package/build/abis/ReferralStorage.json +507 -0
  24. package/build/abis/RewardReader.json +86 -0
  25. package/build/abis/RewardRouter.json +769 -0
  26. package/build/abis/RewardTracker.json +918 -0
  27. package/build/abis/Router-v2.json +605 -0
  28. package/build/abis/Router.json +605 -0
  29. package/build/abis/SubaccountRouter.json +648 -0
  30. package/build/abis/SyntheticsReader.json +4577 -0
  31. package/build/abis/SyntheticsRouter.json +77 -0
  32. package/build/abis/Timelock.json +1737 -0
  33. package/build/abis/Token.json +345 -0
  34. package/build/abis/Treasury.json +411 -0
  35. package/build/abis/UniPool.json +89 -0
  36. package/build/abis/UniswapV2.json +1 -0
  37. package/build/abis/Vault.json +3220 -0
  38. package/build/abis/VaultReader.json +87 -0
  39. package/build/abis/VaultV2.json +3019 -0
  40. package/build/abis/VaultV2b.json +3220 -0
  41. package/build/abis/Vester.json +1031 -0
  42. package/build/abis/WETH.json +320 -0
  43. package/build/abis/YieldFarm.json +599 -0
  44. package/build/abis/YieldToken.json +560 -0
  45. package/build/prebuilt/hashedMarketConfigKeys.json +3658 -0
  46. package/build/prebuilt/hashedMarketValuesKeys.json +1103 -0
  47. package/build/prebuilt/index.ts +28 -0
  48. package/build/src/abis/CustomErrors.json +3254 -0
  49. package/build/src/abis/DataStore.json +1440 -0
  50. package/build/src/abis/ERC721.json +442 -0
  51. package/build/src/abis/EventEmitter.json +2065 -0
  52. package/build/src/abis/ExchangeRouter.json +1598 -0
  53. package/build/src/abis/GMT.json +522 -0
  54. package/build/src/abis/GlpManager.json +591 -0
  55. package/build/src/abis/GlvReader.json +1424 -0
  56. package/build/src/abis/GlvRouter.json +612 -0
  57. package/build/src/abis/GmxMigrator.json +657 -0
  58. package/build/src/abis/GovToken.json +1121 -0
  59. package/build/src/abis/MintableBaseToken.json +696 -0
  60. package/build/src/abis/Multicall.json +333 -0
  61. package/build/src/abis/OrderBook.json +1997 -0
  62. package/build/src/abis/OrderBookReader.json +111 -0
  63. package/build/src/abis/OrderExecutor.json +122 -0
  64. package/build/src/abis/PositionManager.json +1165 -0
  65. package/build/src/abis/PositionRouter.json +2030 -0
  66. package/build/src/abis/Reader.json +355 -0
  67. package/build/src/abis/ReaderV2.json +630 -0
  68. package/build/src/abis/ReferralStorage.json +507 -0
  69. package/build/src/abis/RewardReader.json +86 -0
  70. package/build/src/abis/RewardRouter.json +769 -0
  71. package/build/src/abis/RewardTracker.json +918 -0
  72. package/build/src/abis/Router-v2.json +605 -0
  73. package/build/src/abis/Router.json +605 -0
  74. package/build/src/abis/SubaccountRouter.json +648 -0
  75. package/build/src/abis/SyntheticsReader.json +4577 -0
  76. package/build/src/abis/SyntheticsRouter.json +77 -0
  77. package/build/src/abis/Timelock.json +1737 -0
  78. package/build/src/abis/Token.json +345 -0
  79. package/build/src/abis/Treasury.json +411 -0
  80. package/build/src/abis/UniPool.json +89 -0
  81. package/build/src/abis/UniswapV2.json +1 -0
  82. package/build/src/abis/Vault.json +3220 -0
  83. package/build/src/abis/VaultReader.json +87 -0
  84. package/build/src/abis/VaultV2.json +3019 -0
  85. package/build/src/abis/VaultV2b.json +3220 -0
  86. package/build/src/abis/Vester.json +1031 -0
  87. package/build/src/abis/WETH.json +320 -0
  88. package/build/src/abis/YieldFarm.json +599 -0
  89. package/build/src/abis/YieldToken.json +560 -0
  90. package/build/src/configs/batch.d.ts +6 -0
  91. package/build/src/configs/batch.js +51 -0
  92. package/build/src/configs/chains.d.ts +37 -0
  93. package/build/src/configs/chains.js +90 -0
  94. package/build/src/configs/contracts.d.ts +2 -0
  95. package/build/src/configs/contracts.js +218 -0
  96. package/build/src/configs/dataStore.d.ts +149 -0
  97. package/build/src/configs/dataStore.js +276 -0
  98. package/build/src/configs/factors.d.ts +20 -0
  99. package/build/src/configs/factors.js +21 -0
  100. package/build/src/configs/markets.d.ts +8 -0
  101. package/build/src/configs/markets.js +528 -0
  102. package/build/src/configs/subgraph.d.ts +3 -0
  103. package/build/src/configs/subgraph.js +3 -0
  104. package/build/src/configs/tokens.d.ts +89 -0
  105. package/build/src/configs/tokens.js +1269 -0
  106. package/build/src/index.d.ts +44 -0
  107. package/build/src/index.js +245 -0
  108. package/build/src/modules/accounts/accounts.d.ts +5 -0
  109. package/build/src/modules/accounts/accounts.js +36 -0
  110. package/build/src/modules/accounts/accounts.spec.d.ts +1 -0
  111. package/build/src/modules/accounts/accounts.spec.js +7 -0
  112. package/build/src/modules/base.d.ts +9 -0
  113. package/build/src/modules/base.js +15 -0
  114. package/build/src/modules/markets/index.d.ts +26 -0
  115. package/build/src/modules/markets/index.js +339 -0
  116. package/build/src/modules/markets/markets.spec.d.ts +1 -0
  117. package/build/src/modules/markets/markets.spec.js +38 -0
  118. package/build/src/modules/markets/query-builders.d.ts +40 -0
  119. package/build/src/modules/markets/query-builders.js +379 -0
  120. package/build/src/modules/markets/types.d.ts +42 -0
  121. package/build/src/modules/markets/types.js +1 -0
  122. package/build/src/modules/oracle.d.ts +31 -0
  123. package/build/src/modules/oracle.js +53 -0
  124. package/build/src/modules/orders/orders.d.ts +60 -0
  125. package/build/src/modules/orders/orders.js +270 -0
  126. package/build/src/modules/orders/orders.spec.d.ts +1 -0
  127. package/build/src/modules/orders/orders.spec.js +16 -0
  128. package/build/src/modules/orders/transactions/cancelOrdersTxn.d.ts +6 -0
  129. package/build/src/modules/orders/transactions/cancelOrdersTxn.js +15 -0
  130. package/build/src/modules/orders/transactions/createDecreaseOrderTxn.d.ts +32 -0
  131. package/build/src/modules/orders/transactions/createDecreaseOrderTxn.js +98 -0
  132. package/build/src/modules/orders/transactions/createIncreaseOrderTxn.d.ts +77 -0
  133. package/build/src/modules/orders/transactions/createIncreaseOrderTxn.js +164 -0
  134. package/build/src/modules/orders/transactions/createSwapOrderTxn.d.ts +16 -0
  135. package/build/src/modules/orders/transactions/createSwapOrderTxn.js +97 -0
  136. package/build/src/modules/orders/transactions/createWrapOrUnwrapTxn.d.ts +6 -0
  137. package/build/src/modules/orders/transactions/createWrapOrUnwrapTxn.js +13 -0
  138. package/build/src/modules/orders/transactions/updateOrderTxn.d.ts +23 -0
  139. package/build/src/modules/orders/transactions/updateOrderTxn.js +44 -0
  140. package/build/src/modules/orders/utils.d.ts +248 -0
  141. package/build/src/modules/orders/utils.js +151 -0
  142. package/build/src/modules/positions/positions.d.ts +48 -0
  143. package/build/src/modules/positions/positions.js +563 -0
  144. package/build/src/modules/positions/positions.spec.d.ts +1 -0
  145. package/build/src/modules/positions/positions.spec.js +25 -0
  146. package/build/src/modules/tokens/tokens.d.ts +26 -0
  147. package/build/src/modules/tokens/tokens.js +132 -0
  148. package/build/src/modules/tokens/tokens.spec.d.ts +1 -0
  149. package/build/src/modules/tokens/tokens.spec.js +19 -0
  150. package/build/src/modules/trades/trades.d.ts +48 -0
  151. package/build/src/modules/trades/trades.js +390 -0
  152. package/build/src/modules/trades/trades.spec.d.ts +1 -0
  153. package/build/src/modules/trades/trades.spec.js +14 -0
  154. package/build/src/prebuilt/hashedMarketConfigKeys.json +3658 -0
  155. package/build/src/prebuilt/hashedMarketValuesKeys.json +1103 -0
  156. package/build/src/prebuilt/index.d.ts +14 -0
  157. package/build/src/prebuilt/index.js +9 -0
  158. package/build/src/types/amounts.d.ts +223 -0
  159. package/build/src/types/amounts.js +17 -0
  160. package/build/src/types/fees.d.ts +34 -0
  161. package/build/src/types/fees.js +1 -0
  162. package/build/src/types/markets.d.ts +143 -0
  163. package/build/src/types/markets.js +1 -0
  164. package/build/src/types/orders.d.ts +74 -0
  165. package/build/src/types/orders.js +33 -0
  166. package/build/src/types/positions.d.ts +53 -0
  167. package/build/src/types/positions.js +1 -0
  168. package/build/src/types/referrals.d.ts +124 -0
  169. package/build/src/types/referrals.js +9 -0
  170. package/build/src/types/sdk.d.ts +32 -0
  171. package/build/src/types/sdk.js +1 -0
  172. package/build/src/types/sidecarOrders.d.ts +54 -0
  173. package/build/src/types/sidecarOrders.js +1 -0
  174. package/build/src/types/syntheticsEvents.d.ts +88 -0
  175. package/build/src/types/syntheticsEvents.js +1 -0
  176. package/build/src/types/tokens.d.ts +89 -0
  177. package/build/src/types/tokens.js +1 -0
  178. package/build/src/types/trade.d.ts +223 -0
  179. package/build/src/types/trade.js +17 -0
  180. package/build/src/types/tradeHistory.d.ts +107 -0
  181. package/build/src/types/tradeHistory.js +8 -0
  182. package/build/src/utils/LruCache.d.ts +10 -0
  183. package/build/src/utils/LruCache.js +45 -0
  184. package/build/src/utils/bigmath.d.ts +7 -0
  185. package/build/src/utils/bigmath.js +23 -0
  186. package/build/src/utils/buildUrl.d.ts +1 -0
  187. package/build/src/utils/buildUrl.js +5 -0
  188. package/build/src/utils/callContract.d.ts +17 -0
  189. package/build/src/utils/callContract.js +133 -0
  190. package/build/src/utils/common.d.ts +2 -0
  191. package/build/src/utils/common.js +2 -0
  192. package/build/src/utils/fees/estimateOraclePriceCount.d.ts +6 -0
  193. package/build/src/utils/fees/estimateOraclePriceCount.js +19 -0
  194. package/build/src/utils/fees/executionFee.d.ts +59 -0
  195. package/build/src/utils/fees/executionFee.js +108 -0
  196. package/build/src/utils/fees/index.d.ts +29 -0
  197. package/build/src/utils/fees/index.js +89 -0
  198. package/build/src/utils/fees/priceImpact.d.ts +75 -0
  199. package/build/src/utils/fees/priceImpact.js +287 -0
  200. package/build/src/utils/graphqlFetcher.d.ts +1 -0
  201. package/build/src/utils/graphqlFetcher.js +18 -0
  202. package/build/src/utils/hash.d.ts +5 -0
  203. package/build/src/utils/hash.js +35 -0
  204. package/build/src/utils/marketKeysAndConfigs.d.ts +66 -0
  205. package/build/src/utils/marketKeysAndConfigs.js +257 -0
  206. package/build/src/utils/markets.d.ts +40 -0
  207. package/build/src/utils/markets.js +129 -0
  208. package/build/src/utils/multicall.d.ts +64 -0
  209. package/build/src/utils/multicall.js +116 -0
  210. package/build/src/utils/numbers.d.ts +9 -0
  211. package/build/src/utils/numbers.js +30 -0
  212. package/build/src/utils/objects.d.ts +18 -0
  213. package/build/src/utils/objects.js +30 -0
  214. package/build/src/utils/orders.d.ts +28 -0
  215. package/build/src/utils/orders.js +178 -0
  216. package/build/src/utils/positions.d.ts +60 -0
  217. package/build/src/utils/positions.js +133 -0
  218. package/build/src/utils/prices.d.ts +15 -0
  219. package/build/src/utils/prices.js +34 -0
  220. package/build/src/utils/referrals.d.ts +2 -0
  221. package/build/src/utils/referrals.js +27 -0
  222. package/build/src/utils/simulateExecuteOrder.d.ts +16 -0
  223. package/build/src/utils/simulateExecuteOrder.js +143 -0
  224. package/build/src/utils/slidingWindowFallbackSwitcher.d.ts +24 -0
  225. package/build/src/utils/slidingWindowFallbackSwitcher.js +40 -0
  226. package/build/src/utils/subgraph.d.ts +21 -0
  227. package/build/src/utils/subgraph.js +72 -0
  228. package/build/src/utils/swapStats.d.ts +35 -0
  229. package/build/src/utils/swapStats.js +197 -0
  230. package/build/src/utils/test.d.ts +2 -0
  231. package/build/src/utils/test.js +24 -0
  232. package/build/src/utils/tokens.d.ts +18 -0
  233. package/build/src/utils/tokens.js +64 -0
  234. package/build/src/utils/trade.d.ts +10 -0
  235. package/build/src/utils/trade.js +32 -0
  236. package/build/tsconfig.tsbuildinfo +1 -0
  237. package/package.json +96 -0
@@ -0,0 +1,276 @@
1
+ import { hashData, hashString } from "utils/hash";
2
+ export const POSITION_IMPACT_FACTOR_KEY = hashString("POSITION_IMPACT_FACTOR");
3
+ export const MAX_POSITION_IMPACT_FACTOR_KEY = hashString("MAX_POSITION_IMPACT_FACTOR");
4
+ export const POSITION_IMPACT_EXPONENT_FACTOR_KEY = hashString("POSITION_IMPACT_EXPONENT_FACTOR");
5
+ export const POSITION_FEE_FACTOR_KEY = hashString("POSITION_FEE_FACTOR");
6
+ export const SWAP_IMPACT_FACTOR_KEY = hashString("SWAP_IMPACT_FACTOR");
7
+ export const SWAP_IMPACT_EXPONENT_FACTOR_KEY = hashString("SWAP_IMPACT_EXPONENT_FACTOR");
8
+ export const SWAP_FEE_FACTOR_KEY = hashString("SWAP_FEE_FACTOR");
9
+ export const FEE_RECEIVER_DEPOSIT_FACTOR_KEY = hashString("FEE_RECEIVER_DEPOSIT_FACTOR");
10
+ export const BORROWING_FEE_RECEIVER_FACTOR_KEY = hashString("BORROWING_FEE_RECEIVER_FACTOR");
11
+ export const FEE_RECEIVER_WITHDRAWAL_FACTOR_KEY = hashString("FEE_RECEIVER_WITHDRAWAL_FACTOR");
12
+ export const FEE_RECEIVER_SWAP_FACTOR_KEY = hashString("FEE_RECEIVER_SWAP_FACTOR");
13
+ export const FEE_RECEIVER_POSITION_FACTOR_KEY = hashString("FEE_RECEIVER_POSITION_FACTOR");
14
+ export const OPEN_INTEREST_KEY = hashString("OPEN_INTEREST");
15
+ export const OPEN_INTEREST_IN_TOKENS_KEY = hashString("OPEN_INTEREST_IN_TOKENS");
16
+ export const POOL_AMOUNT_KEY = hashString("POOL_AMOUNT");
17
+ export const MAX_POOL_USD_FOR_DEPOSIT_KEY = hashString("MAX_POOL_USD_FOR_DEPOSIT");
18
+ export const MAX_POOL_AMOUNT_KEY = hashString("MAX_POOL_AMOUNT");
19
+ export const RESERVE_FACTOR_KEY = hashString("RESERVE_FACTOR");
20
+ export const OPEN_INTEREST_RESERVE_FACTOR_KEY = hashString("OPEN_INTEREST_RESERVE_FACTOR");
21
+ export const MAX_OPEN_INTEREST_KEY = hashString("MAX_OPEN_INTEREST");
22
+ export const NONCE_KEY = hashString("NONCE");
23
+ export const BORROWING_FACTOR_KEY = hashString("BORROWING_FACTOR");
24
+ export const BORROWING_EXPONENT_FACTOR_KEY = hashString("BORROWING_EXPONENT_FACTOR");
25
+ export const CUMULATIVE_BORROWING_FACTOR_KEY = hashString("CUMULATIVE_BORROWING_FACTOR");
26
+ export const TOTAL_BORROWING_KEY = hashString("TOTAL_BORROWING");
27
+ export const FUNDING_FACTOR_KEY = hashString("FUNDING_FACTOR");
28
+ export const FUNDING_EXPONENT_FACTOR_KEY = hashString("FUNDING_EXPONENT_FACTOR");
29
+ export const FUNDING_INCREASE_FACTOR_PER_SECOND = hashString("FUNDING_INCREASE_FACTOR_PER_SECOND");
30
+ export const FUNDING_DECREASE_FACTOR_PER_SECOND = hashString("FUNDING_DECREASE_FACTOR_PER_SECOND");
31
+ export const MIN_FUNDING_FACTOR_PER_SECOND = hashString("MIN_FUNDING_FACTOR_PER_SECOND");
32
+ export const MAX_FUNDING_FACTOR_PER_SECOND = hashString("MAX_FUNDING_FACTOR_PER_SECOND");
33
+ export const THRESHOLD_FOR_STABLE_FUNDING = hashString("THRESHOLD_FOR_STABLE_FUNDING");
34
+ export const THRESHOLD_FOR_DECREASE_FUNDING = hashString("THRESHOLD_FOR_DECREASE_FUNDING");
35
+ export const MAX_PNL_FACTOR_KEY = hashString("MAX_PNL_FACTOR");
36
+ export const MAX_PNL_FACTOR_FOR_WITHDRAWALS_KEY = hashString("MAX_PNL_FACTOR_FOR_WITHDRAWALS");
37
+ export const MAX_PNL_FACTOR_FOR_DEPOSITS_KEY = hashString("MAX_PNL_FACTOR_FOR_DEPOSITS");
38
+ export const MAX_PNL_FACTOR_FOR_TRADERS_KEY = hashString("MAX_PNL_FACTOR_FOR_TRADERS");
39
+ export const MAX_POSITION_IMPACT_FACTOR_FOR_LIQUIDATIONS_KEY = hashString("MAX_POSITION_IMPACT_FACTOR_FOR_LIQUIDATIONS");
40
+ export const POSITION_IMPACT_POOL_AMOUNT_KEY = hashString("POSITION_IMPACT_POOL_AMOUNT");
41
+ export const MIN_POSITION_IMPACT_POOL_AMOUNT_KEY = hashString("MIN_POSITION_IMPACT_POOL_AMOUNT");
42
+ export const POSITION_IMPACT_POOL_DISTRIBUTION_RATE_KEY = hashString("POSITION_IMPACT_POOL_DISTRIBUTION_RATE");
43
+ export const SWAP_IMPACT_POOL_AMOUNT_KEY = hashString("SWAP_IMPACT_POOL_AMOUNT");
44
+ export const MIN_COLLATERAL_USD_KEY = hashString("MIN_COLLATERAL_USD");
45
+ export const MIN_COLLATERAL_FACTOR_KEY = hashString("MIN_COLLATERAL_FACTOR");
46
+ export const MIN_COLLATERAL_FACTOR_FOR_OPEN_INTEREST_MULTIPLIER_KEY = hashString("MIN_COLLATERAL_FACTOR_FOR_OPEN_INTEREST_MULTIPLIER");
47
+ export const MIN_POSITION_SIZE_USD_KEY = hashString("MIN_POSITION_SIZE_USD");
48
+ export const MAX_LEVERAGE_KEY = hashString("MAX_LEVERAGE");
49
+ export const DEPOSIT_GAS_LIMIT_KEY = hashString("DEPOSIT_GAS_LIMIT");
50
+ export const WITHDRAWAL_GAS_LIMIT_KEY = hashString("WITHDRAWAL_GAS_LIMIT");
51
+ export const INCREASE_ORDER_GAS_LIMIT_KEY = hashString("INCREASE_ORDER_GAS_LIMIT");
52
+ export const DECREASE_ORDER_GAS_LIMIT_KEY = hashString("DECREASE_ORDER_GAS_LIMIT");
53
+ export const SWAP_ORDER_GAS_LIMIT_KEY = hashString("SWAP_ORDER_GAS_LIMIT");
54
+ export const SHIFT_GAS_LIMIT_KEY = hashString("SHIFT_GAS_LIMIT");
55
+ export const SINGLE_SWAP_GAS_LIMIT_KEY = hashString("SINGLE_SWAP_GAS_LIMIT");
56
+ export const TOKEN_TRANSFER_GAS_LIMIT_KEY = hashString("TOKEN_TRANSFER_GAS_LIMIT");
57
+ export const NATIVE_TOKEN_TRANSFER_GAS_LIMIT_KEY = hashString("NATIVE_TOKEN_TRANSFER_GAS_LIMIT");
58
+ export const ESTIMATED_GAS_FEE_BASE_AMOUNT_V2_1 = hashString("ESTIMATED_GAS_FEE_BASE_AMOUNT_V2_1");
59
+ export const ESTIMATED_GAS_FEE_PER_ORACLE_PRICE = hashString("ESTIMATED_GAS_FEE_PER_ORACLE_PRICE");
60
+ export const ESTIMATED_GAS_FEE_MULTIPLIER_FACTOR = hashString("ESTIMATED_GAS_FEE_MULTIPLIER_FACTOR");
61
+ export const MARKET_LIST_KEY = hashString("MARKET_LIST");
62
+ export const POSITION_LIST_KEY = hashString("POSITION_LIST");
63
+ export const ORDER_LIST_KEY = hashString("ORDER_LIST");
64
+ export const ACCOUNT_ORDER_LIST_KEY = hashString("ACCOUNT_ORDER_LIST");
65
+ export const CLAIMABLE_FUNDING_AMOUNT = hashString("CLAIMABLE_FUNDING_AMOUNT");
66
+ export const VIRTUAL_TOKEN_ID_KEY = hashString("VIRTUAL_TOKEN_ID");
67
+ export const VIRTUAL_MARKET_ID_KEY = hashString("VIRTUAL_MARKET_ID");
68
+ export const VIRTUAL_INVENTORY_FOR_POSITIONS_KEY = hashString("VIRTUAL_INVENTORY_FOR_POSITIONS");
69
+ export const VIRTUAL_INVENTORY_FOR_SWAPS_KEY = hashString("VIRTUAL_INVENTORY_FOR_SWAPS");
70
+ export const POOL_AMOUNT_ADJUSTMENT_KEY = hashString("POOL_AMOUNT_ADJUSTMENT");
71
+ export const AFFILIATE_REWARD_KEY = hashString("AFFILIATE_REWARD");
72
+ export const IS_MARKET_DISABLED_KEY = hashString("IS_MARKET_DISABLED");
73
+ export const UI_FEE_FACTOR = hashString("UI_FEE_FACTOR");
74
+ export const SUBACCOUNT_LIST_KEY = hashString("SUBACCOUNT_LIST");
75
+ export const MAX_ALLOWED_SUBACCOUNT_ACTION_COUNT = hashString("MAX_ALLOWED_SUBACCOUNT_ACTION_COUNT");
76
+ export const SUBACCOUNT_ACTION_COUNT = hashString("SUBACCOUNT_ACTION_COUNT");
77
+ export const SUBACCOUNT_ORDER_ACTION = hashString("SUBACCOUNT_ORDER_ACTION");
78
+ export const SUBACCOUNT_AUTO_TOP_UP_AMOUNT = hashString("SUBACCOUNT_AUTO_TOP_UP_AMOUNT");
79
+ export const GLV_MAX_MARKET_TOKEN_BALANCE_USD = hashString("GLV_MAX_MARKET_TOKEN_BALANCE_USD");
80
+ export const GLV_MAX_MARKET_TOKEN_BALANCE_AMOUNT = hashString("GLV_MAX_MARKET_TOKEN_BALANCE_AMOUNT");
81
+ export const IS_GLV_MARKET_DISABLED = hashString("IS_GLV_MARKET_DISABLED");
82
+ export const GLV_SHIFT_LAST_EXECUTED_AT = hashString("GLV_SHIFT_LAST_EXECUTED_AT");
83
+ export const GLV_SHIFT_MIN_INTERVAL = hashString("GLV_SHIFT_MIN_INTERVAL");
84
+ export const GLV_DEPOSIT_GAS_LIMIT = hashString("GLV_DEPOSIT_GAS_LIMIT");
85
+ export const GLV_WITHDRAWAL_GAS_LIMIT = hashString("GLV_WITHDRAWAL_GAS_LIMIT");
86
+ export const GLV_PER_MARKET_GAS_LIMIT = hashString("GLV_PER_MARKET_GAS_LIMIT");
87
+ export const MAX_AUTO_CANCEL_ORDERS_KEY = hashString("MAX_AUTO_CANCEL_ORDERS");
88
+ export function glvShiftLastExecutedAtKey(glvAddress) {
89
+ return hashData(["bytes32", "address"], [GLV_SHIFT_LAST_EXECUTED_AT, glvAddress]);
90
+ }
91
+ export function glvShiftMinIntervalKey(glvAddress) {
92
+ return hashData(["bytes32", "address"], [GLV_SHIFT_MIN_INTERVAL, glvAddress]);
93
+ }
94
+ export function glvMaxMarketTokenBalanceUsdKey(glvAddress, market) {
95
+ return hashData(["bytes32", "address", "address"], [GLV_MAX_MARKET_TOKEN_BALANCE_USD, glvAddress, market]);
96
+ }
97
+ export function glvMaxMarketTokenBalanceAmountKey(glvAddress, market) {
98
+ return hashData(["bytes32", "address", "address"], [GLV_MAX_MARKET_TOKEN_BALANCE_AMOUNT, glvAddress, market]);
99
+ }
100
+ export function isGlvDisabledKey(glvAddress, market) {
101
+ return hashData(["bytes32", "address", "address"], [IS_GLV_MARKET_DISABLED, glvAddress, market]);
102
+ }
103
+ export function positionImpactFactorKey(market, isPositive) {
104
+ return hashData(["bytes32", "address", "bool"], [POSITION_IMPACT_FACTOR_KEY, market, isPositive]);
105
+ }
106
+ export function positionImpactExponentFactorKey(market) {
107
+ return hashData(["bytes32", "address"], [POSITION_IMPACT_EXPONENT_FACTOR_KEY, market]);
108
+ }
109
+ export function maxPositionImpactFactorKey(market, isPositive) {
110
+ return hashData(["bytes32", "address", "bool"], [MAX_POSITION_IMPACT_FACTOR_KEY, market, isPositive]);
111
+ }
112
+ export function positionFeeFactorKey(market, forPositiveImpact) {
113
+ return hashData(["bytes32", "address", "bool"], [POSITION_FEE_FACTOR_KEY, market, forPositiveImpact]);
114
+ }
115
+ export function swapImpactFactorKey(market, isPositive) {
116
+ return hashData(["bytes32", "address", "bool"], [SWAP_IMPACT_FACTOR_KEY, market, isPositive]);
117
+ }
118
+ export function swapImpactExponentFactorKey(market) {
119
+ return hashData(["bytes32", "address"], [SWAP_IMPACT_EXPONENT_FACTOR_KEY, market]);
120
+ }
121
+ export function swapFeeFactorKey(market, forPositiveImpact) {
122
+ return hashData(["bytes32", "address", "bool"], [SWAP_FEE_FACTOR_KEY, market, forPositiveImpact]);
123
+ }
124
+ export function openInterestKey(market, collateralToken, isLong) {
125
+ return hashData(["bytes32", "address", "address", "bool"], [OPEN_INTEREST_KEY, market, collateralToken, isLong]);
126
+ }
127
+ export function openInterestInTokensKey(market, collateralToken, isLong) {
128
+ return hashData(["bytes32", "address", "address", "bool"], [OPEN_INTEREST_IN_TOKENS_KEY, market, collateralToken, isLong]);
129
+ }
130
+ export function poolAmountKey(market, token) {
131
+ return hashData(["bytes32", "address", "address"], [POOL_AMOUNT_KEY, market, token]);
132
+ }
133
+ export function reserveFactorKey(market, isLong) {
134
+ return hashData(["bytes32", "address", "bool"], [RESERVE_FACTOR_KEY, market, isLong]);
135
+ }
136
+ export function openInterestReserveFactorKey(market, isLong) {
137
+ return hashData(["bytes32", "address", "bool"], [OPEN_INTEREST_RESERVE_FACTOR_KEY, market, isLong]);
138
+ }
139
+ export function maxOpenInterestKey(market, isLong) {
140
+ return hashData(["bytes32", "address", "bool"], [MAX_OPEN_INTEREST_KEY, market, isLong]);
141
+ }
142
+ export function borrowingFactorKey(market, isLong) {
143
+ return hashData(["bytes32", "address", "bool"], [BORROWING_FACTOR_KEY, market, isLong]);
144
+ }
145
+ export function borrowingExponentFactorKey(market, isLong) {
146
+ return hashData(["bytes32", "address", "bool"], [BORROWING_EXPONENT_FACTOR_KEY, market, isLong]);
147
+ }
148
+ export function cumulativeBorrowingFactorKey(market, isLong) {
149
+ return hashData(["bytes32", "address", "bool"], [CUMULATIVE_BORROWING_FACTOR_KEY, market, isLong]);
150
+ }
151
+ export function totalBorrowingKey(market, isLong) {
152
+ return hashData(["bytes32", "address", "bool"], [TOTAL_BORROWING_KEY, market, isLong]);
153
+ }
154
+ export function fundingFactorKey(market) {
155
+ return hashData(["bytes32", "address"], [FUNDING_FACTOR_KEY, market]);
156
+ }
157
+ export function fundingExponentFactorKey(market) {
158
+ return hashData(["bytes32", "address"], [FUNDING_EXPONENT_FACTOR_KEY, market]);
159
+ }
160
+ export function fundingIncreaseFactorPerSecondKey(market) {
161
+ return hashData(["bytes32", "address"], [FUNDING_INCREASE_FACTOR_PER_SECOND, market]);
162
+ }
163
+ export function fundingDecreaseFactorPerSecondKey(market) {
164
+ return hashData(["bytes32", "address"], [FUNDING_DECREASE_FACTOR_PER_SECOND, market]);
165
+ }
166
+ export function minFundingFactorPerSecondKey(market) {
167
+ return hashData(["bytes32", "address"], [MIN_FUNDING_FACTOR_PER_SECOND, market]);
168
+ }
169
+ export function maxFundingFactorPerSecondKey(market) {
170
+ return hashData(["bytes32", "address"], [MAX_FUNDING_FACTOR_PER_SECOND, market]);
171
+ }
172
+ export function thresholdForStableFundingKey(market) {
173
+ return hashData(["bytes32", "address"], [THRESHOLD_FOR_STABLE_FUNDING, market]);
174
+ }
175
+ export function thresholdForDecreaseFundingKey(market) {
176
+ return hashData(["bytes32", "address"], [THRESHOLD_FOR_DECREASE_FUNDING, market]);
177
+ }
178
+ export function maxPnlFactorKey(pnlFactorType, market, isLong) {
179
+ return hashData(["bytes32", "bytes32", "address", "bool"], [MAX_PNL_FACTOR_KEY, pnlFactorType, market, isLong]);
180
+ }
181
+ export function positionImpactPoolAmountKey(market) {
182
+ return hashData(["bytes32", "address"], [POSITION_IMPACT_POOL_AMOUNT_KEY, market]);
183
+ }
184
+ export function minPositionImpactPoolAmountKey(market) {
185
+ return hashData(["bytes32", "address"], [MIN_POSITION_IMPACT_POOL_AMOUNT_KEY, market]);
186
+ }
187
+ export function positionImpactPoolDistributionRateKey(market) {
188
+ return hashData(["bytes32", "address"], [POSITION_IMPACT_POOL_DISTRIBUTION_RATE_KEY, market]);
189
+ }
190
+ export function maxPositionImpactFactorForLiquidationsKey(market) {
191
+ return hashData(["bytes32", "address"], [MAX_POSITION_IMPACT_FACTOR_FOR_LIQUIDATIONS_KEY, market]);
192
+ }
193
+ export function swapImpactPoolAmountKey(market, token) {
194
+ return hashData(["bytes32", "address", "address"], [SWAP_IMPACT_POOL_AMOUNT_KEY, market, token]);
195
+ }
196
+ export function orderKey(dataStoreAddress, nonce) {
197
+ return hashData(["address", "uint256"], [dataStoreAddress, nonce]);
198
+ }
199
+ export function depositGasLimitKey(singleToken) {
200
+ return hashData(["bytes32", "bool"], [DEPOSIT_GAS_LIMIT_KEY, singleToken]);
201
+ }
202
+ export function withdrawalGasLimitKey() {
203
+ return hashData(["bytes32"], [WITHDRAWAL_GAS_LIMIT_KEY]);
204
+ }
205
+ export function shiftGasLimitKey() {
206
+ return SHIFT_GAS_LIMIT_KEY;
207
+ }
208
+ export function singleSwapGasLimitKey() {
209
+ return SINGLE_SWAP_GAS_LIMIT_KEY;
210
+ }
211
+ export function increaseOrderGasLimitKey() {
212
+ return INCREASE_ORDER_GAS_LIMIT_KEY;
213
+ }
214
+ export function decreaseOrderGasLimitKey() {
215
+ return DECREASE_ORDER_GAS_LIMIT_KEY;
216
+ }
217
+ export function swapOrderGasLimitKey() {
218
+ return SWAP_ORDER_GAS_LIMIT_KEY;
219
+ }
220
+ export function accountOrderListKey(account) {
221
+ return hashData(["bytes32", "address"], [ACCOUNT_ORDER_LIST_KEY, account]);
222
+ }
223
+ export function minCollateralFactorKey(market) {
224
+ return hashData(["bytes32", "address"], [MIN_COLLATERAL_FACTOR_KEY, market]);
225
+ }
226
+ export function minCollateralFactorForOpenInterest(market, isLong) {
227
+ return hashData(["bytes32", "address", "bool"], [MIN_COLLATERAL_FACTOR_FOR_OPEN_INTEREST_MULTIPLIER_KEY, market, isLong]);
228
+ }
229
+ export function hashedPositionKey(account, market, collateralToken, isLong) {
230
+ return hashData(["address", "address", "address", "bool"], [account, market, collateralToken, isLong]);
231
+ }
232
+ export function claimableFundingAmountKey(market, token, account) {
233
+ return hashData(["bytes32", "address", "address", "address"], [CLAIMABLE_FUNDING_AMOUNT, market, token, account]);
234
+ }
235
+ export function virtualTokenIdKey(token) {
236
+ return hashData(["bytes32", "address"], [VIRTUAL_TOKEN_ID_KEY, token]);
237
+ }
238
+ export function virtualMarketIdKey(market) {
239
+ return hashData(["bytes32", "address"], [VIRTUAL_MARKET_ID_KEY, market]);
240
+ }
241
+ export function virtualInventoryForSwapsKey(virtualMarketId, token) {
242
+ return hashData(["bytes32", "bytes32", "address"], [VIRTUAL_INVENTORY_FOR_SWAPS_KEY, virtualMarketId, token]);
243
+ }
244
+ export function virtualInventoryForPositionsKey(virtualTokenId) {
245
+ return hashData(["bytes32", "bytes32"], [VIRTUAL_INVENTORY_FOR_POSITIONS_KEY, virtualTokenId]);
246
+ }
247
+ export function poolAmountAdjustmentKey(market, token) {
248
+ return hashData(["bytes32", "address", "address"], [POOL_AMOUNT_ADJUSTMENT_KEY, market, token]);
249
+ }
250
+ export function affiliateRewardKey(market, token, account) {
251
+ return hashData(["bytes32", "address", "address", "address"], [AFFILIATE_REWARD_KEY, market, token, account]);
252
+ }
253
+ export function isMarketDisabledKey(market) {
254
+ return hashData(["bytes32", "address"], [IS_MARKET_DISABLED_KEY, market]);
255
+ }
256
+ export function maxPoolUsdForDepositKey(market, token) {
257
+ return hashData(["bytes32", "address", "address"], [MAX_POOL_USD_FOR_DEPOSIT_KEY, market, token]);
258
+ }
259
+ export function maxPoolAmountKey(market, token) {
260
+ return hashData(["bytes32", "address", "address"], [MAX_POOL_AMOUNT_KEY, market, token]);
261
+ }
262
+ export function uiFeeFactorKey(address) {
263
+ return hashData(["bytes32", "address"], [UI_FEE_FACTOR, address]);
264
+ }
265
+ export function subaccountListKey(account) {
266
+ return hashData(["bytes32", "address"], [SUBACCOUNT_LIST_KEY, account]);
267
+ }
268
+ export function maxAllowedSubaccountActionCountKey(account, subaccount, actionType) {
269
+ return hashData(["bytes32", "address", "address", "bytes32"], [MAX_ALLOWED_SUBACCOUNT_ACTION_COUNT, account, subaccount, actionType]);
270
+ }
271
+ export function subaccountActionCountKey(account, subaccount, actionType) {
272
+ return hashData(["bytes32", "address", "address", "bytes32"], [SUBACCOUNT_ACTION_COUNT, account, subaccount, actionType]);
273
+ }
274
+ export function subaccountAutoTopUpAmountKey(account, subaccount) {
275
+ return hashData(["bytes32", "address", "address"], [SUBACCOUNT_AUTO_TOP_UP_AMOUNT, account, subaccount]);
276
+ }
@@ -0,0 +1,20 @@
1
+ export declare const USD_DECIMALS = 30;
2
+ export declare const BASIS_POINTS_DIVISOR = 10000;
3
+ export declare const BASIS_POINTS_DIVISOR_BIGINT = 10000n;
4
+ /**
5
+ * @deprecated for v2: calculate leverage based on marketInfo.minCollateralFactor
6
+ */
7
+ export declare const MAX_LEVERAGE: number;
8
+ /**
9
+ * @deprecated for v2: calculate leverage based on marketInfo.minCollateralFactor
10
+ */
11
+ export declare const MAX_ALLOWED_LEVERAGE: number;
12
+ export declare const COLLATERAL_SPREAD_SHOW_AFTER_INITIAL_ZERO_THRESHOLD = 5;
13
+ export declare const DEFAULT_SLIPPAGE_AMOUNT = 30;
14
+ export declare const DEFAULT_HIGHER_SLIPPAGE_AMOUNT = 100;
15
+ export declare const EXCESSIVE_SLIPPAGE_AMOUNT: number;
16
+ export declare const HIGH_PRICE_IMPACT_BPS = 80;
17
+ export declare const HIGH_POSITION_IMPACT_BPS = 50;
18
+ export declare const HIGH_COLLATERAL_IMPACT_BPS = 500;
19
+ export declare const HIGH_SWAP_IMPACT_BPS = 50;
20
+ export declare const DEFAULT_ACCEPABLE_PRICE_IMPACT_BUFFER = 30;
@@ -0,0 +1,21 @@
1
+ export const USD_DECIMALS = 30;
2
+ export const BASIS_POINTS_DIVISOR = 10000;
3
+ export const BASIS_POINTS_DIVISOR_BIGINT = 10000n;
4
+ /**
5
+ * @deprecated for v2: calculate leverage based on marketInfo.minCollateralFactor
6
+ */
7
+ export const MAX_LEVERAGE = 100 * BASIS_POINTS_DIVISOR;
8
+ /**
9
+ * @deprecated for v2: calculate leverage based on marketInfo.minCollateralFactor
10
+ */
11
+ export const MAX_ALLOWED_LEVERAGE = 50 * BASIS_POINTS_DIVISOR;
12
+ export const COLLATERAL_SPREAD_SHOW_AFTER_INITIAL_ZERO_THRESHOLD = 5; // 0.05%
13
+ export const DEFAULT_SLIPPAGE_AMOUNT = 30; // 0.3%
14
+ export const DEFAULT_HIGHER_SLIPPAGE_AMOUNT = 100; // 1%
15
+ export const EXCESSIVE_SLIPPAGE_AMOUNT = 2 * 100; // 2%
16
+ // V2
17
+ export const HIGH_PRICE_IMPACT_BPS = 80; // 0.8%
18
+ export const HIGH_POSITION_IMPACT_BPS = 50; // 0.5%
19
+ export const HIGH_COLLATERAL_IMPACT_BPS = 500; // 5%
20
+ export const HIGH_SWAP_IMPACT_BPS = 50; // 0.5%
21
+ export const DEFAULT_ACCEPABLE_PRICE_IMPACT_BUFFER = 30; // 0.3%
@@ -0,0 +1,8 @@
1
+ type MarketConfig = {
2
+ marketTokenAddress: string;
3
+ indexTokenAddress: string;
4
+ longTokenAddress: string;
5
+ shortTokenAddress: string;
6
+ };
7
+ export declare const MARKETS: Record<string, Record<string, MarketConfig>>;
8
+ export {};