@gearbox-protocol/sdk 1.22.4 → 1.23.0

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 (283) 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 +2 -2
  40. package/lib/core/rewardClaimer.js +5 -48
  41. package/lib/core/rewardConvex.js +54 -114
  42. package/lib/core/rewardConvex.spec.js +41 -43
  43. package/lib/core/strategy.d.ts +5 -6
  44. package/lib/core/strategy.js +67 -69
  45. package/lib/core/strategy.spec.js +32 -34
  46. package/lib/core/tokenDistributor.d.ts +1 -2
  47. package/lib/core/trade.d.ts +6 -6
  48. package/lib/core/trade.js +70 -115
  49. package/lib/core/transactions.d.ts +21 -22
  50. package/lib/core/transactions.js +285 -308
  51. package/lib/index.d.ts +0 -2
  52. package/lib/index.js +0 -2
  53. package/lib/oracles/oracles.d.ts +1 -2
  54. package/lib/oracles/priceFeeds.js +2 -3
  55. package/lib/parsers/ERC20Parser.js +20 -38
  56. package/lib/parsers/abstractParser.js +33 -31
  57. package/lib/parsers/addressProviderParser.js +12 -30
  58. package/lib/parsers/airdropDistributorParser.js +12 -30
  59. package/lib/parsers/convexBaseRewardPoolAdapterParser.js +24 -42
  60. package/lib/parsers/convexBaseRewardPoolAdapterParser.spec.js +11 -11
  61. package/lib/parsers/convexBoosterAdapterParser.js +26 -44
  62. package/lib/parsers/convexBoosterAdapterParser.spec.js +10 -10
  63. package/lib/parsers/convextRewardPoolParser.js +12 -30
  64. package/lib/parsers/creditFacadeParser.js +26 -45
  65. package/lib/parsers/creditFacadeParser.spec.js +13 -13
  66. package/lib/parsers/creditManagerParser.js +12 -30
  67. package/lib/parsers/curveAdapterParser.js +60 -78
  68. package/lib/parsers/curveAdapterParser.spec.js +20 -27
  69. package/lib/parsers/dataCompressorParser.js +12 -30
  70. package/lib/parsers/lidoAdapterParser.js +15 -33
  71. package/lib/parsers/lidoAdapterParser.spec.js +9 -9
  72. package/lib/parsers/lidoOracleParser.js +12 -30
  73. package/lib/parsers/lidoSTETHParser.js +19 -37
  74. package/lib/parsers/multicallParser.js +16 -34
  75. package/lib/parsers/offchainOracleParser.js +13 -31
  76. package/lib/parsers/poolParser.js +11 -29
  77. package/lib/parsers/priceOracleParser.js +13 -31
  78. package/lib/parsers/txParser.js +86 -96
  79. package/lib/parsers/uniV2AdapterParser.js +35 -55
  80. package/lib/parsers/uniV2AdapterParser.spec.js +15 -16
  81. package/lib/parsers/uniV3AdapterParser.js +56 -74
  82. package/lib/parsers/uniV3AdapterParser.spec.js +23 -24
  83. package/lib/parsers/wstETHAdapterParser.js +25 -43
  84. package/lib/parsers/wstETHAdapterParser.spec.js +11 -11
  85. package/lib/parsers/yearnAdapterParser.spec.js +17 -17
  86. package/lib/parsers/yearnV2AdapterParser.js +25 -43
  87. package/lib/pathfinder/core.d.ts +3 -4
  88. package/lib/pathfinder/pathOptions.js +52 -101
  89. package/lib/pathfinder/pathOptions.spec.js +55 -57
  90. package/lib/pathfinder/pathfinder.d.ts +3 -3
  91. package/lib/pathfinder/pathfinder.js +109 -202
  92. package/lib/pathfinder/pathfinder.spec.js +13 -13
  93. package/lib/strategies/convex.js +111 -123
  94. package/lib/strategies/creditFacade.js +34 -37
  95. package/lib/strategies/curve.js +74 -80
  96. package/lib/strategies/lido.js +26 -32
  97. package/lib/strategies/uniswapV2.js +21 -24
  98. package/lib/strategies/uniswapV3.js +33 -36
  99. package/lib/strategies/yearn.js +47 -59
  100. package/lib/tokens/balancer.js +3 -5
  101. package/lib/tokens/convex.js +14 -29
  102. package/lib/tokens/curveLP.js +22 -28
  103. package/lib/tokens/gear.js +1 -1
  104. package/lib/tokens/normal.js +3 -5
  105. package/lib/tokens/token.js +29 -35
  106. package/lib/tokens/tokenData.d.ts +0 -9
  107. package/lib/tokens/tokenData.js +17 -15
  108. package/lib/tokens/yearn.js +3 -5
  109. package/lib/types/factories/@chainlink/contracts/src/v0.8/interfaces/AggregatorInterface__factory.js +9 -12
  110. package/lib/types/factories/@chainlink/contracts/src/v0.8/interfaces/AggregatorV2V3Interface__factory.js +9 -12
  111. package/lib/types/factories/@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface__factory.js +9 -12
  112. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IACL.sol/IACLEvents__factory.js +9 -12
  113. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IACL.sol/IACLExceptions__factory.js +9 -12
  114. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IACL.sol/IACL__factory.js +9 -12
  115. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IAccountFactory.sol/IAccountFactoryEvents__factory.js +9 -12
  116. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IAccountFactory.sol/IAccountFactoryGetters__factory.js +9 -12
  117. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IAccountFactory.sol/IAccountFactory__factory.js +9 -12
  118. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IAddressProvider.sol/IAddressProviderEvents__factory.js +9 -12
  119. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IAddressProvider.sol/IAddressProvider__factory.js +9 -12
  120. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IAirdropDistributor.sol/IAirdropDistributorEvents__factory.js +9 -12
  121. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IAirdropDistributor.sol/IAirdropDistributor__factory.js +9 -12
  122. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IContractsRegister.sol/IContractsRegisterEvents__factory.js +9 -12
  123. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IContractsRegister.sol/IContractsRegister__factory.js +9 -12
  124. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditAccount.sol/ICrediAccountExceptions__factory.js +9 -12
  125. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditAccount.sol/ICreditAccount__factory.js +9 -12
  126. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditConfigurator.sol/ICreditConfiguratorEvents__factory.js +9 -12
  127. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditConfigurator.sol/ICreditConfiguratorExceptions__factory.js +9 -12
  128. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditConfigurator.sol/ICreditConfigurator__factory.js +9 -12
  129. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditFacade.sol/ICreditFacadeEvents__factory.js +9 -12
  130. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditFacade.sol/ICreditFacadeExceptions__factory.js +9 -12
  131. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditFacade.sol/ICreditFacadeExtended__factory.js +9 -12
  132. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditFacade.sol/ICreditFacade__factory.js +9 -12
  133. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditManagerV2.sol/ICreditManagerV2Events__factory.js +9 -12
  134. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditManagerV2.sol/ICreditManagerV2Exceptions__factory.js +9 -12
  135. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditManagerV2.sol/ICreditManagerV2__factory.js +9 -12
  136. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDataCompressor.sol/IDataCompressorExceptions__factory.js +9 -12
  137. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDataCompressor.sol/IDataCompressor__factory.js +9 -12
  138. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDegenDistributor.sol/IDegenDistributorEvents__factory.js +9 -12
  139. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDegenDistributor.sol/IDegenDistributor__factory.js +9 -12
  140. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDegenNFT.sol/IDegenNFTEvents__factory.js +9 -12
  141. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDegenNFT.sol/IDegenNFTExceptions__factory.js +9 -12
  142. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDegenNFT.sol/IDegenNFT__factory.js +9 -12
  143. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDieselToken.sol/IDieselTokenExceptions__factory.js +9 -12
  144. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDieselToken.sol/IDieselToken__factory.js +9 -12
  145. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IInterestRateModel__factory.js +9 -12
  146. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ILPPriceFeed.sol/ILPPriceFeedEvents__factory.js +9 -12
  147. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ILPPriceFeed.sol/ILPPriceFeedExceptions__factory.js +9 -12
  148. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ILPPriceFeed.sol/ILPPriceFeed__factory.js +9 -12
  149. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPhantomERC20__factory.js +9 -12
  150. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPoolService.sol/IPoolServiceEvents__factory.js +9 -12
  151. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPoolService.sol/IPoolService__factory.js +9 -12
  152. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPriceFeedType__factory.js +9 -12
  153. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPriceOracle.sol/IPriceOracleV2Events__factory.js +9 -12
  154. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPriceOracle.sol/IPriceOracleV2Exceptions__factory.js +9 -12
  155. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPriceOracle.sol/IPriceOracleV2Ext__factory.js +9 -12
  156. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPriceOracle.sol/IPriceOracleV2__factory.js +9 -12
  157. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IVersion__factory.js +9 -12
  158. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IWETHGateway__factory.js +9 -12
  159. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/V1/ICreditFilter__factory.js +9 -12
  160. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/V1/ICreditManager__factory.js +9 -12
  161. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/adapters/IAdapter.sol/IAdapterExceptions__factory.js +9 -12
  162. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/adapters/IAdapter.sol/IAdapter__factory.js +9 -12
  163. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/adapters/IUniversalAdapter.sol/IUniversalAdapterExceptions__factory.js +9 -12
  164. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/adapters/IUniversalAdapter.sol/IUniversalAdapter__factory.js +9 -12
  165. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/external/IWETH__factory.js +9 -12
  166. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/pool/PoolService__factory.js +27 -50
  167. package/lib/types/factories/@gearbox-protocol/core-v2/contracts/test/interfaces/ITokenTestSuite__factory.js +9 -12
  168. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IBaseRewardPool__factory.js +9 -12
  169. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IBooster__factory.js +9 -12
  170. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IClaimZap__factory.js +9 -12
  171. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IConvexToken__factory.js +9 -12
  172. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IRewards.sol/IBasicRewards__factory.js +9 -12
  173. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IRewards.sol/IRewards__factory.js +9 -12
  174. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/ICrvDeposit__factory.js +9 -12
  175. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/ICurveGauge__factory.js +9 -12
  176. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/ICurveVoteEscrow__factory.js +9 -12
  177. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IDeposit__factory.js +9 -12
  178. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IFeeDistro__factory.js +9 -12
  179. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IMinter__factory.js +9 -12
  180. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IPools__factory.js +9 -12
  181. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IRegistry__factory.js +9 -12
  182. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IRewardFactory__factory.js +9 -12
  183. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IRewards__factory.js +9 -12
  184. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IStaker__factory.js +9 -12
  185. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IStashFactory__factory.js +9 -12
  186. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IStash__factory.js +9 -12
  187. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/ITokenFactory__factory.js +9 -12
  188. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/ITokenMinter__factory.js +9 -12
  189. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IVestedEscrow__factory.js +9 -12
  190. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IVoting__factory.js +9 -12
  191. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IWalletChecker__factory.js +9 -12
  192. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/curve/ICurvePoolStETH__factory.js +9 -12
  193. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/curve/ICurvePool_2.sol/ICurvePool2Assets__factory.js +9 -12
  194. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/curve/ICurvePool_3.sol/ICurvePool3Assets__factory.js +9 -12
  195. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/curve/ICurvePool_4.sol/ICurvePool4Assets__factory.js +9 -12
  196. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/curve/ICurvePool__factory.js +9 -12
  197. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/curve/ICurveRegistry__factory.js +9 -12
  198. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/lido/ILidoOracle__factory.js +9 -12
  199. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/lido/IstETH.sol/IstETHGetters__factory.js +9 -12
  200. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/lido/IstETH.sol/IstETH__factory.js +9 -12
  201. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/lido/IwstETH.sol/IwstETHGetters__factory.js +9 -12
  202. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/lido/IwstETH.sol/IwstETH__factory.js +9 -12
  203. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/lido/IwstETHGateway.sol/IwstETHGateWay__factory.js +9 -12
  204. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/uniswap/IQuoter__factory.js +9 -12
  205. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/uniswap/IUniswapV2Router01__factory.js +9 -12
  206. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/uniswap/IUniswapV2Router02__factory.js +9 -12
  207. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/uniswap/IUniswapV3.sol/ISwapRouter__factory.js +9 -12
  208. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/yearn/IYVault__factory.js +9 -12
  209. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/convex/IConvexV1BaseRewardPoolAdapter.sol/IConvexV1BaseRewardPoolAdapterErrors__factory.js +9 -12
  210. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/convex/IConvexV1BaseRewardPoolAdapter.sol/IConvexV1BaseRewardPoolAdapter__factory.js +9 -12
  211. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/convex/IConvexV1BoosterAdapter__factory.js +9 -12
  212. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/curve/ICurveV1Adapter.sol/ICurveV1AdapterExceptions__factory.js +9 -12
  213. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/curve/ICurveV1Adapter.sol/ICurveV1Adapter__factory.js +9 -12
  214. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/curve/ICurveV1_2AssetsAdapter__factory.js +9 -12
  215. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/curve/ICurveV1_3AssetsAdapter__factory.js +9 -12
  216. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/curve/ICurveV1_4AssetsAdapter__factory.js +9 -12
  217. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/lido/ILidoV1Adapter.sol/ILidoV1AdapterEvents__factory.js +9 -12
  218. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/lido/ILidoV1Adapter.sol/ILidoV1AdapterExceptions__factory.js +9 -12
  219. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/lido/ILidoV1Adapter.sol/ILidoV1Adapter__factory.js +9 -12
  220. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/lido/IwstETHV1Adapter__factory.js +9 -12
  221. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/uniswap/IUniswapPathChecker__factory.js +9 -12
  222. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/uniswap/IUniswapV2Adapter.sol/IUniswapV2AdapterExceptions__factory.js +9 -12
  223. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/uniswap/IUniswapV2Adapter.sol/IUniswapV2Adapter__factory.js +9 -12
  224. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/uniswap/IUniswapV3Adapter.sol/IUniswapV3AdapterExceptions__factory.js +9 -12
  225. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/uniswap/IUniswapV3Adapter.sol/IUniswapV3Adapter__factory.js +9 -12
  226. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/yearn/IYearnV2Adapter__factory.js +9 -12
  227. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/test/config/SupportedContracts.sol/ISupportedContracts__factory.js +9 -12
  228. package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/test/mocks/integrations/LidoMock.sol/ILidoMockEvents__factory.js +9 -12
  229. package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IClosePathResolver__factory.js +9 -12
  230. package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IDepositor.sol/IDepositorOptions__factory.js +9 -12
  231. package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IDepositor.sol/IDepositor__factory.js +9 -12
  232. package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IGasPricer__factory.js +9 -12
  233. package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/ILPWorker.sol/ILPWorkerOptions__factory.js +9 -12
  234. package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/ILPWorker.sol/ILPWorker__factory.js +9 -12
  235. package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IPathResolver__factory.js +9 -12
  236. package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IRouterComponent__factory.js +9 -12
  237. package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IRouter__factory.js +9 -12
  238. package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/ISwapAggregator__factory.js +9 -12
  239. package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/ISwapper__factory.js +9 -12
  240. package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IWithdrawer.sol/IWithdrawerOptions__factory.js +9 -12
  241. package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IWithdrawer.sol/IWithdrawer__factory.js +9 -12
  242. package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IWrapper__factory.js +9 -12
  243. package/lib/types/factories/@openzeppelin/contracts/token/ERC20/IERC20__factory.js +9 -12
  244. package/lib/types/factories/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata__factory.js +9 -12
  245. package/lib/types/factories/@openzeppelin/contracts/token/ERC721/IERC721Receiver__factory.js +9 -12
  246. package/lib/types/factories/@openzeppelin/contracts/token/ERC721/IERC721__factory.js +9 -12
  247. package/lib/types/factories/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata__factory.js +9 -12
  248. package/lib/types/factories/@openzeppelin/contracts/utils/introspection/IERC165__factory.js +9 -12
  249. package/lib/types/factories/contracts/IGas__factory.js +9 -12
  250. package/lib/types/factories/contracts/IGnosisSafeSignatureValidator__factory.js +9 -12
  251. package/lib/types/factories/contracts/ITokenDistributor.sol/ITokenDistributorEvents__factory.js +9 -12
  252. package/lib/types/factories/contracts/ITokenDistributor.sol/ITokenDistributorExceptions__factory.js +9 -12
  253. package/lib/types/factories/contracts/ITokenDistributor.sol/ITokenDistributor__factory.js +9 -12
  254. package/lib/types/factories/contracts/support/IOffchainOracle__factory.js +9 -12
  255. package/lib/types/factories/contracts/support/MultiCall.sol/Multicall2__factory.js +27 -50
  256. package/lib/utils/errors.js +1 -1
  257. package/lib/utils/extracter.js +4 -4
  258. package/lib/utils/formatter.d.ts +8 -8
  259. package/lib/utils/formatter.js +73 -87
  260. package/lib/utils/loading.js +3 -3
  261. package/lib/utils/mappers.js +7 -34
  262. package/lib/utils/math.d.ts +10 -7
  263. package/lib/utils/math.js +22 -25
  264. package/lib/utils/multicall.js +32 -98
  265. package/lib/utils/price.d.ts +3 -4
  266. package/lib/utils/price.js +8 -20
  267. package/lib/utils/repeater.js +12 -53
  268. package/lib/utils/validate.js +2 -2
  269. package/lib/watchers/creditAccountWatcher.js +136 -237
  270. package/lib/watchers/creditAccountWatcher.spec.js +51 -68
  271. package/lib/watchers/creditManagerWatcher.js +21 -71
  272. package/lib/watchers/creditManagerWatcher.spec.js +20 -23
  273. package/package.json +2 -2
  274. package/lib/core/history.d.ts +0 -42
  275. package/lib/core/history.js +0 -2
  276. package/lib/core/wcOperation/abstractOperations.d.ts +0 -23
  277. package/lib/core/wcOperation/abstractOperations.js +0 -39
  278. package/lib/core/wcOperation/index.d.ts +0 -11
  279. package/lib/core/wcOperation/index.js +0 -30
  280. package/lib/core/wcOperation/operations.d.ts +0 -88
  281. package/lib/core/wcOperation/operations.js +0 -146
  282. package/lib/core/wcOperation/types.d.ts +0 -15
  283. package/lib/core/wcOperation/types.js +0 -2
