@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,82 +1,65 @@
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 constants_1 = require("../core/constants");
6
- var types_1 = require("../types");
7
- var creditAccountWatcher_1 = require("./creditAccountWatcher");
8
- var CREDIT_MANAGER_ADDRESS = constants_1.DUMB_ADDRESS;
9
- var CREDIT_FACADE_ADDRESS = "0xcb9a588a47dd0393af3d0d5f86e6f1c8fd252c48";
10
- var CREDIT_FACADE_NEW = "0xcb9a588a47dd0393af3d0d5f86e6f1c8fd252ccc";
11
- var CREDIT_CONFIGURATOR_ADDRESS = "0xcb9a588a47dd0393af3d0d5f86e6f1c8fd252aaa";
12
- var CREDIT_CONFIGURATOR_NEW = "0xcb9a588a47dd0393af3d0d5f86e6f1c8fd252000";
13
- var BORROWER = "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266";
14
- var expectedHash = "".concat(CREDIT_MANAGER_ADDRESS.toLowerCase(), ":").concat(BORROWER.toLowerCase());
15
- var creditManagerInterface = types_1.ICreditManagerV2__factory.createInterface();
16
- var creditFacadeInterface = types_1.ICreditFacade__factory.createInterface();
17
- var creditConfiguratorInterface = types_1.ICreditConfigurator__factory.createInterface();
18
- var cmDumb = {
3
+ const chai_1 = require("chai");
4
+ const ethers_1 = require("ethers");
5
+ const constants_1 = require("../core/constants");
6
+ const types_1 = require("../types");
7
+ const creditAccountWatcher_1 = require("./creditAccountWatcher");
8
+ const CREDIT_MANAGER_ADDRESS = constants_1.DUMB_ADDRESS;
9
+ const CREDIT_FACADE_ADDRESS = "0xcb9a588a47dd0393af3d0d5f86e6f1c8fd252c48";
10
+ const CREDIT_FACADE_NEW = "0xcb9a588a47dd0393af3d0d5f86e6f1c8fd252ccc";
11
+ const CREDIT_CONFIGURATOR_ADDRESS = "0xcb9a588a47dd0393af3d0d5f86e6f1c8fd252aaa";
12
+ const CREDIT_CONFIGURATOR_NEW = "0xcb9a588a47dd0393af3d0d5f86e6f1c8fd252000";
13
+ const BORROWER = "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266";
14
+ const expectedHash = `${CREDIT_MANAGER_ADDRESS.toLowerCase()}:${BORROWER.toLowerCase()}`;
15
+ const creditManagerInterface = types_1.ICreditManagerV2__factory.createInterface();
16
+ const creditFacadeInterface = types_1.ICreditFacade__factory.createInterface();
17
+ const creditConfiguratorInterface = types_1.ICreditConfigurator__factory.createInterface();
18
+ const cmDumb = {
19
19
  address: CREDIT_MANAGER_ADDRESS.toLowerCase(),
20
20
  creditFacade: CREDIT_FACADE_ADDRESS.toLowerCase(),
21
21
  creditConfigurator: CREDIT_CONFIGURATOR_ADDRESS.toLowerCase(),
22
22
  };
23
- var encode = function (abiType, value) {
24
- return ethers_1.utils.defaultAbiCoder.encode([abiType], [value]);
25
- };
26
- var makeLog = function (address, topics, data) {
27
- if (data === void 0) { data = constants_1.ADDRESS_0X0; }
23
+ const encode = (abiType, value) => ethers_1.utils.defaultAbiCoder.encode([abiType], [value]);
24
+ const makeLog = (address, topics, data = constants_1.ADDRESS_0X0) => {
28
25
  return {
29
26
  blockNumber: 0,
30
27
  blockHash: "",
31
28
  transactionIndex: 0,
32
29
  removed: false,
33
- address: address,
34
- data: data,
35
- topics: topics,
30
+ address,
31
+ data,
32
+ topics,
36
33
  transactionHash: "",
37
34
  logIndex: 0,
38
35
  };
39
36
  };
40
- var openLog = function (facadeAddr) {
41
- if (facadeAddr === void 0) { facadeAddr = CREDIT_FACADE_ADDRESS; }
42
- return makeLog(facadeAddr, [
43
- creditFacadeInterface.getEventTopic("OpenCreditAccount"),
44
- encode("address", BORROWER),
45
- encode("address", constants_1.DUMB_ADDRESS),
46
- ], ethers_1.utils.defaultAbiCoder.encode(["uint256", "uint16"], [10, 10]));
47
- };
48
- var closeLog = function (facadeAddr) {
49
- if (facadeAddr === void 0) { facadeAddr = CREDIT_FACADE_ADDRESS; }
50
- return makeLog(facadeAddr, [
51
- creditFacadeInterface.getEventTopic("CloseCreditAccount"),
52
- encode("address", BORROWER),
53
- encode("address", constants_1.DUMB_ADDRESS),
54
- encode("address", constants_1.DUMB_ADDRESS),
55
- ]);
56
- };
57
- var upgradeFacadeLog = function (configuratorAddr, facadeAddr) {
58
- if (configuratorAddr === void 0) { configuratorAddr = CREDIT_CONFIGURATOR_NEW; }
59
- if (facadeAddr === void 0) { facadeAddr = CREDIT_FACADE_NEW; }
60
- return makeLog(configuratorAddr, [
61
- creditConfiguratorInterface.getEventTopic("CreditFacadeUpgraded"),
62
- encode("address", facadeAddr),
63
- ]);
64
- };
65
- var newConfiguratorLog = function (managerAddr, configuratorAddr) {
66
- if (managerAddr === void 0) { managerAddr = CREDIT_MANAGER_ADDRESS; }
67
- if (configuratorAddr === void 0) { configuratorAddr = CREDIT_CONFIGURATOR_NEW; }
68
- return makeLog(managerAddr, [
69
- creditManagerInterface.getEventTopic("NewConfigurator"),
70
- encode("address", configuratorAddr),
71
- ]);
72
- };
73
- describe("CreditAccountTracker test", function () {
74
- it("detects update events correctly", function () {
37
+ const openLog = (facadeAddr = CREDIT_FACADE_ADDRESS) => makeLog(facadeAddr, [
38
+ creditFacadeInterface.getEventTopic("OpenCreditAccount"),
39
+ encode("address", BORROWER),
40
+ encode("address", constants_1.DUMB_ADDRESS),
41
+ ], ethers_1.utils.defaultAbiCoder.encode(["uint256", "uint16"], [10, 10]));
42
+ const closeLog = (facadeAddr = CREDIT_FACADE_ADDRESS) => makeLog(facadeAddr, [
43
+ creditFacadeInterface.getEventTopic("CloseCreditAccount"),
44
+ encode("address", BORROWER),
45
+ encode("address", constants_1.DUMB_ADDRESS),
46
+ encode("address", constants_1.DUMB_ADDRESS),
47
+ ]);
48
+ const upgradeFacadeLog = (configuratorAddr = CREDIT_CONFIGURATOR_NEW, facadeAddr = CREDIT_FACADE_NEW) => makeLog(configuratorAddr, [
49
+ creditConfiguratorInterface.getEventTopic("CreditFacadeUpgraded"),
50
+ encode("address", facadeAddr),
51
+ ]);
52
+ const newConfiguratorLog = (managerAddr = CREDIT_MANAGER_ADDRESS, configuratorAddr = CREDIT_CONFIGURATOR_NEW) => makeLog(managerAddr, [
53
+ creditManagerInterface.getEventTopic("NewConfigurator"),
54
+ encode("address", configuratorAddr),
55
+ ]);
56
+ describe("CreditAccountTracker test", () => {
57
+ it("detects update events correctly", () => {
75
58
  (0, chai_1.expect)(creditAccountWatcher_1.CreditAccountWatcher.detectChanges([openLog()], [cmDumb])).to.be.eql({
76
59
  updated: [expectedHash],
77
60
  deleted: [],
78
61
  });
79
- var log = makeLog(CREDIT_FACADE_ADDRESS, [
62
+ let log = makeLog(CREDIT_FACADE_ADDRESS, [
80
63
  creditFacadeInterface.getEventTopic("IncreaseBorrowedAmount"),
81
64
  encode("address", BORROWER),
82
65
  ], ethers_1.utils.defaultAbiCoder.encode(["uint256"], [10]));
@@ -140,12 +123,12 @@ describe("CreditAccountTracker test", function () {
140
123
  //
141
124
  // DELETED
142
125
  //
143
- it("detects delete events correctly", function () {
126
+ it("detects delete events correctly", () => {
144
127
  (0, chai_1.expect)(creditAccountWatcher_1.CreditAccountWatcher.detectChanges([closeLog()], [cmDumb])).to.be.eql({
145
128
  updated: [],
146
129
  deleted: [expectedHash],
147
130
  });
148
- var log = makeLog(CREDIT_FACADE_ADDRESS, [
131
+ let log = makeLog(CREDIT_FACADE_ADDRESS, [
149
132
  creditFacadeInterface.getEventTopic("LiquidateCreditAccount"),
150
133
  encode("address", BORROWER),
151
134
  encode("address", constants_1.DUMB_ADDRESS),
@@ -168,7 +151,7 @@ describe("CreditAccountTracker test", function () {
168
151
  deleted: [expectedHash],
169
152
  });
170
153
  });
171
- it("doesn't make duplicated", function () {
154
+ it("doesn't make duplicated", () => {
172
155
  (0, chai_1.expect)(creditAccountWatcher_1.CreditAccountWatcher.detectChanges([openLog(), openLog(), openLog()], [cmDumb])).to.be.eql({
173
156
  updated: [expectedHash],
174
157
  deleted: [],
@@ -178,7 +161,7 @@ describe("CreditAccountTracker test", function () {
178
161
  deleted: [expectedHash],
179
162
  });
180
163
  });
181
- it("updates accounts were created and deleted in the batch", function () {
164
+ it("updates accounts were created and deleted in the batch", () => {
182
165
  (0, chai_1.expect)(creditAccountWatcher_1.CreditAccountWatcher.detectChanges([openLog(), closeLog()], [cmDumb])).to.be.eql({
183
166
  updated: [],
184
167
  deleted: [expectedHash],
@@ -188,20 +171,20 @@ describe("CreditAccountTracker test", function () {
188
171
  deleted: [expectedHash],
189
172
  });
190
173
  });
191
- it("TransferAccount works correctly", function () {
192
- var transferLog = makeLog(CREDIT_FACADE_ADDRESS, [
174
+ it("TransferAccount works correctly", () => {
175
+ const transferLog = makeLog(CREDIT_FACADE_ADDRESS, [
193
176
  creditFacadeInterface.getEventTopic("TransferAccount"),
194
177
  encode("address", BORROWER),
195
178
  encode("address", constants_1.DUMB_ADDRESS),
196
179
  ]);
197
180
  (0, chai_1.expect)(creditAccountWatcher_1.CreditAccountWatcher.detectChanges([openLog(), transferLog], [cmDumb])).to.be.eql({
198
181
  updated: [
199
- "".concat(CREDIT_MANAGER_ADDRESS.toLowerCase(), ":").concat(constants_1.DUMB_ADDRESS.toLowerCase()),
182
+ `${CREDIT_MANAGER_ADDRESS.toLowerCase()}:${constants_1.DUMB_ADDRESS.toLowerCase()}`,
200
183
  ],
201
184
  deleted: [expectedHash],
202
185
  });
203
186
  });
204
- it("correctly handles credit configurator change", function () {
187
+ it("correctly handles credit configurator change", () => {
205
188
  (0, chai_1.expect)(creditAccountWatcher_1.CreditAccountWatcher.detectChanges([
206
189
  openLog(),
207
190
  newConfiguratorLog(),
@@ -1,74 +1,27 @@
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.CreditManagerWatcher = void 0;
40
- var creditManager_1 = require("../core/creditManager");
41
- var types_1 = require("../types");
42
- var CreditManagerWatcher = /** @class */ (function () {
43
- function CreditManagerWatcher() {
44
- }
45
- CreditManagerWatcher.getV2CreditManagers = function (dataCompressor, signer, atBlock) {
46
- return __awaiter(this, void 0, void 0, function () {
47
- var creditManagers, creditManagersPayload;
48
- return __generator(this, function (_a) {
49
- switch (_a.label) {
50
- case 0:
51
- creditManagers = {};
52
- return [4 /*yield*/, types_1.IDataCompressor__factory.connect(dataCompressor, signer).getCreditManagersList({ blockTag: atBlock })];
53
- case 1:
54
- creditManagersPayload = _a.sent();
55
- creditManagersPayload
56
- .filter(function (c) { return c.version === 2; })
57
- .forEach(function (c) {
58
- creditManagers[c.addr.toLowerCase()] = new creditManager_1.CreditManagerData(c);
59
- });
60
- return [2 /*return*/, creditManagers];
61
- }
62
- });
4
+ const creditManager_1 = require("../core/creditManager");
5
+ const types_1 = require("../types");
6
+ class CreditManagerWatcher {
7
+ static creditManagerInterface = types_1.ICreditManagerV2__factory.createInterface();
8
+ static creditConfiguratorInterface = types_1.ICreditConfigurator__factory.createInterface();
9
+ static async getV2CreditManagers(dataCompressor, signer, atBlock) {
10
+ const creditManagers = {};
11
+ const creditManagersPayload = await types_1.IDataCompressor__factory.connect(dataCompressor, signer).getCreditManagersList({ blockTag: atBlock });
12
+ creditManagersPayload
13
+ .filter(c => c.version === 2)
14
+ .forEach(c => {
15
+ creditManagers[c.addr.toLowerCase()] = new creditManager_1.CreditManagerData(c);
63
16
  });
64
- };
65
- CreditManagerWatcher.detectConfigChanges = function (freshLogs, creditManagers) {
66
- var cms = creditManagers.map(function (c) { return c.address; });
67
- var ccs = creditManagers.map(function (c) { return c.creditConfigurator; });
68
- for (var _i = 0, freshLogs_1 = freshLogs; _i < freshLogs_1.length; _i++) {
69
- var log = freshLogs_1[_i];
17
+ return creditManagers;
18
+ }
19
+ static detectConfigChanges(freshLogs, creditManagers) {
20
+ const cms = creditManagers.map(c => c.address);
21
+ const ccs = creditManagers.map(c => c.creditConfigurator);
22
+ for (let log of freshLogs) {
70
23
  if (cms.includes(log.address.toLowerCase())) {
71
- var name = CreditManagerWatcher.creditManagerInterface.parseLog(log).name;
24
+ const { name } = CreditManagerWatcher.creditManagerInterface.parseLog(log);
72
25
  if (name === "NewConfigurator") {
73
26
  return true;
74
27
  }
@@ -78,9 +31,6 @@ var CreditManagerWatcher = /** @class */ (function () {
78
31
  }
79
32
  }
80
33
  return false;
81
- };
82
- CreditManagerWatcher.creditManagerInterface = types_1.ICreditManagerV2__factory.createInterface();
83
- CreditManagerWatcher.creditConfiguratorInterface = types_1.ICreditConfigurator__factory.createInterface();
84
- return CreditManagerWatcher;
85
- }());
34
+ }
35
+ }
86
36
  exports.CreditManagerWatcher = CreditManagerWatcher;
@@ -1,37 +1,34 @@
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 constants_1 = require("../core/constants");
6
- var types_1 = require("../types");
7
- var creditManagerWatcher_1 = require("./creditManagerWatcher");
8
- var CREDIT_MANAGER_ADDRESS = constants_1.DUMB_ADDRESS;
9
- var CREDIT_CONFIGIURATOR_ADDRESS = "0xcb9a588a47dd0393af3d0d5f86e6f1c8fd252c48";
10
- var cmDumb = {
3
+ const chai_1 = require("chai");
4
+ const ethers_1 = require("ethers");
5
+ const constants_1 = require("../core/constants");
6
+ const types_1 = require("../types");
7
+ const creditManagerWatcher_1 = require("./creditManagerWatcher");
8
+ const CREDIT_MANAGER_ADDRESS = constants_1.DUMB_ADDRESS;
9
+ const CREDIT_CONFIGIURATOR_ADDRESS = "0xcb9a588a47dd0393af3d0d5f86e6f1c8fd252c48";
10
+ const cmDumb = {
11
11
  address: CREDIT_MANAGER_ADDRESS.toLowerCase(),
12
12
  creditConfigurator: CREDIT_CONFIGIURATOR_ADDRESS.toLowerCase(),
13
13
  };
14
- var encode = function (abiType, value) {
15
- return ethers_1.utils.defaultAbiCoder.encode([abiType], [value]);
16
- };
17
- var makeLog = function (address, topics, data) {
18
- if (data === void 0) { data = constants_1.ADDRESS_0X0; }
14
+ const encode = (abiType, value) => ethers_1.utils.defaultAbiCoder.encode([abiType], [value]);
15
+ const makeLog = (address, topics, data = constants_1.ADDRESS_0X0) => {
19
16
  return {
20
17
  blockNumber: 0,
21
18
  blockHash: "",
22
19
  transactionIndex: 0,
23
20
  removed: false,
24
- address: address,
25
- data: data,
26
- topics: topics,
21
+ address,
22
+ data,
23
+ topics,
27
24
  transactionHash: "",
28
25
  logIndex: 0,
29
26
  };
30
27
  };
31
- describe("CreditManagerTracker test", function () {
32
- it("detects CreditManager events correctly", function () {
33
- var creditManagerInterface = types_1.ICreditManagerV2__factory.createInterface();
34
- var log = makeLog(CREDIT_MANAGER_ADDRESS, [
28
+ describe("CreditManagerTracker test", () => {
29
+ it("detects CreditManager events correctly", () => {
30
+ const creditManagerInterface = types_1.ICreditManagerV2__factory.createInterface();
31
+ let log = makeLog(CREDIT_MANAGER_ADDRESS, [
35
32
  creditManagerInterface.getEventTopic("NewConfigurator"),
36
33
  encode("address", constants_1.DUMB_ADDRESS),
37
34
  ]);
@@ -43,9 +40,9 @@ describe("CreditManagerTracker test", function () {
43
40
  ]);
44
41
  (0, chai_1.expect)(creditManagerWatcher_1.CreditManagerWatcher.detectConfigChanges([log], [cmDumb])).to.be.eq(false);
45
42
  });
46
- it("detects CreditConfigurator events correctly", function () {
47
- var ccInterface = types_1.ICreditConfigurator__factory.createInterface();
48
- var log = makeLog(CREDIT_CONFIGIURATOR_ADDRESS, [
43
+ it("detects CreditConfigurator events correctly", () => {
44
+ const ccInterface = types_1.ICreditConfigurator__factory.createInterface();
45
+ let log = makeLog(CREDIT_CONFIGIURATOR_ADDRESS, [
49
46
  ccInterface.getEventTopic("TokenLiquidationThresholdUpdated"),
50
47
  encode("address", constants_1.DUMB_ADDRESS),
51
48
  ], encode("uint16", 122));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "1.22.4",
3
+ "version": "1.23.1",
4
4
  "description": "Gearbox SDK",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -53,7 +53,7 @@
53
53
  "ts-node": "^10.9.1",
54
54
  "tslog": "^3.3.3",
55
55
  "typechain": "^8.1.0",
56
- "typescript": "^4.7.4"
56
+ "typescript": "5.0.4"
57
57
  },
58
58
  "prettier": "@gearbox-protocol/prettier-config",
59
59
  "lint-staged": {
@@ -1,42 +0,0 @@
1
- import { BigNumber } from "ethers";
2
- export interface BasicEvent {
3
- protocol: string;
4
- txHash: string;
5
- timestamp: number;
6
- }
7
- export type BasicSwapEvent = BasicEvent & {
8
- from: string;
9
- fromAmount: BigNumber;
10
- to: string;
11
- toAmount: BigNumber;
12
- };
13
- export type HistoryEvent = (BasicEvent & {
14
- action: "OpenCreditAccount";
15
- initialFunds: BigNumber;
16
- leverage: number;
17
- }) | (BasicEvent & {
18
- action: "CloseCreditAccount";
19
- remainingFunds: BigNumber;
20
- }) | (BasicEvent & {
21
- action: "LiquidateCreditAccount";
22
- remainingFunds: BigNumber;
23
- }) | (BasicEvent & {
24
- action: "IncreaseBorrowedAmount";
25
- amount: BigNumber;
26
- }) | (BasicEvent & {
27
- action: "AddCollateral";
28
- token: string;
29
- amount: BigNumber;
30
- }) | (BasicEvent & {
31
- action: "RepayCreditAccount";
32
- repayAmount: BigNumber;
33
- }) | (BasicEvent & {
34
- action: "TransferAccount";
35
- newAccount: string;
36
- }) | (BasicSwapEvent & {
37
- action: "Swap";
38
- }) | (BasicSwapEvent & {
39
- action: "Deposit";
40
- }) | (BasicSwapEvent & {
41
- action: "Withdraw";
42
- });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,23 +0,0 @@
1
- import type { TransactionRequest } from "@ethersproject/abstract-provider";
2
- import { BytesLike } from "ethers";
3
- import { RawTransaction } from ".";
4
- export interface BaseWcOperationProps {
5
- raw: RawTransaction;
6
- }
7
- export declare abstract class BaseWcOperation {
8
- readonly id: number;
9
- raw: RawTransaction;
10
- abstract readonly kind: string;
11
- constructor({ raw }: BaseWcOperationProps);
12
- }
13
- export interface SupportedWcOperationProps extends BaseWcOperationProps {
14
- tx: TransactionRequest;
15
- operation: string;
16
- calldata: BytesLike;
17
- }
18
- export declare abstract class SupportedWcOperation extends BaseWcOperation {
19
- tx: TransactionRequest;
20
- operation: string;
21
- protected calldata: BytesLike;
22
- constructor(props: SupportedWcOperationProps);
23
- }
@@ -1,39 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.SupportedWcOperation = exports.BaseWcOperation = void 0;
19
- var BaseWcOperation = /** @class */ (function () {
20
- function BaseWcOperation(_a) {
21
- var raw = _a.raw;
22
- this.id = raw.id;
23
- this.raw = raw;
24
- }
25
- return BaseWcOperation;
26
- }());
27
- exports.BaseWcOperation = BaseWcOperation;
28
- var SupportedWcOperation = /** @class */ (function (_super) {
29
- __extends(SupportedWcOperation, _super);
30
- function SupportedWcOperation(props) {
31
- var _this = _super.call(this, props) || this;
32
- _this.operation = props.operation;
33
- _this.tx = props.tx;
34
- _this.calldata = props.calldata;
35
- return _this;
36
- }
37
- return SupportedWcOperation;
38
- }(BaseWcOperation));
39
- exports.SupportedWcOperation = SupportedWcOperation;
@@ -1,11 +0,0 @@
1
- import { ApproveWCOperation, FailedWCOperation, LpWCOperation, SwapWCOperation } from "./operations";
2
- export * from "./operations";
3
- export * from "./types";
4
- export type AllWCOperations = FailedWCOperation | ApproveWCOperation | SwapWCOperation | LpWCOperation;
5
- export type SupportedWCOperations = ApproveWCOperation | SwapWCOperation | LpWCOperation;
6
- export declare class WcOperationCreator {
7
- static newSwapOperation: typeof SwapWCOperation.create;
8
- static newLPOperation: typeof LpWCOperation.create;
9
- static newUnsupportedOperation: typeof FailedWCOperation.create;
10
- static newApproveOperation: typeof ApproveWCOperation.create;
11
- }
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.WcOperationCreator = void 0;
18
- var operations_1 = require("./operations");
19
- __exportStar(require("./operations"), exports);
20
- __exportStar(require("./types"), exports);
21
- var WcOperationCreator = /** @class */ (function () {
22
- function WcOperationCreator() {
23
- }
24
- WcOperationCreator.newSwapOperation = operations_1.SwapWCOperation.create;
25
- WcOperationCreator.newLPOperation = operations_1.LpWCOperation.create;
26
- WcOperationCreator.newUnsupportedOperation = operations_1.FailedWCOperation.create;
27
- WcOperationCreator.newApproveOperation = operations_1.ApproveWCOperation.create;
28
- return WcOperationCreator;
29
- }());
30
- exports.WcOperationCreator = WcOperationCreator;
@@ -1,88 +0,0 @@
1
- import { BigNumber } from "ethers";
2
- import { CreditManagerData } from "../creditManager";
3
- import { BaseWcOperation, BaseWcOperationProps, SupportedWcOperation, SupportedWcOperationProps } from "./abstractOperations";
4
- import { RawTransaction } from "./types";
5
- export type FailedWCOperationType = "unsupported" | "bad_request" | "unsupported_tokens";
6
- interface FailedWCOperationProps extends BaseWcOperationProps {
7
- message: string;
8
- kind: FailedWCOperationType;
9
- }
10
- export declare class FailedWCOperation extends BaseWcOperation {
11
- kind: FailedWCOperationType;
12
- message: string;
13
- constructor({ raw, kind, message }: FailedWCOperationProps);
14
- static create(props: FailedWCOperationProps): FailedWCOperation;
15
- }
16
- type ApproveWCOperationType = "approve";
17
- interface ApproveWcOperationProps extends SupportedWcOperationProps {
18
- kind: ApproveWCOperationType;
19
- to: string;
20
- from: string;
21
- }
22
- interface CreateApproveWCOperation {
23
- to: string;
24
- args: [string, BigNumber];
25
- raw: RawTransaction;
26
- creditManager: CreditManagerData;
27
- }
28
- export declare class ApproveWCOperation extends SupportedWcOperation {
29
- kind: ApproveWCOperationType;
30
- to: string;
31
- from: string;
32
- constructor(props: ApproveWcOperationProps);
33
- static create({ to: token, args, raw, creditManager, }: CreateApproveWCOperation): FailedWCOperation | ApproveWCOperation;
34
- }
35
- type SwapWCOperationType = "swap";
36
- interface SwapWCOperationProps extends SupportedWcOperationProps {
37
- kind: SwapWCOperationType;
38
- from: string;
39
- to: string;
40
- amountFrom: BigNumber;
41
- amountTo: BigNumber;
42
- }
43
- interface CreateSwapWCOperationProps {
44
- adapter: string;
45
- operation: string;
46
- from: string;
47
- to: string;
48
- amountFrom: BigNumber;
49
- amountTo: BigNumber;
50
- raw: RawTransaction;
51
- }
52
- export declare class SwapWCOperation extends SupportedWcOperation {
53
- kind: SwapWCOperationType;
54
- from: string;
55
- to: string;
56
- amountFrom: BigNumber;
57
- amountTo: BigNumber;
58
- constructor(props: SwapWCOperationProps);
59
- static create(params: CreateSwapWCOperationProps): SwapWCOperation;
60
- }
61
- type LpWCOperationType = "lp";
62
- type LpType = "withdraw" | "deposit";
63
- interface LpWCOperationProps extends SupportedWcOperationProps {
64
- kind: LpWCOperationType;
65
- from: string;
66
- amountFrom: BigNumber;
67
- farm: string;
68
- lpOperationType: LpType;
69
- }
70
- interface CreateLpWCOperation {
71
- adapter: string;
72
- operation: string;
73
- from: string;
74
- amountFrom: BigNumber;
75
- farm: string;
76
- type: LpType;
77
- raw: RawTransaction;
78
- }
79
- export declare class LpWCOperation extends SupportedWcOperation {
80
- kind: LpWCOperationType;
81
- from: string;
82
- amountFrom: BigNumber;
83
- farm: string;
84
- lpOperationType: LpType;
85
- constructor(props: LpWCOperationProps);
86
- static create(params: CreateLpWCOperation): LpWCOperation;
87
- }
88
- export {};