@merkl/api 0.19.7 → 0.19.8

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 (293) hide show
  1. package/dist/src/backgroundJobs/jobs/campaignsCacheUpdater.js +4 -3
  2. package/dist/src/eden/index.d.ts +15 -48
  3. package/dist/src/engine/dynamicData/factory.d.ts +3 -0
  4. package/dist/src/engine/dynamicData/factory.js +54 -0
  5. package/dist/src/engine/dynamicData/implementations/Ajna.d.ts +7 -0
  6. package/dist/src/engine/dynamicData/implementations/Ajna.js +101 -0
  7. package/dist/src/engine/dynamicData/implementations/Ambiant.d.ts +7 -0
  8. package/dist/src/engine/dynamicData/implementations/Ambiant.js +227 -0
  9. package/dist/src/engine/dynamicData/implementations/Badger.d.ts +7 -0
  10. package/dist/src/engine/dynamicData/implementations/Badger.js +84 -0
  11. package/dist/src/engine/dynamicData/implementations/Clamm.d.ts +7 -0
  12. package/dist/src/engine/dynamicData/implementations/Clamm.js +970 -0
  13. package/dist/src/engine/dynamicData/implementations/Compound.d.ts +7 -0
  14. package/dist/src/engine/dynamicData/implementations/Compound.js +136 -0
  15. package/dist/src/engine/dynamicData/implementations/Dolomite.d.ts +7 -0
  16. package/dist/src/engine/dynamicData/implementations/Dolomite.js +53 -0
  17. package/dist/src/engine/dynamicData/implementations/EigenLayer.d.ts +7 -0
  18. package/dist/src/engine/dynamicData/implementations/EigenLayer.js +64 -0
  19. package/dist/src/engine/dynamicData/implementations/Encompassing.d.ts +7 -0
  20. package/dist/src/engine/dynamicData/implementations/Encompassing.js +26 -0
  21. package/dist/src/engine/dynamicData/implementations/Erc20.d.ts +6 -0
  22. package/dist/src/engine/dynamicData/implementations/Erc20.js +159 -0
  23. package/dist/src/engine/dynamicData/implementations/Erc20Snapshot.d.ts +7 -0
  24. package/dist/src/engine/dynamicData/implementations/Erc20Snapshot.js +32 -0
  25. package/dist/src/engine/dynamicData/implementations/EventBased.d.ts +7 -0
  26. package/dist/src/engine/dynamicData/implementations/EventBased.js +104 -0
  27. package/dist/src/engine/dynamicData/implementations/Hyperdrive.d.ts +7 -0
  28. package/dist/src/engine/dynamicData/implementations/Hyperdrive.js +96 -0
  29. package/dist/src/engine/dynamicData/implementations/Morpho.d.ts +7 -0
  30. package/dist/src/engine/dynamicData/implementations/Morpho.js +109 -0
  31. package/dist/src/engine/dynamicData/implementations/Radiant.d.ts +7 -0
  32. package/dist/src/engine/dynamicData/implementations/Radiant.js +117 -0
  33. package/dist/src/engine/dynamicData/implementations/Silo.d.ts +9 -0
  34. package/dist/src/engine/dynamicData/implementations/Silo.js +109 -0
  35. package/dist/src/engine/dynamicData/implementations/UniswapV4.d.ts +7 -0
  36. package/dist/src/engine/dynamicData/implementations/UniswapV4.js +249 -0
  37. package/dist/src/engine/dynamicData/implementations/Vest.d.ts +9 -0
  38. package/dist/src/engine/dynamicData/implementations/Vest.js +58 -0
  39. package/dist/src/engine/dynamicData/implementations/default.d.ts +5 -0
  40. package/dist/src/engine/dynamicData/implementations/default.js +5 -0
  41. package/dist/src/{libs/campaigns → engine/dynamicData}/utils/getEulerV2Vaults.js +1 -1
  42. package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/GenericProcessor.d.ts +1 -1
  43. package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/subtypesRound2.d.ts +1 -1
  44. package/dist/src/{factories → engine}/opportunityMetadata/implementations/Erc20.js +3 -3
  45. package/dist/src/{factories → engine}/opportunityMetadata/implementations/Euler.d.ts +1 -1
  46. package/dist/src/{factories → engine}/opportunityMetadata/implementations/Euler.js +7 -7
  47. package/dist/src/{factories → engine}/opportunityMetadata/implementations/Vest.js +1 -1
  48. package/dist/src/index.d.ts +5 -16
  49. package/dist/src/jobs/update-euler-vaults.js +2 -2
  50. package/dist/src/modules/v4/apr/apr.service.d.ts +1 -1
  51. package/dist/src/modules/v4/apr/apr.service.js +4 -4
  52. package/dist/src/modules/v4/campaign/campaign.service.d.ts +0 -8
  53. package/dist/src/modules/v4/campaign/campaign.service.js +0 -13
  54. package/dist/src/modules/v4/dynamicData/dynamicData.service.js +3 -4
  55. package/dist/src/modules/v4/opportunity/opportunity.service.js +1 -1
  56. package/dist/src/modules/v4/uniswapV4/uniswapV4.controller.d.ts +2 -2
  57. package/dist/src/modules/v4/uniswapV4/uniswapV4.service.d.ts +2 -2
  58. package/dist/src/modules/v4/uniswapV4/uniswapV4.service.js +1 -1
  59. package/dist/src/routes/v3/campaigns.d.ts +1 -1
  60. package/dist/src/routes/v3/compoundV2.d.ts +2 -10
  61. package/dist/src/routes/v3/compoundV2.js +1 -1
  62. package/dist/src/routes/v3/dolomite.js +1 -1
  63. package/dist/src/routes/v3/euler.js +1 -1
  64. package/dist/src/routes/v3/router.d.ts +5 -16
  65. package/dist/src/routes/v3/uniswapv4.d.ts +2 -5
  66. package/dist/src/routes/v3/uniswapv4.js +1 -1
  67. package/dist/src/utils/decodeCalls.d.ts +1 -1
  68. package/dist/src/utils/decodeCalls.js +1 -1
  69. package/dist/src/utils/encodeCalls.d.ts +1 -1
  70. package/dist/src/utils/encodeCalls.js +1 -1
  71. package/dist/src/utils/generateCardName.d.ts +1 -1
  72. package/dist/src/utils/generateCardName.js +1 -1
  73. package/dist/src/utils/generateIcons.d.ts +1 -1
  74. package/dist/src/utils/generateIcons.js +1 -1
  75. package/dist/tsconfig.package.tsbuildinfo +1 -1
  76. package/package.json +1 -1
  77. package/dist/src/factories/dynamicData/factory.d.ts +0 -0
  78. package/dist/src/factories/dynamicData/factory.js +0 -10
  79. package/dist/src/libs/campaigns/campaignTypes/AjnaDynamicData.d.ts +0 -5
  80. package/dist/src/libs/campaigns/campaignTypes/AjnaDynamicData.js +0 -111
  81. package/dist/src/libs/campaigns/campaignTypes/AmbientDynamicData.d.ts +0 -3
  82. package/dist/src/libs/campaigns/campaignTypes/AmbientDynamicData.js +0 -245
  83. package/dist/src/libs/campaigns/campaignTypes/BadgerDynamicData.d.ts +0 -5
  84. package/dist/src/libs/campaigns/campaignTypes/BadgerDynamicData.js +0 -96
  85. package/dist/src/libs/campaigns/campaignTypes/CLAMMDynamicData.d.ts +0 -3
  86. package/dist/src/libs/campaigns/campaignTypes/CLAMMDynamicData.js +0 -988
  87. package/dist/src/libs/campaigns/campaignTypes/CompoundDynamicData.d.ts +0 -3
  88. package/dist/src/libs/campaigns/campaignTypes/CompoundDynamicData.js +0 -142
  89. package/dist/src/libs/campaigns/campaignTypes/DolomiteDynamicData.d.ts +0 -5
  90. package/dist/src/libs/campaigns/campaignTypes/DolomiteDynamicData.js +0 -63
  91. package/dist/src/libs/campaigns/campaignTypes/ERC20DynamicData.d.ts +0 -4
  92. package/dist/src/libs/campaigns/campaignTypes/ERC20DynamicData.js +0 -167
  93. package/dist/src/libs/campaigns/campaignTypes/ERC20_SNAPSHOTDynamicData.d.ts +0 -5
  94. package/dist/src/libs/campaigns/campaignTypes/ERC20_SNAPSHOTDynamicData.js +0 -38
  95. package/dist/src/libs/campaigns/campaignTypes/EigenLayerDynamicData.d.ts +0 -3
  96. package/dist/src/libs/campaigns/campaignTypes/EigenLayerDynamicData.js +0 -70
  97. package/dist/src/libs/campaigns/campaignTypes/EncompassingDynamicData.d.ts +0 -5
  98. package/dist/src/libs/campaigns/campaignTypes/EncompassingDynamicData.js +0 -34
  99. package/dist/src/libs/campaigns/campaignTypes/EventBasedDynamicData.d.ts +0 -3
  100. package/dist/src/libs/campaigns/campaignTypes/EventBasedDynamicData.js +0 -115
  101. package/dist/src/libs/campaigns/campaignTypes/HyperdriveDynamicData.d.ts +0 -5
  102. package/dist/src/libs/campaigns/campaignTypes/HyperdriveDynamicData.js +0 -102
  103. package/dist/src/libs/campaigns/campaignTypes/JSON_AIRDROPDynamicData.d.ts +0 -5
  104. package/dist/src/libs/campaigns/campaignTypes/JSON_AIRDROPDynamicData.js +0 -19
  105. package/dist/src/libs/campaigns/campaignTypes/MORPHODynamicData.d.ts +0 -5
  106. package/dist/src/libs/campaigns/campaignTypes/MORPHODynamicData.js +0 -115
  107. package/dist/src/libs/campaigns/campaignTypes/RadiantDynamicData.d.ts +0 -3
  108. package/dist/src/libs/campaigns/campaignTypes/RadiantDynamicData.js +0 -125
  109. package/dist/src/libs/campaigns/campaignTypes/SILODynamicData.d.ts +0 -7
  110. package/dist/src/libs/campaigns/campaignTypes/SILODynamicData.js +0 -118
  111. package/dist/src/libs/campaigns/campaignTypes/UniswapV4DynamicData.d.ts +0 -3
  112. package/dist/src/libs/campaigns/campaignTypes/UniswapV4DynamicData.js +0 -267
  113. package/dist/src/libs/campaigns/campaignTypes/VestDynamicData.d.ts +0 -5
  114. package/dist/src/libs/campaigns/campaignTypes/VestDynamicData.js +0 -64
  115. package/dist/src/libs/campaigns/campaignsDynamicData.d.ts +0 -3
  116. package/dist/src/libs/campaigns/campaignsDynamicData.js +0 -131
  117. /package/dist/src/{libs/campaigns → engine/dynamicData}/utils/fetchA51Strategies.d.ts +0 -0
  118. /package/dist/src/{libs/campaigns → engine/dynamicData}/utils/fetchA51Strategies.js +0 -0
  119. /package/dist/src/{libs/campaigns → engine/dynamicData}/utils/fetchAmbientInfo.d.ts +0 -0
  120. /package/dist/src/{libs/campaigns → engine/dynamicData}/utils/fetchAmbientInfo.js +0 -0
  121. /package/dist/src/{libs/campaigns → engine/dynamicData}/utils/fetchClamInfo.d.ts +0 -0
  122. /package/dist/src/{libs/campaigns → engine/dynamicData}/utils/fetchClamInfo.js +0 -0
  123. /package/dist/src/{libs/campaigns → engine/dynamicData}/utils/fetchLogs.d.ts +0 -0
  124. /package/dist/src/{libs/campaigns → engine/dynamicData}/utils/fetchLogs.js +0 -0
  125. /package/dist/src/{libs/campaigns → engine/dynamicData}/utils/getCompV2ForksVaults.d.ts +0 -0
  126. /package/dist/src/{libs/campaigns → engine/dynamicData}/utils/getCompV2ForksVaults.js +0 -0
  127. /package/dist/src/{libs/campaigns → engine/dynamicData}/utils/getContractCreationBlock.d.ts +0 -0
  128. /package/dist/src/{libs/campaigns → engine/dynamicData}/utils/getContractCreationBlock.js +0 -0
  129. /package/dist/src/{libs/campaigns → engine/dynamicData}/utils/getDolomiteMarkets.d.ts +0 -0
  130. /package/dist/src/{libs/campaigns → engine/dynamicData}/utils/getDolomiteMarkets.js +0 -0
  131. /package/dist/src/{libs/campaigns → engine/dynamicData}/utils/getEulerV2Vaults.d.ts +0 -0
  132. /package/dist/src/{libs/campaigns → engine/dynamicData}/utils/getUniswapV4Pools.d.ts +0 -0
  133. /package/dist/src/{libs/campaigns → engine/dynamicData}/utils/getUniswapV4Pools.js +0 -0
  134. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/GenericProcessor.js +0 -0
  135. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/helpers/eulerVaultNames.d.ts +0 -0
  136. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/helpers/eulerVaultNames.js +0 -0
  137. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/helpers/factoryFinder.d.ts +0 -0
  138. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/helpers/factoryFinder.js +0 -0
  139. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/helpers/getBlacklistedSupply.d.ts +0 -0
  140. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/helpers/getBlacklistedSupply.js +0 -0
  141. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/helpers/hardcoded.d.ts +0 -0
  142. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/helpers/hardcoded.js +0 -0
  143. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/helpers/metamorphoTvl.d.ts +0 -0
  144. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/helpers/metamorphoTvl.js +0 -0
  145. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/helpers/ownerFinder.d.ts +0 -0
  146. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/helpers/ownerFinder.js +0 -0
  147. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/helpers/spliceTVL.d.ts +0 -0
  148. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/helpers/spliceTVL.js +0 -0
  149. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/helpers/tokenType.d.ts +0 -0
  150. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/helpers/tokenType.js +0 -0
  151. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/AaveProcessor.d.ts +0 -0
  152. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/AaveProcessor.js +0 -0
  153. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/AnglesLiquid.d.ts +0 -0
  154. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/AnglesLiquid.js +0 -0
  155. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/AssetProcessor.d.ts +0 -0
  156. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/AssetProcessor.js +0 -0
  157. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/AuraProcessor.d.ts +0 -0
  158. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/AuraProcessor.js +0 -0
  159. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/BalancerGaugeProcessor.d.ts +0 -0
  160. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/BalancerGaugeProcessor.js +0 -0
  161. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/BalancerPoolProcessor.d.ts +0 -0
  162. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/BalancerPoolProcessor.js +0 -0
  163. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/BalancerV3PoolProcessor.d.ts +0 -0
  164. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/BalancerV3PoolProcessor.js +0 -0
  165. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/BeefyProcessor.d.ts +0 -0
  166. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/BeefyProcessor.js +0 -0
  167. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/BunniV2Processor.d.ts +0 -0
  168. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/BunniV2Processor.js +0 -0
  169. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/CompoundProcessor.d.ts +0 -0
  170. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/CompoundProcessor.js +0 -0
  171. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/ERC4626Processor.d.ts +0 -0
  172. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/ERC4626Processor.js +0 -0
  173. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/EnzymeProcessor.d.ts +0 -0
  174. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/EnzymeProcessor.js +0 -0
  175. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/EqualizerGaugeProcessor.d.ts +0 -0
  176. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/EqualizerGaugeProcessor.js +0 -0
  177. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/EulerBorrowProcessor.d.ts +0 -0
  178. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/EulerBorrowProcessor.js +0 -0
  179. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/EulerLendProcessor.d.ts +0 -0
  180. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/EulerLendProcessor.js +0 -0
  181. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/FluidProcessor.d.ts +0 -0
  182. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/FluidProcessor.js +0 -0
  183. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/FraxProcessor.d.ts +0 -0
  184. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/FraxProcessor.js +0 -0
  185. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/GammaProcessor.d.ts +0 -0
  186. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/GammaProcessor.js +0 -0
  187. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/GearboxProcessor.d.ts +0 -0
  188. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/GearboxProcessor.js +0 -0
  189. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/HanjiVaultProcessor.d.ts +0 -0
  190. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/HanjiVaultProcessor.js +0 -0
  191. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/HoldStationProcessor.d.ts +0 -0
  192. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/HoldStationProcessor.js +0 -0
  193. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/HourglassProcessor.d.ts +0 -0
  194. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/HourglassProcessor.js +0 -0
  195. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/MaverickBPProcessor.d.ts +0 -0
  196. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/MaverickBPProcessor.js +0 -0
  197. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/MetamorphoProcessor.d.ts +0 -0
  198. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/MetamorphoProcessor.js +0 -0
  199. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/NoLinkVaultProcessor.d.ts +0 -0
  200. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/NoLinkVaultProcessor.js +0 -0
  201. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/PendleProcessor.d.ts +0 -0
  202. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/PendleProcessor.js +0 -0
  203. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/PendleYTProcessor.d.ts +0 -0
  204. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/PendleYTProcessor.js +0 -0
  205. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/RadiantProcessor.d.ts +0 -0
  206. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/RadiantProcessor.js +0 -0
  207. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/RfxProcessor.d.ts +0 -0
  208. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/RfxProcessor.js +0 -0
  209. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/Satlayer.d.ts +0 -0
  210. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/Satlayer.js +0 -0
  211. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/SpectraProcessor.d.ts +0 -0
  212. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/SpectraProcessor.js +0 -0
  213. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/SpectraYTProcessor.d.ts +0 -0
  214. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/SpectraYTProcessor.js +0 -0
  215. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/SpliceProcessor.d.ts +0 -0
  216. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/SpliceProcessor.js +0 -0
  217. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/SturdySiloProcessor.d.ts +0 -0
  218. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/SturdySiloProcessor.js +0 -0
  219. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/TempestVaultProcessor.d.ts +0 -0
  220. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/TempestVaultProcessor.js +0 -0
  221. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/TemplateProcessor.d.ts +0 -0
  222. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/TemplateProcessor.js +0 -0
  223. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/TorosProcessor.d.ts +0 -0
  224. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/TorosProcessor.js +0 -0
  225. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/UniswapProcessor.d.ts +0 -0
  226. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/UniswapProcessor.js +0 -0
  227. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/VicunaProcessor.d.ts +0 -0
  228. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/VicunaProcessor.js +0 -0
  229. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/WoofiProcessor.d.ts +0 -0
  230. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/WoofiProcessor.js +0 -0
  231. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/ZkSwapThreePoolProcessor.d.ts +0 -0
  232. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/ZkSwapThreePoolProcessor.js +0 -0
  233. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/curveNPoolProcessor.d.ts +0 -0
  234. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/curveNPoolProcessor.js +0 -0
  235. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/curveProcessor.d.ts +0 -0
  236. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/curveProcessor.js +0 -0
  237. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/processorMapping.d.ts +0 -0
  238. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/processorMapping.js +0 -0
  239. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/stakedCurveProcessor.d.ts +0 -0
  240. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/stakedCurveProcessor.js +0 -0
  241. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/xU308Processor.d.ts +0 -0
  242. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/implementations/xU308Processor.js +0 -0
  243. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/subtypesPrices.d.ts +0 -0
  244. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/subtypesPrices.js +0 -0
  245. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/subtypesRound1.d.ts +0 -0
  246. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/subtypesRound1.js +0 -0
  247. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/subtypesRound2.js +0 -0
  248. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/subtypesRound3.d.ts +0 -0
  249. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/subtypesRound3.js +0 -0
  250. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/subtypesRound4.d.ts +0 -0
  251. /package/dist/src/{libs/campaigns/campaignTypes/ERC20SubTypes → engine/erc20SubTypeProcessors}/subtypesRound4.js +0 -0
  252. /package/dist/src/{factories → engine}/opportunityMetadata/factory.d.ts +0 -0
  253. /package/dist/src/{factories → engine}/opportunityMetadata/factory.js +0 -0
  254. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Ajna.d.ts +0 -0
  255. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Ajna.js +0 -0
  256. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Ambiant.d.ts +0 -0
  257. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Ambiant.js +0 -0
  258. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Badger.d.ts +0 -0
  259. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Badger.js +0 -0
  260. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Clamm.d.ts +0 -0
  261. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Clamm.js +0 -0
  262. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Compound.d.ts +0 -0
  263. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Compound.js +0 -0
  264. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Default.d.ts +0 -0
  265. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Default.js +0 -0
  266. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Dolomite.d.ts +0 -0
  267. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Dolomite.js +0 -0
  268. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/EigenLayer.d.ts +0 -0
  269. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/EigenLayer.js +0 -0
  270. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Encompassing.d.ts +0 -0
  271. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Encompassing.js +0 -0
  272. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Erc20.d.ts +0 -0
  273. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Erc20Snapshot.d.ts +0 -0
  274. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Erc20Snapshot.js +0 -0
  275. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/EventBased.d.ts +0 -0
  276. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/EventBased.js +0 -0
  277. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Hyperdrive.d.ts +0 -0
  278. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Hyperdrive.js +0 -0
  279. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Invalid.d.ts +0 -0
  280. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Invalid.js +0 -0
  281. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Ion.d.ts +0 -0
  282. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Ion.js +0 -0
  283. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/JsonAirdrop.d.ts +0 -0
  284. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/JsonAirdrop.js +0 -0
  285. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Morpho.d.ts +0 -0
  286. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Morpho.js +0 -0
  287. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Radiant.d.ts +0 -0
  288. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Radiant.js +0 -0
  289. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Silo.d.ts +0 -0
  290. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Silo.js +0 -0
  291. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/UniswapV4.d.ts +0 -0
  292. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/UniswapV4.js +0 -0
  293. /package/dist/src/{factories → engine}/opportunityMetadata/implementations/Vest.d.ts +0 -0
