@gearbox-protocol/sdk 1.22.4 → 1.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (284) hide show
  1. package/lib/apy/convexAPY.d.ts +10 -10
  2. package/lib/apy/convexAPY.js +100 -121
  3. package/lib/apy/curveAPY.d.ts +3 -4
  4. package/lib/apy/curveAPY.js +57 -111
  5. package/lib/apy/index.js +4 -6
  6. package/lib/apy/lidoAPY.d.ts +1 -2
  7. package/lib/apy/lidoAPY.js +14 -62
  8. package/lib/apy/yearnAPY.d.ts +2 -3
  9. package/lib/apy/yearnAPY.js +26 -82
  10. package/lib/contracts/contracts.js +9 -22
  11. package/lib/contracts/contractsRegister.js +39 -51
  12. package/lib/contracts/protocols.js +10 -11
  13. package/lib/core/adapter.js +9 -4
  14. package/lib/core/assets.d.ts +6 -7
  15. package/lib/core/assets.js +60 -70
  16. package/lib/core/chains.js +30 -80
  17. package/lib/core/constants.d.ts +9 -10
  18. package/lib/core/constants.js +9 -12
  19. package/lib/core/creditAccount.d.ts +20 -20
  20. package/lib/core/creditAccount.js +123 -134
  21. package/lib/core/creditAccount.spec.js +50 -52
  22. package/lib/core/creditManager.d.ts +26 -26
  23. package/lib/core/creditManager.js +172 -136
  24. package/lib/core/creditManager.spec.js +59 -61
  25. package/lib/core/creditSession.d.ts +12 -13
  26. package/lib/core/creditSession.js +120 -77
  27. package/lib/core/errors.d.ts +2 -3
  28. package/lib/core/errors.js +11 -27
  29. package/lib/core/eventOrTx.js +35 -73
  30. package/lib/core/events.d.ts +19 -20
  31. package/lib/core/events.js +698 -711
  32. package/lib/core/operations.js +11 -5
  33. package/lib/core/pool/data.d.ts +29 -29
  34. package/lib/core/pool/data.js +153 -112
  35. package/lib/core/pool/operation.d.ts +1 -2
  36. package/lib/core/pool/operation.js +23 -35
  37. package/lib/core/priceOracle.d.ts +6 -6
  38. package/lib/core/priceOracle.js +23 -29
  39. package/lib/core/rewardClaimer.d.ts +3 -3
  40. package/lib/core/rewardClaimer.js +5 -48
  41. package/lib/core/rewardConvex.d.ts +1 -1
  42. package/lib/core/rewardConvex.js +58 -118
  43. package/lib/core/rewardConvex.spec.js +56 -58
  44. package/lib/core/strategy.d.ts +5 -6
  45. package/lib/core/strategy.js +67 -69
  46. package/lib/core/strategy.spec.js +32 -34
  47. package/lib/core/tokenDistributor.d.ts +1 -2
  48. package/lib/core/trade.d.ts +6 -6
  49. package/lib/core/trade.js +70 -115
  50. package/lib/core/transactions.d.ts +21 -22
  51. package/lib/core/transactions.js +285 -308
  52. package/lib/index.d.ts +0 -2
  53. package/lib/index.js +0 -2
  54. package/lib/oracles/oracles.d.ts +1 -2
  55. package/lib/oracles/priceFeeds.js +2 -3
  56. package/lib/parsers/ERC20Parser.js +20 -38
  57. package/lib/parsers/abstractParser.js +33 -31
  58. package/lib/parsers/addressProviderParser.js +12 -30
  59. package/lib/parsers/airdropDistributorParser.js +12 -30
  60. package/lib/parsers/convexBaseRewardPoolAdapterParser.js +24 -42
  61. package/lib/parsers/convexBaseRewardPoolAdapterParser.spec.js +11 -11
  62. package/lib/parsers/convexBoosterAdapterParser.js +26 -44
  63. package/lib/parsers/convexBoosterAdapterParser.spec.js +10 -10
  64. package/lib/parsers/convextRewardPoolParser.js +12 -30
  65. package/lib/parsers/creditFacadeParser.js +26 -45
  66. package/lib/parsers/creditFacadeParser.spec.js +13 -13
  67. package/lib/parsers/creditManagerParser.js +12 -30
  68. package/lib/parsers/curveAdapterParser.js +60 -78
  69. package/lib/parsers/curveAdapterParser.spec.js +20 -27
  70. package/lib/parsers/dataCompressorParser.js +12 -30
  71. package/lib/parsers/lidoAdapterParser.js +15 -33
  72. package/lib/parsers/lidoAdapterParser.spec.js +9 -9
  73. package/lib/parsers/lidoOracleParser.js +12 -30
  74. package/lib/parsers/lidoSTETHParser.js +19 -37
  75. package/lib/parsers/multicallParser.js +16 -34
  76. package/lib/parsers/offchainOracleParser.js +13 -31
  77. package/lib/parsers/poolParser.js +11 -29
  78. package/lib/parsers/priceOracleParser.js +13 -31
  79. package/lib/parsers/txParser.js +86 -96
  80. package/lib/parsers/uniV2AdapterParser.js +35 -55
  81. package/lib/parsers/uniV2AdapterParser.spec.js +15 -16
  82. package/lib/parsers/uniV3AdapterParser.js +56 -74
  83. package/lib/parsers/uniV3AdapterParser.spec.js +23 -24
  84. package/lib/parsers/wstETHAdapterParser.js +25 -43
  85. package/lib/parsers/wstETHAdapterParser.spec.js +11 -11
  86. package/lib/parsers/yearnAdapterParser.spec.js +17 -17
  87. package/lib/parsers/yearnV2AdapterParser.js +25 -43
  88. package/lib/pathfinder/core.d.ts +3 -4
  89. package/lib/pathfinder/pathOptions.js +52 -101
  90. package/lib/pathfinder/pathOptions.spec.js +55 -57
  91. package/lib/pathfinder/pathfinder.d.ts +3 -3
  92. package/lib/pathfinder/pathfinder.js +109 -202
  93. package/lib/pathfinder/pathfinder.spec.js +13 -13
  94. package/lib/strategies/convex.js +111 -123
  95. package/lib/strategies/creditFacade.js +34 -37
  96. package/lib/strategies/curve.js +74 -80
  97. package/lib/strategies/lido.js +26 -32
  98. package/lib/strategies/uniswapV2.js +21 -24
  99. package/lib/strategies/uniswapV3.js +33 -36
  100. package/lib/strategies/yearn.js +47 -59
  101. package/lib/tokens/balancer.js +3 -5
  102. package/lib/tokens/convex.js +14 -29
  103. package/lib/tokens/curveLP.js +22 -28
  104. package/lib/tokens/gear.js +1 -1
  105. package/lib/tokens/normal.js +3 -5
  106. package/lib/tokens/token.js +29 -35
  107. package/lib/tokens/tokenData.d.ts +0 -9
  108. package/lib/tokens/tokenData.js +17 -15
  109. package/lib/tokens/yearn.js +3 -5
  110. package/lib/types/factories/@chainlink/contracts/src/v0.8/interfaces/AggregatorInterface__factory.js +9 -12
  111. package/lib/types/factories/@chainlink/contracts/src/v0.8/interfaces/AggregatorV2V3Interface__factory.js +9 -12
  112. package/lib/types/factories/@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface__factory.js +9 -12
  113. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IACL.sol/IACLEvents__factory.js +9 -12
  114. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IACL.sol/IACLExceptions__factory.js +9 -12
  115. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IACL.sol/IACL__factory.js +9 -12
  116. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IAccountFactory.sol/IAccountFactoryEvents__factory.js +9 -12
  117. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IAccountFactory.sol/IAccountFactoryGetters__factory.js +9 -12
  118. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IAccountFactory.sol/IAccountFactory__factory.js +9 -12
  119. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IAddressProvider.sol/IAddressProviderEvents__factory.js +9 -12
  120. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IAddressProvider.sol/IAddressProvider__factory.js +9 -12
  121. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IAirdropDistributor.sol/IAirdropDistributorEvents__factory.js +9 -12
  122. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IAirdropDistributor.sol/IAirdropDistributor__factory.js +9 -12
  123. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IContractsRegister.sol/IContractsRegisterEvents__factory.js +9 -12
  124. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IContractsRegister.sol/IContractsRegister__factory.js +9 -12
  125. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditAccount.sol/ICrediAccountExceptions__factory.js +9 -12
  126. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditAccount.sol/ICreditAccount__factory.js +9 -12
  127. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditConfigurator.sol/ICreditConfiguratorEvents__factory.js +9 -12
  128. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditConfigurator.sol/ICreditConfiguratorExceptions__factory.js +9 -12
  129. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditConfigurator.sol/ICreditConfigurator__factory.js +9 -12
  130. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditFacade.sol/ICreditFacadeEvents__factory.js +9 -12
  131. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditFacade.sol/ICreditFacadeExceptions__factory.js +9 -12
  132. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditFacade.sol/ICreditFacadeExtended__factory.js +9 -12
  133. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditFacade.sol/ICreditFacade__factory.js +9 -12
  134. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditManagerV2.sol/ICreditManagerV2Events__factory.js +9 -12
  135. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditManagerV2.sol/ICreditManagerV2Exceptions__factory.js +9 -12
  136. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditManagerV2.sol/ICreditManagerV2__factory.js +9 -12
  137. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDataCompressor.sol/IDataCompressorExceptions__factory.js +9 -12
  138. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDataCompressor.sol/IDataCompressor__factory.js +9 -12
  139. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDegenDistributor.sol/IDegenDistributorEvents__factory.js +9 -12
  140. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDegenDistributor.sol/IDegenDistributor__factory.js +9 -12
  141. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDegenNFT.sol/IDegenNFTEvents__factory.js +9 -12
  142. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDegenNFT.sol/IDegenNFTExceptions__factory.js +9 -12
  143. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDegenNFT.sol/IDegenNFT__factory.js +9 -12
  144. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDieselToken.sol/IDieselTokenExceptions__factory.js +9 -12
  145. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDieselToken.sol/IDieselToken__factory.js +9 -12
  146. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IInterestRateModel__factory.js +9 -12
  147. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ILPPriceFeed.sol/ILPPriceFeedEvents__factory.js +9 -12
  148. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ILPPriceFeed.sol/ILPPriceFeedExceptions__factory.js +9 -12
  149. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ILPPriceFeed.sol/ILPPriceFeed__factory.js +9 -12
  150. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPhantomERC20__factory.js +9 -12
  151. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPoolService.sol/IPoolServiceEvents__factory.js +9 -12
  152. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPoolService.sol/IPoolService__factory.js +9 -12
  153. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPriceFeedType__factory.js +9 -12
  154. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPriceOracle.sol/IPriceOracleV2Events__factory.js +9 -12
  155. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPriceOracle.sol/IPriceOracleV2Exceptions__factory.js +9 -12
  156. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPriceOracle.sol/IPriceOracleV2Ext__factory.js +9 -12
  157. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPriceOracle.sol/IPriceOracleV2__factory.js +9 -12
  158. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IVersion__factory.js +9 -12
  159. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IWETHGateway__factory.js +9 -12
  160. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/V1/ICreditFilter__factory.js +9 -12
  161. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/V1/ICreditManager__factory.js +9 -12
  162. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/adapters/IAdapter.sol/IAdapterExceptions__factory.js +9 -12
  163. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/adapters/IAdapter.sol/IAdapter__factory.js +9 -12
  164. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/adapters/IUniversalAdapter.sol/IUniversalAdapterExceptions__factory.js +9 -12
  165. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/adapters/IUniversalAdapter.sol/IUniversalAdapter__factory.js +9 -12
  166. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/external/IWETH__factory.js +9 -12
  167. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/pool/PoolService__factory.js +27 -50
  168. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/test/interfaces/ITokenTestSuite__factory.js +9 -12
  169. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IBaseRewardPool__factory.js +9 -12
  170. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IBooster__factory.js +9 -12
  171. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IClaimZap__factory.js +9 -12
  172. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IConvexToken__factory.js +9 -12
  173. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IRewards.sol/IBasicRewards__factory.js +9 -12
  174. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IRewards.sol/IRewards__factory.js +9 -12
  175. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/ICrvDeposit__factory.js +9 -12
  176. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/ICurveGauge__factory.js +9 -12
  177. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/ICurveVoteEscrow__factory.js +9 -12
  178. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IDeposit__factory.js +9 -12
  179. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IFeeDistro__factory.js +9 -12
  180. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IMinter__factory.js +9 -12
  181. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IPools__factory.js +9 -12
  182. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IRegistry__factory.js +9 -12
  183. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IRewardFactory__factory.js +9 -12
  184. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IRewards__factory.js +9 -12
  185. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IStaker__factory.js +9 -12
  186. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IStashFactory__factory.js +9 -12
  187. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IStash__factory.js +9 -12
  188. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/ITokenFactory__factory.js +9 -12
  189. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/ITokenMinter__factory.js +9 -12
  190. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IVestedEscrow__factory.js +9 -12
  191. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IVoting__factory.js +9 -12
  192. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IWalletChecker__factory.js +9 -12
  193. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/curve/ICurvePoolStETH__factory.js +9 -12
  194. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/curve/ICurvePool_2.sol/ICurvePool2Assets__factory.js +9 -12
  195. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/curve/ICurvePool_3.sol/ICurvePool3Assets__factory.js +9 -12
  196. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/curve/ICurvePool_4.sol/ICurvePool4Assets__factory.js +9 -12
  197. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/curve/ICurvePool__factory.js +9 -12
  198. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/curve/ICurveRegistry__factory.js +9 -12
  199. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/lido/ILidoOracle__factory.js +9 -12
  200. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/lido/IstETH.sol/IstETHGetters__factory.js +9 -12
  201. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/lido/IstETH.sol/IstETH__factory.js +9 -12
  202. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/lido/IwstETH.sol/IwstETHGetters__factory.js +9 -12
  203. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/lido/IwstETH.sol/IwstETH__factory.js +9 -12
  204. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/lido/IwstETHGateway.sol/IwstETHGateWay__factory.js +9 -12
  205. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/uniswap/IQuoter__factory.js +9 -12
  206. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/uniswap/IUniswapV2Router01__factory.js +9 -12
  207. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/uniswap/IUniswapV2Router02__factory.js +9 -12
  208. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/uniswap/IUniswapV3.sol/ISwapRouter__factory.js +9 -12
  209. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/yearn/IYVault__factory.js +9 -12
  210. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/convex/IConvexV1BaseRewardPoolAdapter.sol/IConvexV1BaseRewardPoolAdapterErrors__factory.js +9 -12
  211. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/convex/IConvexV1BaseRewardPoolAdapter.sol/IConvexV1BaseRewardPoolAdapter__factory.js +9 -12
  212. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/convex/IConvexV1BoosterAdapter__factory.js +9 -12
  213. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/curve/ICurveV1Adapter.sol/ICurveV1AdapterExceptions__factory.js +9 -12
  214. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/curve/ICurveV1Adapter.sol/ICurveV1Adapter__factory.js +9 -12
  215. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/curve/ICurveV1_2AssetsAdapter__factory.js +9 -12
  216. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/curve/ICurveV1_3AssetsAdapter__factory.js +9 -12
  217. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/curve/ICurveV1_4AssetsAdapter__factory.js +9 -12
  218. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/lido/ILidoV1Adapter.sol/ILidoV1AdapterEvents__factory.js +9 -12
  219. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/lido/ILidoV1Adapter.sol/ILidoV1AdapterExceptions__factory.js +9 -12
  220. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/lido/ILidoV1Adapter.sol/ILidoV1Adapter__factory.js +9 -12
  221. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/lido/IwstETHV1Adapter__factory.js +9 -12
  222. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/uniswap/IUniswapPathChecker__factory.js +9 -12
  223. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/uniswap/IUniswapV2Adapter.sol/IUniswapV2AdapterExceptions__factory.js +9 -12
  224. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/uniswap/IUniswapV2Adapter.sol/IUniswapV2Adapter__factory.js +9 -12
  225. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/uniswap/IUniswapV3Adapter.sol/IUniswapV3AdapterExceptions__factory.js +9 -12
  226. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/uniswap/IUniswapV3Adapter.sol/IUniswapV3Adapter__factory.js +9 -12
  227. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/yearn/IYearnV2Adapter__factory.js +9 -12
  228. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/test/config/SupportedContracts.sol/ISupportedContracts__factory.js +9 -12
  229. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/test/mocks/integrations/LidoMock.sol/ILidoMockEvents__factory.js +9 -12
  230. package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IClosePathResolver__factory.js +9 -12
  231. package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IDepositor.sol/IDepositorOptions__factory.js +9 -12
  232. package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IDepositor.sol/IDepositor__factory.js +9 -12
  233. package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IGasPricer__factory.js +9 -12
  234. package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/ILPWorker.sol/ILPWorkerOptions__factory.js +9 -12
  235. package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/ILPWorker.sol/ILPWorker__factory.js +9 -12
  236. package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IPathResolver__factory.js +9 -12
  237. package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IRouterComponent__factory.js +9 -12
  238. package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IRouter__factory.js +9 -12
  239. package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/ISwapAggregator__factory.js +9 -12
  240. package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/ISwapper__factory.js +9 -12
  241. package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IWithdrawer.sol/IWithdrawerOptions__factory.js +9 -12
  242. package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IWithdrawer.sol/IWithdrawer__factory.js +9 -12
  243. package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IWrapper__factory.js +9 -12
  244. package/lib/types/factories/@openzeppelin/contracts/token/ERC20/IERC20__factory.js +9 -12
  245. package/lib/types/factories/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata__factory.js +9 -12
  246. package/lib/types/factories/@openzeppelin/contracts/token/ERC721/IERC721Receiver__factory.js +9 -12
  247. package/lib/types/factories/@openzeppelin/contracts/token/ERC721/IERC721__factory.js +9 -12
  248. package/lib/types/factories/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata__factory.js +9 -12
  249. package/lib/types/factories/@openzeppelin/contracts/utils/introspection/IERC165__factory.js +9 -12
  250. package/lib/types/factories/contracts/IGas__factory.js +9 -12
  251. package/lib/types/factories/contracts/IGnosisSafeSignatureValidator__factory.js +9 -12
  252. package/lib/types/factories/contracts/ITokenDistributor.sol/ITokenDistributorEvents__factory.js +9 -12
  253. package/lib/types/factories/contracts/ITokenDistributor.sol/ITokenDistributorExceptions__factory.js +9 -12
  254. package/lib/types/factories/contracts/ITokenDistributor.sol/ITokenDistributor__factory.js +9 -12
  255. package/lib/types/factories/contracts/support/IOffchainOracle__factory.js +9 -12
  256. package/lib/types/factories/contracts/support/MultiCall.sol/Multicall2__factory.js +27 -50
  257. package/lib/utils/errors.js +1 -1
  258. package/lib/utils/extracter.js +4 -4
  259. package/lib/utils/formatter.d.ts +8 -8
  260. package/lib/utils/formatter.js +73 -87
  261. package/lib/utils/loading.js +3 -3
  262. package/lib/utils/mappers.js +7 -34
  263. package/lib/utils/math.d.ts +10 -7
  264. package/lib/utils/math.js +22 -25
  265. package/lib/utils/multicall.js +32 -98
  266. package/lib/utils/price.d.ts +3 -4
  267. package/lib/utils/price.js +8 -20
  268. package/lib/utils/repeater.js +12 -53
  269. package/lib/utils/validate.js +2 -2
  270. package/lib/watchers/creditAccountWatcher.js +136 -237
  271. package/lib/watchers/creditAccountWatcher.spec.js +51 -68
  272. package/lib/watchers/creditManagerWatcher.js +21 -71
  273. package/lib/watchers/creditManagerWatcher.spec.js +20 -23
  274. package/package.json +2 -2
  275. package/lib/core/history.d.ts +0 -42
  276. package/lib/core/history.js +0 -2
  277. package/lib/core/wcOperation/abstractOperations.d.ts +0 -23
  278. package/lib/core/wcOperation/abstractOperations.js +0 -39
  279. package/lib/core/wcOperation/index.d.ts +0 -11
  280. package/lib/core/wcOperation/index.js +0 -30
  281. package/lib/core/wcOperation/operations.d.ts +0 -88
  282. package/lib/core/wcOperation/operations.js +0 -146
  283. package/lib/core/wcOperation/types.d.ts +0 -15
  284. package/lib/core/wcOperation/types.js +0 -2
