@merkl/api 0.9.15

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 (819) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +90 -0
  3. package/dist/database/api/.generated/default.d.ts +1 -0
  4. package/dist/database/api/.generated/default.js +1 -0
  5. package/dist/database/api/.generated/drizzle/schema.d.ts +3029 -0
  6. package/dist/database/api/.generated/drizzle/schema.js +868 -0
  7. package/dist/database/api/.generated/drizzle/schema.ts +929 -0
  8. package/dist/database/api/.generated/edge.d.ts +1 -0
  9. package/dist/database/api/.generated/edge.js +691 -0
  10. package/dist/database/api/.generated/index-browser.js +650 -0
  11. package/dist/database/api/.generated/index.d.ts +46187 -0
  12. package/dist/database/api/.generated/index.js +720 -0
  13. package/dist/database/api/.generated/libquery_engine-debian-openssl-3.0.x.so.node +0 -0
  14. package/dist/database/api/.generated/libquery_engine-linux-arm64-openssl-1.1.x.so.node +0 -0
  15. package/dist/database/api/.generated/libquery_engine-linux-musl-arm64-openssl-3.0.x.so.node +0 -0
  16. package/dist/database/api/.generated/package.json +97 -0
  17. package/dist/database/api/.generated/runtime/edge-esm.js +31 -0
  18. package/dist/database/api/.generated/runtime/edge.js +31 -0
  19. package/dist/database/api/.generated/runtime/index-browser.d.ts +365 -0
  20. package/dist/database/api/.generated/runtime/index-browser.js +13 -0
  21. package/dist/database/api/.generated/runtime/library.d.ts +3447 -0
  22. package/dist/database/api/.generated/runtime/library.js +143 -0
  23. package/dist/database/api/.generated/runtime/react-native.js +80 -0
  24. package/dist/database/api/.generated/runtime/wasm.js +32 -0
  25. package/dist/database/api/.generated/schema.prisma +457 -0
  26. package/dist/database/api/.generated/wasm.d.ts +1 -0
  27. package/dist/database/api/.generated/wasm.js +650 -0
  28. package/dist/database/api/seeder/resources/protocol.d.ts +373 -0
  29. package/dist/database/api/seeder/resources/protocol.js +344 -0
  30. package/dist/database/engine/.generated/default.d.ts +1 -0
  31. package/dist/database/engine/.generated/default.js +1 -0
  32. package/dist/database/engine/.generated/edge.d.ts +1 -0
  33. package/dist/database/engine/.generated/edge.js +436 -0
  34. package/dist/database/engine/.generated/index-browser.js +411 -0
  35. package/dist/database/engine/.generated/index.d.ts +18906 -0
  36. package/dist/database/engine/.generated/index.js +465 -0
  37. package/dist/database/engine/.generated/libquery_engine-debian-openssl-3.0.x.so.node +0 -0
  38. package/dist/database/engine/.generated/libquery_engine-linux-arm64-openssl-1.1.x.so.node +0 -0
  39. package/dist/database/engine/.generated/libquery_engine-linux-musl-arm64-openssl-3.0.x.so.node +0 -0
  40. package/dist/database/engine/.generated/package.json +97 -0
  41. package/dist/database/engine/.generated/runtime/edge-esm.js +31 -0
  42. package/dist/database/engine/.generated/runtime/edge.js +31 -0
  43. package/dist/database/engine/.generated/runtime/index-browser.d.ts +365 -0
  44. package/dist/database/engine/.generated/runtime/index-browser.js +13 -0
  45. package/dist/database/engine/.generated/runtime/library.d.ts +3447 -0
  46. package/dist/database/engine/.generated/runtime/library.js +143 -0
  47. package/dist/database/engine/.generated/runtime/react-native.js +80 -0
  48. package/dist/database/engine/.generated/runtime/wasm.js +32 -0
  49. package/dist/database/engine/.generated/schema.prisma +207 -0
  50. package/dist/database/engine/.generated/wasm.d.ts +1 -0
  51. package/dist/database/engine/.generated/wasm.js +411 -0
  52. package/dist/database/index.d.ts +29 -0
  53. package/dist/database/index.js +13 -0
  54. package/dist/src/backgroundJobs/index.d.ts +1 -0
  55. package/dist/src/backgroundJobs/index.js +57 -0
  56. package/dist/src/backgroundJobs/jobs/campaignsCacheUpdater.d.ts +50 -0
  57. package/dist/src/backgroundJobs/jobs/campaignsCacheUpdater.js +173 -0
  58. package/dist/src/backgroundJobs/jobs/health.d.ts +41 -0
  59. package/dist/src/backgroundJobs/jobs/health.js +15 -0
  60. package/dist/src/backgroundJobs/jobs/opportunityUpdater.d.ts +36 -0
  61. package/dist/src/backgroundJobs/jobs/opportunityUpdater.js +19 -0
  62. package/dist/src/cache/declaration.d.ts +133 -0
  63. package/dist/src/cache/declaration.js +121 -0
  64. package/dist/src/cache/index.d.ts +61 -0
  65. package/dist/src/cache/index.js +161 -0
  66. package/dist/src/cache/redis.d.ts +312 -0
  67. package/dist/src/cache/redis.js +56 -0
  68. package/dist/src/constants.d.ts +108 -0
  69. package/dist/src/constants.js +128 -0
  70. package/dist/src/eden/index.d.ts +20952 -0
  71. package/dist/src/eden/index.js +4 -0
  72. package/dist/src/engine/dynamicData/factory.d.ts +3 -0
  73. package/dist/src/engine/dynamicData/factory.js +54 -0
  74. package/dist/src/engine/dynamicData/implementations/Ajna.d.ts +7 -0
  75. package/dist/src/engine/dynamicData/implementations/Ajna.js +101 -0
  76. package/dist/src/engine/dynamicData/implementations/Ambiant.d.ts +7 -0
  77. package/dist/src/engine/dynamicData/implementations/Ambiant.js +227 -0
  78. package/dist/src/engine/dynamicData/implementations/Badger.d.ts +7 -0
  79. package/dist/src/engine/dynamicData/implementations/Badger.js +84 -0
  80. package/dist/src/engine/dynamicData/implementations/Clamm.d.ts +7 -0
  81. package/dist/src/engine/dynamicData/implementations/Clamm.js +970 -0
  82. package/dist/src/engine/dynamicData/implementations/Compound.d.ts +7 -0
  83. package/dist/src/engine/dynamicData/implementations/Compound.js +136 -0
  84. package/dist/src/engine/dynamicData/implementations/Dolomite.d.ts +7 -0
  85. package/dist/src/engine/dynamicData/implementations/Dolomite.js +53 -0
  86. package/dist/src/engine/dynamicData/implementations/EigenLayer.d.ts +7 -0
  87. package/dist/src/engine/dynamicData/implementations/EigenLayer.js +64 -0
  88. package/dist/src/engine/dynamicData/implementations/Encompassing.d.ts +7 -0
  89. package/dist/src/engine/dynamicData/implementations/Encompassing.js +26 -0
  90. package/dist/src/engine/dynamicData/implementations/Erc20.d.ts +6 -0
  91. package/dist/src/engine/dynamicData/implementations/Erc20.js +159 -0
  92. package/dist/src/engine/dynamicData/implementations/Erc20Snapshot.d.ts +7 -0
  93. package/dist/src/engine/dynamicData/implementations/Erc20Snapshot.js +32 -0
  94. package/dist/src/engine/dynamicData/implementations/EventBased.d.ts +7 -0
  95. package/dist/src/engine/dynamicData/implementations/EventBased.js +104 -0
  96. package/dist/src/engine/dynamicData/implementations/Hyperdrive.d.ts +7 -0
  97. package/dist/src/engine/dynamicData/implementations/Hyperdrive.js +106 -0
  98. package/dist/src/engine/dynamicData/implementations/Morpho.d.ts +7 -0
  99. package/dist/src/engine/dynamicData/implementations/Morpho.js +109 -0
  100. package/dist/src/engine/dynamicData/implementations/Radiant.d.ts +7 -0
  101. package/dist/src/engine/dynamicData/implementations/Radiant.js +117 -0
  102. package/dist/src/engine/dynamicData/implementations/Silo.d.ts +9 -0
  103. package/dist/src/engine/dynamicData/implementations/Silo.js +109 -0
  104. package/dist/src/engine/dynamicData/implementations/UniswapV4.d.ts +7 -0
  105. package/dist/src/engine/dynamicData/implementations/UniswapV4.js +249 -0
  106. package/dist/src/engine/dynamicData/implementations/Vest.d.ts +9 -0
  107. package/dist/src/engine/dynamicData/implementations/Vest.js +58 -0
  108. package/dist/src/engine/dynamicData/implementations/default.d.ts +5 -0
  109. package/dist/src/engine/dynamicData/implementations/default.js +5 -0
  110. package/dist/src/engine/dynamicData/utils/fetchA51Strategies.d.ts +18 -0
  111. package/dist/src/engine/dynamicData/utils/fetchA51Strategies.js +44 -0
  112. package/dist/src/engine/dynamicData/utils/fetchAmbientInfo.d.ts +12 -0
  113. package/dist/src/engine/dynamicData/utils/fetchAmbientInfo.js +59 -0
  114. package/dist/src/engine/dynamicData/utils/fetchClamInfo.d.ts +2 -0
  115. package/dist/src/engine/dynamicData/utils/fetchClamInfo.js +27 -0
  116. package/dist/src/engine/dynamicData/utils/fetchLogs.d.ts +10 -0
  117. package/dist/src/engine/dynamicData/utils/fetchLogs.js +149 -0
  118. package/dist/src/engine/dynamicData/utils/getCompV2ForksVaults.d.ts +19 -0
  119. package/dist/src/engine/dynamicData/utils/getCompV2ForksVaults.js +134 -0
  120. package/dist/src/engine/dynamicData/utils/getContractCreationBlock.d.ts +2 -0
  121. package/dist/src/engine/dynamicData/utils/getContractCreationBlock.js +44 -0
  122. package/dist/src/engine/dynamicData/utils/getDolomiteMarkets.d.ts +8 -0
  123. package/dist/src/engine/dynamicData/utils/getDolomiteMarkets.js +53 -0
  124. package/dist/src/engine/dynamicData/utils/getEulerV2Vaults.d.ts +8 -0
  125. package/dist/src/engine/dynamicData/utils/getEulerV2Vaults.js +209 -0
  126. package/dist/src/engine/dynamicData/utils/getUniswapV4Pools.d.ts +8 -0
  127. package/dist/src/engine/dynamicData/utils/getUniswapV4Pools.js +183 -0
  128. package/dist/src/engine/erc20SubTypeProcessors/GenericProcessor.d.ts +99 -0
  129. package/dist/src/engine/erc20SubTypeProcessors/GenericProcessor.js +329 -0
  130. package/dist/src/engine/erc20SubTypeProcessors/helpers/eulerVaultNames.d.ts +1 -0
  131. package/dist/src/engine/erc20SubTypeProcessors/helpers/eulerVaultNames.js +13 -0
  132. package/dist/src/engine/erc20SubTypeProcessors/helpers/factoryFinder.d.ts +5 -0
  133. package/dist/src/engine/erc20SubTypeProcessors/helpers/factoryFinder.js +41 -0
  134. package/dist/src/engine/erc20SubTypeProcessors/helpers/getBlacklistedSupply.d.ts +2 -0
  135. package/dist/src/engine/erc20SubTypeProcessors/helpers/getBlacklistedSupply.js +22 -0
  136. package/dist/src/engine/erc20SubTypeProcessors/helpers/hardcoded.d.ts +3 -0
  137. package/dist/src/engine/erc20SubTypeProcessors/helpers/hardcoded.js +30 -0
  138. package/dist/src/engine/erc20SubTypeProcessors/helpers/metamorphoTvl.d.ts +1 -0
  139. package/dist/src/engine/erc20SubTypeProcessors/helpers/metamorphoTvl.js +35 -0
  140. package/dist/src/engine/erc20SubTypeProcessors/helpers/ownerFinder.d.ts +2 -0
  141. package/dist/src/engine/erc20SubTypeProcessors/helpers/ownerFinder.js +12 -0
  142. package/dist/src/engine/erc20SubTypeProcessors/helpers/spliceTVL.d.ts +7 -0
  143. package/dist/src/engine/erc20SubTypeProcessors/helpers/spliceTVL.js +21 -0
  144. package/dist/src/engine/erc20SubTypeProcessors/helpers/tokenType.d.ts +107 -0
  145. package/dist/src/engine/erc20SubTypeProcessors/helpers/tokenType.js +193 -0
  146. package/dist/src/engine/erc20SubTypeProcessors/implementations/AaveProcessor.d.ts +30 -0
  147. package/dist/src/engine/erc20SubTypeProcessors/implementations/AaveProcessor.js +25 -0
  148. package/dist/src/engine/erc20SubTypeProcessors/implementations/AnglesLiquid.d.ts +35 -0
  149. package/dist/src/engine/erc20SubTypeProcessors/implementations/AnglesLiquid.js +50 -0
  150. package/dist/src/engine/erc20SubTypeProcessors/implementations/AssetProcessor.d.ts +35 -0
  151. package/dist/src/engine/erc20SubTypeProcessors/implementations/AssetProcessor.js +47 -0
  152. package/dist/src/engine/erc20SubTypeProcessors/implementations/AuraProcessor.d.ts +70 -0
  153. package/dist/src/engine/erc20SubTypeProcessors/implementations/AuraProcessor.js +110 -0
  154. package/dist/src/engine/erc20SubTypeProcessors/implementations/BEXRewardGaugeProcessor.d.ts +51 -0
  155. package/dist/src/engine/erc20SubTypeProcessors/implementations/BEXRewardGaugeProcessor.js +102 -0
  156. package/dist/src/engine/erc20SubTypeProcessors/implementations/BalancerGaugeProcessor.d.ts +49 -0
  157. package/dist/src/engine/erc20SubTypeProcessors/implementations/BalancerGaugeProcessor.js +83 -0
  158. package/dist/src/engine/erc20SubTypeProcessors/implementations/BalancerPoolProcessor.d.ts +60 -0
  159. package/dist/src/engine/erc20SubTypeProcessors/implementations/BalancerPoolProcessor.js +95 -0
  160. package/dist/src/engine/erc20SubTypeProcessors/implementations/BalancerV3PoolProcessor.d.ts +44 -0
  161. package/dist/src/engine/erc20SubTypeProcessors/implementations/BalancerV3PoolProcessor.js +75 -0
  162. package/dist/src/engine/erc20SubTypeProcessors/implementations/BeefyProcessor.d.ts +48 -0
  163. package/dist/src/engine/erc20SubTypeProcessors/implementations/BeefyProcessor.js +50 -0
  164. package/dist/src/engine/erc20SubTypeProcessors/implementations/BunniV2Processor.d.ts +45 -0
  165. package/dist/src/engine/erc20SubTypeProcessors/implementations/BunniV2Processor.js +87 -0
  166. package/dist/src/engine/erc20SubTypeProcessors/implementations/CompoundProcessor.d.ts +44 -0
  167. package/dist/src/engine/erc20SubTypeProcessors/implementations/CompoundProcessor.js +36 -0
  168. package/dist/src/engine/erc20SubTypeProcessors/implementations/ERC4626Processor.d.ts +34 -0
  169. package/dist/src/engine/erc20SubTypeProcessors/implementations/ERC4626Processor.js +36 -0
  170. package/dist/src/engine/erc20SubTypeProcessors/implementations/EnzymeProcessor.d.ts +40 -0
  171. package/dist/src/engine/erc20SubTypeProcessors/implementations/EnzymeProcessor.js +51 -0
  172. package/dist/src/engine/erc20SubTypeProcessors/implementations/EqualizerGaugeProcessor.d.ts +28 -0
  173. package/dist/src/engine/erc20SubTypeProcessors/implementations/EqualizerGaugeProcessor.js +53 -0
  174. package/dist/src/engine/erc20SubTypeProcessors/implementations/EulerBorrowProcessor.d.ts +36 -0
  175. package/dist/src/engine/erc20SubTypeProcessors/implementations/EulerBorrowProcessor.js +51 -0
  176. package/dist/src/engine/erc20SubTypeProcessors/implementations/EulerLendProcessor.d.ts +36 -0
  177. package/dist/src/engine/erc20SubTypeProcessors/implementations/EulerLendProcessor.js +47 -0
  178. package/dist/src/engine/erc20SubTypeProcessors/implementations/FluidProcessor.d.ts +39 -0
  179. package/dist/src/engine/erc20SubTypeProcessors/implementations/FluidProcessor.js +36 -0
  180. package/dist/src/engine/erc20SubTypeProcessors/implementations/FraxProcessor.d.ts +33 -0
  181. package/dist/src/engine/erc20SubTypeProcessors/implementations/FraxProcessor.js +41 -0
  182. package/dist/src/engine/erc20SubTypeProcessors/implementations/GammaProcessor.d.ts +43 -0
  183. package/dist/src/engine/erc20SubTypeProcessors/implementations/GammaProcessor.js +63 -0
  184. package/dist/src/engine/erc20SubTypeProcessors/implementations/GearboxProcessor.d.ts +44 -0
  185. package/dist/src/engine/erc20SubTypeProcessors/implementations/GearboxProcessor.js +57 -0
  186. package/dist/src/engine/erc20SubTypeProcessors/implementations/HanjiVaultProcessor.d.ts +43 -0
  187. package/dist/src/engine/erc20SubTypeProcessors/implementations/HanjiVaultProcessor.js +58 -0
  188. package/dist/src/engine/erc20SubTypeProcessors/implementations/HoldStationProcessor.d.ts +29 -0
  189. package/dist/src/engine/erc20SubTypeProcessors/implementations/HoldStationProcessor.js +34 -0
  190. package/dist/src/engine/erc20SubTypeProcessors/implementations/HourglassProcessor.d.ts +36 -0
  191. package/dist/src/engine/erc20SubTypeProcessors/implementations/HourglassProcessor.js +34 -0
  192. package/dist/src/engine/erc20SubTypeProcessors/implementations/MaverickBPProcessor.d.ts +50 -0
  193. package/dist/src/engine/erc20SubTypeProcessors/implementations/MaverickBPProcessor.js +74 -0
  194. package/dist/src/engine/erc20SubTypeProcessors/implementations/MetamorphoProcessor.d.ts +33 -0
  195. package/dist/src/engine/erc20SubTypeProcessors/implementations/MetamorphoProcessor.js +47 -0
  196. package/dist/src/engine/erc20SubTypeProcessors/implementations/NoLinkVaultProcessor.d.ts +38 -0
  197. package/dist/src/engine/erc20SubTypeProcessors/implementations/NoLinkVaultProcessor.js +81 -0
  198. package/dist/src/engine/erc20SubTypeProcessors/implementations/PendleProcessor.d.ts +29 -0
  199. package/dist/src/engine/erc20SubTypeProcessors/implementations/PendleProcessor.js +29 -0
  200. package/dist/src/engine/erc20SubTypeProcessors/implementations/PendleYTProcessor.d.ts +29 -0
  201. package/dist/src/engine/erc20SubTypeProcessors/implementations/PendleYTProcessor.js +29 -0
  202. package/dist/src/engine/erc20SubTypeProcessors/implementations/RadiantProcessor.d.ts +32 -0
  203. package/dist/src/engine/erc20SubTypeProcessors/implementations/RadiantProcessor.js +58 -0
  204. package/dist/src/engine/erc20SubTypeProcessors/implementations/RfxProcessor.d.ts +40 -0
  205. package/dist/src/engine/erc20SubTypeProcessors/implementations/RfxProcessor.js +67 -0
  206. package/dist/src/engine/erc20SubTypeProcessors/implementations/Satlayer.d.ts +34 -0
  207. package/dist/src/engine/erc20SubTypeProcessors/implementations/Satlayer.js +27 -0
  208. package/dist/src/engine/erc20SubTypeProcessors/implementations/SpectraProcessor.d.ts +31 -0
  209. package/dist/src/engine/erc20SubTypeProcessors/implementations/SpectraProcessor.js +41 -0
  210. package/dist/src/engine/erc20SubTypeProcessors/implementations/SpectraYTProcessor.d.ts +31 -0
  211. package/dist/src/engine/erc20SubTypeProcessors/implementations/SpectraYTProcessor.js +39 -0
  212. package/dist/src/engine/erc20SubTypeProcessors/implementations/SpliceProcessor.d.ts +16 -0
  213. package/dist/src/engine/erc20SubTypeProcessors/implementations/SpliceProcessor.js +36 -0
  214. package/dist/src/engine/erc20SubTypeProcessors/implementations/SturdySiloProcessor.d.ts +39 -0
  215. package/dist/src/engine/erc20SubTypeProcessors/implementations/SturdySiloProcessor.js +37 -0
  216. package/dist/src/engine/erc20SubTypeProcessors/implementations/TempestVaultProcessor.d.ts +52 -0
  217. package/dist/src/engine/erc20SubTypeProcessors/implementations/TempestVaultProcessor.js +79 -0
  218. package/dist/src/engine/erc20SubTypeProcessors/implementations/TemplateProcessor.d.ts +32 -0
  219. package/dist/src/engine/erc20SubTypeProcessors/implementations/TemplateProcessor.js +40 -0
  220. package/dist/src/engine/erc20SubTypeProcessors/implementations/TorosProcessor.d.ts +30 -0
  221. package/dist/src/engine/erc20SubTypeProcessors/implementations/TorosProcessor.js +33 -0
  222. package/dist/src/engine/erc20SubTypeProcessors/implementations/UniswapProcessor.d.ts +44 -0
  223. package/dist/src/engine/erc20SubTypeProcessors/implementations/UniswapProcessor.js +68 -0
  224. package/dist/src/engine/erc20SubTypeProcessors/implementations/VicunaProcessor.d.ts +28 -0
  225. package/dist/src/engine/erc20SubTypeProcessors/implementations/VicunaProcessor.js +35 -0
  226. package/dist/src/engine/erc20SubTypeProcessors/implementations/WoofiProcessor.d.ts +32 -0
  227. package/dist/src/engine/erc20SubTypeProcessors/implementations/WoofiProcessor.js +40 -0
  228. package/dist/src/engine/erc20SubTypeProcessors/implementations/ZkSwapThreePoolProcessor.d.ts +53 -0
  229. package/dist/src/engine/erc20SubTypeProcessors/implementations/ZkSwapThreePoolProcessor.js +55 -0
  230. package/dist/src/engine/erc20SubTypeProcessors/implementations/curveNPoolProcessor.d.ts +39 -0
  231. package/dist/src/engine/erc20SubTypeProcessors/implementations/curveNPoolProcessor.js +95 -0
  232. package/dist/src/engine/erc20SubTypeProcessors/implementations/curveProcessor.d.ts +49 -0
  233. package/dist/src/engine/erc20SubTypeProcessors/implementations/curveProcessor.js +70 -0
  234. package/dist/src/engine/erc20SubTypeProcessors/implementations/processorMapping.d.ts +6 -0
  235. package/dist/src/engine/erc20SubTypeProcessors/implementations/processorMapping.js +142 -0
  236. package/dist/src/engine/erc20SubTypeProcessors/implementations/stakedCurveProcessor.d.ts +54 -0
  237. package/dist/src/engine/erc20SubTypeProcessors/implementations/stakedCurveProcessor.js +77 -0
  238. package/dist/src/engine/erc20SubTypeProcessors/implementations/xU308Processor.d.ts +37 -0
  239. package/dist/src/engine/erc20SubTypeProcessors/implementations/xU308Processor.js +49 -0
  240. package/dist/src/engine/erc20SubTypeProcessors/subtypesPrices.d.ts +4 -0
  241. package/dist/src/engine/erc20SubTypeProcessors/subtypesPrices.js +24 -0
  242. package/dist/src/engine/erc20SubTypeProcessors/subtypesRound1.d.ts +3 -0
  243. package/dist/src/engine/erc20SubTypeProcessors/subtypesRound1.js +336 -0
  244. package/dist/src/engine/erc20SubTypeProcessors/subtypesRound2.d.ts +4 -0
  245. package/dist/src/engine/erc20SubTypeProcessors/subtypesRound2.js +22 -0
  246. package/dist/src/engine/erc20SubTypeProcessors/subtypesRound3.d.ts +3 -0
  247. package/dist/src/engine/erc20SubTypeProcessors/subtypesRound3.js +22 -0
  248. package/dist/src/engine/erc20SubTypeProcessors/subtypesRound4.d.ts +3 -0
  249. package/dist/src/engine/erc20SubTypeProcessors/subtypesRound4.js +22 -0
  250. package/dist/src/engine/opportunityMetadata/factory.d.ts +3 -0
  251. package/dist/src/engine/opportunityMetadata/factory.js +57 -0
  252. package/dist/src/engine/opportunityMetadata/implementations/Ajna.d.ts +15 -0
  253. package/dist/src/engine/opportunityMetadata/implementations/Ajna.js +52 -0
  254. package/dist/src/engine/opportunityMetadata/implementations/Ambiant.d.ts +15 -0
  255. package/dist/src/engine/opportunityMetadata/implementations/Ambiant.js +31 -0
  256. package/dist/src/engine/opportunityMetadata/implementations/Badger.d.ts +15 -0
  257. package/dist/src/engine/opportunityMetadata/implementations/Badger.js +25 -0
  258. package/dist/src/engine/opportunityMetadata/implementations/Clamm.d.ts +15 -0
  259. package/dist/src/engine/opportunityMetadata/implementations/Clamm.js +50 -0
  260. package/dist/src/engine/opportunityMetadata/implementations/Compound.d.ts +16 -0
  261. package/dist/src/engine/opportunityMetadata/implementations/Compound.js +20 -0
  262. package/dist/src/engine/opportunityMetadata/implementations/Default.d.ts +13 -0
  263. package/dist/src/engine/opportunityMetadata/implementations/Default.js +11 -0
  264. package/dist/src/engine/opportunityMetadata/implementations/Dolomite.d.ts +15 -0
  265. package/dist/src/engine/opportunityMetadata/implementations/Dolomite.js +17 -0
  266. package/dist/src/engine/opportunityMetadata/implementations/EigenLayer.d.ts +15 -0
  267. package/dist/src/engine/opportunityMetadata/implementations/EigenLayer.js +11 -0
  268. package/dist/src/engine/opportunityMetadata/implementations/Encompassing.d.ts +15 -0
  269. package/dist/src/engine/opportunityMetadata/implementations/Encompassing.js +37 -0
  270. package/dist/src/engine/opportunityMetadata/implementations/Erc20.d.ts +15 -0
  271. package/dist/src/engine/opportunityMetadata/implementations/Erc20.js +71 -0
  272. package/dist/src/engine/opportunityMetadata/implementations/Erc20Snapshot.d.ts +14 -0
  273. package/dist/src/engine/opportunityMetadata/implementations/Erc20Snapshot.js +10 -0
  274. package/dist/src/engine/opportunityMetadata/implementations/Euler.d.ts +15 -0
  275. package/dist/src/engine/opportunityMetadata/implementations/Euler.js +34 -0
  276. package/dist/src/engine/opportunityMetadata/implementations/EventBased.d.ts +20 -0
  277. package/dist/src/engine/opportunityMetadata/implementations/EventBased.js +45 -0
  278. package/dist/src/engine/opportunityMetadata/implementations/Hyperdrive.d.ts +15 -0
  279. package/dist/src/engine/opportunityMetadata/implementations/Hyperdrive.js +21 -0
  280. package/dist/src/engine/opportunityMetadata/implementations/Invalid.d.ts +11 -0
  281. package/dist/src/engine/opportunityMetadata/implementations/Invalid.js +10 -0
  282. package/dist/src/engine/opportunityMetadata/implementations/Ion.d.ts +16 -0
  283. package/dist/src/engine/opportunityMetadata/implementations/Ion.js +15 -0
  284. package/dist/src/engine/opportunityMetadata/implementations/JsonAirdrop.d.ts +15 -0
  285. package/dist/src/engine/opportunityMetadata/implementations/JsonAirdrop.js +38 -0
  286. package/dist/src/engine/opportunityMetadata/implementations/Morpho.d.ts +15 -0
  287. package/dist/src/engine/opportunityMetadata/implementations/Morpho.js +21 -0
  288. package/dist/src/engine/opportunityMetadata/implementations/Radiant.d.ts +15 -0
  289. package/dist/src/engine/opportunityMetadata/implementations/Radiant.js +11 -0
  290. package/dist/src/engine/opportunityMetadata/implementations/Silo.d.ts +15 -0
  291. package/dist/src/engine/opportunityMetadata/implementations/Silo.js +15 -0
  292. package/dist/src/engine/opportunityMetadata/implementations/UniswapV4.d.ts +15 -0
  293. package/dist/src/engine/opportunityMetadata/implementations/UniswapV4.js +28 -0
  294. package/dist/src/engine/opportunityMetadata/implementations/Vest.d.ts +15 -0
  295. package/dist/src/engine/opportunityMetadata/implementations/Vest.js +12 -0
  296. package/dist/src/entities/campaign.d.ts +58 -0
  297. package/dist/src/entities/campaign.js +136 -0
  298. package/dist/src/errors/BadRequest.error.d.ts +4 -0
  299. package/dist/src/errors/BadRequest.error.js +7 -0
  300. package/dist/src/errors/Conflict.error.d.ts +4 -0
  301. package/dist/src/errors/Conflict.error.js +7 -0
  302. package/dist/src/errors/HttpError.d.ts +11 -0
  303. package/dist/src/errors/HttpError.js +17 -0
  304. package/dist/src/errors/NotFound.error.d.ts +8 -0
  305. package/dist/src/errors/NotFound.error.js +12 -0
  306. package/dist/src/errors/Opportunity.error.d.ts +6 -0
  307. package/dist/src/errors/Opportunity.error.js +11 -0
  308. package/dist/src/errors/Unauthorized.error.d.ts +4 -0
  309. package/dist/src/errors/Unauthorized.error.js +7 -0
  310. package/dist/src/errors/VoidString.error.d.ts +4 -0
  311. package/dist/src/errors/VoidString.error.js +7 -0
  312. package/dist/src/errors/index.d.ts +5 -0
  313. package/dist/src/errors/index.js +5 -0
  314. package/dist/src/guards/BackOffice.guard.d.ts +7 -0
  315. package/dist/src/guards/BackOffice.guard.js +10 -0
  316. package/dist/src/guards/Engine.guard.d.ts +7 -0
  317. package/dist/src/guards/Engine.guard.js +10 -0
  318. package/dist/src/guards/TokenAuth.guard.d.ts +7 -0
  319. package/dist/src/guards/TokenAuth.guard.js +10 -0
  320. package/dist/src/hooks/checkQueryAddressValidity.d.ts +22 -0
  321. package/dist/src/hooks/checkQueryAddressValidity.js +7 -0
  322. package/dist/src/hooks/checkQueryChainIdValidity.d.ts +22 -0
  323. package/dist/src/hooks/checkQueryChainIdValidity.js +7 -0
  324. package/dist/src/index.d.ts +5237 -0
  325. package/dist/src/index.js +111 -0
  326. package/dist/src/jobs/dynamic-data.d.ts +9 -0
  327. package/dist/src/jobs/dynamic-data.js +24 -0
  328. package/dist/src/jobs/pendings.d.ts +1 -0
  329. package/dist/src/jobs/pendings.js +236 -0
  330. package/dist/src/jobs/prices.d.ts +1 -0
  331. package/dist/src/jobs/prices.js +10 -0
  332. package/dist/src/jobs/reward-breakdowns.d.ts +1 -0
  333. package/dist/src/jobs/reward-breakdowns.js +152 -0
  334. package/dist/src/jobs/rewards.d.ts +1 -0
  335. package/dist/src/jobs/rewards.js +112 -0
  336. package/dist/src/jobs/set-dungeon-keeper.d.ts +1 -0
  337. package/dist/src/jobs/set-dungeon-keeper.js +82 -0
  338. package/dist/src/jobs/update-dynamic-data.d.ts +1 -0
  339. package/dist/src/jobs/update-dynamic-data.js +62 -0
  340. package/dist/src/jobs/update-euler-vaults.d.ts +1 -0
  341. package/dist/src/jobs/update-euler-vaults.js +122 -0
  342. package/dist/src/jobs/update-uniswap-v4-pools.d.ts +1 -0
  343. package/dist/src/jobs/update-uniswap-v4-pools.js +14 -0
  344. package/dist/src/libs/computeFee.d.ts +4 -0
  345. package/dist/src/libs/computeFee.js +34 -0
  346. package/dist/src/libs/deprecated-merklv3/index.d.ts +5 -0
  347. package/dist/src/libs/deprecated-merklv3/index.js +184 -0
  348. package/dist/src/libs/getTokensList.d.ts +23 -0
  349. package/dist/src/libs/getTokensList.js +19 -0
  350. package/dist/src/libs/merklChainData.d.ts +4 -0
  351. package/dist/src/libs/merklChainData.js +115 -0
  352. package/dist/src/libs/parse/marketsWithCache.d.ts +4 -0
  353. package/dist/src/libs/parse/marketsWithCache.js +8 -0
  354. package/dist/src/libs/positions/EigenLayer/index.d.ts +6 -0
  355. package/dist/src/libs/positions/EigenLayer/index.js +54 -0
  356. package/dist/src/libs/positions/ajna/index.d.ts +6 -0
  357. package/dist/src/libs/positions/ajna/index.js +107 -0
  358. package/dist/src/libs/positions/badger/index.d.ts +6 -0
  359. package/dist/src/libs/positions/badger/index.js +80 -0
  360. package/dist/src/libs/positions/clamm/index.d.ts +7 -0
  361. package/dist/src/libs/positions/clamm/index.js +412 -0
  362. package/dist/src/libs/positions/clamm/thegraph/fetchAlmPositions.d.ts +5 -0
  363. package/dist/src/libs/positions/clamm/thegraph/fetchAlmPositions.js +36 -0
  364. package/dist/src/libs/positions/clamm/thegraph/fetchAmmPositions.d.ts +8 -0
  365. package/dist/src/libs/positions/clamm/thegraph/fetchAmmPositions.js +36 -0
  366. package/dist/src/libs/positions/clamm/thegraph/fetchFarmedPositions.d.ts +10 -0
  367. package/dist/src/libs/positions/clamm/thegraph/fetchFarmedPositions.js +42 -0
  368. package/dist/src/libs/positions/clamm/thegraph/index.d.ts +40 -0
  369. package/dist/src/libs/positions/clamm/thegraph/index.js +163 -0
  370. package/dist/src/libs/positions/compound/index.d.ts +24 -0
  371. package/dist/src/libs/positions/compound/index.js +91 -0
  372. package/dist/src/libs/positions/dolomite/index.d.ts +17 -0
  373. package/dist/src/libs/positions/dolomite/index.js +51 -0
  374. package/dist/src/libs/positions/erc20/index.d.ts +5 -0
  375. package/dist/src/libs/positions/erc20/index.js +56 -0
  376. package/dist/src/libs/positions/euler/index.d.ts +5 -0
  377. package/dist/src/libs/positions/euler/index.js +57 -0
  378. package/dist/src/libs/positions/index.d.ts +3 -0
  379. package/dist/src/libs/positions/index.js +53 -0
  380. package/dist/src/libs/positions/morpho/index.d.ts +6 -0
  381. package/dist/src/libs/positions/morpho/index.js +177 -0
  382. package/dist/src/libs/positions/prepareFetch.d.ts +22 -0
  383. package/dist/src/libs/positions/prepareFetch.js +392 -0
  384. package/dist/src/libs/positions/silo/index.d.ts +5 -0
  385. package/dist/src/libs/positions/silo/index.js +68 -0
  386. package/dist/src/libs/positions/types.d.ts +75 -0
  387. package/dist/src/libs/positions/types.js +1 -0
  388. package/dist/src/libs/staticCampaigns.d.ts +7 -0
  389. package/dist/src/libs/staticCampaigns.js +15 -0
  390. package/dist/src/libs/tokens/allowances.d.ts +1 -0
  391. package/dist/src/libs/tokens/allowances.js +18 -0
  392. package/dist/src/libs/tokens/balances.d.ts +11 -0
  393. package/dist/src/libs/tokens/balances.js +127 -0
  394. package/dist/src/libs/tokens/tokenInfo.d.ts +8 -0
  395. package/dist/src/libs/tokens/tokenInfo.js +22 -0
  396. package/dist/src/modules/v4/accounting/accounting.controller.d.ts +219 -0
  397. package/dist/src/modules/v4/accounting/accounting.controller.js +66 -0
  398. package/dist/src/modules/v4/accounting/accounting.model.d.ts +32 -0
  399. package/dist/src/modules/v4/accounting/accounting.model.js +32 -0
  400. package/dist/src/modules/v4/accounting/accounting.repository.d.ts +99 -0
  401. package/dist/src/modules/v4/accounting/accounting.repository.js +100 -0
  402. package/dist/src/modules/v4/accounting/accounting.service.d.ts +59 -0
  403. package/dist/src/modules/v4/accounting/accounting.service.js +107 -0
  404. package/dist/src/modules/v4/accounting/index.d.ts +3 -0
  405. package/dist/src/modules/v4/accounting/index.js +3 -0
  406. package/dist/src/modules/v4/airflow/airflow.service.d.ts +3 -0
  407. package/dist/src/modules/v4/airflow/airflow.service.js +20 -0
  408. package/dist/src/modules/v4/apr/apr.model.d.ts +41 -0
  409. package/dist/src/modules/v4/apr/apr.model.js +15 -0
  410. package/dist/src/modules/v4/apr/apr.service.d.ts +6 -0
  411. package/dist/src/modules/v4/apr/apr.service.js +49 -0
  412. package/dist/src/modules/v4/apr/index.d.ts +2 -0
  413. package/dist/src/modules/v4/apr/index.js +2 -0
  414. package/dist/src/modules/v4/blacklist/blacklist.controller.d.ts +123 -0
  415. package/dist/src/modules/v4/blacklist/blacklist.controller.js +42 -0
  416. package/dist/src/modules/v4/blacklist/blacklist.model.d.ts +15 -0
  417. package/dist/src/modules/v4/blacklist/blacklist.model.js +13 -0
  418. package/dist/src/modules/v4/blacklist/blacklist.repository.d.ts +21 -0
  419. package/dist/src/modules/v4/blacklist/blacklist.repository.js +50 -0
  420. package/dist/src/modules/v4/blacklist/blacklist.service.d.ts +24 -0
  421. package/dist/src/modules/v4/blacklist/blacklist.service.js +31 -0
  422. package/dist/src/modules/v4/blacklist/index.d.ts +3 -0
  423. package/dist/src/modules/v4/blacklist/index.js +3 -0
  424. package/dist/src/modules/v4/boost/boost.controller.d.ts +88 -0
  425. package/dist/src/modules/v4/boost/boost.controller.js +15 -0
  426. package/dist/src/modules/v4/boost/boost.model.d.ts +12 -0
  427. package/dist/src/modules/v4/boost/boost.model.js +14 -0
  428. package/dist/src/modules/v4/boost/boost.service.d.ts +11 -0
  429. package/dist/src/modules/v4/boost/boost.service.js +20 -0
  430. package/dist/src/modules/v4/boost/index.d.ts +2 -0
  431. package/dist/src/modules/v4/boost/index.js +2 -0
  432. package/dist/src/modules/v4/bucket/bucket.model.d.ts +10 -0
  433. package/dist/src/modules/v4/bucket/bucket.model.js +85 -0
  434. package/dist/src/modules/v4/bucket/bucket.service.d.ts +11 -0
  435. package/dist/src/modules/v4/bucket/bucket.service.js +170 -0
  436. package/dist/src/modules/v4/cache/cache.model.d.ts +13 -0
  437. package/dist/src/modules/v4/cache/cache.model.js +14 -0
  438. package/dist/src/modules/v4/cache/cache.repository.d.ts +5 -0
  439. package/dist/src/modules/v4/cache/cache.repository.js +62 -0
  440. package/dist/src/modules/v4/cache/cache.service.d.ts +9 -0
  441. package/dist/src/modules/v4/cache/cache.service.js +50 -0
  442. package/dist/src/modules/v4/cache/index.d.ts +1 -0
  443. package/dist/src/modules/v4/cache/index.js +1 -0
  444. package/dist/src/modules/v4/campaign/campaign.controller.d.ts +632 -0
  445. package/dist/src/modules/v4/campaign/campaign.controller.js +149 -0
  446. package/dist/src/modules/v4/campaign/campaign.model.d.ts +165 -0
  447. package/dist/src/modules/v4/campaign/campaign.model.js +113 -0
  448. package/dist/src/modules/v4/campaign/campaign.repository.d.ts +735 -0
  449. package/dist/src/modules/v4/campaign/campaign.repository.js +448 -0
  450. package/dist/src/modules/v4/campaign/campaign.service.d.ts +728 -0
  451. package/dist/src/modules/v4/campaign/campaign.service.js +309 -0
  452. package/dist/src/modules/v4/campaign/index.d.ts +2 -0
  453. package/dist/src/modules/v4/campaign/index.js +2 -0
  454. package/dist/src/modules/v4/chain/chain.controller.d.ts +145 -0
  455. package/dist/src/modules/v4/chain/chain.controller.js +44 -0
  456. package/dist/src/modules/v4/chain/chain.model.d.ts +43 -0
  457. package/dist/src/modules/v4/chain/chain.model.js +38 -0
  458. package/dist/src/modules/v4/chain/chain.repository.d.ts +75 -0
  459. package/dist/src/modules/v4/chain/chain.repository.js +70 -0
  460. package/dist/src/modules/v4/chain/chain.service.d.ts +55 -0
  461. package/dist/src/modules/v4/chain/chain.service.js +48 -0
  462. package/dist/src/modules/v4/chainInteraction/chainInteraction.service.d.ts +2 -0
  463. package/dist/src/modules/v4/chainInteraction/chainInteraction.service.js +4 -0
  464. package/dist/src/modules/v4/claims/claims.controller.d.ts +42 -0
  465. package/dist/src/modules/v4/claims/claims.controller.js +18 -0
  466. package/dist/src/modules/v4/claims/claims.model.d.ts +9 -0
  467. package/dist/src/modules/v4/claims/claims.model.js +1 -0
  468. package/dist/src/modules/v4/claims/claims.repository.d.ts +5 -0
  469. package/dist/src/modules/v4/claims/claims.repository.js +39 -0
  470. package/dist/src/modules/v4/claims/claims.service.d.ts +9 -0
  471. package/dist/src/modules/v4/claims/claims.service.js +40 -0
  472. package/dist/src/modules/v4/computedValue/computedValue.controller.d.ts +119 -0
  473. package/dist/src/modules/v4/computedValue/computedValue.controller.js +45 -0
  474. package/dist/src/modules/v4/computedValue/computedValue.model.d.ts +27 -0
  475. package/dist/src/modules/v4/computedValue/computedValue.model.js +30 -0
  476. package/dist/src/modules/v4/computedValue/computedValue.repository.d.ts +16 -0
  477. package/dist/src/modules/v4/computedValue/computedValue.repository.js +48 -0
  478. package/dist/src/modules/v4/computedValue/computedValue.service.d.ts +16 -0
  479. package/dist/src/modules/v4/computedValue/computedValue.service.js +25 -0
  480. package/dist/src/modules/v4/computedValue/index.d.ts +2 -0
  481. package/dist/src/modules/v4/computedValue/index.js +2 -0
  482. package/dist/src/modules/v4/creator/creator.controller.d.ts +118 -0
  483. package/dist/src/modules/v4/creator/creator.controller.js +30 -0
  484. package/dist/src/modules/v4/creator/creator.model.d.ts +29 -0
  485. package/dist/src/modules/v4/creator/creator.model.js +18 -0
  486. package/dist/src/modules/v4/creator/creator.repository.d.ts +40 -0
  487. package/dist/src/modules/v4/creator/creator.repository.js +63 -0
  488. package/dist/src/modules/v4/creator/creator.service.d.ts +61 -0
  489. package/dist/src/modules/v4/creator/creator.service.js +44 -0
  490. package/dist/src/modules/v4/creator/index.d.ts +3 -0
  491. package/dist/src/modules/v4/creator/index.js +3 -0
  492. package/dist/src/modules/v4/dynamicData/dynamicData.controller.d.ts +49 -0
  493. package/dist/src/modules/v4/dynamicData/dynamicData.controller.js +19 -0
  494. package/dist/src/modules/v4/dynamicData/dynamicData.model.d.ts +60 -0
  495. package/dist/src/modules/v4/dynamicData/dynamicData.model.js +54 -0
  496. package/dist/src/modules/v4/dynamicData/dynamicData.repository.d.ts +0 -0
  497. package/dist/src/modules/v4/dynamicData/dynamicData.repository.js +1 -0
  498. package/dist/src/modules/v4/dynamicData/dynamicData.service.d.ts +14 -0
  499. package/dist/src/modules/v4/dynamicData/dynamicData.service.js +131 -0
  500. package/dist/src/modules/v4/enso/enso.model.d.ts +166 -0
  501. package/dist/src/modules/v4/enso/enso.model.js +147 -0
  502. package/dist/src/modules/v4/enso/enso.service.d.ts +69 -0
  503. package/dist/src/modules/v4/enso/enso.service.js +116 -0
  504. package/dist/src/modules/v4/explorer/explorer.controller.d.ts +45 -0
  505. package/dist/src/modules/v4/explorer/explorer.controller.js +13 -0
  506. package/dist/src/modules/v4/explorer/explorer.model.d.ts +16 -0
  507. package/dist/src/modules/v4/explorer/explorer.model.js +8 -0
  508. package/dist/src/modules/v4/explorer/explorer.repository.d.ts +21 -0
  509. package/dist/src/modules/v4/explorer/explorer.repository.js +23 -0
  510. package/dist/src/modules/v4/explorer/explorer.service.d.ts +28 -0
  511. package/dist/src/modules/v4/explorer/explorer.service.js +24 -0
  512. package/dist/src/modules/v4/interaction/interaction.controller.d.ts +97 -0
  513. package/dist/src/modules/v4/interaction/interaction.controller.js +40 -0
  514. package/dist/src/modules/v4/interaction/interaction.model.d.ts +110 -0
  515. package/dist/src/modules/v4/interaction/interaction.model.js +25 -0
  516. package/dist/src/modules/v4/interaction/interaction.service.d.ts +38 -0
  517. package/dist/src/modules/v4/interaction/interaction.service.js +95 -0
  518. package/dist/src/modules/v4/kyberzap/kyberzap.model.d.ts +114 -0
  519. package/dist/src/modules/v4/kyberzap/kyberzap.model.js +83 -0
  520. package/dist/src/modules/v4/kyberzap/kyberzap.service.d.ts +34 -0
  521. package/dist/src/modules/v4/kyberzap/kyberzap.service.js +176 -0
  522. package/dist/src/modules/v4/liquidity/implementations/AjnaPositionFetcher.d.ts +6 -0
  523. package/dist/src/modules/v4/liquidity/implementations/AjnaPositionFetcher.js +90 -0
  524. package/dist/src/modules/v4/liquidity/implementations/BadgerPositionFetcher.d.ts +6 -0
  525. package/dist/src/modules/v4/liquidity/implementations/BadgerPositionFetcher.js +69 -0
  526. package/dist/src/modules/v4/liquidity/implementations/ClammPositionFetcher.d.ts +6 -0
  527. package/dist/src/modules/v4/liquidity/implementations/ClammPositionFetcher.js +61 -0
  528. package/dist/src/modules/v4/liquidity/implementations/DolomitePositionFetcher.d.ts +6 -0
  529. package/dist/src/modules/v4/liquidity/implementations/DolomitePositionFetcher.js +45 -0
  530. package/dist/src/modules/v4/liquidity/implementations/ERC20PositionFetcher.d.ts +6 -0
  531. package/dist/src/modules/v4/liquidity/implementations/ERC20PositionFetcher.js +47 -0
  532. package/dist/src/modules/v4/liquidity/implementations/EulerPositionFetcher.d.ts +6 -0
  533. package/dist/src/modules/v4/liquidity/implementations/EulerPositionFetcher.js +40 -0
  534. package/dist/src/modules/v4/liquidity/liquidity.controller.d.ts +39 -0
  535. package/dist/src/modules/v4/liquidity/liquidity.controller.js +16 -0
  536. package/dist/src/modules/v4/liquidity/liquidity.model.d.ts +25 -0
  537. package/dist/src/modules/v4/liquidity/liquidity.model.js +5 -0
  538. package/dist/src/modules/v4/liquidity/liquidity.repository.d.ts +14 -0
  539. package/dist/src/modules/v4/liquidity/liquidity.repository.js +6 -0
  540. package/dist/src/modules/v4/liquidity/liquidity.service.d.ts +5 -0
  541. package/dist/src/modules/v4/liquidity/liquidity.service.js +34 -0
  542. package/dist/src/modules/v4/merklRoot/index.d.ts +3 -0
  543. package/dist/src/modules/v4/merklRoot/index.js +3 -0
  544. package/dist/src/modules/v4/merklRoot/merklRoot.controller.d.ts +93 -0
  545. package/dist/src/modules/v4/merklRoot/merklRoot.controller.js +31 -0
  546. package/dist/src/modules/v4/merklRoot/merklRoot.model.d.ts +13 -0
  547. package/dist/src/modules/v4/merklRoot/merklRoot.model.js +12 -0
  548. package/dist/src/modules/v4/merklRoot/merklRoot.repository.d.ts +29 -0
  549. package/dist/src/modules/v4/merklRoot/merklRoot.repository.js +35 -0
  550. package/dist/src/modules/v4/merklRoot/merklRoot.service.d.ts +46 -0
  551. package/dist/src/modules/v4/merklRoot/merklRoot.service.js +44 -0
  552. package/dist/src/modules/v4/opportunity/index.d.ts +3 -0
  553. package/dist/src/modules/v4/opportunity/index.js +3 -0
  554. package/dist/src/modules/v4/opportunity/opportunity.controller.d.ts +958 -0
  555. package/dist/src/modules/v4/opportunity/opportunity.controller.js +155 -0
  556. package/dist/src/modules/v4/opportunity/opportunity.converter.d.ts +10 -0
  557. package/dist/src/modules/v4/opportunity/opportunity.converter.js +174 -0
  558. package/dist/src/modules/v4/opportunity/opportunity.model.d.ts +357 -0
  559. package/dist/src/modules/v4/opportunity/opportunity.model.js +112 -0
  560. package/dist/src/modules/v4/opportunity/opportunity.repository.d.ts +985 -0
  561. package/dist/src/modules/v4/opportunity/opportunity.repository.js +430 -0
  562. package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +982 -0
  563. package/dist/src/modules/v4/opportunity/opportunity.service.js +302 -0
  564. package/dist/src/modules/v4/opportunity/transform-id.pipe.d.ts +5 -0
  565. package/dist/src/modules/v4/opportunity/transform-id.pipe.js +6 -0
  566. package/dist/src/modules/v4/opportunity/validate-id.pipe.d.ts +5 -0
  567. package/dist/src/modules/v4/opportunity/validate-id.pipe.js +12 -0
  568. package/dist/src/modules/v4/price/index.d.ts +3 -0
  569. package/dist/src/modules/v4/price/index.js +3 -0
  570. package/dist/src/modules/v4/price/price.controller.d.ts +185 -0
  571. package/dist/src/modules/v4/price/price.controller.js +55 -0
  572. package/dist/src/modules/v4/price/price.model.d.ts +32 -0
  573. package/dist/src/modules/v4/price/price.model.js +12 -0
  574. package/dist/src/modules/v4/price/price.repository.d.ts +36 -0
  575. package/dist/src/modules/v4/price/price.repository.js +22 -0
  576. package/dist/src/modules/v4/price/price.service.d.ts +40 -0
  577. package/dist/src/modules/v4/price/price.service.js +44 -0
  578. package/dist/src/modules/v4/prisma/index.d.ts +32 -0
  579. package/dist/src/modules/v4/prisma/index.js +1 -0
  580. package/dist/src/modules/v4/programPayload/programPayload.controller.d.ts +281 -0
  581. package/dist/src/modules/v4/programPayload/programPayload.controller.js +85 -0
  582. package/dist/src/modules/v4/programPayload/programPayload.model.d.ts +262 -0
  583. package/dist/src/modules/v4/programPayload/programPayload.model.js +176 -0
  584. package/dist/src/modules/v4/programPayload/programPayload.repository.d.ts +926 -0
  585. package/dist/src/modules/v4/programPayload/programPayload.repository.js +5418 -0
  586. package/dist/src/modules/v4/programPayload/programPayload.service.d.ts +26 -0
  587. package/dist/src/modules/v4/programPayload/programPayload.service.js +218 -0
  588. package/dist/src/modules/v4/protocol/protocol.controller.d.ts +155 -0
  589. package/dist/src/modules/v4/protocol/protocol.controller.js +38 -0
  590. package/dist/src/modules/v4/protocol/protocol.model.d.ts +55 -0
  591. package/dist/src/modules/v4/protocol/protocol.model.js +115 -0
  592. package/dist/src/modules/v4/protocol/protocol.repository.d.ts +79 -0
  593. package/dist/src/modules/v4/protocol/protocol.repository.js +81 -0
  594. package/dist/src/modules/v4/protocol/protocol.service.d.ts +24 -0
  595. package/dist/src/modules/v4/protocol/protocol.service.js +62 -0
  596. package/dist/src/modules/v4/referral/referral.controller.d.ts +82 -0
  597. package/dist/src/modules/v4/referral/referral.controller.js +25 -0
  598. package/dist/src/modules/v4/referral/referral.model.d.ts +10 -0
  599. package/dist/src/modules/v4/referral/referral.model.js +12 -0
  600. package/dist/src/modules/v4/referral/referral.service.d.ts +216 -0
  601. package/dist/src/modules/v4/referral/referral.service.js +171 -0
  602. package/dist/src/modules/v4/reward/index.d.ts +2 -0
  603. package/dist/src/modules/v4/reward/index.js +2 -0
  604. package/dist/src/modules/v4/reward/reward.controller.d.ts +338 -0
  605. package/dist/src/modules/v4/reward/reward.controller.js +124 -0
  606. package/dist/src/modules/v4/reward/reward.converter.d.ts +14 -0
  607. package/dist/src/modules/v4/reward/reward.converter.js +124 -0
  608. package/dist/src/modules/v4/reward/reward.model.d.ts +240 -0
  609. package/dist/src/modules/v4/reward/reward.model.js +159 -0
  610. package/dist/src/modules/v4/reward/reward.repository.d.ts +156 -0
  611. package/dist/src/modules/v4/reward/reward.repository.js +305 -0
  612. package/dist/src/modules/v4/reward/reward.service.d.ts +595 -0
  613. package/dist/src/modules/v4/reward/reward.service.js +347 -0
  614. package/dist/src/modules/v4/router.d.ts +4375 -0
  615. package/dist/src/modules/v4/router.js +76 -0
  616. package/dist/src/modules/v4/status/status.controller.d.ts +239 -0
  617. package/dist/src/modules/v4/status/status.controller.js +68 -0
  618. package/dist/src/modules/v4/status/status.model.d.ts +63 -0
  619. package/dist/src/modules/v4/status/status.model.js +34 -0
  620. package/dist/src/modules/v4/status/status.repository.d.ts +104 -0
  621. package/dist/src/modules/v4/status/status.repository.js +146 -0
  622. package/dist/src/modules/v4/status/status.service.d.ts +88 -0
  623. package/dist/src/modules/v4/status/status.service.js +144 -0
  624. package/dist/src/modules/v4/token/token.controller.d.ts +360 -0
  625. package/dist/src/modules/v4/token/token.controller.js +108 -0
  626. package/dist/src/modules/v4/token/token.model.d.ts +113 -0
  627. package/dist/src/modules/v4/token/token.model.js +74 -0
  628. package/dist/src/modules/v4/token/token.repository.d.ts +114 -0
  629. package/dist/src/modules/v4/token/token.repository.js +169 -0
  630. package/dist/src/modules/v4/token/token.service.d.ts +266 -0
  631. package/dist/src/modules/v4/token/token.service.js +422 -0
  632. package/dist/src/modules/v4/tracer/index.d.ts +1 -0
  633. package/dist/src/modules/v4/tracer/index.js +1 -0
  634. package/dist/src/modules/v4/tracer/tracer.service.d.ts +3 -0
  635. package/dist/src/modules/v4/tracer/tracer.service.js +30 -0
  636. package/dist/src/modules/v4/tvl/index.d.ts +2 -0
  637. package/dist/src/modules/v4/tvl/index.js +2 -0
  638. package/dist/src/modules/v4/tvl/tvl.model.d.ts +39 -0
  639. package/dist/src/modules/v4/tvl/tvl.model.js +15 -0
  640. package/dist/src/modules/v4/tvl/tvl.service.d.ts +6 -0
  641. package/dist/src/modules/v4/tvl/tvl.service.js +49 -0
  642. package/dist/src/modules/v4/uniswapV4/index.d.ts +4 -0
  643. package/dist/src/modules/v4/uniswapV4/index.js +4 -0
  644. package/dist/src/modules/v4/uniswapV4/uniswapV4.controller.d.ts +53 -0
  645. package/dist/src/modules/v4/uniswapV4/uniswapV4.controller.js +12 -0
  646. package/dist/src/modules/v4/uniswapV4/uniswapV4.model.d.ts +24 -0
  647. package/dist/src/modules/v4/uniswapV4/uniswapV4.model.js +17 -0
  648. package/dist/src/modules/v4/uniswapV4/uniswapV4.repository.d.ts +13 -0
  649. package/dist/src/modules/v4/uniswapV4/uniswapV4.repository.js +12 -0
  650. package/dist/src/modules/v4/uniswapV4/uniswapV4.service.d.ts +22 -0
  651. package/dist/src/modules/v4/uniswapV4/uniswapV4.service.js +247 -0
  652. package/dist/src/modules/v4/user/user.controller.d.ts +408 -0
  653. package/dist/src/modules/v4/user/user.controller.js +89 -0
  654. package/dist/src/modules/v4/user/user.model.d.ts +70 -0
  655. package/dist/src/modules/v4/user/user.model.js +67 -0
  656. package/dist/src/modules/v4/user/user.repository.d.ts +29 -0
  657. package/dist/src/modules/v4/user/user.repository.js +38 -0
  658. package/dist/src/modules/v4/user/user.service.d.ts +31 -0
  659. package/dist/src/modules/v4/user/user.service.js +67 -0
  660. package/dist/src/plugins/error-handling.plugin.d.ts +29 -0
  661. package/dist/src/plugins/error-handling.plugin.js +34 -0
  662. package/dist/src/routes/v1/allowances.d.ts +67 -0
  663. package/dist/src/routes/v1/allowances.js +115 -0
  664. package/dist/src/routes/v1/balances.d.ts +50 -0
  665. package/dist/src/routes/v1/balances.js +25 -0
  666. package/dist/src/routes/v1/prices.d.ts +42 -0
  667. package/dist/src/routes/v1/prices.js +9 -0
  668. package/dist/src/routes/v1/router.d.ts +102 -0
  669. package/dist/src/routes/v1/router.js +6 -0
  670. package/dist/src/routes/v1/tokens.d.ts +45 -0
  671. package/dist/src/routes/v1/tokens.js +17 -0
  672. package/dist/src/routes/v2/merkl.d.ts +55 -0
  673. package/dist/src/routes/v2/merkl.js +13 -0
  674. package/dist/src/routes/v2/router.d.ts +46 -0
  675. package/dist/src/routes/v2/router.js +3 -0
  676. package/dist/src/routes/v3/app.d.ts +48 -0
  677. package/dist/src/routes/v3/app.js +38 -0
  678. package/dist/src/routes/v3/blacklist.d.ts +45 -0
  679. package/dist/src/routes/v3/blacklist.js +19 -0
  680. package/dist/src/routes/v3/campaign/delay.d.ts +49 -0
  681. package/dist/src/routes/v3/campaign/delay.js +81 -0
  682. package/dist/src/routes/v3/campaignClaims.d.ts +48 -0
  683. package/dist/src/routes/v3/campaignClaims.js +29 -0
  684. package/dist/src/routes/v3/campaignUnclaimed.d.ts +47 -0
  685. package/dist/src/routes/v3/campaignUnclaimed.js +28 -0
  686. package/dist/src/routes/v3/campaigns.d.ts +58 -0
  687. package/dist/src/routes/v3/campaigns.js +136 -0
  688. package/dist/src/routes/v3/campaignsForMainParameter.d.ts +54 -0
  689. package/dist/src/routes/v3/campaignsForMainParameter.js +33 -0
  690. package/dist/src/routes/v3/campaignsRewardsReport.d.ts +47 -0
  691. package/dist/src/routes/v3/campaignsRewardsReport.js +48 -0
  692. package/dist/src/routes/v3/claims.d.ts +48 -0
  693. package/dist/src/routes/v3/claims.js +16 -0
  694. package/dist/src/routes/v3/compoundV2.d.ts +42 -0
  695. package/dist/src/routes/v3/compoundV2.js +9 -0
  696. package/dist/src/routes/v3/createCampaign.d.ts +47 -0
  697. package/dist/src/routes/v3/createCampaign.js +66 -0
  698. package/dist/src/routes/v3/dolomite.d.ts +46 -0
  699. package/dist/src/routes/v3/dolomite.js +12 -0
  700. package/dist/src/routes/v3/euler.d.ts +53 -0
  701. package/dist/src/routes/v3/euler.js +17 -0
  702. package/dist/src/routes/v3/fetch.d.ts +46 -0
  703. package/dist/src/routes/v3/fetch.js +27 -0
  704. package/dist/src/routes/v3/health.d.ts +40 -0
  705. package/dist/src/routes/v3/health.js +13 -0
  706. package/dist/src/routes/v3/lostyield.d.ts +53 -0
  707. package/dist/src/routes/v3/lostyield.js +101 -0
  708. package/dist/src/routes/v3/merkl.d.ts +88 -0
  709. package/dist/src/routes/v3/merkl.js +119 -0
  710. package/dist/src/routes/v3/morphoMarkets.d.ts +62 -0
  711. package/dist/src/routes/v3/morphoMarkets.js +27 -0
  712. package/dist/src/routes/v3/morphoVaults.d.ts +52 -0
  713. package/dist/src/routes/v3/morphoVaults.js +22 -0
  714. package/dist/src/routes/v3/multiChainPositions.d.ts +45 -0
  715. package/dist/src/routes/v3/multiChainPositions.js +70 -0
  716. package/dist/src/routes/v3/opportunity.d.ts +52 -0
  717. package/dist/src/routes/v3/opportunity.js +28 -0
  718. package/dist/src/routes/v3/overview.d.ts +78 -0
  719. package/dist/src/routes/v3/overview.js +72 -0
  720. package/dist/src/routes/v3/parse.d.ts +47 -0
  721. package/dist/src/routes/v3/parse.js +23 -0
  722. package/dist/src/routes/v3/payload.d.ts +58 -0
  723. package/dist/src/routes/v3/payload.js +40 -0
  724. package/dist/src/routes/v3/poolInfo.d.ts +43 -0
  725. package/dist/src/routes/v3/poolInfo.js +88 -0
  726. package/dist/src/routes/v3/positions.d.ts +62 -0
  727. package/dist/src/routes/v3/positions.js +62 -0
  728. package/dist/src/routes/v3/radiant.d.ts +56 -0
  729. package/dist/src/routes/v3/radiant.js +26 -0
  730. package/dist/src/routes/v3/recipients.d.ts +46 -0
  731. package/dist/src/routes/v3/recipients.js +29 -0
  732. package/dist/src/routes/v3/rewards.d.ts +73 -0
  733. package/dist/src/routes/v3/rewards.js +36 -0
  734. package/dist/src/routes/v3/rewardsReport.d.ts +56 -0
  735. package/dist/src/routes/v3/rewardsReport.js +40 -0
  736. package/dist/src/routes/v3/router.d.ts +752 -0
  737. package/dist/src/routes/v3/router.js +70 -0
  738. package/dist/src/routes/v3/silo.d.ts +53 -0
  739. package/dist/src/routes/v3/silo.js +20 -0
  740. package/dist/src/routes/v3/token.d.ts +51 -0
  741. package/dist/src/routes/v3/token.js +24 -0
  742. package/dist/src/routes/v3/twt/participants.d.ts +41 -0
  743. package/dist/src/routes/v3/twt/participants.js +63 -0
  744. package/dist/src/routes/v3/uniswapv4.d.ts +42 -0
  745. package/dist/src/routes/v3/uniswapv4.js +9 -0
  746. package/dist/src/routes/v3/updates.d.ts +53 -0
  747. package/dist/src/routes/v3/updates.js +47 -0
  748. package/dist/src/routes/v3/userRewards.d.ts +69 -0
  749. package/dist/src/routes/v3/userRewards.js +62 -0
  750. package/dist/src/types/external/spectraAPI.d.ts +88 -0
  751. package/dist/src/types/external/spectraAPI.js +1 -0
  752. package/dist/src/types/index.d.ts +20 -0
  753. package/dist/src/types/index.js +1 -0
  754. package/dist/src/types/returnTypes.d.ts +19 -0
  755. package/dist/src/types/returnTypes.js +1 -0
  756. package/dist/src/types/utils.d.ts +5 -0
  757. package/dist/src/types/utils.js +1 -0
  758. package/dist/src/utils/bigintToString.d.ts +1 -0
  759. package/dist/src/utils/bigintToString.js +20 -0
  760. package/dist/src/utils/caseChanges.d.ts +3 -0
  761. package/dist/src/utils/caseChanges.js +12 -0
  762. package/dist/src/utils/decodeCalls.d.ts +3 -0
  763. package/dist/src/utils/decodeCalls.js +306 -0
  764. package/dist/src/utils/encodeCalls.d.ts +3 -0
  765. package/dist/src/utils/encodeCalls.js +490 -0
  766. package/dist/src/utils/error.d.ts +60 -0
  767. package/dist/src/utils/error.js +102 -0
  768. package/dist/src/utils/execute.d.ts +22 -0
  769. package/dist/src/utils/execute.js +117 -0
  770. package/dist/src/utils/generateCardName.d.ts +6 -0
  771. package/dist/src/utils/generateCardName.js +198 -0
  772. package/dist/src/utils/generateIcons.d.ts +3 -0
  773. package/dist/src/utils/generateIcons.js +65 -0
  774. package/dist/src/utils/generic.d.ts +7 -0
  775. package/dist/src/utils/generic.js +43 -0
  776. package/dist/src/utils/hashArray.d.ts +2 -0
  777. package/dist/src/utils/hashArray.js +7 -0
  778. package/dist/src/utils/lastBlockBefore.d.ts +3 -0
  779. package/dist/src/utils/lastBlockBefore.js +78 -0
  780. package/dist/src/utils/logger.d.ts +62 -0
  781. package/dist/src/utils/logger.js +52 -0
  782. package/dist/src/utils/pricer.d.ts +54 -0
  783. package/dist/src/utils/pricer.js +189 -0
  784. package/dist/src/utils/prices/chainlinkRead.d.ts +4 -0
  785. package/dist/src/utils/prices/chainlinkRead.js +8 -0
  786. package/dist/src/utils/prices/curveVirtualPrice.d.ts +4 -0
  787. package/dist/src/utils/prices/curveVirtualPrice.js +7 -0
  788. package/dist/src/utils/prices/getDQUICK.d.ts +4 -0
  789. package/dist/src/utils/prices/getDQUICK.js +8 -0
  790. package/dist/src/utils/prices/priceFetcherFactory.d.ts +10 -0
  791. package/dist/src/utils/prices/priceFetcherFactory.js +29 -0
  792. package/dist/src/utils/prices/priceService.d.ts +13 -0
  793. package/dist/src/utils/prices/priceService.js +308 -0
  794. package/dist/src/utils/prices/services/coinGeckoService.d.ts +12 -0
  795. package/dist/src/utils/prices/services/coinGeckoService.js +61 -0
  796. package/dist/src/utils/prices/services/defillamaService.d.ts +12 -0
  797. package/dist/src/utils/prices/services/defillamaService.js +53 -0
  798. package/dist/src/utils/prices/services/dexScreenerService.d.ts +12 -0
  799. package/dist/src/utils/prices/services/dexScreenerService.js +62 -0
  800. package/dist/src/utils/prices/services/erc4626Service.d.ts +9 -0
  801. package/dist/src/utils/prices/services/erc4626Service.js +38 -0
  802. package/dist/src/utils/prices/services/getERC4626.d.ts +4 -0
  803. package/dist/src/utils/prices/services/getERC4626.js +11 -0
  804. package/dist/src/utils/prices/services/indexCoopService.d.ts +12 -0
  805. package/dist/src/utils/prices/services/indexCoopService.js +55 -0
  806. package/dist/src/utils/prices/services/priceFetcher.d.ts +8 -0
  807. package/dist/src/utils/prices/services/priceFetcher.js +1 -0
  808. package/dist/src/utils/prices/uniV2Price.d.ts +7 -0
  809. package/dist/src/utils/prices/uniV2Price.js +40 -0
  810. package/dist/src/utils/providers.d.ts +13 -0
  811. package/dist/src/utils/providers.js +37 -0
  812. package/dist/src/utils/queries/allCampaigns.d.ts +2 -0
  813. package/dist/src/utils/queries/allCampaigns.js +12 -0
  814. package/dist/src/utils/stryke.d.ts +2 -0
  815. package/dist/src/utils/stryke.js +4 -0
  816. package/dist/src/utils/throw.d.ts +21 -0
  817. package/dist/src/utils/throw.js +44 -0
  818. package/dist/tsconfig.package.tsbuildinfo +1 -0
  819. package/package.json +109 -0
