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