@gearbox-protocol/sdk 1.22.4 → 1.23.1
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 +19 -20
- package/lib/core/events.js +698 -711
- 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 +3 -3
- package/lib/core/rewardClaimer.js +5 -48
- package/lib/core/rewardConvex.d.ts +1 -1
- package/lib/core/rewardConvex.js +58 -118
- package/lib/core/rewardConvex.spec.js +56 -58
- 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
package/lib/apy/lidoAPY.js
CHANGED
|
@@ -1,70 +1,22 @@
|
|
|
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
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
4
|
};
|
|
41
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
6
|
exports.getLidoAPY = void 0;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
case 1:
|
|
58
|
-
res = _c.sent();
|
|
59
|
-
_b = (((_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.data) || {}).smaApr, smaApr = _b === void 0 ? 0 : _b;
|
|
60
|
-
return [2 /*return*/, (0, formatter_1.toBN)(String(smaApr), constants_1.WAD_DECIMALS_POW).div(constants_1.PERCENTAGE_DECIMALS)];
|
|
61
|
-
case 2:
|
|
62
|
-
e_1 = _c.sent();
|
|
63
|
-
console.error(e_1);
|
|
64
|
-
return [2 /*return*/, ethers_1.BigNumber.from(0)];
|
|
65
|
-
case 3: return [2 /*return*/];
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
});
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const constants_1 = require("../core/constants");
|
|
9
|
+
const formatter_1 = require("../utils/formatter");
|
|
10
|
+
const LIDO_URL = "https://eth-api.lido.fi/v1/protocol/steth/apr/sma";
|
|
11
|
+
async function getLidoAPY() {
|
|
12
|
+
try {
|
|
13
|
+
const res = await axios_1.default.get(LIDO_URL);
|
|
14
|
+
const { smaApr = 0 } = res?.data?.data || {};
|
|
15
|
+
return (0, formatter_1.toBN)(String(smaApr), constants_1.WAD_DECIMALS_POW) / constants_1.PERCENTAGE_DECIMALS;
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
console.error(e);
|
|
19
|
+
return 0n;
|
|
20
|
+
}
|
|
69
21
|
}
|
|
70
22
|
exports.getLidoAPY = getLidoAPY;
|
package/lib/apy/yearnAPY.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { BigNumber } from "ethers";
|
|
2
1
|
import { YearnLPToken } from "../tokens/yearn";
|
|
3
|
-
export type YearnAPYResult = Record<YearnLPToken,
|
|
4
|
-
export declare function getYearnAPY(): Promise<YearnAPYResult>;
|
|
2
|
+
export type YearnAPYResult = Record<YearnLPToken, bigint>;
|
|
3
|
+
export declare function getYearnAPY(): Promise<YearnAPYResult | null>;
|
package/lib/apy/yearnAPY.js
CHANGED
|
@@ -1,90 +1,34 @@
|
|
|
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
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
4
|
};
|
|
41
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
6
|
exports.getYearnAPY = void 0;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
var apy = (dataBySymbol_1[transformSymbol(yearnSymbol)] || {}).apy;
|
|
70
|
-
var netApy = (apy || {}).net_apy;
|
|
71
|
-
acc[yearnSymbol] = (0, formatter_1.toBN)((netApy / RESPONSE_DECIMALS).toString(), constants_1.WAD_DECIMALS_POW);
|
|
72
|
-
return acc;
|
|
73
|
-
}, {});
|
|
74
|
-
return [2 /*return*/, yearnAPY];
|
|
75
|
-
case 2:
|
|
76
|
-
e_1 = _a.sent();
|
|
77
|
-
return [2 /*return*/, {
|
|
78
|
-
yvDAI: ZERO,
|
|
79
|
-
yvUSDC: ZERO,
|
|
80
|
-
yvWETH: ZERO,
|
|
81
|
-
yvWBTC: ZERO,
|
|
82
|
-
yvCurve_stETH: ZERO,
|
|
83
|
-
yvCurve_FRAX: ZERO,
|
|
84
|
-
}];
|
|
85
|
-
case 3: return [2 /*return*/];
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
});
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const constants_1 = require("../core/constants");
|
|
9
|
+
const yearn_1 = require("../tokens/yearn");
|
|
10
|
+
const formatter_1 = require("../utils/formatter");
|
|
11
|
+
const mappers_1 = require("../utils/mappers");
|
|
12
|
+
const RESPONSE_DECIMALS = 1;
|
|
13
|
+
const URL = "https://api.yearn.finance/v1/chains/1/vaults/all";
|
|
14
|
+
const transformSymbol = (s) => s.replaceAll("_", "-").toLowerCase();
|
|
15
|
+
async function getYearnAPY() {
|
|
16
|
+
try {
|
|
17
|
+
const { data } = await axios_1.default.get(URL);
|
|
18
|
+
const dataBySymbol = data.reduce((acc, d) => {
|
|
19
|
+
acc[d.symbol.toLowerCase()] = d;
|
|
20
|
+
return acc;
|
|
21
|
+
}, {});
|
|
22
|
+
const yearnAPY = (0, mappers_1.objectEntries)(yearn_1.yearnTokens).reduce((acc, [yearnSymbol]) => {
|
|
23
|
+
const { apy } = dataBySymbol[transformSymbol(yearnSymbol)] || {};
|
|
24
|
+
const { net_apy: netApy } = apy || {};
|
|
25
|
+
acc[yearnSymbol] = (0, formatter_1.toBN)((netApy / RESPONSE_DECIMALS).toString(), constants_1.WAD_DECIMALS_POW);
|
|
26
|
+
return acc;
|
|
27
|
+
}, {});
|
|
28
|
+
return yearnAPY;
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
89
33
|
}
|
|
90
34
|
exports.getYearnAPY = getYearnAPY;
|
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
exports.isSupportedContract = exports.contractsByAddress = exports.contractParams = exports.UNISWAP_V3_QUOTER = exports.contractsByNetwork = void 0;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
const token_1 = require("../tokens/token");
|
|
5
|
+
const mappers_1 = require("../utils/mappers");
|
|
6
|
+
const adapters_1 = require("./adapters");
|
|
7
|
+
const protocols_1 = require("./protocols");
|
|
19
8
|
exports.contractsByNetwork = {
|
|
20
9
|
Mainnet: {
|
|
21
10
|
UNISWAP_V2_ROUTER: "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D",
|
|
@@ -493,11 +482,9 @@ exports.contractParams = {
|
|
|
493
482
|
type: adapters_1.AdapterInterface.BALANCER_VAULT,
|
|
494
483
|
},
|
|
495
484
|
};
|
|
496
|
-
exports.contractsByAddress = (0, mappers_1.objectEntries)(exports.contractsByNetwork).reduce(
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
}, {});
|
|
500
|
-
|
|
501
|
-
return typeof t === "string" && !!exports.contractParams[t];
|
|
502
|
-
};
|
|
485
|
+
exports.contractsByAddress = (0, mappers_1.objectEntries)(exports.contractsByNetwork).reduce((acc, [, contracts]) => ({
|
|
486
|
+
...acc,
|
|
487
|
+
...(0, mappers_1.filterEmptyKeys)((0, mappers_1.keyToLowercase)((0, mappers_1.swapKeyValue)(contracts))),
|
|
488
|
+
}), {});
|
|
489
|
+
const isSupportedContract = (t) => typeof t === "string" && !!exports.contractParams[t];
|
|
503
490
|
exports.isSupportedContract = isSupportedContract;
|
|
@@ -1,20 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var _a;
|
|
14
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
3
|
exports.getContractName = exports.deployedContracts = exports.CREDIT_MANAGER_WBTC_V2_GOERLI = exports.CREDIT_MANAGER_WSTETH_V2_GOERLI = exports.CREDIT_MANAGER_WETH_V2_GOERLI = exports.CREDIT_MANAGER_USDC_V2_GOERLI = exports.CREDIT_MANAGER_DAI_V2_GOERLI = exports.CREDIT_MANAGER_FRAX_V2_MAINNET = exports.CREDIT_MANAGER_WBTC_V2_MAINNET = exports.CREDIT_MANAGER_WSTETH_V2_MAINNET = exports.CREDIT_MANAGER_WETH_V2_MAINNET = exports.CREDIT_MANAGER_USDC_V2_MAINNET = exports.CREDIT_MANAGER_DAI_V2_MAINNET = exports.stEthPoolWrapper = void 0;
|
|
16
|
-
|
|
17
|
-
|
|
4
|
+
const mappers_1 = require("../utils/mappers");
|
|
5
|
+
const contracts_1 = require("./contracts");
|
|
18
6
|
exports.stEthPoolWrapper = {
|
|
19
7
|
Mainnet: "0x5a97e3E43dCBFe620ccF7865739075f92E93F5E4",
|
|
20
8
|
Goerli: "0x3fe62a62C022A069952069b32C9d56718D30B7ec",
|
|
@@ -31,49 +19,49 @@ exports.CREDIT_MANAGER_USDC_V2_GOERLI = "0x2144a7785baecbab32295188285717cad6c1a
|
|
|
31
19
|
exports.CREDIT_MANAGER_WETH_V2_GOERLI = "0x2ad4a2f1bdd815e285a22cdcc072fbb43818b09b".toLowerCase();
|
|
32
20
|
exports.CREDIT_MANAGER_WSTETH_V2_GOERLI = "0x40d542a5c15b2c0c65af047984c285c2c30847af".toLowerCase();
|
|
33
21
|
exports.CREDIT_MANAGER_WBTC_V2_GOERLI = "0x6546dd4e8d507e3e45bb924818c0bad2a3aa2c5f".toLowerCase();
|
|
34
|
-
exports.deployedContracts =
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
},
|
|
22
|
+
exports.deployedContracts = {
|
|
23
|
+
// MAINNET
|
|
24
|
+
"0x777E23A2AcB2fCbB35f6ccF98272d03C722Ba6EB": "DAI",
|
|
25
|
+
"0x2664cc24CBAd28749B3Dd6fC97A6B402484De527": "USDC",
|
|
26
|
+
"0x968f9a68a98819E2e6Bb910466e191A7b6cf02F0": "WETH",
|
|
27
|
+
"0xC38478B0A4bAFE964C3526EEFF534d70E1E09017": "WBTC",
|
|
28
|
+
"0x79012c8d491dcf3a30db20d1f449b14caf01da6c": "FRAX",
|
|
29
|
+
// MAINNET POOLS
|
|
30
|
+
"0x24946bCbBd028D5ABb62ad9B635EB1b1a67AF668": "DAI",
|
|
31
|
+
"0x86130bDD69143D8a4E5fc50bf4323D48049E98E4": "USDC",
|
|
32
|
+
"0xB03670c20F87f2169A7c4eBE35746007e9575901": "WETH",
|
|
33
|
+
"0xB8cf3Ed326bB0E51454361Fb37E9E8df6DC5C286": "wstETH",
|
|
34
|
+
"0xB2A015c71c17bCAC6af36645DEad8c572bA08A08": "WBTC",
|
|
48
35
|
// MAINNET V2 CM
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
36
|
+
[exports.CREDIT_MANAGER_DAI_V2_MAINNET]: "DAI",
|
|
37
|
+
[exports.CREDIT_MANAGER_USDC_V2_MAINNET]: "USDC",
|
|
38
|
+
[exports.CREDIT_MANAGER_WETH_V2_MAINNET]: "WETH",
|
|
39
|
+
[exports.CREDIT_MANAGER_WSTETH_V2_MAINNET]: "wstETH",
|
|
40
|
+
[exports.CREDIT_MANAGER_WBTC_V2_MAINNET]: "WBTC",
|
|
41
|
+
[exports.CREDIT_MANAGER_FRAX_V2_MAINNET]: "FRAX",
|
|
55
42
|
// GOERLI CM
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
43
|
+
[exports.CREDIT_MANAGER_DAI_V2_GOERLI]: "DAI",
|
|
44
|
+
[exports.CREDIT_MANAGER_USDC_V2_GOERLI]: "USDC",
|
|
45
|
+
[exports.CREDIT_MANAGER_WETH_V2_GOERLI]: "WETH",
|
|
46
|
+
[exports.CREDIT_MANAGER_WSTETH_V2_GOERLI]: "wstETH",
|
|
47
|
+
[exports.CREDIT_MANAGER_WBTC_V2_GOERLI]: "WBTC",
|
|
61
48
|
// GOERLI pools
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
var addr = _a[0], cSymbol = _a[1];
|
|
71
|
-
var params = contracts_1.contractParams[cSymbol];
|
|
49
|
+
"0xfb422e503f8b768184aba5e73587543d1c871a23": "DAI",
|
|
50
|
+
"0x7c14c88f672d5513c8fa640fa48815f40c781a60": "USDC",
|
|
51
|
+
"0x13376d637ded73a0df20d192f691a88c8af7dd0a": "ETH/WETH",
|
|
52
|
+
"0x3f926a46893af659c2768f118d5f189190baa15c": "WBTC",
|
|
53
|
+
"0xbdf0395fa6f134b8de35ef30c61b2b9711cbd67a": "wstETH",
|
|
54
|
+
};
|
|
55
|
+
const contractNames = Object.entries(contracts_1.contractsByAddress).reduce((acc, [addr, cSymbol]) => {
|
|
56
|
+
const params = contracts_1.contractParams[cSymbol];
|
|
72
57
|
if (!params)
|
|
73
58
|
return acc;
|
|
74
|
-
return
|
|
59
|
+
return { ...acc, [addr]: params.name };
|
|
75
60
|
}, {});
|
|
76
|
-
|
|
61
|
+
const contractsFullList = {
|
|
62
|
+
...(0, mappers_1.keyToLowercase)(exports.deployedContracts),
|
|
63
|
+
...contractNames,
|
|
64
|
+
};
|
|
77
65
|
function getContractName(address) {
|
|
78
66
|
return contractsFullList[address.toLowerCase()] || address;
|
|
79
67
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.protocolData = exports.Protocols = void 0;
|
|
5
4
|
var Protocols;
|
|
@@ -13,37 +12,37 @@ var Protocols;
|
|
|
13
12
|
Protocols[Protocols["Gearbox"] = 6] = "Gearbox";
|
|
14
13
|
Protocols[Protocols["Balancer"] = 7] = "Balancer";
|
|
15
14
|
})(Protocols = exports.Protocols || (exports.Protocols = {}));
|
|
16
|
-
exports.protocolData =
|
|
17
|
-
|
|
15
|
+
exports.protocolData = {
|
|
16
|
+
[Protocols.Uniswap]: {
|
|
18
17
|
name: "Uniswap",
|
|
19
18
|
icon: "/protocols/uniswap.png",
|
|
20
19
|
},
|
|
21
|
-
|
|
20
|
+
[Protocols.Sushiswap]: {
|
|
22
21
|
name: "Sushiswap",
|
|
23
22
|
icon: "/protocols/sushi.svg",
|
|
24
23
|
},
|
|
25
|
-
|
|
24
|
+
[Protocols.Curve]: {
|
|
26
25
|
name: "Curve",
|
|
27
26
|
icon: "/protocols/curve.svg",
|
|
28
27
|
},
|
|
29
|
-
|
|
28
|
+
[Protocols.Yearn]: {
|
|
30
29
|
name: "Yearn",
|
|
31
30
|
icon: "/protocols/yearn.svg",
|
|
32
31
|
},
|
|
33
|
-
|
|
32
|
+
[Protocols.Convex]: {
|
|
34
33
|
name: "Convex",
|
|
35
34
|
icon: "/protocols/convex.svg",
|
|
36
35
|
},
|
|
37
|
-
|
|
36
|
+
[Protocols.Lido]: {
|
|
38
37
|
name: "Lido",
|
|
39
38
|
icon: "/protocols/lido.svg",
|
|
40
39
|
},
|
|
41
|
-
|
|
40
|
+
[Protocols.Gearbox]: {
|
|
42
41
|
name: "Gearbox",
|
|
43
42
|
icon: "",
|
|
44
43
|
},
|
|
45
|
-
|
|
44
|
+
[Protocols.Balancer]: {
|
|
46
45
|
name: "Balancer",
|
|
47
46
|
icon: "",
|
|
48
47
|
},
|
|
49
|
-
|
|
48
|
+
};
|
package/lib/core/adapter.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BaseAdapter = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
class BaseAdapter {
|
|
5
|
+
name;
|
|
6
|
+
adapterInterface;
|
|
7
|
+
contractAddress;
|
|
8
|
+
adapterAddress;
|
|
9
|
+
contractSymbol;
|
|
10
|
+
creditManager;
|
|
11
|
+
constructor(props) {
|
|
6
12
|
this.name = props.name;
|
|
7
13
|
this.adapterInterface = props.adapterInterface;
|
|
8
14
|
this.adapterAddress = props.adapterAddress;
|
|
@@ -10,6 +16,5 @@ var BaseAdapter = /** @class */ (function () {
|
|
|
10
16
|
this.contractSymbol = props.contractSymbol;
|
|
11
17
|
this.creditManager = props.creditManager;
|
|
12
18
|
}
|
|
13
|
-
|
|
14
|
-
}());
|
|
19
|
+
}
|
|
15
20
|
exports.BaseAdapter = BaseAdapter;
|
package/lib/core/assets.d.ts
CHANGED
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
import { BigNumber } from "ethers";
|
|
2
1
|
import { TokenData } from "../tokens/tokenData";
|
|
3
2
|
export interface Asset {
|
|
4
3
|
token: string;
|
|
5
|
-
balance:
|
|
4
|
+
balance: bigint;
|
|
6
5
|
}
|
|
7
6
|
export interface AssetWithView extends Asset {
|
|
8
7
|
balanceView: string;
|
|
9
8
|
}
|
|
10
9
|
export interface AssetWithAmountInTarget extends Asset {
|
|
11
|
-
amountInTarget:
|
|
10
|
+
amountInTarget: bigint;
|
|
12
11
|
}
|
|
13
12
|
interface NextAssetProps<T extends Asset> {
|
|
14
13
|
allowedTokens: Array<string>;
|
|
15
14
|
selectedAssets: Array<T>;
|
|
16
|
-
balances: Record<string,
|
|
15
|
+
balances: Record<string, bigint>;
|
|
17
16
|
tokensList: Record<string, TokenData>;
|
|
18
|
-
prices?: Record<string,
|
|
17
|
+
prices?: Record<string, bigint>;
|
|
19
18
|
}
|
|
20
|
-
export type WrapResult<T> = [Array<T>,
|
|
19
|
+
export type WrapResult<T> = [Array<T>, bigint, bigint];
|
|
21
20
|
export declare class AssetUtils {
|
|
22
21
|
static nextAsset<T extends Asset>({ allowedTokens, selectedAssets, balances, tokensList, prices, }: NextAssetProps<T>): string | undefined;
|
|
23
|
-
static getBalances(allowedTokens: Array<string>, externalBalances: Record<string,
|
|
22
|
+
static getBalances(allowedTokens: Array<string>, externalBalances: Record<string, bigint>): Record<string, bigint>;
|
|
24
23
|
static constructAssetRecord<A extends Asset>(a: Array<A>): Record<string, A>;
|
|
25
24
|
static memoWrapETH: (ethAddress: string, wethAddress: string) => <T extends Asset>(assets: T[]) => WrapResult<T>;
|
|
26
25
|
/**
|
package/lib/core/assets.js
CHANGED
|
@@ -1,98 +1,88 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
exports.AssetUtils = void 0;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
AssetUtils.nextAsset = function (_a) {
|
|
22
|
-
var allowedTokens = _a.allowedTokens, selectedAssets = _a.selectedAssets, balances = _a.balances, tokensList = _a.tokensList, _b = _a.prices, prices = _b === void 0 ? {} : _b;
|
|
23
|
-
var selectedRecord = selectedAssets.reduce(function (acc, _a) {
|
|
24
|
-
var token = _a.token;
|
|
4
|
+
const math_1 = require("../utils/math");
|
|
5
|
+
const creditAccount_1 = require("./creditAccount");
|
|
6
|
+
class AssetUtils {
|
|
7
|
+
static nextAsset({ allowedTokens, selectedAssets, balances, tokensList, prices = {}, }) {
|
|
8
|
+
const selectedRecord = selectedAssets.reduce((acc, { token }) => {
|
|
25
9
|
acc[token.toLowerCase()] = true;
|
|
26
10
|
return acc;
|
|
27
11
|
}, {});
|
|
28
|
-
|
|
29
|
-
|
|
12
|
+
const notSelected = allowedTokens.filter(allowedToken => {
|
|
13
|
+
const alreadySelected = selectedRecord[allowedToken.toLowerCase()];
|
|
30
14
|
return !alreadySelected;
|
|
31
15
|
});
|
|
32
|
-
|
|
33
|
-
|
|
16
|
+
const sorted = (0, creditAccount_1.sortBalances)(AssetUtils.getBalances(notSelected, balances), prices, tokensList);
|
|
17
|
+
const [address] = sorted[0] || [];
|
|
34
18
|
return address;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return allowedTokens.reduce(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
19
|
+
}
|
|
20
|
+
static getBalances(allowedTokens, externalBalances) {
|
|
21
|
+
return allowedTokens.reduce((acc, address) => {
|
|
22
|
+
const addressLc = address.toLowerCase();
|
|
23
|
+
return {
|
|
24
|
+
...acc,
|
|
25
|
+
[addressLc]: externalBalances[addressLc] || 0n,
|
|
26
|
+
};
|
|
41
27
|
}, {});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
28
|
+
}
|
|
29
|
+
static constructAssetRecord(a) {
|
|
30
|
+
const record = a.reduce((acc, asset) => {
|
|
45
31
|
acc[asset.token] = asset;
|
|
46
32
|
return acc;
|
|
47
33
|
}, {});
|
|
48
34
|
return record;
|
|
35
|
+
}
|
|
36
|
+
static memoWrapETH = (ethAddress, wethAddress) => function wrapETH(assets) {
|
|
37
|
+
const assetsRecord = AssetUtils.constructAssetRecord(assets);
|
|
38
|
+
const weth = assetsRecord[wethAddress];
|
|
39
|
+
const { balance: wethAmount = 0n } = weth || {};
|
|
40
|
+
const eth = assetsRecord[ethAddress];
|
|
41
|
+
const { balance: ethAmount = 0n } = eth || {};
|
|
42
|
+
const wethOrETH = weth || eth;
|
|
43
|
+
if (wethOrETH) {
|
|
44
|
+
assetsRecord[wethAddress] = {
|
|
45
|
+
...wethOrETH,
|
|
46
|
+
token: wethAddress,
|
|
47
|
+
balance: (0, math_1.nonNegativeBn)(ethAmount) + (0, math_1.nonNegativeBn)(wethAmount),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
if (eth) {
|
|
51
|
+
delete assetsRecord[ethAddress];
|
|
52
|
+
}
|
|
53
|
+
return [Object.values(assetsRecord), ethAmount, wethAmount];
|
|
49
54
|
};
|
|
50
55
|
/**
|
|
51
56
|
* Sums the the second assets list into the first assets list
|
|
52
57
|
* Creates new assets.
|
|
53
58
|
*/
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
acc[bAsset.token] =
|
|
59
|
+
static sumAssets(a, b) {
|
|
60
|
+
const aRecord = AssetUtils.constructAssetRecord(a);
|
|
61
|
+
const resRecord = b.reduce((acc, bAsset) => {
|
|
62
|
+
const aAsset = acc[bAsset.token];
|
|
63
|
+
const { balance: amount = 0n } = aAsset || {};
|
|
64
|
+
const amountSum = (0, math_1.nonNegativeBn)(bAsset.balance) + (0, math_1.nonNegativeBn)(amount);
|
|
65
|
+
const aOrB = aAsset || bAsset;
|
|
66
|
+
acc[bAsset.token] = {
|
|
67
|
+
...aOrB,
|
|
68
|
+
balance: amountSum,
|
|
69
|
+
};
|
|
62
70
|
return acc;
|
|
63
71
|
}, aRecord);
|
|
64
72
|
return Object.values(resRecord);
|
|
65
|
-
}
|
|
73
|
+
}
|
|
66
74
|
/**
|
|
67
75
|
* Subtracts the the second assets list from the first assets list
|
|
68
76
|
* Balance cant be negative; doesn't create new assets.
|
|
69
77
|
*/
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return a.map(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return
|
|
78
|
+
static subAssets(a, b) {
|
|
79
|
+
const bRecord = AssetUtils.constructAssetRecord(b);
|
|
80
|
+
return a.map(asset => {
|
|
81
|
+
const bAsset = bRecord[asset.token];
|
|
82
|
+
const { balance: bAmount = 0n } = bAsset || {};
|
|
83
|
+
const amountSub = (0, math_1.nonNegativeBn)(asset.balance) - (0, math_1.nonNegativeBn)(bAmount);
|
|
84
|
+
return { ...asset, balance: (0, math_1.nonNegativeBn)(amountSub) };
|
|
77
85
|
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return function wrapETH(assets) {
|
|
81
|
-
var assetsRecord = AssetUtils.constructAssetRecord(assets);
|
|
82
|
-
var weth = assetsRecord[wethAddress];
|
|
83
|
-
var _a = (weth || {}).balance, wethAmount = _a === void 0 ? ethers_1.BigNumber.from(0) : _a;
|
|
84
|
-
var eth = assetsRecord[ethAddress];
|
|
85
|
-
var _b = (eth || {}).balance, ethAmount = _b === void 0 ? ethers_1.BigNumber.from(0) : _b;
|
|
86
|
-
var wethOrETH = weth || eth;
|
|
87
|
-
if (wethOrETH) {
|
|
88
|
-
assetsRecord[wethAddress] = __assign(__assign({}, wethOrETH), { token: wethAddress, balance: (0, math_1.nonNegativeBn)(ethAmount).add((0, math_1.nonNegativeBn)(wethAmount)) });
|
|
89
|
-
}
|
|
90
|
-
if (eth) {
|
|
91
|
-
delete assetsRecord[ethAddress];
|
|
92
|
-
}
|
|
93
|
-
return [Object.values(assetsRecord), ethAmount, wethAmount];
|
|
94
|
-
};
|
|
95
|
-
};
|
|
96
|
-
return AssetUtils;
|
|
97
|
-
}());
|
|
86
|
+
}
|
|
87
|
+
}
|
|
98
88
|
exports.AssetUtils = AssetUtils;
|