@gearbox-protocol/sdk 3.0.0-next.5 → 3.0.0-next.50

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 (264) hide show
  1. package/contracts/IAirdropDistributor.sol +55 -0
  2. package/contracts/IDegenDistributor.sol +28 -0
  3. package/contracts/IOffchainOracle.sol +17 -0
  4. package/contracts/IWETHGateway.sol +33 -0
  5. package/contracts/IwstETHGateway.sol +24 -0
  6. package/contracts/index.sol +11 -3
  7. package/lib/apy/curveAPY.js +2 -1
  8. package/lib/apy/index.d.ts +2 -2
  9. package/lib/apy/yearnAPY.js +1 -1
  10. package/lib/config.d.ts +0 -1
  11. package/lib/config.js +1 -2
  12. package/lib/core/assets.d.ts +4 -4
  13. package/lib/core/assets.js +28 -17
  14. package/lib/core/creditAccount.d.ts +31 -6
  15. package/lib/core/creditAccount.js +101 -37
  16. package/lib/core/creditAccount.spec.js +693 -10
  17. package/lib/core/creditManager.d.ts +22 -8
  18. package/lib/core/creditManager.js +86 -30
  19. package/lib/core/events.js +14 -14
  20. package/lib/core/gauge.d.ts +26 -0
  21. package/lib/core/gauge.js +63 -0
  22. package/lib/core/gaugeMath.d.ts +40 -0
  23. package/lib/core/gaugeMath.js +108 -0
  24. package/lib/core/gaugeMath.spec.d.ts +1 -0
  25. package/lib/core/gaugeMath.spec.js +388 -0
  26. package/lib/core/{pool/data.d.ts → pool.d.ts} +18 -10
  27. package/lib/core/{pool/data.js → pool.js} +69 -24
  28. package/lib/core/strategy.js +2 -2
  29. package/lib/core/trade.d.ts +5 -23
  30. package/lib/core/trade.js +4 -61
  31. package/lib/core/transactions.d.ts +50 -3
  32. package/lib/core/transactions.js +136 -105
  33. package/lib/index.d.ts +3 -0
  34. package/lib/index.js +3 -0
  35. package/lib/parsers/abstractParser.js +1 -2
  36. package/lib/parsers/creditFacadeParser.d.ts +2 -1
  37. package/lib/parsers/creditFacadeParser.js +17 -5
  38. package/lib/parsers/creditFacadeParser.spec.js +2 -3
  39. package/lib/parsers/curveAdapterParser.js +2 -3
  40. package/lib/parsers/txParser.d.ts +4 -4
  41. package/lib/parsers/txParser.js +9 -3
  42. package/lib/parsers/uniV2AdapterParser.js +2 -2
  43. package/lib/parsers/uniV3AdapterParser.js +3 -3
  44. package/lib/pathfinder/core.d.ts +4 -4
  45. package/lib/pathfinder/pathOptions.d.ts +2 -1
  46. package/lib/pathfinder/pathOptions.js +20 -1
  47. package/lib/pathfinder/pathOptions.spec.js +2 -2
  48. package/lib/pathfinder/pathfinder.js +4 -3
  49. package/lib/pathfinder/pathfinder.spec.js +3 -1
  50. package/lib/payload/creditAccount.d.ts +2 -2
  51. package/lib/payload/gauge.d.ts +12 -0
  52. package/lib/payload/pool.d.ts +6 -1
  53. package/lib/types/IAirdropDistributor.sol/IAirdropDistributor.d.ts +124 -0
  54. package/lib/types/IAirdropDistributor.sol/IAirdropDistributorEvents.d.ts +73 -0
  55. package/lib/types/IAirdropDistributor.sol/index.d.ts +2 -0
  56. package/lib/types/IConvexToken.d.ts +9 -1
  57. package/lib/types/IConvexV1BaseRewardPoolAdapter.d.ts +17 -1
  58. package/lib/types/{IConvexV1BoosterAdapter.d.ts → IConvexV1BoosterAdapter.sol/IConvexV1BoosterAdapter.d.ts} +19 -4
  59. package/lib/types/IConvexV1BoosterAdapter.sol/IConvexV1BoosterAdapterEvents.d.ts +43 -0
  60. package/lib/types/IConvexV1BoosterAdapter.sol/index.d.ts +2 -0
  61. package/lib/types/ICreditConfiguratorV3.sol/ICreditConfiguratorV3.d.ts +716 -0
  62. package/lib/types/ICreditConfiguratorV3.sol/ICreditConfiguratorV3Events.d.ts +275 -0
  63. package/lib/types/ICreditConfiguratorV3.sol/index.d.ts +2 -0
  64. package/lib/types/ICreditFacadeV2.sol/ICreditFacadeV2Extended.d.ts +7 -11
  65. package/lib/types/ICreditFacadeV3.sol/ICreditFacadeV3.d.ts +165 -20
  66. package/lib/types/ICreditFacadeV3.sol/ICreditFacadeV3Events.d.ts +5 -7
  67. package/lib/types/ICreditFacadeV3Multicall.d.ts +35 -12
  68. package/lib/types/ICreditManagerV3.sol/ICreditManagerV3.d.ts +273 -39
  69. package/lib/types/IDataCompressorV2_10.d.ts +43 -9
  70. package/lib/types/IDataCompressorV3_00.d.ts +140 -10
  71. package/lib/types/IDegenDistributor.sol/IDegenDistributor.d.ts +96 -0
  72. package/lib/types/IDegenDistributor.sol/IDegenDistributorEvents.d.ts +53 -0
  73. package/lib/types/IDegenDistributor.sol/index.d.ts +2 -0
  74. package/lib/types/{draft-IERC20Permit.sol/IERC20Permit.d.ts → IERC20Permit.d.ts} +1 -1
  75. package/lib/types/IERC20ZapperDeposits.d.ts +117 -0
  76. package/lib/types/IETHZapperDeposits.d.ts +66 -0
  77. package/lib/types/IGasPricer.d.ts +44 -0
  78. package/lib/types/IGearStakingV3.sol/IGearStakingV3.d.ts +408 -0
  79. package/lib/types/IGearStakingV3.sol/IGearStakingV3Events.d.ts +117 -0
  80. package/lib/types/IGearStakingV3.sol/index.d.ts +2 -0
  81. package/lib/types/{ILidoV1Adapter.sol/ILidoV1Adapter.d.ts → ILidoV1Adapter.d.ts} +5 -40
  82. package/lib/types/ILidoV1Adapter.js +2 -0
  83. package/lib/types/IOffchainOracle.d.ts +58 -0
  84. package/lib/types/IOffchainOracle.js +2 -0
  85. package/lib/types/IPoolV3.sol/IPoolV3.d.ts +43 -11
  86. package/lib/types/IPoolV3.sol/index.d.ts +0 -1
  87. package/lib/types/IWETHGateway.d.ts +90 -0
  88. package/lib/types/IWETHGateway.js +2 -0
  89. package/lib/types/IZapper.d.ts +130 -0
  90. package/lib/types/IZapper.js +2 -0
  91. package/lib/types/IwstETHGateway.sol/IwstETHGateWay.d.ts +70 -0
  92. package/lib/types/IwstETHGateway.sol/IwstETHGateWay.js +2 -0
  93. package/lib/types/IwstETHGateway.sol/index.d.ts +1 -0
  94. package/lib/types/IwstETHGateway.sol/index.js +2 -0
  95. package/lib/types/factories/AddressProvider__factory.d.ts +1 -1
  96. package/lib/types/factories/AddressProvider__factory.js +1 -1
  97. package/lib/types/factories/Balances.sol/BalanceOps__factory.d.ts +1 -1
  98. package/lib/types/factories/Balances.sol/BalanceOps__factory.js +1 -1
  99. package/lib/types/factories/Claimable__factory.d.ts +1 -1
  100. package/lib/types/factories/Claimable__factory.js +1 -1
  101. package/lib/types/factories/Errors__factory.d.ts +1 -1
  102. package/lib/types/factories/Errors__factory.js +1 -1
  103. package/lib/types/factories/IAirdropDistributor.sol/IAirdropDistributorEvents__factory.d.ts +63 -0
  104. package/lib/types/factories/IAirdropDistributor.sol/IAirdropDistributorEvents__factory.js +88 -0
  105. package/lib/types/factories/IAirdropDistributor.sol/IAirdropDistributor__factory.d.ts +119 -0
  106. package/lib/types/factories/IAirdropDistributor.sol/IAirdropDistributor__factory.js +161 -0
  107. package/lib/types/factories/IAirdropDistributor.sol/index.d.ts +2 -0
  108. package/lib/types/factories/IAirdropDistributor.sol/index.js +10 -0
  109. package/lib/types/factories/IConvexToken__factory.d.ts +10 -0
  110. package/lib/types/factories/IConvexToken__factory.js +13 -0
  111. package/lib/types/factories/IConvexV1BaseRewardPoolAdapter__factory.d.ts +20 -0
  112. package/lib/types/factories/IConvexV1BaseRewardPoolAdapter__factory.js +26 -0
  113. package/lib/types/factories/IConvexV1BoosterAdapter.sol/IConvexV1BoosterAdapterEvents__factory.d.ts +23 -0
  114. package/lib/types/factories/IConvexV1BoosterAdapter.sol/IConvexV1BoosterAdapterEvents__factory.js +38 -0
  115. package/lib/types/factories/{IConvexV1BoosterAdapter__factory.d.ts → IConvexV1BoosterAdapter.sol/IConvexV1BoosterAdapter__factory.d.ts} +16 -1
  116. package/lib/types/factories/{IConvexV1BoosterAdapter__factory.js → IConvexV1BoosterAdapter.sol/IConvexV1BoosterAdapter__factory.js} +19 -0
  117. package/lib/types/factories/IConvexV1BoosterAdapter.sol/index.d.ts +2 -0
  118. package/lib/types/factories/IConvexV1BoosterAdapter.sol/index.js +10 -0
  119. package/lib/types/factories/ICreditConfiguratorV3.sol/ICreditConfiguratorV3Events__factory.d.ts +273 -0
  120. package/lib/types/factories/ICreditConfiguratorV3.sol/ICreditConfiguratorV3Events__factory.js +357 -0
  121. package/lib/types/factories/ICreditConfiguratorV3.sol/ICreditConfiguratorV3__factory.d.ts +605 -0
  122. package/lib/types/factories/ICreditConfiguratorV3.sol/ICreditConfiguratorV3__factory.js +785 -0
  123. package/lib/types/factories/ICreditConfiguratorV3.sol/index.d.ts +2 -0
  124. package/lib/types/factories/ICreditConfiguratorV3.sol/index.js +10 -0
  125. package/lib/types/factories/ICreditFacadeV2.sol/ICreditFacadeV2Extended__factory.d.ts +0 -4
  126. package/lib/types/factories/ICreditFacadeV2.sol/ICreditFacadeV2Extended__factory.js +0 -5
  127. package/lib/types/factories/ICreditFacadeV3.sol/ICreditFacadeV3Events__factory.d.ts +1 -6
  128. package/lib/types/factories/ICreditFacadeV3.sol/ICreditFacadeV3Events__factory.js +1 -7
  129. package/lib/types/factories/ICreditFacadeV3.sol/ICreditFacadeV3__factory.d.ts +144 -13
  130. package/lib/types/factories/ICreditFacadeV3.sol/ICreditFacadeV3__factory.js +185 -15
  131. package/lib/types/factories/ICreditFacadeV3Multicall__factory.d.ts +35 -5
  132. package/lib/types/factories/ICreditFacadeV3Multicall__factory.js +43 -5
  133. package/lib/types/factories/ICreditManagerV3.sol/ICreditManagerV3__factory.d.ts +199 -25
  134. package/lib/types/factories/ICreditManagerV3.sol/ICreditManagerV3__factory.js +252 -28
  135. package/lib/types/factories/IDataCompressorV2_10__factory.d.ts +110 -12
  136. package/lib/types/factories/IDataCompressorV2_10__factory.js +138 -14
  137. package/lib/types/factories/IDataCompressorV3_00__factory.d.ts +400 -16
  138. package/lib/types/factories/IDataCompressorV3_00__factory.js +508 -19
  139. package/lib/types/factories/IDegenDistributor.sol/IDegenDistributorEvents__factory.d.ts +38 -0
  140. package/lib/types/factories/{AaveV2_WrappedAToken.sol/IWrappedATokenEvents__factory.js → IDegenDistributor.sol/IDegenDistributorEvents__factory.js} +13 -25
  141. package/lib/types/factories/IDegenDistributor.sol/IDegenDistributor__factory.d.ts +84 -0
  142. package/lib/types/factories/{IPoolV3.sol/IPoolBase__factory.js → IDegenDistributor.sol/IDegenDistributor__factory.js} +46 -41
  143. package/lib/types/factories/IDegenDistributor.sol/index.d.ts +2 -0
  144. package/lib/types/factories/IDegenDistributor.sol/index.js +10 -0
  145. package/lib/types/factories/{draft-IERC20Permit.sol/IERC20Permit__factory.d.ts → IERC20Permit__factory.d.ts} +1 -1
  146. package/lib/types/factories/IERC20ZapperDeposits__factory.d.ts +120 -0
  147. package/lib/types/factories/IERC20ZapperDeposits__factory.js +165 -0
  148. package/lib/types/factories/IETHZapperDeposits__factory.d.ts +40 -0
  149. package/lib/types/factories/IETHZapperDeposits__factory.js +62 -0
  150. package/lib/types/factories/IGasPricer__factory.d.ts +22 -0
  151. package/lib/types/factories/{ILidoV1Adapter.sol/ILidoV1AdapterEvents__factory.js → IGasPricer__factory.js} +14 -8
  152. package/lib/types/factories/IGearStakingV3.sol/IGearStakingV3Events__factory.d.ts +113 -0
  153. package/lib/types/factories/IGearStakingV3.sol/IGearStakingV3Events__factory.js +152 -0
  154. package/lib/types/factories/IGearStakingV3.sol/IGearStakingV3__factory.d.ts +504 -0
  155. package/lib/types/factories/IGearStakingV3.sol/IGearStakingV3__factory.js +660 -0
  156. package/lib/types/factories/IGearStakingV3.sol/index.d.ts +2 -0
  157. package/lib/types/factories/IGearStakingV3.sol/index.js +10 -0
  158. package/lib/types/factories/{ILidoV1Adapter.sol/ILidoV1Adapter__factory.d.ts → ILidoV1Adapter__factory.d.ts} +1 -35
  159. package/lib/types/factories/{ILidoV1Adapter.sol/ILidoV1Adapter__factory.js → ILidoV1Adapter__factory.js} +0 -44
  160. package/lib/types/factories/IOffchainOracle__factory.d.ts +48 -0
  161. package/lib/types/factories/IOffchainOracle__factory.js +72 -0
  162. package/lib/types/factories/IPoolV3.sol/IPoolV3__factory.d.ts +62 -14
  163. package/lib/types/factories/IPoolV3.sol/IPoolV3__factory.js +79 -17
  164. package/lib/types/factories/IPoolV3.sol/index.d.ts +0 -1
  165. package/lib/types/factories/IPoolV3.sol/index.js +1 -3
  166. package/lib/types/factories/IWETHGateway__factory.d.ts +58 -0
  167. package/lib/types/factories/IWETHGateway__factory.js +83 -0
  168. package/lib/types/factories/{WERC20ZapperBase__factory.d.ts → IZapper__factory.d.ts} +57 -61
  169. package/lib/types/factories/{WERC20ZapperBase__factory.js → IZapper__factory.js} +65 -71
  170. package/lib/types/factories/{ZapperBase__factory.d.ts → IwstETHGateway.sol/IwstETHGateWay__factory.d.ts} +22 -34
  171. package/lib/types/factories/{ZapperBase__factory.js → IwstETHGateway.sol/IwstETHGateWay__factory.js} +22 -39
  172. package/lib/types/factories/IwstETHGateway.sol/index.d.ts +1 -0
  173. package/lib/types/factories/IwstETHGateway.sol/index.js +8 -0
  174. package/lib/types/factories/SafeERC20__factory.d.ts +1 -1
  175. package/lib/types/factories/SafeERC20__factory.js +1 -1
  176. package/lib/types/factories/index.d.ts +15 -13
  177. package/lib/types/factories/index.js +25 -25
  178. package/lib/types/factories/{IRouter__factory.d.ts → interfaces/IRouter__factory.d.ts} +15 -1
  179. package/lib/types/factories/{IRouter__factory.js → interfaces/IRouter__factory.js} +19 -0
  180. package/lib/types/factories/interfaces/index.d.ts +1 -0
  181. package/lib/types/factories/interfaces/index.js +8 -0
  182. package/lib/types/index.d.ts +62 -48
  183. package/lib/types/index.js +52 -46
  184. package/lib/types/{IRouter.d.ts → interfaces/IRouter.d.ts} +12 -2
  185. package/lib/types/interfaces/IRouter.js +2 -0
  186. package/lib/types/interfaces/index.d.ts +1 -0
  187. package/lib/types/interfaces/index.js +2 -0
  188. package/lib/utils/formatter.d.ts +0 -3
  189. package/lib/utils/formatter.js +1 -67
  190. package/lib/utils/math.d.ts +2 -0
  191. package/lib/utils/math.js +2 -0
  192. package/lib/utils/types.d.ts +1 -0
  193. package/lib/watchers/creditAccountWatcher.d.ts +3 -2
  194. package/lib/watchers/creditAccountWatcher.js +19 -13
  195. package/lib/watchers/creditAccountWatcher.spec.js +18 -18
  196. package/lib/watchers/creditManagerWatcher.d.ts +5 -3
  197. package/lib/watchers/creditManagerWatcher.js +32 -10
  198. package/lib/watchers/creditManagerWatcher.spec.js +12 -4
  199. package/package.json +10 -9
  200. package/contracts/IRouter.sol +0 -100
  201. package/lib/core/pool/index.d.ts +0 -1
  202. package/lib/core/pool/index.js +0 -17
  203. package/lib/types/AaveV2_WrappedAToken.sol/IWrappedATokenEvents.d.ts +0 -60
  204. package/lib/types/AaveV2_WrappedAToken.sol/WrappedAToken.d.ts +0 -332
  205. package/lib/types/AaveV2_WrappedAToken.sol/index.d.ts +0 -2
  206. package/lib/types/ERC20.d.ts +0 -198
  207. package/lib/types/IAToken.d.ts +0 -182
  208. package/lib/types/ILendingPool.d.ts +0 -140
  209. package/lib/types/ILidoV1Adapter.sol/ILidoV1AdapterEvents.d.ts +0 -39
  210. package/lib/types/ILidoV1Adapter.sol/ILidoV1AdapterExceptions.d.ts +0 -27
  211. package/lib/types/ILidoV1Adapter.sol/index.d.ts +0 -3
  212. package/lib/types/IPoolV3.sol/IPoolBase.d.ts +0 -102
  213. package/lib/types/WATokenZapper.d.ts +0 -134
  214. package/lib/types/WERC20ZapperBase.d.ts +0 -134
  215. package/lib/types/WETHZapper.d.ts +0 -122
  216. package/lib/types/WstETHZapper.d.ts +0 -134
  217. package/lib/types/ZapperBase.d.ts +0 -70
  218. package/lib/types/draft-IERC20Permit.sol/index.d.ts +0 -1
  219. package/lib/types/factories/AaveV2_WrappedAToken.sol/IWrappedATokenEvents__factory.d.ts +0 -48
  220. package/lib/types/factories/AaveV2_WrappedAToken.sol/WrappedAToken__factory.d.ts +0 -397
  221. package/lib/types/factories/AaveV2_WrappedAToken.sol/WrappedAToken__factory.js +0 -535
  222. package/lib/types/factories/AaveV2_WrappedAToken.sol/index.d.ts +0 -2
  223. package/lib/types/factories/AaveV2_WrappedAToken.sol/index.js +0 -10
  224. package/lib/types/factories/ERC20__factory.d.ts +0 -239
  225. package/lib/types/factories/ERC20__factory.js +0 -328
  226. package/lib/types/factories/IAToken__factory.d.ts +0 -198
  227. package/lib/types/factories/IAToken__factory.js +0 -267
  228. package/lib/types/factories/ILendingPool__factory.d.ts +0 -134
  229. package/lib/types/factories/ILendingPool__factory.js +0 -183
  230. package/lib/types/factories/ILidoV1Adapter.sol/ILidoV1AdapterEvents__factory.d.ts +0 -18
  231. package/lib/types/factories/ILidoV1Adapter.sol/ILidoV1AdapterExceptions__factory.d.ts +0 -12
  232. package/lib/types/factories/ILidoV1Adapter.sol/ILidoV1AdapterExceptions__factory.js +0 -24
  233. package/lib/types/factories/ILidoV1Adapter.sol/index.d.ts +0 -3
  234. package/lib/types/factories/ILidoV1Adapter.sol/index.js +0 -12
  235. package/lib/types/factories/IPoolV3.sol/IPoolBase__factory.d.ts +0 -80
  236. package/lib/types/factories/WATokenZapper__factory.d.ts +0 -161
  237. package/lib/types/factories/WATokenZapper__factory.js +0 -227
  238. package/lib/types/factories/WETHZapper__factory.d.ts +0 -138
  239. package/lib/types/factories/WETHZapper__factory.js +0 -198
  240. package/lib/types/factories/WstETHZapper__factory.d.ts +0 -161
  241. package/lib/types/factories/WstETHZapper__factory.js +0 -227
  242. package/lib/types/factories/draft-IERC20Permit.sol/index.d.ts +0 -1
  243. package/lib/types/factories/draft-IERC20Permit.sol/index.js +0 -8
  244. /package/lib/{types/AaveV2_WrappedAToken.sol/IWrappedATokenEvents.js → payload/gauge.js} +0 -0
  245. /package/lib/types/{AaveV2_WrappedAToken.sol/WrappedAToken.js → IAirdropDistributor.sol/IAirdropDistributor.js} +0 -0
  246. /package/lib/types/{AaveV2_WrappedAToken.sol/index.js → IAirdropDistributor.sol/IAirdropDistributorEvents.js} +0 -0
  247. /package/lib/types/{ILidoV1Adapter.sol → IAirdropDistributor.sol}/index.js +0 -0
  248. /package/lib/types/{IConvexV1BoosterAdapter.js → IConvexV1BoosterAdapter.sol/IConvexV1BoosterAdapter.js} +0 -0
  249. /package/lib/types/{ERC20.js → IConvexV1BoosterAdapter.sol/IConvexV1BoosterAdapterEvents.js} +0 -0
  250. /package/lib/types/{draft-IERC20Permit.sol → IConvexV1BoosterAdapter.sol}/index.js +0 -0
  251. /package/lib/types/{IAToken.js → ICreditConfiguratorV3.sol/ICreditConfiguratorV3.js} +0 -0
  252. /package/lib/types/{ILendingPool.js → ICreditConfiguratorV3.sol/ICreditConfiguratorV3Events.js} +0 -0
  253. /package/lib/types/{ILidoV1Adapter.sol/ILidoV1Adapter.js → ICreditConfiguratorV3.sol/index.js} +0 -0
  254. /package/lib/types/{ILidoV1Adapter.sol/ILidoV1AdapterEvents.js → IDegenDistributor.sol/IDegenDistributor.js} +0 -0
  255. /package/lib/types/{ILidoV1Adapter.sol/ILidoV1AdapterExceptions.js → IDegenDistributor.sol/IDegenDistributorEvents.js} +0 -0
  256. /package/lib/types/{IPoolV3.sol/IPoolBase.js → IDegenDistributor.sol/index.js} +0 -0
  257. /package/lib/types/{draft-IERC20Permit.sol/IERC20Permit.js → IERC20Permit.js} +0 -0
  258. /package/lib/types/{IRouter.js → IERC20ZapperDeposits.js} +0 -0
  259. /package/lib/types/{WATokenZapper.js → IETHZapperDeposits.js} +0 -0
  260. /package/lib/types/{WERC20ZapperBase.js → IGasPricer.js} +0 -0
  261. /package/lib/types/{WETHZapper.js → IGearStakingV3.sol/IGearStakingV3.js} +0 -0
  262. /package/lib/types/{WstETHZapper.js → IGearStakingV3.sol/IGearStakingV3Events.js} +0 -0
  263. /package/lib/types/{ZapperBase.js → IGearStakingV3.sol/index.js} +0 -0
  264. /package/lib/types/factories/{draft-IERC20Permit.sol/IERC20Permit__factory.js → IERC20Permit__factory.js} +0 -0