@@ -0,0 +1,347 @@
1
+ import { log } from "@/utils/logger";
2
+ import { Campaign as CampaignEnum, DAY, DistributorService, NETWORK_LABELS, } from "@sdk";
3
+ import moment from "moment";
4
+ import { BlacklistService } from "../blacklist";
5
+ import { CacheService } from "../cache";
6
+ import { TTLPresets } from "../cache/cache.model";
7
+ import { CampaignService } from "../campaign";
8
+ import { ChainService } from "../chain/chain.service";
9
+ import { MerklRootService } from "../merklRoot";
10
+ import { OpportunityService } from "../opportunity";
11
+ import { TokenService } from "../token/token.service";
12
+ import { RewardRepository } from "./reward.repository";
13
+ export class RewardService {
14
+ static hashId(root, recipient, rewardTokenId) {
15
+ return Bun.hash(`${root}${recipient}${rewardTokenId}`).toString();
16
+ }
17
+ static hashDailyRewardsRecordId(opportunityId, timestamp) {
18
+ return Bun.hash(`${opportunityId}${timestamp}`).toString();
19
+ }
20
+ static async createManyReward(rewards) {
21
+ return await RewardRepository.createManyReward(rewards);
22
+ }
23
+ /**
24
+ * Format the reward breakdown to conform to its resource model declaration
25
+ * @param breakdown straight from db
26
+ * @returns a RewardBreakdown model
27
+ */
28
+ static formatBreakdown(breakdown) {
29
+ const { Campaign, id, rewardId, protocolId, ...rest } = breakdown;
30
+ return {
31
+ ...rest,
32
+ campaignId: Campaign.campaignId,
33
+ opportunity: Campaign.Opportunity,
34
+ };
35
+ }
36
+ /**
37
+ * Format the reward to conform to its resource model declaration
38
+ * @param reward straight from db
39
+ * @returns a Reward model
40
+ */
41
+ static format(rewards) {
42
+ return rewards.map(reward => {
43
+ const { Breakdown, RewardToken, id, rewardTokenId, ...rest } = reward;
44
+ return {
45
+ ...rest,
46
+ token: RewardToken,
47
+ breakdowns: Breakdown.map(RewardService.formatBreakdown),
48
+ claimed: BigInt(rest.claimed),
49
+ amount: BigInt(rest.amount),
50
+ pending: BigInt(rest.pending),
51
+ };
52
+ });
53
+ }
54
+ static async createManyBreakdown(data) {
55
+ const missingCampaigns = [];
56
+ const foundCampaigns = [];
57
+ for (const dataPerCampaign of data) {
58
+ const campaignUnique = {
59
+ distributionChain: dataPerCampaign.distributionChainId,
60
+ campaignId: dataPerCampaign.campaignId,
61
+ };
62
+ const campaignExists = await CampaignService.checkIfExist(campaignUnique);
63
+ if (!campaignExists) {
64
+ const { success, fail } = await CampaignService.fill([campaignUnique]);
65
+ if (fail === 1 || success !== 1) {
66
+ missingCampaigns.push(CampaignService.hashId(campaignUnique));
67
+ log.warn(`createManyBreakdown - Missing campaign: ${campaignUnique.campaignId} on ${NETWORK_LABELS[campaignUnique.distributionChain]}`);
68
+ continue;
69
+ }
70
+ }
71
+ foundCampaigns.push(CampaignService.hashId(campaignUnique));
72
+ }
73
+ try {
74
+ return await RewardRepository.createManyBreakdown(data.filter(dataPerCampaign => !missingCampaigns.includes(CampaignService.hashId({
75
+ distributionChain: dataPerCampaign.distributionChainId,
76
+ campaignId: dataPerCampaign.campaignId,
77
+ }))));
78
+ }
79
+ catch (e) {
80
+ log.error(`createManyBreakdown - error creating many breakdowns for campaigns ${foundCampaigns.join(", ")}`, e);
81
+ }
82
+ }
83
+ static async getByRecipient(recipient, roots, withToken = false, withTestTokens = false, chainFilter) {
84
+ return RewardRepository.getByRecipient(recipient, roots, withToken, withTestTokens, chainFilter);
85
+ }
86
+ /**
87
+ * Groups a breakdown array by their corresponding opportunities
88
+ * @param breakdowns with campaignIds
89
+ * @returns array of breakdown group, including the opportunity they belong to
90
+ */
91
+ static splitBreakdownByOpportunity(breakdowns) {
92
+ const opportunities = breakdowns.reduce((aux, { opportunity }) => {
93
+ if (!aux.some(o => o.id === opportunity.id))
94
+ aux.push(opportunity);
95
+ return aux;
96
+ }, []);
97
+ if (!opportunities)
98
+ return [];
99
+ return opportunities.map(opportunity => {
100
+ const relatedBreakdowns = breakdowns.filter(b => opportunity.id.includes(b.opportunity.id));
101
+ const formattedOpportunity = OpportunityService.formatResponseBase(opportunity);
102
+ return {
103
+ opportunity: formattedOpportunity,
104
+ claimed: relatedBreakdowns.reduce((total, { claimed }) => total + BigInt(claimed), 0n),
105
+ amount: relatedBreakdowns.reduce((total, { amount }) => total + BigInt(amount), 0n),
106
+ pending: relatedBreakdowns.reduce((total, { pending }) => total + BigInt(pending), 0n),
107
+ };
108
+ });
109
+ }
110
+ /**
111
+ * Applies the splitBreakdownByOpportunity function to each rewards in the array
112
+ * @param rewards return type for most of the rewards functions
113
+ * @returns rewards with updated breakdowns, including the opportunity they belong to
114
+ */
115
+ static splitRewardsBreakdownByOpportunity(rewards) {
116
+ return rewards.map(rewardByChain => {
117
+ const rewards = rewardByChain.rewards.map(reward => {
118
+ const breakdowns = RewardService.splitBreakdownByOpportunity(reward.breakdowns);
119
+ return Object.assign(reward, { breakdowns });
120
+ });
121
+ const distributor = DistributorService(rewardByChain.chain.id).address;
122
+ return Object.assign(rewardByChain, { rewards }, { distributor });
123
+ });
124
+ }
125
+ static removeOpportunityFromRewardBreakdown(rewards) {
126
+ return rewards.map(rewardByChain => {
127
+ const rewards = rewardByChain.rewards.map(reward => {
128
+ const breakdowns = reward.breakdowns.map(breakdown => {
129
+ const { opportunity, ...rest } = breakdown;
130
+ return rest;
131
+ });
132
+ return Object.assign(reward, { breakdowns });
133
+ });
134
+ return Object.assign(rewardByChain, { rewards });
135
+ });
136
+ }
137
+ static async findManyRootsOnChain(chainId) {
138
+ return await CacheService.wrap(TTLPresets.MIN_10, RewardRepository.findManyRootsWithRewardOnChain, chainId);
139
+ }
140
+ static async checkLastClaim(chainId, user, roots, rewards) {
141
+ const claims = await DistributorService(chainId).claimedMultiple(user, rewards.map(reward => reward.RewardToken.address));
142
+ const rootsWithRewardOnChain = await RewardService.findManyRootsOnChain(chainId);
143
+ for (const [index, reward] of rewards.entries()) {
144
+ const tokenId = TokenService.hashId(reward.RewardToken);
145
+ const merklRootClaimedOn = claims[index].merkleRoot;
146
+ // -> claim is on the current root (chainData.merklRoot) -> claimed === accumulated
147
+ if (merklRootClaimedOn === roots.live) {
148
+ reward.claimed = reward.amount;
149
+ await RewardRepository.updateRewardClaimed(user, tokenId, reward.amount);
150
+ for (const breakdown of reward.Breakdown) {
151
+ if (BigInt(breakdown.claimed) === BigInt(breakdown.amount))
152
+ continue;
153
+ breakdown.claimed = breakdown.amount; // Set unclaim to 0
154
+ await RewardRepository.updateBreakdownClaimed(user, tokenId, reward.Breakdown[0].campaignId, reward.Breakdown[0].reason, reward.Breakdown[0].amount);
155
+ }
156
+ }
157
+ // -> claim is on a tree we have in db -> claimed === accumulated of the rewards of lastTree
158
+ else if (rootsWithRewardOnChain.includes(merklRootClaimedOn)) {
159
+ const lastTreeRewards = await RewardRepository.getByChainRecipientToken(user, merklRootClaimedOn, TokenService.hashId(reward.RewardToken));
160
+ if (!lastTreeRewards)
161
+ continue;
162
+ reward.claimed = lastTreeRewards.amount;
163
+ await RewardRepository.updateRewardClaimed(user, tokenId, lastTreeRewards.amount);
164
+ for (const breakdown of reward.Breakdown) {
165
+ const lastTreeRewardsBreakdown = lastTreeRewards.Breakdown.find(lastTreeBreakdown => lastTreeBreakdown.reason === breakdown.reason &&
166
+ lastTreeBreakdown.Campaign.campaignId === breakdown.Campaign.campaignId);
167
+ if (!lastTreeRewardsBreakdown)
168
+ continue;
169
+ breakdown.claimed = lastTreeRewardsBreakdown.amount;
170
+ await RewardRepository.updateBreakdownClaimed(user, tokenId, breakdown.campaignId, breakdown.reason, breakdown.amount);
171
+ }
172
+ }
173
+ }
174
+ return rewards;
175
+ }
176
+ static async getUserRewardsByChain(user, withToken, chainFilter = [], connectedChainId = null, withTestTokens = false) {
177
+ const chains = await ChainService.findMany({});
178
+ let chainIds = !chainFilter || !chainFilter.length
179
+ ? chains.map(({ id }) => id)
180
+ : chains.map(({ id }) => id).filter(id => chainFilter.includes(id));
181
+ /** Check if the user is blacklisted */
182
+ const isBlacklisted = !!(await BlacklistService.isBlacklisted(user));
183
+ const res = [];
184
+ if (isBlacklisted)
185
+ return res;
186
+ /** Fetch current Merkle Roots */
187
+ const merkleRootsPromises = await Promise.allSettled(chainIds.map(chainId => MerklRootService.fetch(chainId)));
188
+ /** Filter out unsuccessful chainIds */
189
+ chainIds = chainIds.filter((_, index) => merkleRootsPromises[index].status === "fulfilled");
190
+ const merkleRoots = merkleRootsPromises
191
+ .filter(({ status }) => status === "fulfilled")
192
+ .map(x => x.value);
193
+ /** Load rewards from api DB */
194
+ const rewards = (await RewardService.getByRecipient(user, merkleRoots.map(({ live }) => live), withToken, withTestTokens)).filter(reward => chainIds.includes(reward.RewardToken.chainId));
195
+ const promises = [];
196
+ for (const [index, chainId] of chainIds.entries()) {
197
+ const chain = chains.find(chain => chain.id === chainId);
198
+ if (!chain)
199
+ throw new Error(`Chain ${chainId} not found`);
200
+ const chainRewards = rewards.filter(reward => reward.RewardToken.chainId === chainId);
201
+ /** Check when the last claim happened */
202
+ if (chain.id === connectedChainId && chainRewards.length > 0) {
203
+ promises.push(RewardService.checkLastClaim(chainId, user, merkleRoots[index], chainRewards).then(r => {
204
+ return { chain, rewards: r };
205
+ }));
206
+ }
207
+ else if (chainRewards.length > 0) {
208
+ promises.push(Promise.resolve({ chain, rewards: chainRewards }));
209
+ }
210
+ }
211
+ const settledPromises = await Promise.allSettled(promises);
212
+ for (const promise of settledPromises) {
213
+ if (promise.status === "rejected") {
214
+ log.error("checkLastClaim failed", promise.reason);
215
+ }
216
+ else {
217
+ res.push({ chain: promise.value.chain, rewards: RewardService.format(promise.value.rewards) });
218
+ }
219
+ }
220
+ return res;
221
+ }
222
+ static async registerClaims(claims) {
223
+ for (const claim of claims) {
224
+ const tokenId = TokenService.hashId({
225
+ chainId: claim.chainId,
226
+ address: claim.token,
227
+ });
228
+ const rewards = await RewardRepository.getByChainRecipientToken(claim.recipient, claim.root, tokenId);
229
+ if (!rewards)
230
+ continue;
231
+ await RewardRepository.updateRewardClaimed(claim.recipient, tokenId, rewards.amount);
232
+ for (const breakdown of rewards.Breakdown) {
233
+ await RewardRepository.updateBreakdownClaimed(claim.recipient, tokenId, breakdown.campaignId, breakdown.reason, breakdown.amount);
234
+ }
235
+ }
236
+ }
237
+ static async countOnChain(chainId) {
238
+ const roots = await MerklRootService.fetch(chainId);
239
+ const promises = [
240
+ RewardRepository.countRewardAndBreakdownOnChain(chainId, roots.tree),
241
+ RewardRepository.countRewardAndBreakdownOnChain(chainId, roots.lastTree),
242
+ ];
243
+ await Promise.all(promises);
244
+ return {
245
+ [roots.tree]: await promises[0],
246
+ [roots.lastTree]: await promises[1],
247
+ };
248
+ }
249
+ static async breakdownForCampaign(query) {
250
+ const root = await MerklRootService.fetch(query.chainId);
251
+ const id = CampaignService.hashId({ distributionChain: query.chainId, campaignId: query.campaignId });
252
+ return RewardRepository.breakdownForCampaign(root.live, id, query);
253
+ }
254
+ static async countForCampaign(query) {
255
+ const root = await MerklRootService.fetch(query.chainId);
256
+ const id = CampaignService.hashId({ distributionChain: query.chainId, campaignId: query.campaignId });
257
+ return RewardRepository.countForCampaign(id, root.live);
258
+ }
259
+ static async totalForCampaign(query) {
260
+ const root = await MerklRootService.fetch(query.chainId);
261
+ return RewardRepository.totalForCampaign(CampaignService.hashId({ distributionChain: query.chainId, campaignId: query.campaignId }), root.live);
262
+ }
263
+ static async breakdownForToken(query) {
264
+ return CacheService.wrap(TTLPresets.MIN_10, async (query) => {
265
+ const root = await MerklRootService.fetch(query.chainId);
266
+ const id = TokenService.hashId({ chainId: query.chainId, address: query.address });
267
+ return RewardRepository.breakdownForToken(root.live, id, query);
268
+ }, query);
269
+ }
270
+ static async countForToken(query) {
271
+ return CacheService.wrap(TTLPresets.MIN_10, async (query) => {
272
+ const root = await MerklRootService.fetch(query.chainId);
273
+ const id = TokenService.hashId({ chainId: query.chainId, address: query.address });
274
+ return RewardRepository.countForToken(id, root.live);
275
+ }, query);
276
+ }
277
+ static async totalForToken(query) {
278
+ return CacheService.wrap(TTLPresets.MIN_10, async (query) => {
279
+ const root = await MerklRootService.fetch(query.chainId);
280
+ const id = TokenService.hashId({ chainId: query.chainId, address: query.address });
281
+ return RewardRepository.totalForToken(id, root.live);
282
+ }, query);
283
+ }
284
+ static async getAmountAndClaimedForCampaigns(x) {
285
+ const currentRoot = await MerklRootService.fetch(x.chainId);
286
+ return await RewardRepository.getAmountAndClaimedForCampaigns(currentRoot.live, x);
287
+ }
288
+ static async getUnclaimed(x) {
289
+ const campaignToCampaignIds = x.campaignIds.reduce((acc, campaignId) => {
290
+ acc[CampaignService.hashId({ distributionChain: x.chainId, campaignId })] = campaignId;
291
+ return acc;
292
+ }, {});
293
+ const data = await RewardService.getAmountAndClaimedForCampaigns(x);
294
+ return data.reduce((acc, { amount, campaignId, claimed }) => {
295
+ if (!acc[campaignToCampaignIds[campaignId]])
296
+ acc[campaignToCampaignIds[campaignId]] = "0";
297
+ acc[campaignToCampaignIds[campaignId]] = (BigInt(acc[campaignToCampaignIds[campaignId]]) +
298
+ BigInt(amount) -
299
+ BigInt(claimed)).toString();
300
+ return acc;
301
+ }, {});
302
+ }
303
+ static async extractDailyRewardsRecordFromDynamicData(type, dynamicData, timestamp = BigInt(moment().unix())) {
304
+ const typesWithoutApr = [CampaignEnum.INVALID];
305
+ if (typesWithoutApr.includes(type))
306
+ return { timestamp, total: 0, breakdowns: [] };
307
+ const breakdowns = [];
308
+ for (const { amount, rewardToken, chainId, startTimestamp: start, endTimestamp: end, campaignId } of dynamicData) {
309
+ if (end < moment().unix())
310
+ continue;
311
+ const timespan = Number(end - start);
312
+ const isWithinTimespan = moment().unix() > start && moment().unix() < end;
313
+ const dayspan = Math.max(1, Math.floor(timespan / DAY));
314
+ const dailyAmount = isWithinTimespan ? BigInt(amount) / BigInt(dayspan) : BigInt(0);
315
+ const campaignIdInDb = CampaignService.hashId({ campaignId, distributionChain: chainId });
316
+ const tokenToAmount = new Map();
317
+ tokenToAmount.set(TokenService.hashId({ address: rewardToken, chainId }), dailyAmount);
318
+ try {
319
+ let token;
320
+ try {
321
+ token = await TokenService.findUniqueOrThrow({ address: rewardToken, chainId });
322
+ }
323
+ catch {
324
+ await TokenService.findManyOrCreate([{ address: rewardToken, chainId }]);
325
+ token = await TokenService.findUniqueOrThrow({ address: rewardToken, chainId });
326
+ }
327
+ const campaignDailyValue = await TokenService.getValueByTokenId(tokenToAmount);
328
+ breakdowns.push({
329
+ campaignId: campaignIdInDb,
330
+ value: campaignDailyValue,
331
+ amount: dailyAmount,
332
+ token,
333
+ });
334
+ }
335
+ catch (_err) {
336
+ log.warn(`token ${rewardToken} not found`);
337
+ }
338
+ }
339
+ return {
340
+ timestamp,
341
+ total: breakdowns.reduce((sum, { value }) => {
342
+ return sum + value;
343
+ }, 0),
344
+ breakdowns,
345
+ };
346
+ }
347
+ }