@gearbox-protocol/sdk 1.22.3 → 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.
- package/lib/apy/convexAPY.d.ts +10 -10
- package/lib/apy/convexAPY.js +100 -121
- package/lib/apy/curveAPY.d.ts +3 -4
- package/lib/apy/curveAPY.js +57 -111
- package/lib/apy/index.js +4 -6
- package/lib/apy/lidoAPY.d.ts +1 -2
- package/lib/apy/lidoAPY.js +14 -62
- package/lib/apy/yearnAPY.d.ts +2 -3
- package/lib/apy/yearnAPY.js +26 -82
- package/lib/contracts/contracts.js +9 -22
- package/lib/contracts/contractsRegister.js +39 -51
- package/lib/contracts/protocols.js +10 -11
- package/lib/core/adapter.js +9 -4
- package/lib/core/assets.d.ts +6 -7
- package/lib/core/assets.js +60 -70
- package/lib/core/chains.js +30 -80
- package/lib/core/constants.d.ts +9 -10
- package/lib/core/constants.js +9 -12
- package/lib/core/creditAccount.d.ts +20 -20
- package/lib/core/creditAccount.js +123 -134
- package/lib/core/creditAccount.spec.js +50 -52
- package/lib/core/creditManager.d.ts +26 -26
- package/lib/core/creditManager.js +172 -136
- package/lib/core/creditManager.spec.js +59 -61
- package/lib/core/creditSession.d.ts +12 -13
- package/lib/core/creditSession.js +120 -77
- package/lib/core/errors.d.ts +2 -3
- package/lib/core/errors.js +11 -27
- package/lib/core/eventOrTx.js +35 -73
- package/lib/core/events.d.ts +31 -24
- package/lib/core/events.js +702 -702
- package/lib/core/operations.js +11 -5
- package/lib/core/pool/data.d.ts +29 -29
- package/lib/core/pool/data.js +153 -112
- package/lib/core/pool/operation.d.ts +1 -2
- package/lib/core/pool/operation.js +23 -35
- package/lib/core/priceOracle.d.ts +6 -6
- package/lib/core/priceOracle.js +23 -29
- package/lib/core/rewardClaimer.d.ts +2 -2
- package/lib/core/rewardClaimer.js +5 -48
- package/lib/core/rewardConvex.js +54 -114
- package/lib/core/rewardConvex.spec.js +41 -43
- package/lib/core/strategy.d.ts +5 -6
- package/lib/core/strategy.js +67 -69
- package/lib/core/strategy.spec.js +32 -34
- package/lib/core/tokenDistributor.d.ts +1 -2
- package/lib/core/trade.d.ts +6 -6
- package/lib/core/trade.js +70 -115
- package/lib/core/transactions.d.ts +21 -22
- package/lib/core/transactions.js +285 -308
- package/lib/index.d.ts +0 -2
- package/lib/index.js +0 -2
- package/lib/oracles/oracles.d.ts +1 -2
- package/lib/oracles/priceFeeds.js +2 -3
- package/lib/parsers/ERC20Parser.js +20 -38
- package/lib/parsers/abstractParser.js +33 -31
- package/lib/parsers/addressProviderParser.js +12 -30
- package/lib/parsers/airdropDistributorParser.js +12 -30
- package/lib/parsers/convexBaseRewardPoolAdapterParser.js +24 -42
- package/lib/parsers/convexBaseRewardPoolAdapterParser.spec.js +11 -11
- package/lib/parsers/convexBoosterAdapterParser.js +26 -44
- package/lib/parsers/convexBoosterAdapterParser.spec.js +10 -10
- package/lib/parsers/convextRewardPoolParser.js +12 -30
- package/lib/parsers/creditFacadeParser.js +26 -45
- package/lib/parsers/creditFacadeParser.spec.js +13 -13
- package/lib/parsers/creditManagerParser.js +12 -30
- package/lib/parsers/curveAdapterParser.js +60 -78
- package/lib/parsers/curveAdapterParser.spec.js +20 -27
- package/lib/parsers/dataCompressorParser.js +12 -30
- package/lib/parsers/lidoAdapterParser.js +15 -33
- package/lib/parsers/lidoAdapterParser.spec.js +9 -9
- package/lib/parsers/lidoOracleParser.js +12 -30
- package/lib/parsers/lidoSTETHParser.js +19 -37
- package/lib/parsers/multicallParser.js +16 -34
- package/lib/parsers/offchainOracleParser.js +13 -31
- package/lib/parsers/poolParser.js +11 -29
- package/lib/parsers/priceOracleParser.js +13 -31
- package/lib/parsers/txParser.js +86 -96
- package/lib/parsers/uniV2AdapterParser.js +35 -55
- package/lib/parsers/uniV2AdapterParser.spec.js +15 -16
- package/lib/parsers/uniV3AdapterParser.js +56 -74
- package/lib/parsers/uniV3AdapterParser.spec.js +23 -24
- package/lib/parsers/wstETHAdapterParser.js +25 -43
- package/lib/parsers/wstETHAdapterParser.spec.js +11 -11
- package/lib/parsers/yearnAdapterParser.spec.js +17 -17
- package/lib/parsers/yearnV2AdapterParser.js +25 -43
- package/lib/pathfinder/core.d.ts +3 -4
- package/lib/pathfinder/pathOptions.js +52 -101
- package/lib/pathfinder/pathOptions.spec.js +55 -57
- package/lib/pathfinder/pathfinder.d.ts +3 -3
- package/lib/pathfinder/pathfinder.js +109 -202
- package/lib/pathfinder/pathfinder.spec.js +13 -13
- package/lib/strategies/convex.js +111 -123
- package/lib/strategies/creditFacade.js +34 -37
- package/lib/strategies/curve.js +74 -80
- package/lib/strategies/lido.js +26 -32
- package/lib/strategies/uniswapV2.js +21 -24
- package/lib/strategies/uniswapV3.js +33 -36
- package/lib/strategies/yearn.js +47 -59
- package/lib/tokens/balancer.js +3 -5
- package/lib/tokens/convex.js +14 -29
- package/lib/tokens/curveLP.js +22 -28
- package/lib/tokens/gear.js +1 -1
- package/lib/tokens/normal.js +3 -5
- package/lib/tokens/token.js +29 -35
- package/lib/tokens/tokenData.d.ts +0 -9
- package/lib/tokens/tokenData.js +17 -15
- package/lib/tokens/yearn.js +3 -5
- package/lib/types/factories/@chainlink/contracts/src/v0.8/interfaces/AggregatorInterface__factory.js +9 -12
- package/lib/types/factories/@chainlink/contracts/src/v0.8/interfaces/AggregatorV2V3Interface__factory.js +9 -12
- package/lib/types/factories/@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IACL.sol/IACLEvents__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IACL.sol/IACLExceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IACL.sol/IACL__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IAccountFactory.sol/IAccountFactoryEvents__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IAccountFactory.sol/IAccountFactoryGetters__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IAccountFactory.sol/IAccountFactory__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IAddressProvider.sol/IAddressProviderEvents__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IAddressProvider.sol/IAddressProvider__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IAirdropDistributor.sol/IAirdropDistributorEvents__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IAirdropDistributor.sol/IAirdropDistributor__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IContractsRegister.sol/IContractsRegisterEvents__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IContractsRegister.sol/IContractsRegister__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditAccount.sol/ICrediAccountExceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditAccount.sol/ICreditAccount__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditConfigurator.sol/ICreditConfiguratorEvents__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditConfigurator.sol/ICreditConfiguratorExceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditConfigurator.sol/ICreditConfigurator__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditFacade.sol/ICreditFacadeEvents__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditFacade.sol/ICreditFacadeExceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditFacade.sol/ICreditFacadeExtended__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditFacade.sol/ICreditFacade__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditManagerV2.sol/ICreditManagerV2Events__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditManagerV2.sol/ICreditManagerV2Exceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditManagerV2.sol/ICreditManagerV2__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDataCompressor.sol/IDataCompressorExceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDataCompressor.sol/IDataCompressor__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDegenDistributor.sol/IDegenDistributorEvents__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDegenDistributor.sol/IDegenDistributor__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDegenNFT.sol/IDegenNFTEvents__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDegenNFT.sol/IDegenNFTExceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDegenNFT.sol/IDegenNFT__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDieselToken.sol/IDieselTokenExceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IDieselToken.sol/IDieselToken__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IInterestRateModel__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ILPPriceFeed.sol/ILPPriceFeedEvents__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ILPPriceFeed.sol/ILPPriceFeedExceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ILPPriceFeed.sol/ILPPriceFeed__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPhantomERC20__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPoolService.sol/IPoolServiceEvents__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPoolService.sol/IPoolService__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPriceFeedType__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPriceOracle.sol/IPriceOracleV2Events__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPriceOracle.sol/IPriceOracleV2Exceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPriceOracle.sol/IPriceOracleV2Ext__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IPriceOracle.sol/IPriceOracleV2__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IVersion__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/IWETHGateway__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/V1/ICreditFilter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/V1/ICreditManager__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/adapters/IAdapter.sol/IAdapterExceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/adapters/IAdapter.sol/IAdapter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/adapters/IUniversalAdapter.sol/IUniversalAdapterExceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/adapters/IUniversalAdapter.sol/IUniversalAdapter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/external/IWETH__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/pool/PoolService__factory.js +27 -50
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/test/interfaces/ITokenTestSuite__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IBaseRewardPool__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IBooster__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IClaimZap__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IConvexToken__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IRewards.sol/IBasicRewards__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IRewards.sol/IRewards__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/ICrvDeposit__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/ICurveGauge__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/ICurveVoteEscrow__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IDeposit__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IFeeDistro__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IMinter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IPools__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IRegistry__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IRewardFactory__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IRewards__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IStaker__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IStashFactory__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IStash__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/ITokenFactory__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/ITokenMinter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IVestedEscrow__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IVoting__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/convex/Interfaces.sol/IWalletChecker__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/curve/ICurvePoolStETH__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/curve/ICurvePool_2.sol/ICurvePool2Assets__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/curve/ICurvePool_3.sol/ICurvePool3Assets__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/curve/ICurvePool_4.sol/ICurvePool4Assets__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/curve/ICurvePool__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/curve/ICurveRegistry__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/lido/ILidoOracle__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/lido/IstETH.sol/IstETHGetters__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/lido/IstETH.sol/IstETH__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/lido/IwstETH.sol/IwstETHGetters__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/lido/IwstETH.sol/IwstETH__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/lido/IwstETHGateway.sol/IwstETHGateWay__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/uniswap/IQuoter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/uniswap/IUniswapV2Router01__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/uniswap/IUniswapV2Router02__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/uniswap/IUniswapV3.sol/ISwapRouter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/integrations/yearn/IYVault__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/convex/IConvexV1BaseRewardPoolAdapter.sol/IConvexV1BaseRewardPoolAdapterErrors__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/convex/IConvexV1BaseRewardPoolAdapter.sol/IConvexV1BaseRewardPoolAdapter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/convex/IConvexV1BoosterAdapter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/curve/ICurveV1Adapter.sol/ICurveV1AdapterExceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/curve/ICurveV1Adapter.sol/ICurveV1Adapter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/curve/ICurveV1_2AssetsAdapter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/curve/ICurveV1_3AssetsAdapter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/curve/ICurveV1_4AssetsAdapter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/lido/ILidoV1Adapter.sol/ILidoV1AdapterEvents__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/lido/ILidoV1Adapter.sol/ILidoV1AdapterExceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/lido/ILidoV1Adapter.sol/ILidoV1Adapter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/lido/IwstETHV1Adapter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/uniswap/IUniswapPathChecker__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/uniswap/IUniswapV2Adapter.sol/IUniswapV2AdapterExceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/uniswap/IUniswapV2Adapter.sol/IUniswapV2Adapter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/uniswap/IUniswapV3Adapter.sol/IUniswapV3AdapterExceptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/uniswap/IUniswapV3Adapter.sol/IUniswapV3Adapter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/interfaces/yearn/IYearnV2Adapter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/test/config/SupportedContracts.sol/ISupportedContracts__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/integrations-v2/contracts/test/mocks/integrations/LidoMock.sol/ILidoMockEvents__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IClosePathResolver__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IDepositor.sol/IDepositorOptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IDepositor.sol/IDepositor__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IGasPricer__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/ILPWorker.sol/ILPWorkerOptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/ILPWorker.sol/ILPWorker__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IPathResolver__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IRouterComponent__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IRouter__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/ISwapAggregator__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/ISwapper__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IWithdrawer.sol/IWithdrawerOptions__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IWithdrawer.sol/IWithdrawer__factory.js +9 -12
- package/lib/types/factories/@gearbox-protocol/router/contracts/interfaces/IWrapper__factory.js +9 -12
- package/lib/types/factories/@openzeppelin/contracts/token/ERC20/IERC20__factory.js +9 -12
- package/lib/types/factories/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata__factory.js +9 -12
- package/lib/types/factories/@openzeppelin/contracts/token/ERC721/IERC721Receiver__factory.js +9 -12
- package/lib/types/factories/@openzeppelin/contracts/token/ERC721/IERC721__factory.js +9 -12
- package/lib/types/factories/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata__factory.js +9 -12
- package/lib/types/factories/@openzeppelin/contracts/utils/introspection/IERC165__factory.js +9 -12
- package/lib/types/factories/contracts/IGas__factory.js +9 -12
- package/lib/types/factories/contracts/IGnosisSafeSignatureValidator__factory.js +9 -12
- package/lib/types/factories/contracts/ITokenDistributor.sol/ITokenDistributorEvents__factory.js +9 -12
- package/lib/types/factories/contracts/ITokenDistributor.sol/ITokenDistributorExceptions__factory.js +9 -12
- package/lib/types/factories/contracts/ITokenDistributor.sol/ITokenDistributor__factory.js +9 -12
- package/lib/types/factories/contracts/support/IOffchainOracle__factory.js +9 -12
- package/lib/types/factories/contracts/support/MultiCall.sol/Multicall2__factory.js +27 -50
- package/lib/utils/errors.js +1 -1
- package/lib/utils/extracter.js +4 -4
- package/lib/utils/formatter.d.ts +8 -8
- package/lib/utils/formatter.js +73 -87
- package/lib/utils/loading.js +3 -3
- package/lib/utils/mappers.js +7 -34
- package/lib/utils/math.d.ts +10 -7
- package/lib/utils/math.js +22 -25
- package/lib/utils/multicall.js +32 -98
- package/lib/utils/price.d.ts +3 -4
- package/lib/utils/price.js +8 -20
- package/lib/utils/repeater.js +12 -53
- package/lib/utils/validate.js +2 -2
- package/lib/watchers/creditAccountWatcher.js +136 -237
- package/lib/watchers/creditAccountWatcher.spec.js +51 -68
- package/lib/watchers/creditManagerWatcher.js +21 -71
- package/lib/watchers/creditManagerWatcher.spec.js +20 -23
- package/package.json +2 -2
- package/lib/core/history.d.ts +0 -42
- package/lib/core/history.js +0 -2
- package/lib/core/wcOperation/abstractOperations.d.ts +0 -23
- package/lib/core/wcOperation/abstractOperations.js +0 -39
- package/lib/core/wcOperation/index.d.ts +0 -11
- package/lib/core/wcOperation/index.js +0 -30
- package/lib/core/wcOperation/operations.d.ts +0 -88
- package/lib/core/wcOperation/operations.js +0 -146
- package/lib/core/wcOperation/types.d.ts +0 -15
- package/lib/core/wcOperation/types.js +0 -2
|
@@ -1,48 +1,14 @@
|
|
|
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.CreditAccountWatcher = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
4
|
+
const creditAccount_1 = require("../core/creditAccount");
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
const multicall_1 = require("../utils/multicall");
|
|
7
|
+
class CreditAccountWatcher {
|
|
8
|
+
static IERC20 = types_1.IERC20__factory.createInterface();
|
|
9
|
+
static creditManagerInterface = types_1.ICreditManagerV2__factory.createInterface();
|
|
10
|
+
static creditConfiguratorInterface = types_1.ICreditConfigurator__factory.createInterface();
|
|
11
|
+
static creditFacadeInterface = types_1.ICreditFacade__factory.createInterface();
|
|
46
12
|
/**
|
|
47
13
|
* Gets hashes of all opened credit accounts at toBlock (or "latest" by default)
|
|
48
14
|
* @param creditManager CreditManagerData of desired CreditManager to check
|
|
@@ -50,173 +16,113 @@ var CreditAccountWatcher = /** @class */ (function () {
|
|
|
50
16
|
* @param toBlock Optional. Set the last block you;d like to get opened accounts
|
|
51
17
|
* @returns Arrays of hashes for opened accounts
|
|
52
18
|
*/
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
eventsByDate = [];
|
|
63
|
-
addToEvents = function (e, address, operation) {
|
|
64
|
-
eventsByDate.push({
|
|
65
|
-
time: e.blockNumber * 100000 + e.logIndex,
|
|
66
|
-
address: address,
|
|
67
|
-
operation: operation,
|
|
68
|
-
});
|
|
69
|
-
};
|
|
70
|
-
accounts = new Set();
|
|
71
|
-
cm = types_1.ICreditManagerV2__factory.connect(creditManager.address, provider);
|
|
72
|
-
return [4 /*yield*/, cm.queryFilter(cm.filters.NewConfigurator(), undefined, toBlock)];
|
|
73
|
-
case 1:
|
|
74
|
-
ccAddrs = (_a.sent()).map(function (e) { return e.args.newConfigurator; });
|
|
75
|
-
return [4 /*yield*/, Promise.all(ccAddrs.map(function (ccAddr) { return __awaiter(_this, void 0, void 0, function () {
|
|
76
|
-
var cc, cfUpgradedEvents;
|
|
77
|
-
return __generator(this, function (_a) {
|
|
78
|
-
switch (_a.label) {
|
|
79
|
-
case 0:
|
|
80
|
-
cc = types_1.ICreditConfigurator__factory.connect(ccAddr, provider);
|
|
81
|
-
return [4 /*yield*/, cc.queryFilter(cc.filters.CreditFacadeUpgraded(), undefined, toBlock)];
|
|
82
|
-
case 1:
|
|
83
|
-
cfUpgradedEvents = _a.sent();
|
|
84
|
-
return [2 /*return*/, cfUpgradedEvents.map(function (e) { return e.args.newCreditFacade; })];
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}); }))];
|
|
88
|
-
case 2:
|
|
89
|
-
cfUpgraded = (_a.sent()).flat();
|
|
90
|
-
_loop_1 = function (creditFacade) {
|
|
91
|
-
var cf, topics, logs;
|
|
92
|
-
return __generator(this, function (_b) {
|
|
93
|
-
switch (_b.label) {
|
|
94
|
-
case 0:
|
|
95
|
-
cf = types_1.ICreditFacade__factory.connect(creditFacade, provider);
|
|
96
|
-
topics = {
|
|
97
|
-
OpenCreditAccount: cf.interface.getEventTopic("OpenCreditAccount"),
|
|
98
|
-
CloseCreditAccount: cf.interface.getEventTopic("CloseCreditAccount"),
|
|
99
|
-
LiquidateCreditAccount: cf.interface.getEventTopic("LiquidateCreditAccount"),
|
|
100
|
-
LiquidateExpiredCreditAccount: cf.interface.getEventTopic("LiquidateExpiredCreditAccount"),
|
|
101
|
-
TransferAccount: cf.interface.getEventTopic("TransferAccount"),
|
|
102
|
-
};
|
|
103
|
-
return [4 /*yield*/, cf.queryFilter({
|
|
104
|
-
address: cf.address,
|
|
105
|
-
topics: [Object.values(topics)],
|
|
106
|
-
}, undefined, toBlock)];
|
|
107
|
-
case 1:
|
|
108
|
-
logs = _b.sent();
|
|
109
|
-
logs.forEach(function (log) {
|
|
110
|
-
var e = cf.interface.parseLog(log);
|
|
111
|
-
switch (log.topics[0]) {
|
|
112
|
-
case topics.OpenCreditAccount:
|
|
113
|
-
addToEvents(log, e.args.onBehalfOf, "add");
|
|
114
|
-
break;
|
|
115
|
-
case topics.CloseCreditAccount:
|
|
116
|
-
case topics.LiquidateCreditAccount:
|
|
117
|
-
case topics.LiquidateExpiredCreditAccount:
|
|
118
|
-
addToEvents(log, e.args.borrower, "delete");
|
|
119
|
-
break;
|
|
120
|
-
case topics.TransferAccount:
|
|
121
|
-
addToEvents(log, e.args.oldOwner, "delete");
|
|
122
|
-
addToEvents(log, log.args.newOwner, "add");
|
|
123
|
-
break;
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
return [2 /*return*/];
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
};
|
|
130
|
-
_i = 0, cfUpgraded_1 = cfUpgraded;
|
|
131
|
-
_a.label = 3;
|
|
132
|
-
case 3:
|
|
133
|
-
if (!(_i < cfUpgraded_1.length)) return [3 /*break*/, 6];
|
|
134
|
-
creditFacade = cfUpgraded_1[_i];
|
|
135
|
-
return [5 /*yield**/, _loop_1(creditFacade)];
|
|
136
|
-
case 4:
|
|
137
|
-
_a.sent();
|
|
138
|
-
_a.label = 5;
|
|
139
|
-
case 5:
|
|
140
|
-
_i++;
|
|
141
|
-
return [3 /*break*/, 3];
|
|
142
|
-
case 6:
|
|
143
|
-
eventsByDate
|
|
144
|
-
.sort(function (a, b) {
|
|
145
|
-
return a.time > b.time ? 1 : -1;
|
|
146
|
-
})
|
|
147
|
-
.forEach(function (e) {
|
|
148
|
-
if (e.operation === "add") {
|
|
149
|
-
accounts.add(e.address);
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
accounts.delete(e.address);
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
return [2 /*return*/, Array.from(accounts.values()).map(function (borrower) {
|
|
156
|
-
return creditAccount_1.CreditAccountData.hash(creditManager.address, borrower);
|
|
157
|
-
})];
|
|
158
|
-
}
|
|
19
|
+
static async getOpenAccounts(creditManager, provider, toBlock) {
|
|
20
|
+
if (creditManager.version !== 2)
|
|
21
|
+
throw new Error("Works for V2 only");
|
|
22
|
+
const eventsByDate = [];
|
|
23
|
+
const addToEvents = (e, address, operation) => {
|
|
24
|
+
eventsByDate.push({
|
|
25
|
+
time: e.blockNumber * 100000 + e.logIndex,
|
|
26
|
+
address,
|
|
27
|
+
operation,
|
|
159
28
|
});
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
case
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
case
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
case 3:
|
|
200
|
-
_i++;
|
|
201
|
-
return [3 /*break*/, 1];
|
|
202
|
-
case 4: return [2 /*return*/, data.flat().map(function (c) { return new creditAccount_1.CreditAccountData(c); })];
|
|
29
|
+
};
|
|
30
|
+
const accounts = new Set();
|
|
31
|
+
const cm = types_1.ICreditManagerV2__factory.connect(creditManager.address, provider);
|
|
32
|
+
// get all historical creditConfigurators for this cm
|
|
33
|
+
const ccAddrs = (await cm.queryFilter(cm.filters.NewConfigurator(), undefined, toBlock)).map(e => e.args.newConfigurator);
|
|
34
|
+
// get all historical creditFacades for this cm
|
|
35
|
+
const cfUpgraded = (await Promise.all(ccAddrs.map(async (ccAddr) => {
|
|
36
|
+
const cc = types_1.ICreditConfigurator__factory.connect(ccAddr, provider);
|
|
37
|
+
const cfUpgradedEvents = await cc.queryFilter(cc.filters.CreditFacadeUpgraded(), undefined, toBlock);
|
|
38
|
+
return cfUpgradedEvents.map(e => e.args.newCreditFacade);
|
|
39
|
+
}))).flat();
|
|
40
|
+
for (const creditFacade of cfUpgraded) {
|
|
41
|
+
const cf = types_1.ICreditFacade__factory.connect(creditFacade, provider);
|
|
42
|
+
const topics = {
|
|
43
|
+
OpenCreditAccount: cf.interface.getEventTopic("OpenCreditAccount"),
|
|
44
|
+
CloseCreditAccount: cf.interface.getEventTopic("CloseCreditAccount"),
|
|
45
|
+
LiquidateCreditAccount: cf.interface.getEventTopic("LiquidateCreditAccount"),
|
|
46
|
+
LiquidateExpiredCreditAccount: cf.interface.getEventTopic("LiquidateExpiredCreditAccount"),
|
|
47
|
+
TransferAccount: cf.interface.getEventTopic("TransferAccount"),
|
|
48
|
+
};
|
|
49
|
+
const logs = await cf.queryFilter({
|
|
50
|
+
address: cf.address,
|
|
51
|
+
topics: [Object.values(topics)],
|
|
52
|
+
}, undefined, toBlock);
|
|
53
|
+
logs.forEach(log => {
|
|
54
|
+
const e = cf.interface.parseLog(log);
|
|
55
|
+
switch (log.topics[0]) {
|
|
56
|
+
case topics.OpenCreditAccount:
|
|
57
|
+
addToEvents(log, e.args.onBehalfOf, "add");
|
|
58
|
+
break;
|
|
59
|
+
case topics.CloseCreditAccount:
|
|
60
|
+
case topics.LiquidateCreditAccount:
|
|
61
|
+
case topics.LiquidateExpiredCreditAccount:
|
|
62
|
+
addToEvents(log, e.args.borrower, "delete");
|
|
63
|
+
break;
|
|
64
|
+
case topics.TransferAccount:
|
|
65
|
+
addToEvents(log, e.args.oldOwner, "delete");
|
|
66
|
+
addToEvents(log, log.args.newOwner, "add");
|
|
67
|
+
break;
|
|
203
68
|
}
|
|
204
69
|
});
|
|
70
|
+
}
|
|
71
|
+
eventsByDate
|
|
72
|
+
.sort((a, b) => {
|
|
73
|
+
return a.time > b.time ? 1 : -1;
|
|
74
|
+
})
|
|
75
|
+
.forEach(e => {
|
|
76
|
+
if (e.operation === "add") {
|
|
77
|
+
accounts.add(e.address);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
accounts.delete(e.address);
|
|
81
|
+
}
|
|
205
82
|
});
|
|
206
|
-
|
|
83
|
+
return Array.from(accounts.values()).map(borrower => creditAccount_1.CreditAccountData.hash(creditManager.address, borrower));
|
|
84
|
+
}
|
|
85
|
+
static async batchCreditAccountLoad(accs, dataCompressor, signer, options) {
|
|
86
|
+
let chunkSize = 1000;
|
|
87
|
+
let atBlock;
|
|
88
|
+
if (typeof options === "object") {
|
|
89
|
+
atBlock = options.atBlock;
|
|
90
|
+
chunkSize = options.chunkSize ?? 1000;
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
atBlock = options;
|
|
94
|
+
}
|
|
95
|
+
const dcmc = new multicall_1.MultiCallContract(dataCompressor, types_1.IDataCompressor__factory.createInterface(), signer);
|
|
96
|
+
const calls = [];
|
|
97
|
+
for (let i = 0; i < accs.length; i++) {
|
|
98
|
+
const chunk = accs.slice(i * chunkSize, (i + 1) * chunkSize);
|
|
99
|
+
calls[i] = chunk.map(c => {
|
|
100
|
+
return {
|
|
101
|
+
method: "getCreditAccountData(address,address)",
|
|
102
|
+
params: c.split(":"),
|
|
103
|
+
};
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
const data = [];
|
|
107
|
+
for (let c of calls) {
|
|
108
|
+
const result = await dcmc.call(c, { blockTag: atBlock, gasLimit: 300e6 });
|
|
109
|
+
data.push(result);
|
|
110
|
+
}
|
|
111
|
+
return data.flat().map(c => new creditAccount_1.CreditAccountData(c));
|
|
112
|
+
}
|
|
207
113
|
/**
|
|
208
114
|
* Tracks block logs and detects whichj acccounts were changed (created / modified) and which were deleted
|
|
209
115
|
* @param logs Logs from last N blocks
|
|
210
116
|
* @param creditManagers Array of CreditManager data which account it should track
|
|
211
117
|
* @returns CreditManagerUpdate which contains updated (created / modified) and deleted accounts
|
|
212
118
|
*/
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
119
|
+
static detectChanges(logs, creditManagers) {
|
|
120
|
+
const cms = creditManagers.map(c => c.address.toLowerCase());
|
|
121
|
+
const cfToCm = {};
|
|
122
|
+
const ccToCm = {};
|
|
217
123
|
// maps credit manager addr to credit configurator addresses
|
|
218
|
-
|
|
219
|
-
creditManagers.forEach(
|
|
124
|
+
const trackers = {};
|
|
125
|
+
creditManagers.forEach(cm => {
|
|
220
126
|
trackers[cm.address.toLowerCase()] = {
|
|
221
127
|
updated: new Set(),
|
|
222
128
|
deleted: new Set(),
|
|
@@ -224,40 +130,39 @@ var CreditAccountWatcher = /** @class */ (function () {
|
|
|
224
130
|
ccToCm[cm.creditConfigurator.toLowerCase()] = cm.address.toLowerCase();
|
|
225
131
|
cfToCm[cm.creditFacade.toLowerCase()] = cm.address.toLowerCase();
|
|
226
132
|
});
|
|
227
|
-
for (
|
|
228
|
-
|
|
229
|
-
var logAddr = log.address.toLowerCase();
|
|
133
|
+
for (let log of logs) {
|
|
134
|
+
const logAddr = log.address.toLowerCase();
|
|
230
135
|
if (cms.includes(logAddr)) {
|
|
231
|
-
|
|
136
|
+
const { name, args } = CreditAccountWatcher.creditManagerInterface.parseLog(log);
|
|
232
137
|
if (name === "ExecuteOrder") {
|
|
233
|
-
|
|
138
|
+
const { borrower } = args;
|
|
234
139
|
if (!borrower)
|
|
235
|
-
throw new Error(
|
|
140
|
+
throw new Error(`Cant parser event ${log}`);
|
|
236
141
|
/// Excludes credit facade which represents borrower in multicall
|
|
237
142
|
if (!(borrower.toLowerCase() in cfToCm)) {
|
|
238
143
|
trackers[logAddr].updated.add(borrower);
|
|
239
144
|
}
|
|
240
145
|
}
|
|
241
146
|
else if (name === "NewConfigurator") {
|
|
242
|
-
|
|
147
|
+
const newConfigurator = args.newConfigurator.toLowerCase();
|
|
243
148
|
ccToCm[newConfigurator] = logAddr;
|
|
244
149
|
}
|
|
245
150
|
}
|
|
246
151
|
else if (logAddr in ccToCm) {
|
|
247
|
-
|
|
152
|
+
const { name, args } = CreditAccountWatcher.creditConfiguratorInterface.parseLog(log);
|
|
248
153
|
if (name === "CreditFacadeUpgraded") {
|
|
249
|
-
|
|
154
|
+
const newCreditFacade = args.newCreditFacade.toLowerCase();
|
|
250
155
|
cfToCm[newCreditFacade] = ccToCm[logAddr];
|
|
251
156
|
}
|
|
252
157
|
}
|
|
253
158
|
else if (logAddr in cfToCm) {
|
|
254
|
-
|
|
159
|
+
const { name, args } = CreditAccountWatcher.creditFacadeInterface.parseLog(log);
|
|
255
160
|
switch (name) {
|
|
256
161
|
case "OpenCreditAccount":
|
|
257
162
|
case "AddCollateral": {
|
|
258
|
-
|
|
163
|
+
const { onBehalfOf } = args;
|
|
259
164
|
if (!onBehalfOf)
|
|
260
|
-
throw new Error(
|
|
165
|
+
throw new Error(`Cant parser event ${log}`);
|
|
261
166
|
trackers[cfToCm[logAddr]].updated.add(onBehalfOf);
|
|
262
167
|
break;
|
|
263
168
|
}
|
|
@@ -266,26 +171,26 @@ var CreditAccountWatcher = /** @class */ (function () {
|
|
|
266
171
|
case "TokenDisabled":
|
|
267
172
|
case "TokenEnabled":
|
|
268
173
|
case "MultiCallStarted": {
|
|
269
|
-
|
|
174
|
+
const { borrower } = args;
|
|
270
175
|
if (!borrower)
|
|
271
|
-
throw new Error(
|
|
176
|
+
throw new Error(`Cant parser event ${log}`);
|
|
272
177
|
trackers[cfToCm[logAddr]].updated.add(borrower);
|
|
273
178
|
break;
|
|
274
179
|
}
|
|
275
180
|
case "CloseCreditAccount":
|
|
276
181
|
case "LiquidateCreditAccount":
|
|
277
182
|
case "LiquidateExpiredCreditAccount": {
|
|
278
|
-
|
|
183
|
+
const { borrower } = args;
|
|
279
184
|
if (!borrower)
|
|
280
|
-
throw new Error(
|
|
185
|
+
throw new Error(`Cant parser event ${log}`);
|
|
281
186
|
trackers[cfToCm[logAddr]].updated.delete(borrower);
|
|
282
187
|
trackers[cfToCm[logAddr]].deleted.add(borrower);
|
|
283
188
|
break;
|
|
284
189
|
}
|
|
285
190
|
case "TransferAccount": {
|
|
286
|
-
|
|
191
|
+
const { oldOwner, newOwner } = args;
|
|
287
192
|
if (!oldOwner || !newOwner)
|
|
288
|
-
throw new Error(
|
|
193
|
+
throw new Error(`Cant parser event ${log}`);
|
|
289
194
|
trackers[cfToCm[logAddr]].updated.delete(oldOwner);
|
|
290
195
|
trackers[cfToCm[logAddr]].updated.add(newOwner);
|
|
291
196
|
trackers[cfToCm[logAddr]].deleted.add(oldOwner);
|
|
@@ -293,33 +198,32 @@ var CreditAccountWatcher = /** @class */ (function () {
|
|
|
293
198
|
}
|
|
294
199
|
}
|
|
295
200
|
}
|
|
296
|
-
|
|
201
|
+
const result = {
|
|
297
202
|
updated: [],
|
|
298
203
|
deleted: [],
|
|
299
204
|
};
|
|
300
|
-
cms.forEach(
|
|
301
|
-
trackers[cm].updated.forEach(
|
|
205
|
+
cms.forEach(cm => {
|
|
206
|
+
trackers[cm].updated.forEach(borrower => {
|
|
302
207
|
result.updated.push(creditAccount_1.CreditAccountData.hash(cm, borrower));
|
|
303
208
|
});
|
|
304
|
-
trackers[cm].deleted.forEach(
|
|
209
|
+
trackers[cm].deleted.forEach(borrower => {
|
|
305
210
|
result.deleted.push(creditAccount_1.CreditAccountData.hash(cm, borrower));
|
|
306
211
|
});
|
|
307
212
|
});
|
|
308
213
|
return result;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
accounts.forEach(
|
|
214
|
+
}
|
|
215
|
+
static trackDirectTransfers(freshLogs, tokensToTrack, accounts) {
|
|
216
|
+
const tkns = tokensToTrack.map(t => t.toLowerCase());
|
|
217
|
+
const accAddresses = [];
|
|
218
|
+
const accToCa = {};
|
|
219
|
+
const modified = new Set();
|
|
220
|
+
accounts.forEach(ca => {
|
|
316
221
|
accAddresses.push(ca.addr);
|
|
317
222
|
accToCa[ca.addr] = ca;
|
|
318
223
|
});
|
|
319
|
-
for (
|
|
320
|
-
var log = freshLogs_1[_i];
|
|
224
|
+
for (let log of freshLogs) {
|
|
321
225
|
if (tkns.includes(log.address.toLocaleLowerCase())) {
|
|
322
|
-
|
|
226
|
+
const { name, args } = CreditAccountWatcher.IERC20.parseLog(log);
|
|
323
227
|
if (name === "Transfer" &&
|
|
324
228
|
accAddresses.includes(args.to.toLowerCase())) {
|
|
325
229
|
modified.add(accToCa[args.to.toLowerCase()].hash());
|
|
@@ -327,11 +231,6 @@ var CreditAccountWatcher = /** @class */ (function () {
|
|
|
327
231
|
}
|
|
328
232
|
}
|
|
329
233
|
return Array.from(modified);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
CreditAccountWatcher.creditManagerInterface = types_1.ICreditManagerV2__factory.createInterface();
|
|
333
|
-
CreditAccountWatcher.creditConfiguratorInterface = types_1.ICreditConfigurator__factory.createInterface();
|
|
334
|
-
CreditAccountWatcher.creditFacadeInterface = types_1.ICreditFacade__factory.createInterface();
|
|
335
|
-
return CreditAccountWatcher;
|
|
336
|
-
}());
|
|
234
|
+
}
|
|
235
|
+
}
|
|
337
236
|
exports.CreditAccountWatcher = CreditAccountWatcher;
|