@@ -1,4 +1,4 @@
1
- import { BigNumber, providers } from "ethers";
1
+ import { providers } from "ethers";
2
2
  import { SupportedContract } from "../contracts/contracts";
3
3
  import { MultiCall } from "../pathfinder/core";
4
4
  import { SupportedToken } from "../tokens/token";
@@ -7,11 +7,11 @@ import { CreditAccountData } from "./creditAccount";
7
7
  import { CreditManagerData } from "./creditManager";
8
8
  export interface Rewards {
9
9
  contract: SupportedContract;
10
- rewards: Partial<Record<SupportedToken, BigNumber>>;
10
+ rewards: Partial<Record<SupportedToken, bigint>>;
11
11
  calls: Array<MultiCall>;
12
12
  }
13
13
  export interface AdapterWithType {
14
- adapter: string;
14
+ contractAddress: string;
15
15
  contract: SupportedContract;
16
16
  }
17
17
  export declare class RewardClaimer {
@@ -1,53 +1,10 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
2
  Object.defineProperty(exports, "__esModule", { value: true });
39
3
  exports.RewardClaimer = void 0;
40
- var rewardConvex_1 = require("./rewardConvex");
41
- var RewardClaimer = /** @class */ (function () {
42
- function RewardClaimer() {
4
+ const rewardConvex_1 = require("./rewardConvex");
5
+ class RewardClaimer {
6
+ static async findRewards(ca, cm, network, provider) {
7
+ return rewardConvex_1.RewardConvex.findRewards(ca, cm, network, provider);
43
8
  }
44
- RewardClaimer.findRewards = function (ca, cm, network, provider) {
45
- return __awaiter(this, void 0, void 0, function () {
46
- return __generator(this, function (_a) {
47
- return [2 /*return*/, rewardConvex_1.RewardConvex.findRewards(ca, cm, network, provider)];
48
- });
49
- });
50
- };
51
- return RewardClaimer;
52
- }());
9
+ }
53
10
  exports.RewardClaimer = RewardClaimer;
@@ -8,7 +8,7 @@ import { CreditAccountData } from "./creditAccount";
8
8
  import { CreditManagerData } from "./creditManager";
9
9
  import { AdapterWithType, Rewards } from "./rewardClaimer";
10
10
  export interface RewardDistribution {
11
- adapter: string;
11
+ contractAddress: string;
12
12
  contract: SupportedContract;
13
13
  token: SupportedToken;
14
14
  }
@@ -1,118 +1,60 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
2
  Object.defineProperty(exports, "__esModule", { value: true });
39
3
  exports.RewardConvex = void 0;
40
- var ethers_1 = require("ethers");
41
- var apy_1 = require("../apy");
42
- var adapters_1 = require("../contracts/adapters");
43
- var contracts_1 = require("../contracts/contracts");
44
- var token_1 = require("../tokens/token");
45
- var types_1 = require("../types");
46
- var multicall_1 = require("../utils/multicall");
47
- var RewardConvex = /** @class */ (function () {
48
- function RewardConvex() {
49
- }
50
- RewardConvex.findRewards = function (ca, cm, network, provider) {
51
- return __awaiter(this, void 0, void 0, function () {
52
- var _a, calls, distribution, mcalls, rewards, totalSupply, results;
53
- return __generator(this, function (_b) {
54
- switch (_b.label) {
55
- case 0:
56
- _a = RewardConvex.prepareMultiCalls(ca.addr, cm, network), calls = _a.calls, distribution = _a.distribution;
57
- mcalls = calls;
58
- mcalls.push({
59
- address: token_1.tokenDataByNetwork[network].CVX,
60
- interface: types_1.IConvexToken__factory.createInterface(),
61
- method: "totalSupply()",
62
- });
63
- return [4 /*yield*/, (0, multicall_1.multicall)(mcalls, provider)];
64
- case 1:
65
- rewards = _b.sent();
66
- totalSupply = rewards.pop();
67
- results = RewardConvex.parseResults(ca.addr, rewards, distribution);
68
- results.forEach(function (r) {
69
- r.rewards.CVX = (0, apy_1.getCVXMintAmount)(r.rewards.CRV || ethers_1.BigNumber.from(0), totalSupply);
70
- });
71
- return [2 /*return*/, results];
72
- }
73
- });
4
+ const apy_1 = require("../apy");
5
+ const adapters_1 = require("../contracts/adapters");
6
+ const contracts_1 = require("../contracts/contracts");
7
+ const token_1 = require("../tokens/token");
8
+ const types_1 = require("../types");
9
+ const formatter_1 = require("../utils/formatter");
10
+ const multicall_1 = require("../utils/multicall");
11
+ class RewardConvex {
12
+ static poolInterface = types_1.IConvexV1BaseRewardPoolAdapter__factory.createInterface();
13
+ static async findRewards(ca, cm, network, provider) {
14
+ const { calls, distribution } = RewardConvex.prepareMultiCalls(ca.addr, cm, network);
15
+ const mcalls = calls;
16
+ mcalls.push({
17
+ address: token_1.tokenDataByNetwork[network].CVX,
18
+ interface: types_1.IConvexToken__factory.createInterface(),
19
+ method: "totalSupply()",
74
20
  });
75
- };
76
- RewardConvex.findAdapters = function (cm) {
77
- var convexPools = Object.entries(contracts_1.contractParams)
78
- .filter(function (_a) {
79
- var _ = _a[0], params = _a[1];
80
- return params.type === adapters_1.AdapterInterface.CONVEX_V1_BASE_REWARD_POOL;
81
- })
82
- .map(function (_a) {
83
- var contract = _a[0];
84
- return contract;
21
+ const rewards = await (0, multicall_1.multicall)(mcalls, provider);
22
+ const totalSupply = rewards.pop();
23
+ const results = RewardConvex.parseResults(ca.addr, rewards, distribution);
24
+ results.forEach(r => {
25
+ r.rewards.CVX = (0, apy_1.getCVXMintAmount)(r.rewards.CRV || 0n, (0, formatter_1.toBigInt)(totalSupply));
85
26
  });
27
+ return results;
28
+ }
29
+ static findAdapters(cm) {
30
+ const convexPools = Object.entries(contracts_1.contractParams)
31
+ .filter(([_, params]) => params.type === adapters_1.AdapterInterface.CONVEX_V1_BASE_REWARD_POOL)
32
+ .map(([contract]) => contract);
86
33
  return Object.entries(cm.adapters)
87
- .map(function (_a) {
88
- var contract = _a[0], adapter = _a[1];
89
- return ({
90
- adapter: adapter,
91
- contract: contracts_1.contractsByAddress[contract.toLowerCase()],
92
- });
93
- })
94
- .filter(function (a) { return convexPools.includes(a.contract); });
95
- };
96
- RewardConvex.prepareMultiCalls = function (creditAccount, cm, network) {
97
- var calls = [];
98
- var distribution = [];
99
- var adapters = this.findAdapters(cm);
100
- for (var _i = 0, adapters_2 = adapters; _i < adapters_2.length; _i++) {
101
- var a = adapters_2[_i];
34
+ .map(([contract]) => ({
35
+ contractAddress: contract,
36
+ contract: contracts_1.contractsByAddress[contract.toLowerCase()],
37
+ }))
38
+ .filter(a => convexPools.includes(a.contract));
39
+ }
40
+ static prepareMultiCalls(creditAccount, cm, network) {
41
+ const calls = [];
42
+ const distribution = [];
43
+ const adapters = this.findAdapters(cm);
44
+ for (let a of adapters) {
102
45
  calls.push({
103
- address: a.adapter,
46
+ address: a.contractAddress,
104
47
  interface: RewardConvex.poolInterface,
105
48
  method: "earned(address)",
106
49
  params: [creditAccount],
107
50
  });
108
51
  distribution.push({
109
- adapter: a.adapter,
52
+ contractAddress: a.contractAddress,
110
53
  contract: a.contract,
111
54
  token: "CRV",
112
55
  });
113
- var params = contracts_1.contractParams[a.contract];
114
- for (var _a = 0, _b = params.extraRewards; _a < _b.length; _a++) {
115
- var er = _b[_a];
56
+ const params = contracts_1.contractParams[a.contract];
57
+ for (let er of params.extraRewards) {
116
58
  calls.push({
117
59
  address: er.poolAddress[network],
118
60
  interface: RewardConvex.poolInterface,
@@ -120,42 +62,40 @@ var RewardConvex = /** @class */ (function () {
120
62
  params: [creditAccount],
121
63
  });
122
64
  distribution.push({
123
- adapter: a.adapter,
65
+ contractAddress: a.contractAddress,
124
66
  contract: a.contract,
125
67
  token: er.rewardToken,
126
68
  });
127
69
  }
128
70
  }
129
71
  return {
130
- calls: calls,
131
- distribution: distribution,
72
+ calls,
73
+ distribution,
132
74
  };
133
- };
134
- RewardConvex.parseResults = function (creditAccount, rewards, distribution) {
135
- var result = {};
136
- var callData = RewardConvex.poolInterface.encodeFunctionData("getReward(address,bool)", [creditAccount, true]);
137
- for (var i = 0; i < rewards.length; i++) {
138
- var _a = distribution[i], contract = _a.contract, adapter = _a.adapter, token = _a.token;
139
- var reward = rewards[i];
75
+ }
76
+ static parseResults(creditAccount, rewards, distribution) {
77
+ const result = {};
78
+ const callData = RewardConvex.poolInterface.encodeFunctionData("getReward(address,bool)", [creditAccount, true]);
79
+ for (let i = 0; i < rewards.length; i++) {
80
+ const { contract, contractAddress, token } = distribution[i];
81
+ const reward = rewards[i];
140
82
  if (!reward.isZero()) {
141
83
  if (!result[contract]) {
142
84
  result[contract] = {
143
- contract: contract,
85
+ contract,
144
86
  rewards: {},
145
87
  calls: [
146
88
  {
147
- target: adapter,
148
- callData: callData,
89
+ target: contractAddress,
90
+ callData,
149
91
  },
150
92
  ],
151
93
  };
152
94
  }
153
- result[contract].rewards[token] = reward;
95
+ result[contract].rewards[token] = BigInt(reward.toString());
154
96
  }
155
97
  }
156
98
  return Object.values(result);
157
- };
158
- RewardConvex.poolInterface = types_1.IConvexV1BaseRewardPoolAdapter__factory.createInterface();
159
- return RewardConvex;
160
- }());
99
+ }
100
+ }
161
101
  exports.RewardConvex = RewardConvex;
@@ -1,55 +1,53 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var chai_1 = require("chai");
4
- var ethers_1 = require("ethers");
5
- var contracts_1 = require("../contracts/contracts");
6
- var constants_1 = require("./constants");
7
- var rewardConvex_1 = require("./rewardConvex");
8
- var ADAPTER_CONVEX_3CRV_POOL = constants_1.DUMB_ADDRESS;
9
- var ADAPTER_CURVE_FRAX_POOL = constants_1.DUMB_ADDRESS2;
10
- var ADAPTER_CONVEX_FRAX3CRV_POOL = constants_1.DUMB_ADDRESS3;
11
- var CREDIT_ACCOUNT = constants_1.DUMB_ADDRESS4;
12
- describe("RewardConvex test", function () {
13
- it("findAdapters find convex adapters correctly", function () {
14
- var _a;
15
- var cm = {
16
- adapters: (_a = {},
17
- _a[contracts_1.contractsByNetwork.Mainnet.CONVEX_3CRV_POOL] = ADAPTER_CONVEX_3CRV_POOL,
18
- _a[contracts_1.contractsByNetwork.Mainnet.CURVE_FRAX_POOL] = ADAPTER_CURVE_FRAX_POOL,
19
- _a[contracts_1.contractsByNetwork.Goerli.CONVEX_FRAX3CRV_POOL] = ADAPTER_CONVEX_FRAX3CRV_POOL,
20
- _a),
3
+ const chai_1 = require("chai");
4
+ const ethers_1 = require("ethers");
5
+ const contracts_1 = require("../contracts/contracts");
6
+ const constants_1 = require("./constants");
7
+ const rewardConvex_1 = require("./rewardConvex");
8
+ const ADAPTER_CONVEX_3CRV_POOL = constants_1.DUMB_ADDRESS;
9
+ const ADAPTER_CURVE_FRAX_POOL = constants_1.DUMB_ADDRESS2;
10
+ const ADAPTER_CONVEX_FRAX3CRV_POOL = constants_1.DUMB_ADDRESS3;
11
+ const CREDIT_ACCOUNT = constants_1.DUMB_ADDRESS4;
12
+ describe("RewardConvex test", () => {
13
+ it("findAdapters find convex adapters correctly", () => {
14
+ const cm = {
15
+ adapters: {
16
+ [contracts_1.contractsByNetwork.Mainnet.CONVEX_3CRV_POOL]: ADAPTER_CONVEX_3CRV_POOL,
17
+ [contracts_1.contractsByNetwork.Mainnet.CURVE_FRAX_POOL]: ADAPTER_CURVE_FRAX_POOL,
18
+ [contracts_1.contractsByNetwork.Goerli.CONVEX_FRAX3CRV_POOL]: ADAPTER_CONVEX_FRAX3CRV_POOL,
19
+ },
21
20
  };
22
- var expectedResult = [
21
+ const expectedResult = [
23
22
  {
24
- adapter: ADAPTER_CONVEX_3CRV_POOL,
25
23
  contract: "CONVEX_3CRV_POOL",
24
+ contractAddress: contracts_1.contractsByNetwork.Mainnet.CONVEX_3CRV_POOL,
26
25
  },
27
26
  {
28
- adapter: ADAPTER_CONVEX_FRAX3CRV_POOL,
29
27
  contract: "CONVEX_FRAX3CRV_POOL",
28
+ contractAddress: contracts_1.contractsByNetwork.Goerli.CONVEX_FRAX3CRV_POOL,
30
29
  },
31
30
  ];
32
- var result = rewardConvex_1.RewardConvex.findAdapters(cm);
31
+ const result = rewardConvex_1.RewardConvex.findAdapters(cm);
33
32
  (0, chai_1.expect)(result).to.be.eql(expectedResult);
34
33
  });
35
- it("prepareMultiCalls prepares multicall data correctly", function () {
36
- var _a;
37
- var cm = {
38
- adapters: (_a = {},
39
- _a[contracts_1.contractsByNetwork.Mainnet.CONVEX_3CRV_POOL] = ADAPTER_CONVEX_3CRV_POOL,
40
- _a[contracts_1.contractsByNetwork.Mainnet.CURVE_FRAX_POOL] = ADAPTER_CURVE_FRAX_POOL,
41
- _a[contracts_1.contractsByNetwork.Goerli.CONVEX_FRAX3CRV_POOL] = ADAPTER_CONVEX_FRAX3CRV_POOL,
42
- _a),
34
+ it("prepareMultiCalls prepares multicall data correctly", () => {
35
+ const cm = {
36
+ adapters: {
37
+ [contracts_1.contractsByNetwork.Mainnet.CONVEX_3CRV_POOL]: ADAPTER_CONVEX_3CRV_POOL,
38
+ [contracts_1.contractsByNetwork.Mainnet.CURVE_FRAX_POOL]: ADAPTER_CURVE_FRAX_POOL,
39
+ [contracts_1.contractsByNetwork.Goerli.CONVEX_FRAX3CRV_POOL]: ADAPTER_CONVEX_FRAX3CRV_POOL,
40
+ },
43
41
  };
44
- var calls = [
42
+ const calls = [
45
43
  {
46
- address: ADAPTER_CONVEX_3CRV_POOL,
44
+ address: contracts_1.contractsByNetwork.Mainnet.CONVEX_3CRV_POOL,
47
45
  interface: rewardConvex_1.RewardConvex.poolInterface,
48
46
  method: "earned(address)",
49
47
  params: [CREDIT_ACCOUNT],
50
48
  },
51
49
  {
52
- address: ADAPTER_CONVEX_FRAX3CRV_POOL,
50
+ address: contracts_1.contractsByNetwork.Goerli.CONVEX_FRAX3CRV_POOL,
53
51
  interface: rewardConvex_1.RewardConvex.poolInterface,
54
52
  method: "earned(address)",
55
53
  params: [CREDIT_ACCOUNT],
@@ -62,74 +60,74 @@ describe("RewardConvex test", function () {
62
60
  params: [CREDIT_ACCOUNT],
63
61
  },
64
62
  ];
65
- var distribution = [
63
+ const distribution = [
66
64
  {
67
- adapter: ADAPTER_CONVEX_3CRV_POOL,
65
+ contractAddress: contracts_1.contractsByNetwork.Mainnet.CONVEX_3CRV_POOL,
68
66
  contract: "CONVEX_3CRV_POOL",
69
67
  token: "CRV",
70
68
  },
71
69
  {
72
- adapter: ADAPTER_CONVEX_FRAX3CRV_POOL,
70
+ contractAddress: contracts_1.contractsByNetwork.Goerli.CONVEX_FRAX3CRV_POOL,
73
71
  contract: "CONVEX_FRAX3CRV_POOL",
74
72
  token: "CRV",
75
73
  },
76
74
  {
77
- adapter: ADAPTER_CONVEX_FRAX3CRV_POOL,
75
+ contractAddress: contracts_1.contractsByNetwork.Goerli.CONVEX_FRAX3CRV_POOL,
78
76
  contract: "CONVEX_FRAX3CRV_POOL",
79
77
  token: "FXS",
80
78
  },
81
79
  ];
82
- var result = rewardConvex_1.RewardConvex.prepareMultiCalls(CREDIT_ACCOUNT, cm, "Mainnet");
83
- (0, chai_1.expect)(result).to.be.eql({ calls: calls, distribution: distribution });
80
+ const result = rewardConvex_1.RewardConvex.prepareMultiCalls(CREDIT_ACCOUNT, cm, "Mainnet");
81
+ (0, chai_1.expect)(result).to.be.eql({ calls, distribution });
84
82
  });
85
- it("parseResults parse data correctly", function () {
86
- var rewards = [
87
- ethers_1.BigNumber.from(1000),
88
- ethers_1.BigNumber.from(2000),
89
- ethers_1.BigNumber.from(4000),
83
+ it("parseResults parse data correctly", () => {
84
+ const rewards = [
85
+ ethers_1.BigNumber.from(1000n),
86
+ ethers_1.BigNumber.from(2000n),
87
+ ethers_1.BigNumber.from(4000n),
90
88
  ];
91
- var distribution = [
89
+ const distribution = [
92
90
  {
93
- adapter: ADAPTER_CONVEX_3CRV_POOL,
91
+ contractAddress: contracts_1.contractsByNetwork.Mainnet.CONVEX_3CRV_POOL,
94
92
  contract: "CONVEX_3CRV_POOL",
95
93
  token: "CRV",
96
94
  },
97
95
  {
98
- adapter: ADAPTER_CONVEX_FRAX3CRV_POOL,
96
+ contractAddress: contracts_1.contractsByNetwork.Goerli.CONVEX_FRAX3CRV_POOL,
99
97
  contract: "CONVEX_FRAX3CRV_POOL",
100
98
  token: "CRV",
101
99
  },
102
100
  {
103
- adapter: ADAPTER_CONVEX_FRAX3CRV_POOL,
101
+ contractAddress: contracts_1.contractsByNetwork.Goerli.CONVEX_FRAX3CRV_POOL,
104
102
  contract: "CONVEX_FRAX3CRV_POOL",
105
103
  token: "FXS",
106
104
  },
107
105
  ];
108
- var parsed = rewardConvex_1.RewardConvex.parseResults(CREDIT_ACCOUNT, rewards, distribution);
109
- var callData = rewardConvex_1.RewardConvex.poolInterface.encodeFunctionData("getReward(address,bool)", [CREDIT_ACCOUNT, true]);
110
- var expected = [
106
+ const parsed = rewardConvex_1.RewardConvex.parseResults(CREDIT_ACCOUNT, rewards, distribution);
107
+ const callData = rewardConvex_1.RewardConvex.poolInterface.encodeFunctionData("getReward(address,bool)", [CREDIT_ACCOUNT, true]);
108
+ const expected = [
111
109
  {
112
110
  contract: "CONVEX_3CRV_POOL",
113
111
  rewards: {
114
- CRV: ethers_1.BigNumber.from(1000),
112
+ CRV: 1000n,
115
113
  },
116
114
  calls: [
117
115
  {
118
- target: ADAPTER_CONVEX_3CRV_POOL,
119
- callData: callData,
116
+ target: contracts_1.contractsByNetwork.Mainnet.CONVEX_3CRV_POOL,
117
+ callData,
120
118
  },
121
119
  ],
122
120
  },
123
121
  {
124
122
  contract: "CONVEX_FRAX3CRV_POOL",
125
123
  rewards: {
126
- CRV: ethers_1.BigNumber.from(2000),
127
- FXS: ethers_1.BigNumber.from(4000),
124
+ CRV: 2000n,
125
+ FXS: 4000n,
128
126
  },
129
127
  calls: [
130
128
  {
131
- target: ADAPTER_CONVEX_FRAX3CRV_POOL,
132
- callData: callData,
129
+ target: contracts_1.contractsByNetwork.Goerli.CONVEX_FRAX3CRV_POOL,
130
+ callData,
133
131
  },
134
132
  ],
135
133
  },
@@ -1,4 +1,3 @@
1
- import { BigNumber } from "ethers";
2
1
  import { CreditManagerData } from "./creditManager";
3
2
  export interface StrategyPayload {
4
3
  apy?: number;
@@ -10,11 +9,11 @@ export interface StrategyPayload {
10
9
  baseAssets: Array<string>;
11
10
  }
12
11
  interface LiquidationPriceProps {
13
- prices: Record<string, BigNumber>;
14
- liquidationThresholds: Record<string, BigNumber>;
15
- borrowed: BigNumber;
12
+ prices: Record<string, bigint>;
13
+ liquidationThresholds: Record<string, bigint>;
14
+ borrowed: bigint;
16
15
  underlyingToken: string;
17
- lpAmount: BigNumber;
16
+ lpAmount: bigint;
18
17
  lpToken: string;
19
18
  }
20
19
  export declare class Strategy {
@@ -29,7 +28,7 @@ export declare class Strategy {
29
28
  static maxLeverage(lpToken: string, cms: Array<PartialCM>): number;
30
29
  maxAPY(baseAPY: number, maxLeverage: number, borrowAPY: number): number;
31
30
  overallAPY(apy: number, leverage: number, depositCollateral: string, borrowAPY: number): number;
32
- static liquidationPrice({ prices, liquidationThresholds, borrowed, underlyingToken, lpAmount, lpToken, }: LiquidationPriceProps): BigNumber;
31
+ static liquidationPrice({ prices, liquidationThresholds, borrowed, underlyingToken, lpAmount, lpToken, }: LiquidationPriceProps): bigint;
33
32
  protected farmLev(leverage: number, depositCollateral: string): number;
34
33
  protected inBaseAssets(depositCollateral: string): boolean;
35
34
  protected inLeveragableAssets(depositCollateral: string): boolean;