@gmx-io/sdk 1.4.2 → 1.5.0-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 (412) hide show
  1. package/build/cjs/scripts/prebuild/index.js +6 -1
  2. package/build/cjs/scripts/prebuild/prebuildKinkModelMarketRatesKeys.js +2 -28
  3. package/build/cjs/scripts/prebuild/prebuildMarketConfigKeys.js +2 -2
  4. package/build/cjs/scripts/prebuild/prebuildMarketValuesKeys.js +2 -2
  5. package/build/cjs/scripts/subsquid-codegen.js +26 -0
  6. package/build/cjs/src/{utils → clients/v1}/callContract.js +4 -6
  7. package/build/cjs/src/{index.js → clients/v1/index.js} +4 -4
  8. package/build/cjs/src/{modules → clients/v1/modules}/accounts/accounts.js +1 -1
  9. package/build/cjs/src/{modules → clients/v1/modules}/accounts/accounts.spec.js +1 -1
  10. package/build/cjs/src/clients/v1/modules/markets/index.js +227 -0
  11. package/build/cjs/src/{modules → clients/v1/modules}/markets/markets.spec.js +1 -1
  12. package/build/cjs/src/{modules → clients/v1/modules}/oracle.js +1 -1
  13. package/build/cjs/src/{modules → clients/v1/modules}/orders/helpers.js +9 -9
  14. package/build/cjs/src/{modules → clients/v1/modules}/orders/helpers.spec.js +5 -5
  15. package/build/cjs/src/{modules → clients/v1/modules}/orders/orders.js +11 -11
  16. package/build/cjs/src/{modules → clients/v1/modules}/orders/orders.spec.js +1 -1
  17. package/build/cjs/src/{modules → clients/v1/modules}/orders/transactions/cancelOrdersTxn.js +2 -2
  18. package/build/cjs/src/{modules → clients/v1/modules}/orders/transactions/createDecreaseOrderTxn.js +7 -7
  19. package/build/cjs/src/{modules → clients/v1/modules}/orders/transactions/createIncreaseOrderTxn.js +11 -11
  20. package/build/cjs/src/{modules → clients/v1/modules}/orders/transactions/createSwapOrderTxn.js +10 -10
  21. package/build/cjs/src/{modules → clients/v1/modules}/orders/transactions/createWrapOrUnwrapTxn.js +2 -2
  22. package/build/cjs/src/{modules → clients/v1/modules}/orders/transactions/updateOrderTxn.js +3 -3
  23. package/build/cjs/src/{modules → clients/v1/modules}/orders/utils.js +7 -7
  24. package/build/cjs/src/{modules → clients/v1/modules}/positions/positions.js +11 -11
  25. package/build/cjs/src/{modules → clients/v1/modules}/positions/positions.spec.js +1 -1
  26. package/build/cjs/src/{modules → clients/v1/modules}/tokens/tokens.js +3 -3
  27. package/build/cjs/src/{modules → clients/v1/modules}/tokens/tokens.spec.js +1 -1
  28. package/build/cjs/src/{modules → clients/v1/modules}/trades/trades.js +19 -19
  29. package/build/cjs/src/{modules → clients/v1/modules}/trades/trades.spec.js +1 -1
  30. package/build/cjs/src/{modules → clients/v1/modules}/utils/utils.js +8 -8
  31. package/build/cjs/src/{utils → clients/v1}/multicall.js +2 -2
  32. package/build/cjs/src/{utils → clients/v1}/simulateExecuteOrder.js +5 -5
  33. package/build/cjs/src/{utils → clients/v1}/testUtil.js +2 -2
  34. package/build/cjs/src/clients/v2/index.js +21 -0
  35. package/build/cjs/src/codegen/prebuilt/index.js +16 -0
  36. package/build/cjs/src/configs/api.js +15 -0
  37. package/build/cjs/src/configs/chains.js +29 -1
  38. package/build/cjs/src/configs/dataStore.js +6 -2
  39. package/build/cjs/src/configs/multichain.js +29 -19
  40. package/build/cjs/src/configs/tokens.js +1 -0
  41. package/build/cjs/src/test/mock.js +5 -122
  42. package/build/cjs/src/utils/24h/index.js +17 -0
  43. package/build/cjs/src/utils/LruCache/index.js +17 -0
  44. package/build/cjs/src/utils/__tests__/fees.spec.js +1 -1
  45. package/build/cjs/src/utils/__tests__/orderTransactions/batchUtils.spec.js +2 -2
  46. package/build/cjs/src/utils/__tests__/orderTransactions/decreaseOrders.spec.js +33 -33
  47. package/build/cjs/src/utils/__tests__/orderTransactions/exchangeRouterMulticall.spec.js +4 -4
  48. package/build/cjs/src/utils/__tests__/orderTransactions/increaseOrders.spec.js +28 -28
  49. package/build/cjs/src/utils/__tests__/orderTransactions/swapOrders.spec.js +20 -20
  50. package/build/cjs/src/utils/__tests__/orderTransactions/updateOrder.spec.js +3 -3
  51. package/build/cjs/src/utils/__tests__/prices.spec.js +18 -18
  52. package/build/cjs/src/utils/abort/index.js +17 -0
  53. package/build/cjs/src/utils/bigmath/index.js +17 -0
  54. package/build/cjs/src/utils/buildUrl/index.js +17 -0
  55. package/build/cjs/src/utils/chains/index.js +17 -0
  56. package/build/cjs/src/utils/common/index.js +17 -0
  57. package/build/cjs/src/utils/{common.js → common/utils.js} +1 -2
  58. package/build/cjs/src/utils/fees/executionFee.js +2 -2
  59. package/build/cjs/src/utils/fees/index.js +9 -9
  60. package/build/cjs/src/utils/gelatoRelay/index.js +17 -0
  61. package/build/cjs/src/utils/graphqlFetcher/index.js +8 -0
  62. package/build/cjs/src/utils/hash/index.js +17 -0
  63. package/build/cjs/src/utils/{hash.js → hash/utils.js} +1 -1
  64. package/build/cjs/src/utils/http/http.js +33 -0
  65. package/build/cjs/src/utils/indexers/index.js +17 -0
  66. package/build/cjs/src/utils/{indexers.js → indexers/utils.js} +1 -1
  67. package/build/cjs/src/utils/markets/__tests__/mockMarkets.js +129 -0
  68. package/build/cjs/src/utils/markets/api.js +14 -0
  69. package/build/cjs/src/utils/{marketKeysAndConfigs.js → markets/hashKeys.js} +32 -3
  70. package/build/cjs/src/utils/markets/index.js +21 -0
  71. package/build/cjs/src/{modules/markets/query-builders.js → utils/markets/multicall.js} +149 -42
  72. package/build/cjs/src/utils/markets/utils.js +398 -0
  73. package/build/cjs/src/utils/numbers/index.js +17 -0
  74. package/build/cjs/src/utils/{numbers.js → numbers/utils.js} +8 -3
  75. package/build/cjs/src/utils/objects/index.js +17 -0
  76. package/build/cjs/src/utils/{objects.js → objects/utils.js} +9 -1
  77. package/build/cjs/src/utils/orderTransactions/index.js +17 -0
  78. package/build/cjs/src/utils/{orderTransactions.js → orderTransactions/utils.js} +22 -22
  79. package/build/cjs/src/utils/orders/index.js +18 -0
  80. package/build/cjs/src/utils/{orders.js → orders/utils.js} +22 -22
  81. package/build/cjs/src/utils/positions/index.js +18 -0
  82. package/build/cjs/src/utils/{positions.js → positions/utils.js} +6 -6
  83. package/build/cjs/src/utils/prices/index.js +17 -0
  84. package/build/cjs/src/utils/{prices.js → prices/utils.js} +15 -15
  85. package/build/cjs/src/utils/referrals/index.js +18 -0
  86. package/build/cjs/src/utils/sidecarOrders/index.js +17 -0
  87. package/build/cjs/src/utils/swap/__tests__/mockRouting.spec.js +14 -14
  88. package/build/cjs/src/utils/swap/__tests__/swapRouting.spec.js +5 -5
  89. package/build/cjs/src/utils/swap/__tests__/swapStats.spec.js +10 -10
  90. package/build/cjs/src/utils/swap/botanixStaking.js +3 -3
  91. package/build/cjs/src/utils/swap/buildSwapStrategy.js +2 -2
  92. package/build/cjs/src/utils/swap/externalSwapPath.js +2 -2
  93. package/build/cjs/src/utils/swap/externalSwapQuoteByPath.js +2 -2
  94. package/build/cjs/src/utils/swap/index.js +12 -0
  95. package/build/cjs/src/utils/swap/swapPath.js +3 -3
  96. package/build/cjs/src/utils/swap/swapValues.js +4 -4
  97. package/build/cjs/src/utils/time/index.js +17 -0
  98. package/build/cjs/src/utils/tokens/index.js +18 -0
  99. package/build/cjs/src/utils/{tokens.js → tokens/utils.js} +4 -4
  100. package/build/cjs/src/utils/trade/decrease.js +8 -8
  101. package/build/cjs/src/utils/trade/increase.js +2 -2
  102. package/build/cjs/src/utils/trade/index.js +3 -0
  103. package/build/cjs/src/utils/trade/trade.js +10 -10
  104. package/build/cjs/src/utils/tradeHistory/index.js +18 -0
  105. package/build/cjs/src/utils/{tradeHistory.js → tradeHistory/utils.js} +4 -4
  106. package/build/cjs/src/utils/twap/index.js +15 -0
  107. package/build/cjs/src/utils/types/index.js +7 -0
  108. package/build/esm/scripts/prebuild/index.js +3 -1
  109. package/build/esm/scripts/prebuild/prebuildKinkModelMarketRatesKeys.js +2 -28
  110. package/build/esm/scripts/prebuild/prebuildMarketConfigKeys.js +1 -1
  111. package/build/esm/scripts/prebuild/prebuildMarketValuesKeys.js +1 -1
  112. package/build/esm/scripts/subsquid-codegen.js +24 -0
  113. package/build/esm/src/{utils → clients/v1}/callContract.js +5 -5
  114. package/build/esm/src/{index.js → clients/v1/index.js} +4 -4
  115. package/build/esm/src/{modules → clients/v1/modules}/accounts/accounts.js +1 -1
  116. package/build/esm/src/{modules → clients/v1/modules}/accounts/accounts.spec.js +1 -1
  117. package/build/esm/src/clients/v1/modules/markets/index.js +220 -0
  118. package/build/esm/src/{modules → clients/v1/modules}/markets/markets.spec.js +1 -1
  119. package/build/esm/src/{modules → clients/v1/modules}/oracle.js +1 -1
  120. package/build/esm/src/{modules → clients/v1/modules}/orders/helpers.js +6 -6
  121. package/build/esm/src/{modules → clients/v1/modules}/orders/helpers.spec.js +5 -5
  122. package/build/esm/src/{modules → clients/v1/modules}/orders/orders.js +4 -4
  123. package/build/esm/src/{modules → clients/v1/modules}/orders/orders.spec.js +1 -1
  124. package/build/esm/src/{modules → clients/v1/modules}/orders/transactions/cancelOrdersTxn.js +2 -2
  125. package/build/esm/src/{modules → clients/v1/modules}/orders/transactions/createDecreaseOrderTxn.js +7 -7
  126. package/build/esm/src/{modules → clients/v1/modules}/orders/transactions/createIncreaseOrderTxn.js +8 -8
  127. package/build/esm/src/{modules → clients/v1/modules}/orders/transactions/createSwapOrderTxn.js +7 -7
  128. package/build/esm/src/{modules → clients/v1/modules}/orders/transactions/createWrapOrUnwrapTxn.js +2 -2
  129. package/build/esm/src/{modules → clients/v1/modules}/orders/transactions/updateOrderTxn.js +3 -3
  130. package/build/esm/src/{modules → clients/v1/modules}/orders/utils.js +7 -7
  131. package/build/esm/src/{modules → clients/v1/modules}/positions/positions.js +11 -11
  132. package/build/esm/src/{modules → clients/v1/modules}/positions/positions.spec.js +1 -1
  133. package/build/esm/src/{modules → clients/v1/modules}/tokens/tokens.js +3 -3
  134. package/build/esm/src/{modules → clients/v1/modules}/tokens/tokens.spec.js +1 -1
  135. package/build/esm/src/{modules → clients/v1/modules}/trades/trades.js +8 -8
  136. package/build/esm/src/{modules → clients/v1/modules}/trades/trades.spec.js +1 -1
  137. package/build/esm/src/{modules → clients/v1/modules}/utils/utils.js +8 -8
  138. package/build/esm/src/{utils → clients/v1}/multicall.js +2 -2
  139. package/build/esm/src/{utils → clients/v1}/simulateExecuteOrder.js +5 -5
  140. package/build/esm/src/{utils → clients/v1}/testUtil.js +2 -2
  141. package/build/esm/src/clients/v2/index.js +17 -0
  142. package/build/esm/src/codegen/prebuilt/index.js +10 -0
  143. package/build/esm/src/configs/api.js +11 -0
  144. package/build/esm/src/configs/chains.js +29 -1
  145. package/build/esm/src/configs/dataStore.js +3 -0
  146. package/build/esm/src/configs/multichain.js +28 -19
  147. package/build/esm/src/configs/tokens.js +1 -0
  148. package/build/esm/src/test/mock.js +3 -120
  149. package/build/esm/src/utils/24h/index.js +1 -0
  150. package/build/esm/src/utils/LruCache/index.js +1 -0
  151. package/build/esm/src/utils/__tests__/fees.spec.js +1 -1
  152. package/build/esm/src/utils/__tests__/orderTransactions/batchUtils.spec.js +1 -1
  153. package/build/esm/src/utils/__tests__/orderTransactions/decreaseOrders.spec.js +1 -1
  154. package/build/esm/src/utils/__tests__/orderTransactions/exchangeRouterMulticall.spec.js +1 -1
  155. package/build/esm/src/utils/__tests__/orderTransactions/increaseOrders.spec.js +1 -1
  156. package/build/esm/src/utils/__tests__/orderTransactions/swapOrders.spec.js +1 -1
  157. package/build/esm/src/utils/__tests__/orderTransactions/updateOrder.spec.js +1 -1
  158. package/build/esm/src/utils/__tests__/prices.spec.js +2 -2
  159. package/build/esm/src/utils/abort/index.js +1 -0
  160. package/build/esm/src/utils/bigmath/index.js +1 -0
  161. package/build/esm/src/utils/buildUrl/index.js +1 -0
  162. package/build/esm/src/utils/chains/index.js +1 -0
  163. package/build/esm/src/utils/common/index.js +1 -0
  164. package/build/esm/src/utils/{common.js → common/utils.js} +0 -1
  165. package/build/esm/src/utils/fees/executionFee.js +1 -1
  166. package/build/esm/src/utils/fees/index.js +7 -7
  167. package/build/esm/src/utils/gelatoRelay/index.js +1 -0
  168. package/build/esm/src/utils/graphqlFetcher/index.js +1 -0
  169. package/build/esm/src/utils/hash/index.js +1 -0
  170. package/build/esm/src/utils/{hash.js → hash/utils.js} +1 -1
  171. package/build/esm/src/utils/http/http.js +26 -0
  172. package/build/esm/src/utils/indexers/index.js +1 -0
  173. package/build/esm/src/utils/{indexers.js → indexers/utils.js} +1 -1
  174. package/build/esm/src/utils/markets/__tests__/mockMarkets.js +124 -0
  175. package/build/esm/src/utils/markets/api.js +9 -0
  176. package/build/esm/src/utils/{marketKeysAndConfigs.js → markets/hashKeys.js} +30 -2
  177. package/build/esm/src/utils/markets/index.js +5 -0
  178. package/build/esm/src/{modules/markets/query-builders.js → utils/markets/multicall.js} +146 -41
  179. package/build/esm/src/utils/markets/utils.js +364 -0
  180. package/build/esm/src/utils/numbers/index.js +1 -0
  181. package/build/esm/src/utils/{numbers.js → numbers/utils.js} +8 -3
  182. package/build/esm/src/utils/objects/index.js +1 -0
  183. package/build/esm/src/utils/{objects.js → objects/utils.js} +7 -0
  184. package/build/esm/src/utils/orderTransactions/index.js +1 -0
  185. package/build/esm/src/utils/{orderTransactions.js → orderTransactions/utils.js} +14 -14
  186. package/build/esm/src/utils/orders/index.js +2 -0
  187. package/build/esm/src/utils/{orders.js → orders/utils.js} +8 -8
  188. package/build/esm/src/utils/positions/index.js +2 -0
  189. package/build/esm/src/utils/{positions.js → positions/utils.js} +6 -6
  190. package/build/esm/src/utils/prices/index.js +1 -0
  191. package/build/esm/src/utils/{prices.js → prices/utils.js} +7 -7
  192. package/build/esm/src/utils/referrals/index.js +2 -0
  193. package/build/esm/src/utils/sidecarOrders/index.js +1 -0
  194. package/build/esm/src/utils/swap/__tests__/mockRouting.spec.js +1 -1
  195. package/build/esm/src/utils/swap/__tests__/swapRouting.spec.js +1 -1
  196. package/build/esm/src/utils/swap/__tests__/swapStats.spec.js +1 -1
  197. package/build/esm/src/utils/swap/botanixStaking.js +1 -1
  198. package/build/esm/src/utils/swap/buildSwapStrategy.js +1 -1
  199. package/build/esm/src/utils/swap/externalSwapPath.js +1 -1
  200. package/build/esm/src/utils/swap/externalSwapQuoteByPath.js +1 -1
  201. package/build/esm/src/utils/swap/index.js +12 -0
  202. package/build/esm/src/utils/swap/swapPath.js +1 -1
  203. package/build/esm/src/utils/swap/swapValues.js +1 -1
  204. package/build/esm/src/utils/time/index.js +1 -0
  205. package/build/esm/src/utils/tokens/index.js +2 -0
  206. package/build/esm/src/utils/{tokens.js → tokens/utils.js} +4 -4
  207. package/build/esm/src/utils/trade/decrease.js +1 -1
  208. package/build/esm/src/utils/trade/increase.js +1 -1
  209. package/build/esm/src/utils/trade/index.js +3 -0
  210. package/build/esm/src/utils/trade/trade.js +2 -2
  211. package/build/esm/src/utils/tradeHistory/index.js +2 -0
  212. package/build/esm/src/utils/{tradeHistory.js → tradeHistory/utils.js} +4 -4
  213. package/build/esm/src/utils/twap/index.js +1 -0
  214. package/build/esm/src/utils/types/index.js +3 -0
  215. package/build/types/scripts/subsquid-codegen.d.ts +3 -0
  216. package/build/types/src/clients/v1/callContract.d.ts +7 -0
  217. package/build/types/src/{index.d.ts → clients/v1/index.d.ts} +3 -3
  218. package/build/types/src/{modules → clients/v1/modules}/markets/index.d.ts +12 -1
  219. package/build/types/src/{modules → clients/v1/modules}/oracle.d.ts +1 -1
  220. package/build/types/src/{modules → clients/v1/modules}/orders/helpers.d.ts +3 -3
  221. package/build/types/src/{modules → clients/v1/modules}/orders/orders.d.ts +5 -5
  222. package/build/types/src/{modules → clients/v1/modules}/orders/transactions/createDecreaseOrderTxn.d.ts +2 -2
  223. package/build/types/src/{modules → clients/v1/modules}/orders/transactions/createIncreaseOrderTxn.d.ts +4 -4
  224. package/build/types/src/{modules → clients/v1/modules}/orders/transactions/createSwapOrderTxn.d.ts +2 -2
  225. package/build/types/src/{modules → clients/v1/modules}/orders/transactions/updateOrderTxn.d.ts +1 -1
  226. package/build/types/src/{modules → clients/v1/modules}/orders/utils.d.ts +8 -8
  227. package/build/types/src/{modules → clients/v1/modules}/positions/positions.d.ts +4 -4
  228. package/build/types/src/{modules → clients/v1/modules}/tokens/tokens.d.ts +1 -1
  229. package/build/types/src/{modules → clients/v1/modules}/trades/trades.d.ts +4 -4
  230. package/build/types/src/{modules → clients/v1/modules}/utils/utils.d.ts +4 -4
  231. package/build/types/src/{utils → clients/v1}/multicall.d.ts +2 -2
  232. package/build/types/src/{utils → clients/v1}/simulateExecuteOrder.d.ts +3 -3
  233. package/build/types/src/{utils → clients/v1}/testUtil.d.ts +2 -2
  234. package/build/types/src/{types/sdk.d.ts → clients/v1/types.d.ts} +3 -3
  235. package/build/types/src/clients/v2/index.d.ts +13 -0
  236. package/build/types/src/codegen/prebuilt/index.d.ts +13636 -0
  237. package/build/types/src/{types → codegen}/subsquid.d.ts +13 -0
  238. package/build/types/src/configs/api.d.ts +1 -0
  239. package/build/types/src/configs/chains.d.ts +26 -2
  240. package/build/types/src/configs/dataStore.d.ts +1 -0
  241. package/build/types/src/configs/express.d.ts +1 -1
  242. package/build/types/src/configs/gasLimits.d.ts +1 -1
  243. package/build/types/src/configs/markets.d.ts +1 -1
  244. package/build/types/src/configs/multichain.d.ts +6 -3
  245. package/build/types/src/configs/tokens.d.ts +1 -1
  246. package/build/types/src/test/mock.d.ts +3 -7
  247. package/build/types/src/utils/24h/index.d.ts +1 -0
  248. package/build/types/src/utils/24h/types.d.ts +7 -0
  249. package/build/types/src/utils/LruCache/index.d.ts +1 -0
  250. package/build/types/src/utils/abort/index.d.ts +1 -0
  251. package/build/types/src/utils/bigmath/index.d.ts +1 -0
  252. package/build/types/src/utils/buildUrl/index.d.ts +1 -0
  253. package/build/types/src/utils/chains/index.d.ts +1 -0
  254. package/build/types/src/utils/common/index.d.ts +1 -0
  255. package/build/types/src/utils/{common.d.ts → common/utils.d.ts} +0 -1
  256. package/build/types/src/utils/fees/executionFee.d.ts +3 -3
  257. package/build/types/src/utils/fees/getNaiveEstimatedGasBySwapCount.d.ts +1 -1
  258. package/build/types/src/utils/fees/index.d.ts +10 -13
  259. package/build/types/src/utils/fees/priceImpact.d.ts +3 -3
  260. package/build/types/src/{types/fees.d.ts → utils/fees/types.d.ts} +2 -2
  261. package/build/types/src/utils/gelatoRelay/index.d.ts +1 -0
  262. package/build/types/src/utils/graphqlFetcher/index.d.ts +1 -0
  263. package/build/types/src/utils/hash/index.d.ts +1 -0
  264. package/build/types/src/utils/http/http.d.ts +9 -0
  265. package/build/types/src/utils/http/types.d.ts +7 -0
  266. package/build/types/src/utils/indexers/index.d.ts +1 -0
  267. package/build/types/src/utils/markets/__tests__/mockMarkets.d.ts +9 -0
  268. package/build/types/src/utils/markets/api.d.ts +9 -0
  269. package/build/types/src/utils/markets/hashKeys.d.ts +23 -0
  270. package/build/types/src/utils/markets/index.d.ts +5 -0
  271. package/build/types/src/utils/markets/multicall.d.ts +25 -0
  272. package/build/types/src/{types/markets.d.ts → utils/markets/types.d.ts} +64 -1
  273. package/build/types/src/utils/markets/utils.d.ts +122 -0
  274. package/build/types/src/utils/numbers/index.d.ts +1 -0
  275. package/build/types/src/utils/{numbers.d.ts → numbers/utils.d.ts} +3 -1
  276. package/build/types/src/utils/objects/index.d.ts +1 -0
  277. package/build/types/src/utils/{objects.d.ts → objects/utils.d.ts} +1 -0
  278. package/build/types/src/utils/orderTransactions/index.d.ts +1 -0
  279. package/build/types/src/utils/{orderTransactions.d.ts → orderTransactions/utils.d.ts} +6 -6
  280. package/build/types/src/utils/orders/index.d.ts +2 -0
  281. package/build/types/src/{types/orders.d.ts → utils/orders/types.d.ts} +3 -3
  282. package/build/types/src/utils/{orders.d.ts → orders/utils.d.ts} +3 -3
  283. package/build/types/src/utils/positions/index.d.ts +2 -0
  284. package/build/types/src/{types/positions.d.ts → utils/positions/types.d.ts} +2 -2
  285. package/build/types/src/utils/{positions.d.ts → positions/utils.d.ts} +4 -4
  286. package/build/types/src/utils/prices/index.d.ts +1 -0
  287. package/build/types/src/utils/{prices.d.ts → prices/utils.d.ts} +4 -4
  288. package/build/types/src/utils/referrals/index.d.ts +2 -0
  289. package/build/types/src/utils/sidecarOrders/index.d.ts +1 -0
  290. package/build/types/src/{types/sidecarOrders.d.ts → utils/sidecarOrders/types.d.ts} +2 -2
  291. package/build/types/src/utils/swap/botanixStaking.d.ts +2 -2
  292. package/build/types/src/utils/swap/buildSwapStrategy.d.ts +5 -5
  293. package/build/types/src/utils/swap/externalSwapPath.d.ts +1 -1
  294. package/build/types/src/utils/swap/externalSwapQuoteByPath.d.ts +1 -1
  295. package/build/types/src/utils/swap/findSwapPathsBetweenTokens.d.ts +1 -1
  296. package/build/types/src/utils/swap/index.d.ts +12 -0
  297. package/build/types/src/utils/swap/preparedSwapData.d.ts +1 -1
  298. package/build/types/src/utils/swap/swapPath.d.ts +6 -6
  299. package/build/types/src/utils/swap/swapRouting.d.ts +5 -5
  300. package/build/types/src/utils/swap/swapStats.d.ts +3 -3
  301. package/build/types/src/utils/swap/swapValues.d.ts +4 -4
  302. package/build/types/src/{types/swapStrategy.d.ts → utils/swap/types.d.ts} +1 -1
  303. package/build/types/src/utils/time/index.d.ts +1 -0
  304. package/build/types/src/utils/tokens/index.d.ts +2 -0
  305. package/build/types/src/utils/{tokens.d.ts → tokens/utils.d.ts} +2 -2
  306. package/build/types/src/utils/trade/decrease.d.ts +5 -5
  307. package/build/types/src/utils/trade/increase.d.ts +5 -5
  308. package/build/types/src/utils/trade/index.d.ts +3 -0
  309. package/build/types/src/utils/trade/trade.d.ts +1 -1
  310. package/build/types/src/{types/trade.d.ts → utils/trade/types.d.ts} +4 -4
  311. package/build/types/src/utils/tradeHistory/index.d.ts +2 -0
  312. package/build/types/src/{types/tradeHistory.d.ts → utils/tradeHistory/types.d.ts} +3 -3
  313. package/build/types/src/utils/{tradeHistory.d.ts → tradeHistory/utils.d.ts} +4 -4
  314. package/build/types/src/utils/twap/index.d.ts +3 -2
  315. package/build/types/src/utils/{types.d.ts → types/index.d.ts} +0 -1
  316. package/package.json +277 -29
  317. package/build/cjs/src/modules/markets/index.js +0 -366
  318. package/build/cjs/src/prebuilt/index.js +0 -15
  319. package/build/cjs/src/utils/markets.js +0 -195
  320. package/build/cjs/src/utils/types.js +0 -13
  321. package/build/esm/src/modules/markets/index.js +0 -359
  322. package/build/esm/src/prebuilt/index.js +0 -7
  323. package/build/esm/src/utils/markets.js +0 -171
  324. package/build/esm/src/utils/types.js +0 -8
  325. package/build/types/src/modules/markets/query-builders.d.ts +0 -42
  326. package/build/types/src/modules/markets/types.d.ts +0 -51
  327. package/build/types/src/prebuilt/index.d.ts +0 -24
  328. package/build/types/src/types/common.d.ts +0 -1
  329. package/build/types/src/utils/callContract.d.ts +0 -17
  330. package/build/types/src/utils/marketKeysAndConfigs.d.ts +0 -73
  331. package/build/types/src/utils/markets.d.ts +0 -58
  332. /package/build/cjs/src/{modules → clients/v1/modules}/base.js +0 -0
  333. /package/build/cjs/src/{modules/markets → clients/v1}/types.js +0 -0
  334. /package/build/cjs/src/{prebuilt → codegen/prebuilt}/hashedKinkModelMarketRatesKeys.json +0 -0
  335. /package/build/cjs/src/{prebuilt → codegen/prebuilt}/hashedMarketConfigKeys.json +0 -0
  336. /package/build/cjs/src/{prebuilt → codegen/prebuilt}/hashedMarketValuesKeys.json +0 -0
  337. /package/build/cjs/src/{types → codegen}/subsquid.js +0 -0
  338. /package/build/cjs/src/{types/chains.js → utils/24h/types.js} +0 -0
  339. /package/build/cjs/src/utils/{LruCache.js → LruCache/utils.js} +0 -0
  340. /package/build/cjs/src/utils/{abort.js → abort/utils.js} +0 -0
  341. /package/build/cjs/src/utils/{bigmath.js → bigmath/utils.js} +0 -0
  342. /package/build/cjs/src/utils/{buildUrl.js → buildUrl/utils.js} +0 -0
  343. /package/build/cjs/src/{types/common.js → utils/chains/types.js} +0 -0
  344. /package/build/cjs/src/{types/fees.js → utils/fees/types.js} +0 -0
  345. /package/build/cjs/src/utils/{gelatoRelay.js → gelatoRelay/utils.js} +0 -0
  346. /package/build/cjs/src/utils/{graphqlFetcher.js → graphqlFetcher/utils.js} +0 -0
  347. /package/build/cjs/src/{types/markets.js → utils/http/types.js} +0 -0
  348. /package/build/cjs/src/{types/positions.js → utils/markets/types.js} +0 -0
  349. /package/build/cjs/src/{types/orders.js → utils/orders/types.js} +0 -0
  350. /package/build/cjs/src/{types/sdk.js → utils/positions/types.js} +0 -0
  351. /package/build/cjs/src/{types/referrals.js → utils/referrals/types.js} +0 -0
  352. /package/build/cjs/src/utils/{referrals.js → referrals/utils.js} +0 -0
  353. /package/build/cjs/src/{types/sidecarOrders.js → utils/sidecarOrders/types.js} +0 -0
  354. /package/build/cjs/src/{types/swapStrategy.js → utils/swap/types.js} +0 -0
  355. /package/build/cjs/src/utils/{time.js → time/utils.js} +0 -0
  356. /package/build/cjs/src/{types/tokens.js → utils/tokens/types.js} +0 -0
  357. /package/build/cjs/src/{types/trade.js → utils/trade/types.js} +0 -0
  358. /package/build/cjs/src/{types/tradeHistory.js → utils/tradeHistory/types.js} +0 -0
  359. /package/build/cjs/src/{types/twap.js → utils/twap/types.js} +0 -0
  360. /package/build/esm/src/{modules → clients/v1/modules}/base.js +0 -0
  361. /package/build/esm/src/{modules/markets → clients/v1}/types.js +0 -0
  362. /package/build/esm/src/{prebuilt → codegen/prebuilt}/hashedKinkModelMarketRatesKeys.json +0 -0
  363. /package/build/esm/src/{prebuilt → codegen/prebuilt}/hashedMarketConfigKeys.json +0 -0
  364. /package/build/esm/src/{prebuilt → codegen/prebuilt}/hashedMarketValuesKeys.json +0 -0
  365. /package/build/esm/src/{types → codegen}/subsquid.js +0 -0
  366. /package/build/esm/src/{types/chains.js → utils/24h/types.js} +0 -0
  367. /package/build/esm/src/utils/{LruCache.js → LruCache/utils.js} +0 -0
  368. /package/build/esm/src/utils/{abort.js → abort/utils.js} +0 -0
  369. /package/build/esm/src/utils/{bigmath.js → bigmath/utils.js} +0 -0
  370. /package/build/esm/src/utils/{buildUrl.js → buildUrl/utils.js} +0 -0
  371. /package/build/esm/src/{types/common.js → utils/chains/types.js} +0 -0
  372. /package/build/esm/src/{types/fees.js → utils/fees/types.js} +0 -0
  373. /package/build/esm/src/utils/{gelatoRelay.js → gelatoRelay/utils.js} +0 -0
  374. /package/build/esm/src/utils/{graphqlFetcher.js → graphqlFetcher/utils.js} +0 -0
  375. /package/build/esm/src/{types/markets.js → utils/http/types.js} +0 -0
  376. /package/build/esm/src/{types/positions.js → utils/markets/types.js} +0 -0
  377. /package/build/esm/src/{types/orders.js → utils/orders/types.js} +0 -0
  378. /package/build/esm/src/{types/sdk.js → utils/positions/types.js} +0 -0
  379. /package/build/esm/src/{types/referrals.js → utils/referrals/types.js} +0 -0
  380. /package/build/esm/src/utils/{referrals.js → referrals/utils.js} +0 -0
  381. /package/build/esm/src/{types/sidecarOrders.js → utils/sidecarOrders/types.js} +0 -0
  382. /package/build/esm/src/{types/swapStrategy.js → utils/swap/types.js} +0 -0
  383. /package/build/esm/src/utils/{time.js → time/utils.js} +0 -0
  384. /package/build/esm/src/{types/tokens.js → utils/tokens/types.js} +0 -0
  385. /package/build/esm/src/{types/trade.js → utils/trade/types.js} +0 -0
  386. /package/build/esm/src/{types/tradeHistory.js → utils/tradeHistory/types.js} +0 -0
  387. /package/build/esm/src/{types/twap.js → utils/twap/types.js} +0 -0
  388. /package/build/types/src/{modules → clients/v1/modules}/accounts/accounts.d.ts +0 -0
  389. /package/build/types/src/{modules → clients/v1/modules}/accounts/accounts.spec.d.ts +0 -0
  390. /package/build/types/src/{modules → clients/v1/modules}/base.d.ts +0 -0
  391. /package/build/types/src/{modules → clients/v1/modules}/markets/markets.spec.d.ts +0 -0
  392. /package/build/types/src/{modules → clients/v1/modules}/orders/helpers.spec.d.ts +0 -0
  393. /package/build/types/src/{modules → clients/v1/modules}/orders/orders.spec.d.ts +0 -0
  394. /package/build/types/src/{modules → clients/v1/modules}/orders/transactions/cancelOrdersTxn.d.ts +0 -0
  395. /package/build/types/src/{modules → clients/v1/modules}/orders/transactions/createWrapOrUnwrapTxn.d.ts +0 -0
  396. /package/build/types/src/{modules → clients/v1/modules}/positions/positions.spec.d.ts +0 -0
  397. /package/build/types/src/{modules → clients/v1/modules}/tokens/tokens.spec.d.ts +0 -0
  398. /package/build/types/src/{modules → clients/v1/modules}/trades/trades.spec.d.ts +0 -0
  399. /package/build/types/src/utils/{LruCache.d.ts → LruCache/utils.d.ts} +0 -0
  400. /package/build/types/src/utils/{abort.d.ts → abort/utils.d.ts} +0 -0
  401. /package/build/types/src/utils/{bigmath.d.ts → bigmath/utils.d.ts} +0 -0
  402. /package/build/types/src/utils/{buildUrl.d.ts → buildUrl/utils.d.ts} +0 -0
  403. /package/build/types/src/{types/chains.d.ts → utils/chains/types.d.ts} +0 -0
  404. /package/build/types/src/utils/{gelatoRelay.d.ts → gelatoRelay/utils.d.ts} +0 -0
  405. /package/build/types/src/utils/{graphqlFetcher.d.ts → graphqlFetcher/utils.d.ts} +0 -0
  406. /package/build/types/src/utils/{hash.d.ts → hash/utils.d.ts} +0 -0
  407. /package/build/types/src/utils/{indexers.d.ts → indexers/utils.d.ts} +0 -0
  408. /package/build/types/src/{types/referrals.d.ts → utils/referrals/types.d.ts} +0 -0
  409. /package/build/types/src/utils/{referrals.d.ts → referrals/utils.d.ts} +0 -0
  410. /package/build/types/src/utils/{time.d.ts → time/utils.d.ts} +0 -0
  411. /package/build/types/src/{types/tokens.d.ts → utils/tokens/types.d.ts} +0 -0
  412. /package/build/types/src/{types/twap.d.ts → utils/twap/types.d.ts} +0 -0