@@ -1,988 +0,0 @@
1
- import { nftPositionByIdsQuery, positionMultipleOwnersQuery } from "@/libs/positions/clamm/thegraph";
2
- import { fetchFarmedPositions } from "@/libs/positions/clamm/thegraph/fetchFarmedPositions";
3
- import { TokenService } from "@/modules/v4/token/token.service";
4
- import { A51Factory__factory, ALM, ALMMapping, AMM, AMMAlgorithm, AMMAlgorithmMapping, BN2Number, DecodeLiquidity, EAprBreakdownType, ERC20Interface, Forwarder, JonesDoubleRewardTracker__factory, Liquidity, NETWORK_LABELS, NitroInterface, PoolInterface, PoolState, PriorityAMM, SqrtPrice, almName, ammName, getAmountsForLiquidity, getTickAtSqrtRatio, isBlacklisted, isWhitelisted, merklSubgraphAMMEndpoints, shortenAddress, spNFTInterface, withTimeout, } from "@sdk";
5
- import axios from "axios";
6
- import { BigNumber, utils } from "ethers";
7
- import request from "graphql-request";
8
- import JSBI from "jsbi";
9
- import moment from "moment";
10
- import { MERKL_ALM_POSITION_FETCHING_TIMEOUT } from "../../../constants";
11
- import { log } from "../../../utils/logger";
12
- import { Pricer } from "../../../utils/pricer";
13
- import { isStrykeCampaign } from "../../../utils/stryke";
14
- import { fetchA51Strategies } from "../utils/fetchA51Strategies";
15
- export async function CLAMMDynamicData(chainId, campaigns) {
16
- const dynamicData = [];
17
- const pricer = await Pricer.load();
18
- const calls = [];
19
- const A51Interface = A51Factory__factory.createInterface();
20
- /** Dedupe pools from campaigns to build pool list */
21
- let poolList = [];
22
- for (const campaign of campaigns ?? []) {
23
- /** Loop through all campaigns to add pools */
24
- if (!poolList?.map(p => p.mainParameter.toLowerCase()).includes(campaign.mainParameter.toLowerCase())) {
25
- if (AMMAlgorithmMapping[campaign.campaignParameters.amm] === undefined) {
26
- console.log("Invalid AMM", campaign.campaignParameters.amm);
27
- continue;
28
- }
29
- poolList.push({
30
- address: campaign.campaignParameters.poolAddress,
31
- mainParameter: campaign.mainParameter, // main parameter containes info of poolAddress + AMM (in case its a priority AMM)
32
- alms: [],
33
- amm: campaign.campaignParameters.amm,
34
- });
35
- }
36
- /** Now we have an entry with campaign.mainParameter in poolList */
37
- const poolIndex = poolList
38
- ?.map(p => p.mainParameter.toLowerCase())
39
- .findIndex(a => a === campaign.mainParameter.toLowerCase());
40
- /** Fill ALMs per pools */
41
- for (const forwarder of campaign.campaignParameters.forwarders
42
- .filter(f => f.forwarderType === Forwarder.CLAMM)
43
- .sort((a, b) => a.priority - b.priority)) {
44
- const alm = {
45
- address: forwarder.sender,
46
- ...(!!forwarder.owner && { owner: forwarder.owner?.toLowerCase() }),
47
- target: forwarder.target.toLowerCase(),
48
- type: forwarder.type,
49
- priority: forwarder.priority,
50
- };
51
- /** If the ALM is not found - add it */
52
- if (poolList[poolIndex].alms.findIndex(a => alm.address === a.address && alm.target === a.target) === -1) {
53
- poolList[poolIndex].alms.push(alm);
54
- }
55
- }
56
- }
57
- poolList = poolList.filter(p => p.amm !== undefined && p.amm !== null);
58
- if (!!poolList) {
59
- // Prepare A51 fetching
60
- const A51Pools = [];
61
- for (const pool of poolList) {
62
- for (const _ of pool.alms.filter(a => a.type === ALM.A51)) {
63
- A51Pools.push(pool.address.toLowerCase());
64
- }
65
- }
66
- let A51Strategies = {};
67
- if (A51Pools.length > 0) {
68
- A51Strategies = await fetchA51Strategies(chainId, [...new Set(A51Pools)]);
69
- }
70
- for (const pool of poolList) {
71
- const poolInterface = PoolInterface[AMMAlgorithmMapping[pool.amm]];
72
- const d = campaigns?.filter(campaign => campaign.mainParameter.toLowerCase() === pool.mainParameter.toLowerCase())[0];
73
- calls.push({
74
- allowFailure: true,
75
- callData: poolInterface.encodeFunctionData(Liquidity[AMMAlgorithmMapping[pool.amm]]),
76
- target: pool.address,
77
- }, {
78
- allowFailure: true,
79
- callData: poolInterface.encodeFunctionData(PoolState[AMMAlgorithmMapping[pool.amm]]),
80
- target: pool.address,
81
- }, {
82
- allowFailure: true,
83
- callData: ERC20Interface.encodeFunctionData("balanceOf", [pool.address]),
84
- target: d.campaignParameters.token0,
85
- }, {
86
- allowFailure: true,
87
- callData: ERC20Interface.encodeFunctionData("balanceOf", [pool.address]),
88
- target: d.campaignParameters.token1,
89
- });
90
- /** Direct ALMs */
91
- for (const alm of pool.alms.filter(a => a.target.toLowerCase() === pool.address.toLowerCase() && a.type !== ALM.A51)) {
92
- let almAddress = alm.address;
93
- if (alm.type === ALM.Beefy) {
94
- almAddress = alm.owner ?? alm.address;
95
- }
96
- calls.push({
97
- allowFailure: true,
98
- callData: ERC20Interface.encodeFunctionData("totalSupply"),
99
- target: alm.address,
100
- });
101
- calls.push({
102
- allowFailure: true,
103
- callData: ERC20Interface.encodeFunctionData("balanceOf", [almAddress]),
104
- target: d.campaignParameters.token0,
105
- });
106
- calls.push({
107
- allowFailure: true,
108
- callData: ERC20Interface.encodeFunctionData("balanceOf", [almAddress]),
109
- target: d.campaignParameters.token1,
110
- });
111
- }
112
- /** Multi-hop ALMs */
113
- for (const alm of pool.alms.filter(a => a.target !== pool.address.toLowerCase())) {
114
- if (alm.type === ALM.spNFT) {
115
- calls.push({
116
- allowFailure: true,
117
- callData: spNFTInterface.encodeFunctionData("getPoolInfo"),
118
- target: alm.address,
119
- });
120
- }
121
- else if (alm.type === ALM.kpNFT) {
122
- calls.push({
123
- allowFailure: true,
124
- callData: spNFTInterface.encodeFunctionData("getPoolInfo"),
125
- target: alm.address,
126
- });
127
- }
128
- else if (alm.type === ALM.Nitro) {
129
- calls.push({
130
- allowFailure: true,
131
- callData: NitroInterface.encodeFunctionData("totalDepositAmount"),
132
- target: alm.address,
133
- });
134
- }
135
- else if ([ALM.ConcentricStaker, ALM.GammaChef].includes(alm.type)) {
136
- calls.push({
137
- allowFailure: true,
138
- callData: ERC20Interface.encodeFunctionData("balanceOf", [alm.address]),
139
- target: alm.target,
140
- });
141
- }
142
- else if (alm.type === ALM.JonesTracker) {
143
- calls.push({
144
- allowFailure: true,
145
- callData: JonesDoubleRewardTracker__factory.createInterface().encodeFunctionData("totalStakedAmount"),
146
- target: alm.address,
147
- });
148
- }
149
- else {
150
- calls.push({
151
- allowFailure: true,
152
- callData: ERC20Interface.encodeFunctionData("totalSupply"),
153
- target: alm.address,
154
- });
155
- }
156
- }
157
- /** A51 Strategies */
158
- for (const w of pool.alms.filter(a => a.type === ALM.A51)) {
159
- const strategies = A51Strategies?.[pool.address.toLowerCase()]?.[w.address] ?? [];
160
- for (const strategy of strategies) {
161
- calls.push({
162
- allowFailure: true,
163
- callData: A51Interface.encodeFunctionData("strategies", [strategy.id]),
164
- target: w.address,
165
- });
166
- }
167
- }
168
- }
169
- /**
170
- * Fetch all ALM vaults positions for the pools.
171
- * @dev Do it in parallel with 1 call / AMM subgraph to save time.
172
- */
173
- const positions = {};
174
- const positionsPromise = Object.keys(AMM)
175
- .filter(amm => !!merklSubgraphAMMEndpoints[chainId][Number.parseInt(amm)])
176
- .map(async (amm) => {
177
- const tgURL = merklSubgraphAMMEndpoints[chainId][Number.parseInt(amm)];
178
- let targetAddressesList = [];
179
- if (!!poolList) {
180
- for (const pool of poolList) {
181
- if (pool.amm === Number.parseInt(amm)) {
182
- /** Add direct alm addresses */
183
- targetAddressesList = targetAddressesList.concat(pool.alms
184
- .filter(a => a.target.toLowerCase() === pool.address.toLowerCase())
185
- ?.map(w => {
186
- return !!w?.owner && Number.parseInt(amm) !== AMM.Stryke
187
- ? w.owner.toLowerCase()
188
- : w.address.toLowerCase();
189
- }) ?? []);
190
- /** Add blacklisted / whitelisted addresses (optional) */
191
- for (const campaign of campaigns.filter(campaign => campaign.mainParameter.toLowerCase() === pool.mainParameter.toLowerCase())) {
192
- const distributionBlacklist = campaign.campaignId === "0x4a805dd97d823dfbc34d138af3d09536ac792b6ad73079573df082c71d4b057c"
193
- ? [...campaign.campaignParameters.blacklist, "0x657e6d2073A99aF61952beb7EE564169616b90C1"]
194
- : campaign.campaignParameters.blacklist;
195
- if (!!distributionBlacklist && distributionBlacklist.length > 0)
196
- targetAddressesList = targetAddressesList.concat(distributionBlacklist.map((address) => address.toLowerCase()));
197
- let distributionWhitelist = campaign.campaignParameters?.whitelist;
198
- if (distributionWhitelist.length === 1 &&
199
- distributionWhitelist[0].toLowerCase() === "0xE4bA6740aF4c666325D49B3112E4758371386aDc".toLowerCase()) {
200
- distributionWhitelist = ["0xe11d346757d052214686bCbC860C94363AfB4a9A"];
201
- }
202
- if (!isStrykeCampaign(pool.amm) && !!distributionWhitelist && distributionWhitelist.length > 0)
203
- targetAddressesList = targetAddressesList.concat(distributionWhitelist.map((address) => address.toLowerCase()));
204
- }
205
- }
206
- }
207
- }
208
- targetAddressesList = targetAddressesList.filter((a, index, self) => self.indexOf(a) === index); // Dedupe
209
- if (targetAddressesList?.length > 0) {
210
- positions[Number.parseInt(amm)] = [];
211
- /** Fetch NFT Wrapper positions */
212
- const farmedPositionsList = await fetchFarmedPositions(chainId, targetAddressesList, Number(amm));
213
- const farmedPositionsById = Object.keys(farmedPositionsList).reduce((acc, curr) => {
214
- for (const pos of farmedPositionsList[curr]) {
215
- acc[pos.id] = pos;
216
- }
217
- return acc;
218
- }, {});
219
- if (Object.keys(farmedPositionsById).length > 0) {
220
- let hasFollowingPage = true;
221
- let skip = 0;
222
- const res = { nft: [] };
223
- while (hasFollowingPage) {
224
- const auxRes = await request(tgURL, nftPositionByIdsQuery, {
225
- ids: Object.keys(farmedPositionsById),
226
- skip,
227
- });
228
- res.nft = res.nft.concat(auxRes.nft ?? []);
229
- if (auxRes.nft.length < 1000) {
230
- hasFollowingPage = false;
231
- }
232
- skip += 1000;
233
- }
234
- if (!!res.nft) {
235
- for (const pos of res.nft) {
236
- positions[Number.parseInt(amm)]?.push({
237
- ...pos,
238
- owner: farmedPositionsById[pos.id].holder,
239
- });
240
- }
241
- }
242
- }
243
- await withTimeout((async () => {
244
- let hasFollowingPage = true;
245
- let skip = 0;
246
- const res = { direct: [], nft: [] };
247
- while (hasFollowingPage) {
248
- const auxRes = await request(tgURL, positionMultipleOwnersQuery, {
249
- owners: targetAddressesList,
250
- skip,
251
- });
252
- res.direct = res.direct.concat(auxRes.direct ?? []);
253
- res.nft = res.nft.concat(auxRes.nft ?? []);
254
- if (auxRes.direct.length < 1000 && auxRes.nft.length < 1000) {
255
- hasFollowingPage = false;
256
- }
257
- skip += 1000;
258
- }
259
- return res;
260
- })().then(res => {
261
- if (!!res.direct) {
262
- for (const pos of res.direct) {
263
- positions[Number.parseInt(amm)]?.push(pos);
264
- }
265
- }
266
- if (!!res.nft) {
267
- for (const pos of res.nft) {
268
- positions[Number.parseInt(amm)]?.push(pos);
269
- }
270
- }
271
- }), MERKL_ALM_POSITION_FETCHING_TIMEOUT).catch(error => {
272
- const service = `Merkl AMM Subgraph for ${NETWORK_LABELS[chainId]} ${AMM[Number.parseInt(amm)]}`;
273
- log.error(service, error, service, tgURL);
274
- });
275
- }
276
- });
277
- return {
278
- cached: false,
279
- call: {
280
- callData: calls,
281
- handler: () => { },
282
- reducer: async (result) => {
283
- // Wait for position fetching before finalizing the data
284
- await Promise.all(positionsPromise);
285
- let i = 0;
286
- if (!!poolList) {
287
- for (const pool of poolList) {
288
- const poolInterface = PoolInterface[AMMAlgorithmMapping[pool.amm]];
289
- // This liquidity call gives the active liquidity on the pool. To get the total liquidity we would need to loop over all positions
290
- let poolTotalLiquidity;
291
- let sqrtPrice;
292
- let poolBalanceToken0;
293
- let poolBalanceToken1;
294
- const d = campaigns?.filter(campaign => campaign.mainParameter.toLowerCase() === pool.mainParameter.toLowerCase())[0];
295
- const decimalsToken0 = d.campaignParameters.decimalsToken0;
296
- const decimalsToken1 = d.campaignParameters.decimalsToken1;
297
- const symbolToken0 = d.campaignParameters.symbolToken0;
298
- const symbolToken1 = d.campaignParameters.symbolToken1;
299
- const prevI = i;
300
- try {
301
- poolTotalLiquidity = BN2Number(poolInterface.decodeFunctionResult(Liquidity[AMMAlgorithmMapping[pool.amm]], result[i++])[DecodeLiquidity[AMMAlgorithmMapping[pool.amm]]]);
302
- sqrtPrice = poolInterface
303
- .decodeFunctionResult(PoolState[AMMAlgorithmMapping[pool.amm]], result[i++])[SqrtPrice[AMMAlgorithmMapping[pool.amm]]].toString();
304
- poolBalanceToken0 = BN2Number(ERC20Interface.decodeFunctionResult("balanceOf", result[i++])[0], decimalsToken0);
305
- poolBalanceToken1 = BN2Number(ERC20Interface.decodeFunctionResult("balanceOf", result[i++])[0], decimalsToken1);
306
- }
307
- catch (e) {
308
- log.warn(`merklDynamic data - failed to decode state of pool ${pool.address} on ${NETWORK_LABELS[chainId]}`);
309
- i = prevI + 4;
310
- continue;
311
- }
312
- const priceToken0 = (await pricer.get({
313
- address: d.campaignParameters.token0,
314
- chainId: chainId,
315
- symbol: symbolToken0,
316
- }));
317
- const priceToken1 = (await pricer.get({
318
- address: d.campaignParameters.token1,
319
- chainId: chainId,
320
- symbol: symbolToken1,
321
- }));
322
- const almDetails = [];
323
- /** Direct ALMs */
324
- for (const w of pool.alms.filter(a => a.target.toLowerCase() === pool.address.toLowerCase() && a.type !== ALM.A51)) {
325
- const prevI = i;
326
- try {
327
- const totalSupply = BN2Number(ERC20Interface.decodeFunctionResult("totalSupply", result[i++])[0]);
328
- const almIdleBalance0 = BN2Number(ERC20Interface.decodeFunctionResult("balanceOf", result[i++])[0], d.campaignParameters.decimalsToken0);
329
- let almBalance0 = almIdleBalance0;
330
- const almIdleBalance1 = BN2Number(ERC20Interface.decodeFunctionResult("balanceOf", result[i++])[0], d.campaignParameters.decimalsToken1);
331
- let almBalance1 = almIdleBalance1;
332
- let almTotalLiquidity = 0;
333
- let almInRangeLiquidity = 0;
334
- const almPositions = positions?.[pool.amm]?.filter(pos => pos.pool.id === pool.address.toLowerCase() &&
335
- [w.address.toLowerCase(), ...[!!w?.owner && w.owner.toLowerCase()]].includes(pos.owner.toLowerCase()));
336
- const almPositionsWithAPIType = [];
337
- if (!!almPositions) {
338
- for (const position of almPositions) {
339
- const upperTick = Number.parseInt(position.tickUpper);
340
- const lowerTick = Number.parseInt(position.tickLower);
341
- const [amount0, amount1] = getAmountsForLiquidity(sqrtPrice, lowerTick, upperTick, BigNumber.from(position.liquidity));
342
- const balance0 = BN2Number(amount0, decimalsToken0);
343
- const balance1 = BN2Number(amount1, decimalsToken1);
344
- const totalLiquidity = BN2Number(position.liquidity);
345
- const inRangeLiquidity = balance0 > 0 && balance1 > 0 ? (BN2Number(position.liquidity) ?? 0) : 0;
346
- almTotalLiquidity += totalLiquidity;
347
- almInRangeLiquidity += inRangeLiquidity;
348
- almBalance0 += balance0;
349
- almBalance1 += balance1;
350
- almPositionsWithAPIType.push({
351
- balance0,
352
- balance1,
353
- id: position.id,
354
- inRangeLiquidity,
355
- lowerTick,
356
- totalLiquidity,
357
- tvl: priceToken0 * balance0 + priceToken1 * balance1,
358
- upperTick,
359
- });
360
- }
361
- // The wrapper type can exist in the subgraph without being declared in the SDK which can lead to type errors
362
- if (!!ALMMapping[pool.amm] && w.type in ALMMapping[pool.amm]) {
363
- almDetails.push({
364
- almAPR: 0, // filled later on
365
- almAddress: utils.getAddress(w.address),
366
- almBalance0,
367
- almIdleBalance0,
368
- almIdleBalance1,
369
- almBalance1,
370
- almInRangeLiquidity,
371
- almTVL: almBalance0 * priceToken0 + almBalance1 * priceToken1,
372
- almTotalLiquidity,
373
- forwarderType: Forwarder.CLAMM,
374
- label: `${ALMMapping[pool.amm]?.[w.type]} ${w.address}`,
375
- origin: w.type,
376
- positions: almPositionsWithAPIType,
377
- priority: 0,
378
- sender: utils.getAddress(w.address),
379
- target: w.target,
380
- owner: utils.getAddress(w.owner ?? w.address),
381
- totalSupply,
382
- type: w.type,
383
- });
384
- }
385
- }
386
- }
387
- catch (e) {
388
- log.warn(`merklDynamic data - failed to handle direct alm data of pool ${pool.address} on ${NETWORK_LABELS[chainId]} - ${w.address}`);
389
- i = prevI + 3;
390
- }
391
- }
392
- /** Multi-hop ALMs */
393
- for (const w of pool.alms.filter(a => a.target !== pool.address.toLowerCase())) {
394
- const prevI = i;
395
- try {
396
- let totalSupply;
397
- if (w.type === ALM.spNFT) {
398
- totalSupply = BN2Number(spNFTInterface.decodeFunctionResult("getPoolInfo", result[i++])[5]);
399
- }
400
- else if (w.type === ALM.kpNFT) {
401
- totalSupply = BN2Number(spNFTInterface.decodeFunctionResult("getPoolInfo", result[i++])[5]);
402
- }
403
- else if (w.type === ALM.Nitro) {
404
- totalSupply = BN2Number(NitroInterface.decodeFunctionResult("totalDepositAmount", result[i++])[0]);
405
- }
406
- else if ([ALM.ConcentricStaker, ALM.GammaChef].includes(w.type)) {
407
- totalSupply = BN2Number(ERC20Interface.decodeFunctionResult("balanceOf", result[i++])[0]);
408
- }
409
- else if (w.type === ALM.JonesTracker) {
410
- totalSupply = BN2Number(JonesDoubleRewardTracker__factory.createInterface().decodeFunctionResult("totalStakedAmount", result[i++])[0]);
411
- }
412
- else {
413
- totalSupply = BN2Number(ERC20Interface.decodeFunctionResult("totalSupply", result[i++])[0]);
414
- }
415
- const wrappedALM = almDetails.filter(a => utils.getAddress(a.almAddress) === utils.getAddress(w.target))[0];
416
- if (!!wrappedALM && !!wrappedALM.totalSupply) {
417
- const ratio = totalSupply / wrappedALM.totalSupply;
418
- almDetails.push({
419
- almAPR: 0,
420
- // filled later on
421
- almAddress: w.address,
422
- almIdleBalance0: 0,
423
- almIdleBalance1: 0,
424
- almBalance0: ratio * wrappedALM.almBalance0,
425
- almBalance1: ratio * wrappedALM.almBalance1,
426
- almInRangeLiquidity: ratio * wrappedALM.almInRangeLiquidity,
427
- almTVL: ratio * wrappedALM.almTVL,
428
- almTotalLiquidity: ratio * wrappedALM.almTotalLiquidity,
429
- forwarderType: Forwarder.CLAMM,
430
- label: `${ALMMapping[pool.amm]?.[w.type]} ${w.address}`,
431
- origin: w.type,
432
- positions: wrappedALM.positions.map(pos => {
433
- return {
434
- ...pos,
435
- balance0: ratio * pos.balance0,
436
- balance1: ratio * pos.balance1,
437
- inRangeLiquidity: ratio * pos.inRangeLiquidity,
438
- totalLiquidity: ratio * pos.totalLiquidity,
439
- tvl: ratio * pos.tvl,
440
- };
441
- }),
442
- priority: wrappedALM.priority + 1,
443
- sender: utils.getAddress(w.address),
444
- target: w.target,
445
- owner: w.owner ?? w.address,
446
- totalSupply,
447
- type: w.type,
448
- });
449
- }
450
- else {
451
- log.local(`Target ALM not found (${NETWORK_LABELS[chainId]}). Address: ${w.address}, Target: ${w.target}`);
452
- }
453
- }
454
- catch {
455
- log.warn(`merklDynamic data - failed to handle multi hop alm data of pool ${pool.address} on ${NETWORK_LABELS[chainId]} - ${w.address}`);
456
- i = prevI + 1;
457
- }
458
- }
459
- /** A51 Strategies */
460
- for (const w of pool.alms.filter(a => a.type === ALM.A51)) {
461
- const prevI = i;
462
- const strategies = A51Strategies?.[pool.address.toLowerCase()]?.[w.address] ?? [];
463
- let j = 0;
464
- for (const strategy of strategies) {
465
- j++;
466
- const almPositionsWithAPIType = [];
467
- let almTotalLiquidity = 0;
468
- let almInRangeLiquidity = 0;
469
- let almBalance0 = 0;
470
- let almBalance1 = 0;
471
- try {
472
- // struct StrategyData {
473
- // StrategyKey key; 0
474
- // address owner; 1
475
- // bytes actions; 2
476
- // bytes actionStatus; 3
477
- // bool isCompound; 4
478
- // bool isPrivate; 5
479
- // uint256 managementFee; 6
480
- // uint256 performanceFee; 7
481
- // Account account; 8
482
- // }
483
- const strategyAccount = A51Interface.decodeFunctionResult("strategies", result[i++])[8];
484
- // struct Account {
485
- // uint256 fee0; 0
486
- // uint256 fee1; 1
487
- // uint256 balance0; 2
488
- // uint256 balance1; 3
489
- // uint256 totalShares; 4
490
- // uint128 uniswapLiquidity;
491
- // uint256 feeGrowthInside0LastX128;
492
- // uint256 feeGrowthInside1LastX128;
493
- // uint256 feeGrowthOutside0LastX128;
494
- // uint256 feeGrowthOutside1LastX128;
495
- // }
496
- const a51Positions = positions?.[pool.amm]?.filter(pos => pos.pool.id === pool.address.toLowerCase() &&
497
- pos.owner === w.address.toLowerCase() &&
498
- pos.tickLower === strategy.tickLower.toString() &&
499
- pos.tickUpper === strategy.tickUpper.toString());
500
- if (!!a51Positions) {
501
- for (const position of a51Positions) {
502
- const upperTick = Number.parseInt(position.tickUpper);
503
- const lowerTick = Number.parseInt(position.tickLower);
504
- const [amount0, amount1] = getAmountsForLiquidity(sqrtPrice, lowerTick, upperTick, BigNumber.from(position.liquidity));
505
- const balance0 = BN2Number(amount0, decimalsToken0);
506
- const balance1 = BN2Number(amount1, decimalsToken1);
507
- const totalLiquidity = BN2Number(position.liquidity);
508
- const inRangeLiquidity = balance0 > 0 && balance1 > 0 ? (BN2Number(position.liquidity) ?? 0) : 0;
509
- almTotalLiquidity += totalLiquidity;
510
- almInRangeLiquidity += inRangeLiquidity;
511
- almBalance0 += balance0;
512
- almBalance1 += balance1;
513
- almPositionsWithAPIType.push({
514
- balance0,
515
- balance1,
516
- id: position.id,
517
- inRangeLiquidity,
518
- lowerTick,
519
- totalLiquidity,
520
- tvl: priceToken0 * balance0 + priceToken1 * balance1,
521
- upperTick,
522
- });
523
- }
524
- }
525
- if (!!ALMMapping[pool.amm] && w.type in ALMMapping[pool.amm]) {
526
- almDetails.push({
527
- almAPR: 0,
528
- // filled later on
529
- almAddress: utils.getAddress(w.address),
530
- almBalance0,
531
- almBalance1,
532
- almIdleBalance0: 0,
533
- almIdleBalance1: 0,
534
- almInRangeLiquidity,
535
- almTVL: almBalance0 * priceToken0 + almBalance1 * priceToken1,
536
- almTotalLiquidity,
537
- forwarderType: Forwarder.CLAMM,
538
- label: `${ALMMapping[pool.amm]?.[w.type]} ${w.address} - ${strategy.id}`,
539
- origin: w.type,
540
- positions: almPositionsWithAPIType,
541
- priority: 0,
542
- sender: w.address,
543
- target: w.target,
544
- owner: w.owner ?? w.address,
545
- totalSupply: strategyAccount[4].toString(),
546
- type: w.type,
547
- });
548
- }
549
- }
550
- catch (e) {
551
- log.warn(`merklDynamic data - failed to handle A51 data of pool ${pool.address} on ${NETWORK_LABELS[chainId]} - ${w.address}`);
552
- i = prevI + j;
553
- }
554
- }
555
- }
556
- /** Iterate over distributions to compute APRs */
557
- for (const campaign of campaigns.filter(campaign => campaign.mainParameter.toLowerCase() === pool.mainParameter.toLowerCase())) {
558
- const c = campaign;
559
- const amount = BN2Number(c.amount, c.campaignParameters.decimalsRewardToken);
560
- const startTimestamp = BN2Number(c.startTimestamp, 0);
561
- const endTimestamp = BN2Number(c.endTimestamp, 0);
562
- const isLive = moment().unix() > startTimestamp && moment().unix() < endTimestamp;
563
- const totalWeight = BN2Number(c.campaignParameters.weightFees, 4) +
564
- BN2Number(c.campaignParameters.weightToken0, 4) +
565
- BN2Number(c.campaignParameters.weightToken1, 4);
566
- // Proportions in percentage
567
- const propFees = (BN2Number(c.campaignParameters.weightFees, 4) / totalWeight) * 100;
568
- const propToken0 = (BN2Number(c.campaignParameters.weightToken0, 4) / totalWeight) * 100;
569
- const propToken1 = (BN2Number(c.campaignParameters.weightToken1, 4) / totalWeight) * 100;
570
- let distributionMeanAPR = 0;
571
- let blacklistedBalance0 = 0;
572
- let blacklistedBalance1 = 0;
573
- let blacklistedLiquidity = 0;
574
- /**
575
- * @dev In case there is a super amm handling some other amm lp positions,
576
- * we only need to check the positions associated to this super amm subgraph
577
- * in order to compute the APRs.
578
- * Yet, the pool will still be labelled with the main amm
579
- */
580
- const amm = c.campaignParameters.whitelist.length > 0 &&
581
- !!PriorityAMM?.[chainId]?.[c.campaignParameters.whitelist[0]]
582
- ? PriorityAMM[chainId]?.[c.campaignParameters.whitelist[0]]
583
- : pool.amm;
584
- const aprs = {};
585
- const aprBreakdowns = [];
586
- /** Clear alm APRs */
587
- const distributionForwarders = almDetails.map(x => ({ ...x }));
588
- let priceRewardToken = 0;
589
- if (isLive && c.campaignParameters.symbolRewardToken !== "aglaMerkl") {
590
- // priceRewardToken = (await pricer.get({
591
- // address: c.rewardToken,
592
- // chainId: chainId,
593
- // symbol: c.campaignParameters.symbolRewardToken,
594
- // })) as number;
595
- priceRewardToken = await TokenService.getRewardTokenPrice(campaign);
596
- /**
597
- * Handle whitelisted/blacklisted addresses to compute APR
598
- */
599
- if (c.campaignParameters.whitelist.length > 0) {
600
- blacklistedBalance0 = poolBalanceToken0;
601
- blacklistedBalance1 = poolBalanceToken1;
602
- blacklistedLiquidity = poolTotalLiquidity;
603
- // Get all beefy staker is whitelisted, get a list of all senders
604
- let targetToMatch = "";
605
- for (const alm of almDetails.filter(a => a.type === ALM.BeefyStaker)) {
606
- if (c.campaignParameters.whitelist.includes(alm.sender)) {
607
- targetToMatch = alm.target;
608
- }
609
- }
610
- if (targetToMatch !== "") {
611
- for (const alm of almDetails.filter(a => a.type === ALM.Beefy)) {
612
- if (targetToMatch === alm.sender.toLowerCase()) {
613
- c.campaignParameters.whitelist.push(alm.owner);
614
- }
615
- }
616
- }
617
- positions?.[pool.amm]?.forEach(pos => {
618
- if (pos.pool.id === pool.address.toLowerCase() &&
619
- (isWhitelisted(pos.owner, c.campaignParameters.whitelist) || isStrykeCampaign(pool.amm))) {
620
- let [amount0, amount1] = [BigNumber.from(0), BigNumber.from(0)];
621
- try {
622
- [amount0, amount1] = getAmountsForLiquidity(sqrtPrice, Number.parseInt(pos.tickLower), Number.parseInt(pos.tickUpper), BigNumber.from(pos.liquidity));
623
- }
624
- catch {
625
- log.warn(`merklDynamic data - failed to handle whitelisted positions of pool ${pool.address} on ${NETWORK_LABELS[chainId]} - ${pos.owner} ${pos.tickLower} ${pos.tickUpper} ${pos.liquidity}`);
626
- }
627
- blacklistedBalance0 -= BN2Number(amount0, decimalsToken0);
628
- blacklistedBalance1 -= BN2Number(amount1, decimalsToken1);
629
- if (c.campaignParameters.isOutOfRangeIncentivized
630
- ? BN2Number(amount0, decimalsToken0) > 0 || BN2Number(amount1, decimalsToken1) > 0
631
- : BN2Number(amount0, decimalsToken0) > 0 && BN2Number(amount1, decimalsToken1) > 0)
632
- blacklistedLiquidity -= BN2Number(pos.liquidity);
633
- }
634
- // Handling the case of a ALM of priority 2 being whitelisted
635
- else if (pos.pool.id === pool.address.toLowerCase() &&
636
- almDetails.map(a => a.target.toLowerCase()).includes(pos.owner.toLowerCase()) // If pos owner is an ALM
637
- ) {
638
- // If we're in this branch it means the ALM owning the position is not whitelisted
639
- const almHolding = almDetails.filter(a => a.almAddress.toLowerCase() === pos.owner.toLowerCase())[0];
640
- for (const whitelistedAddress of c.campaignParameters.whitelist) {
641
- const forwarderIndex = distributionForwarders.findIndex(f => utils.getAddress(f.almAddress) === utils.getAddress(whitelistedAddress));
642
- if (forwarderIndex !== -1 &&
643
- almHolding.almAddress.toLowerCase() ===
644
- distributionForwarders[forwarderIndex].target.toLowerCase()) {
645
- // If we are here it means one of the ALM whitelisted is a "child" of the ALM holding the position
646
- const childALM = distributionForwarders[forwarderIndex];
647
- let [amount0, amount1] = [BigNumber.from(0), BigNumber.from(0)];
648
- try {
649
- [amount0, amount1] = getAmountsForLiquidity(sqrtPrice, Number.parseInt(pos.tickLower), Number.parseInt(pos.tickUpper), BigNumber.from(pos.liquidity));
650
- }
651
- catch {
652
- log.warn(`merklDynamic data - failed to handle whitelisted positions of pool ${pool.address} on ${NETWORK_LABELS[chainId]} - ${pos.owner} ${pos.tickLower} ${pos.tickUpper} ${pos.liquidity}`);
653
- }
654
- blacklistedBalance0 -=
655
- (BN2Number(amount0, decimalsToken0) * childALM.almBalance0) / almHolding.almBalance0;
656
- blacklistedBalance1 -=
657
- (BN2Number(amount1, decimalsToken1) * childALM.almBalance1) / almHolding.almBalance1;
658
- if (c.campaignParameters.isOutOfRangeIncentivized
659
- ? BN2Number(amount0, decimalsToken0) > 0 || BN2Number(amount1, decimalsToken1) > 0
660
- : BN2Number(amount0, decimalsToken0) > 0 && BN2Number(amount1, decimalsToken1) > 0)
661
- blacklistedLiquidity -=
662
- (BN2Number(pos.liquidity) * childALM.almTotalLiquidity) / almHolding.almTotalLiquidity;
663
- }
664
- }
665
- }
666
- });
667
- }
668
- else if (c.campaignParameters.blacklist.length > 0) {
669
- blacklistedBalance0 = 0;
670
- blacklistedBalance1 = 0;
671
- blacklistedLiquidity = 0;
672
- for (const blacklistedAddress of c.campaignParameters.blacklist) {
673
- const blackAddressPositions = positions?.[amm]?.filter(pos => pos.pool.id === pool.address.toLowerCase() && pos.owner === blacklistedAddress.toLowerCase());
674
- if (!!blackAddressPositions) {
675
- for (const position of blackAddressPositions) {
676
- const [amount0, amount1] = getAmountsForLiquidity(sqrtPrice, Number.parseInt(position.tickLower), Number.parseInt(position.tickUpper), BigNumber.from(position.liquidity));
677
- blacklistedBalance0 += BN2Number(amount0, decimalsToken0);
678
- blacklistedBalance1 += BN2Number(amount1, decimalsToken1);
679
- if (BN2Number(amount0, decimalsToken0) > 0 && BN2Number(amount1, decimalsToken1) > 0)
680
- blacklistedLiquidity += BN2Number(position.liquidity);
681
- }
682
- }
683
- }
684
- }
685
- /** Yearly rewards in $ */
686
- const yearlyToken0Rewards = (propToken0 * priceRewardToken * amount * (365 * 24 * 3_600)) / (endTimestamp - startTimestamp);
687
- const yearlyToken1Rewards = (propToken1 * priceRewardToken * amount * (365 * 24 * 3_600)) / (endTimestamp - startTimestamp);
688
- const yearlyFeeRewards = (propFees * priceRewardToken * amount * (365 * 24 * 3_600)) / (endTimestamp - startTimestamp);
689
- let poolAPRkey = "";
690
- // /**
691
- // * @notice Stryke users receive rewards with respect to their LP positions (they hold through
692
- // * Stryke contracts and the `used liquidity` hold in the Stryke option market contracts
693
- // */
694
- // if (amm === AMM.Stryke || amm === AMM.StrykePCS) {
695
- // try {
696
- // poolBalanceToken0 +=
697
- // BN2Number(
698
- // await Erc20__factory.connect(c.campaignParameters.token0, providers[chainId]).balanceOf(
699
- // DOPEX_OPTION_MARKET[pool.address.toLowerCase()]
700
- // ),
701
- // c.campaignParameters.decimalsToken0
702
- // ) / 2;
703
- // poolBalanceToken1 +=
704
- // BN2Number(
705
- // await Erc20__factory.connect(c.campaignParameters.token1, providers[chainId]).balanceOf(
706
- // DOPEX_OPTION_MARKET[pool.address.toLowerCase()]
707
- // ),
708
- // c.campaignParameters.decimalsToken1
709
- // ) / 2;
710
- // } catch {
711
- // log.error(
712
- // "clamm dynamic data fetching",
713
- // `failed to handle dopex option market - ${pool.address}`
714
- // );
715
- // }
716
- // }
717
- /**
718
- * General APR (@notice potentially with a boost)
719
- */
720
- let poolBalanceToken0WithoutBlacklist = poolBalanceToken0 - (blacklistedBalance0 ?? 0);
721
- poolBalanceToken0WithoutBlacklist = !!poolBalanceToken0WithoutBlacklist
722
- ? poolBalanceToken0WithoutBlacklist
723
- : 0.00001;
724
- let poolBalanceToken1WithoutBlacklist = poolBalanceToken1 - (blacklistedBalance1 ?? 0);
725
- poolBalanceToken1WithoutBlacklist = !!poolBalanceToken1WithoutBlacklist
726
- ? poolBalanceToken1WithoutBlacklist
727
- : 0.00001;
728
- const poolLiquidityWithoutBlacklist = poolTotalLiquidity - (blacklistedLiquidity ?? 0);
729
- const tvl = isStrykeCampaign(amm)
730
- ? (await axios.get(`https://api.stryke.xyz/clamm/stats/tvl/${pool.address}?chainId=${chainId}`)).data
731
- : poolBalanceToken0WithoutBlacklist * priceToken0 + poolBalanceToken1WithoutBlacklist * priceToken1;
732
- distributionMeanAPR = (yearlyToken0Rewards + yearlyToken1Rewards + yearlyFeeRewards) / tvl;
733
- distributionMeanAPR =
734
- !distributionMeanAPR || Number.isNaN(distributionMeanAPR) ? 0 : distributionMeanAPR;
735
- /**
736
- * @dev We cannot include a whitelisted distrib apr into the mean APR
737
- */
738
- if (c.campaignParameters.whitelist.length === 0) {
739
- poolAPRkey = "Average APR (rewards / pool TVL)";
740
- if (!aprs[poolAPRkey])
741
- aprs[poolAPRkey] = 0;
742
- aprs[poolAPRkey] += distributionMeanAPR;
743
- // @Hugo wip: new way to structure aprBreakdowns
744
- aprBreakdowns.push({
745
- address: pool.address,
746
- value: distributionMeanAPR,
747
- type: EAprBreakdownType.AVERAGE,
748
- label: "Average APR (rewards / pool TVL)",
749
- });
750
- // APR per token
751
- poolAPRkey = `APR for holding ${c.campaignParameters.symbolToken0} in pool`;
752
- if (!aprs[poolAPRkey])
753
- aprs[poolAPRkey] = 0;
754
- aprs[poolAPRkey] += yearlyToken0Rewards / (poolBalanceToken0WithoutBlacklist * priceToken0);
755
- // @Hugo wip: new way to structure aprBreakdowns
756
- aprBreakdowns.push({
757
- address: pool.address,
758
- value: yearlyToken0Rewards / (poolBalanceToken0WithoutBlacklist * priceToken0),
759
- type: EAprBreakdownType.TOKEN1,
760
- label: c.campaignParameters.symbolToken0,
761
- });
762
- poolAPRkey = `APR for holding ${c.campaignParameters.symbolToken1} in pool`;
763
- if (!aprs[poolAPRkey])
764
- aprs[poolAPRkey] = 0;
765
- aprs[poolAPRkey] += yearlyToken1Rewards / (poolBalanceToken1WithoutBlacklist * priceToken1);
766
- // @Hugo wip: new way to structure aprBreakdowns
767
- aprBreakdowns.push({
768
- address: pool.address,
769
- value: yearlyToken1Rewards / (poolBalanceToken1WithoutBlacklist * priceToken1),
770
- type: EAprBreakdownType.TOKEN2,
771
- label: c.campaignParameters.symbolToken1,
772
- });
773
- }
774
- else {
775
- for (const whitelistedAddress of c.campaignParameters.whitelist) {
776
- const forwarderIndex = distributionForwarders.findIndex(f => utils.getAddress(f.almAddress) === utils.getAddress(whitelistedAddress));
777
- const poolAPRkey = `Whitelisted campaign on ${ammName(amm)} via address ${shortenAddress(c.campaignParameters.whitelist[0])} Average APR`;
778
- if (!aprs[poolAPRkey])
779
- aprs[poolAPRkey] = 0;
780
- // Account for idle liquidity
781
- if (forwarderIndex > -1) {
782
- // @Hugo wip: new way to structure aprBreakdowns
783
- const breakdownWl = {
784
- address: c.campaignParameters.whitelist[0],
785
- value: 0,
786
- type: EAprBreakdownType.WHITELIST,
787
- label: ammName(amm),
788
- };
789
- if (distributionForwarders[forwarderIndex].priority === 2) {
790
- distributionMeanAPR =
791
- (yearlyToken0Rewards + yearlyToken1Rewards + yearlyFeeRewards) /
792
- (tvl +
793
- distributionForwarders[forwarderIndex].almBalance0 * priceToken0 +
794
- distributionForwarders[forwarderIndex].almBalance1 * priceToken1);
795
- }
796
- else {
797
- distributionMeanAPR =
798
- (yearlyToken0Rewards + yearlyToken1Rewards + yearlyFeeRewards) /
799
- (tvl +
800
- distributionForwarders[forwarderIndex].almIdleBalance0 * priceToken0 +
801
- distributionForwarders[forwarderIndex].almIdleBalance1 * priceToken1);
802
- }
803
- distributionMeanAPR =
804
- !distributionMeanAPR || Number.isNaN(distributionMeanAPR) ? 0 : distributionMeanAPR;
805
- // @Hugo wip: new way to structure aprBreakdowns
806
- breakdownWl.value = distributionMeanAPR;
807
- aprBreakdowns.push(breakdownWl);
808
- }
809
- }
810
- aprs[poolAPRkey] += distributionMeanAPR;
811
- }
812
- /**
813
- * ALM APRs
814
- * @notice given a campaign
815
- * */
816
- distributionForwarders.forEach((alm, index) => {
817
- const targetForwarder = distributionForwarders.filter(f => f.almAddress.toLowerCase() === alm.target.toLowerCase())?.[0];
818
- // @Hugo wip: new way to structure aprBreakdowns
819
- const aprsBreakdown = getForwarderAprbreakDown(distributionForwarders, alm, c, pool, yearlyToken0Rewards, yearlyToken1Rewards, yearlyFeeRewards, poolBalanceToken0WithoutBlacklist, poolBalanceToken1WithoutBlacklist, poolLiquidityWithoutBlacklist, tvl, distributionMeanAPR, index, chainId, amm);
820
- // @Hugo wip: new way to structure aprBreakdowns
821
- aprsBreakdown && aprBreakdowns.push(aprsBreakdown);
822
- const isALMWhitelisted = c.campaignParameters.whitelist.length > 0
823
- ? isStrykeCampaign(pool.amm)
824
- ? true
825
- : isWhitelisted(alm.sender, c.campaignParameters.whitelist) ||
826
- isWhitelisted(alm.almAddress, c.campaignParameters.whitelist) ||
827
- isWhitelisted(!!alm?.owner ? alm.owner : "", c.campaignParameters.whitelist) ||
828
- isWhitelisted(!!alm?.target ? alm.target : "", c.campaignParameters.whitelist) ||
829
- (!!targetForwarder?.owner &&
830
- isWhitelisted(targetForwarder?.owner, c.campaignParameters.whitelist))
831
- : true;
832
- const isBlacklistedByCampaign = isBlacklisted(alm.sender, c.campaignParameters.blacklist) ||
833
- isBlacklisted(alm.almAddress, c.campaignParameters.blacklist) ||
834
- (!!alm?.target && isBlacklisted(alm?.target, c.campaignParameters.blacklist)) ||
835
- !isALMWhitelisted;
836
- if (!isBlacklistedByCampaign && !!alm.almTVL && alm.almTVL > 0) {
837
- try {
838
- poolAPRkey = `${almName(alm.origin)} ${alm.almAddress}`;
839
- if (!aprs[poolAPRkey])
840
- aprs[poolAPRkey] = 0;
841
- // Token 0 APR
842
- const almToken0APR = (yearlyToken0Rewards * (alm?.almBalance0 ?? 0 - alm?.almIdleBalance0 ?? 0)) /
843
- poolBalanceToken0WithoutBlacklist /
844
- alm.almTVL;
845
- aprs[poolAPRkey] += almToken0APR;
846
- // Token 1 APR
847
- const almToken1APR = (yearlyToken1Rewards * (alm?.almBalance1 ?? 0 - alm?.almIdleBalance1 ?? 0)) /
848
- poolBalanceToken1WithoutBlacklist /
849
- alm.almTVL;
850
- ((alm.almBalance1 / (alm?.almBalance1 ?? 0 + alm?.almIdleBalance1 ?? 0)) *
851
- alm.almBalance1 *
852
- yearlyToken1Rewards) /
853
- poolBalanceToken1WithoutBlacklist /
854
- alm.almTVL;
855
- aprs[poolAPRkey] += almToken1APR;
856
- // Fee APR
857
- const almFeeAPR = (yearlyFeeRewards * (alm?.almInRangeLiquidity ?? 0)) /
858
- poolLiquidityWithoutBlacklist /
859
- alm.almTVL;
860
- aprs[poolAPRkey] += almFeeAPR;
861
- if (isStrykeCampaign(amm)) {
862
- // computation is less precise here as we don't have the details of balances
863
- aprs[poolAPRkey] = (yearlyToken0Rewards + yearlyToken1Rewards + yearlyFeeRewards) / tvl;
864
- }
865
- /** Fix to tackle discrepancies in the APRs when there is a whitelist */
866
- if ((c.campaignParameters.whitelist?.length === 1 &&
867
- (isWhitelisted(alm.sender, c.campaignParameters.whitelist) ||
868
- isWhitelisted(alm.almAddress, c.campaignParameters.whitelist) ||
869
- isWhitelisted(!!alm?.target ? alm.target : "", c.campaignParameters.whitelist) ||
870
- isWhitelisted(!!alm?.owner ? alm.owner : "", c.campaignParameters.whitelist))) ||
871
- (!!targetForwarder?.owner &&
872
- isWhitelisted(targetForwarder?.owner, c.campaignParameters.whitelist))) {
873
- if (aprs[poolAPRkey] < distributionMeanAPR || !aprs[poolAPRkey] || aprs[poolAPRkey] > 1e12) {
874
- aprs[poolAPRkey] = distributionMeanAPR;
875
- }
876
- }
877
- distributionForwarders[index].almAPR = aprs[poolAPRkey];
878
- }
879
- catch (e) {
880
- log.error("CLAMMDynamicData", `failed to compute ALM APR for ${alm.almAddress} (sender ${alm.sender}) on ${NETWORK_LABELS[chainId]}: ${e}`);
881
- }
882
- }
883
- });
884
- }
885
- dynamicData.push({
886
- ...campaign,
887
- amm: pool.amm,
888
- ammAlgo: AMMAlgorithmMapping[pool.amm],
889
- ammAlgoName: AMMAlgorithm[AMMAlgorithmMapping[pool.amm]],
890
- ammName: AMM[pool.amm],
891
- apr: distributionMeanAPR,
892
- aprs,
893
- aprBreakdowns,
894
- blacklistedBalance0,
895
- blacklistedBalance1,
896
- blacklistedLiquidity,
897
- forwarders: distributionForwarders,
898
- isLive,
899
- isMock: c.campaignParameters.symbolRewardToken === "aglaMerkl",
900
- poolBalanceToken0,
901
- poolBalanceToken1,
902
- poolTotalLiquidity,
903
- symbolToken0,
904
- symbolToken1,
905
- tick: getTickAtSqrtRatio(JSBI.BigInt(sqrtPrice)),
906
- priceRewardToken: priceRewardToken,
907
- tvl: isStrykeCampaign(pool.amm)
908
- ? (await axios.get(`https://api.stryke.xyz/clamm/stats/tvl/${pool.address}?chainId=${chainId}`)).data
909
- : poolBalanceToken0 * priceToken0 + poolBalanceToken1 * priceToken1,
910
- });
911
- }
912
- }
913
- }
914
- return dynamicData;
915
- },
916
- },
917
- };
918
- }
919
- // Fallback in case something fails
920
- return {
921
- cached: false,
922
- call: {
923
- callData: [],
924
- handler: () => { },
925
- reducer: async (_result) => {
926
- return campaigns;
927
- },
928
- },
929
- };
930
- }
931
- function getForwarderAprbreakDown(distributionForwarders, alm, campaign, pool, yearlyToken0Rewards, yearlyToken1Rewards, yearlyFeeRewards, poolBalanceToken0WithoutBlacklist, poolBalanceToken1WithoutBlacklist, poolLiquidityWithoutBlacklist, tvl, distributionMeanAPR, index, chainId, amm) {
932
- if (!distributionForwarders)
933
- return null;
934
- let aprBreakdowns = null;
935
- const targetForwarder = distributionForwarders.filter(f => f.almAddress.toLowerCase() === alm.target.toLowerCase())?.[0];
936
- const isALMWhitelisted = campaign.campaignParameters.whitelist.length > 0
937
- ? isStrykeCampaign(pool.amm)
938
- ? true
939
- : isWhitelisted(alm.sender, campaign.campaignParameters.whitelist) ||
940
- isWhitelisted(alm.almAddress, campaign.campaignParameters.whitelist) ||
941
- isWhitelisted(!!alm?.owner ? alm.owner : "", campaign.campaignParameters.whitelist) ||
942
- isWhitelisted(!!alm?.target ? alm.target : "", campaign.campaignParameters.whitelist) ||
943
- (!!targetForwarder?.owner && isWhitelisted(targetForwarder?.owner, campaign.campaignParameters.whitelist))
944
- : true;
945
- const isBlacklistedByCampaign = isBlacklisted(alm.sender, campaign.campaignParameters.blacklist) ||
946
- isBlacklisted(alm.almAddress, campaign.campaignParameters.blacklist) ||
947
- (!!alm?.target && isBlacklisted(alm?.target, campaign.campaignParameters.blacklist)) ||
948
- !isALMWhitelisted;
949
- if (!isBlacklistedByCampaign && !!alm.almTVL && alm.almTVL > 0) {
950
- try {
951
- // Token 0 APR
952
- const almToken0APR = (yearlyToken0Rewards * (alm?.almBalance0 ?? 0 - alm?.almIdleBalance0 ?? 0)) /
953
- poolBalanceToken0WithoutBlacklist /
954
- alm.almTVL;
955
- // Token 1 APR
956
- const almToken1APR = (yearlyToken1Rewards * (alm?.almBalance1 ?? 0 - alm?.almIdleBalance1 ?? 0)) /
957
- poolBalanceToken1WithoutBlacklist /
958
- alm.almTVL;
959
- // Fee APR
960
- const almFeeAPR = (yearlyFeeRewards * (alm?.almInRangeLiquidity ?? 0)) / poolLiquidityWithoutBlacklist / alm.almTVL;
961
- let aprValue = almToken0APR + almToken1APR + almFeeAPR;
962
- // computation is less precise here as we don't have the details of balances
963
- if (isStrykeCampaign(amm))
964
- aprValue = (yearlyToken0Rewards + yearlyToken1Rewards + yearlyFeeRewards) / tvl;
965
- /** Fix to tackle discrepancies in the APRs when there is a whitelist */
966
- if ((campaign.campaignParameters.whitelist?.length === 1 &&
967
- (isWhitelisted(alm.sender, campaign.campaignParameters.whitelist) ||
968
- isWhitelisted(alm.almAddress, campaign.campaignParameters.whitelist) ||
969
- isWhitelisted(!!alm?.target ? alm.target : "", campaign.campaignParameters.whitelist) ||
970
- isWhitelisted(!!alm?.owner ? alm.owner : "", campaign.campaignParameters.whitelist))) ||
971
- (!!targetForwarder?.owner && isWhitelisted(targetForwarder?.owner, campaign.campaignParameters.whitelist))) {
972
- if (aprValue < distributionMeanAPR || !aprValue || aprValue > 1e12)
973
- aprValue = distributionMeanAPR;
974
- }
975
- aprBreakdowns = {
976
- address: pool.address,
977
- value: aprValue,
978
- type: EAprBreakdownType.FORWARDER,
979
- label: almName(alm.origin),
980
- };
981
- distributionForwarders[index].almAPR = aprValue; // @Hugo wip: new way to structure aprBreakdowns + check this
982
- }
983
- catch (e) {
984
- log.error("CLAMMDynamicData", `failed to compute ALM APR for ${alm.almAddress} (sender ${alm.sender}) on ${NETWORK_LABELS[chainId]}: ${e}`);
985
- }
986
- }
987
- return aprBreakdowns;
988
- }