@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,37 +1,19 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.TxEnableTokens = exports.TxApprove = exports.TxCloseAccount = exports.TxRepayAccount = exports.TxClaimGearRewards = exports.TxClaimNFT = exports.TxClaimReward = exports.TxOpenMultitokenAccount = exports.TxOpenAccount = exports.TxDecreaseBorrowAmount = exports.TxIncreaseBorrowAmount = exports.TxAddCollateral = exports.TXSwap = exports.TxRemoveLiquidity = exports.TxAddLiquidity = exports.TxSerializer = void 0;
19
- var ethers_1 = require("ethers");
20
- var contracts_1 = require("../contracts/contracts");
21
- var contractsRegister_1 = require("../contracts/contractsRegister");
22
- var token_1 = require("../tokens/token");
23
- var formatter_1 = require("../utils/formatter");
24
- var constants_1 = require("./constants");
25
- var eventOrTx_1 = require("./eventOrTx");
26
- var TxSerializer = /** @class */ (function () {
27
- function TxSerializer() {
28
- }
29
- TxSerializer.serialize = function (items) {
30
- return JSON.stringify(items.map(function (i) { return i.serialize(); }));
31
- };
32
- TxSerializer.deserialize = function (data) {
33
- return JSON.parse(data).map(function (e) {
34
- var params = JSON.parse(e.content);
4
+ const contracts_1 = require("../contracts/contracts");
5
+ const contractsRegister_1 = require("../contracts/contractsRegister");
6
+ const token_1 = require("../tokens/token");
7
+ const formatter_1 = require("../utils/formatter");
8
+ const constants_1 = require("./constants");
9
+ const eventOrTx_1 = require("./eventOrTx");
10
+ class TxSerializer {
11
+ static serialize(items) {
12
+ return JSON.stringify(items.map(i => i.serialize()));
13
+ }
14
+ static deserialize(data) {
15
+ return JSON.parse(data).map(e => {
16
+ const params = JSON.parse(e.content);
35
17
  switch (e.type) {
36
18
  case "TxAddLiquidity":
37
19
  return new TxAddLiquidity(params);
@@ -64,434 +46,429 @@ var TxSerializer = /** @class */ (function () {
64
46
  case "TxEnableTokens":
65
47
  return new TxEnableTokens(params);
66
48
  default:
67
- throw new Error("Unknown transaction for parsing: ".concat(e.type));
49
+ throw new Error(`Unknown transaction for parsing: ${e.type}`);
68
50
  }
69
51
  });
70
- };
71
- return TxSerializer;
72
- }());
52
+ }
53
+ }
73
54
  exports.TxSerializer = TxSerializer;
74
- var TxAddLiquidity = /** @class */ (function (_super) {
75
- __extends(TxAddLiquidity, _super);
76
- function TxAddLiquidity(opts) {
77
- var _this = _super.call(this, {
55
+ class TxAddLiquidity extends eventOrTx_1.EVMTx {
56
+ amount;
57
+ underlyingToken;
58
+ pool;
59
+ constructor(opts) {
60
+ super({
78
61
  block: opts.block,
79
62
  txHash: opts.txHash,
80
63
  txStatus: opts.txStatus,
81
64
  timestamp: opts.timestamp,
82
- }) || this;
83
- _this.amount = opts.amount;
84
- _this.underlyingToken = opts.underlyingToken;
85
- _this.pool = opts.pool;
86
- return _this;
87
- }
88
- TxAddLiquidity.prototype.toString = function () {
89
- var _a = (0, token_1.extractTokenData)(this.underlyingToken), underlyingSymbol = _a[0], underlyingDecimals = _a[1];
90
- return "".concat((0, contractsRegister_1.getContractName)(this.pool), ": Deposit ").concat((0, formatter_1.formatBN)(this.amount, underlyingDecimals || 18), " ").concat(underlyingSymbol);
91
- };
92
- TxAddLiquidity.prototype.serialize = function () {
65
+ });
66
+ this.amount = opts.amount;
67
+ this.underlyingToken = opts.underlyingToken;
68
+ this.pool = opts.pool;
69
+ }
70
+ toString() {
71
+ const [underlyingSymbol, underlyingDecimals] = (0, token_1.extractTokenData)(this.underlyingToken);
72
+ return `${(0, contractsRegister_1.getContractName)(this.pool)}: Deposit ${(0, formatter_1.formatBN)(this.amount, underlyingDecimals || 18)} ${underlyingSymbol}`;
73
+ }
74
+ serialize() {
93
75
  return {
94
76
  type: "TxAddLiquidity",
95
77
  content: JSON.stringify(this),
96
78
  };
97
- };
98
- return TxAddLiquidity;
99
- }(eventOrTx_1.EVMTx));
79
+ }
80
+ }
100
81
  exports.TxAddLiquidity = TxAddLiquidity;
101
- var TxRemoveLiquidity = /** @class */ (function (_super) {
102
- __extends(TxRemoveLiquidity, _super);
103
- function TxRemoveLiquidity(opts) {
104
- var _this = _super.call(this, {
82
+ class TxRemoveLiquidity extends eventOrTx_1.EVMTx {
83
+ amount;
84
+ dieselToken;
85
+ pool;
86
+ constructor(opts) {
87
+ super({
105
88
  block: opts.block,
106
89
  txHash: opts.txHash,
107
90
  txStatus: opts.txStatus,
108
91
  timestamp: opts.timestamp,
109
- }) || this;
110
- _this.amount = opts.amount;
111
- _this.dieselToken = opts.dieselToken;
112
- _this.pool = opts.pool;
113
- return _this;
114
- }
115
- TxRemoveLiquidity.prototype.toString = function () {
116
- var _a = (0, token_1.extractTokenData)(this.dieselToken), dSymbol = _a[0], dDecimals = _a[1];
117
- return "".concat((0, contractsRegister_1.getContractName)(this.pool), ": Withdraw ").concat((0, formatter_1.formatBN)(this.amount, dDecimals || 18), " ").concat(dSymbol);
118
- };
119
- TxRemoveLiquidity.prototype.serialize = function () {
92
+ });
93
+ this.amount = opts.amount;
94
+ this.dieselToken = opts.dieselToken;
95
+ this.pool = opts.pool;
96
+ }
97
+ toString() {
98
+ const [dSymbol, dDecimals] = (0, token_1.extractTokenData)(this.dieselToken);
99
+ return `${(0, contractsRegister_1.getContractName)(this.pool)}: Withdraw ${(0, formatter_1.formatBN)(this.amount, dDecimals || 18)} ${dSymbol}`;
100
+ }
101
+ serialize() {
120
102
  return {
121
103
  type: "TxRemoveLiquidity",
122
104
  content: JSON.stringify(this),
123
105
  };
124
- };
125
- return TxRemoveLiquidity;
126
- }(eventOrTx_1.EVMTx));
106
+ }
107
+ }
127
108
  exports.TxRemoveLiquidity = TxRemoveLiquidity;
128
- var TXSwap = /** @class */ (function (_super) {
129
- __extends(TXSwap, _super);
130
- function TXSwap(opts) {
131
- var _this = _super.call(this, {
109
+ class TXSwap extends eventOrTx_1.EVMTx {
110
+ protocol;
111
+ operation;
112
+ amountFrom;
113
+ amountTo;
114
+ tokenFrom;
115
+ tokenTo;
116
+ creditManager;
117
+ constructor(opts) {
118
+ super({
132
119
  block: opts.block,
133
120
  txHash: opts.txHash,
134
121
  txStatus: opts.txStatus,
135
122
  timestamp: opts.timestamp,
136
- }) || this;
137
- _this.protocol = opts.protocol;
138
- _this.operation = opts.operation;
139
- _this.amountFrom = opts.amountFrom;
140
- _this.amountTo = opts.amountTo;
141
- _this.tokenFrom = opts.tokenFrom;
142
- _this.tokenTo = opts.tokenTo;
143
- _this.creditManager = opts.creditManager;
144
- return _this;
145
- }
146
- TXSwap.prototype.toString = function () {
147
- var toPart = "";
123
+ });
124
+ this.protocol = opts.protocol;
125
+ this.operation = opts.operation;
126
+ this.amountFrom = opts.amountFrom;
127
+ this.amountTo = opts.amountTo;
128
+ this.tokenFrom = opts.tokenFrom;
129
+ this.tokenTo = opts.tokenTo;
130
+ this.creditManager = opts.creditManager;
131
+ }
132
+ toString() {
133
+ let toPart = "";
148
134
  if (this.tokenTo && this.amountTo) {
149
- var _a = (0, token_1.extractTokenData)(this.tokenTo), toSymbol = _a[0], toDecimals = _a[1];
150
- toPart = " \u21D2 ".concat((0, formatter_1.formatBN)(this.amountTo, toDecimals || 18), " ").concat(toSymbol);
135
+ const [toSymbol, toDecimals] = (0, token_1.extractTokenData)(this.tokenTo);
136
+ toPart = ` ${(0, formatter_1.formatBN)(this.amountTo, toDecimals || 18)} ${toSymbol}`;
151
137
  }
152
- var _b = (0, token_1.extractTokenData)(this.tokenFrom), fromSymbol = _b[0], fromDecimals = _b[1];
153
- return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": ").concat(this.operation, " ").concat((0, formatter_1.formatBN)(this.amountFrom, fromDecimals || 18), " ").concat(fromSymbol, " ").concat(toPart, " on ").concat((0, contractsRegister_1.getContractName)(this.protocol));
154
- };
155
- TXSwap.prototype.serialize = function () {
138
+ const [fromSymbol, fromDecimals] = (0, token_1.extractTokenData)(this.tokenFrom);
139
+ return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: ${this.operation} ${(0, formatter_1.formatBN)(this.amountFrom, fromDecimals || 18)} ${fromSymbol} ${toPart} on ${(0, contractsRegister_1.getContractName)(this.protocol)}`;
140
+ }
141
+ serialize() {
156
142
  return {
157
143
  type: "TxSwap",
158
144
  content: JSON.stringify(this),
159
145
  };
160
- };
161
- return TXSwap;
162
- }(eventOrTx_1.EVMTx));
146
+ }
147
+ }
163
148
  exports.TXSwap = TXSwap;
164
- var TxAddCollateral = /** @class */ (function (_super) {
165
- __extends(TxAddCollateral, _super);
166
- function TxAddCollateral(opts) {
167
- var _this = _super.call(this, {
149
+ class TxAddCollateral extends eventOrTx_1.EVMTx {
150
+ amount;
151
+ addedToken;
152
+ creditManager;
153
+ constructor(opts) {
154
+ super({
168
155
  block: opts.block,
169
156
  txHash: opts.txHash,
170
157
  txStatus: opts.txStatus,
171
158
  timestamp: opts.timestamp,
172
- }) || this;
173
- _this.amount = opts.amount;
174
- _this.addedToken = opts.addedToken;
175
- _this.creditManager = opts.creditManager;
176
- return _this;
177
- }
178
- TxAddCollateral.prototype.toString = function () {
179
- var _a = (0, token_1.extractTokenData)(this.addedToken), addedSymbol = _a[0], addedDecimals = _a[1];
180
- return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": Added ").concat((0, formatter_1.formatBN)(this.amount, addedDecimals || 18), " ").concat(addedSymbol, " as collateral");
181
- };
182
- TxAddCollateral.prototype.serialize = function () {
159
+ });
160
+ this.amount = opts.amount;
161
+ this.addedToken = opts.addedToken;
162
+ this.creditManager = opts.creditManager;
163
+ }
164
+ toString() {
165
+ const [addedSymbol, addedDecimals] = (0, token_1.extractTokenData)(this.addedToken);
166
+ return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: Added ${(0, formatter_1.formatBN)(this.amount, addedDecimals || 18)} ${addedSymbol} as collateral`;
167
+ }
168
+ serialize() {
183
169
  return {
184
170
  type: "TxAddCollateral",
185
171
  content: JSON.stringify(this),
186
172
  };
187
- };
188
- return TxAddCollateral;
189
- }(eventOrTx_1.EVMTx));
173
+ }
174
+ }
190
175
  exports.TxAddCollateral = TxAddCollateral;
191
- var TxIncreaseBorrowAmount = /** @class */ (function (_super) {
192
- __extends(TxIncreaseBorrowAmount, _super);
193
- function TxIncreaseBorrowAmount(opts) {
194
- var _this = _super.call(this, {
176
+ class TxIncreaseBorrowAmount extends eventOrTx_1.EVMTx {
177
+ amount;
178
+ underlyingToken;
179
+ creditManager;
180
+ constructor(opts) {
181
+ super({
195
182
  block: opts.block,
196
183
  txHash: opts.txHash,
197
184
  txStatus: opts.txStatus,
198
185
  timestamp: opts.timestamp,
199
- }) || this;
200
- _this.amount = opts.amount;
201
- _this.underlyingToken = opts.underlyingToken;
202
- _this.creditManager = opts.creditManager;
203
- return _this;
204
- }
205
- TxIncreaseBorrowAmount.prototype.toString = function () {
206
- var _a = (0, token_1.extractTokenData)(this.underlyingToken), tokenSymbol = _a[0], tokenDecimals = _a[1];
207
- return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": Borrowed amount was increased for ").concat((0, formatter_1.formatBN)(this.amount, tokenDecimals || 18), " ").concat(tokenSymbol);
208
- };
209
- TxIncreaseBorrowAmount.prototype.serialize = function () {
186
+ });
187
+ this.amount = opts.amount;
188
+ this.underlyingToken = opts.underlyingToken;
189
+ this.creditManager = opts.creditManager;
190
+ }
191
+ toString() {
192
+ const [tokenSymbol, tokenDecimals] = (0, token_1.extractTokenData)(this.underlyingToken);
193
+ return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: Borrowed amount was increased for ${(0, formatter_1.formatBN)(this.amount, tokenDecimals || 18)} ${tokenSymbol}`;
194
+ }
195
+ serialize() {
210
196
  return {
211
197
  type: "TxIncreaseBorrowAmount",
212
198
  content: JSON.stringify(this),
213
199
  };
214
- };
215
- return TxIncreaseBorrowAmount;
216
- }(eventOrTx_1.EVMTx));
200
+ }
201
+ }
217
202
  exports.TxIncreaseBorrowAmount = TxIncreaseBorrowAmount;
218
- var TxDecreaseBorrowAmount = /** @class */ (function (_super) {
219
- __extends(TxDecreaseBorrowAmount, _super);
220
- function TxDecreaseBorrowAmount(opts) {
221
- var _this = _super.call(this, {
203
+ class TxDecreaseBorrowAmount extends eventOrTx_1.EVMTx {
204
+ amount;
205
+ underlyingToken;
206
+ creditManager;
207
+ constructor(opts) {
208
+ super({
222
209
  block: opts.block,
223
210
  txHash: opts.txHash,
224
211
  txStatus: opts.txStatus,
225
212
  timestamp: opts.timestamp,
226
- }) || this;
227
- _this.amount = opts.amount;
228
- _this.underlyingToken = opts.underlyingToken;
229
- _this.creditManager = opts.creditManager;
230
- return _this;
231
- }
232
- TxDecreaseBorrowAmount.prototype.toString = function () {
233
- var _a = (0, token_1.extractTokenData)(this.underlyingToken), tokenSymbol = _a[0], tokenDecimals = _a[1];
234
- return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": Borrowed amount was decreased for ").concat((0, formatter_1.formatBN)(this.amount, tokenDecimals || 18), " ").concat(tokenSymbol);
235
- };
236
- TxDecreaseBorrowAmount.prototype.serialize = function () {
213
+ });
214
+ this.amount = opts.amount;
215
+ this.underlyingToken = opts.underlyingToken;
216
+ this.creditManager = opts.creditManager;
217
+ }
218
+ toString() {
219
+ const [tokenSymbol, tokenDecimals] = (0, token_1.extractTokenData)(this.underlyingToken);
220
+ return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: Borrowed amount was decreased for ${(0, formatter_1.formatBN)(this.amount, tokenDecimals || 18)} ${tokenSymbol}`;
221
+ }
222
+ serialize() {
237
223
  return {
238
224
  type: "TxIncreaseBorrowAmount",
239
225
  content: JSON.stringify(this),
240
226
  };
241
- };
242
- return TxDecreaseBorrowAmount;
243
- }(eventOrTx_1.EVMTx));
227
+ }
228
+ }
244
229
  exports.TxDecreaseBorrowAmount = TxDecreaseBorrowAmount;
245
- var TxOpenAccount = /** @class */ (function (_super) {
246
- __extends(TxOpenAccount, _super);
247
- function TxOpenAccount(opts) {
248
- var _this = _super.call(this, {
230
+ class TxOpenAccount extends eventOrTx_1.EVMTx {
231
+ amount;
232
+ underlyingToken;
233
+ leverage;
234
+ creditManager;
235
+ constructor(opts) {
236
+ super({
249
237
  block: opts.block,
250
238
  txHash: opts.txHash,
251
239
  txStatus: opts.txStatus,
252
240
  timestamp: opts.timestamp,
253
- }) || this;
254
- _this.amount = ethers_1.BigNumber.from(opts.amount);
255
- _this.underlyingToken = opts.underlyingToken;
256
- _this.leverage = opts.leverage;
257
- _this.creditManager = opts.creditManager;
258
- return _this;
259
- }
260
- TxOpenAccount.prototype.toString = function () {
261
- var _a = (0, token_1.extractTokenData)(this.underlyingToken), tokenSymbol = _a[0], tokenDecimals = _a[1];
262
- return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": opening ").concat((0, formatter_1.formatBN)(this.amount, tokenDecimals || 18), " ").concat(tokenSymbol, " x ").concat(this.leverage.toFixed(2), " \u21D2 \n ").concat((0, formatter_1.formatBN)(this.amount
263
- .mul(Math.floor(this.leverage * constants_1.LEVERAGE_DECIMALS))
264
- .div(constants_1.LEVERAGE_DECIMALS), tokenDecimals || 18), " ").concat(tokenSymbol);
265
- };
266
- TxOpenAccount.prototype.serialize = function () {
241
+ });
242
+ this.amount = opts.amount;
243
+ this.underlyingToken = opts.underlyingToken;
244
+ this.leverage = opts.leverage;
245
+ this.creditManager = opts.creditManager;
246
+ }
247
+ toString() {
248
+ const [tokenSymbol, tokenDecimals] = (0, token_1.extractTokenData)(this.underlyingToken);
249
+ return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: opening ${(0, formatter_1.formatBN)(this.amount, tokenDecimals || 18)} ${tokenSymbol} x ${this.leverage.toFixed(2)} ⇒
250
+ ${(0, formatter_1.formatBN)((this.amount *
251
+ BigInt(Math.floor(this.leverage * Number(constants_1.LEVERAGE_DECIMALS)))) /
252
+ constants_1.LEVERAGE_DECIMALS, tokenDecimals || 18)} ${tokenSymbol}`;
253
+ }
254
+ serialize() {
267
255
  return {
268
256
  type: "TxOpenAccount",
269
257
  content: JSON.stringify(this),
270
258
  };
271
- };
272
- return TxOpenAccount;
273
- }(eventOrTx_1.EVMTx));
259
+ }
260
+ }
274
261
  exports.TxOpenAccount = TxOpenAccount;
275
- var TxOpenMultitokenAccount = /** @class */ (function (_super) {
276
- __extends(TxOpenMultitokenAccount, _super);
277
- function TxOpenMultitokenAccount(opts) {
278
- var _this = _super.call(this, {
262
+ class TxOpenMultitokenAccount extends eventOrTx_1.EVMTx {
263
+ borrowedAmount;
264
+ creditManager;
265
+ underlyingToken;
266
+ assets;
267
+ constructor(opts) {
268
+ super({
279
269
  block: opts.block,
280
270
  txHash: opts.txHash,
281
271
  txStatus: opts.txStatus,
282
272
  timestamp: opts.timestamp,
283
- }) || this;
284
- _this.borrowedAmount = ethers_1.BigNumber.from(opts.borrowedAmount);
285
- _this.underlyingToken = opts.underlyingToken;
286
- _this.creditManager = opts.creditManager;
287
- _this.assets = opts.assets;
288
- return _this;
289
- }
290
- TxOpenMultitokenAccount.prototype.toString = function () {
291
- var assetSymbols = this.assets.reduce(function (acc, assetAddress) {
292
- var tokenSymbol = (0, token_1.extractTokenData)(assetAddress)[0];
273
+ });
274
+ this.borrowedAmount = opts.borrowedAmount;
275
+ this.underlyingToken = opts.underlyingToken;
276
+ this.creditManager = opts.creditManager;
277
+ this.assets = opts.assets;
278
+ }
279
+ toString() {
280
+ const assetSymbols = this.assets.reduce((acc, assetAddress) => {
281
+ const [tokenSymbol] = (0, token_1.extractTokenData)(assetAddress);
293
282
  if (tokenSymbol)
294
283
  acc.push(tokenSymbol);
295
284
  return acc;
296
285
  }, []);
297
- var _a = (0, token_1.extractTokenData)(this.underlyingToken), symbol = _a[0], underlyingDecimals = _a[1];
298
- return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": opening. Borrowed amount: ").concat((0, formatter_1.formatBN)(this.borrowedAmount, underlyingDecimals || 18), " ").concat(symbol, "; assets: ").concat(assetSymbols.join(", "));
299
- };
300
- TxOpenMultitokenAccount.prototype.serialize = function () {
286
+ const [symbol, underlyingDecimals] = (0, token_1.extractTokenData)(this.underlyingToken);
287
+ return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: opening. Borrowed amount: ${(0, formatter_1.formatBN)(this.borrowedAmount, underlyingDecimals || 18)} ${symbol}; assets: ${assetSymbols.join(", ")}`;
288
+ }
289
+ serialize() {
301
290
  return {
302
291
  type: "TxOpenMultitokenAccount",
303
292
  content: JSON.stringify(this),
304
293
  };
305
- };
306
- return TxOpenMultitokenAccount;
307
- }(eventOrTx_1.EVMTx));
294
+ }
295
+ }
308
296
  exports.TxOpenMultitokenAccount = TxOpenMultitokenAccount;
309
- var TxClaimReward = /** @class */ (function (_super) {
310
- __extends(TxClaimReward, _super);
311
- function TxClaimReward(opts) {
312
- var _this = _super.call(this, {
297
+ class TxClaimReward extends eventOrTx_1.EVMTx {
298
+ contracts;
299
+ constructor(opts) {
300
+ super({
313
301
  block: opts.block,
314
302
  txHash: opts.txHash,
315
303
  txStatus: opts.txStatus,
316
304
  timestamp: opts.timestamp,
317
- }) || this;
318
- _this.contracts = opts.contracts;
319
- return _this;
305
+ });
306
+ this.contracts = opts.contracts;
320
307
  }
321
- TxClaimReward.prototype.toString = function () {
322
- var contractNames = this.contracts.map(function (contract) {
323
- var contractInfo = contracts_1.contractParams[contract];
308
+ toString() {
309
+ const contractNames = this.contracts.map(contract => {
310
+ const contractInfo = contracts_1.contractParams[contract];
324
311
  return contractInfo.name;
325
312
  });
326
- return "Pools reward claimed: ".concat(contractNames.join(", "));
327
- };
328
- TxClaimReward.prototype.serialize = function () {
313
+ return `Pools reward claimed: ${contractNames.join(", ")}`;
314
+ }
315
+ serialize() {
329
316
  return {
330
317
  type: "TxClaimReward",
331
318
  content: JSON.stringify(this),
332
319
  };
333
- };
334
- return TxClaimReward;
335
- }(eventOrTx_1.EVMTx));
320
+ }
321
+ }
336
322
  exports.TxClaimReward = TxClaimReward;
337
- var TxClaimNFT = /** @class */ (function (_super) {
338
- __extends(TxClaimNFT, _super);
339
- function TxClaimNFT(opts) {
340
- return _super.call(this, {
323
+ class TxClaimNFT extends eventOrTx_1.EVMTx {
324
+ constructor(opts) {
325
+ super({
341
326
  block: opts.block,
342
327
  txHash: opts.txHash,
343
328
  txStatus: opts.txStatus,
344
329
  timestamp: opts.timestamp,
345
- }) || this;
330
+ });
346
331
  }
347
- TxClaimNFT.prototype.toString = function () {
348
- return "NFT claimed";
349
- };
350
- TxClaimNFT.prototype.serialize = function () {
332
+ toString() {
333
+ return `NFT claimed`;
334
+ }
335
+ serialize() {
351
336
  return {
352
337
  type: "TxClaimNFT",
353
338
  content: JSON.stringify(this),
354
339
  };
355
- };
356
- return TxClaimNFT;
357
- }(eventOrTx_1.EVMTx));
340
+ }
341
+ }
358
342
  exports.TxClaimNFT = TxClaimNFT;
359
- var TxClaimGearRewards = /** @class */ (function (_super) {
360
- __extends(TxClaimGearRewards, _super);
361
- function TxClaimGearRewards(opts) {
362
- var _this = _super.call(this, {
343
+ class TxClaimGearRewards extends eventOrTx_1.EVMTx {
344
+ token;
345
+ amount;
346
+ constructor(opts) {
347
+ super({
363
348
  block: opts.block,
364
349
  txHash: opts.txHash,
365
350
  txStatus: opts.txStatus,
366
351
  timestamp: opts.timestamp,
367
- }) || this;
368
- _this.amount = opts.amount;
369
- _this.token = opts.token;
370
- return _this;
371
- }
372
- TxClaimGearRewards.prototype.toString = function () {
373
- var _a = (0, token_1.extractTokenData)(this.token), symbol = _a[0], decimals = _a[1];
374
- return "GEAR Rewards claimed: ".concat((0, formatter_1.formatBN)(this.amount, decimals || 18), " ").concat(symbol, " ");
375
- };
376
- TxClaimGearRewards.prototype.serialize = function () {
352
+ });
353
+ this.amount = opts.amount;
354
+ this.token = opts.token;
355
+ }
356
+ toString() {
357
+ const [symbol, decimals] = (0, token_1.extractTokenData)(this.token);
358
+ return `GEAR Rewards claimed: ${(0, formatter_1.formatBN)(this.amount, decimals || 18)} ${symbol} `;
359
+ }
360
+ serialize() {
377
361
  return {
378
362
  type: "TxClaimGearRewards",
379
363
  content: JSON.stringify(this),
380
364
  };
381
- };
382
- return TxClaimGearRewards;
383
- }(eventOrTx_1.EVMTx));
365
+ }
366
+ }
384
367
  exports.TxClaimGearRewards = TxClaimGearRewards;
385
- var TxRepayAccount = /** @class */ (function (_super) {
386
- __extends(TxRepayAccount, _super);
387
- function TxRepayAccount(opts) {
388
- var _this = _super.call(this, {
368
+ class TxRepayAccount extends eventOrTx_1.EVMTx {
369
+ creditManager;
370
+ constructor(opts) {
371
+ super({
389
372
  block: opts.block,
390
373
  txHash: opts.txHash,
391
374
  txStatus: opts.txStatus,
392
375
  timestamp: opts.timestamp,
393
- }) || this;
394
- _this.creditManager = opts.creditManager;
395
- return _this;
396
- }
397
- TxRepayAccount.prototype.toString = function () {
398
- return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": Repaying account");
399
- };
400
- TxRepayAccount.prototype.serialize = function () {
376
+ });
377
+ this.creditManager = opts.creditManager;
378
+ }
379
+ toString() {
380
+ return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: Repaying account`;
381
+ }
382
+ serialize() {
401
383
  return {
402
384
  type: "TxRepayAccount",
403
385
  content: JSON.stringify(this),
404
386
  };
405
- };
406
- return TxRepayAccount;
407
- }(eventOrTx_1.EVMTx));
387
+ }
388
+ }
408
389
  exports.TxRepayAccount = TxRepayAccount;
409
- var TxCloseAccount = /** @class */ (function (_super) {
410
- __extends(TxCloseAccount, _super);
411
- function TxCloseAccount(opts) {
412
- var _this = _super.call(this, {
390
+ class TxCloseAccount extends eventOrTx_1.EVMTx {
391
+ creditManager;
392
+ constructor(opts) {
393
+ super({
413
394
  block: opts.block,
414
395
  txHash: opts.txHash,
415
396
  txStatus: opts.txStatus,
416
397
  timestamp: opts.timestamp,
417
- }) || this;
418
- _this.creditManager = opts.creditManager;
419
- return _this;
420
- }
421
- TxCloseAccount.prototype.toString = function () {
422
- return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": Closing account");
423
- };
424
- TxCloseAccount.prototype.serialize = function () {
398
+ });
399
+ this.creditManager = opts.creditManager;
400
+ }
401
+ toString() {
402
+ return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: Closing account`;
403
+ }
404
+ serialize() {
425
405
  return {
426
406
  type: "TxCloseAccount",
427
407
  content: JSON.stringify(this),
428
408
  };
429
- };
430
- return TxCloseAccount;
431
- }(eventOrTx_1.EVMTx));
409
+ }
410
+ }
432
411
  exports.TxCloseAccount = TxCloseAccount;
433
- var TxApprove = /** @class */ (function (_super) {
434
- __extends(TxApprove, _super);
435
- function TxApprove(opts) {
436
- var _this = _super.call(this, {
412
+ class TxApprove extends eventOrTx_1.EVMTx {
413
+ token;
414
+ constructor(opts) {
415
+ super({
437
416
  block: opts.block,
438
417
  txHash: opts.txHash,
439
418
  txStatus: opts.txStatus,
440
419
  timestamp: opts.timestamp,
441
- }) || this;
442
- _this.token = opts.token;
443
- return _this;
444
- }
445
- TxApprove.prototype.toString = function () {
446
- var symbol = (0, token_1.extractTokenData)(this.token)[0];
447
- return "Approve ".concat(symbol);
448
- };
449
- TxApprove.prototype.serialize = function () {
420
+ });
421
+ this.token = opts.token;
422
+ }
423
+ toString() {
424
+ const [symbol] = (0, token_1.extractTokenData)(this.token);
425
+ return `Approve ${symbol}`;
426
+ }
427
+ serialize() {
450
428
  return {
451
429
  type: "TxApprove",
452
430
  content: JSON.stringify(this),
453
431
  };
454
- };
455
- return TxApprove;
456
- }(eventOrTx_1.EVMTx));
432
+ }
433
+ }
457
434
  exports.TxApprove = TxApprove;
458
- var TxEnableTokens = /** @class */ (function (_super) {
459
- __extends(TxEnableTokens, _super);
460
- function TxEnableTokens(opts) {
461
- var _this = _super.call(this, {
435
+ class TxEnableTokens extends eventOrTx_1.EVMTx {
436
+ enabledTokens;
437
+ disabledTokens;
438
+ creditManager;
439
+ constructor(opts) {
440
+ super({
462
441
  block: opts.block,
463
442
  txHash: opts.txHash,
464
443
  txStatus: opts.txStatus,
465
444
  timestamp: opts.timestamp,
466
- }) || this;
467
- _this.enabledTokens = opts.enabledTokens;
468
- _this.disabledTokens = opts.disabledTokens;
469
- _this.creditManager = opts.creditManager;
470
- return _this;
471
- }
472
- TxEnableTokens.prototype.toString = function () {
473
- var enabledSymbols = this.enabledTokens.map(function (address) {
474
- var tokenSymbol = (0, token_1.extractTokenData)(address)[0];
445
+ });
446
+ this.enabledTokens = opts.enabledTokens;
447
+ this.disabledTokens = opts.disabledTokens;
448
+ this.creditManager = opts.creditManager;
449
+ }
450
+ toString() {
451
+ const enabledSymbols = this.enabledTokens.map(address => {
452
+ const [tokenSymbol] = (0, token_1.extractTokenData)(address);
475
453
  return tokenSymbol;
476
454
  });
477
- var disabledSymbols = this.disabledTokens.map(function (address) {
478
- var tokenSymbol = (0, token_1.extractTokenData)(address)[0];
455
+ const disabledSymbols = this.disabledTokens.map(address => {
456
+ const [tokenSymbol] = (0, token_1.extractTokenData)(address);
479
457
  return tokenSymbol;
480
458
  });
481
- var currentSentences = [
482
- enabledSymbols.length > 0 ? "enabled: ".concat(enabledSymbols.join(", ")) : "",
459
+ const currentSentences = [
460
+ enabledSymbols.length > 0 ? `enabled: ${enabledSymbols.join(", ")}` : "",
483
461
  disabledSymbols.length > 0
484
- ? "disabled: ".concat(disabledSymbols.join(", "))
462
+ ? `disabled: ${disabledSymbols.join(", ")}`
485
463
  : "",
486
- ].filter(function (s) { return !!s; });
487
- return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": ").concat(currentSentences.join("; "));
488
- };
489
- TxEnableTokens.prototype.serialize = function () {
464
+ ].filter(s => !!s);
465
+ return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: ${currentSentences.join("; ")}`;
466
+ }
467
+ serialize() {
490
468
  return {
491
469
  type: "TxEnableTokens",
492
470
  content: JSON.stringify(this),
493
471
  };
494
- };
495
- return TxEnableTokens;
496
- }(eventOrTx_1.EVMTx));
472
+ }
473
+ }
497
474
  exports.TxEnableTokens = TxEnableTokens;