@@ -1,14 +1,12 @@
1
1
  "use strict";
2
- var _a, _b;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
- var chai_1 = require("chai");
5
- var ethers_1 = require("ethers");
6
- var decimals_1 = require("../tokens/decimals");
7
- var token_1 = require("../tokens/token");
8
- var formatter_1 = require("../utils/formatter");
9
- var constants_1 = require("./constants");
10
- var strategy_1 = require("./strategy");
11
- var lidoPayload = {
3
+ const chai_1 = require("chai");
4
+ const decimals_1 = require("../tokens/decimals");
5
+ const token_1 = require("../tokens/token");
6
+ const formatter_1 = require("../utils/formatter");
7
+ const constants_1 = require("./constants");
8
+ const strategy_1 = require("./strategy");
9
+ const lidoPayload = {
12
10
  name: "Lido",
13
11
  lpToken: token_1.tokenDataByNetwork.Mainnet.STETH,
14
12
  apy: 38434,
@@ -21,8 +19,8 @@ var lidoPayload = {
21
19
  leveragableCollateral: [],
22
20
  baseAssets: [token_1.tokenDataByNetwork.Mainnet.WETH],
23
21
  };
24
- var lidoStrategy = new strategy_1.Strategy(lidoPayload);
25
- var pools = {
22
+ const lidoStrategy = new strategy_1.Strategy(lidoPayload);
23
+ const pools = {
26
24
  "0x1": {
27
25
  borrowRate: 27543,
28
26
  },
@@ -30,29 +28,29 @@ var pools = {
30
28
  borrowRate: 5736,
31
29
  },
32
30
  };
33
- var prices = (_a = {},
34
- _a[token_1.tokenDataByNetwork.Mainnet.WETH.toLowerCase()] = (0, formatter_1.toBN)("1738.11830000", constants_1.PRICE_DECIMALS_POW),
35
- _a[token_1.tokenDataByNetwork.Mainnet.DAI.toLowerCase()] = (0, formatter_1.toBN)("0.99941103", constants_1.PRICE_DECIMALS_POW),
36
- _a[token_1.tokenDataByNetwork.Mainnet.STETH.toLowerCase()] = (0, formatter_1.toBN)("1703.87588096", constants_1.PRICE_DECIMALS_POW),
37
- _a);
38
- var liquidationThresholds = (_b = {},
39
- _b[token_1.tokenDataByNetwork.Mainnet.DAI.toLowerCase()] = ethers_1.BigNumber.from("9300"),
40
- _b[token_1.tokenDataByNetwork.Mainnet.WETH.toLowerCase()] = ethers_1.BigNumber.from("8500"),
41
- _b[token_1.tokenDataByNetwork.Mainnet.STETH.toLowerCase()] = ethers_1.BigNumber.from("9000"),
42
- _b);
43
- describe("Strategy test", function () {
44
- it("maxAPY calculation is correct", function () {
45
- var result = lidoStrategy.maxAPY(53203, 10 * constants_1.LEVERAGE_DECIMALS, pools["0x1"].borrowRate);
31
+ const prices = {
32
+ [token_1.tokenDataByNetwork.Mainnet.WETH.toLowerCase()]: (0, formatter_1.toBN)("1738.11830000", constants_1.PRICE_DECIMALS_POW),
33
+ [token_1.tokenDataByNetwork.Mainnet.DAI.toLowerCase()]: (0, formatter_1.toBN)("0.99941103", constants_1.PRICE_DECIMALS_POW),
34
+ [token_1.tokenDataByNetwork.Mainnet.STETH.toLowerCase()]: (0, formatter_1.toBN)("1703.87588096", constants_1.PRICE_DECIMALS_POW),
35
+ };
36
+ const liquidationThresholds = {
37
+ [token_1.tokenDataByNetwork.Mainnet.DAI.toLowerCase()]: 9300n,
38
+ [token_1.tokenDataByNetwork.Mainnet.WETH.toLowerCase()]: 8500n,
39
+ [token_1.tokenDataByNetwork.Mainnet.STETH.toLowerCase()]: 9000n,
40
+ };
41
+ describe("Strategy test", () => {
42
+ it("maxAPY calculation is correct", () => {
43
+ const result = lidoStrategy.maxAPY(53203, 10 * Number(constants_1.LEVERAGE_DECIMALS), pools["0x1"].borrowRate);
46
44
  (0, chai_1.expect)(result).to.be.eq(284143);
47
45
  });
48
- it("overallAPY calculation is correct", function () {
49
- var result = lidoStrategy.overallAPY(lidoStrategy.apy || 0, 10 * constants_1.LEVERAGE_DECIMALS, token_1.tokenDataByNetwork.Mainnet.WETH, pools["0x2"].borrowRate);
46
+ it("overallAPY calculation is correct", () => {
47
+ const result = lidoStrategy.overallAPY(lidoStrategy.apy || 0, 10 * Number(constants_1.LEVERAGE_DECIMALS), token_1.tokenDataByNetwork.Mainnet.WETH, pools["0x2"].borrowRate);
50
48
  (0, chai_1.expect)(result).to.be.eq(332716);
51
49
  });
52
- it("liquidationPrice calculation is correct", function () {
53
- var result = strategy_1.Strategy.liquidationPrice({
54
- liquidationThresholds: liquidationThresholds,
55
- prices: prices,
50
+ it("liquidationPrice calculation is correct", () => {
51
+ const result = strategy_1.Strategy.liquidationPrice({
52
+ liquidationThresholds,
53
+ prices,
56
54
  borrowed: (0, formatter_1.toBN)("350", decimals_1.decimals.WETH),
57
55
  underlyingToken: token_1.tokenDataByNetwork.Mainnet.WETH,
58
56
  lpAmount: (0, formatter_1.toBN)("400", decimals_1.decimals.STETH),
@@ -60,10 +58,10 @@ describe("Strategy test", function () {
60
58
  });
61
59
  (0, chai_1.expect)(Number((0, formatter_1.toSignificant)(result, constants_1.WAD_DECIMALS_POW)).toFixed(3)).to.be.eq("0.992");
62
60
  });
63
- it("maxLeverage is correct", function () {
64
- var result = strategy_1.Strategy.maxLeverage(token_1.tokenDataByNetwork.Mainnet.STETH, [
65
- { address: "0x1", liquidationThresholds: liquidationThresholds },
61
+ it("maxLeverage is correct", () => {
62
+ const result = strategy_1.Strategy.maxLeverage(token_1.tokenDataByNetwork.Mainnet.STETH, [
63
+ { address: "0x1", liquidationThresholds },
66
64
  ]);
67
- (0, chai_1.expect)(result).to.be.eq(9 * constants_1.LEVERAGE_DECIMALS);
65
+ (0, chai_1.expect)(result).to.be.eq(9 * Number(constants_1.LEVERAGE_DECIMALS));
68
66
  });
69
67
  });
@@ -1,7 +1,6 @@
1
- import { BigNumber } from "ethers";
2
1
  export interface TokenShare {
3
2
  holder: string;
4
- amount: BigNumber;
3
+ amount: bigint;
5
4
  share: number;
6
5
  isCompany: boolean;
7
6
  }
@@ -1,4 +1,4 @@
1
- import { BigNumber, Signer } from "ethers";
1
+ import { Signer } from "ethers";
2
2
  import { AdapterInterface } from "../contracts/adapters";
3
3
  import { MultiCall, PathFinderResult, SwapOperation } from "../pathfinder/core";
4
4
  import { ICreditFacade } from "../types";
@@ -6,8 +6,8 @@ import { BaseAdapter } from "./adapter";
6
6
  import { EVMTx } from "./eventOrTx";
7
7
  interface BaseTradeInterface {
8
8
  swapType: SwapOperation;
9
- sourceAmount: BigNumber;
10
- expectedAmount: BigNumber;
9
+ sourceAmount: bigint;
10
+ expectedAmount: bigint;
11
11
  tokenFrom: string;
12
12
  tokenTo: string;
13
13
  operationName: TradeOperations;
@@ -23,9 +23,9 @@ export declare class Trade implements BaseTradeInterface {
23
23
  readonly tradePath: PathFinderResult;
24
24
  readonly creditFacade: string;
25
25
  readonly swapType: SwapOperation;
26
- readonly sourceAmount: BigNumber;
27
- readonly expectedAmount: BigNumber;
28
- readonly rate: BigNumber;
26
+ readonly sourceAmount: bigint;
27
+ readonly expectedAmount: bigint;
28
+ readonly rate: bigint;
29
29
  readonly tokenFrom: string;
30
30
  readonly tokenTo: string;
31
31
  readonly operationName: TradeOperations;
package/lib/core/trade.js CHANGED
@@ -1,122 +1,87 @@
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.Trade = void 0;
40
- var decimals_1 = require("../tokens/decimals");
41
- var token_1 = require("../tokens/token");
42
- var types_1 = require("../types");
43
- var formatter_1 = require("../utils/formatter");
44
- var constants_1 = require("./constants");
45
- var transactions_1 = require("./transactions");
46
- var OPERATION_NAMES = {
4
+ const decimals_1 = require("../tokens/decimals");
5
+ const token_1 = require("../tokens/token");
6
+ const types_1 = require("../types");
7
+ const formatter_1 = require("../utils/formatter");
8
+ const constants_1 = require("./constants");
9
+ const transactions_1 = require("./transactions");
10
+ const OPERATION_NAMES = {
47
11
  farmWithdraw: "Farm withdraw",
48
12
  farmDeposit: "Farm deposit",
49
13
  swap: "Swap",
50
14
  unknownOperation: "Unknown operation",
51
15
  };
52
- var Trade = /** @class */ (function () {
53
- function Trade(props) {
16
+ class Trade {
17
+ helper;
18
+ tradePath;
19
+ creditFacade;
20
+ swapType;
21
+ sourceAmount;
22
+ expectedAmount;
23
+ rate;
24
+ tokenFrom;
25
+ tokenTo;
26
+ operationName;
27
+ constructor(props) {
54
28
  this.helper = props.adapter;
55
29
  this.tradePath = props.tradePath;
56
30
  this.creditFacade = props.creditFacade;
57
31
  this.swapType = props.swapType;
58
32
  this.sourceAmount = props.sourceAmount;
59
33
  this.expectedAmount = props.expectedAmount;
60
- this.rate = constants_1.WAD.mul(props.expectedAmount).div(props.sourceAmount);
34
+ this.rate = (constants_1.WAD * props.expectedAmount) / props.sourceAmount;
61
35
  this.tokenFrom = props.tokenFrom;
62
36
  this.tokenTo = props.tokenTo;
63
37
  this.operationName = props.operationName;
64
38
  }
65
- Trade.prototype.getName = function () {
39
+ getName() {
66
40
  return this.helper.name;
67
- };
68
- Trade.prototype.getAdapterInterface = function () {
41
+ }
42
+ getAdapterInterface() {
69
43
  return this.helper.adapterInterface;
70
- };
71
- Trade.prototype.getContractAddress = function () {
44
+ }
45
+ getContractAddress() {
72
46
  return this.helper.contractAddress;
73
- };
74
- Trade.prototype.getAdapterAddress = function () {
47
+ }
48
+ getAdapterAddress() {
75
49
  return this.helper.adapterAddress;
76
- };
77
- Trade.prototype.execute = function (signer) {
78
- return __awaiter(this, void 0, void 0, function () {
79
- var receipt;
80
- return __generator(this, function (_a) {
81
- switch (_a.label) {
82
- case 0: return [4 /*yield*/, Trade.executeMulticallPath(this.creditFacade, signer, this.tradePath.calls)];
83
- case 1:
84
- receipt = _a.sent();
85
- return [2 /*return*/, new transactions_1.TXSwap({
86
- txHash: receipt.hash,
87
- protocol: this.helper.contractAddress,
88
- operation: OPERATION_NAMES[this.operationName],
89
- amountFrom: this.sourceAmount,
90
- amountTo: this.expectedAmount,
91
- tokenFrom: this.tokenFrom,
92
- tokenTo: this.tokenTo,
93
- creditManager: this.helper.creditManager,
94
- timestamp: 0,
95
- })];
96
- }
97
- });
50
+ }
51
+ async execute(signer) {
52
+ const receipt = await Trade.executeMulticallPath(this.creditFacade, signer, this.tradePath.calls);
53
+ return new transactions_1.TXSwap({
54
+ txHash: receipt.hash,
55
+ protocol: this.helper.contractAddress,
56
+ operation: OPERATION_NAMES[this.operationName],
57
+ amountFrom: this.sourceAmount,
58
+ amountTo: this.expectedAmount,
59
+ tokenFrom: this.tokenFrom,
60
+ tokenTo: this.tokenTo,
61
+ creditManager: this.helper.creditManager,
62
+ timestamp: 0,
98
63
  });
99
- };
100
- Trade.prototype.toString = function () {
101
- var symbolFrom = token_1.tokenSymbolByAddress[this.tokenFrom.toLowerCase()];
102
- var symbolTo = token_1.tokenSymbolByAddress[this.tokenTo.toLowerCase()];
64
+ }
65
+ toString() {
66
+ const symbolFrom = token_1.tokenSymbolByAddress[this.tokenFrom.toLowerCase()];
67
+ const symbolTo = token_1.tokenSymbolByAddress[this.tokenTo.toLowerCase()];
103
68
  if (!symbolFrom)
104
- throw new Error("Unknown token: ".concat(this.tokenFrom));
69
+ throw new Error(`Unknown token: ${this.tokenFrom}`);
105
70
  if (!symbolTo)
106
- throw new Error("Unknown token: ".concat(this.tokenTo));
107
- var decimalsFrom = decimals_1.decimals[symbolFrom];
108
- var decimalsTo = decimals_1.decimals[symbolTo];
109
- return "".concat(this.operationName, " ").concat((0, formatter_1.formatBN)(this.sourceAmount, decimalsFrom), " ").concat(symbolFrom, " \u21D2 ").concat((0, formatter_1.formatBN)(this.expectedAmount, decimalsTo), " ").concat(symbolTo, " on ").concat(this.helper.name);
110
- };
111
- Trade.getOperationName = function (tokenInAddress, tokenOutAddress) {
112
- var tokenInSymbol = token_1.tokenSymbolByAddress[tokenInAddress];
113
- var tokenOutSymbol = token_1.tokenSymbolByAddress[tokenOutAddress];
114
- var tokenInIsLp = (0, token_1.isLPToken)(tokenInSymbol);
115
- var tokenOutIsLp = (0, token_1.isLPToken)(tokenOutSymbol);
71
+ throw new Error(`Unknown token: ${this.tokenTo}`);
72
+ const decimalsFrom = decimals_1.decimals[symbolFrom];
73
+ const decimalsTo = decimals_1.decimals[symbolTo];
74
+ return `${this.operationName} ${(0, formatter_1.formatBN)(this.sourceAmount, decimalsFrom)} ${symbolFrom} ${(0, formatter_1.formatBN)(this.expectedAmount, decimalsTo)} ${symbolTo} on ${this.helper.name}`;
75
+ }
76
+ static getOperationName(tokenInAddress, tokenOutAddress) {
77
+ const tokenInSymbol = token_1.tokenSymbolByAddress[tokenInAddress];
78
+ const tokenOutSymbol = token_1.tokenSymbolByAddress[tokenOutAddress];
79
+ const tokenInIsLp = (0, token_1.isLPToken)(tokenInSymbol);
80
+ const tokenOutIsLp = (0, token_1.isLPToken)(tokenOutSymbol);
116
81
  if (!tokenInSymbol)
117
- throw new Error("Unknown token: ".concat(tokenInAddress));
82
+ throw new Error(`Unknown token: ${tokenInAddress}`);
118
83
  if (!tokenOutSymbol)
119
- throw new Error("Unknown token: ".concat(tokenOutAddress));
84
+ throw new Error(`Unknown token: ${tokenOutAddress}`);
120
85
  if (tokenInIsLp && !tokenOutIsLp)
121
86
  return "farmWithdraw";
122
87
  if (!tokenInIsLp && tokenOutIsLp)
@@ -124,27 +89,17 @@ var Trade = /** @class */ (function () {
124
89
  if (!tokenInIsLp && !tokenOutIsLp)
125
90
  return "swap";
126
91
  return "unknownOperation";
127
- };
128
- Trade.executeMulticallPath = function (creditFacade, signer, calls) {
129
- return __awaiter(this, void 0, void 0, function () {
130
- var safeCreditFacade;
131
- return __generator(this, function (_a) {
132
- if (calls.length < 1)
133
- throw new Error("No path to execute");
134
- safeCreditFacade = typeof creditFacade === "string"
135
- ? types_1.ICreditFacade__factory.connect(creditFacade, signer)
136
- : creditFacade;
137
- return [2 /*return*/, this.executeOnCreditFacade(calls, safeCreditFacade)];
138
- });
139
- });
140
- };
141
- Trade.executeOnCreditFacade = function (calls, creditFacade) {
142
- return __awaiter(this, void 0, void 0, function () {
143
- return __generator(this, function (_a) {
144
- return [2 /*return*/, creditFacade.multicall(calls)];
145
- });
146
- });
147
- };
148
- return Trade;
149
- }());
92
+ }
93
+ static async executeMulticallPath(creditFacade, signer, calls) {
94
+ if (calls.length < 1)
95
+ throw new Error("No path to execute");
96
+ const safeCreditFacade = typeof creditFacade === "string"
97
+ ? types_1.ICreditFacade__factory.connect(creditFacade, signer)
98
+ : creditFacade;
99
+ return this.executeOnCreditFacade(calls, safeCreditFacade);
100
+ }
101
+ static async executeOnCreditFacade(calls, creditFacade) {
102
+ return creditFacade.multicall(calls);
103
+ }
104
+ }
150
105
  exports.Trade = Trade;
@@ -1,4 +1,3 @@
1
- import { BigNumber } from "ethers";
2
1
  import { SupportedContract } from "../contracts/contracts";
3
2
  import { EVMTx, EVMTxProps } from "./eventOrTx";
4
3
  export interface TxSerialized {
@@ -10,12 +9,12 @@ export declare class TxSerializer {
10
9
  static deserialize(data: string): Array<EVMTx>;
11
10
  }
12
11
  interface AddLiquidityProps extends EVMTxProps {
13
- amount: BigNumber;
12
+ amount: bigint;
14
13
  underlyingToken: string;
15
14
  pool: string;
16
15
  }
17
16
  export declare class TxAddLiquidity extends EVMTx {
18
- readonly amount: BigNumber;
17
+ readonly amount: bigint;
19
18
  readonly underlyingToken: string;
20
19
  readonly pool: string;
21
20
  constructor(opts: AddLiquidityProps);
@@ -23,12 +22,12 @@ export declare class TxAddLiquidity extends EVMTx {
23
22
  serialize(): TxSerialized;
24
23
  }
25
24
  interface RemoveLiquidityProps extends EVMTxProps {
26
- amount: BigNumber;
25
+ amount: bigint;
27
26
  dieselToken: string;
28
27
  pool: string;
29
28
  }
30
29
  export declare class TxRemoveLiquidity extends EVMTx {
31
- readonly amount: BigNumber;
30
+ readonly amount: bigint;
32
31
  readonly dieselToken: string;
33
32
  readonly pool: string;
34
33
  constructor(opts: RemoveLiquidityProps);
@@ -38,8 +37,8 @@ export declare class TxRemoveLiquidity extends EVMTx {
38
37
  interface SwapProps extends EVMTxProps {
39
38
  protocol: string;
40
39
  operation: string;
41
- amountFrom: BigNumber;
42
- amountTo?: BigNumber;
40
+ amountFrom: bigint;
41
+ amountTo?: bigint;
43
42
  tokenFrom: string;
44
43
  tokenTo?: string;
45
44
  creditManager: string;
@@ -47,8 +46,8 @@ interface SwapProps extends EVMTxProps {
47
46
  export declare class TXSwap extends EVMTx {
48
47
  readonly protocol: string;
49
48
  readonly operation: string;
50
- readonly amountFrom: BigNumber;
51
- readonly amountTo?: BigNumber;
49
+ readonly amountFrom: bigint;
50
+ readonly amountTo?: bigint;
52
51
  readonly tokenFrom: string;
53
52
  readonly tokenTo?: string;
54
53
  readonly creditManager: string;
@@ -57,12 +56,12 @@ export declare class TXSwap extends EVMTx {
57
56
  serialize(): TxSerialized;
58
57
  }
59
58
  interface AddCollateralProps extends EVMTxProps {
60
- amount: BigNumber;
59
+ amount: bigint;
61
60
  addedToken: string;
62
61
  creditManager: string;
63
62
  }
64
63
  export declare class TxAddCollateral extends EVMTx {
65
- readonly amount: BigNumber;
64
+ readonly amount: bigint;
66
65
  readonly addedToken: string;
67
66
  readonly creditManager: string;
68
67
  constructor(opts: AddCollateralProps);
@@ -70,12 +69,12 @@ export declare class TxAddCollateral extends EVMTx {
70
69
  serialize(): TxSerialized;
71
70
  }
72
71
  interface IncreaseBorrowAmountProps extends EVMTxProps {
73
- amount: BigNumber;
72
+ amount: bigint;
74
73
  underlyingToken: string;
75
74
  creditManager: string;
76
75
  }
77
76
  export declare class TxIncreaseBorrowAmount extends EVMTx {
78
- readonly amount: BigNumber;
77
+ readonly amount: bigint;
79
78
  readonly underlyingToken: string;
80
79
  readonly creditManager: string;
81
80
  constructor(opts: IncreaseBorrowAmountProps);
@@ -83,12 +82,12 @@ export declare class TxIncreaseBorrowAmount extends EVMTx {
83
82
  serialize(): TxSerialized;
84
83
  }
85
84
  interface DecreaseBorrowAmountProps extends EVMTxProps {
86
- amount: BigNumber;
85
+ amount: bigint;
87
86
  underlyingToken: string;
88
87
  creditManager: string;
89
88
  }
90
89
  export declare class TxDecreaseBorrowAmount extends EVMTx {
91
- readonly amount: BigNumber;
90
+ readonly amount: bigint;
92
91
  readonly underlyingToken: string;
93
92
  readonly creditManager: string;
94
93
  constructor(opts: DecreaseBorrowAmountProps);
@@ -96,13 +95,13 @@ export declare class TxDecreaseBorrowAmount extends EVMTx {
96
95
  serialize(): TxSerialized;
97
96
  }
98
97
  interface OpenAccountProps extends EVMTxProps {
99
- amount: BigNumber;
98
+ amount: bigint;
100
99
  underlyingToken: string;
101
100
  leverage: number;
102
101
  creditManager: string;
103
102
  }
104
103
  export declare class TxOpenAccount extends EVMTx {
105
- readonly amount: BigNumber;
104
+ readonly amount: bigint;
106
105
  readonly underlyingToken: string;
107
106
  readonly leverage: number;
108
107
  readonly creditManager: string;
@@ -111,13 +110,13 @@ export declare class TxOpenAccount extends EVMTx {
111
110
  serialize(): TxSerialized;
112
111
  }
113
112
  interface TxOpenMultitokenAccountProps extends EVMTxProps {
114
- borrowedAmount: BigNumber;
113
+ borrowedAmount: bigint;
115
114
  creditManager: string;
116
115
  underlyingToken: string;
117
116
  assets: Array<string>;
118
117
  }
119
118
  export declare class TxOpenMultitokenAccount extends EVMTx {
120
- readonly borrowedAmount: BigNumber;
119
+ readonly borrowedAmount: bigint;
121
120
  readonly creditManager: string;
122
121
  readonly underlyingToken: string;
123
122
  readonly assets: Array<string>;
@@ -142,11 +141,11 @@ export declare class TxClaimNFT extends EVMTx {
142
141
  }
143
142
  interface TxClaimGearRewardsProps extends EVMTxProps {
144
143
  token: string;
145
- amount: BigNumber;
144
+ amount: bigint;
146
145
  }
147
146
  export declare class TxClaimGearRewards extends EVMTx {
148
- token: string;
149
- amount: BigNumber;
147
+ readonly token: string;
148
+ readonly amount: bigint;
150
149
  constructor(opts: TxClaimGearRewardsProps);
151
150
  toString(): string;
152
151
  serialize(): TxSerialized;