@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,39 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.ConvexRewardPoolParser = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
_this.ifc = types_1.IBaseRewardPool__factory.createInterface();
|
|
26
|
-
return _this;
|
|
4
|
+
const types_1 = require("../types");
|
|
5
|
+
const abstractParser_1 = require("./abstractParser");
|
|
6
|
+
class ConvexRewardPoolParser extends abstractParser_1.AbstractParser {
|
|
7
|
+
constructor(token) {
|
|
8
|
+
super(`ConvexRewardPool_${token}`);
|
|
9
|
+
this.ifc = types_1.IBaseRewardPool__factory.createInterface();
|
|
27
10
|
}
|
|
28
|
-
|
|
29
|
-
|
|
11
|
+
parse(calldata) {
|
|
12
|
+
const { functionFragment, functionName } = this.parseSelector(calldata);
|
|
30
13
|
switch (functionFragment.name) {
|
|
31
14
|
case "rewardRate":
|
|
32
|
-
return
|
|
15
|
+
return `${functionName}()`;
|
|
33
16
|
default:
|
|
34
|
-
return
|
|
17
|
+
return `${functionName}: Unknown operation ${functionFragment.name} with calldata ${calldata}`;
|
|
35
18
|
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
}(abstractParser_1.AbstractParser));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
39
21
|
exports.ConvexRewardPoolParser = ConvexRewardPoolParser;
|
|
@@ -1,66 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.CreditFacadeParser = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
_this.adapterName = "CreditFacade";
|
|
27
|
-
return _this;
|
|
4
|
+
const types_1 = require("../types");
|
|
5
|
+
const abstractParser_1 = require("./abstractParser");
|
|
6
|
+
class CreditFacadeParser extends abstractParser_1.AbstractParser {
|
|
7
|
+
constructor(token) {
|
|
8
|
+
super(token);
|
|
9
|
+
this.ifc = types_1.ICreditFacadeExtended__factory.createInterface();
|
|
10
|
+
this.adapterName = "CreditFacade";
|
|
28
11
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var _a = this.parseSelector(calldata), functionFragment = _a.functionFragment, functionName = _a.functionName;
|
|
12
|
+
parse(calldata) {
|
|
13
|
+
const { functionFragment, functionName } = this.parseSelector(calldata);
|
|
32
14
|
switch (functionFragment.name) {
|
|
33
15
|
case "addCollateral": {
|
|
34
|
-
|
|
35
|
-
return
|
|
16
|
+
const [onBehalf, token, amount] = this.decodeFunctionData(functionFragment, calldata);
|
|
17
|
+
return `${functionName}(onBehalf: ${onBehalf}, token: ${this.tokenSymbol(token)}, amount: ${this.formatAmount(amount)})`;
|
|
36
18
|
}
|
|
37
19
|
case "increaseDebt":
|
|
38
20
|
case "decreaseDebt": {
|
|
39
|
-
|
|
40
|
-
return
|
|
21
|
+
const [amount] = this.decodeFunctionData(functionFragment, calldata);
|
|
22
|
+
return `${functionName}(amount: ${this.formatAmount(amount)})`;
|
|
41
23
|
}
|
|
42
24
|
case "enableToken":
|
|
43
25
|
case "disableToken": {
|
|
44
|
-
|
|
45
|
-
return
|
|
26
|
+
const [address] = this.decodeFunctionData(functionFragment, calldata);
|
|
27
|
+
return `${functionName}(token: ${this.tokenSymbol(address)})`;
|
|
46
28
|
}
|
|
47
29
|
case "revertIfReceivedLessThan": {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
.map(
|
|
51
|
-
|
|
52
|
-
return
|
|
30
|
+
const [balances] = this.decodeFunctionData(functionFragment, calldata);
|
|
31
|
+
const balancesStr = balances
|
|
32
|
+
.map(b => {
|
|
33
|
+
const symbol = this.tokenSymbol(b.token);
|
|
34
|
+
return `${symbol}: ${this.formatBN(b.balance, symbol)}`;
|
|
53
35
|
})
|
|
54
36
|
.join(", ");
|
|
55
|
-
return
|
|
37
|
+
return `${functionName}(${balancesStr})`;
|
|
56
38
|
}
|
|
57
39
|
default:
|
|
58
|
-
return
|
|
40
|
+
return `${functionName}: Unknown operation ${functionFragment.name} with calldata ${calldata}`;
|
|
59
41
|
}
|
|
60
|
-
}
|
|
61
|
-
|
|
42
|
+
}
|
|
43
|
+
formatAmount(amount) {
|
|
62
44
|
return this.formatBN(amount, this.contract);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
}(abstractParser_1.AbstractParser));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
66
47
|
exports.CreditFacadeParser = CreditFacadeParser;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
describe("CreditFacadeParser test",
|
|
9
|
-
it("all functions works well",
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
const chai_1 = require("chai");
|
|
4
|
+
const constants_1 = require("../core/constants");
|
|
5
|
+
const token_1 = require("../tokens/token");
|
|
6
|
+
const types_1 = require("../types");
|
|
7
|
+
const creditFacadeParser_1 = require("./creditFacadeParser");
|
|
8
|
+
describe("CreditFacadeParser test", () => {
|
|
9
|
+
it("all functions works well", () => {
|
|
10
|
+
let parser = new creditFacadeParser_1.CreditFacadeParser("DAI");
|
|
11
|
+
const ifc = types_1.ICreditFacadeExtended__factory.createInterface();
|
|
12
|
+
let parsed = parser.parse(ifc.encodeFunctionData("addCollateral", [
|
|
13
13
|
constants_1.DUMB_ADDRESS,
|
|
14
14
|
token_1.tokenDataByNetwork.Mainnet.WBTC,
|
|
15
|
-
constants_1.WAD
|
|
15
|
+
(constants_1.WAD * 444n) / 10n,
|
|
16
16
|
]));
|
|
17
17
|
(0, chai_1.expect)(parsed).to.be.eq("CreditFacade[DAI].addCollateral(onBehalf: 0xC4375B7De8af5a38a93548eb8453a498222C4fF2, token: WBTC, amount: 44.40 [44400000000000000000])", "Incorrect parse addCollateral");
|
|
18
|
-
parsed = parser.parse(ifc.encodeFunctionData("increaseDebt", [constants_1.WAD
|
|
18
|
+
parsed = parser.parse(ifc.encodeFunctionData("increaseDebt", [(constants_1.WAD * 414n) / 10n]));
|
|
19
19
|
(0, chai_1.expect)(parsed).to.be.eq("CreditFacade[DAI].increaseDebt(amount: 41.40 [41400000000000000000])", "Incorrect parse increaseDebt");
|
|
20
|
-
parsed = parser.parse(ifc.encodeFunctionData("decreaseDebt", [constants_1.WAD
|
|
20
|
+
parsed = parser.parse(ifc.encodeFunctionData("decreaseDebt", [(constants_1.WAD * 334n) / 10n]));
|
|
21
21
|
(0, chai_1.expect)(parsed).to.be.eq("CreditFacade[DAI].decreaseDebt(amount: 33.40 [33400000000000000000])", "Incorrect parse decreaseDebt");
|
|
22
22
|
parsed = parser.parse(ifc.encodeFunctionData("enableToken", [token_1.tokenDataByNetwork.Mainnet.WETH]));
|
|
23
23
|
(0, chai_1.expect)(parsed).to.be.eq("CreditFacade[DAI].enableToken(token: WETH)", "Incorrect parse enableToken");
|
|
@@ -1,43 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.CreditManagerParser = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
_this.ifc =
|
|
4
|
+
const types_1 = require("../types");
|
|
5
|
+
const abstractParser_1 = require("./abstractParser");
|
|
6
|
+
class CreditManagerParser extends abstractParser_1.AbstractParser {
|
|
7
|
+
constructor(version) {
|
|
8
|
+
super(`CreditManager_V${version}`);
|
|
9
|
+
this.ifc =
|
|
26
10
|
version === 1
|
|
27
11
|
? types_1.ICreditManager__factory.createInterface()
|
|
28
12
|
: types_1.ICreditManagerV2__factory.createInterface();
|
|
29
|
-
return _this;
|
|
30
13
|
}
|
|
31
|
-
|
|
32
|
-
|
|
14
|
+
parse(calldata) {
|
|
15
|
+
const { functionFragment, functionName } = this.parseSelector(calldata);
|
|
33
16
|
switch (functionFragment.name) {
|
|
34
17
|
case "creditConfigurator": {
|
|
35
|
-
return
|
|
18
|
+
return `${functionName}()`;
|
|
36
19
|
}
|
|
37
20
|
default:
|
|
38
|
-
return
|
|
21
|
+
return `${functionName}: Unknown operation ${functionFragment.name} with calldata ${calldata}`;
|
|
39
22
|
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
}(abstractParser_1.AbstractParser));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
43
25
|
exports.CreditManagerParser = CreditManagerParser;
|
|
@@ -1,138 +1,120 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.CurveAdapterParser = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
4
|
+
const contracts_1 = require("../contracts/contracts");
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
const formatter_1 = require("../utils/formatter");
|
|
7
|
+
const abstractParser_1 = require("./abstractParser");
|
|
8
|
+
class CurveAdapterParser extends abstractParser_1.AbstractParser {
|
|
9
|
+
lpToken;
|
|
10
|
+
constructor(contract, isContract) {
|
|
11
|
+
super(contract);
|
|
12
|
+
let contractName = "";
|
|
13
|
+
const nCoins = contracts_1.contractParams[contract].tokens.length;
|
|
29
14
|
switch (nCoins) {
|
|
30
15
|
case 2:
|
|
31
|
-
|
|
32
|
-
contractName =
|
|
16
|
+
this.ifc = types_1.ICurveV1_2AssetsAdapter__factory.createInterface();
|
|
17
|
+
contractName = `Curve2AssetsAdapter`;
|
|
33
18
|
break;
|
|
34
19
|
case 3:
|
|
35
|
-
|
|
36
|
-
contractName =
|
|
20
|
+
this.ifc = types_1.ICurveV1_3AssetsAdapter__factory.createInterface();
|
|
21
|
+
contractName = `Curve3AssetsAdapter`;
|
|
37
22
|
break;
|
|
38
23
|
case 4:
|
|
39
|
-
|
|
40
|
-
contractName =
|
|
24
|
+
this.ifc = types_1.ICurveV1_4AssetsAdapter__factory.createInterface();
|
|
25
|
+
contractName = `Curve4AssetsAdapter`;
|
|
41
26
|
break;
|
|
42
27
|
default:
|
|
43
|
-
throw new Error(
|
|
28
|
+
throw new Error(`Unsupported curve contract ${contract}`);
|
|
44
29
|
}
|
|
45
|
-
|
|
30
|
+
this.lpToken = contracts_1.contractParams[contract].lpToken;
|
|
46
31
|
if (!isContract)
|
|
47
|
-
|
|
48
|
-
return _this;
|
|
32
|
+
this.adapterName = contractName;
|
|
49
33
|
}
|
|
50
|
-
|
|
51
|
-
|
|
34
|
+
parse(calldata) {
|
|
35
|
+
const { functionFragment, functionName } = this.parseSelector(calldata);
|
|
52
36
|
switch (functionFragment.name) {
|
|
53
37
|
case "exchange":
|
|
54
38
|
case "exchange_underlying": {
|
|
55
|
-
|
|
56
|
-
|
|
39
|
+
const [i, j, dx, min_dy] = this.decodeFunctionData(functionFragment, calldata);
|
|
40
|
+
const iSym = functionFragment.name === "exchange_underlying"
|
|
57
41
|
? this.getUnderlyingTokenByIndex(i)
|
|
58
42
|
: this.getTokenByIndex(i);
|
|
59
|
-
|
|
43
|
+
const jSym = functionFragment.name === "exchange_underlying"
|
|
60
44
|
? this.getUnderlyingTokenByIndex(j)
|
|
61
45
|
: this.getTokenByIndex(j);
|
|
62
|
-
return
|
|
46
|
+
return `${functionName}(i ,j: ${iSym} => ${jSym}, dx: ${this.formatBN(dx, iSym)}, min_dy: ${this.formatBN(min_dy, jSym)})`;
|
|
63
47
|
}
|
|
64
48
|
case "exchange_all":
|
|
65
49
|
case "exchange_all_underlying": {
|
|
66
|
-
|
|
67
|
-
|
|
50
|
+
const [i, j, rateMinRAY] = this.decodeFunctionData(functionFragment, calldata);
|
|
51
|
+
const iSym = functionFragment.name === "exchange_all_underlying"
|
|
68
52
|
? this.getUnderlyingTokenByIndex(i)
|
|
69
53
|
: this.getTokenByIndex(i);
|
|
70
|
-
|
|
54
|
+
const jSym = functionFragment.name === "exchange_all_underlying"
|
|
71
55
|
? this.getUnderlyingTokenByIndex(j)
|
|
72
56
|
: this.getTokenByIndex(j);
|
|
73
|
-
return
|
|
57
|
+
return `${functionName}(i: ${iSym}, j: ${jSym}, rateMinRAY: ${(0, formatter_1.formatBN)(rateMinRAY, 27)}`;
|
|
74
58
|
}
|
|
75
59
|
case "add_liquidity_one_coin": {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return
|
|
60
|
+
const [amount, i, minAmount] = this.decodeFunctionData(functionFragment, calldata);
|
|
61
|
+
const iSym = this.getTokenByIndex(i);
|
|
62
|
+
return `${functionName}(amount: ${this.formatBN(amount, iSym)}, i: ${iSym}, minAmount: ${this.formatBN(minAmount, this.lpToken)})`;
|
|
79
63
|
}
|
|
80
64
|
case "add_all_liquidity_one_coin":
|
|
81
65
|
case "remove_all_liquidity_one_coin": {
|
|
82
|
-
|
|
83
|
-
return
|
|
66
|
+
const [i, rateMinRAY] = this.decodeFunctionData(functionFragment, calldata);
|
|
67
|
+
return `${functionName}(i: ${this.getTokenByIndex(i)}, rateMinRAY: ${(0, formatter_1.formatBN)(rateMinRAY, 27)})`;
|
|
84
68
|
}
|
|
85
69
|
case "add_liquidity": {
|
|
86
|
-
|
|
87
|
-
return
|
|
70
|
+
const [amounts, minAmount] = this.decodeFunctionData(functionFragment, calldata);
|
|
71
|
+
return `${functionName}(amounts: [${this.convertAmounts(amounts)}], minAmount: ${this.formatBN(minAmount, this.lpToken)})`;
|
|
88
72
|
}
|
|
89
73
|
case "remove_liquidity": {
|
|
90
|
-
|
|
91
|
-
return
|
|
74
|
+
const [amount, min_amounts] = this.decodeFunctionData(functionFragment, calldata);
|
|
75
|
+
return `${functionName}(amount: ${this.formatBN(amount, this.lpToken)}, min_amounts: [${this.convertAmounts(min_amounts)}])`;
|
|
92
76
|
}
|
|
93
77
|
case "remove_liquidity_imbalance": {
|
|
94
|
-
|
|
95
|
-
return
|
|
78
|
+
const [amounts, maxBurnAmount] = this.decodeFunctionData(functionFragment, calldata);
|
|
79
|
+
return `${functionName}(amounts: [${this.convertAmounts(amounts)}], max_burn_amount: ${this.formatBN(maxBurnAmount, this.lpToken)})`;
|
|
96
80
|
}
|
|
97
81
|
case "totalSupply": {
|
|
98
|
-
return
|
|
82
|
+
return `${functionName}()`;
|
|
99
83
|
}
|
|
100
84
|
case "balances": {
|
|
101
|
-
|
|
102
|
-
return
|
|
85
|
+
const [i] = this.decodeFunctionData(functionFragment, calldata);
|
|
86
|
+
return `${functionName}(${this.getTokenByIndex(i)})`;
|
|
103
87
|
}
|
|
104
88
|
case "balanceOf": {
|
|
105
|
-
|
|
106
|
-
return
|
|
89
|
+
const [address] = this.decodeFunctionData(functionFragment, calldata);
|
|
90
|
+
return `${functionName}(${address})`;
|
|
107
91
|
}
|
|
108
92
|
case "get_virtual_price": {
|
|
109
|
-
return
|
|
93
|
+
return `${functionName}()`;
|
|
110
94
|
}
|
|
111
95
|
case "allowance": {
|
|
112
|
-
|
|
113
|
-
return
|
|
96
|
+
const [account, to] = this.decodeFunctionData(functionFragment, calldata);
|
|
97
|
+
return `${functionName}(account: ${account}, to: ${to})`;
|
|
114
98
|
}
|
|
115
99
|
default:
|
|
116
|
-
return
|
|
100
|
+
return `${functionName}: Unknown operation ${functionFragment.name} with calldata ${calldata}`;
|
|
117
101
|
}
|
|
118
|
-
}
|
|
119
|
-
|
|
102
|
+
}
|
|
103
|
+
getTokenByIndex(index) {
|
|
120
104
|
return contracts_1.contractParams[this.contract]
|
|
121
105
|
.tokens[index];
|
|
122
|
-
}
|
|
123
|
-
|
|
106
|
+
}
|
|
107
|
+
getUnderlyingTokenByIndex(index) {
|
|
124
108
|
return contracts_1.contractParams[this.contract]
|
|
125
109
|
.underlyings[index];
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
var _this = this;
|
|
110
|
+
}
|
|
111
|
+
convertAmounts(amounts) {
|
|
129
112
|
return amounts
|
|
130
|
-
.map(
|
|
131
|
-
|
|
132
|
-
return
|
|
113
|
+
.map((a, coin) => {
|
|
114
|
+
const sym = this.getTokenByIndex(coin);
|
|
115
|
+
return `${sym}: ${this.formatBN(a, sym)}`;
|
|
133
116
|
})
|
|
134
117
|
.join(", ");
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
}(abstractParser_1.AbstractParser));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
138
120
|
exports.CurveAdapterParser = CurveAdapterParser;
|
|
@@ -1,48 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
describe("CurveAdapterParser test",
|
|
8
|
-
it("stake / withdraw functions works well",
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
const chai_1 = require("chai");
|
|
4
|
+
const constants_1 = require("../core/constants");
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
const curveAdapterParser_1 = require("./curveAdapterParser");
|
|
7
|
+
describe("CurveAdapterParser test", () => {
|
|
8
|
+
it("stake / withdraw functions works well", () => {
|
|
9
|
+
let parser = new curveAdapterParser_1.CurveAdapterParser("CURVE_FRAX_POOL", false);
|
|
10
|
+
const ifc = types_1.ICurveV1_2AssetsAdapter__factory.createInterface();
|
|
11
|
+
let parsed = parser.parse(ifc.encodeFunctionData("exchange", [0, 1, constants_1.WAD * 3n, constants_1.WAD * 32n]));
|
|
12
12
|
(0, chai_1.expect)(parsed).to.be.eq("Curve2AssetsAdapter[CURVE_FRAX_POOL].exchange(i ,j: FRAX => 3Crv, dx: 3.00 [3000000000000000000], min_dy: 32.00 [32000000000000000000])", "Curve2AssetsAdapter: Incorrect parse exchange");
|
|
13
13
|
parsed = parser.parse(ifc.encodeFunctionData("exchange_underlying", [
|
|
14
14
|
0,
|
|
15
15
|
1,
|
|
16
|
-
constants_1.WAD
|
|
17
|
-
constants_1.WAD
|
|
16
|
+
constants_1.WAD * 3n,
|
|
17
|
+
constants_1.WAD * 32n,
|
|
18
18
|
]));
|
|
19
19
|
(0, chai_1.expect)(parsed).to.be.eq("Curve2AssetsAdapter[CURVE_FRAX_POOL].exchange_underlying(i ,j: FRAX => DAI, dx: 3.00 [3000000000000000000], min_dy: 32.00 [32000000000000000000])", "Curve2AssetsAdapter: Incorrect parse exchange_underlying");
|
|
20
|
-
parsed = parser.parse(ifc.encodeFunctionData("add_liquidity_one_coin", [
|
|
21
|
-
constants_1.WAD.mul(3),
|
|
22
|
-
0,
|
|
23
|
-
constants_1.WAD.mul(2),
|
|
24
|
-
]));
|
|
20
|
+
parsed = parser.parse(ifc.encodeFunctionData("add_liquidity_one_coin", [constants_1.WAD * 3n, 0, constants_1.WAD * 2n]));
|
|
25
21
|
(0, chai_1.expect)(parsed).to.be.eq("Curve2AssetsAdapter[CURVE_FRAX_POOL].add_liquidity_one_coin(amount: 3.00 [3000000000000000000], i: FRAX, minAmount: 2.00 [2000000000000000000])", "Curve2AssetsAdapter: Incorrect parse add_liquidity_one_coin");
|
|
26
|
-
parsed = parser.parse(ifc.encodeFunctionData("add_all_liquidity_one_coin", [0, constants_1.RAY
|
|
22
|
+
parsed = parser.parse(ifc.encodeFunctionData("add_all_liquidity_one_coin", [0, constants_1.RAY * 912n]));
|
|
27
23
|
(0, chai_1.expect)(parsed).to.be.eq("Curve2AssetsAdapter[CURVE_FRAX_POOL].add_all_liquidity_one_coin(i: FRAX, rateMinRAY: 912.00)", "Curve2AssetsAdapter: Incorrect parse add_all_liquidity_one_coin");
|
|
28
|
-
parsed = parser.parse(ifc.encodeFunctionData("remove_all_liquidity_one_coin", [
|
|
29
|
-
0,
|
|
30
|
-
constants_1.RAY.mul(721),
|
|
31
|
-
]));
|
|
24
|
+
parsed = parser.parse(ifc.encodeFunctionData("remove_all_liquidity_one_coin", [0, constants_1.RAY * 721n]));
|
|
32
25
|
(0, chai_1.expect)(parsed).to.be.eq("Curve2AssetsAdapter[CURVE_FRAX_POOL].remove_all_liquidity_one_coin(i: FRAX, rateMinRAY: 721.00)", "Curve2AssetsAdapter: Incorrect parse remove_all_liquidity_one_coin");
|
|
33
26
|
parsed = parser.parse(ifc.encodeFunctionData("add_liquidity", [
|
|
34
|
-
[constants_1.WAD
|
|
35
|
-
constants_1.WAD
|
|
27
|
+
[constants_1.WAD * 100n, constants_1.WAD * 100n],
|
|
28
|
+
constants_1.WAD * 80n,
|
|
36
29
|
]));
|
|
37
30
|
(0, chai_1.expect)(parsed).to.be.eq("Curve2AssetsAdapter[CURVE_FRAX_POOL].add_liquidity(amounts: [FRAX: 100.00 [100000000000000000000], 3Crv: 100.00 [100000000000000000000]], minAmount: 80.00 [80000000000000000000])", "Curve2AssetsAdapter: Incorrect parse add_liquidity");
|
|
38
31
|
parsed = parser.parse(ifc.encodeFunctionData("remove_liquidity", [
|
|
39
|
-
constants_1.WAD
|
|
40
|
-
[constants_1.WAD
|
|
32
|
+
constants_1.WAD * 120n,
|
|
33
|
+
[constants_1.WAD * 100n, constants_1.WAD * 100n],
|
|
41
34
|
]));
|
|
42
35
|
(0, chai_1.expect)(parsed).to.be.eq("Curve2AssetsAdapter[CURVE_FRAX_POOL].remove_liquidity(amount: 120.00 [120000000000000000000], min_amounts: [FRAX: 100.00 [100000000000000000000], 3Crv: 100.00 [100000000000000000000]])", "Curve2AssetsAdapter: Incorrect parse remove_liquidity");
|
|
43
36
|
parsed = parser.parse(ifc.encodeFunctionData("remove_liquidity_imbalance", [
|
|
44
|
-
[constants_1.WAD
|
|
45
|
-
constants_1.WAD
|
|
37
|
+
[constants_1.WAD * 100n, constants_1.WAD * 100n],
|
|
38
|
+
constants_1.WAD * 80n,
|
|
46
39
|
]));
|
|
47
40
|
(0, chai_1.expect)(parsed).to.be.eq("Curve2AssetsAdapter[CURVE_FRAX_POOL].remove_liquidity_imbalance(amounts: [FRAX: 100.00 [100000000000000000000], 3Crv: 100.00 [100000000000000000000]], max_burn_amount: 80.00 [80000000000000000000])", "Curve2AssetsAdapter: Incorrect parse remove_liquidity_imbalance");
|
|
48
41
|
});
|
|
@@ -1,41 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.DataCompressorParser = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
_this.ifc = types_1.IDataCompressor__factory.createInterface();
|
|
26
|
-
return _this;
|
|
4
|
+
const types_1 = require("../types");
|
|
5
|
+
const abstractParser_1 = require("./abstractParser");
|
|
6
|
+
class DataCompressorParser extends abstractParser_1.AbstractParser {
|
|
7
|
+
constructor() {
|
|
8
|
+
super("DataCompressor");
|
|
9
|
+
this.ifc = types_1.IDataCompressor__factory.createInterface();
|
|
27
10
|
}
|
|
28
|
-
|
|
29
|
-
|
|
11
|
+
parse(calldata) {
|
|
12
|
+
const { functionFragment, functionName } = this.parseSelector(calldata);
|
|
30
13
|
switch (functionFragment.name) {
|
|
31
14
|
case "getPoolsList":
|
|
32
15
|
case "getCreditManagersList": {
|
|
33
|
-
return
|
|
16
|
+
return `${functionName}()`;
|
|
34
17
|
}
|
|
35
18
|
default:
|
|
36
|
-
return
|
|
19
|
+
return `${functionName}: Unknown operation ${functionFragment.name} with calldata ${calldata}`;
|
|
37
20
|
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
}(abstractParser_1.AbstractParser));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
41
23
|
exports.DataCompressorParser = DataCompressorParser;
|