@merkl/api 0.10.129 → 0.10.131

Sign up to get free protection for your applications and to get access to all the features.
Files changed (361) hide show
  1. package/dist/database/api/.generated/default.js +1 -0
  2. package/dist/database/api/.generated/edge.js +609 -0
  3. package/dist/database/api/.generated/index-browser.js +586 -0
  4. package/dist/database/api/.generated/index.js +638 -0
  5. package/dist/database/api/.generated/runtime/edge-esm.js +31 -0
  6. package/dist/database/api/.generated/runtime/edge.js +31 -0
  7. package/dist/database/api/.generated/runtime/index-browser.js +13 -0
  8. package/dist/database/api/.generated/runtime/library.js +143 -0
  9. package/dist/database/api/.generated/runtime/react-native.js +80 -0
  10. package/dist/database/api/.generated/runtime/wasm.js +32 -0
  11. package/dist/database/api/.generated/wasm.js +586 -0
  12. package/dist/database/api/seeder/resources/protocol.js +341 -0
  13. package/dist/database/engine/.generated/default.js +1 -0
  14. package/dist/database/engine/.generated/edge.js +438 -0
  15. package/dist/database/engine/.generated/index-browser.js +415 -0
  16. package/dist/database/engine/.generated/index.js +467 -0
  17. package/dist/database/engine/.generated/runtime/edge-esm.js +31 -0
  18. package/dist/database/engine/.generated/runtime/edge.js +31 -0
  19. package/dist/database/engine/.generated/runtime/index-browser.js +13 -0
  20. package/dist/database/engine/.generated/runtime/library.js +143 -0
  21. package/dist/database/engine/.generated/runtime/react-native.js +80 -0
  22. package/dist/database/engine/.generated/runtime/wasm.js +32 -0
  23. package/dist/database/engine/.generated/wasm.js +415 -0
  24. package/dist/src/backgroundJobs/index.js +44 -0
  25. package/dist/src/backgroundJobs/jobs/campaignsCacheUpdater.js +160 -0
  26. package/dist/src/backgroundJobs/jobs/health.js +15 -0
  27. package/dist/src/backgroundJobs/jobs/opportunityUpdater.js +63 -0
  28. package/dist/src/backgroundJobs/jobs/priceUpdater.js +16 -0
  29. package/dist/src/backgroundJobs/jobs/sync.js +33 -0
  30. package/dist/src/cache/declaration.js +146 -0
  31. package/dist/src/cache/index.js +152 -0
  32. package/dist/src/cache/redis.js +49 -0
  33. package/dist/src/constants.js +119 -0
  34. package/dist/src/entities/campaign.js +134 -0
  35. package/dist/src/entities/opportunity.js +549 -0
  36. package/dist/src/errors/BadRequest.error.js +7 -0
  37. package/dist/src/errors/Conflict.error.js +7 -0
  38. package/dist/src/errors/HttpError.js +11 -0
  39. package/dist/src/errors/NotFound.error.js +7 -0
  40. package/dist/src/errors/Opportunity.error.js +11 -0
  41. package/dist/src/errors/Unauthorized.error.js +7 -0
  42. package/dist/src/errors/index.js +5 -0
  43. package/dist/src/guards/BackOffice.guard.js +10 -0
  44. package/dist/src/guards/Engine.guard.js +10 -0
  45. package/dist/src/guards/TokenAuth.guard.js +10 -0
  46. package/dist/src/hooks/checkQueryAddressValidity.js +7 -0
  47. package/dist/src/hooks/checkQueryChainIdValidity.js +7 -0
  48. package/dist/src/index.js +79 -0
  49. package/dist/src/internal/controllers/endingCampaigns.js +41 -0
  50. package/dist/src/internal/controllers/unclaimed.js +36 -0
  51. package/dist/src/internal/index.js +30 -0
  52. package/dist/src/libs/campaigns/campaignTypes/AjnaDynamicData.js +111 -0
  53. package/dist/src/libs/campaigns/campaignTypes/BadgerDynamicData.js +93 -0
  54. package/dist/src/libs/campaigns/campaignTypes/CLAMMDynamicData.js +942 -0
  55. package/dist/src/libs/campaigns/campaignTypes/CompoundDynamicData.js +90 -0
  56. package/dist/src/libs/campaigns/campaignTypes/DolomiteDynamicData.js +60 -0
  57. package/dist/src/libs/campaigns/campaignTypes/ERC20DynamicData.js +162 -0
  58. package/dist/src/libs/campaigns/campaignTypes/ERC20DynamicDataRefacto.js +159 -0
  59. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/eulerVaultNames.js +13 -0
  60. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/factoryFinder.js +29 -0
  61. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/getBlacklistedSupply.js +22 -0
  62. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/metamorphoTvl.js +35 -0
  63. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/spliceTVL.js +21 -0
  64. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/tokenType.js +106 -0
  65. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/AaveProcessor.js +26 -0
  66. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/AssetProcessor.js +47 -0
  67. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/AuraProcessor.js +103 -0
  68. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/BalancerGaugeProcessor.js +83 -0
  69. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/BalancerPoolProcessor.js +99 -0
  70. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/BeefyProcessor.js +51 -0
  71. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/CompoundProcessor.js +36 -0
  72. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/EnzymeProcessor.js +51 -0
  73. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/EulerBorrowProcessor.js +46 -0
  74. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/EulerLendProcessor.js +47 -0
  75. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/FluidProcessor.js +36 -0
  76. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/FraxProcessor.js +41 -0
  77. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/GearboxProcessor.js +44 -0
  78. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/GenericProcessor.js +239 -0
  79. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/MetamorphoProcessor.js +43 -0
  80. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/PendleProcessor.js +31 -0
  81. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/RadiantProcessor.js +58 -0
  82. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/RfxProcessor.js +64 -0
  83. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/SpliceProcessor.js +35 -0
  84. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/SturdySiloProcessor.js +37 -0
  85. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/TemplateProcessor.js +40 -0
  86. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/TorosProcessor.js +33 -0
  87. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/UniswapProcessor.js +48 -0
  88. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/WoofiProcessor.js +40 -0
  89. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/curveProcessor.js +68 -0
  90. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/processorMapping.js +77 -0
  91. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesPrices.js +583 -0
  92. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesPricesRefactoFinal.js +24 -0
  93. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound1.js +1209 -0
  94. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound1RefactoFinal.js +194 -0
  95. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound2.js +645 -0
  96. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound2RefactoFinal.js +22 -0
  97. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound3.js +392 -0
  98. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound3RefactoFinal.js +22 -0
  99. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound4.js +323 -0
  100. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound4RefactoFinal.js +22 -0
  101. package/dist/src/libs/campaigns/campaignTypes/ERC20_SNAPSHOTDynamicData.js +38 -0
  102. package/dist/src/libs/campaigns/campaignTypes/EulerDynamicData.js +165 -0
  103. package/dist/src/libs/campaigns/campaignTypes/JSON_AIRDROPDynamicData.js +19 -0
  104. package/dist/src/libs/campaigns/campaignTypes/MORPHODynamicData.js +120 -0
  105. package/dist/src/libs/campaigns/campaignTypes/RadiantDynamicData.js +112 -0
  106. package/dist/src/libs/campaigns/campaignTypes/SILODynamicData.js +113 -0
  107. package/dist/src/libs/campaigns/campaignsDynamicData.js +83 -0
  108. package/dist/src/libs/campaigns/campaignsDynamicDataRefacto.js +78 -0
  109. package/dist/src/libs/campaigns/getCampaigns.js +18 -0
  110. package/dist/src/libs/campaigns/utils/fetchA51Strategies.js +44 -0
  111. package/dist/src/libs/campaigns/utils/fetchClamInfo.js +27 -0
  112. package/dist/src/libs/campaigns/utils/fetchLogs.js +91 -0
  113. package/dist/src/libs/campaigns/utils/getCompV2ForksVaults.js +122 -0
  114. package/dist/src/libs/campaigns/utils/getContractCreationBlock.js +44 -0
  115. package/dist/src/libs/campaigns/utils/getDolomiteMarkets.js +50 -0
  116. package/dist/src/libs/campaigns/utils/getEulerV2Vaults.js +87 -0
  117. package/dist/src/libs/campaigns/utils/getLastEligibilityRatio.js +56 -0
  118. package/dist/src/libs/computeFee.js +34 -0
  119. package/dist/src/libs/custom/twtParticipants.js +54 -0
  120. package/dist/src/libs/deprecated-merklv3/index.js +184 -0
  121. package/dist/src/libs/getTokensList.js +37 -0
  122. package/dist/src/libs/merklChainData.js +129 -0
  123. package/dist/src/libs/parse/marketsWithCache.js +8 -0
  124. package/dist/src/libs/positions/ajna/index.js +107 -0
  125. package/dist/src/libs/positions/badger/index.js +79 -0
  126. package/dist/src/libs/positions/clamm/index.js +419 -0
  127. package/dist/src/libs/positions/clamm/thegraph/fetchAlmPositions.js +35 -0
  128. package/dist/src/libs/positions/clamm/thegraph/fetchAmmPositions.js +35 -0
  129. package/dist/src/libs/positions/clamm/thegraph/fetchFarmedPositions.js +44 -0
  130. package/dist/src/libs/positions/clamm/thegraph/index.js +162 -0
  131. package/dist/src/libs/positions/compound/index.js +93 -0
  132. package/dist/src/libs/positions/dolomite/index.js +49 -0
  133. package/dist/src/libs/positions/erc20/index.js +55 -0
  134. package/dist/src/libs/positions/euler/index.js +57 -0
  135. package/dist/src/libs/positions/index.js +48 -0
  136. package/dist/src/libs/positions/morpho/index.js +177 -0
  137. package/dist/src/libs/positions/prepareFetch.js +339 -0
  138. package/dist/src/libs/positions/silo/index.js +67 -0
  139. package/dist/src/libs/positions/types.js +1 -0
  140. package/dist/src/libs/reports/campaignReport.js +37 -0
  141. package/dist/src/libs/reports/mainParameterRewards.js +48 -0
  142. package/dist/src/libs/rewards/userRewards.js +154 -0
  143. package/dist/src/libs/staticCampaigns.js +10 -0
  144. package/dist/src/libs/tokens/balances.js +126 -0
  145. package/dist/src/libs/tokens/tokenInfo.js +22 -0
  146. package/dist/src/modules/v4/accounting/accounting.controller.js +66 -0
  147. package/dist/src/modules/v4/accounting/accounting.model.js +32 -0
  148. package/dist/src/modules/v4/accounting/accounting.repository.js +100 -0
  149. package/dist/src/modules/v4/accounting/accounting.service.js +78 -0
  150. package/dist/src/modules/v4/accounting/index.js +3 -0
  151. package/dist/src/modules/v4/apr/apr.controller.js +1 -0
  152. package/dist/src/modules/v4/apr/apr.model.js +1 -0
  153. package/dist/src/modules/v4/apr/apr.repository.js +1 -0
  154. package/dist/src/modules/v4/apr/apr.service.js +40 -0
  155. package/dist/src/modules/v4/apr/index.js +2 -0
  156. package/dist/src/modules/v4/blacklist/blacklist.controller.js +45 -0
  157. package/dist/src/modules/v4/blacklist/blacklist.model.js +13 -0
  158. package/dist/src/modules/v4/blacklist/blacklist.repository.js +56 -0
  159. package/dist/src/modules/v4/blacklist/blacklist.service.js +24 -0
  160. package/dist/src/modules/v4/blacklist/index.js +3 -0
  161. package/dist/src/modules/v4/cache/cache.model.js +14 -0
  162. package/dist/src/modules/v4/cache/cache.repository.js +10 -0
  163. package/dist/src/modules/v4/cache/cache.service.js +44 -0
  164. package/dist/src/modules/v4/cache/index.js +1 -0
  165. package/dist/src/modules/v4/campaign/campaign.controller.js +56 -0
  166. package/dist/src/modules/v4/campaign/campaign.model.js +54 -0
  167. package/dist/src/modules/v4/campaign/campaign.repository.js +346 -0
  168. package/dist/src/modules/v4/campaign/campaign.service.js +203 -0
  169. package/dist/src/modules/v4/campaign/index.js +3 -0
  170. package/dist/src/modules/v4/chain/chain.controller.js +40 -0
  171. package/dist/src/modules/v4/chain/chain.model.js +17 -0
  172. package/dist/src/modules/v4/chain/chain.repository.js +64 -0
  173. package/dist/src/modules/v4/chain/chain.service.js +42 -0
  174. package/dist/src/modules/v4/chain/index.js +3 -0
  175. package/dist/src/modules/v4/dynamicData/dynamicData.controller.js +19 -0
  176. package/dist/src/modules/v4/dynamicData/dynamicData.model.js +6 -0
  177. package/dist/src/modules/v4/dynamicData/dynamicData.repository.js +1 -0
  178. package/dist/src/modules/v4/dynamicData/dynamicData.service.js +49 -0
  179. package/dist/src/modules/v4/dynamicData/index.js +3 -0
  180. package/dist/src/modules/v4/enso/enso.model.js +108 -0
  181. package/dist/src/modules/v4/enso/enso.service.js +46 -0
  182. package/dist/src/modules/v4/explorer/explorer.model.js +2 -0
  183. package/dist/src/modules/v4/explorer/explorer.repository.js +23 -0
  184. package/dist/src/modules/v4/explorer/explorer.service.js +24 -0
  185. package/dist/src/modules/v4/explorer/index.js +1 -0
  186. package/dist/src/modules/v4/index.js +4 -0
  187. package/dist/src/modules/v4/merklRoot/index.js +3 -0
  188. package/dist/src/modules/v4/merklRoot/merklRoot.controller.js +19 -0
  189. package/dist/src/modules/v4/merklRoot/merklRoot.model.js +6 -0
  190. package/dist/src/modules/v4/merklRoot/merklRoot.repository.js +31 -0
  191. package/dist/src/modules/v4/merklRoot/merklRoot.service.js +38 -0
  192. package/dist/src/modules/v4/opportunity/index.js +3 -0
  193. package/dist/src/modules/v4/opportunity/opportunity.controller.js +69 -0
  194. package/dist/src/modules/v4/opportunity/opportunity.model.js +36 -0
  195. package/dist/src/modules/v4/opportunity/opportunity.repository.d.ts +14 -0
  196. package/dist/src/modules/v4/opportunity/opportunity.repository.js +217 -0
  197. package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +0 -15
  198. package/dist/src/modules/v4/opportunity/opportunity.service.js +180 -0
  199. package/dist/src/modules/v4/opportunity/subservices/getAjnaMetadata.service.js +50 -0
  200. package/dist/src/modules/v4/opportunity/subservices/getBadgerMetadata.service.js +23 -0
  201. package/dist/src/modules/v4/opportunity/subservices/getClammMetadata.service.js +33 -0
  202. package/dist/src/modules/v4/opportunity/subservices/getCompoundMetadata.service.js +18 -0
  203. package/dist/src/modules/v4/opportunity/subservices/getDolomiteMetadata.service.js +15 -0
  204. package/dist/src/modules/v4/opportunity/subservices/getErc20Metadata.service.js +63 -0
  205. package/dist/src/modules/v4/opportunity/subservices/getErc20SnapshotMetadata.service.js +8 -0
  206. package/dist/src/modules/v4/opportunity/subservices/getEulerMetadata.service.js +30 -0
  207. package/dist/src/modules/v4/opportunity/subservices/getJsonAirDropMetadata.service.js +36 -0
  208. package/dist/src/modules/v4/opportunity/subservices/getMorphoMetadata.service.js +19 -0
  209. package/dist/src/modules/v4/opportunity/subservices/getRadiantMetadata.service.js +9 -0
  210. package/dist/src/modules/v4/opportunity/subservices/getSiloMetadata.service.js +13 -0
  211. package/dist/src/modules/v4/opportunity/transform-id.pipe.js +6 -0
  212. package/dist/src/modules/v4/opportunity/validate-id.pipe.js +12 -0
  213. package/dist/src/modules/v4/participate/participate.controller.js +66 -0
  214. package/dist/src/modules/v4/participate/participate.model.js +24 -0
  215. package/dist/src/modules/v4/participate/participate.service.js +33 -0
  216. package/dist/src/modules/v4/price/index.js +3 -0
  217. package/dist/src/modules/v4/price/price.controller.js +62 -0
  218. package/dist/src/modules/v4/price/price.model.js +12 -0
  219. package/dist/src/modules/v4/price/price.repository.js +18 -0
  220. package/dist/src/modules/v4/price/price.service.js +44 -0
  221. package/dist/src/modules/v4/prisma/index.js +1 -0
  222. package/dist/src/modules/v4/protocol/index.js +3 -0
  223. package/dist/src/modules/v4/protocol/protocol.controller.js +23 -0
  224. package/dist/src/modules/v4/protocol/protocol.model.js +68 -0
  225. package/dist/src/modules/v4/protocol/protocol.repository.js +37 -0
  226. package/dist/src/modules/v4/protocol/protocol.service.js +77 -0
  227. package/dist/src/modules/v4/reward/index.js +3 -0
  228. package/dist/src/modules/v4/reward/reward.controller.js +52 -0
  229. package/dist/src/modules/v4/reward/reward.model.js +104 -0
  230. package/dist/src/modules/v4/reward/reward.repository.js +237 -0
  231. package/dist/src/modules/v4/reward/reward.service.js +283 -0
  232. package/dist/src/modules/v4/reward/rewardConvertor.service.js +136 -0
  233. package/dist/src/modules/v4/router.js +57 -0
  234. package/dist/src/modules/v4/status/index.js +3 -0
  235. package/dist/src/modules/v4/status/status.controller.js +48 -0
  236. package/dist/src/modules/v4/status/status.model.js +24 -0
  237. package/dist/src/modules/v4/status/status.repository.js +88 -0
  238. package/dist/src/modules/v4/status/status.service.js +60 -0
  239. package/dist/src/modules/v4/token/index.js +3 -0
  240. package/dist/src/modules/v4/token/token.controller.js +32 -0
  241. package/dist/src/modules/v4/token/token.model.js +23 -0
  242. package/dist/src/modules/v4/token/token.repository.js +128 -0
  243. package/dist/src/modules/v4/token/token.service.js +268 -0
  244. package/dist/src/modules/v4/tvl/index.js +2 -0
  245. package/dist/src/modules/v4/tvl/tvl.controller.js +1 -0
  246. package/dist/src/modules/v4/tvl/tvl.model.js +1 -0
  247. package/dist/src/modules/v4/tvl/tvl.repository.js +1 -0
  248. package/dist/src/modules/v4/tvl/tvl.service.js +49 -0
  249. package/dist/src/modules/v4/uniswapV4/index.js +4 -0
  250. package/dist/src/modules/v4/uniswapV4/uniswapV4.controller.js +11 -0
  251. package/dist/src/modules/v4/uniswapV4/uniswapV4.model.js +17 -0
  252. package/dist/src/modules/v4/uniswapV4/uniswapV4.repository.js +2 -0
  253. package/dist/src/modules/v4/uniswapV4/uniswapV4.service.js +73 -0
  254. package/dist/src/modules/v4/user/index.js +3 -0
  255. package/dist/src/modules/v4/user/user.controller.js +69 -0
  256. package/dist/src/modules/v4/user/user.model.js +18 -0
  257. package/dist/src/modules/v4/user/user.repository.js +38 -0
  258. package/dist/src/modules/v4/user/user.service.js +50 -0
  259. package/dist/src/plugins/error-handling.plugin.js +28 -0
  260. package/dist/src/plugins/logger.plugin.js +22 -0
  261. package/dist/src/routes/v1/allowances.js +115 -0
  262. package/dist/src/routes/v1/balances.js +25 -0
  263. package/dist/src/routes/v1/prices.js +11 -0
  264. package/dist/src/routes/v1/tokens.js +17 -0
  265. package/dist/src/routes/v2/merkl.js +13 -0
  266. package/dist/src/routes/v3/ERC20Campaigns.js +63 -0
  267. package/dist/src/routes/v3/app.js +18 -0
  268. package/dist/src/routes/v3/blacklist.js +18 -0
  269. package/dist/src/routes/v3/campaign/delay.js +78 -0
  270. package/dist/src/routes/v3/campaignClaims.js +24 -0
  271. package/dist/src/routes/v3/campaignReport.js +22 -0
  272. package/dist/src/routes/v3/campaignUnclaimed.js +28 -0
  273. package/dist/src/routes/v3/campaigns.js +101 -0
  274. package/dist/src/routes/v3/campaignsForMainParameter.js +19 -0
  275. package/dist/src/routes/v3/campaignsInfo.js +54 -0
  276. package/dist/src/routes/v3/campaignsRewardsReport.js +47 -0
  277. package/dist/src/routes/v3/claims.js +45 -0
  278. package/dist/src/routes/v3/compoundV2.js +9 -0
  279. package/dist/src/routes/v3/createCampaign.js +66 -0
  280. package/dist/src/routes/v3/dolomite.js +9 -0
  281. package/dist/src/routes/v3/euler.js +9 -0
  282. package/dist/src/routes/v3/exports/campaigns.js +28 -0
  283. package/dist/src/routes/v3/fetch.js +27 -0
  284. package/dist/src/routes/v3/health.js +13 -0
  285. package/dist/src/routes/v3/lostyield.js +98 -0
  286. package/dist/src/routes/v3/merkl.js +119 -0
  287. package/dist/src/routes/v3/morphoMarkets.js +27 -0
  288. package/dist/src/routes/v3/morphoVaults.js +22 -0
  289. package/dist/src/routes/v3/multiChainPositions.js +69 -0
  290. package/dist/src/routes/v3/opportunity.js +63 -0
  291. package/dist/src/routes/v3/overview.js +73 -0
  292. package/dist/src/routes/v3/parse.js +23 -0
  293. package/dist/src/routes/v3/payload.js +40 -0
  294. package/dist/src/routes/v3/poolInfo.js +88 -0
  295. package/dist/src/routes/v3/positions.js +62 -0
  296. package/dist/src/routes/v3/radiant.js +26 -0
  297. package/dist/src/routes/v3/recipients.js +20 -0
  298. package/dist/src/routes/v3/rewards.js +33 -0
  299. package/dist/src/routes/v3/rewardsReport.js +51 -0
  300. package/dist/src/routes/v3/rootForTimestamp.js +47 -0
  301. package/dist/src/routes/v3/silo.js +20 -0
  302. package/dist/src/routes/v3/token.js +24 -0
  303. package/dist/src/routes/v3/tokenUnclaimed.js +24 -0
  304. package/dist/src/routes/v3/twt/participants.js +11 -0
  305. package/dist/src/routes/v3/updates.js +47 -0
  306. package/dist/src/routes/v3/userRewards.js +59 -0
  307. package/dist/src/types/index.js +6 -0
  308. package/dist/src/types/parameters/Action.js +11 -0
  309. package/dist/src/types/parameters/Chain.js +13 -0
  310. package/dist/src/types/parameters/ChainCampaignId.js +13 -0
  311. package/dist/src/types/parameters/MainParameter.js +19 -0
  312. package/dist/src/types/parameters/OpportunityId.js +14 -0
  313. package/dist/src/types/parameters/Timestamp.js +16 -0
  314. package/dist/src/types/parameters/Type.js +15 -0
  315. package/dist/src/types/parameters/index.js +17 -0
  316. package/dist/src/types/returnTypes.js +1 -0
  317. package/dist/src/types/utils.js +1 -0
  318. package/dist/src/utils/addString.js +6 -0
  319. package/dist/src/utils/bigintToString.js +20 -0
  320. package/dist/src/utils/crypto.js +4 -0
  321. package/dist/src/utils/decodeCalls.js +170 -0
  322. package/dist/src/utils/encodeCalls.js +240 -0
  323. package/dist/src/utils/error.js +90 -0
  324. package/dist/src/utils/execute.js +41 -0
  325. package/dist/src/utils/generateCardName.js +89 -0
  326. package/dist/src/utils/generic.js +117 -0
  327. package/dist/src/utils/hashArray.js +4 -0
  328. package/dist/src/utils/lastBlockBefore.js +78 -0
  329. package/dist/src/utils/logger.js +52 -0
  330. package/dist/src/utils/pricer.js +180 -0
  331. package/dist/src/utils/prices/chainlinkRead.js +8 -0
  332. package/dist/src/utils/prices/curveVirtualPrice.js +7 -0
  333. package/dist/src/utils/prices/getDQUICK.js +8 -0
  334. package/dist/src/utils/prices/priceFetcherFactory.js +29 -0
  335. package/dist/src/utils/prices/priceService.js +328 -0
  336. package/dist/src/utils/prices/services/coinGeckoService.js +53 -0
  337. package/dist/src/utils/prices/services/defillamaService.js +53 -0
  338. package/dist/src/utils/prices/services/dexScreenerService.js +62 -0
  339. package/dist/src/utils/prices/services/erc4626Service.js +30 -0
  340. package/dist/src/utils/prices/services/getERC4626.js +11 -0
  341. package/dist/src/utils/prices/services/indexCoopService.js +55 -0
  342. package/dist/src/utils/prices/services/priceFetcher.js +1 -0
  343. package/dist/src/utils/prices/uniV2Price.js +40 -0
  344. package/dist/src/utils/prisma.js +12 -0
  345. package/dist/src/utils/providers.js +30 -0
  346. package/dist/src/utils/queries/activeCampaigns.js +22 -0
  347. package/dist/src/utils/queries/allCampaigns.js +51 -0
  348. package/dist/src/utils/queries/campaignsForMainParameter.js +23 -0
  349. package/dist/src/utils/queries/claimsOverTime.js +111 -0
  350. package/dist/src/utils/queries/endingCampaigns.js +21 -0
  351. package/dist/src/utils/queries/futureCampaigns.js +19 -0
  352. package/dist/src/utils/queries/mainParameterCampaigns.js +11 -0
  353. package/dist/src/utils/queries/rewardsAmount.js +106 -0
  354. package/dist/src/utils/queries/unclaimed.js +81 -0
  355. package/dist/src/utils/rateLimit.js +13 -0
  356. package/dist/src/utils/stryke.js +4 -0
  357. package/dist/src/utils/throw.js +27 -0
  358. package/dist/src/utils/validation.js +20 -0
  359. package/dist/tsconfig.package.tsbuildinfo +1 -1
  360. package/package.json +2 -2
  361. package/dist/package.json +0 -91
