@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/convexAPY.d.ts
CHANGED
|
@@ -5,14 +5,14 @@ import { CurveLPToken } from "../tokens/curveLP";
|
|
|
5
5
|
import { SupportedToken } from "../tokens/token";
|
|
6
6
|
import { MCall } from "../utils/multicall";
|
|
7
7
|
import { CurveAPYResult } from "./curveAPY";
|
|
8
|
-
type GetTokenPriceCallback = (tokenAddress: string, currency?: string) =>
|
|
8
|
+
type GetTokenPriceCallback = (tokenAddress: string, currency?: string) => bigint;
|
|
9
9
|
export interface GetConvexAPYBulkProps {
|
|
10
10
|
getTokenPrice: GetTokenPriceCallback;
|
|
11
11
|
curveAPY: CurveAPYResult;
|
|
12
12
|
generated: GetConvexAPYBulkCallsReturns;
|
|
13
13
|
response: Array<BigNumber>;
|
|
14
14
|
}
|
|
15
|
-
export declare function getConvexAPYBulk({ generated, response, getTokenPrice, curveAPY, }: GetConvexAPYBulkProps):
|
|
15
|
+
export declare function getConvexAPYBulk({ generated, response, getTokenPrice, curveAPY, }: GetConvexAPYBulkProps): bigint[];
|
|
16
16
|
type GetConvexAPYBulkCallsReturns = ReturnType<typeof getConvexAPYBulkCalls>;
|
|
17
17
|
export interface GetConvexAPYBulkCallsProps {
|
|
18
18
|
pools: Array<ConvexPoolContract>;
|
|
@@ -22,15 +22,15 @@ export declare function getConvexAPYBulkCalls({ pools, networkType, }: GetConvex
|
|
|
22
22
|
poolsInfo: (readonly [ConvexPoolParams, string, string, CurveLPToken, string[], Record<SupportedToken, string>])[];
|
|
23
23
|
calls: [MCall<import("../types/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IBaseRewardPool").IBaseRewardPoolInterface>, MCall<import("../types/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IBaseRewardPool").IBaseRewardPoolInterface>, MCall<import("../types/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IBaseRewardPool").IBaseRewardPoolInterface>, MCall<import("../types/@gearbox-protocol/integrations-v2/contracts/integrations/curve/ICurvePool").ICurvePoolInterface>, MCall<import("../types/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IConvexToken").IConvexTokenInterface>, ...MCall<import("../types/@gearbox-protocol/integrations-v2/contracts/integrations/convex/IBaseRewardPool").IBaseRewardPoolInterface>[]][];
|
|
24
24
|
};
|
|
25
|
-
export declare function getCVXMintAmount(crvAmount:
|
|
25
|
+
export declare function getCVXMintAmount(crvAmount: bigint, cvxSupply: bigint): bigint;
|
|
26
26
|
export interface CalculateConvexAPYProps {
|
|
27
|
-
baseRewardsFinish:
|
|
28
|
-
basePoolRate:
|
|
29
|
-
basePoolSupply:
|
|
30
|
-
vPrice:
|
|
31
|
-
cvxSupply:
|
|
32
|
-
extra: Array<
|
|
33
|
-
extraRewardsFinish: Array<
|
|
27
|
+
baseRewardsFinish: bigint;
|
|
28
|
+
basePoolRate: bigint;
|
|
29
|
+
basePoolSupply: bigint;
|
|
30
|
+
vPrice: bigint;
|
|
31
|
+
cvxSupply: bigint;
|
|
32
|
+
extra: Array<bigint>;
|
|
33
|
+
extraRewardsFinish: Array<bigint>;
|
|
34
34
|
extraPoolAddresses: string[];
|
|
35
35
|
poolParams: ConvexPoolParams;
|
|
36
36
|
underlying: CurveLPToken;
|
package/lib/apy/convexAPY.js
CHANGED
|
@@ -1,66 +1,53 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
-
if (ar || !(i in from)) {
|
|
5
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
-
ar[i] = from[i];
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.getCVXMintAmount = exports.getConvexAPYBulkCalls = exports.getConvexAPYBulk = void 0;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
function getConvexAPYBulk(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var end = start + call.length;
|
|
24
|
-
var currentResponse = response.slice(start, end);
|
|
4
|
+
const contracts_1 = require("../contracts/contracts");
|
|
5
|
+
const constants_1 = require("../core/constants");
|
|
6
|
+
const token_1 = require("../tokens/token");
|
|
7
|
+
const types_1 = require("../types");
|
|
8
|
+
const formatter_1 = require("../utils/formatter");
|
|
9
|
+
function getConvexAPYBulk({ generated, response, getTokenPrice, curveAPY, }) {
|
|
10
|
+
const { poolsInfo, calls } = generated;
|
|
11
|
+
const [parsedResponse] = calls.reduce(([acc, start], call) => {
|
|
12
|
+
const end = start + call.length;
|
|
13
|
+
const currentResponse = response.slice(start, end);
|
|
25
14
|
acc.push(currentResponse);
|
|
26
15
|
return [acc, end];
|
|
27
|
-
}, [[], 0])
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
tokenList: tokenList,
|
|
16
|
+
}, [[], 0]);
|
|
17
|
+
const apyList = parsedResponse.map(([baseRewardsFinish, basePoolRate, basePoolSupply, vPrice, cvxSupply, ...rest], i) => {
|
|
18
|
+
const [poolParams, , , underlying, extraPoolAddresses, tokenList] = poolsInfo[i];
|
|
19
|
+
const extra = rest.slice(0, extraPoolAddresses.length);
|
|
20
|
+
const extraRewardsFinish = rest.slice(extraPoolAddresses.length);
|
|
21
|
+
const apy = calculateConvexAPY({
|
|
22
|
+
baseRewardsFinish: (0, formatter_1.toBigInt)(baseRewardsFinish),
|
|
23
|
+
basePoolRate: (0, formatter_1.toBigInt)(basePoolRate),
|
|
24
|
+
basePoolSupply: (0, formatter_1.toBigInt)(basePoolSupply),
|
|
25
|
+
vPrice: (0, formatter_1.toBigInt)(vPrice),
|
|
26
|
+
cvxSupply: (0, formatter_1.toBigInt)(cvxSupply),
|
|
27
|
+
extra: extra.map(v => (0, formatter_1.toBigInt)(v)),
|
|
28
|
+
extraRewardsFinish: extraRewardsFinish.map(v => (0, formatter_1.toBigInt)(v)),
|
|
29
|
+
extraPoolAddresses,
|
|
30
|
+
poolParams,
|
|
31
|
+
underlying,
|
|
32
|
+
getTokenPrice,
|
|
33
|
+
curveAPY,
|
|
34
|
+
tokenList,
|
|
47
35
|
});
|
|
48
36
|
return apy;
|
|
49
37
|
});
|
|
50
38
|
return apyList;
|
|
51
39
|
}
|
|
52
40
|
exports.getConvexAPYBulk = getConvexAPYBulk;
|
|
53
|
-
function getPoolInfo(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
var extraPoolAddresses = poolParams.extraRewards.map(function (d) { return d.poolAddress[networkType]; });
|
|
41
|
+
function getPoolInfo({ pool, networkType }) {
|
|
42
|
+
const tokenList = token_1.tokenDataByNetwork[networkType];
|
|
43
|
+
const contractsList = contracts_1.contractsByNetwork[networkType];
|
|
44
|
+
const poolParams = contracts_1.contractParams[pool];
|
|
45
|
+
const stakedTokenParams = token_1.supportedTokens[poolParams.stakedToken];
|
|
46
|
+
const { underlying } = stakedTokenParams;
|
|
47
|
+
const basePoolAddress = contractsList[pool];
|
|
48
|
+
const crvParams = token_1.supportedTokens[underlying];
|
|
49
|
+
const swapPoolAddress = contractsList[crvParams.pool];
|
|
50
|
+
const extraPoolAddresses = poolParams.extraRewards.map(d => d.poolAddress[networkType]);
|
|
64
51
|
return [
|
|
65
52
|
poolParams,
|
|
66
53
|
basePoolAddress,
|
|
@@ -70,24 +57,19 @@ function getPoolInfo(_a) {
|
|
|
70
57
|
tokenList,
|
|
71
58
|
];
|
|
72
59
|
}
|
|
73
|
-
function getConvexAPYBulkCalls(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
extraPoolAddresses: extraPoolAddresses,
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
return { poolsInfo: poolsInfo, calls: calls };
|
|
60
|
+
function getConvexAPYBulkCalls({ pools, networkType, }) {
|
|
61
|
+
const poolsInfo = pools.map(pool => getPoolInfo({ networkType, pool }));
|
|
62
|
+
const calls = poolsInfo.map(([, basePoolAddress, swapPoolAddress, , extraPoolAddresses, tokenList]) => getPoolDataCalls({
|
|
63
|
+
basePoolAddress,
|
|
64
|
+
swapPoolAddress,
|
|
65
|
+
cvxAddress: tokenList.CVX,
|
|
66
|
+
extraPoolAddresses,
|
|
67
|
+
}));
|
|
68
|
+
return { poolsInfo, calls };
|
|
86
69
|
}
|
|
87
70
|
exports.getConvexAPYBulkCalls = getConvexAPYBulkCalls;
|
|
88
|
-
function getPoolDataCalls(
|
|
89
|
-
|
|
90
|
-
var calls = __spreadArray(__spreadArray([
|
|
71
|
+
function getPoolDataCalls({ basePoolAddress, swapPoolAddress, cvxAddress, extraPoolAddresses, }) {
|
|
72
|
+
const calls = [
|
|
91
73
|
{
|
|
92
74
|
address: basePoolAddress,
|
|
93
75
|
interface: types_1.IBaseRewardPool__factory.createInterface(),
|
|
@@ -112,69 +94,66 @@ function getPoolDataCalls(_a) {
|
|
|
112
94
|
address: cvxAddress,
|
|
113
95
|
interface: types_1.IConvexToken__factory.createInterface(),
|
|
114
96
|
method: "totalSupply()",
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
97
|
+
},
|
|
98
|
+
...extraPoolAddresses.map((extraPoolAddress) => ({
|
|
99
|
+
address: extraPoolAddress,
|
|
100
|
+
interface: types_1.IBaseRewardPool__factory.createInterface(),
|
|
101
|
+
method: "rewardRate()",
|
|
102
|
+
})),
|
|
103
|
+
...extraPoolAddresses.map((extraPoolAddress) => ({
|
|
104
|
+
address: extraPoolAddress,
|
|
105
|
+
interface: types_1.IBaseRewardPool__factory.createInterface(),
|
|
106
|
+
method: "periodFinish()",
|
|
107
|
+
})),
|
|
108
|
+
];
|
|
125
109
|
return calls;
|
|
126
110
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
111
|
+
const CVX_MAX_SUPPLY = constants_1.WAD * 100000000n;
|
|
112
|
+
const CVX_REDUCTION_PER_CLIFF = 100000n;
|
|
113
|
+
const CVX_TOTAL_CLIFFS = constants_1.WAD * 1000n;
|
|
130
114
|
function getCVXMintAmount(crvAmount, cvxSupply) {
|
|
131
|
-
|
|
132
|
-
if (currentCliff
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return mintedAmount
|
|
115
|
+
const currentCliff = cvxSupply / CVX_REDUCTION_PER_CLIFF;
|
|
116
|
+
if (currentCliff < CVX_TOTAL_CLIFFS) {
|
|
117
|
+
const remainingCliffs = CVX_TOTAL_CLIFFS - currentCliff;
|
|
118
|
+
const mintedAmount = (crvAmount * remainingCliffs) / CVX_TOTAL_CLIFFS;
|
|
119
|
+
const amountTillMax = CVX_MAX_SUPPLY - cvxSupply;
|
|
120
|
+
return mintedAmount > amountTillMax ? amountTillMax : mintedAmount;
|
|
137
121
|
}
|
|
138
|
-
return
|
|
122
|
+
return 0n;
|
|
139
123
|
}
|
|
140
124
|
exports.getCVXMintAmount = getCVXMintAmount;
|
|
141
125
|
function getTimestampInSeconds() {
|
|
142
126
|
return Math.floor(Date.now() / 1000);
|
|
143
127
|
}
|
|
144
|
-
|
|
128
|
+
const CURRENCY_LIST = {
|
|
145
129
|
stkcvxsteCRV: "WETH",
|
|
146
130
|
};
|
|
147
|
-
function calculateConvexAPY(
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
var perYear = perUnderlying.mul(constants_1.SECONDS_PER_YEAR);
|
|
172
|
-
var extraPrice = getTokenPrice(tokenList[extraRewardSymbol], currency);
|
|
173
|
-
var extraAPY = perYear.mul(extraPrice).div(constants_1.PRICE_DECIMALS);
|
|
174
|
-
var finished = extraFinished.lte(currentTimestamp);
|
|
175
|
-
return finished ? ethers_1.BigNumber.from(0) : extraAPY;
|
|
131
|
+
function calculateConvexAPY({ baseRewardsFinish, basePoolRate, basePoolSupply, vPrice, cvxSupply, extra, extraRewardsFinish, extraPoolAddresses, poolParams, underlying, getTokenPrice, curveAPY, tokenList, }) {
|
|
132
|
+
const currentTimestamp = getTimestampInSeconds();
|
|
133
|
+
const currencySymbol = CURRENCY_LIST[poolParams.stakedToken];
|
|
134
|
+
const currency = currencySymbol && tokenList[currencySymbol || ""];
|
|
135
|
+
const cvxPrice = getTokenPrice(tokenList.CVX, currency);
|
|
136
|
+
const crvPrice = getTokenPrice(tokenList.CRV, currency);
|
|
137
|
+
const crvPerSecond = basePoolRate;
|
|
138
|
+
const virtualSupply = (basePoolSupply * vPrice) / constants_1.WAD;
|
|
139
|
+
const crvPerUnderlying = (crvPerSecond * constants_1.WAD) / virtualSupply;
|
|
140
|
+
const crvPerYear = crvPerUnderlying * BigInt(constants_1.SECONDS_PER_YEAR);
|
|
141
|
+
const cvxPerYear = getCVXMintAmount(crvPerYear, cvxSupply);
|
|
142
|
+
const baseFinished = baseRewardsFinish <= currentTimestamp;
|
|
143
|
+
const crvAPY = baseFinished ? 0n : (crvPerYear * crvPrice) / constants_1.PRICE_DECIMALS;
|
|
144
|
+
const cvxAPY = baseFinished ? 0n : (cvxPerYear * cvxPrice) / constants_1.PRICE_DECIMALS;
|
|
145
|
+
const extraAPRs = extraPoolAddresses.map((_, index) => {
|
|
146
|
+
const extraRewardSymbol = poolParams.extraRewards[index].rewardToken;
|
|
147
|
+
const extraPoolRate = extra[index];
|
|
148
|
+
const extraFinished = extraRewardsFinish[index];
|
|
149
|
+
const perUnderlying = (extraPoolRate * constants_1.WAD) / virtualSupply;
|
|
150
|
+
const perYear = perUnderlying * BigInt(constants_1.SECONDS_PER_YEAR);
|
|
151
|
+
const extraPrice = getTokenPrice(tokenList[extraRewardSymbol], currency);
|
|
152
|
+
const extraAPY = (perYear * extraPrice) / constants_1.PRICE_DECIMALS;
|
|
153
|
+
const finished = extraFinished <= currentTimestamp;
|
|
154
|
+
return finished ? 0n : extraAPY;
|
|
176
155
|
});
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
return baseApyWAD
|
|
156
|
+
const extraAPYTotal = extraAPRs.reduce((acc, apy) => acc + apy, 0n);
|
|
157
|
+
const baseApyWAD = curveAPY[underlying].base;
|
|
158
|
+
return baseApyWAD + crvAPY + cvxAPY + extraAPYTotal;
|
|
180
159
|
}
|
package/lib/apy/curveAPY.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { BigNumber } from "ethers";
|
|
2
1
|
import { CurveLPToken } from "../tokens/curveLP";
|
|
3
2
|
import { GearboxToken } from "../tokens/gear";
|
|
4
3
|
type CurveAPYTokens = CurveLPToken | GearboxToken;
|
|
5
4
|
interface CurveAPY {
|
|
6
|
-
base:
|
|
7
|
-
crv:
|
|
8
|
-
gauge: Array<[string,
|
|
5
|
+
base: bigint;
|
|
6
|
+
crv: bigint;
|
|
7
|
+
gauge: Array<[string, bigint]>;
|
|
9
8
|
}
|
|
10
9
|
export type CurveAPYResult = Record<CurveAPYTokens, CurveAPY>;
|
|
11
10
|
export declare function getCurveAPY(): Promise<CurveAPYResult | null>;
|
package/lib/apy/curveAPY.js
CHANGED
|
@@ -1,59 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
39
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
40
|
-
if (ar || !(i in from)) {
|
|
41
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
42
|
-
ar[i] = from[i];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
|
-
};
|
|
47
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
48
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
4
|
};
|
|
50
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
6
|
exports.getCurveAPY = void 0;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const constants_1 = require("../core/constants");
|
|
9
|
+
const formatter_1 = require("../utils/formatter");
|
|
10
|
+
const mappers_1 = require("../utils/mappers");
|
|
11
|
+
const APY_DICTIONARY = {
|
|
57
12
|
"3Crv": "0",
|
|
58
13
|
FRAX3CRV: "34",
|
|
59
14
|
gusd3CRV: "19",
|
|
@@ -69,69 +24,60 @@ var APY_DICTIONARY = {
|
|
|
69
24
|
crvUSDTWBTCWETH: "factory-tricrypto-1",
|
|
70
25
|
LDOETH: "factory-crypto-204",
|
|
71
26
|
};
|
|
72
|
-
|
|
27
|
+
const CRV_APY_RESPONSE_DECIMALS = 100;
|
|
73
28
|
// const CRYPTO = "https://api.curve.fi/api/getPools/ethereum/crypto";
|
|
74
29
|
// const FACTORY = "https://api.curve.fi/api/getPools/ethereum/factory";
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
function getCurveAPY() {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
return [2 /*return*/, curveAPY];
|
|
127
|
-
case 2:
|
|
128
|
-
e_1 = _f.sent();
|
|
129
|
-
console.error(e_1);
|
|
130
|
-
return [2 /*return*/, null];
|
|
131
|
-
case 3: return [2 /*return*/];
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
});
|
|
30
|
+
const CURVE_APY_URL = "https://www.convexfinance.com/api/curve-apys";
|
|
31
|
+
const CURVE_MAIN_URL = "https://api.curve.fi/api/getPools/ethereum/main";
|
|
32
|
+
const CURVE_FACTORY_CRYPTO_URL = "https://api.curve.fi/api/getPools/ethereum/factory-crypto";
|
|
33
|
+
const CURVE_CRYPTO_URL = "https://api.curve.fi/api/getPools/ethereum/crypto";
|
|
34
|
+
const CURVE_FACTORY_TRICRYPTO_URL = "https://api.curve.fi/api/getPools/ethereum/factory-tricrypto";
|
|
35
|
+
async function getCurveAPY() {
|
|
36
|
+
try {
|
|
37
|
+
const [{ data: apyData }, { data: main }, { data: factoryCrypto }, { data: crypto }, { data: factoryTricrypto },] = await Promise.all([
|
|
38
|
+
axios_1.default.get(CURVE_APY_URL),
|
|
39
|
+
axios_1.default.get(CURVE_MAIN_URL),
|
|
40
|
+
axios_1.default.get(CURVE_FACTORY_CRYPTO_URL),
|
|
41
|
+
axios_1.default.get(CURVE_CRYPTO_URL),
|
|
42
|
+
axios_1.default.get(CURVE_FACTORY_TRICRYPTO_URL),
|
|
43
|
+
]);
|
|
44
|
+
const { apys } = apyData || {};
|
|
45
|
+
const { poolData: mainPoolData = [] } = main?.data || {};
|
|
46
|
+
const { poolData: factoryCryptoPoolData = [] } = factoryCrypto?.data || {};
|
|
47
|
+
const { poolData: cryptoPoolData = [] } = crypto?.data || {};
|
|
48
|
+
const { poolData: factoryTricryptoPoolData = [] } = factoryTricrypto?.data || {};
|
|
49
|
+
const poolDataByID = Object.fromEntries([
|
|
50
|
+
...mainPoolData.map(p => [p.id, p]),
|
|
51
|
+
...factoryCryptoPoolData.map(p => [p.id, p]),
|
|
52
|
+
...cryptoPoolData.map(p => [p.id, p]),
|
|
53
|
+
...factoryTricryptoPoolData.map(p => [p.id, p]),
|
|
54
|
+
]);
|
|
55
|
+
const curveAPY = (0, mappers_1.objectEntries)(APY_DICTIONARY).reduce((acc, [curveSymbol, poolId]) => {
|
|
56
|
+
const { baseApy, crvApy } = apys[poolId] || {};
|
|
57
|
+
if (baseApy === undefined)
|
|
58
|
+
console.warn(`No base apy for: ${curveSymbol}, ${poolId}`);
|
|
59
|
+
const pool = poolDataByID[poolId];
|
|
60
|
+
const { gaugeRewards = [] } = pool || {};
|
|
61
|
+
if (pool === undefined)
|
|
62
|
+
console.warn(`No pool data for: ${curveSymbol}, ${poolId}`);
|
|
63
|
+
const extraRewards = gaugeRewards.map(({ apy = 0, symbol }) => [
|
|
64
|
+
symbol.toLowerCase(),
|
|
65
|
+
curveAPYToBn(apy),
|
|
66
|
+
]);
|
|
67
|
+
const maxCrv = pool?.gaugeCrvApy.length > 0 ? Math.max(...pool.gaugeCrvApy) : crvApy;
|
|
68
|
+
acc[curveSymbol] = {
|
|
69
|
+
base: curveAPYToBn(baseApy || 0),
|
|
70
|
+
crv: curveAPYToBn(maxCrv || 0),
|
|
71
|
+
gauge: extraRewards,
|
|
72
|
+
};
|
|
73
|
+
return acc;
|
|
74
|
+
}, {});
|
|
75
|
+
return curveAPY;
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
console.error(e);
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
135
81
|
}
|
|
136
82
|
exports.getCurveAPY = getCurveAPY;
|
|
137
83
|
function curveAPYToBn(baseApy) {
|
package/lib/apy/index.js
CHANGED
|
@@ -15,15 +15,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.isTokenWithAPY = exports.additionalTokensWIthAPY = void 0;
|
|
18
|
-
|
|
18
|
+
const token_1 = require("../tokens/token");
|
|
19
19
|
exports.additionalTokensWIthAPY = {
|
|
20
20
|
STETH: true,
|
|
21
21
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
!!exports.additionalTokensWIthAPY[t]);
|
|
26
|
-
};
|
|
22
|
+
const isTokenWithAPY = (t) => typeof t === "string" &&
|
|
23
|
+
(!!token_1.lpTokens[t] ||
|
|
24
|
+
!!exports.additionalTokensWIthAPY[t]);
|
|
27
25
|
exports.isTokenWithAPY = isTokenWithAPY;
|
|
28
26
|
__exportStar(require("./convexAPY"), exports);
|
|
29
27
|
__exportStar(require("./curveAPY"), exports);
|
package/lib/apy/lidoAPY.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function getLidoAPY(): Promise<BigNumber>;
|
|
1
|
+
export declare function getLidoAPY(): Promise<bigint>;
|