package/lib/core/trade.js CHANGED
@@ -4,19 +4,9 @@ exports.Trade = void 0;
4
4
  const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
5
5
  const txParser_1 = require("../parsers/txParser");
6
6
  const core_1 = require("../pathfinder/core");
7
- const types_1 = require("../types");
8
- const formatter_1 = require("../utils/formatter");
9
- const transactions_1 = require("./transactions");
10
- const OPERATION_NAMES = {
11
- farmWithdraw: "Farm withdraw",
12
- farmDeposit: "Farm deposit",
13
- swap: "Swap",
14
- unknownOperation: "Unknown operation",
15
- };
16
7
  class Trade {
17
8
  helper;
18
9
  tradePath;
19
- creditFacade;
20
10
  swapType;
21
11
  sourceAmount;
22
12
  expectedAmount;
@@ -27,7 +17,6 @@ class Trade {
27
17
  constructor(props) {
28
18
  this.helper = props.adapter;
29
19
  this.tradePath = props.tradePath;
30
- this.creditFacade = props.creditFacade;
31
20
  this.swapType = props.swapType;
32
21
  this.sourceAmount = props.sourceAmount;
33
22
  this.expectedAmount = props.expectedAmount;
@@ -39,20 +28,6 @@ class Trade {
39
28
  getName() {
40
29
  return this.helper.name;
41
30
  }
42
- async execute(signer) {
43
- const receipt = await Trade.executeMulticallPath(this.creditFacade, signer, this.tradePath.calls);
44
- return new transactions_1.TXSwap({
45
- txHash: receipt.hash,
46
- protocol: this.helper.contractAddress,
47
- operation: OPERATION_NAMES[this.operationName],
48
- amountFrom: this.sourceAmount,
49
- amountTo: this.expectedAmount,
50
- tokenFrom: this.tokenFrom,
51
- tokenTo: this.tokenTo,
52
- creditManager: this.helper.creditManager,
53
- timestamp: 0,
54
- });
55
- }
56
31
  toString() {
57
32
  const symbolFrom = sdk_gov_1.tokenSymbolByAddress[this.tokenFrom.toLowerCase()];
58
33
  const symbolTo = sdk_gov_1.tokenSymbolByAddress[this.tokenTo.toLowerCase()];
@@ -62,45 +37,27 @@ class Trade {
62
37
  throw new Error(`Unknown token: ${this.tokenTo}`);
63
38
  const decimalsFrom = sdk_gov_1.decimals[symbolFrom];
64
39
  const decimalsTo = sdk_gov_1.decimals[symbolTo];
65
- return `${this.operationName} ${(0, formatter_1.formatBN)(this.sourceAmount, decimalsFrom)} ${symbolFrom} ⇒ ${(0, formatter_1.formatBN)(this.expectedAmount, decimalsTo)} ${symbolTo} on ${this.helper.name}`;
40
+ return `${this.operationName} ${(0, sdk_gov_1.formatBN)(this.sourceAmount, decimalsFrom)} ${symbolFrom} ⇒ ${(0, sdk_gov_1.formatBN)(this.expectedAmount, decimalsTo)} ${symbolTo} on ${this.helper.name}`;
66
41
  }
67
- static getTrades({ from, to, amount, results, creditManager, currentContracts, }) {
42
+ static getTrades({ from, to, amount, results, creditManager, currentContracts, swapType, swapName, }) {
68
43
  const trades = results.reduce((acc, tradePath) => {
69
44
  const { calls } = tradePath;
70
45
  const callInfo = Trade.getCallInfo(calls, creditManager.address, currentContracts);
71
46
  const trade = new Trade({
72
47
  tradePath,
73
- creditFacade: creditManager.creditFacade,
74
48
  adapter: callInfo[0],
75
- swapType: core_1.SwapOperation.EXACT_INPUT,
49
+ swapType,
76
50
  sourceAmount: amount,
77
51
  expectedAmount: tradePath.amount,
78
52
  tokenFrom: from,
79
53
  tokenTo: to,
80
- swapName: Trade.getOperationName(from, to),
54
+ swapName,
81
55
  });
82
56
  acc.push(trade);
83
57
  return acc;
84
58
  }, []);
85
59
  return trades;
86
60
  }
87
- static getOperationName(tokenInAddress, tokenOutAddress) {
88
- const tokenInSymbol = sdk_gov_1.tokenSymbolByAddress[tokenInAddress];
89
- const tokenOutSymbol = sdk_gov_1.tokenSymbolByAddress[tokenOutAddress];
90
- const tokenInIsLp = (0, sdk_gov_1.isLPToken)(tokenInSymbol);
91
- const tokenOutIsLp = (0, sdk_gov_1.isLPToken)(tokenOutSymbol);
92
- if (!tokenInSymbol)
93
- throw new Error(`Unknown token: ${tokenInAddress}`);
94
- if (!tokenOutSymbol)
95
- throw new Error(`Unknown token: ${tokenOutAddress}`);
96
- if (tokenInIsLp && !tokenOutIsLp)
97
- return "farmWithdraw";
98
- if (!tokenInIsLp && tokenOutIsLp)
99
- return "farmDeposit";
100
- if (!tokenInIsLp && !tokenOutIsLp)
101
- return "swap";
102
- return "unknownOperation";
103
- }
104
61
  static getCallInfo(calls, creditManager, currentContracts) {
105
62
  const callAdapters = calls.reduce((acc, call) => {
106
63
  const contractSymbol = this.getContractSymbol(call.target.toLowerCase());
@@ -126,9 +83,6 @@ class Trade {
126
83
  return undefined;
127
84
  }
128
85
  }
129
- static getTradeId(trade) {
130
- return `${trade.getName()}:${trade.expectedAmount.toString()}`;
131
- }
132
86
  static sortTrades(trades, swapStrategy) {
133
87
  if (trades.length === 0)
134
88
  return [];
@@ -144,16 +98,5 @@ class Trade {
144
98
  });
145
99
  return sorted;
146
100
  }
147
- static async executeMulticallPath(creditFacade, signer, calls) {
148
- if (calls.length < 1)
149
- throw new Error("No path to execute");
150
- const safeCreditFacade = typeof creditFacade === "string"
151
- ? types_1.ICreditFacadeV2__factory.connect(creditFacade, signer)
152
- : creditFacade;
153
- return this.executeOnCreditFacade(calls, safeCreditFacade);
154
- }
155
- static async executeOnCreditFacade(calls, creditFacade) {
156
- return creditFacade.multicall(calls);
157
- }
158
101
  }
159
102
  exports.Trade = Trade;
@@ -1,7 +1,8 @@
1
1
  import { SupportedContract } from "@gearbox-protocol/sdk-gov";
2
+ import { Asset } from "./assets";
2
3
  import { EVMTx, EVMTxProps } from "./eventOrTx";
3
4
  export interface TxSerialized {
4
- type: "TxAddLiquidity" | "TxRemoveLiquidity" | "TxSwap" | "TxAddCollateral" | "TxIncreaseBorrowAmount" | "TxDecreaseBorrowAmount" | "TxOpenAccount" | "TxRepayAccount" | "TxCloseAccount" | "TxApprove" | "TxOpenMultitokenAccount" | "TxClaimReward" | "TxClaimNFT" | "TxClaimGearRewards" | "TxEnableTokens";
5
+ type: "TxAddLiquidity" | "TxRemoveLiquidity" | "TxSwap" | "TxAddCollateral" | "TxIncreaseBorrowAmount" | "TxDecreaseBorrowAmount" | "TxOpenAccount" | "TxRepayAccount" | "TxCloseAccount" | "TxApprove" | "TxOpenMultitokenAccount" | "TxClaimReward" | "TxClaimNFT" | "TxClaimGearRewards" | "TxEnableTokens" | "TxUpdateQuota" | "TxGaugeStake" | "TxGaugeUnstake" | "TxGaugeClaim" | "TxGaugeVote";
5
6
  content: string;
6
7
  }
7
8
  export declare class TxSerializer {
@@ -133,9 +134,7 @@ export declare class TxClaimReward extends EVMTx {
133
134
  toString(): string;
134
135
  serialize(): TxSerialized;
135
136
  }
136
- type TxClaimNFTProps = EVMTxProps;
137
137
  export declare class TxClaimNFT extends EVMTx {
138
- constructor(opts: TxClaimNFTProps);
139
138
  toString(): string;
140
139
  serialize(): TxSerialized;
141
140
  }
@@ -190,4 +189,52 @@ export declare class TxEnableTokens extends EVMTx {
190
189
  toString(): string;
191
190
  serialize(): TxSerialized;
192
191
  }
192
+ interface TxUpdateQuotaProps extends EVMTxProps {
193
+ updatedQuotas: Array<Asset>;
194
+ underlyingToken: string;
195
+ creditManager: string;
196
+ }
197
+ export declare class TxUpdateQuota extends EVMTx {
198
+ readonly updatedQuotas: Array<Asset>;
199
+ readonly underlyingToken: string;
200
+ readonly creditManager: string;
201
+ constructor(opts: TxUpdateQuotaProps);
202
+ toString(): string;
203
+ serialize(): TxSerialized;
204
+ }
205
+ interface TxGaugeStakeProps extends EVMTxProps {
206
+ amount: bigint;
207
+ }
208
+ export declare class TxGaugeStake extends EVMTx {
209
+ readonly amount: bigint;
210
+ constructor(opts: TxGaugeStakeProps);
211
+ toString(): string;
212
+ serialize(): TxSerialized;
213
+ }
214
+ interface TxGaugeUnstakeProps extends EVMTxProps {
215
+ amount: bigint;
216
+ }
217
+ export declare class TxGaugeUnstake extends EVMTx {
218
+ readonly amount: bigint;
219
+ constructor(opts: TxGaugeUnstakeProps);
220
+ toString(): string;
221
+ serialize(): TxSerialized;
222
+ }
223
+ export declare class TxGaugeClaim extends EVMTx {
224
+ toString(): string;
225
+ serialize(): TxSerialized;
226
+ }
227
+ interface TxGaugeVoteProps extends EVMTxProps {
228
+ tokens: Array<{
229
+ token: string;
230
+ }>;
231
+ }
232
+ export declare class TxGaugeVote extends EVMTx {
233
+ readonly tokens: Array<{
234
+ token: string;
235
+ }>;
236
+ constructor(opts: TxGaugeVoteProps);
237
+ toString(): string;
238
+ serialize(): TxSerialized;
239
+ }
193
240
  export {};
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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;
3
+ exports.TxGaugeVote = exports.TxGaugeClaim = exports.TxGaugeUnstake = exports.TxGaugeStake = exports.TxUpdateQuota = 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;
4
4
  const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
5
5
  const contractsRegister_1 = require("../contracts/contractsRegister");
6
- const formatter_1 = require("../utils/formatter");
6
+ const math_1 = require("../utils/math");
7
7
  const eventOrTx_1 = require("./eventOrTx");
8
8
  class TxSerializer {
9
9
  static serialize(items) {
@@ -43,6 +43,16 @@ class TxSerializer {
43
43
  return new TxClaimGearRewards(params);
44
44
  case "TxEnableTokens":
45
45
  return new TxEnableTokens(params);
46
+ case "TxUpdateQuota":
47
+ return new TxUpdateQuota(params);
48
+ case "TxGaugeStake":
49
+ return new TxGaugeStake(params);
50
+ case "TxGaugeUnstake":
51
+ return new TxGaugeUnstake(params);
52
+ case "TxGaugeClaim":
53
+ return new TxGaugeClaim(params);
54
+ case "TxGaugeVote":
55
+ return new TxGaugeVote(params);
46
56
  default:
47
57
  throw new Error(`Unknown transaction for parsing: ${e.type}`);
48
58
  }
@@ -55,19 +65,14 @@ class TxAddLiquidity extends eventOrTx_1.EVMTx {
55
65
  underlyingToken;
56
66
  pool;
57
67
  constructor(opts) {
58
- super({
59
- block: opts.block,
60
- txHash: opts.txHash,
61
- txStatus: opts.txStatus,
62
- timestamp: opts.timestamp,
63
- });
68
+ super(opts);
64
69
  this.amount = opts.amount;
65
70
  this.underlyingToken = opts.underlyingToken;
66
71
  this.pool = opts.pool;
67
72
  }
68
73
  toString() {
69
74
  const [underlyingSymbol, underlyingDecimals] = (0, sdk_gov_1.extractTokenData)(this.underlyingToken);
70
- return `${(0, contractsRegister_1.getContractName)(this.pool)}: Deposit ${(0, formatter_1.formatBN)(this.amount, underlyingDecimals || 18)} ${underlyingSymbol}`;
75
+ return `${(0, contractsRegister_1.getContractName)(this.pool)}: Deposit ${(0, sdk_gov_1.formatBN)(this.amount, underlyingDecimals || 18)} ${underlyingSymbol}`;
71
76
  }
72
77
  serialize() {
73
78
  return {
@@ -82,19 +87,14 @@ class TxRemoveLiquidity extends eventOrTx_1.EVMTx {
82
87
  dieselToken;
83
88
  pool;
84
89
  constructor(opts) {
85
- super({
86
- block: opts.block,
87
- txHash: opts.txHash,
88
- txStatus: opts.txStatus,
89
- timestamp: opts.timestamp,
90
- });
90
+ super(opts);
91
91
  this.amount = opts.amount;
92
92
  this.dieselToken = opts.dieselToken;
93
93
  this.pool = opts.pool;
94
94
  }
95
95
  toString() {
96
96
  const [dSymbol, dDecimals] = (0, sdk_gov_1.extractTokenData)(this.dieselToken);
97
- return `${(0, contractsRegister_1.getContractName)(this.pool)}: Withdraw ${(0, formatter_1.formatBN)(this.amount, dDecimals || 18)} ${dSymbol}`;
97
+ return `${(0, contractsRegister_1.getContractName)(this.pool)}: Withdraw ${(0, sdk_gov_1.formatBN)(this.amount, dDecimals || 18)} ${dSymbol}`;
98
98
  }
99
99
  serialize() {
100
100
  return {
@@ -113,12 +113,7 @@ class TXSwap extends eventOrTx_1.EVMTx {
113
113
  tokenTo;
114
114
  creditManager;
115
115
  constructor(opts) {
116
- super({
117
- block: opts.block,
118
- txHash: opts.txHash,
119
- txStatus: opts.txStatus,
120
- timestamp: opts.timestamp,
121
- });
116
+ super(opts);
122
117
  this.protocol = opts.protocol;
123
118
  this.operation = opts.operation;
124
119
  this.amountFrom = opts.amountFrom;
@@ -131,10 +126,10 @@ class TXSwap extends eventOrTx_1.EVMTx {
131
126
  let toPart = "";
132
127
  if (this.tokenTo && this.amountTo) {
133
128
  const [toSymbol, toDecimals] = (0, sdk_gov_1.extractTokenData)(this.tokenTo);
134
- toPart = ` ⇒ ${(0, formatter_1.formatBN)(this.amountTo, toDecimals || 18)} ${toSymbol}`;
129
+ toPart = ` ⇒ ${(0, sdk_gov_1.formatBN)(this.amountTo, toDecimals || 18)} ${toSymbol}`;
135
130
  }
136
131
  const [fromSymbol, fromDecimals] = (0, sdk_gov_1.extractTokenData)(this.tokenFrom);
137
- 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)}`;
132
+ return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: ${this.operation} ${(0, sdk_gov_1.formatBN)(this.amountFrom, fromDecimals || 18)} ${fromSymbol} ${toPart} on ${(0, contractsRegister_1.getContractName)(this.protocol)}`;
138
133
  }
139
134
  serialize() {
140
135
  return {
@@ -149,19 +144,14 @@ class TxAddCollateral extends eventOrTx_1.EVMTx {
149
144
  addedToken;
150
145
  creditManager;
151
146
  constructor(opts) {
152
- super({
153
- block: opts.block,
154
- txHash: opts.txHash,
155
- txStatus: opts.txStatus,
156
- timestamp: opts.timestamp,
157
- });
147
+ super(opts);
158
148
  this.amount = opts.amount;
159
149
  this.addedToken = opts.addedToken;
160
150
  this.creditManager = opts.creditManager;
161
151
  }
162
152
  toString() {
163
153
  const [addedSymbol, addedDecimals] = (0, sdk_gov_1.extractTokenData)(this.addedToken);
164
- return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: Added ${(0, formatter_1.formatBN)(this.amount, addedDecimals || 18)} ${addedSymbol} as collateral`;
154
+ return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: Added ${(0, sdk_gov_1.formatBN)(this.amount, addedDecimals || 18)} ${addedSymbol} as collateral`;
165
155
  }
166
156
  serialize() {
167
157
  return {
@@ -176,19 +166,14 @@ class TxIncreaseBorrowAmount extends eventOrTx_1.EVMTx {
176
166
  underlyingToken;
177
167
  creditManager;
178
168
  constructor(opts) {
179
- super({
180
- block: opts.block,
181
- txHash: opts.txHash,
182
- txStatus: opts.txStatus,
183
- timestamp: opts.timestamp,
184
- });
169
+ super(opts);
185
170
  this.amount = opts.amount;
186
171
  this.underlyingToken = opts.underlyingToken;
187
172
  this.creditManager = opts.creditManager;
188
173
  }
189
174
  toString() {
190
175
  const [tokenSymbol, tokenDecimals] = (0, sdk_gov_1.extractTokenData)(this.underlyingToken);
191
- return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: Borrowed amount was increased for ${(0, formatter_1.formatBN)(this.amount, tokenDecimals || 18)} ${tokenSymbol}`;
176
+ return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: Borrowed amount was increased for ${(0, sdk_gov_1.formatBN)(this.amount, tokenDecimals || 18)} ${tokenSymbol}`;
192
177
  }
193
178
  serialize() {
194
179
  return {
@@ -203,19 +188,14 @@ class TxDecreaseBorrowAmount extends eventOrTx_1.EVMTx {
203
188
  underlyingToken;
204
189
  creditManager;
205
190
  constructor(opts) {
206
- super({
207
- block: opts.block,
208
- txHash: opts.txHash,
209
- txStatus: opts.txStatus,
210
- timestamp: opts.timestamp,
211
- });
191
+ super(opts);
212
192
  this.amount = opts.amount;
213
193
  this.underlyingToken = opts.underlyingToken;
214
194
  this.creditManager = opts.creditManager;
215
195
  }
216
196
  toString() {
217
197
  const [tokenSymbol, tokenDecimals] = (0, sdk_gov_1.extractTokenData)(this.underlyingToken);
218
- return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: Borrowed amount was decreased for ${(0, formatter_1.formatBN)(this.amount, tokenDecimals || 18)} ${tokenSymbol}`;
198
+ return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: Borrowed amount was decreased for ${(0, sdk_gov_1.formatBN)(this.amount, tokenDecimals || 18)} ${tokenSymbol}`;
219
199
  }
220
200
  serialize() {
221
201
  return {
@@ -231,12 +211,7 @@ class TxOpenAccount extends eventOrTx_1.EVMTx {
231
211
  leverage;
232
212
  creditManager;
233
213
  constructor(opts) {
234
- super({
235
- block: opts.block,
236
- txHash: opts.txHash,
237
- txStatus: opts.txStatus,
238
- timestamp: opts.timestamp,
239
- });
214
+ super(opts);
240
215
  this.amount = opts.amount;
241
216
  this.underlyingToken = opts.underlyingToken;
242
217
  this.leverage = opts.leverage;
@@ -244,8 +219,8 @@ class TxOpenAccount extends eventOrTx_1.EVMTx {
244
219
  }
245
220
  toString() {
246
221
  const [tokenSymbol, tokenDecimals] = (0, sdk_gov_1.extractTokenData)(this.underlyingToken);
247
- return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: opening ${(0, formatter_1.formatBN)(this.amount, tokenDecimals || 18)} ${tokenSymbol} x ${this.leverage.toFixed(2)} ⇒
248
- ${(0, formatter_1.formatBN)((this.amount *
222
+ return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: opening ${(0, sdk_gov_1.formatBN)(this.amount, tokenDecimals || 18)} ${tokenSymbol} x ${this.leverage.toFixed(2)} ⇒
223
+ ${(0, sdk_gov_1.formatBN)((this.amount *
249
224
  BigInt(Math.floor(this.leverage * Number(sdk_gov_1.LEVERAGE_DECIMALS)))) /
250
225
  sdk_gov_1.LEVERAGE_DECIMALS, tokenDecimals || 18)} ${tokenSymbol}`;
251
226
  }
@@ -263,12 +238,7 @@ class TxOpenMultitokenAccount extends eventOrTx_1.EVMTx {
263
238
  underlyingToken;
264
239
  assets;
265
240
  constructor(opts) {
266
- super({
267
- block: opts.block,
268
- txHash: opts.txHash,
269
- txStatus: opts.txStatus,
270
- timestamp: opts.timestamp,
271
- });
241
+ super(opts);
272
242
  this.borrowedAmount = opts.borrowedAmount;
273
243
  this.underlyingToken = opts.underlyingToken;
274
244
  this.creditManager = opts.creditManager;
@@ -282,7 +252,7 @@ class TxOpenMultitokenAccount extends eventOrTx_1.EVMTx {
282
252
  return acc;
283
253
  }, []);
284
254
  const [symbol, underlyingDecimals] = (0, sdk_gov_1.extractTokenData)(this.underlyingToken);
285
- return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: opening. Borrowed amount: ${(0, formatter_1.formatBN)(this.borrowedAmount, underlyingDecimals || 18)} ${symbol}; assets: ${assetSymbols.join(", ")}`;
255
+ return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: opening. Borrowed amount: ${(0, sdk_gov_1.formatBN)(this.borrowedAmount, underlyingDecimals || 18)} ${symbol}; assets: ${assetSymbols.join(", ")}`;
286
256
  }
287
257
  serialize() {
288
258
  return {
@@ -295,12 +265,7 @@ exports.TxOpenMultitokenAccount = TxOpenMultitokenAccount;
295
265
  class TxClaimReward extends eventOrTx_1.EVMTx {
296
266
  contracts;
297
267
  constructor(opts) {
298
- super({
299
- block: opts.block,
300
- txHash: opts.txHash,
301
- txStatus: opts.txStatus,
302
- timestamp: opts.timestamp,
303
- });
268
+ super(opts);
304
269
  this.contracts = opts.contracts;
305
270
  }
306
271
  toString() {
@@ -319,14 +284,6 @@ class TxClaimReward extends eventOrTx_1.EVMTx {
319
284
  }
320
285
  exports.TxClaimReward = TxClaimReward;
321
286
  class TxClaimNFT extends eventOrTx_1.EVMTx {
322
- constructor(opts) {
323
- super({
324
- block: opts.block,
325
- txHash: opts.txHash,
326
- txStatus: opts.txStatus,
327
- timestamp: opts.timestamp,
328
- });
329
- }
330
287
  toString() {
331
288
  return `NFT claimed`;
332
289
  }
@@ -342,18 +299,13 @@ class TxClaimGearRewards extends eventOrTx_1.EVMTx {
342
299
  token;
343
300
  amount;
344
301
  constructor(opts) {
345
- super({
346
- block: opts.block,
347
- txHash: opts.txHash,
348
- txStatus: opts.txStatus,
349
- timestamp: opts.timestamp,
350
- });
302
+ super(opts);
351
303
  this.amount = opts.amount;
352
304
  this.token = opts.token;
353
305
  }
354
306
  toString() {
355
307
  const [symbol, decimals] = (0, sdk_gov_1.extractTokenData)(this.token);
356
- return `GEAR Rewards claimed: ${(0, formatter_1.formatBN)(this.amount, decimals || 18)} ${symbol} `;
308
+ return `GEAR Rewards claimed: ${(0, sdk_gov_1.formatBN)(this.amount, decimals || 18)} ${symbol} `;
357
309
  }
358
310
  serialize() {
359
311
  return {
@@ -366,12 +318,7 @@ exports.TxClaimGearRewards = TxClaimGearRewards;
366
318
  class TxRepayAccount extends eventOrTx_1.EVMTx {
367
319
  creditManager;
368
320
  constructor(opts) {
369
- super({
370
- block: opts.block,
371
- txHash: opts.txHash,
372
- txStatus: opts.txStatus,
373
- timestamp: opts.timestamp,
374
- });
321
+ super(opts);
375
322
  this.creditManager = opts.creditManager;
376
323
  }
377
324
  toString() {
@@ -388,12 +335,7 @@ exports.TxRepayAccount = TxRepayAccount;
388
335
  class TxCloseAccount extends eventOrTx_1.EVMTx {
389
336
  creditManager;
390
337
  constructor(opts) {
391
- super({
392
- block: opts.block,
393
- txHash: opts.txHash,
394
- txStatus: opts.txStatus,
395
- timestamp: opts.timestamp,
396
- });
338
+ super(opts);
397
339
  this.creditManager = opts.creditManager;
398
340
  }
399
341
  toString() {
@@ -410,12 +352,7 @@ exports.TxCloseAccount = TxCloseAccount;
410
352
  class TxApprove extends eventOrTx_1.EVMTx {
411
353
  token;
412
354
  constructor(opts) {
413
- super({
414
- block: opts.block,
415
- txHash: opts.txHash,
416
- txStatus: opts.txStatus,
417
- timestamp: opts.timestamp,
418
- });
355
+ super(opts);
419
356
  this.token = opts.token;
420
357
  }
421
358
  toString() {
@@ -435,12 +372,7 @@ class TxEnableTokens extends eventOrTx_1.EVMTx {
435
372
  disabledTokens;
436
373
  creditManager;
437
374
  constructor(opts) {
438
- super({
439
- block: opts.block,
440
- txHash: opts.txHash,
441
- txStatus: opts.txStatus,
442
- timestamp: opts.timestamp,
443
- });
375
+ super(opts);
444
376
  this.enabledTokens = opts.enabledTokens;
445
377
  this.disabledTokens = opts.disabledTokens;
446
378
  this.creditManager = opts.creditManager;
@@ -470,3 +402,102 @@ class TxEnableTokens extends eventOrTx_1.EVMTx {
470
402
  }
471
403
  }
472
404
  exports.TxEnableTokens = TxEnableTokens;
405
+ class TxUpdateQuota extends eventOrTx_1.EVMTx {
406
+ updatedQuotas;
407
+ underlyingToken;
408
+ creditManager;
409
+ constructor(opts) {
410
+ super(opts);
411
+ this.updatedQuotas = opts.updatedQuotas;
412
+ this.creditManager = opts.creditManager;
413
+ this.underlyingToken = opts.underlyingToken;
414
+ }
415
+ toString() {
416
+ const [, underlyingDecimals] = (0, sdk_gov_1.extractTokenData)(this.underlyingToken);
417
+ const quota = this.updatedQuotas.map(({ token, balance }) => {
418
+ const [tokenSymbol] = (0, sdk_gov_1.extractTokenData)(token);
419
+ const sign = balance < 0 ? "-" : "";
420
+ const amountString = (0, sdk_gov_1.formatBN)(math_1.BigIntMath.abs(balance), underlyingDecimals || 18);
421
+ return `${tokenSymbol} by ${sign}${amountString}`;
422
+ });
423
+ return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)} quota updated: ${quota.join("; ")}`;
424
+ }
425
+ serialize() {
426
+ return {
427
+ type: "TxUpdateQuota",
428
+ content: JSON.stringify(this),
429
+ };
430
+ }
431
+ }
432
+ exports.TxUpdateQuota = TxUpdateQuota;
433
+ class TxGaugeStake extends eventOrTx_1.EVMTx {
434
+ amount;
435
+ constructor(opts) {
436
+ super(opts);
437
+ this.amount = opts.amount;
438
+ }
439
+ toString() {
440
+ const tokenDecimals = sdk_gov_1.decimals.GEAR;
441
+ const amountString = (0, sdk_gov_1.formatBN)(math_1.BigIntMath.abs(this.amount), tokenDecimals);
442
+ return `Gauge: staked ${amountString} GEAR`;
443
+ }
444
+ serialize() {
445
+ return {
446
+ type: "TxGaugeStake",
447
+ content: JSON.stringify(this),
448
+ };
449
+ }
450
+ }
451
+ exports.TxGaugeStake = TxGaugeStake;
452
+ class TxGaugeUnstake extends eventOrTx_1.EVMTx {
453
+ amount;
454
+ constructor(opts) {
455
+ super(opts);
456
+ this.amount = opts.amount;
457
+ }
458
+ toString() {
459
+ const tokenDecimals = sdk_gov_1.decimals.GEAR;
460
+ const amountString = (0, sdk_gov_1.formatBN)(math_1.BigIntMath.abs(this.amount), tokenDecimals);
461
+ return `Gauge: unstaked ${amountString} GEAR`;
462
+ }
463
+ serialize() {
464
+ return {
465
+ type: "TxGaugeUnstake",
466
+ content: JSON.stringify(this),
467
+ };
468
+ }
469
+ }
470
+ exports.TxGaugeUnstake = TxGaugeUnstake;
471
+ class TxGaugeClaim extends eventOrTx_1.EVMTx {
472
+ toString() {
473
+ return `Gauge: withdrawals claimed`;
474
+ }
475
+ serialize() {
476
+ return {
477
+ type: "TxGaugeClaim",
478
+ content: JSON.stringify(this),
479
+ };
480
+ }
481
+ }
482
+ exports.TxGaugeClaim = TxGaugeClaim;
483
+ class TxGaugeVote extends eventOrTx_1.EVMTx {
484
+ tokens;
485
+ constructor(opts) {
486
+ super(opts);
487
+ this.tokens = opts.tokens;
488
+ }
489
+ toString() {
490
+ const votes = this.tokens.map(({ token }) => {
491
+ const [tokenSymbol] = (0, sdk_gov_1.extractTokenData)(token);
492
+ return tokenSymbol;
493
+ });
494
+ return `Gauge: voted for ${votes.join(", ")}`;
495
+ }
496
+ serialize() {
497
+ return {
498
+ type: "TxGaugeVote",
499
+ content: JSON.stringify(this),
500
+ };
501
+ }
502
+ }
503
+ exports.TxGaugeVote = TxGaugeVote;
package/lib/index.d.ts CHANGED
@@ -7,6 +7,8 @@ export * from "./core/creditSession";
7
7
  export * from "./core/errors";
8
8
  export * from "./core/eventOrTx";
9
9
  export * from "./core/events";
10
+ export * from "./core/gauge";
11
+ export * from "./core/gaugeMath";
10
12
  export * from "./core/pool";
11
13
  export * from "./core/rewardClaimer";
12
14
  export * from "./core/strategy";
@@ -19,6 +21,7 @@ export * from "./pathfinder/pathfinder";
19
21
  export * from "./payload/creditAccount";
20
22
  export * from "./payload/creditManager";
21
23
  export * from "./payload/creditSession";
24
+ export * from "./payload/gauge";
22
25
  export * from "./payload/graphPayload";
23
26
  export * from "./payload/pool";
24
27
  export * from "./payload/token";
package/lib/index.js CHANGED
@@ -24,6 +24,8 @@ __exportStar(require("./core/creditSession"), exports);
24
24
  __exportStar(require("./core/errors"), exports);
25
25
  __exportStar(require("./core/eventOrTx"), exports);
26
26
  __exportStar(require("./core/events"), exports);
27
+ __exportStar(require("./core/gauge"), exports);
28
+ __exportStar(require("./core/gaugeMath"), exports);
27
29
  __exportStar(require("./core/pool"), exports);
28
30
  __exportStar(require("./core/rewardClaimer"), exports);
29
31
  __exportStar(require("./core/strategy"), exports);
@@ -36,6 +38,7 @@ __exportStar(require("./pathfinder/pathfinder"), exports);
36
38
  __exportStar(require("./payload/creditAccount"), exports);
37
39
  __exportStar(require("./payload/creditManager"), exports);
38
40
  __exportStar(require("./payload/creditSession"), exports);
41
+ __exportStar(require("./payload/gauge"), exports);
39
42
  __exportStar(require("./payload/graphPayload"), exports);
40
43
  __exportStar(require("./payload/pool"), exports);
41
44
  __exportStar(require("./payload/token"), exports);
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AbstractParser = void 0;
4
4
  const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
5
5
  const ethers_1 = require("ethers");
6
- const formatter_1 = require("../utils/formatter");
7
6
  class AbstractParser {
8
7
  contract;
9
8
  ifc;
@@ -30,7 +29,7 @@ class AbstractParser {
30
29
  return symbol;
31
30
  }
32
31
  formatBN(amount, token) {
33
- return `${(0, formatter_1.formatBN)(amount, sdk_gov_1.decimals[token])} [${(0, sdk_gov_1.toBigInt)(amount).toString()}]`;
32
+ return `${(0, sdk_gov_1.formatBN)(amount, sdk_gov_1.decimals[token])} [${(0, sdk_gov_1.toBigInt)(amount).toString()}]`;
34
33
  }
35
34
  parseToObject(address, calldata) {
36
35
  const { functionFragment } = this.parseSelector(calldata);
@@ -3,7 +3,8 @@ import { BigNumberish } from "ethers";
3
3
  import { AbstractParser } from "./abstractParser";
4
4
  import { IParser } from "./iParser";
5
5
  export declare class CreditFacadeParser extends AbstractParser implements IParser {
6
- constructor(token: SupportedToken);
6
+ version: number;
7
+ constructor(token: SupportedToken, version: number);
7
8
  parse(calldata: string): string;
8
9
  formatAmount(amount: BigNumberish): string;
9
10
  }