@@ -1,359 +0,0 @@
1
- import { zeroAddress } from "viem";
2
- import { getContract } from "../../configs/contracts";
3
- import { USE_OPEN_INTEREST_IN_TOKENS_FOR_BALANCE } from "../../configs/dataStore";
4
- import { convertTokenAddress, getToken } from "../../configs/tokens";
5
- import graphqlFetcher from "../../utils/graphqlFetcher";
6
- import { getMarketDivisor, getMarketFullName } from "../../utils/markets";
7
- import { getByKey } from "../../utils/objects";
8
- import { Module } from "../base";
9
- import { buildClaimableFundingDataRequest, buildMarketsConfigsRequest, buildMarketsValuesRequest, } from "./query-builders";
10
- export class Markets extends Module {
11
- async getClaimableFundingData() {
12
- const chainId = this.chainId;
13
- const account = this.account;
14
- if (!account) {
15
- return {};
16
- }
17
- const { marketsAddresses, marketsData } = await this.getMarkets();
18
- return this.sdk
19
- .executeMulticall(buildClaimableFundingDataRequest({
20
- chainId,
21
- account,
22
- marketsAddresses,
23
- marketsData,
24
- }))
25
- .then((result) => {
26
- return Object.entries(result.data).reduce((claimableFundingData, [marketAddress, callsResult]) => {
27
- const market = getByKey(marketsData, marketAddress);
28
- if (!market) {
29
- return claimableFundingData;
30
- }
31
- const marketDivisor = getMarketDivisor(market);
32
- claimableFundingData[marketAddress] = {
33
- claimableFundingAmountLong: callsResult.claimableFundingAmountLong.returnValues[0] / marketDivisor,
34
- claimableFundingAmountShort: callsResult.claimableFundingAmountShort.returnValues[0] / marketDivisor,
35
- };
36
- return claimableFundingData;
37
- }, {});
38
- });
39
- }
40
- async getMarketsValues({ marketsAddresses, marketsData, tokensData, }) {
41
- const dataStoreAddress = getContract(this.chainId, "DataStore");
42
- const syntheticsReaderAddress = getContract(this.chainId, "SyntheticsReader");
43
- const request = await buildMarketsValuesRequest(this.chainId, {
44
- marketsAddresses,
45
- marketsData,
46
- tokensData,
47
- dataStoreAddress,
48
- syntheticsReaderAddress,
49
- });
50
- return this.sdk.executeMulticall(request).then((res) => {
51
- const result = marketsAddresses.reduce((acc, marketAddress) => {
52
- const readerErrors = res.errors[`${marketAddress}-reader`];
53
- const dataStoreErrors = res.errors[`${marketAddress}-dataStore`];
54
- const readerValues = res.data[`${marketAddress}-reader`];
55
- const dataStoreValues = res.data[`${marketAddress}-dataStore`];
56
- // Skip invalid market
57
- if (!readerValues || !dataStoreValues || readerErrors || dataStoreErrors) {
58
- // eslint-disable-next-line no-console
59
- console.warn(`No market found ${marketAddress} in getMarketsValues`);
60
- return acc;
61
- }
62
- const market = getByKey(marketsData, marketAddress);
63
- const marketDivisor = market.isSameCollaterals ? 2n : 1n;
64
- const longInterestUsingLongToken = BigInt(dataStoreValues.longInterestUsingLongToken.returnValues[0]) / marketDivisor;
65
- const longInterestUsingShortToken = BigInt(dataStoreValues.longInterestUsingShortToken.returnValues[0]) / marketDivisor;
66
- const shortInterestUsingLongToken = BigInt(dataStoreValues.shortInterestUsingLongToken.returnValues[0]) / marketDivisor;
67
- const shortInterestUsingShortToken = BigInt(dataStoreValues.shortInterestUsingShortToken.returnValues[0]) / marketDivisor;
68
- const longInterestUsd = longInterestUsingLongToken + longInterestUsingShortToken;
69
- const shortInterestUsd = shortInterestUsingLongToken + shortInterestUsingShortToken;
70
- const longInterestInTokensUsingLongToken = BigInt(dataStoreValues.longInterestInTokensUsingLongToken.returnValues[0]) / marketDivisor;
71
- const longInterestInTokensUsingShortToken = BigInt(dataStoreValues.longInterestInTokensUsingShortToken.returnValues[0]) / marketDivisor;
72
- const shortInterestInTokensUsingLongToken = BigInt(dataStoreValues.shortInterestInTokensUsingLongToken.returnValues[0]) / marketDivisor;
73
- const shortInterestInTokensUsingShortToken = BigInt(dataStoreValues.shortInterestInTokensUsingShortToken.returnValues[0]) / marketDivisor;
74
- const longInterestInTokens = longInterestInTokensUsingLongToken + longInterestInTokensUsingShortToken;
75
- const shortInterestInTokens = shortInterestInTokensUsingLongToken + shortInterestInTokensUsingShortToken;
76
- const { nextFunding, virtualInventory } = readerValues.marketInfo.returnValues;
77
- const [, poolValueInfoMin] = readerValues.marketTokenPriceMin.returnValues;
78
- const [, poolValueInfoMax] = readerValues.marketTokenPriceMax.returnValues;
79
- acc[marketAddress] = {
80
- longInterestUsd,
81
- shortInterestUsd,
82
- longInterestInTokens,
83
- shortInterestInTokens,
84
- longPoolAmount: dataStoreValues.longPoolAmount.returnValues[0] / marketDivisor,
85
- shortPoolAmount: dataStoreValues.shortPoolAmount.returnValues[0] / marketDivisor,
86
- poolValueMin: poolValueInfoMin.poolValue,
87
- poolValueMax: poolValueInfoMax.poolValue,
88
- totalBorrowingFees: poolValueInfoMax.totalBorrowingFees,
89
- positionImpactPoolAmount: dataStoreValues.positionImpactPoolAmount.returnValues[0],
90
- swapImpactPoolAmountLong: dataStoreValues.swapImpactPoolAmountLong.returnValues[0],
91
- swapImpactPoolAmountShort: dataStoreValues.swapImpactPoolAmountShort.returnValues[0],
92
- borrowingFactorPerSecondForLongs: readerValues.marketInfo.returnValues.borrowingFactorPerSecondForLongs,
93
- borrowingFactorPerSecondForShorts: readerValues.marketInfo.returnValues.borrowingFactorPerSecondForShorts,
94
- fundingFactorPerSecond: nextFunding.fundingFactorPerSecond,
95
- longsPayShorts: nextFunding.longsPayShorts,
96
- virtualPoolAmountForLongToken: virtualInventory.virtualPoolAmountForLongToken,
97
- virtualPoolAmountForShortToken: virtualInventory.virtualPoolAmountForShortToken,
98
- virtualInventoryForPositions: virtualInventory.virtualInventoryForPositions,
99
- };
100
- return acc;
101
- }, {});
102
- return result;
103
- });
104
- }
105
- async getMarketsConfigs({ marketsAddresses, marketsData, }) {
106
- const dataStoreAddress = getContract(this.chainId, "DataStore");
107
- const request = await buildMarketsConfigsRequest(this.chainId, {
108
- marketsData,
109
- marketsAddresses,
110
- dataStoreAddress,
111
- });
112
- return this.sdk.executeMulticall(request).then((res) => {
113
- const result = marketsAddresses.reduce((acc, marketAddress) => {
114
- const dataStoreErrors = res.errors[`${marketAddress}-dataStore`];
115
- const dataStoreValues = res.data[`${marketAddress}-dataStore`];
116
- // Skip invalid market
117
- if (!dataStoreValues || dataStoreErrors) {
118
- // eslint-disable-next-line no-console
119
- console.log("Market info error", marketAddress, dataStoreErrors, dataStoreValues);
120
- return acc;
121
- }
122
- acc[marketAddress] = {
123
- isDisabled: dataStoreValues.isDisabled.returnValues[0],
124
- maxLongPoolUsdForDeposit: dataStoreValues.maxLongPoolUsdForDeposit.returnValues[0],
125
- maxShortPoolUsdForDeposit: dataStoreValues.maxShortPoolUsdForDeposit.returnValues[0],
126
- maxLongPoolAmount: dataStoreValues.maxLongPoolAmount.returnValues[0],
127
- maxShortPoolAmount: dataStoreValues.maxShortPoolAmount.returnValues[0],
128
- reserveFactorLong: dataStoreValues.reserveFactorLong.returnValues[0],
129
- reserveFactorShort: dataStoreValues.reserveFactorShort.returnValues[0],
130
- openInterestReserveFactorLong: dataStoreValues.openInterestReserveFactorLong.returnValues[0],
131
- openInterestReserveFactorShort: dataStoreValues.openInterestReserveFactorShort.returnValues[0],
132
- maxOpenInterestLong: dataStoreValues.maxOpenInterestLong.returnValues[0],
133
- maxOpenInterestShort: dataStoreValues.maxOpenInterestShort.returnValues[0],
134
- minPositionImpactPoolAmount: dataStoreValues.minPositionImpactPoolAmount.returnValues[0],
135
- positionImpactPoolDistributionRate: dataStoreValues.positionImpactPoolDistributionRate.returnValues[0],
136
- borrowingFactorLong: dataStoreValues.borrowingFactorLong.returnValues[0],
137
- borrowingFactorShort: dataStoreValues.borrowingFactorShort.returnValues[0],
138
- borrowingExponentFactorLong: dataStoreValues.borrowingExponentFactorLong.returnValues[0],
139
- borrowingExponentFactorShort: dataStoreValues.borrowingExponentFactorShort.returnValues[0],
140
- fundingFactor: dataStoreValues.fundingFactor.returnValues[0],
141
- fundingExponentFactor: dataStoreValues.fundingExponentFactor.returnValues[0],
142
- fundingIncreaseFactorPerSecond: dataStoreValues.fundingIncreaseFactorPerSecond.returnValues[0],
143
- fundingDecreaseFactorPerSecond: dataStoreValues.fundingDecreaseFactorPerSecond.returnValues[0],
144
- thresholdForDecreaseFunding: dataStoreValues.thresholdForDecreaseFunding.returnValues[0],
145
- thresholdForStableFunding: dataStoreValues.thresholdForStableFunding.returnValues[0],
146
- minFundingFactorPerSecond: dataStoreValues.minFundingFactorPerSecond.returnValues[0],
147
- maxFundingFactorPerSecond: dataStoreValues.maxFundingFactorPerSecond.returnValues[0],
148
- maxPnlFactorForTradersLong: dataStoreValues.maxPnlFactorForTradersLong.returnValues[0],
149
- maxPnlFactorForTradersShort: dataStoreValues.maxPnlFactorForTradersShort.returnValues[0],
150
- minCollateralFactor: dataStoreValues.minCollateralFactor.returnValues[0],
151
- minCollateralFactorForOpenInterestLong: dataStoreValues.minCollateralFactorForOpenInterestLong.returnValues[0],
152
- minCollateralFactorForOpenInterestShort: dataStoreValues.minCollateralFactorForOpenInterestShort.returnValues[0],
153
- minCollateralFactorForLiquidation: dataStoreValues.minCollateralFactorForLiquidation.returnValues[0],
154
- positionFeeFactorForBalanceWasImproved: dataStoreValues.positionFeeFactorForBalanceWasImproved.returnValues[0],
155
- positionFeeFactorForBalanceWasNotImproved: dataStoreValues.positionFeeFactorForBalanceWasNotImproved.returnValues[0],
156
- positionImpactFactorPositive: dataStoreValues.positionImpactFactorPositive.returnValues[0],
157
- positionImpactFactorNegative: dataStoreValues.positionImpactFactorNegative.returnValues[0],
158
- maxPositionImpactFactorPositive: dataStoreValues.maxPositionImpactFactorPositive.returnValues[0],
159
- maxPositionImpactFactorNegative: dataStoreValues.maxPositionImpactFactorNegative.returnValues[0],
160
- maxPositionImpactFactorForLiquidations: dataStoreValues.maxPositionImpactFactorForLiquidations.returnValues[0],
161
- maxLendableImpactFactor: dataStoreValues.maxLendableImpactFactor.returnValues[0],
162
- maxLendableImpactFactorForWithdrawals: dataStoreValues.maxLendableImpactFactorForWithdrawals.returnValues[0],
163
- maxLendableImpactUsd: dataStoreValues.maxLendableImpactUsd.returnValues[0],
164
- lentPositionImpactPoolAmount: dataStoreValues.lentPositionImpactPoolAmount.returnValues[0],
165
- positionImpactExponentFactorPositive: dataStoreValues.positionImpactExponentFactorPositive.returnValues[0],
166
- positionImpactExponentFactorNegative: dataStoreValues.positionImpactExponentFactorNegative.returnValues[0],
167
- swapFeeFactorForBalanceWasImproved: dataStoreValues.swapFeeFactorForBalanceWasImproved.returnValues[0],
168
- swapFeeFactorForBalanceWasNotImproved: dataStoreValues.swapFeeFactorForBalanceWasNotImproved.returnValues[0],
169
- swapImpactFactorPositive: dataStoreValues.swapImpactFactorPositive.returnValues[0],
170
- atomicSwapFeeFactor: dataStoreValues.atomicSwapFeeFactor.returnValues[0],
171
- swapImpactFactorNegative: dataStoreValues.swapImpactFactorNegative.returnValues[0],
172
- swapImpactExponentFactor: dataStoreValues.swapImpactExponentFactor.returnValues[0],
173
- withdrawalFeeFactorBalanceWasImproved: dataStoreValues.withdrawalFeeFactorBalanceWasImproved.returnValues[0],
174
- withdrawalFeeFactorBalanceWasNotImproved: dataStoreValues.withdrawalFeeFactorBalanceWasNotImproved.returnValues[0],
175
- virtualMarketId: dataStoreValues.virtualMarketId.returnValues[0],
176
- virtualLongTokenId: dataStoreValues.virtualLongTokenId.returnValues[0],
177
- virtualShortTokenId: dataStoreValues.virtualShortTokenId.returnValues[0],
178
- };
179
- return acc;
180
- }, {});
181
- return result;
182
- });
183
- }
184
- async getMarketsConstants() {
185
- const dataStoreAddress = getContract(this.chainId, "DataStore");
186
- return this.sdk
187
- .executeMulticall({
188
- dataStore: {
189
- contractAddress: dataStoreAddress,
190
- abiId: "DataStore",
191
- calls: {
192
- useOpenInterestInTokensForBalance: {
193
- methodName: "getBool",
194
- params: [USE_OPEN_INTEREST_IN_TOKENS_FOR_BALANCE],
195
- },
196
- },
197
- },
198
- })
199
- .then((res) => {
200
- if (res.errors.dataStore || !res.data.dataStore) {
201
- // eslint-disable-next-line no-console
202
- console.warn("Failed to get markets constants", res.errors.dataStore, res.data.dataStore);
203
- return undefined;
204
- }
205
- return {
206
- useOpenInterestInTokensForBalance: res.data.dataStore.useOpenInterestInTokensForBalance.returnValues[0],
207
- };
208
- });
209
- }
210
- async getMarkets(offset = 0n, limit = 300n) {
211
- if (this._marketsData && this._marketsDataOffset === offset && this._marketsDataLimit === limit) {
212
- return this._marketsData;
213
- }
214
- const readerAddress = getContract(this.chainId, "SyntheticsReader");
215
- const dataStoreAddress = getContract(this.chainId, "DataStore");
216
- const apiMarkets = await this.sdk.oracle.getMarkets();
217
- const configMarkets = this.sdk.config.markets ?? {};
218
- const marketsMap = apiMarkets.reduce((acc, market) => {
219
- if (configMarkets[market.marketToken]?.isListed === false) {
220
- return acc;
221
- }
222
- return {
223
- ...acc,
224
- [market.marketToken]: market,
225
- };
226
- }, {});
227
- const markets = await this.sdk
228
- .executeMulticall({
229
- markets: {
230
- contractAddress: readerAddress,
231
- abiId: "SyntheticsReader",
232
- calls: {
233
- markets: {
234
- methodName: "getMarkets",
235
- params: [dataStoreAddress, offset, offset + limit],
236
- },
237
- },
238
- },
239
- })
240
- .then((res) => {
241
- return res.data.markets.markets.returnValues.map((market) => {
242
- return {
243
- marketTokenAddress: market.marketToken,
244
- indexTokenAddress: market.indexToken,
245
- longTokenAddress: market.longToken,
246
- shortTokenAddress: market.shortToken,
247
- };
248
- });
249
- });
250
- const chainId = this.chainId;
251
- const marketsResult = markets.reduce((acc, market) => {
252
- try {
253
- if (!marketsMap[market.marketTokenAddress]?.isListed) {
254
- return acc;
255
- }
256
- const indexToken = getToken(chainId, convertTokenAddress(chainId, market.indexTokenAddress, "native"));
257
- const longToken = getToken(chainId, market.longTokenAddress);
258
- const shortToken = getToken(chainId, market.shortTokenAddress);
259
- const isSameCollaterals = market.longTokenAddress === market.shortTokenAddress;
260
- const isSpotOnly = market.indexTokenAddress === zeroAddress;
261
- const name = getMarketFullName({ indexToken, longToken, shortToken, isSpotOnly });
262
- acc.marketsAddresses.push(market.marketTokenAddress);
263
- acc.marketsData[market.marketTokenAddress] = {
264
- ...market,
265
- isSameCollaterals,
266
- isSpotOnly,
267
- name,
268
- data: "",
269
- };
270
- }
271
- catch (e) {
272
- // eslint-disable-next-line no-console
273
- console.warn(`Unsupported market ${market.marketTokenAddress}`, e);
274
- }
275
- return acc;
276
- }, { marketsData: {}, marketsAddresses: [] });
277
- this._marketsData = marketsResult;
278
- this._marketsDataOffset = offset;
279
- this._marketsDataLimit = limit;
280
- return marketsResult;
281
- }
282
- async getMarketsInfo() {
283
- const { marketsData, marketsAddresses } = await this.getMarkets();
284
- const { tokensData, pricesUpdatedAt } = await this.sdk.tokens.getTokensData();
285
- const [marketsValues, marketsConfigs, claimableFundingData, marketsConstants] = await Promise.all([
286
- this.getMarketsValues({
287
- account: this.account,
288
- marketsAddresses,
289
- marketsData,
290
- tokensData,
291
- }),
292
- this.getMarketsConfigs({
293
- marketsAddresses,
294
- marketsData,
295
- }),
296
- this.getClaimableFundingData(),
297
- this.getMarketsConstants(),
298
- ]);
299
- if (!marketsValues || !marketsConfigs || !marketsAddresses || !claimableFundingData) {
300
- return {
301
- marketsInfoData: {},
302
- tokensData,
303
- pricesUpdatedAt,
304
- };
305
- }
306
- // Manual merging to avoid cloning tokens as they are sometimes compared by reference
307
- const marketsInfoData = {};
308
- for (const marketAddress of marketsAddresses) {
309
- const market = marketsData?.[marketAddress];
310
- const marketValues = marketsValues[marketAddress];
311
- const marketConfig = marketsConfigs[marketAddress];
312
- const longToken = getByKey(tokensData, market?.longTokenAddress);
313
- const shortToken = getByKey(tokensData, market?.shortTokenAddress);
314
- const indexToken = market
315
- ? getByKey(tokensData, convertTokenAddress(this.chainId, market.indexTokenAddress, "native"))
316
- : undefined;
317
- if (!market || !marketValues || !marketConfig || !longToken || !shortToken || !indexToken || !marketsConstants) {
318
- continue;
319
- }
320
- const fullMarketInfo = {
321
- ...marketValues,
322
- ...marketConfig,
323
- ...claimableFundingData[marketAddress],
324
- ...market,
325
- ...marketsConstants,
326
- longToken,
327
- shortToken,
328
- indexToken,
329
- };
330
- marketsInfoData[marketAddress] = fullMarketInfo;
331
- }
332
- return {
333
- marketsInfoData,
334
- tokensData,
335
- pricesUpdatedAt,
336
- };
337
- }
338
- async getDailyVolumes() {
339
- const { marketsAddresses } = await this.getMarkets();
340
- const endpoint = this.sdk.config.subsquidUrl;
341
- if (!marketsAddresses || !endpoint) {
342
- return;
343
- }
344
- return graphqlFetcher(endpoint, POSITIONS_VOLUME_INFOS_QUERY).then((data) => {
345
- return data?.positionsVolume.length
346
- ? data?.positionsVolume.reduce((acc, { market, volume }) => {
347
- return { ...acc, [market]: BigInt(volume) };
348
- }, {})
349
- : {};
350
- });
351
- }
352
- }
353
- const POSITIONS_VOLUME_INFOS_QUERY = `
354
- {
355
- positionsVolume(where: {period: "1d"}) {
356
- market
357
- volume
358
- }
359
- }`;
@@ -1,7 +0,0 @@
1
- import hashedKinkModelMarketRatesKeys from "./hashedKinkModelMarketRatesKeys.json";
2
- import hashedMarketConfigKeysJson from "./hashedMarketConfigKeys.json";
3
- import hashedMarketValuesKeysJson from "./hashedMarketValuesKeys.json";
4
- const HASHED_MARKET_VALUES_KEYS = hashedMarketValuesKeysJson;
5
- const HASHED_MARKET_CONFIG_KEYS = hashedMarketConfigKeysJson;
6
- const HASHED_KINK_MODEL_MARKET_RATES_KEYS = hashedKinkModelMarketRatesKeys;
7
- export { HASHED_KINK_MODEL_MARKET_RATES_KEYS, HASHED_MARKET_CONFIG_KEYS, HASHED_MARKET_VALUES_KEYS };
@@ -1,171 +0,0 @@
1
- import { BASIS_POINTS_DIVISOR } from "../configs/factors";
2
- import { getTokenVisualMultiplier, NATIVE_TOKEN_ADDRESS } from "../configs/tokens";
3
- import { applyFactor, PRECISION } from "./numbers";
4
- import { getByKey } from "./objects";
5
- import { convertToContractTokenPrices, convertToUsd, getMidPrice } from "./tokens";
6
- export function getMarketFullName(p) {
7
- const { indexToken, longToken, shortToken, isSpotOnly } = p;
8
- return `${getMarketIndexName({ indexToken, isSpotOnly })} [${getMarketPoolName({ longToken, shortToken })}]`;
9
- }
10
- export function getMarketIndexName(p) {
11
- if (p.isSpotOnly) {
12
- return `SWAP-ONLY`;
13
- }
14
- return `${getMarketBaseName(p)}/USD`;
15
- }
16
- export function getMarketBaseName(p) {
17
- const { isSpotOnly } = p;
18
- const firstToken = "indexToken" in p ? p.indexToken : p.glvToken;
19
- if (isSpotOnly) {
20
- return `SWAP-ONLY`;
21
- }
22
- const prefix = getTokenVisualMultiplier(firstToken);
23
- return `${prefix}${firstToken.baseSymbol || firstToken.symbol}`;
24
- }
25
- export function getMarketPoolName(p, separator = "-") {
26
- const { longToken, shortToken } = p;
27
- return `${longToken.symbol}${separator}${shortToken.symbol}`;
28
- }
29
- export function getContractMarketPrices(tokensData, market) {
30
- const indexToken = getByKey(tokensData, market.indexTokenAddress);
31
- const longToken = getByKey(tokensData, market.longTokenAddress);
32
- const shortToken = getByKey(tokensData, market.shortTokenAddress);
33
- if (!indexToken || !longToken || !shortToken) {
34
- return undefined;
35
- }
36
- return {
37
- indexTokenPrice: indexToken && convertToContractTokenPrices(indexToken.prices, indexToken.decimals),
38
- longTokenPrice: longToken && convertToContractTokenPrices(longToken.prices, longToken.decimals),
39
- shortTokenPrice: shortToken && convertToContractTokenPrices(shortToken.prices, shortToken.decimals),
40
- };
41
- }
42
- /**
43
- * Apart from usual cases, returns `long` for single token backed markets.
44
- */
45
- export function getTokenPoolType(marketInfo, tokenAddress) {
46
- const { longToken, shortToken } = marketInfo;
47
- if (longToken.address === shortToken.address && tokenAddress === longToken.address) {
48
- return "long";
49
- }
50
- if (tokenAddress === longToken.address || (tokenAddress === NATIVE_TOKEN_ADDRESS && longToken.isWrapped)) {
51
- return "long";
52
- }
53
- if (tokenAddress === shortToken.address || (tokenAddress === NATIVE_TOKEN_ADDRESS && shortToken.isWrapped)) {
54
- return "short";
55
- }
56
- return undefined;
57
- }
58
- export function getPoolUsdWithoutPnl(marketInfo, isLong, priceType) {
59
- const poolAmount = isLong ? marketInfo.longPoolAmount : marketInfo.shortPoolAmount;
60
- const token = isLong ? marketInfo.longToken : marketInfo.shortToken;
61
- let price;
62
- if (priceType === "minPrice") {
63
- price = token.prices?.minPrice;
64
- }
65
- else if (priceType === "maxPrice") {
66
- price = token.prices?.maxPrice;
67
- }
68
- else {
69
- price = getMidPrice(token.prices);
70
- }
71
- return convertToUsd(poolAmount, token.decimals, price);
72
- }
73
- export function getCappedPoolPnl(p) {
74
- const { marketInfo, poolUsd, poolPnl, isLong } = p;
75
- if (poolPnl < 0) {
76
- return poolPnl;
77
- }
78
- const maxPnlFactor = isLong ? marketInfo.maxPnlFactorForTradersLong : marketInfo.maxPnlFactorForTradersShort;
79
- const maxPnl = applyFactor(poolUsd, maxPnlFactor);
80
- return poolPnl > maxPnl ? maxPnl : poolPnl;
81
- }
82
- export function getMaxLeverageByMinCollateralFactor(minCollateralFactor) {
83
- if (minCollateralFactor === undefined)
84
- return 100 * BASIS_POINTS_DIVISOR;
85
- if (minCollateralFactor === 0n)
86
- return 100 * BASIS_POINTS_DIVISOR;
87
- const x = Number(PRECISION / minCollateralFactor);
88
- const rounded = Math.round(x / 10) * 10;
89
- return rounded * BASIS_POINTS_DIVISOR;
90
- }
91
- export function getMaxAllowedLeverageByMinCollateralFactor(minCollateralFactor) {
92
- return getMaxLeverageByMinCollateralFactor(minCollateralFactor) / 2;
93
- }
94
- export function getOppositeCollateral(marketInfo, tokenAddress) {
95
- const poolType = getTokenPoolType(marketInfo, tokenAddress);
96
- if (poolType === "long") {
97
- return marketInfo.shortToken;
98
- }
99
- if (poolType === "short") {
100
- return marketInfo.longToken;
101
- }
102
- return undefined;
103
- }
104
- export function getOppositeCollateralFromConfig(marketConfig, tokenAddress) {
105
- return marketConfig.shortTokenAddress === tokenAddress
106
- ? marketConfig.longTokenAddress
107
- : marketConfig.shortTokenAddress;
108
- }
109
- export function getAvailableUsdLiquidityForCollateral(marketInfo, isLong) {
110
- const poolUsd = getPoolUsdWithoutPnl(marketInfo, isLong, "minPrice");
111
- if (marketInfo.isSpotOnly) {
112
- return poolUsd;
113
- }
114
- const reservedUsd = getReservedUsd(marketInfo, isLong);
115
- const maxReserveFactor = isLong ? marketInfo.reserveFactorLong : marketInfo.reserveFactorShort;
116
- if (maxReserveFactor === 0n) {
117
- return 0n;
118
- }
119
- const minPoolUsd = (reservedUsd * PRECISION) / maxReserveFactor;
120
- const liquidity = poolUsd - minPoolUsd;
121
- return liquidity;
122
- }
123
- export function getReservedUsd(marketInfo, isLong) {
124
- const { indexToken } = marketInfo;
125
- if (isLong) {
126
- return convertToUsd(marketInfo.longInterestInTokens, marketInfo.indexToken.decimals, indexToken.prices.maxPrice);
127
- }
128
- else {
129
- return marketInfo.shortInterestUsd;
130
- }
131
- }
132
- export function getMarketDivisor({ longTokenAddress, shortTokenAddress, }) {
133
- return longTokenAddress === shortTokenAddress ? 2n : 1n;
134
- }
135
- export function getMarketPnl(marketInfo, isLong, forMaxPoolValue) {
136
- const maximize = !forMaxPoolValue;
137
- const openInterestUsd = getOpenInterestUsd(marketInfo, isLong);
138
- const openInterestInTokens = getOpenInterestInTokens(marketInfo, isLong);
139
- if (openInterestUsd === 0n || openInterestInTokens === 0n) {
140
- return 0n;
141
- }
142
- const price = getPriceForPnl(marketInfo.indexToken.prices, isLong, maximize);
143
- const openInterestValue = convertToUsd(openInterestInTokens, marketInfo.indexToken.decimals, price);
144
- const pnl = isLong ? openInterestValue - openInterestUsd : openInterestUsd - openInterestValue;
145
- return pnl;
146
- }
147
- export function getOpenInterestUsd(marketInfo, isLong) {
148
- return isLong ? marketInfo.longInterestUsd : marketInfo.shortInterestUsd;
149
- }
150
- export function getOpenInterestInTokens(marketInfo, isLong) {
151
- return isLong ? marketInfo.longInterestInTokens : marketInfo.shortInterestInTokens;
152
- }
153
- export function getOpenInterestForBalance(marketInfo, isLong) {
154
- if (marketInfo.useOpenInterestInTokensForBalance) {
155
- const interestInTokens = isLong ? marketInfo.longInterestInTokens : marketInfo.shortInterestInTokens;
156
- const indexTokenPrice = getMidPrice(marketInfo.indexToken.prices);
157
- return convertToUsd(interestInTokens, marketInfo.indexToken.decimals, indexTokenPrice);
158
- }
159
- return isLong ? marketInfo.longInterestUsd : marketInfo.shortInterestUsd;
160
- }
161
- export function getPriceForPnl(prices, isLong, maximize) {
162
- // for long positions, pick the larger price to maximize pnl
163
- // for short positions, pick the smaller price to maximize pnl
164
- if (isLong) {
165
- return maximize ? prices.maxPrice : prices.minPrice;
166
- }
167
- return maximize ? prices.minPrice : prices.maxPrice;
168
- }
169
- export function getIsMarketAvailableForExpressSwaps(marketInfo) {
170
- return [marketInfo.indexToken, marketInfo.longToken, marketInfo.shortToken].every((token) => token.hasPriceFeedProvider);
171
- }
@@ -1,8 +0,0 @@
1
- export const mustNeverExist = (x) => {
2
- throw new Error(`Must never exist: ${x}`);
3
- };
4
- export const assertDefined = (x) => {
5
- if (x === undefined)
6
- throw new Error(`Expected defined value, got undefined`);
7
- return x;
8
- };
@@ -1,42 +0,0 @@
1
- import { ContractsChainId } from "../../configs/chains";
2
- import { MarketsData } from "../../types/markets";
3
- import { TokensData } from "../../types/tokens";
4
- import type { ContractCallsConfig } from "../../utils/multicall";
5
- export declare function buildClaimableFundingDataRequest({ marketsAddresses, marketsData, chainId, account, }: {
6
- marketsAddresses: string[] | undefined;
7
- marketsData: MarketsData | undefined;
8
- account: string;
9
- chainId: ContractsChainId;
10
- }): Record<string, ContractCallsConfig<any>>;
11
- export declare function buildMarketsValuesRequest(chainId: number, { marketsAddresses, marketsData, tokensData, dataStoreAddress, syntheticsReaderAddress, }: {
12
- marketsAddresses: string[] | undefined;
13
- marketsData: MarketsData | undefined;
14
- tokensData: TokensData | undefined;
15
- dataStoreAddress: string;
16
- syntheticsReaderAddress: string;
17
- }): Promise<import("../../utils/multicall").MulticallRequestConfig<{
18
- [key: `${string}-reader`]: {
19
- calls: Record<"marketInfo" | "marketTokenPriceMax" | "marketTokenPriceMin", {
20
- methodName: string;
21
- params: any[];
22
- }>;
23
- };
24
- [key: `${string}-dataStore`]: {
25
- calls: Record<"positionImpactPoolAmount" | "longPoolAmount" | "shortPoolAmount" | "swapImpactPoolAmountLong" | "swapImpactPoolAmountShort" | "longInterestUsingLongToken" | "longInterestUsingShortToken" | "shortInterestUsingLongToken" | "shortInterestUsingShortToken" | "longInterestInTokensUsingLongToken" | "longInterestInTokensUsingShortToken" | "shortInterestInTokensUsingLongToken" | "shortInterestInTokensUsingShortToken", {
26
- methodName: string;
27
- params: any[];
28
- }>;
29
- };
30
- }>>;
31
- export declare function buildMarketsConfigsRequest(chainId: number, { marketsData, marketsAddresses, dataStoreAddress, }: {
32
- marketsData: MarketsData | undefined;
33
- marketsAddresses: string[] | undefined;
34
- dataStoreAddress: string;
35
- }): Promise<import("../../utils/multicall").MulticallRequestConfig<{
36
- [key: `${string}-dataStore`]: {
37
- calls: Record<"maxFundingFactorPerSecond" | "isDisabled" | "maxLongPoolAmount" | "maxShortPoolAmount" | "maxLongPoolUsdForDeposit" | "maxShortPoolUsdForDeposit" | "reserveFactorLong" | "reserveFactorShort" | "openInterestReserveFactorLong" | "openInterestReserveFactorShort" | "maxOpenInterestLong" | "maxOpenInterestShort" | "minPositionImpactPoolAmount" | "positionImpactPoolDistributionRate" | "borrowingFactorLong" | "borrowingFactorShort" | "borrowingExponentFactorLong" | "borrowingExponentFactorShort" | "fundingFactor" | "fundingExponentFactor" | "fundingIncreaseFactorPerSecond" | "fundingDecreaseFactorPerSecond" | "thresholdForStableFunding" | "thresholdForDecreaseFunding" | "minFundingFactorPerSecond" | "maxPnlFactorForTradersLong" | "maxPnlFactorForTradersShort" | "positionFeeFactorForBalanceWasImproved" | "positionFeeFactorForBalanceWasNotImproved" | "positionImpactFactorPositive" | "positionImpactFactorNegative" | "maxPositionImpactFactorPositive" | "maxPositionImpactFactorNegative" | "maxPositionImpactFactorForLiquidations" | "maxLendableImpactFactor" | "maxLendableImpactFactorForWithdrawals" | "maxLendableImpactUsd" | "lentPositionImpactPoolAmount" | "minCollateralFactor" | "minCollateralFactorForLiquidation" | "minCollateralFactorForOpenInterestLong" | "minCollateralFactorForOpenInterestShort" | "positionImpactExponentFactorPositive" | "positionImpactExponentFactorNegative" | "swapFeeFactorForBalanceWasImproved" | "swapFeeFactorForBalanceWasNotImproved" | "atomicSwapFeeFactor" | "swapImpactFactorPositive" | "swapImpactFactorNegative" | "swapImpactExponentFactor" | "withdrawalFeeFactorBalanceWasImproved" | "withdrawalFeeFactorBalanceWasNotImproved" | "virtualMarketId" | "virtualLongTokenId" | "virtualShortTokenId", {
38
- methodName: string;
39
- params: any[];
40
- }>;
41
- };
42
- }>>;
@@ -1,51 +0,0 @@
1
- import { MarketInfo, MarketsData, MarketsInfoData } from "../../types/markets";
2
- import { TokensData } from "../../types/tokens";
3
- import { MulticallRequestConfig } from "../../utils/multicall";
4
- export type MarketsResult = {
5
- marketsData?: MarketsData;
6
- marketsAddresses?: string[];
7
- error?: Error | undefined;
8
- };
9
- export type MarketsInfoResult = {
10
- marketsInfoData?: MarketsInfoData;
11
- tokensData?: TokensData;
12
- pricesUpdatedAt?: number;
13
- };
14
- /**
15
- * Updates frequently
16
- */
17
- export type MarketValues = Pick<MarketInfo, "longInterestUsd" | "shortInterestUsd" | "longInterestInTokens" | "shortInterestInTokens" | "longPoolAmount" | "shortPoolAmount" | "poolValueMin" | "poolValueMax" | "totalBorrowingFees" | "positionImpactPoolAmount" | "swapImpactPoolAmountLong" | "swapImpactPoolAmountShort" | "borrowingFactorPerSecondForLongs" | "borrowingFactorPerSecondForShorts" | "fundingFactorPerSecond" | "longsPayShorts" | "virtualPoolAmountForLongToken" | "virtualPoolAmountForShortToken" | "virtualInventoryForPositions">;
18
- /**
19
- * Updates seldom
20
- */
21
- export type MarketConfig = Pick<MarketInfo, "isDisabled" | "maxLongPoolUsdForDeposit" | "maxShortPoolUsdForDeposit" | "maxLongPoolAmount" | "maxShortPoolAmount" | "reserveFactorLong" | "reserveFactorShort" | "openInterestReserveFactorLong" | "openInterestReserveFactorShort" | "maxOpenInterestLong" | "maxOpenInterestShort" | "minPositionImpactPoolAmount" | "positionImpactPoolDistributionRate" | "borrowingFactorLong" | "borrowingFactorShort" | "borrowingExponentFactorLong" | "borrowingExponentFactorShort" | "fundingFactor" | "fundingExponentFactor" | "fundingIncreaseFactorPerSecond" | "fundingDecreaseFactorPerSecond" | "thresholdForDecreaseFunding" | "thresholdForStableFunding" | "minFundingFactorPerSecond" | "maxFundingFactorPerSecond" | "maxPnlFactorForTradersLong" | "maxPnlFactorForTradersShort" | "minCollateralFactor" | "minCollateralFactorForLiquidation" | "minCollateralFactorForOpenInterestLong" | "minCollateralFactorForOpenInterestShort" | "positionFeeFactorForBalanceWasImproved" | "positionFeeFactorForBalanceWasNotImproved" | "positionImpactFactorPositive" | "positionImpactFactorNegative" | "maxPositionImpactFactorPositive" | "maxPositionImpactFactorNegative" | "maxPositionImpactFactorForLiquidations" | "maxLendableImpactFactor" | "maxLendableImpactFactorForWithdrawals" | "maxLendableImpactUsd" | "lentPositionImpactPoolAmount" | "positionImpactExponentFactorPositive" | "positionImpactExponentFactorNegative" | "swapFeeFactorForBalanceWasImproved" | "swapFeeFactorForBalanceWasNotImproved" | "swapImpactFactorPositive" | "swapImpactFactorNegative" | "swapImpactExponentFactor" | "atomicSwapFeeFactor" | "withdrawalFeeFactorBalanceWasImproved" | "withdrawalFeeFactorBalanceWasNotImproved" | "virtualMarketId" | "virtualLongTokenId" | "virtualShortTokenId">;
22
- export type MarketValuesMulticallRequestConfig = MulticallRequestConfig<{
23
- [key: `${string}-reader`]: {
24
- calls: Record<"marketInfo" | "marketTokenPriceMax" | "marketTokenPriceMin", {
25
- methodName: string;
26
- params: any[];
27
- }>;
28
- };
29
- [key: `${string}-dataStore`]: {
30
- calls: Record<"longPoolAmount" | "shortPoolAmount" | "positionImpactPoolAmount" | "swapImpactPoolAmountLong" | "swapImpactPoolAmountShort" | "longInterestUsingLongToken" | "longInterestUsingShortToken" | "shortInterestUsingLongToken" | "shortInterestUsingShortToken" | "longInterestInTokensUsingLongToken" | "longInterestInTokensUsingShortToken" | "shortInterestInTokensUsingLongToken" | "shortInterestInTokensUsingShortToken", {
31
- methodName: string;
32
- params: any[];
33
- }>;
34
- };
35
- }>;
36
- export type MarketConfigMulticallRequestConfig = MulticallRequestConfig<{
37
- [key: `${string}-dataStore`]: {
38
- calls: Record<"isDisabled" | "maxLongPoolAmount" | "maxShortPoolAmount" | "maxLongPoolUsdForDeposit" | "maxShortPoolUsdForDeposit" | "reserveFactorLong" | "reserveFactorShort" | "openInterestReserveFactorLong" | "openInterestReserveFactorShort" | "maxOpenInterestLong" | "maxOpenInterestShort" | "minPositionImpactPoolAmount" | "positionImpactPoolDistributionRate" | "borrowingFactorLong" | "borrowingFactorShort" | "borrowingExponentFactorLong" | "borrowingExponentFactorShort" | "fundingFactor" | "fundingExponentFactor" | "fundingIncreaseFactorPerSecond" | "fundingDecreaseFactorPerSecond" | "thresholdForStableFunding" | "thresholdForDecreaseFunding" | "minFundingFactorPerSecond" | "maxFundingFactorPerSecond" | "maxPnlFactorForTradersLong" | "maxPnlFactorForTradersShort" | "positionFeeFactorForBalanceWasImproved" | "positionFeeFactorForBalanceWasNotImproved" | "positionImpactFactorPositive" | "positionImpactFactorNegative" | "maxPositionImpactFactorPositive" | "maxPositionImpactFactorNegative" | "maxPositionImpactFactorForLiquidations" | "maxLendableImpactFactor" | "maxLendableImpactFactorForWithdrawals" | "maxLendableImpactUsd" | "lentPositionImpactPoolAmount" | "minCollateralFactor" | "minCollateralFactorForLiquidation" | "minCollateralFactorForOpenInterestLong" | "minCollateralFactorForOpenInterestShort" | "positionImpactExponentFactorPositive" | "positionImpactExponentFactorNegative" | "swapFeeFactorForBalanceWasImproved" | "swapFeeFactorForBalanceWasNotImproved" | "atomicSwapFeeFactor" | "swapImpactFactorPositive" | "swapImpactFactorNegative" | "swapImpactExponentFactor" | "withdrawalFeeFactorBalanceWasImproved" | "withdrawalFeeFactorBalanceWasNotImproved" | "virtualMarketId" | "virtualLongTokenId" | "virtualShortTokenId", {
39
- methodName: string;
40
- params: any[];
41
- }>;
42
- };
43
- }>;
44
- export type KinkModelMarketRateMulticallRequestConfig = MulticallRequestConfig<{
45
- [key: `${string}-dataStore`]: {
46
- calls: Record<"optimalUsageFactorLong" | "optimalUsageFactorShort" | "baseBorrowingFactorLong" | "baseBorrowingFactorShort" | "aboveOptimalUsageBorrowingFactorLong" | "aboveOptimalUsageBorrowingFactorShort", {
47
- methodName: string;
48
- params: any[];
49
- }>;
50
- };
51
- }>;