@@ -0,0 +1,63 @@
1
+ import { Redis } from "../../cache";
2
+ import { ANGLE_NETWORKS } from "@sdk";
3
+ import { extractIds, getCampaignsFor, splitCampaigns } from "../../entities/campaign";
4
+ import { extractOpportunities } from "../../entities/opportunity";
5
+ import { log } from "../../utils/logger";
6
+ import { Pricer } from "../../utils/pricer";
7
+ export const OPPORTUNITY_CACHE = "Opportunities_All";
8
+ export const OPPORTUNITY_CACHE_TEST = "Opportunities_Test";
9
+ const reduceOpportunities = async (showTest = false) => {
10
+ const campaigns = await getCampaignsFor(ANGLE_NETWORKS.merkl.map(c => c));
11
+ const pricer = await Pricer.load();
12
+ const opportunityIds = extractIds(campaigns);
13
+ const opportunityCampaigns = splitCampaigns(campaigns, opportunityIds, showTest);
14
+ const opportunities = {};
15
+ for (const { id, ...opportunity } of opportunityCampaigns) {
16
+ const [_, type, mainParameter] = id.split("_");
17
+ if (!extractOpportunities[type])
18
+ continue;
19
+ const { campaigns: oppCampaigns, ...extracted } = extractOpportunities[type](opportunity?.all?.[0], {
20
+ all: opportunity?.all ?? [],
21
+ active: opportunity.active ?? [],
22
+ inactive: opportunity.inactive ?? [],
23
+ }, pricer?.prices);
24
+ opportunities[`${type}_${mainParameter}`] = {
25
+ ...extracted,
26
+ campaigns: {
27
+ type: Number.parseInt(type),
28
+ ids: opportunity?.all?.map(({ campaignId }) => campaignId).filter(c => c),
29
+ },
30
+ };
31
+ }
32
+ return opportunities;
33
+ };
34
+ const getUpdateBreakdown = (opportunities) => {
35
+ const total = Object.keys(opportunities)?.length;
36
+ const totalByChain = Object.entries(opportunities).reduce((prev, [_, { chainId }]) => {
37
+ prev[chainId] += 1;
38
+ return prev;
39
+ }, ANGLE_NETWORKS.merkl.reduce((allChains, chain) => Object.assign(allChains, { [chain]: 0 }), {}));
40
+ const breakdown = Object.entries(totalByChain).reduce((prev, [chain, count]) => {
41
+ if (count === 0)
42
+ return prev;
43
+ prev[chain] = count;
44
+ return prev;
45
+ }, {});
46
+ return { total, breakdown };
47
+ };
48
+ export const opportunityUpdater = (app) => {
49
+ return app.get("/v3/updateOpportunities", async () => {
50
+ const opportunities = await reduceOpportunities(false);
51
+ const opportunitiesWithTest = await reduceOpportunities(true);
52
+ await Redis.safeSet("Opportunities", opportunities);
53
+ await Redis.safeSet("OpportunitiesWithTest", opportunitiesWithTest);
54
+ log.info("✅ opportunity cache updated successfully");
55
+ return new Response(JSON.stringify({
56
+ status: "success",
57
+ all: getUpdateBreakdown(opportunities),
58
+ test: getUpdateBreakdown(opportunitiesWithTest),
59
+ }), {
60
+ status: 200,
61
+ });
62
+ });
63
+ };
@@ -0,0 +1,16 @@
1
+ import { TokenService } from "../../modules/v4";
2
+ import { log } from "../../utils/logger";
3
+ import { Pricer } from "../../utils/pricer";
4
+ export const priceUpdater = (app) => {
5
+ return app.get("/v3/updatePrices", async () => {
6
+ const pricer = await Pricer.load();
7
+ await pricer.update();
8
+ log.info("✅ price cache updated successfully");
9
+ await TokenService.updatePrices(pricer);
10
+ return new Response(JSON.stringify({
11
+ status: "success",
12
+ }), {
13
+ status: 200,
14
+ });
15
+ });
16
+ };
@@ -0,0 +1,33 @@
1
+ import { AuthorizationHeadersDto, EngineGuard } from "../../guards/Engine.guard";
2
+ import { CampaignService } from "../../modules/v4/campaign";
3
+ import { ChainService } from "../../modules/v4/chain";
4
+ import { log } from "../../utils/logger";
5
+ import Elysia from "elysia";
6
+ export const sync = new Elysia({ prefix: "/jobs" }).get("/api/sync-with-engine", async () => {
7
+ const chains = await ChainService.getMany({});
8
+ for (const chain of chains) {
9
+ log.info(`fetching campaigns on ${chain.name} (chainId: ${chain.id})`);
10
+ const campaignsV3 = await CampaignService.getFromEngineDb(chain.id, 0);
11
+ const campaigns = campaignsV3.map(campaignV3 => {
12
+ return {
13
+ amount: campaignV3.amount,
14
+ campaignId: campaignV3.campaignId,
15
+ chainId: campaignV3.chainId,
16
+ computeChainId: campaignV3.computeChainId,
17
+ creator: campaignV3.creator,
18
+ endTimestamp: campaignV3.endTimestamp.toString(),
19
+ opportunityIdentifier: campaignV3.mainParameter,
20
+ params: JSON.stringify(campaignV3.campaignParameters),
21
+ rewardTokenAddress: campaignV3.rewardToken,
22
+ startTimestamp: campaignV3.startTimestamp.toString(),
23
+ type: campaignV3.campaignType,
24
+ subType: campaignV3.campaignSubType,
25
+ };
26
+ });
27
+ log.info(`syncing ${campaigns.length} campaigns to sync on ${chain.name}...`);
28
+ const { success, fail } = await CampaignService.createMany(campaigns);
29
+ log.info(`${success} campaigns synced successfully on ${chain.name}`);
30
+ log.info(`${fail} campaigns failed to sync on ${chain.name}`);
31
+ }
32
+ return;
33
+ }, { headers: AuthorizationHeadersDto, beforeHandle: EngineGuard });
@@ -0,0 +1,146 @@
1
+ import { TTLType } from "./redis";
2
+ export const CacheDeclaration = {
3
+ Updates: { compressed: false, redisTTL: TTLType.Minutes2, localCache: false },
4
+ Delays: { compressed: false, redisTTL: TTLType.Minutes2, localCache: false },
5
+ TwtParticipants: { compressed: false, redisTTL: TTLType.Minutes5, localCache: false },
6
+ CampaignRewards: {
7
+ compressed: true,
8
+ redisTTL: TTLType.Hours12,
9
+ localCache: false,
10
+ },
11
+ RewardsMainParameter: {
12
+ compressed: true,
13
+ redisTTL: TTLType.Hours12,
14
+ localCache: false,
15
+ },
16
+ RewardsMainParameterDelta: {
17
+ compressed: true,
18
+ redisTTL: TTLType.Hours12,
19
+ localCache: false,
20
+ },
21
+ CampaignRewardsDelta: {
22
+ compressed: true,
23
+ redisTTL: TTLType.Hours12,
24
+ localCache: false,
25
+ },
26
+ LastBlockBefore: {
27
+ compressed: false,
28
+ redisTTL: TTLType.Hours12,
29
+ localCache: false,
30
+ },
31
+ LostYield: {
32
+ compressed: false,
33
+ redisTTL: TTLType.Hours3,
34
+ localCache: false,
35
+ },
36
+ DolomiteMarkets: {
37
+ compressed: false,
38
+ redisTTL: TTLType.Minutes30,
39
+ localCache: false,
40
+ },
41
+ EulerV2Vaults: {
42
+ compressed: false,
43
+ redisTTL: TTLType.Minutes30,
44
+ localCache: false,
45
+ },
46
+ CompoundV2ForksVaults: {
47
+ compressed: false,
48
+ redisTTL: TTLType.Week,
49
+ localCache: false,
50
+ },
51
+ RadiantMarkets: {
52
+ compressed: false,
53
+ redisTTL: TTLType.Minutes30,
54
+ localCache: false,
55
+ },
56
+ SiloMarkets: {
57
+ compressed: false,
58
+ redisTTL: TTLType.Minutes30,
59
+ localCache: false,
60
+ },
61
+ MorphoMarkets: {
62
+ compressed: false,
63
+ redisTTL: TTLType.Minutes30,
64
+ localCache: false,
65
+ },
66
+ FarmedPositions: {
67
+ compressed: false,
68
+ redisTTL: TTLType.Minutes2,
69
+ localCache: false,
70
+ },
71
+ JsonByTimestamp: {
72
+ compressed: false,
73
+ redisTTL: TTLType.Minutes10,
74
+ localCache: false,
75
+ },
76
+ Prices: {
77
+ compressed: true,
78
+ redisTTL: TTLType.Minutes30,
79
+ localCache: false,
80
+ },
81
+ MerklChainData: {
82
+ compressed: false,
83
+ redisTTL: TTLType.Hours12,
84
+ localCache: false,
85
+ },
86
+ Opportunities: {
87
+ compressed: true,
88
+ redisTTL: TTLType.Hours12,
89
+ localCache: false,
90
+ },
91
+ OpportunitiesWithTest: {
92
+ compressed: true,
93
+ redisTTL: TTLType.Hours12,
94
+ localCache: false,
95
+ },
96
+ Campaigns: {
97
+ compressed: true,
98
+ redisTTL: TTLType.Hours12,
99
+ localCache: false,
100
+ },
101
+ LiveCampaigns: {
102
+ compressed: true,
103
+ redisTTL: TTLType.Hours12,
104
+ localCache: false,
105
+ },
106
+ CampaignsOldFormat: {
107
+ compressed: true,
108
+ redisTTL: TTLType.Hours12,
109
+ localCache: false,
110
+ },
111
+ LiveCampaignsOldFormat: {
112
+ compressed: true,
113
+ redisTTL: TTLType.Hours12,
114
+ localCache: false,
115
+ },
116
+ StaticCampaigns: {
117
+ compressed: true,
118
+ redisTTL: TTLType.Hours12,
119
+ localCache: false,
120
+ },
121
+ Blacklist: {
122
+ compressed: true,
123
+ redisTTL: TTLType.Minutes10,
124
+ localCache: false,
125
+ },
126
+ TokenList: {
127
+ compressed: false,
128
+ redisTTL: TTLType.Minutes30,
129
+ localCache: false,
130
+ },
131
+ CurrentRoot: {
132
+ compressed: false,
133
+ redisTTL: TTLType.Seconds30,
134
+ localCache: true,
135
+ },
136
+ Chains: {
137
+ compressed: false,
138
+ redisTTL: TTLType.Hours3,
139
+ localCache: true,
140
+ },
141
+ RootsWithRewardOnChain: {
142
+ compressed: false,
143
+ redisTTL: TTLType.Minutes2,
144
+ localCache: true,
145
+ },
146
+ };
@@ -0,0 +1,152 @@
1
+ import { InvalidCacheCall } from "../utils/error";
2
+ import { log } from "../utils/logger";
3
+ import { withRetry, withTimeout } from "@sdk";
4
+ import NodeCache from "node-cache";
5
+ import { CacheDeclaration } from "./declaration";
6
+ import { REDIS_CRON_WRITE_TIMEOUT, REDIS_READ_TIMEOUT, REDIS_RETRIES, redisClient } from "./redis";
7
+ export class Cache {
8
+ static decoder = new TextDecoder();
9
+ static encoder = new TextEncoder();
10
+ localCache = new NodeCache();
11
+ /*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
12
+ UTILS
13
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
14
+ static baseKey(key) {
15
+ return key.split("_")[0];
16
+ }
17
+ /** @notice Uncompress (if enabled), parsed and typed data from the cache */
18
+ static uncompress(key, value) {
19
+ const { compressed } = CacheDeclaration[Cache.baseKey(key)];
20
+ if (!compressed)
21
+ return JSON.parse(value);
22
+ if (!value)
23
+ return {};
24
+ const encoded = Buffer.from(value, "base64");
25
+ const uncompressed = Bun.gunzipSync(encoded);
26
+ const decoded = Cache.decoder.decode(uncompressed);
27
+ return JSON.parse(decoded);
28
+ }
29
+ /** @notice Compress (if enabled), stringify and encoded data to be stored in the cache */
30
+ static compress(key, value) {
31
+ const { compressed } = CacheDeclaration[Cache.baseKey(key)];
32
+ if (!compressed)
33
+ return JSON.stringify(value);
34
+ const encoded = Cache.encoder.encode(JSON.stringify(value));
35
+ const compressedValue = Bun.gzipSync(encoded);
36
+ return Buffer.from(compressedValue).toString("base64");
37
+ }
38
+ /*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
39
+ REDIS CACHE
40
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
41
+ async getRaw(key) {
42
+ if (!key || key === "")
43
+ throw new InvalidCacheCall("Trying to access cache with no key");
44
+ return await withRetry(withTimeout, [redisClient.get(key), REDIS_READ_TIMEOUT], REDIS_RETRIES);
45
+ }
46
+ async getManyRaw(keys) {
47
+ if (keys?.length === 0)
48
+ throw new InvalidCacheCall("Trying to access cache with no keys");
49
+ const strippedKeys = Array.from(keys.map(a => a.split("_")[0]).reduce((unique, key) => unique.add(key), new Set()));
50
+ const multipleCached = await withRetry(withTimeout, [redisClient.mGet(keys), REDIS_READ_TIMEOUT], REDIS_RETRIES);
51
+ log.local(`Redis: ${keys.length} data fetched with mGet`);
52
+ return multipleCached;
53
+ }
54
+ async setRaw(key, value) {
55
+ const { redisTTL } = CacheDeclaration[Cache.baseKey(key)];
56
+ await redisClient.set(key, value, { EX: redisTTL });
57
+ }
58
+ /** @notice Set value for a given key for both local and raw cache */
59
+ async set(key, value) {
60
+ this.setLocally(key, value);
61
+ this.setRaw(key, Cache.compress(key, value));
62
+ }
63
+ /*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
64
+ LOCAL CACHE
65
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
66
+ isLocallyCached(key) {
67
+ return false;
68
+ // return this.localCache.has(key);
69
+ }
70
+ setLocally(key, value) {
71
+ return true;
72
+ // const { localCacheTtl } = CacheDeclaration[Cache.baseKey<T, Key>(key)] as { localCacheTtl?: number };
73
+ // return this.localCache.set(key, value, localCacheTtl ?? DEFAULT_LOCAL_TTL);
74
+ }
75
+ getLocally(key) {
76
+ return undefined;
77
+ // return this.localCache.get(key);
78
+ }
79
+ /*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
80
+ PUBLIC OPERATIONS
81
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
82
+ /**
83
+ * @returns the uncompressed (if enabled), parsed and typed data from the cache
84
+ */
85
+ async get(key, args) {
86
+ const actualKey = (args ? `${key}_${args}` : key);
87
+ if (this.isLocallyCached(actualKey))
88
+ return this.getLocally(actualKey);
89
+ const rawCache = await this.getRaw(actualKey);
90
+ if (rawCache === null)
91
+ return null;
92
+ const value = Cache.uncompress(actualKey, rawCache);
93
+ this.setLocally(actualKey, value);
94
+ return value;
95
+ }
96
+ /**
97
+ * Get many data from cache
98
+ * @param key cache key
99
+ * @returns the uncompressed (if enabled), parsed and typed data from the cache for all keys
100
+ */
101
+ async getMany(keys) {
102
+ const nonLocalKeys = keys.filter(key => !this.isLocallyCached(key)); // Keys not stored locally
103
+ const cached = !!nonLocalKeys.length ? await this.getManyRaw(nonLocalKeys) : [];
104
+ const res = keys.map(key => {
105
+ if (!nonLocalKeys.includes(key))
106
+ return this.localCache.get(key);
107
+ const cachedValue = cached[nonLocalKeys.indexOf(key)];
108
+ if (cachedValue !== null) {
109
+ const value = Cache.uncompress(key, cachedValue);
110
+ this.setLocally(key, value);
111
+ return value;
112
+ }
113
+ return null;
114
+ });
115
+ return res;
116
+ }
117
+ /**
118
+ * Get many data from cache with argument
119
+ * @param key cache key
120
+ * @param args arguments to append to cache keys
121
+ * @returns the uncompressed (if enabled), parsed and typed data from the cache for all keys
122
+ */
123
+ async getManyWithArgs(key, args) {
124
+ const actualKeys = args.map(arg => `${key}_${arg}`);
125
+ return this.getMany(actualKeys);
126
+ }
127
+ /**
128
+ * Get data from cache or set it using the callback
129
+ * @param key cache key
130
+ * @returns the uncompressed (if enabled), parsed and typed data from the cache
131
+ */
132
+ async getOrSet(key, callback, ...args) {
133
+ if (this.isLocallyCached(key))
134
+ return this.localCache.get(key);
135
+ let value;
136
+ const cachedValue = await this.getRaw(key);
137
+ if (cachedValue !== null) {
138
+ value = Cache.uncompress(key, cachedValue);
139
+ }
140
+ else {
141
+ value = await callback(...args);
142
+ await this.setRaw(key, Cache.compress(key, value));
143
+ }
144
+ this.setLocally(key, value);
145
+ return value;
146
+ }
147
+ /** @notice Set with retrials */
148
+ async safeSet(key, value) {
149
+ return await withRetry(withTimeout, [this.set(key, value), REDIS_CRON_WRITE_TIMEOUT], REDIS_RETRIES);
150
+ }
151
+ }
152
+ export const Redis = new Cache();
@@ -0,0 +1,49 @@
1
+ import { log } from "../utils/logger";
2
+ import { createClient } from "redis";
3
+ const REDISHOST = process.env.REDISHOST || "redis";
4
+ const REDISPORT = !!process.env.REDISPORT ? Number(process.env.REDISPORT) : 6379;
5
+ const REDISPASSWORD = process.env.REDISPASSWORD || "";
6
+ export const REDIS_RETRIES = 0;
7
+ export const REDIS_READ_TIMEOUT = !!process.env.REDIS_READ_TIMEOUT
8
+ ? Number.parseInt(process.env.REDIS_READ_TIMEOUT)
9
+ : Bun.env.NODE_ENV === "production"
10
+ ? 4_000
11
+ : 10 * 2_000;
12
+ export const REDIS_WRITE_TIMEOUT = 4000;
13
+ export const REDIS_CRON_READ_TIMEOUT = 5000;
14
+ export const REDIS_CRON_WRITE_TIMEOUT = 10000;
15
+ export var TTLType;
16
+ (function (TTLType) {
17
+ TTLType[TTLType["HalfBlock"] = 4] = "HalfBlock";
18
+ TTLType[TTLType["Block"] = 11] = "Block";
19
+ TTLType[TTLType["Seconds30"] = 30] = "Seconds30";
20
+ TTLType[TTLType["Minutes2"] = 120] = "Minutes2";
21
+ TTLType[TTLType["Minutes3"] = 180] = "Minutes3";
22
+ TTLType[TTLType["Minutes5"] = 300] = "Minutes5";
23
+ TTLType[TTLType["Minutes10"] = 600] = "Minutes10";
24
+ TTLType[TTLType["Minutes25"] = 1500] = "Minutes25";
25
+ TTLType[TTLType["Minutes30"] = 1800] = "Minutes30";
26
+ TTLType[TTLType["Minutes35"] = 2100] = "Minutes35";
27
+ TTLType[TTLType["Hours3"] = 10800] = "Hours3";
28
+ TTLType[TTLType["Hours12"] = 43200] = "Hours12";
29
+ TTLType[TTLType["Day"] = 86400] = "Day";
30
+ TTLType[TTLType["Week"] = 604800] = "Week";
31
+ })(TTLType || (TTLType = {}));
32
+ /** Redis client
33
+ * @dev About how handling client connections -> https://stackoverflow.com/questions/22387187/node-js-express-redis-when-to-close-connection
34
+ * @dev Also -> https://github.com/redis/node-redis/issues/568
35
+ */
36
+ const redisConfig = {
37
+ url: `redis://${REDISHOST}:${REDISPORT}`,
38
+ socket: REDISHOST === "redis" ? undefined : { tls: true },
39
+ password: REDISPASSWORD,
40
+ };
41
+ export const redisClient = createClient(redisConfig);
42
+ redisClient.on("error", error => {
43
+ log.error("Redis", error);
44
+ });
45
+ redisClient.connect();
46
+ redisClient.on("end", () => log.info("Redis: disconnected"));
47
+ redisClient.on("ready", () => {
48
+ log.debug("Redis: connected!");
49
+ });
@@ -0,0 +1,119 @@
1
+ import Big from "big.js";
2
+ export const zeroBN = new Big(0);
3
+ export const baseTestAnalyticsGraphUrl = "https://api.thegraph.com/subgraphs/name/angleprotocol/test-analytics-";
4
+ export const baseAnalyticsGraphUrl = "https://api.thegraph.com/subgraphs/name/angleprotocol/test-analytics-";
5
+ export const EXPORTER_URL = "https://exporter.angle.money";
6
+ export const DEFAULT_LOCAL_TTL = 120;
7
+ export const subgraphSuffixMapping = {
8
+ [ChainId.ARBITRUM]: "arb",
9
+ [ChainId.MAINNET]: "eth",
10
+ [ChainId.OPTIMISM]: "opt",
11
+ [ChainId.POLYGON]: "pol",
12
+ [ChainId.BASE]: "bas",
13
+ [ChainId.POLYGONZKEVM]: "zke",
14
+ };
15
+ export const MAX_NUM_SUBCALLS = 100;
16
+ export const MERKL_TREE_OPTIONS = { hashLeaves: true, sortLeaves: true, sortPairs: true };
17
+ export const MERKL_USER_POSITION_FETCHING_TIMEOUT = 8000;
18
+ export const MERKL_USER_POSITION_FETCHING_GLOBAL_TIMEOUT = 10000;
19
+ export const MERKL_USER_CLAIMED_TOKENS_TIMEOUT = 10000;
20
+ export const MERKL_ALM_FETCHING_TIMEOUT = 10000;
21
+ export const MERKL_ALM_POSITION_FETCHING_TIMEOUT = 100000;
22
+ export const MERKL_USER_REWARDS_FETCHING_TIMEOUT = 10000;
23
+ export const GITHUB_MERKL_REWARDS_URL = "https://raw.githubusercontent.com/AngleProtocol/merkl-rewards/main/";
24
+ export const GCLOUD_STORAGE_MERKL_PUBLIC_URL = "https://storage.googleapis.com/merkl-production-rewards/";
25
+ export const MERKL_BLACKLIST = [
26
+ "0xa6161c3e1bc3c743819f0be91322e108946c1a0e7666ae2885ce03c2068cbef7", // ETH - stETH fucked up by gauntlet
27
+ ];
28
+ export const EBTC_ADDRESS = "0x661c70333AA1850CcDBAe82776Bb436A0fCfeEfB";
29
+ export const CDPMANAGER_ADDRESS = "0xc4cbaE499bb4Ca41E78f52F07f5d98c375711774";
30
+ export const SORTEDCDPS_ADDRESS = "0x591AcB5AE192c147948c12651a0a5f24f0529BE3";
31
+ export const RFX_DATASTORE = "0x895124783008C6c68eFcccac24c482Fdf30439B2";
32
+ export const DOPEX_OPTION_MARKET = {
33
+ // UniswapV3 pools
34
+ ["0xC6962004f452bE9203591991D15f6b388e09E8D0".toLowerCase()]: "0x501B03BdB431154b8Df17BF1c00756E3a8F21744",
35
+ ["0x0E4831319A50228B9e450861297aB92dee15B44F".toLowerCase()]: "0x550e7E236912DaA302F7d5D0d6e5D7b6EF191f04", // wBTC / USDC
36
+ ["0xb0f6cA40411360c03d41C5fFc5F179b8403CdcF8".toLowerCase()]: "0x4eed3A2b797Bf5630517EcCe2e31C1438A76bb92",
37
+ ["0xC31E54c7a869B9FcBEcc14363CF510d1c41fa443".toLowerCase()]: "0x764fA09d0B3de61EeD242099BD9352C1C61D3d27",
38
+ ["0xac70bD92F89e6739B3a08Db9B6081a923912f73D".toLowerCase()]: "0x3808E8C983023a125fFE2714E2A703A3BF02bE0d",
39
+ ["0xcDa53B1F66614552F834cEeF361A8D12a0B8DaD8".toLowerCase()]: "0x77b6f45a3Dcf0493f1B9Ac9874e5982AB526AA9e",
40
+ // PCS pools
41
+ ["0x843aC8dc6D34AEB07a56812b8b36429eE46BDd07".toLowerCase()]: "0x550e7E236912DaA302F7d5D0d6e5D7b6EF191f04", // wBTC / USDC
42
+ ["0xd9e2a1a61b6e61b275cec326465d417e52c1b95c".toLowerCase()]: "0x501B03BdB431154b8Df17BF1c00756E3a8F21744", // wETH / USDC
43
+ ["0x9fFCA51D23Ac7F7df82da414865Ef1055E5aFCc3".toLowerCase()]: "0x4eed3A2b797Bf5630517EcCe2e31C1438A76bb92", // ARB / USDC
44
+ };
45
+ import { ChainId } from "@sdk";
46
+ const COMMON_PREFIX_STAKE = "https://lockers.stakedao.org/api/strategies/cache/curve";
47
+ const COMMON_PREFIX_CONVEX = "https://www.convexfinance.com/api/curve-apys";
48
+ export const constantChain = {
49
+ [ChainId.MAINNET]: {
50
+ apw: "0x4104b135dbc9609fc1a9490e61369036497660c8",
51
+ convexEndpoint: COMMON_PREFIX_CONVEX,
52
+ crv: "0xD533a949740bb3306d119CC777fa900bA034cd52",
53
+ crv3: "0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490",
54
+ crvANGLESDANGLE: "0x96AAE323E111A19b1E0e26F55e8De21F1dD01f26",
55
+ crvEURAEUROC: "0xBa3436Fd341F2C8A928452Db3C5A3670d1d5Cc73",
56
+ crvEURAEURe: "0x413928a25D6ea1A26F2625d633207755f67Bf97c",
57
+ crvEuropool: "0xe7A3b38c39F97E977723bd1239C3470702568e7B",
58
+ crvFRAX: "0x3175Df0976dFA876431C2E9eE6Bc45b65d3473CC",
59
+ crvFRAXEURA: "0x22e859Ee894c2068920858A60b51DC03ac5581c1",
60
+ crvLUSD3CRV: "0xEd279fDD11cA84bEef15AF5D39BB4d4bEE23F0cA",
61
+ cvx: "0x4e3FBD56CD56c3e72c1403e103b45Db9da5B9D2B",
62
+ dai: "0x6B175474E89094C44Da98b954EedeAC495271d0F",
63
+ frax: "0x853d955aCEf822Db058eb8505911ED77F175b99e",
64
+ fxs: "0x3432B6A60D23Ca0dFCa7761B7ab56459D9C964D0",
65
+ morpho: "0x9994E35Db50125E0DF82e4c2dde62496CE330999",
66
+ rKP3R: "0x1ceb5cb57c4d4e2b2433641b95dd330a33185a44",
67
+ sdt: "0x73968b9a57c6e53d41345fd57a6e6ae27d6cdb2f",
68
+ stakeEndpoint: COMMON_PREFIX_STAKE,
69
+ sushi: "0x6b3595068778dd592e39a122f4f5a5cf09c90fe2",
70
+ usdc: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
71
+ weth: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
72
+ wstETH: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0",
73
+ },
74
+ [ChainId.ARBITRUM]: {
75
+ arb: "0x912ce59144191c1204e64559fe8253a0e49e6548",
76
+ chr: "0x15b2fb8f08E4Ac1Ce019EADAe02eE92AeDF06851",
77
+ convexProxy: "0x989AEb4d175e16225E39E87d0D97A3360524AD80",
78
+ crv: "0x11cdb42b0eb46d95f990bedd4695a6e3fa034978",
79
+ crv2Pool: "0x7f90122BF0700F9E7e1F688fe926940E8839F353",
80
+ cvx: "0xb952A807345991BD529FDded05009F5e80Fe8F45",
81
+ frax: "0x17FC002b466eEc40DaE837Fc4bE5c67993ddBd6F",
82
+ jeur: "0xAD435674417520aeeED6b504bBe654d4f556182F",
83
+ ram: "0xAAA6C1E32C55A7Bfa8066A6FAE9b42650F262418",
84
+ sdt: "0x7ba4a00d54a07461d9db2aef539e91409943adc9",
85
+ sliz: "0x463913D3a3D3D291667D53B8325c598Eb88D3B0e",
86
+ stakeEndpoint: `${COMMON_PREFIX_STAKE}-arbitrum`,
87
+ usdc: "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8",
88
+ },
89
+ [ChainId.OPTIMISM]: {
90
+ jeur: "0x79AF5dd14e855823FA3E9ECAcdF001D99647d043",
91
+ mai: "0xdFA46478F9e5EA86d57387849598dbFB2e964b02",
92
+ op: "0x4200000000000000000000000000000000000042",
93
+ usdc: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
94
+ usdce: "0x7F5c764cBc14f9669B88837ca1490cCa17c31607",
95
+ velo: "0x3c8b650257cfb5f272f799f5e2b4e65093a11a05",
96
+ veloV2: "0x9560e827aF36c94D2Ac33a39bCE1Fe78631088Db",
97
+ },
98
+ [ChainId.BASE]: {
99
+ aero: "0x940181a94A35A4569E4529A3CDfB74e38FD98631",
100
+ usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
101
+ },
102
+ [ChainId.POLYGON]: {
103
+ am3CRV: "0xE7a24EF0C5e95Ffb0f6684b813A78F2a3AD7D171",
104
+ amDAI: "0x27F8D03b3a2196956ED754baDc28D73be8830A6e",
105
+ amUSDC: "0x1a13F4Ca1d028320A707D99520AbFefca3998b7F",
106
+ amUSDT: "0x60D55F02A771d515e077c9C2403a1ef324885CeC",
107
+ jeur: "0x4e3Decbb3645551B8A19f0eA1678079FCB33fB4c",
108
+ jrt: "0x596ebe76e2db4470966ea395b0d063ac6197a8c5",
109
+ oretro: "0x3A29CAb2E124919d14a6F735b6033a3AaD2B260F",
110
+ usdc: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
111
+ },
112
+ [ChainId.AVALANCHE]: {
113
+ glcr: "0x3712871408a829C5cd4e86DA1f4CE727eFCD28F6",
114
+ usdc: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
115
+ },
116
+ [ChainId.BSC]: {
117
+ cake: "0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82",
118
+ },
119
+ };