@gearbox-protocol/sdk 3.0.0-next.7 → 3.0.0-next.71
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/contracts/index.sol +29 -4
- package/lib/apy/curveAPY.js +2 -1
- package/lib/apy/index.d.ts +2 -2
- package/lib/apy/yearnAPY.js +1 -1
- package/lib/core/assets.d.ts +4 -4
- package/lib/core/assets.js +28 -17
- package/lib/core/creditAccount.d.ts +32 -8
- package/lib/core/creditAccount.js +101 -44
- package/lib/core/creditAccount.spec.js +693 -10
- package/lib/core/creditManager.d.ts +12 -3
- package/lib/core/creditManager.js +43 -10
- package/lib/core/events.js +14 -14
- package/lib/core/gauge.d.ts +26 -0
- package/lib/core/gauge.js +63 -0
- package/lib/core/gaugeMath.d.ts +40 -0
- package/lib/core/gaugeMath.js +108 -0
- package/lib/core/gaugeMath.spec.d.ts +1 -0
- package/lib/core/gaugeMath.spec.js +388 -0
- package/lib/core/{pool/data.d.ts → pool.d.ts} +17 -10
- package/lib/core/{pool/data.js → pool.js} +66 -24
- package/lib/core/strategy.d.ts +4 -3
- package/lib/core/strategy.js +15 -14
- package/lib/core/strategy.spec.js +68 -3
- package/lib/core/trade.d.ts +12 -29
- package/lib/core/trade.js +33 -82
- package/lib/core/transactions.d.ts +65 -3
- package/lib/core/transactions.js +162 -105
- package/lib/index.d.ts +3 -0
- package/lib/index.js +3 -0
- package/lib/parsers/abstractParser.js +1 -2
- package/lib/parsers/convexBaseRewardPoolAdapterParser.js +10 -8
- package/lib/parsers/convexBaseRewardPoolAdapterParser.spec.js +9 -6
- package/lib/parsers/convexBoosterAdapterParser.js +6 -6
- package/lib/parsers/convexBoosterAdapterParser.spec.js +4 -4
- package/lib/parsers/creditFacadeParser.d.ts +2 -1
- package/lib/parsers/creditFacadeParser.js +40 -5
- package/lib/parsers/creditFacadeParser.spec.js +3 -4
- package/lib/parsers/curveAdapterParser.js +10 -11
- package/lib/parsers/curveAdapterParser.spec.js +6 -2
- package/lib/parsers/lidoAdapterParser.js +3 -2
- package/lib/parsers/lidoAdapterParser.spec.js +2 -2
- package/lib/parsers/txParser.d.ts +1 -1
- package/lib/parsers/txParser.js +9 -3
- package/lib/parsers/uniV2AdapterParser.js +5 -4
- package/lib/parsers/uniV2AdapterParser.spec.js +3 -2
- package/lib/parsers/uniV3AdapterParser.js +9 -7
- package/lib/parsers/uniV3AdapterParser.spec.js +3 -2
- package/lib/parsers/wstETHAdapterParser.js +6 -4
- package/lib/parsers/wstETHAdapterParser.spec.js +4 -4
- package/lib/parsers/yearnAdapterParser.spec.js +4 -4
- package/lib/parsers/yearnV2AdapterParser.js +13 -3
- package/lib/pathfinder/core.d.ts +8 -9
- package/lib/pathfinder/pathOptions.d.ts +2 -1
- package/lib/pathfinder/pathOptions.js +20 -1
- package/lib/pathfinder/pathOptions.spec.js +2 -2
- package/lib/pathfinder/pathfinder.d.ts +38 -10
- package/lib/pathfinder/pathfinder.js +53 -34
- package/lib/pathfinder/pathfinder.spec.js +7 -3
- package/lib/payload/creditAccount.d.ts +3 -4
- package/lib/payload/gauge.d.ts +12 -0
- package/lib/payload/pool.d.ts +6 -1
- package/lib/types/IAaveV2_LendingPoolAdapter.d.ts +171 -0
- package/lib/types/IAaveV2_WrappedATokenAdapter.d.ts +290 -0
- package/lib/types/IBalancerV2Vault.sol/IBalancerV2Vault.d.ts +308 -0
- package/lib/types/IBalancerV2Vault.sol/IBalancerV2VaultGetters.d.ts +112 -0
- package/lib/types/IBalancerV2Vault.sol/index.d.ts +2 -0
- package/lib/types/IBalancerV2VaultAdapter.sol/IBalancerV2VaultAdapter.d.ts +466 -0
- package/lib/types/IBalancerV2VaultAdapter.sol/IBalancerV2VaultAdapterEvents.d.ts +43 -0
- package/lib/types/{ILidoV1Adapter.sol/ILidoV1AdapterEvents.d.ts → IBalancerV2VaultAdapter.sol/IBalancerV2VaultAdapterExceptions.d.ts} +6 -18
- package/lib/types/IBalancerV2VaultAdapter.sol/index.d.ts +3 -0
- package/lib/types/IBotListV3.sol/IBotListV3.d.ts +286 -0
- package/lib/types/IBotListV3.sol/IBotListV3Events.d.ts +103 -0
- package/lib/types/IBotListV3.sol/index.d.ts +2 -0
- package/lib/types/ICompoundV2_CTokenAdapter.sol/ICompoundV2_CTokenAdapter.d.ts +216 -0
- package/lib/types/ICompoundV2_CTokenAdapter.sol/ICompoundV2_Exceptions.d.ts +27 -0
- package/lib/types/ICompoundV2_CTokenAdapter.sol/index.d.ts +2 -0
- package/lib/types/IContractsRegister.sol/IContractsRegister.d.ts +128 -0
- package/lib/types/IContractsRegister.sol/IContractsRegisterEvents.d.ts +50 -0
- package/lib/types/IContractsRegister.sol/index.d.ts +2 -0
- package/lib/types/IControllerTimelockV3.sol/IControllerTimelockV3.d.ts +504 -0
- package/lib/types/IControllerTimelockV3.sol/IControllerTimelockV3Events.d.ts +82 -0
- package/lib/types/IControllerTimelockV3.sol/index.d.ts +2 -0
- package/lib/types/IConvexToken.d.ts +9 -1
- package/lib/types/IConvexV1BaseRewardPoolAdapter.d.ts +46 -30
- package/lib/types/{IConvexV1BoosterAdapter.d.ts → IConvexV1BoosterAdapter.sol/IConvexV1BoosterAdapter.d.ts} +40 -21
- package/lib/types/IConvexV1BoosterAdapter.sol/IConvexV1BoosterAdapterEvents.d.ts +43 -0
- package/lib/types/IConvexV1BoosterAdapter.sol/IConvexV1BoosterAdapterEvents.js +2 -0
- package/lib/types/IConvexV1BoosterAdapter.sol/index.d.ts +2 -0
- package/lib/types/IConvexV1BoosterAdapter.sol/index.js +2 -0
- package/lib/types/ICreditConfiguratorV3.sol/ICreditConfiguratorV3.d.ts +716 -0
- package/lib/types/ICreditConfiguratorV3.sol/ICreditConfiguratorV3.js +2 -0
- package/lib/types/ICreditConfiguratorV3.sol/ICreditConfiguratorV3Events.d.ts +275 -0
- package/lib/types/ICreditConfiguratorV3.sol/ICreditConfiguratorV3Events.js +2 -0
- package/lib/types/ICreditConfiguratorV3.sol/index.d.ts +2 -0
- package/lib/types/ICreditConfiguratorV3.sol/index.js +2 -0
- package/lib/types/ICreditFacadeV2.sol/ICreditFacadeV2Extended.d.ts +7 -11
- package/lib/types/ICreditFacadeV3.sol/ICreditFacadeV3.d.ts +201 -94
- package/lib/types/ICreditFacadeV3.sol/ICreditFacadeV3Events.d.ts +31 -33
- package/lib/types/ICreditFacadeV3Multicall.d.ts +91 -60
- package/lib/types/ICreditManagerV3.sol/ICreditManagerV3.d.ts +360 -98
- package/lib/types/ICurveV1Adapter.d.ts +41 -105
- package/lib/types/ICurveV1_2AssetsAdapter.d.ts +41 -105
- package/lib/types/ICurveV1_3AssetsAdapter.d.ts +41 -105
- package/lib/types/ICurveV1_4AssetsAdapter.d.ts +41 -105
- package/lib/types/IDataCompressorV2_10.d.ts +44 -36
- package/lib/types/IDataCompressorV3_00.d.ts +141 -37
- package/lib/types/IDegenNFTV2.sol/IDegenNFTV2.d.ts +339 -0
- package/lib/types/IDegenNFTV2.sol/IDegenNFTV2.js +2 -0
- package/lib/types/IDegenNFTV2.sol/IDegenNFTV2Events.d.ts +61 -0
- package/lib/types/IDegenNFTV2.sol/IDegenNFTV2Events.js +2 -0
- package/lib/types/IDegenNFTV2.sol/IDegenNFTV2Exceptions.d.ts +27 -0
- package/lib/types/IDegenNFTV2.sol/IDegenNFTV2Exceptions.js +2 -0
- package/lib/types/IDegenNFTV2.sol/index.d.ts +3 -0
- package/lib/types/IDegenNFTV2.sol/index.js +2 -0
- package/lib/types/IERC165.d.ts +42 -0
- package/lib/types/IERC165.js +2 -0
- package/lib/types/{draft-IERC20Permit.sol/IERC20Permit.d.ts → IERC20Permit.d.ts} +1 -1
- package/lib/types/IERC20Permit.js +2 -0
- package/lib/types/IERC20ZapperDeposits.d.ts +117 -0
- package/lib/types/IERC20ZapperDeposits.js +2 -0
- package/lib/types/IERC4626Adapter.d.ts +238 -0
- package/lib/types/IERC4626Adapter.js +2 -0
- package/lib/types/IERC721.d.ts +220 -0
- package/lib/types/IERC721.js +2 -0
- package/lib/types/IERC721Metadata.d.ts +244 -0
- package/lib/types/IERC721Metadata.js +2 -0
- package/lib/types/IETHZapperDeposits.d.ts +66 -0
- package/lib/types/IETHZapperDeposits.js +2 -0
- package/lib/types/IGasPricer.d.ts +44 -0
- package/lib/types/IGasPricer.js +2 -0
- package/lib/types/IGaugeV3.sol/IGaugeV3.d.ts +366 -0
- package/lib/types/IGaugeV3.sol/IGaugeV3.js +2 -0
- package/lib/types/IGaugeV3.sol/IGaugeV3Events.d.ts +114 -0
- package/lib/types/IGaugeV3.sol/IGaugeV3Events.js +2 -0
- package/lib/types/IGaugeV3.sol/index.d.ts +2 -0
- package/lib/types/IGaugeV3.sol/index.js +2 -0
- package/lib/types/IGearStakingV3.sol/IGearStakingV3.d.ts +408 -0
- package/lib/types/IGearStakingV3.sol/IGearStakingV3.js +2 -0
- package/lib/types/IGearStakingV3.sol/IGearStakingV3Events.d.ts +117 -0
- package/lib/types/IGearStakingV3.sol/IGearStakingV3Events.js +2 -0
- package/lib/types/IGearStakingV3.sol/index.d.ts +2 -0
- package/lib/types/IGearStakingV3.sol/index.js +2 -0
- package/lib/types/ILPPriceFeed.sol/ILPPriceFeed.d.ts +285 -0
- package/lib/types/ILPPriceFeed.sol/ILPPriceFeed.js +2 -0
- package/lib/types/ILPPriceFeed.sol/ILPPriceFeedEvents.d.ts +54 -0
- package/lib/types/ILPPriceFeed.sol/ILPPriceFeedEvents.js +2 -0
- package/lib/types/ILPPriceFeed.sol/ILPPriceFeedExceptions.d.ts +27 -0
- package/lib/types/ILPPriceFeed.sol/ILPPriceFeedExceptions.js +2 -0
- package/lib/types/ILPPriceFeed.sol/index.d.ts +3 -0
- package/lib/types/ILPPriceFeed.sol/index.js +2 -0
- package/lib/types/{ILidoV1Adapter.sol/ILidoV1Adapter.d.ts → ILidoV1Adapter.d.ts} +13 -48
- package/lib/types/ILidoV1Adapter.js +2 -0
- package/lib/types/ILinearInterestRateModelV3.d.ts +120 -0
- package/lib/types/ILinearInterestRateModelV3.js +2 -0
- package/lib/types/IPoolQuotaKeeperV3.sol/IPoolQuotaKeeperV3.d.ts +473 -0
- package/lib/types/IPoolQuotaKeeperV3.sol/IPoolQuotaKeeperV3.js +2 -0
- package/lib/types/IPoolQuotaKeeperV3.sol/IPoolQuotaKeeperV3Events.d.ts +113 -0
- package/lib/types/IPoolQuotaKeeperV3.sol/IPoolQuotaKeeperV3Events.js +2 -0
- package/lib/types/IPoolQuotaKeeperV3.sol/index.d.ts +2 -0
- package/lib/types/IPoolQuotaKeeperV3.sol/index.js +2 -0
- package/lib/types/IPoolV3.sol/IPoolV3.d.ts +43 -11
- package/lib/types/IPoolV3.sol/index.d.ts +0 -1
- package/lib/types/IPriceFeed.sol/IPriceFeed.d.ts +109 -0
- package/lib/types/IPriceFeed.sol/IPriceFeed.js +2 -0
- package/lib/types/IPriceFeed.sol/IUpdatablePriceFeed.d.ts +133 -0
- package/lib/types/IPriceFeed.sol/IUpdatablePriceFeed.js +2 -0
- package/lib/types/IPriceFeed.sol/index.d.ts +2 -0
- package/lib/types/IPriceFeed.sol/index.js +2 -0
- package/lib/types/IPriceOracle.sol/IPriceOracleV2.d.ts +166 -0
- package/lib/types/IPriceOracle.sol/IPriceOracleV2.js +2 -0
- package/lib/types/IPriceOracle.sol/IPriceOracleV2Events.d.ts +43 -0
- package/lib/types/IPriceOracle.sol/IPriceOracleV2Events.js +2 -0
- package/lib/types/{ILidoV1Adapter.sol/ILidoV1AdapterExceptions.d.ts → IPriceOracle.sol/IPriceOracleV2Exceptions.d.ts} +3 -3
- package/lib/types/IPriceOracle.sol/IPriceOracleV2Exceptions.js +2 -0
- package/lib/types/IPriceOracle.sol/IPriceOracleV2Ext.d.ts +182 -0
- package/lib/types/IPriceOracle.sol/IPriceOracleV2Ext.js +2 -0
- package/lib/types/IPriceOracle.sol/index.d.ts +4 -0
- package/lib/types/IPriceOracle.sol/index.js +2 -0
- package/lib/types/IPriceOracleV3.sol/IPriceOracleV3.d.ts +272 -0
- package/lib/types/IPriceOracleV3.sol/IPriceOracleV3.js +2 -0
- package/lib/types/IPriceOracleV3.sol/IPriceOracleV3Events.d.ts +79 -0
- package/lib/types/IPriceOracleV3.sol/IPriceOracleV3Events.js +2 -0
- package/lib/types/IPriceOracleV3.sol/index.d.ts +2 -0
- package/lib/types/IPriceOracleV3.sol/index.js +2 -0
- package/lib/types/IUniswapV2Adapter.sol/IUniswapV2Adapter.d.ts +10 -9
- package/lib/types/IUniswapV3Adapter.sol/IUniswapV3Adapter.d.ts +27 -21
- package/lib/types/IVotingContractV3.d.ts +74 -0
- package/lib/types/IVotingContractV3.js +2 -0
- package/lib/types/IYearnV2Adapter.d.ts +22 -22
- package/lib/types/IZapper.d.ts +125 -0
- package/lib/types/IZapper.js +2 -0
- package/lib/types/IZapperRegister.d.ts +62 -0
- package/lib/types/IZapperRegister.js +2 -0
- package/lib/types/IwstETHV1Adapter.d.ts +17 -17
- package/lib/types/factories/AddressProvider__factory.d.ts +1 -1
- package/lib/types/factories/AddressProvider__factory.js +1 -1
- package/lib/types/factories/Claimable__factory.d.ts +1 -1
- package/lib/types/factories/Claimable__factory.js +1 -1
- package/lib/types/factories/IAaveV2_LendingPoolAdapter__factory.d.ts +158 -0
- package/lib/types/factories/IAaveV2_LendingPoolAdapter__factory.js +215 -0
- package/lib/types/factories/IAaveV2_WrappedATokenAdapter__factory.d.ts +252 -0
- package/lib/types/factories/IAaveV2_WrappedATokenAdapter__factory.js +341 -0
- package/lib/types/factories/IBalancerV2Vault.sol/IBalancerV2VaultGetters__factory.d.ts +78 -0
- package/lib/types/factories/{ZapperBase__factory.js → IBalancerV2Vault.sol/IBalancerV2VaultGetters__factory.js} +54 -31
- package/lib/types/factories/IBalancerV2Vault.sol/IBalancerV2Vault__factory.d.ts +360 -0
- package/lib/types/factories/IBalancerV2Vault.sol/IBalancerV2Vault__factory.js +475 -0
- package/lib/types/factories/IBalancerV2Vault.sol/index.d.ts +2 -0
- package/lib/types/factories/IBalancerV2Vault.sol/index.js +10 -0
- package/lib/types/factories/IBalancerV2VaultAdapter.sol/IBalancerV2VaultAdapterEvents__factory.d.ts +23 -0
- package/lib/types/factories/IBalancerV2VaultAdapter.sol/IBalancerV2VaultAdapterEvents__factory.js +38 -0
- package/lib/types/factories/IBalancerV2VaultAdapter.sol/IBalancerV2VaultAdapterExceptions__factory.d.ts +12 -0
- package/lib/types/factories/{ILidoV1Adapter.sol/ILidoV1AdapterExceptions__factory.js → IBalancerV2VaultAdapter.sol/IBalancerV2VaultAdapterExceptions__factory.js} +4 -4
- package/lib/types/factories/IBalancerV2VaultAdapter.sol/IBalancerV2VaultAdapter__factory.d.ts +514 -0
- package/lib/types/factories/IBalancerV2VaultAdapter.sol/IBalancerV2VaultAdapter__factory.js +675 -0
- package/lib/types/factories/IBalancerV2VaultAdapter.sol/index.d.ts +3 -0
- package/lib/types/factories/IBalancerV2VaultAdapter.sol/index.js +12 -0
- package/lib/types/factories/IBotListV3.sol/IBotListV3Events__factory.d.ts +103 -0
- package/lib/types/factories/IBotListV3.sol/IBotListV3Events__factory.js +138 -0
- package/lib/types/factories/IBotListV3.sol/IBotListV3__factory.d.ts +315 -0
- package/lib/types/factories/IBotListV3.sol/IBotListV3__factory.js +416 -0
- package/lib/types/factories/IBotListV3.sol/index.d.ts +2 -0
- package/lib/types/factories/IBotListV3.sol/index.js +10 -0
- package/lib/types/factories/ICompoundV2_CTokenAdapter.sol/ICompoundV2_CTokenAdapter__factory.d.ts +196 -0
- package/lib/types/factories/ICompoundV2_CTokenAdapter.sol/ICompoundV2_CTokenAdapter__factory.js +267 -0
- package/lib/types/factories/ICompoundV2_CTokenAdapter.sol/ICompoundV2_Exceptions__factory.d.ts +16 -0
- package/lib/types/factories/{ILidoV1Adapter.sol/ILidoV1AdapterEvents__factory.js → ICompoundV2_CTokenAdapter.sol/ICompoundV2_Exceptions__factory.js} +6 -8
- package/lib/types/factories/ICompoundV2_CTokenAdapter.sol/index.d.ts +2 -0
- package/lib/types/factories/ICompoundV2_CTokenAdapter.sol/index.js +10 -0
- package/lib/types/factories/IContractsRegister.sol/IContractsRegisterEvents__factory.d.ts +28 -0
- package/lib/types/factories/IContractsRegister.sol/IContractsRegisterEvents__factory.js +45 -0
- package/lib/types/factories/IContractsRegister.sol/IContractsRegister__factory.d.ts +134 -0
- package/lib/types/factories/IContractsRegister.sol/IContractsRegister__factory.js +186 -0
- package/lib/types/factories/IContractsRegister.sol/index.d.ts +2 -0
- package/lib/types/factories/IContractsRegister.sol/index.js +10 -0
- package/lib/types/factories/IControllerTimelockV3.sol/IControllerTimelockV3Events__factory.d.ts +73 -0
- package/lib/types/factories/IControllerTimelockV3.sol/IControllerTimelockV3Events__factory.js +101 -0
- package/lib/types/factories/IControllerTimelockV3.sol/IControllerTimelockV3__factory.d.ts +427 -0
- package/lib/types/factories/IControllerTimelockV3.sol/IControllerTimelockV3__factory.js +556 -0
- package/lib/types/factories/IControllerTimelockV3.sol/index.d.ts +2 -0
- package/lib/types/factories/IControllerTimelockV3.sol/index.js +10 -0
- package/lib/types/factories/IConvexToken__factory.d.ts +10 -0
- package/lib/types/factories/IConvexToken__factory.js +13 -0
- package/lib/types/factories/IConvexV1BaseRewardPoolAdapter__factory.d.ts +38 -6
- package/lib/types/factories/IConvexV1BaseRewardPoolAdapter__factory.js +48 -6
- package/lib/types/factories/IConvexV1BoosterAdapter.sol/IConvexV1BoosterAdapterEvents__factory.d.ts +23 -0
- package/lib/types/factories/IConvexV1BoosterAdapter.sol/IConvexV1BoosterAdapterEvents__factory.js +38 -0
- package/lib/types/factories/{IConvexV1BoosterAdapter__factory.d.ts → IConvexV1BoosterAdapter.sol/IConvexV1BoosterAdapter__factory.d.ts} +26 -3
- package/lib/types/factories/{IConvexV1BoosterAdapter__factory.js → IConvexV1BoosterAdapter.sol/IConvexV1BoosterAdapter__factory.js} +31 -2
- package/lib/types/factories/IConvexV1BoosterAdapter.sol/index.d.ts +2 -0
- package/lib/types/factories/IConvexV1BoosterAdapter.sol/index.js +10 -0
- package/lib/types/factories/ICreditConfiguratorV3.sol/ICreditConfiguratorV3Events__factory.d.ts +273 -0
- package/lib/types/factories/ICreditConfiguratorV3.sol/ICreditConfiguratorV3Events__factory.js +357 -0
- package/lib/types/factories/ICreditConfiguratorV3.sol/ICreditConfiguratorV3__factory.d.ts +605 -0
- package/lib/types/factories/ICreditConfiguratorV3.sol/ICreditConfiguratorV3__factory.js +785 -0
- package/lib/types/factories/ICreditConfiguratorV3.sol/index.d.ts +2 -0
- package/lib/types/factories/ICreditConfiguratorV3.sol/index.js +10 -0
- package/lib/types/factories/ICreditFacadeV2.sol/ICreditFacadeV2Extended__factory.d.ts +0 -4
- package/lib/types/factories/ICreditFacadeV2.sol/ICreditFacadeV2Extended__factory.js +0 -5
- package/lib/types/factories/ICreditFacadeV3.sol/ICreditFacadeV3Events__factory.d.ts +19 -24
- package/lib/types/factories/ICreditFacadeV3.sol/ICreditFacadeV3Events__factory.js +21 -27
- package/lib/types/factories/ICreditFacadeV3.sol/ICreditFacadeV3__factory.d.ts +151 -72
- package/lib/types/factories/ICreditFacadeV3.sol/ICreditFacadeV3__factory.js +189 -85
- package/lib/types/factories/ICreditFacadeV3Multicall__factory.d.ts +77 -43
- package/lib/types/factories/ICreditFacadeV3Multicall__factory.js +96 -54
- package/lib/types/factories/ICreditManagerV3.sol/ICreditManagerV3__factory.d.ts +339 -147
- package/lib/types/factories/ICreditManagerV3.sol/ICreditManagerV3__factory.js +427 -180
- package/lib/types/factories/ICurveV1Adapter__factory.d.ts +13 -71
- package/lib/types/factories/ICurveV1Adapter__factory.js +14 -91
- package/lib/types/factories/ICurveV1_2AssetsAdapter__factory.d.ts +13 -71
- package/lib/types/factories/ICurveV1_2AssetsAdapter__factory.js +14 -91
- package/lib/types/factories/ICurveV1_3AssetsAdapter__factory.d.ts +13 -71
- package/lib/types/factories/ICurveV1_3AssetsAdapter__factory.js +14 -91
- package/lib/types/factories/ICurveV1_4AssetsAdapter__factory.d.ts +13 -71
- package/lib/types/factories/ICurveV1_4AssetsAdapter__factory.js +14 -91
- package/lib/types/factories/IDataCompressorV2_10__factory.d.ts +110 -54
- package/lib/types/factories/IDataCompressorV2_10__factory.js +138 -68
- package/lib/types/factories/IDataCompressorV3_00__factory.d.ts +379 -79
- package/lib/types/factories/IDataCompressorV3_00__factory.js +481 -100
- package/lib/types/factories/IDegenNFTV2.sol/IDegenNFTV2Events__factory.d.ts +38 -0
- package/lib/types/factories/IDegenNFTV2.sol/IDegenNFTV2Events__factory.js +58 -0
- package/lib/types/factories/IDegenNFTV2.sol/IDegenNFTV2Exceptions__factory.d.ts +24 -0
- package/lib/types/factories/IDegenNFTV2.sol/IDegenNFTV2Exceptions__factory.js +39 -0
- package/lib/types/factories/{IWithdrawalManagerV3.sol/IWithdrawalManagerV3__factory.d.ts → IDegenNFTV2.sol/IDegenNFTV2__factory.d.ts} +190 -180
- package/lib/types/factories/{IWithdrawalManagerV3.sol/IWithdrawalManagerV3__factory.js → IDegenNFTV2.sol/IDegenNFTV2__factory.js} +212 -195
- package/lib/types/factories/IDegenNFTV2.sol/index.d.ts +3 -0
- package/lib/types/factories/IDegenNFTV2.sol/index.js +12 -0
- package/lib/types/factories/IERC165__factory.d.ts +22 -0
- package/lib/types/factories/IERC165__factory.js +38 -0
- package/lib/types/factories/{draft-IERC20Permit.sol/IERC20Permit__factory.d.ts → IERC20Permit__factory.d.ts} +1 -1
- package/lib/types/factories/IERC20ZapperDeposits__factory.d.ts +120 -0
- package/lib/types/factories/IERC20ZapperDeposits__factory.js +165 -0
- package/lib/types/factories/IERC4626Adapter__factory.d.ts +220 -0
- package/lib/types/factories/IERC4626Adapter__factory.js +297 -0
- package/lib/types/factories/IERC721Metadata__factory.d.ts +262 -0
- package/lib/types/factories/IERC721Metadata__factory.js +349 -0
- package/lib/types/factories/IERC721__factory.d.ts +228 -0
- package/lib/types/factories/IERC721__factory.js +304 -0
- package/lib/types/factories/IETHZapperDeposits__factory.d.ts +40 -0
- package/lib/types/factories/{AaveV2_WrappedAToken.sol/IWrappedATokenEvents__factory.js → IETHZapperDeposits__factory.js} +18 -25
- package/lib/types/factories/IGasPricer__factory.d.ts +22 -0
- package/lib/types/factories/IGasPricer__factory.js +38 -0
- package/lib/types/factories/IGaugeV3.sol/IGaugeV3Events__factory.d.ts +118 -0
- package/lib/types/factories/IGaugeV3.sol/IGaugeV3Events__factory.js +157 -0
- package/lib/types/factories/IGaugeV3.sol/IGaugeV3__factory.d.ts +342 -0
- package/lib/types/factories/IGaugeV3.sol/IGaugeV3__factory.js +448 -0
- package/lib/types/factories/IGaugeV3.sol/index.d.ts +2 -0
- package/lib/types/factories/IGaugeV3.sol/index.js +10 -0
- package/lib/types/factories/{IWithdrawalManagerV3.sol/IWithdrawalManagerV3Events__factory.d.ts → IGearStakingV3.sol/IGearStakingV3Events__factory.d.ts} +33 -63
- package/lib/types/factories/{IWithdrawalManagerV3.sol/IWithdrawalManagerV3Events__factory.js → IGearStakingV3.sol/IGearStakingV3Events__factory.js} +34 -70
- package/lib/types/factories/IGearStakingV3.sol/IGearStakingV3__factory.d.ts +504 -0
- package/lib/types/factories/IGearStakingV3.sol/IGearStakingV3__factory.js +660 -0
- package/lib/types/factories/IGearStakingV3.sol/index.d.ts +2 -0
- package/lib/types/factories/IGearStakingV3.sol/index.js +10 -0
- package/lib/types/factories/ILPPriceFeed.sol/ILPPriceFeedEvents__factory.d.ts +33 -0
- package/lib/types/factories/ILPPriceFeed.sol/ILPPriceFeedEvents__factory.js +51 -0
- package/lib/types/factories/ILPPriceFeed.sol/ILPPriceFeedExceptions__factory.d.ts +24 -0
- package/lib/types/factories/ILPPriceFeed.sol/ILPPriceFeedExceptions__factory.js +39 -0
- package/lib/types/factories/ILPPriceFeed.sol/ILPPriceFeed__factory.d.ts +257 -0
- package/lib/types/factories/ILPPriceFeed.sol/ILPPriceFeed__factory.js +339 -0
- package/lib/types/factories/ILPPriceFeed.sol/index.d.ts +3 -0
- package/lib/types/factories/ILPPriceFeed.sol/index.js +12 -0
- package/lib/types/factories/{ILidoV1Adapter.sol/ILidoV1Adapter__factory.d.ts → ILidoV1Adapter__factory.d.ts} +7 -37
- package/lib/types/factories/{ILidoV1Adapter.sol/ILidoV1Adapter__factory.js → ILidoV1Adapter__factory.js} +8 -46
- package/lib/types/factories/ILinearInterestRateModelV3__factory.d.ts +98 -0
- package/lib/types/factories/ILinearInterestRateModelV3__factory.js +136 -0
- package/lib/types/factories/IPoolQuotaKeeperV3.sol/IPoolQuotaKeeperV3Events__factory.d.ts +103 -0
- package/lib/types/factories/IPoolQuotaKeeperV3.sol/IPoolQuotaKeeperV3Events__factory.js +140 -0
- package/lib/types/factories/IPoolQuotaKeeperV3.sol/IPoolQuotaKeeperV3__factory.d.ts +441 -0
- package/lib/types/factories/IPoolQuotaKeeperV3.sol/IPoolQuotaKeeperV3__factory.js +580 -0
- package/lib/types/factories/IPoolQuotaKeeperV3.sol/index.d.ts +2 -0
- package/lib/types/factories/IPoolQuotaKeeperV3.sol/index.js +10 -0
- package/lib/types/factories/IPoolV3.sol/IPoolV3__factory.d.ts +62 -14
- package/lib/types/factories/IPoolV3.sol/IPoolV3__factory.js +79 -17
- package/lib/types/factories/IPoolV3.sol/index.d.ts +0 -1
- package/lib/types/factories/IPoolV3.sol/index.js +1 -3
- package/lib/types/factories/{IPoolV3.sol/IPoolBase__factory.d.ts → IPriceFeed.sol/IPriceFeed__factory.d.ts} +39 -35
- package/lib/types/factories/{IPoolV3.sol/IPoolBase__factory.js → IPriceFeed.sol/IPriceFeed__factory.js} +40 -35
- package/lib/types/factories/IPriceFeed.sol/IUpdatablePriceFeed__factory.d.ts +104 -0
- package/lib/types/factories/IPriceFeed.sol/IUpdatablePriceFeed__factory.js +143 -0
- package/lib/types/factories/IPriceFeed.sol/index.d.ts +2 -0
- package/lib/types/factories/IPriceFeed.sol/index.js +10 -0
- package/lib/types/factories/IPriceOracle.sol/IPriceOracleV2Events__factory.d.ts +23 -0
- package/lib/types/factories/IPriceOracle.sol/IPriceOracleV2Events__factory.js +38 -0
- package/lib/types/factories/IPriceOracle.sol/IPriceOracleV2Exceptions__factory.d.ts +20 -0
- package/lib/types/factories/IPriceOracle.sol/IPriceOracleV2Exceptions__factory.js +34 -0
- package/lib/types/factories/{IAToken__factory.d.ts → IPriceOracle.sol/IPriceOracleV2Ext__factory.d.ts} +98 -99
- package/lib/types/factories/IPriceOracle.sol/IPriceOracleV2Ext__factory.js +267 -0
- package/lib/types/factories/IPriceOracle.sol/IPriceOracleV2__factory.d.ts +183 -0
- package/lib/types/factories/{IAToken__factory.js → IPriceOracle.sol/IPriceOracleV2__factory.js} +94 -112
- package/lib/types/factories/IPriceOracle.sol/index.d.ts +4 -0
- package/lib/types/factories/IPriceOracle.sol/index.js +14 -0
- package/lib/types/factories/IPriceOracleV3.sol/IPriceOracleV3Events__factory.d.ts +78 -0
- package/lib/types/factories/IPriceOracleV3.sol/IPriceOracleV3Events__factory.js +106 -0
- package/lib/types/factories/IPriceOracleV3.sol/IPriceOracleV3__factory.d.ts +326 -0
- package/lib/types/factories/IPriceOracleV3.sol/IPriceOracleV3__factory.js +433 -0
- package/lib/types/factories/IPriceOracleV3.sol/index.d.ts +2 -0
- package/lib/types/factories/IPriceOracleV3.sol/index.js +10 -0
- package/lib/types/factories/IUniswapV2Adapter.sol/IUniswapV2Adapter__factory.d.ts +5 -1
- package/lib/types/factories/IUniswapV2Adapter.sol/IUniswapV2Adapter__factory.js +6 -1
- package/lib/types/factories/IUniswapV3Adapter.sol/IUniswapV3Adapter__factory.d.ts +12 -4
- package/lib/types/factories/IUniswapV3Adapter.sol/IUniswapV3Adapter__factory.js +14 -4
- package/lib/types/factories/IVotingContractV3__factory.d.ts +44 -0
- package/lib/types/factories/IVotingContractV3__factory.js +65 -0
- package/lib/types/factories/IYearnV2Adapter__factory.d.ts +21 -13
- package/lib/types/factories/IYearnV2Adapter__factory.js +27 -15
- package/lib/types/factories/IZapperRegister__factory.d.ts +42 -0
- package/lib/types/factories/IZapperRegister__factory.js +64 -0
- package/lib/types/factories/{WERC20ZapperBase__factory.d.ts → IZapper__factory.d.ts} +52 -64
- package/lib/types/factories/{WERC20ZapperBase__factory.js → IZapper__factory.js} +58 -74
- package/lib/types/factories/IwstETHV1Adapter__factory.d.ts +12 -4
- package/lib/types/factories/IwstETHV1Adapter__factory.js +16 -4
- package/lib/types/factories/SafeERC20__factory.d.ts +1 -1
- package/lib/types/factories/SafeERC20__factory.js +1 -1
- package/lib/types/factories/index.d.ts +32 -14
- package/lib/types/factories/index.js +49 -26
- package/lib/types/factories/{IRouter__factory.d.ts → interfaces/IRouter__factory.d.ts} +75 -6
- package/lib/types/factories/{IRouter__factory.js → interfaces/IRouter__factory.js} +96 -6
- package/lib/types/factories/interfaces/index.d.ts +1 -0
- package/lib/types/factories/interfaces/index.js +8 -0
- package/lib/types/index.d.ts +141 -46
- package/lib/types/index.js +109 -38
- package/lib/types/{IRouter.d.ts → interfaces/IRouter.d.ts} +48 -35
- package/lib/types/interfaces/IRouter.js +2 -0
- package/lib/types/interfaces/index.d.ts +1 -0
- package/lib/types/interfaces/index.js +2 -0
- package/lib/utils/formatter.d.ts +0 -3
- package/lib/utils/formatter.js +1 -67
- package/lib/utils/math.d.ts +2 -0
- package/lib/utils/math.js +2 -0
- package/lib/utils/types.d.ts +1 -0
- package/lib/watchers/creditAccountWatcher.d.ts +3 -2
- package/lib/watchers/creditAccountWatcher.js +19 -13
- package/lib/watchers/creditAccountWatcher.spec.js +18 -18
- package/lib/watchers/creditManagerWatcher.d.ts +5 -3
- package/lib/watchers/creditManagerWatcher.js +32 -10
- package/lib/watchers/creditManagerWatcher.spec.js +12 -4
- package/package.json +10 -9
- package/contracts/IRouter.sol +0 -100
- package/lib/core/pool/index.d.ts +0 -1
- package/lib/core/pool/index.js +0 -17
- package/lib/types/AaveV2_WrappedAToken.sol/IWrappedATokenEvents.d.ts +0 -60
- package/lib/types/AaveV2_WrappedAToken.sol/WrappedAToken.d.ts +0 -332
- package/lib/types/AaveV2_WrappedAToken.sol/index.d.ts +0 -2
- package/lib/types/ERC20.d.ts +0 -198
- package/lib/types/IAToken.d.ts +0 -182
- package/lib/types/ILendingPool.d.ts +0 -140
- package/lib/types/ILidoV1Adapter.sol/index.d.ts +0 -3
- package/lib/types/IPoolV3.sol/IPoolBase.d.ts +0 -102
- package/lib/types/IWithdrawalManagerV3.sol/IWithdrawalManagerV3.d.ts +0 -370
- package/lib/types/IWithdrawalManagerV3.sol/IWithdrawalManagerV3Events.d.ts +0 -133
- package/lib/types/IWithdrawalManagerV3.sol/index.d.ts +0 -2
- package/lib/types/WATokenZapper.d.ts +0 -134
- package/lib/types/WERC20ZapperBase.d.ts +0 -134
- package/lib/types/WETHZapper.d.ts +0 -122
- package/lib/types/WstETHZapper.d.ts +0 -134
- package/lib/types/ZapperBase.d.ts +0 -70
- package/lib/types/draft-IERC20Permit.sol/index.d.ts +0 -1
- package/lib/types/factories/AaveV2_WrappedAToken.sol/IWrappedATokenEvents__factory.d.ts +0 -48
- package/lib/types/factories/AaveV2_WrappedAToken.sol/WrappedAToken__factory.d.ts +0 -397
- package/lib/types/factories/AaveV2_WrappedAToken.sol/WrappedAToken__factory.js +0 -535
- package/lib/types/factories/AaveV2_WrappedAToken.sol/index.d.ts +0 -2
- package/lib/types/factories/AaveV2_WrappedAToken.sol/index.js +0 -10
- package/lib/types/factories/ERC20__factory.d.ts +0 -239
- package/lib/types/factories/ERC20__factory.js +0 -328
- package/lib/types/factories/ILendingPool__factory.d.ts +0 -134
- package/lib/types/factories/ILendingPool__factory.js +0 -183
- package/lib/types/factories/ILidoV1Adapter.sol/ILidoV1AdapterEvents__factory.d.ts +0 -18
- package/lib/types/factories/ILidoV1Adapter.sol/ILidoV1AdapterExceptions__factory.d.ts +0 -12
- package/lib/types/factories/ILidoV1Adapter.sol/index.d.ts +0 -3
- package/lib/types/factories/ILidoV1Adapter.sol/index.js +0 -12
- package/lib/types/factories/IWithdrawalManagerV3.sol/index.d.ts +0 -2
- package/lib/types/factories/IWithdrawalManagerV3.sol/index.js +0 -10
- package/lib/types/factories/WATokenZapper__factory.d.ts +0 -161
- package/lib/types/factories/WATokenZapper__factory.js +0 -227
- package/lib/types/factories/WETHZapper__factory.d.ts +0 -138
- package/lib/types/factories/WETHZapper__factory.js +0 -198
- package/lib/types/factories/WstETHZapper__factory.d.ts +0 -161
- package/lib/types/factories/WstETHZapper__factory.js +0 -227
- package/lib/types/factories/ZapperBase__factory.d.ts +0 -60
- package/lib/types/factories/draft-IERC20Permit.sol/index.d.ts +0 -1
- package/lib/types/factories/draft-IERC20Permit.sol/index.js +0 -8
- /package/lib/{types/AaveV2_WrappedAToken.sol/IWrappedATokenEvents.js → payload/gauge.js} +0 -0
- /package/lib/types/{AaveV2_WrappedAToken.sol/WrappedAToken.js → IAaveV2_LendingPoolAdapter.js} +0 -0
- /package/lib/types/{AaveV2_WrappedAToken.sol/index.js → IAaveV2_WrappedATokenAdapter.js} +0 -0
- /package/lib/types/{ERC20.js → IBalancerV2Vault.sol/IBalancerV2Vault.js} +0 -0
- /package/lib/types/{IAToken.js → IBalancerV2Vault.sol/IBalancerV2VaultGetters.js} +0 -0
- /package/lib/types/{ILidoV1Adapter.sol → IBalancerV2Vault.sol}/index.js +0 -0
- /package/lib/types/{IConvexV1BoosterAdapter.js → IBalancerV2VaultAdapter.sol/IBalancerV2VaultAdapter.js} +0 -0
- /package/lib/types/{ILendingPool.js → IBalancerV2VaultAdapter.sol/IBalancerV2VaultAdapterEvents.js} +0 -0
- /package/lib/types/{ILidoV1Adapter.sol/ILidoV1Adapter.js → IBalancerV2VaultAdapter.sol/IBalancerV2VaultAdapterExceptions.js} +0 -0
- /package/lib/types/{IWithdrawalManagerV3.sol → IBalancerV2VaultAdapter.sol}/index.js +0 -0
- /package/lib/types/{ILidoV1Adapter.sol/ILidoV1AdapterEvents.js → IBotListV3.sol/IBotListV3.js} +0 -0
- /package/lib/types/{ILidoV1Adapter.sol/ILidoV1AdapterExceptions.js → IBotListV3.sol/IBotListV3Events.js} +0 -0
- /package/lib/types/{draft-IERC20Permit.sol → IBotListV3.sol}/index.js +0 -0
- /package/lib/types/{IPoolV3.sol/IPoolBase.js → ICompoundV2_CTokenAdapter.sol/ICompoundV2_CTokenAdapter.js} +0 -0
- /package/lib/types/{IRouter.js → ICompoundV2_CTokenAdapter.sol/ICompoundV2_Exceptions.js} +0 -0
- /package/lib/types/{IWithdrawalManagerV3.sol/IWithdrawalManagerV3.js → ICompoundV2_CTokenAdapter.sol/index.js} +0 -0
- /package/lib/types/{IWithdrawalManagerV3.sol/IWithdrawalManagerV3Events.js → IContractsRegister.sol/IContractsRegister.js} +0 -0
- /package/lib/types/{WATokenZapper.js → IContractsRegister.sol/IContractsRegisterEvents.js} +0 -0
- /package/lib/types/{WERC20ZapperBase.js → IContractsRegister.sol/index.js} +0 -0
- /package/lib/types/{WETHZapper.js → IControllerTimelockV3.sol/IControllerTimelockV3.js} +0 -0
- /package/lib/types/{WstETHZapper.js → IControllerTimelockV3.sol/IControllerTimelockV3Events.js} +0 -0
- /package/lib/types/{ZapperBase.js → IControllerTimelockV3.sol/index.js} +0 -0
- /package/lib/types/{draft-IERC20Permit.sol/IERC20Permit.js → IConvexV1BoosterAdapter.sol/IConvexV1BoosterAdapter.js} +0 -0
- /package/lib/types/factories/{draft-IERC20Permit.sol/IERC20Permit__factory.js → IERC20Permit__factory.js} +0 -0
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const chai_1 = require("chai");
|
|
4
|
+
const gaugeMath_1 = require("./gaugeMath");
|
|
5
|
+
describe("GaugeMath vote() test", () => {
|
|
6
|
+
it("with empty state and with no changes", () => {
|
|
7
|
+
const s = { available: 0n, voteCalls: [] };
|
|
8
|
+
const v = { state: s };
|
|
9
|
+
const r = gaugeMath_1.GaugeMath.vote(v);
|
|
10
|
+
const res = { ...s, voteCalls: [] };
|
|
11
|
+
(0, chai_1.expect)(r).to.be.eql(res);
|
|
12
|
+
});
|
|
13
|
+
it("remove with no prev vote", () => {
|
|
14
|
+
const s = { available: 0n, voteCalls: [] };
|
|
15
|
+
const v = { state: s, change: { type: "remove", amount: 10n } };
|
|
16
|
+
const r = gaugeMath_1.GaugeMath.vote(v);
|
|
17
|
+
const res = { ...s, voteCalls: [] };
|
|
18
|
+
(0, chai_1.expect)(r).to.be.eql(res);
|
|
19
|
+
});
|
|
20
|
+
it("remove with prev vote - more than available", () => {
|
|
21
|
+
const s = {
|
|
22
|
+
available: 0n,
|
|
23
|
+
vote: { type: "lower", amount: 5n },
|
|
24
|
+
voteCalls: [],
|
|
25
|
+
};
|
|
26
|
+
const v = { state: s, change: { type: "remove", amount: 10n } };
|
|
27
|
+
const r = gaugeMath_1.GaugeMath.vote(v);
|
|
28
|
+
const res = {
|
|
29
|
+
available: 5n,
|
|
30
|
+
vote: { type: "lower", amount: 0n },
|
|
31
|
+
voteCalls: [{ type: "remove", amount: 5n }],
|
|
32
|
+
};
|
|
33
|
+
(0, chai_1.expect)(r).to.be.eql(res);
|
|
34
|
+
});
|
|
35
|
+
it("remove with prev vote - eq than available", () => {
|
|
36
|
+
const s = {
|
|
37
|
+
available: 0n,
|
|
38
|
+
vote: { type: "lower", amount: 5n },
|
|
39
|
+
voteCalls: [],
|
|
40
|
+
};
|
|
41
|
+
const v = { state: s, change: { type: "remove", amount: 5n } };
|
|
42
|
+
const r = gaugeMath_1.GaugeMath.vote(v);
|
|
43
|
+
const res = {
|
|
44
|
+
available: 5n,
|
|
45
|
+
vote: { type: "lower", amount: 0n },
|
|
46
|
+
voteCalls: [{ type: "remove", amount: 5n }],
|
|
47
|
+
};
|
|
48
|
+
(0, chai_1.expect)(r).to.be.eql(res);
|
|
49
|
+
});
|
|
50
|
+
it("remove with prev vote - more than available", () => {
|
|
51
|
+
const s = {
|
|
52
|
+
available: 0n,
|
|
53
|
+
vote: { type: "lower", amount: 10n },
|
|
54
|
+
voteCalls: [],
|
|
55
|
+
};
|
|
56
|
+
const v = { state: s, change: { type: "remove", amount: 5n } };
|
|
57
|
+
const r = gaugeMath_1.GaugeMath.vote(v);
|
|
58
|
+
const res = {
|
|
59
|
+
available: 5n,
|
|
60
|
+
vote: { type: "lower", amount: 5n },
|
|
61
|
+
voteCalls: [{ type: "remove", amount: 5n }],
|
|
62
|
+
};
|
|
63
|
+
(0, chai_1.expect)(r).to.be.eql(res);
|
|
64
|
+
});
|
|
65
|
+
it("add to zero", () => {
|
|
66
|
+
const s = { available: 10n, voteCalls: [] };
|
|
67
|
+
const v = { state: s, change: { type: "lower", amount: 10n } };
|
|
68
|
+
const r = gaugeMath_1.GaugeMath.vote(v);
|
|
69
|
+
const res = {
|
|
70
|
+
available: 0n,
|
|
71
|
+
vote: { type: "lower", amount: 10n },
|
|
72
|
+
voteCalls: [{ type: "lower", amount: 10n }],
|
|
73
|
+
};
|
|
74
|
+
(0, chai_1.expect)(r).to.be.eql(res);
|
|
75
|
+
});
|
|
76
|
+
it("add to same type", () => {
|
|
77
|
+
const s = {
|
|
78
|
+
available: 10n,
|
|
79
|
+
vote: { type: "lower", amount: 5n },
|
|
80
|
+
voteCalls: [],
|
|
81
|
+
};
|
|
82
|
+
const v = { state: s, change: { type: "lower", amount: 10n } };
|
|
83
|
+
const r = gaugeMath_1.GaugeMath.vote(v);
|
|
84
|
+
const res = {
|
|
85
|
+
available: 0n,
|
|
86
|
+
vote: { type: "lower", amount: 15n },
|
|
87
|
+
voteCalls: [{ type: "lower", amount: 10n }],
|
|
88
|
+
};
|
|
89
|
+
(0, chai_1.expect)(r).to.be.eql(res);
|
|
90
|
+
});
|
|
91
|
+
it("add different type", () => {
|
|
92
|
+
const s = {
|
|
93
|
+
available: 10n,
|
|
94
|
+
vote: { type: "lower", amount: 10n },
|
|
95
|
+
voteCalls: [],
|
|
96
|
+
};
|
|
97
|
+
const v = { state: s, change: { type: "raise", amount: 5n } };
|
|
98
|
+
const r = gaugeMath_1.GaugeMath.vote(v);
|
|
99
|
+
const res = {
|
|
100
|
+
available: 15n,
|
|
101
|
+
vote: { type: "raise", amount: 5n },
|
|
102
|
+
voteCalls: [
|
|
103
|
+
{ type: "remove", amount: 10n },
|
|
104
|
+
{ type: "raise", amount: 5n },
|
|
105
|
+
],
|
|
106
|
+
};
|
|
107
|
+
(0, chai_1.expect)(r).to.be.eql(res);
|
|
108
|
+
});
|
|
109
|
+
it("available can be negative after add", () => {
|
|
110
|
+
const s = {
|
|
111
|
+
available: 5n,
|
|
112
|
+
vote: { type: "lower", amount: 5n },
|
|
113
|
+
voteCalls: [],
|
|
114
|
+
};
|
|
115
|
+
const v = { state: s, change: { type: "raise", amount: 15n } };
|
|
116
|
+
const r = gaugeMath_1.GaugeMath.vote(v);
|
|
117
|
+
const res = {
|
|
118
|
+
available: -5n,
|
|
119
|
+
vote: { type: "raise", amount: 15n },
|
|
120
|
+
voteCalls: [
|
|
121
|
+
{ type: "remove", amount: 5n },
|
|
122
|
+
{ type: "raise", amount: 15n },
|
|
123
|
+
],
|
|
124
|
+
};
|
|
125
|
+
(0, chai_1.expect)(r).to.be.eql(res);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
describe("GaugeMath revertVote() test", () => {
|
|
129
|
+
it("if no votes before & after, should return initial amount", () => {
|
|
130
|
+
const initialBalance = 21n;
|
|
131
|
+
const r = gaugeMath_1.GaugeMath.revertVote({
|
|
132
|
+
balanceAfter: initialBalance,
|
|
133
|
+
nextVoteType: "lower",
|
|
134
|
+
});
|
|
135
|
+
(0, chai_1.expect)(r).to.be.eql(initialBalance);
|
|
136
|
+
});
|
|
137
|
+
it("if no vote after and next expected type is not changed, should return initial amount", () => {
|
|
138
|
+
const initialBalance = 27n;
|
|
139
|
+
const initialVote = {
|
|
140
|
+
type: "lower",
|
|
141
|
+
amount: 99n,
|
|
142
|
+
};
|
|
143
|
+
const r = gaugeMath_1.GaugeMath.revertVote({
|
|
144
|
+
balanceAfter: initialBalance,
|
|
145
|
+
initialVote,
|
|
146
|
+
nextVoteType: "lower",
|
|
147
|
+
});
|
|
148
|
+
(0, chai_1.expect)(r).to.be.eql(initialBalance);
|
|
149
|
+
});
|
|
150
|
+
it("if no vote after and next expected type is changed, should revert initial vote", () => {
|
|
151
|
+
const initialBalance = 27n;
|
|
152
|
+
const initialVote = {
|
|
153
|
+
type: "lower",
|
|
154
|
+
amount: 99n,
|
|
155
|
+
};
|
|
156
|
+
const r = gaugeMath_1.GaugeMath.revertVote({
|
|
157
|
+
balanceAfter: initialBalance,
|
|
158
|
+
initialVote,
|
|
159
|
+
nextVoteType: "raise",
|
|
160
|
+
});
|
|
161
|
+
(0, chai_1.expect)(r).to.be.eql(initialBalance + initialVote.amount);
|
|
162
|
+
});
|
|
163
|
+
it("if no vote before, should revert vote after", () => {
|
|
164
|
+
const initialBalance = 26n;
|
|
165
|
+
const voteBy = 5n;
|
|
166
|
+
const voteAfter = {
|
|
167
|
+
available: initialBalance - voteBy,
|
|
168
|
+
vote: { type: "lower", amount: voteBy },
|
|
169
|
+
voteCalls: [{ type: "lower", amount: voteBy }],
|
|
170
|
+
};
|
|
171
|
+
const balanceAfter = voteAfter.available;
|
|
172
|
+
const r = gaugeMath_1.GaugeMath.revertVote({
|
|
173
|
+
balanceAfter,
|
|
174
|
+
nextVoteType: "lower",
|
|
175
|
+
voteAfter: voteAfter,
|
|
176
|
+
});
|
|
177
|
+
(0, chai_1.expect)(r).to.be.eql(initialBalance);
|
|
178
|
+
});
|
|
179
|
+
it("if vote before type matches expected type, should revert vote after", () => {
|
|
180
|
+
const initialBalance = 10n;
|
|
181
|
+
const voteBy = 6n;
|
|
182
|
+
const initialVote = {
|
|
183
|
+
type: "lower",
|
|
184
|
+
amount: 20n,
|
|
185
|
+
};
|
|
186
|
+
const voteAfter = {
|
|
187
|
+
available: initialBalance - voteBy,
|
|
188
|
+
vote: { type: "lower", amount: initialVote.amount + voteBy },
|
|
189
|
+
voteCalls: [{ type: "lower", amount: voteBy }],
|
|
190
|
+
};
|
|
191
|
+
const balanceAfter = voteAfter.available;
|
|
192
|
+
const r = gaugeMath_1.GaugeMath.revertVote({
|
|
193
|
+
initialVote,
|
|
194
|
+
balanceAfter,
|
|
195
|
+
nextVoteType: "lower",
|
|
196
|
+
voteAfter: voteAfter,
|
|
197
|
+
});
|
|
198
|
+
(0, chai_1.expect)(r).to.be.eql(initialBalance);
|
|
199
|
+
});
|
|
200
|
+
it("if vote before type doesn't match expected type, should revert vote before", () => {
|
|
201
|
+
const initialBalance = 10n;
|
|
202
|
+
const voteBy = 20n;
|
|
203
|
+
const initialVote = {
|
|
204
|
+
type: "raise",
|
|
205
|
+
amount: 61n,
|
|
206
|
+
};
|
|
207
|
+
const voteAfter = {
|
|
208
|
+
available: initialBalance + initialVote.amount - voteBy,
|
|
209
|
+
vote: { type: "lower", amount: voteBy },
|
|
210
|
+
voteCalls: [
|
|
211
|
+
{ type: "remove", amount: initialVote.amount },
|
|
212
|
+
{ type: "lower", amount: voteBy },
|
|
213
|
+
],
|
|
214
|
+
};
|
|
215
|
+
const r = gaugeMath_1.GaugeMath.revertVote({
|
|
216
|
+
initialVote,
|
|
217
|
+
balanceAfter: voteAfter.available,
|
|
218
|
+
nextVoteType: "lower",
|
|
219
|
+
voteAfter: voteAfter,
|
|
220
|
+
});
|
|
221
|
+
(0, chai_1.expect)(r).to.be.eql(initialBalance + initialVote.amount);
|
|
222
|
+
});
|
|
223
|
+
it("on remove, if vote before type matches expected type, should revert removal", () => {
|
|
224
|
+
const initialBalance = 100n;
|
|
225
|
+
const voteBy = 13n;
|
|
226
|
+
const initialVote = {
|
|
227
|
+
type: "lower",
|
|
228
|
+
amount: 30n,
|
|
229
|
+
};
|
|
230
|
+
const voteAfter = {
|
|
231
|
+
available: initialBalance + voteBy,
|
|
232
|
+
vote: { type: "lower", amount: initialVote.amount - voteBy },
|
|
233
|
+
voteCalls: [{ type: "remove", amount: voteBy }],
|
|
234
|
+
};
|
|
235
|
+
const r = gaugeMath_1.GaugeMath.revertVote({
|
|
236
|
+
initialVote,
|
|
237
|
+
balanceAfter: voteAfter.available,
|
|
238
|
+
nextVoteType: "lower",
|
|
239
|
+
voteAfter: voteAfter,
|
|
240
|
+
});
|
|
241
|
+
(0, chai_1.expect)(r).to.be.eql(initialBalance);
|
|
242
|
+
});
|
|
243
|
+
it("on remove, if vote before type doesn't match expected type, should revert vote before", () => {
|
|
244
|
+
const initialBalance = 100n;
|
|
245
|
+
const voteBy = 13n;
|
|
246
|
+
const initialVote = {
|
|
247
|
+
type: "raise",
|
|
248
|
+
amount: 30n,
|
|
249
|
+
};
|
|
250
|
+
const voteAfter = {
|
|
251
|
+
available: initialBalance + voteBy,
|
|
252
|
+
vote: { type: "raise", amount: initialVote.amount - voteBy },
|
|
253
|
+
voteCalls: [{ type: "remove", amount: voteBy }],
|
|
254
|
+
};
|
|
255
|
+
const r = gaugeMath_1.GaugeMath.revertVote({
|
|
256
|
+
initialVote,
|
|
257
|
+
balanceAfter: voteAfter.available,
|
|
258
|
+
nextVoteType: "lower",
|
|
259
|
+
voteAfter: voteAfter,
|
|
260
|
+
});
|
|
261
|
+
(0, chai_1.expect)(r).to.be.eql(initialBalance + initialVote.amount);
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
describe("GaugeMath getGaugeApy() test", () => {
|
|
265
|
+
it("should return null if no quota", () => {
|
|
266
|
+
const vote = { amount: 0n, type: "lower" };
|
|
267
|
+
const voteAfter = {
|
|
268
|
+
vote: { amount: 5n, type: "lower" },
|
|
269
|
+
voteCalls: [{ amount: 5n, type: "lower" }],
|
|
270
|
+
};
|
|
271
|
+
const r = gaugeMath_1.GaugeMath.getGaugeApy({
|
|
272
|
+
quota: undefined,
|
|
273
|
+
vote,
|
|
274
|
+
voteAfter,
|
|
275
|
+
});
|
|
276
|
+
(0, chai_1.expect)(r).to.be.eql(null);
|
|
277
|
+
});
|
|
278
|
+
it("should return min rate if total is zero", () => {
|
|
279
|
+
const quota = {
|
|
280
|
+
totalVotesCaSide: 0n,
|
|
281
|
+
totalVotesLpSide: 0n,
|
|
282
|
+
stakerVotesCaSide: 0n,
|
|
283
|
+
stakerVotesLpSide: 0n,
|
|
284
|
+
minRate: 12,
|
|
285
|
+
maxRate: 12345,
|
|
286
|
+
};
|
|
287
|
+
const r = gaugeMath_1.GaugeMath.getGaugeApy({
|
|
288
|
+
quota,
|
|
289
|
+
});
|
|
290
|
+
(0, chai_1.expect)(r).to.be.eql(12);
|
|
291
|
+
});
|
|
292
|
+
it("should calculate quota without votes", () => {
|
|
293
|
+
const quota = {
|
|
294
|
+
totalVotesCaSide: 100n,
|
|
295
|
+
totalVotesLpSide: 100n,
|
|
296
|
+
stakerVotesCaSide: 10n,
|
|
297
|
+
stakerVotesLpSide: 0n,
|
|
298
|
+
minRate: 0,
|
|
299
|
+
maxRate: 10000,
|
|
300
|
+
};
|
|
301
|
+
const r = gaugeMath_1.GaugeMath.getGaugeApy({
|
|
302
|
+
quota,
|
|
303
|
+
});
|
|
304
|
+
(0, chai_1.expect)(r).to.be.eql(5000);
|
|
305
|
+
});
|
|
306
|
+
it("should calculate quota with prev vote", () => {
|
|
307
|
+
const quota = {
|
|
308
|
+
totalVotesCaSide: 100n,
|
|
309
|
+
totalVotesLpSide: 100n,
|
|
310
|
+
stakerVotesCaSide: 10n,
|
|
311
|
+
stakerVotesLpSide: 0n,
|
|
312
|
+
minRate: 0,
|
|
313
|
+
maxRate: 10000,
|
|
314
|
+
};
|
|
315
|
+
const vote = { amount: 10n, type: "lower" };
|
|
316
|
+
const r = gaugeMath_1.GaugeMath.getGaugeApy({
|
|
317
|
+
quota,
|
|
318
|
+
vote,
|
|
319
|
+
});
|
|
320
|
+
(0, chai_1.expect)(r).to.be.eql(5000);
|
|
321
|
+
});
|
|
322
|
+
it("should calculate quota with same vote increase", () => {
|
|
323
|
+
const quota = {
|
|
324
|
+
totalVotesCaSide: 100n,
|
|
325
|
+
totalVotesLpSide: 100n,
|
|
326
|
+
stakerVotesCaSide: 10n,
|
|
327
|
+
stakerVotesLpSide: 0n,
|
|
328
|
+
minRate: 0,
|
|
329
|
+
maxRate: 10000,
|
|
330
|
+
};
|
|
331
|
+
const vote = { amount: 10n, type: "lower" };
|
|
332
|
+
const voteAfter = {
|
|
333
|
+
vote: { amount: 20n, type: "lower" },
|
|
334
|
+
voteCalls: [{ amount: 10n, type: "lower" }],
|
|
335
|
+
};
|
|
336
|
+
const r = gaugeMath_1.GaugeMath.getGaugeApy({
|
|
337
|
+
quota,
|
|
338
|
+
vote,
|
|
339
|
+
voteAfter,
|
|
340
|
+
});
|
|
341
|
+
(0, chai_1.expect)(r).to.be.eql(4761);
|
|
342
|
+
});
|
|
343
|
+
it("should calculate quota with different vote increase", () => {
|
|
344
|
+
const quota = {
|
|
345
|
+
totalVotesCaSide: 100n,
|
|
346
|
+
totalVotesLpSide: 100n,
|
|
347
|
+
stakerVotesCaSide: 20n,
|
|
348
|
+
stakerVotesLpSide: 0n,
|
|
349
|
+
minRate: 0,
|
|
350
|
+
maxRate: 10000,
|
|
351
|
+
};
|
|
352
|
+
const vote = { amount: 30n, type: "lower" };
|
|
353
|
+
const voteAfter = {
|
|
354
|
+
vote: { amount: 20n, type: "raise" },
|
|
355
|
+
voteCalls: [
|
|
356
|
+
{ amount: 30n, type: "remove" },
|
|
357
|
+
{ amount: 20n, type: "raise" },
|
|
358
|
+
],
|
|
359
|
+
};
|
|
360
|
+
const r = gaugeMath_1.GaugeMath.getGaugeApy({
|
|
361
|
+
quota,
|
|
362
|
+
vote,
|
|
363
|
+
voteAfter,
|
|
364
|
+
});
|
|
365
|
+
(0, chai_1.expect)(r).to.be.eql(6315);
|
|
366
|
+
});
|
|
367
|
+
it("should calculate quota with vote remove", () => {
|
|
368
|
+
const quota = {
|
|
369
|
+
totalVotesCaSide: 100n,
|
|
370
|
+
totalVotesLpSide: 100n,
|
|
371
|
+
stakerVotesCaSide: 20n,
|
|
372
|
+
stakerVotesLpSide: 0n,
|
|
373
|
+
minRate: 0,
|
|
374
|
+
maxRate: 10000,
|
|
375
|
+
};
|
|
376
|
+
const vote = { amount: 20n, type: "lower" };
|
|
377
|
+
const voteAfter = {
|
|
378
|
+
vote: { amount: 0n, type: "lower" },
|
|
379
|
+
voteCalls: [{ amount: 20n, type: "remove" }],
|
|
380
|
+
};
|
|
381
|
+
const r = gaugeMath_1.GaugeMath.getGaugeApy({
|
|
382
|
+
quota,
|
|
383
|
+
vote,
|
|
384
|
+
voteAfter,
|
|
385
|
+
});
|
|
386
|
+
(0, chai_1.expect)(r).to.be.eql(5555);
|
|
387
|
+
});
|
|
388
|
+
});
|
|
@@ -1,36 +1,43 @@
|
|
|
1
1
|
import { providers, Signer } from "ethers";
|
|
2
|
-
import { CreditManagerDebtParams, QuotaInfo } from "
|
|
3
|
-
import { ChartsPoolDataPayload, LinearModel, PoolDataPayload, UserPoolPayload } from "
|
|
4
|
-
import { IPoolService, IPoolV3 } from "
|
|
2
|
+
import { CreditManagerDebtParams, QuotaInfo } from "../payload/creditManager";
|
|
3
|
+
import { ChartsPoolDataPayload, LinearModel, PoolDataPayload, PoolZapper, UserPoolPayload } from "../payload/pool";
|
|
4
|
+
import { IPoolService, IPoolV3 } from "../types";
|
|
5
|
+
export type PoolType = "universal" | "trade" | "farm";
|
|
5
6
|
export declare class PoolData {
|
|
6
7
|
readonly address: string;
|
|
8
|
+
readonly type: PoolType;
|
|
7
9
|
readonly underlyingToken: string;
|
|
8
10
|
readonly dieselToken: string;
|
|
9
|
-
readonly isWETH: boolean;
|
|
10
|
-
readonly isWSTETH: boolean;
|
|
11
11
|
readonly isPaused: boolean;
|
|
12
12
|
readonly version: number;
|
|
13
|
+
readonly poolQuotaKeeper: string;
|
|
14
|
+
readonly gauge: string;
|
|
15
|
+
readonly name: string;
|
|
16
|
+
readonly symbol: string;
|
|
13
17
|
readonly expectedLiquidity: bigint;
|
|
14
18
|
readonly expectedLiquidityLimit: bigint;
|
|
15
19
|
readonly availableLiquidity: bigint;
|
|
16
|
-
readonly
|
|
20
|
+
readonly baseInterestIndex: bigint;
|
|
17
21
|
readonly totalBorrowed: bigint;
|
|
18
22
|
readonly totalDebtLimit: bigint;
|
|
19
|
-
readonly creditManagerDebtParams:
|
|
20
|
-
readonly quotas:
|
|
23
|
+
readonly creditManagerDebtParams: Record<string, CreditManagerDebtParams>;
|
|
24
|
+
readonly quotas: Record<string, QuotaInfo>;
|
|
25
|
+
readonly zappers: Record<string, Record<string, PoolZapper>>;
|
|
21
26
|
readonly totalAssets: bigint;
|
|
22
27
|
readonly totalSupply: bigint;
|
|
28
|
+
readonly supplyAPY7D: number | undefined;
|
|
23
29
|
readonly depositAPY: number;
|
|
24
30
|
readonly borrowAPY: number;
|
|
25
31
|
readonly interestModel: LinearModel;
|
|
26
32
|
readonly dieselRate: number;
|
|
27
33
|
readonly dieselRateRay: bigint;
|
|
28
34
|
readonly withdrawFee: number;
|
|
29
|
-
readonly
|
|
35
|
+
readonly lastBaseInterestUpdate: bigint;
|
|
30
36
|
constructor(payload: PoolDataPayload);
|
|
31
|
-
|
|
37
|
+
getPoolContractV1(signer: Signer): IPoolService;
|
|
32
38
|
getPoolContractV3(signer: Signer): IPoolV3;
|
|
33
39
|
calculateBorrowRate({ provider, expectedLiquidity, availableLiquidity, }: CalculateBorrowRateProps): Promise<import("ethers").BigNumber>;
|
|
40
|
+
static getPoolType(name: string): PoolType;
|
|
34
41
|
}
|
|
35
42
|
interface CalculateBorrowRateProps {
|
|
36
43
|
provider: providers.Provider;
|
|
@@ -2,68 +2,100 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UserPoolData = exports.ChartsPoolData = exports.PoolData = void 0;
|
|
4
4
|
const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
5
|
-
const types_1 = require("
|
|
6
|
-
const formatter_1 = require("
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
const formatter_1 = require("../utils/formatter");
|
|
7
7
|
class PoolData {
|
|
8
8
|
address;
|
|
9
|
+
type;
|
|
9
10
|
underlyingToken;
|
|
10
11
|
dieselToken;
|
|
11
|
-
isWETH;
|
|
12
|
-
isWSTETH;
|
|
13
12
|
isPaused;
|
|
14
13
|
version;
|
|
14
|
+
poolQuotaKeeper;
|
|
15
|
+
gauge;
|
|
16
|
+
name;
|
|
17
|
+
symbol;
|
|
15
18
|
// Information
|
|
16
19
|
expectedLiquidity;
|
|
17
20
|
expectedLiquidityLimit;
|
|
18
21
|
availableLiquidity;
|
|
19
|
-
|
|
22
|
+
baseInterestIndex;
|
|
20
23
|
totalBorrowed;
|
|
21
24
|
totalDebtLimit;
|
|
22
25
|
creditManagerDebtParams;
|
|
23
26
|
quotas;
|
|
27
|
+
zappers;
|
|
24
28
|
totalAssets;
|
|
25
29
|
totalSupply;
|
|
30
|
+
supplyAPY7D;
|
|
26
31
|
depositAPY;
|
|
27
32
|
borrowAPY;
|
|
28
33
|
interestModel;
|
|
29
34
|
dieselRate;
|
|
30
35
|
dieselRateRay;
|
|
31
36
|
withdrawFee;
|
|
32
|
-
|
|
37
|
+
lastBaseInterestUpdate;
|
|
33
38
|
constructor(payload) {
|
|
34
39
|
this.address = payload.addr.toLowerCase();
|
|
35
|
-
|
|
40
|
+
this.type = PoolData.getPoolType(payload.name || "");
|
|
36
41
|
this.underlyingToken = payload.underlying.toLowerCase();
|
|
37
42
|
this.dieselToken = payload.dieselToken.toLowerCase();
|
|
38
|
-
this.isWETH = sdk_gov_1.tokenSymbolByAddress[underlying] === "WETH";
|
|
39
|
-
this.isWSTETH = sdk_gov_1.tokenSymbolByAddress[underlying] === "wstETH";
|
|
40
43
|
this.isPaused = payload.isPaused;
|
|
41
44
|
this.version = payload.version.toNumber();
|
|
45
|
+
this.poolQuotaKeeper = payload.poolQuotaKeeper.toLowerCase();
|
|
46
|
+
this.gauge = payload.gauge.toLowerCase();
|
|
47
|
+
this.name = payload.name;
|
|
48
|
+
this.symbol = payload.symbol;
|
|
42
49
|
this.expectedLiquidity = (0, sdk_gov_1.toBigInt)(payload.expectedLiquidity);
|
|
43
50
|
this.availableLiquidity = (0, sdk_gov_1.toBigInt)(payload.availableLiquidity);
|
|
44
51
|
this.expectedLiquidityLimit =
|
|
45
52
|
this.expectedLiquidity + this.availableLiquidity;
|
|
46
|
-
this.
|
|
53
|
+
this.baseInterestIndex = (0, sdk_gov_1.toBigInt)(payload.baseInterestIndex);
|
|
47
54
|
this.totalBorrowed = (0, sdk_gov_1.toBigInt)(payload.totalBorrowed);
|
|
48
55
|
this.totalDebtLimit = (0, sdk_gov_1.toBigInt)(payload.totalDebtLimit);
|
|
49
|
-
this.creditManagerDebtParams = payload.creditManagerDebtParams.map(p =>
|
|
50
|
-
creditManager
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
this.creditManagerDebtParams = Object.fromEntries(payload.creditManagerDebtParams.map(p => {
|
|
57
|
+
const creditManager = p.creditManager.toLowerCase();
|
|
58
|
+
return [
|
|
59
|
+
creditManager,
|
|
60
|
+
{
|
|
61
|
+
creditManager,
|
|
62
|
+
borrowed: (0, sdk_gov_1.toBigInt)(p.borrowed),
|
|
63
|
+
limit: (0, sdk_gov_1.toBigInt)(p.limit),
|
|
64
|
+
availableToBorrow: (0, sdk_gov_1.toBigInt)(p.availableToBorrow),
|
|
65
|
+
},
|
|
66
|
+
];
|
|
54
67
|
}));
|
|
55
|
-
this.quotas = payload.quotas.map(q =>
|
|
56
|
-
token
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
68
|
+
this.quotas = Object.fromEntries(payload.quotas.map(q => {
|
|
69
|
+
const token = q.token.toLowerCase();
|
|
70
|
+
return [
|
|
71
|
+
token,
|
|
72
|
+
{
|
|
73
|
+
token,
|
|
74
|
+
rate: Number((0, sdk_gov_1.toBigInt)(q.rate) * sdk_gov_1.PERCENTAGE_DECIMALS),
|
|
75
|
+
quotaIncreaseFee: q.quotaIncreaseFee,
|
|
76
|
+
totalQuoted: (0, sdk_gov_1.toBigInt)(q.totalQuoted),
|
|
77
|
+
limit: (0, sdk_gov_1.toBigInt)(q.limit),
|
|
78
|
+
isActive: q.isActive,
|
|
79
|
+
},
|
|
80
|
+
];
|
|
62
81
|
}));
|
|
82
|
+
this.zappers = payload.zappers.reduce((acc, z) => {
|
|
83
|
+
const tokenIn = z.tokenIn.toLowerCase();
|
|
84
|
+
const tokenOut = z.tokenOut.toLowerCase();
|
|
85
|
+
const old = acc[tokenIn] || {};
|
|
86
|
+
return {
|
|
87
|
+
...acc,
|
|
88
|
+
[tokenIn]: {
|
|
89
|
+
...old,
|
|
90
|
+
[tokenOut]: { tokenIn, tokenOut, zapper: z.zapper.toLowerCase() },
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}, {});
|
|
63
94
|
this.totalAssets = (0, sdk_gov_1.toBigInt)(payload.totalAssets);
|
|
64
95
|
this.totalSupply = (0, sdk_gov_1.toBigInt)(payload.totalSupply);
|
|
65
96
|
this.depositAPY = (0, formatter_1.rayToNumber)((0, sdk_gov_1.toBigInt)(payload.supplyRate) * sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
66
97
|
this.borrowAPY = (0, formatter_1.rayToNumber)((0, sdk_gov_1.toBigInt)(payload.baseInterestRate) * sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
98
|
+
this.supplyAPY7D = payload.supplyAPY7D;
|
|
67
99
|
this.interestModel = {
|
|
68
100
|
interestModel: payload.lirm.interestModel.toLowerCase(),
|
|
69
101
|
U_1: payload.lirm.U_1,
|
|
@@ -73,14 +105,15 @@ class PoolData {
|
|
|
73
105
|
R_slope2: payload.lirm.R_slope2,
|
|
74
106
|
R_slope3: payload.lirm.R_slope3,
|
|
75
107
|
version: payload?.lirm?.version?.toNumber(),
|
|
108
|
+
isBorrowingMoreU2Forbidden: payload?.lirm?.isBorrowingMoreU2Forbidden,
|
|
76
109
|
};
|
|
77
110
|
this.dieselRate = (0, formatter_1.rayToNumber)(payload.dieselRate_RAY);
|
|
78
111
|
this.dieselRateRay = (0, sdk_gov_1.toBigInt)(payload.dieselRate_RAY);
|
|
79
|
-
this.
|
|
112
|
+
this.lastBaseInterestUpdate = (0, sdk_gov_1.toBigInt)(payload.lastBaseInterestUpdate);
|
|
80
113
|
this.withdrawFee =
|
|
81
114
|
Number((0, sdk_gov_1.toBigInt)(payload.withdrawFee)) / Number(sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
82
115
|
}
|
|
83
|
-
|
|
116
|
+
getPoolContractV1(signer) {
|
|
84
117
|
return types_1.IPoolService__factory.connect(this.address, signer);
|
|
85
118
|
}
|
|
86
119
|
getPoolContractV3(signer) {
|
|
@@ -90,6 +123,15 @@ class PoolData {
|
|
|
90
123
|
const model = types_1.IInterestRateModel__factory.connect(this.interestModel.interestModel, provider);
|
|
91
124
|
return model.calcBorrowRate(expectedLiquidity, availableLiquidity);
|
|
92
125
|
}
|
|
126
|
+
static getPoolType(name) {
|
|
127
|
+
const [identity = ""] = name.split(" ") || [];
|
|
128
|
+
const lc = identity.toLowerCase();
|
|
129
|
+
if (lc === "farm")
|
|
130
|
+
return "farm";
|
|
131
|
+
if (lc === "trade")
|
|
132
|
+
return "trade";
|
|
133
|
+
return "universal";
|
|
134
|
+
}
|
|
93
135
|
}
|
|
94
136
|
exports.PoolData = PoolData;
|
|
95
137
|
class ChartsPoolData {
|
package/lib/core/strategy.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Asset } from "./assets";
|
|
1
2
|
import { CreditManagerData } from "./creditManager";
|
|
2
3
|
export interface StrategyPayload {
|
|
3
4
|
apy?: number;
|
|
@@ -13,8 +14,8 @@ interface LiquidationPriceProps {
|
|
|
13
14
|
liquidationThresholds: Record<string, bigint>;
|
|
14
15
|
borrowed: bigint;
|
|
15
16
|
underlyingToken: string;
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
targetToken: string;
|
|
18
|
+
assets: Record<string, Asset>;
|
|
18
19
|
}
|
|
19
20
|
export declare class Strategy {
|
|
20
21
|
apy: number | undefined;
|
|
@@ -27,7 +28,7 @@ export declare class Strategy {
|
|
|
27
28
|
constructor(payload: StrategyPayload);
|
|
28
29
|
static maxLeverage(lpToken: string, cms: Array<PartialCM>): number;
|
|
29
30
|
maxAPY(baseAPY: number, maxLeverage: number, borrowAPY: number): number;
|
|
30
|
-
static liquidationPrice({ prices, liquidationThresholds, borrowed, underlyingToken,
|
|
31
|
+
static liquidationPrice({ prices, liquidationThresholds, borrowed, underlyingToken, targetToken, assets, }: LiquidationPriceProps): bigint;
|
|
31
32
|
protected static maxLeverageThreshold(lpToken: string, cms: Array<PartialCM>): readonly [bigint, string];
|
|
32
33
|
}
|
|
33
34
|
type PartialCM = Pick<CreditManagerData, "liquidationThresholds" | "address">;
|
package/lib/core/strategy.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Strategy = void 0;
|
|
4
4
|
const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
5
|
+
const math_1 = require("../utils/math");
|
|
5
6
|
const price_1 = require("../utils/price");
|
|
6
7
|
class Strategy {
|
|
7
8
|
apy;
|
|
@@ -31,18 +32,18 @@ class Strategy {
|
|
|
31
32
|
((baseAPY - borrowAPY) * (maxLeverage - Number(sdk_gov_1.LEVERAGE_DECIMALS))) /
|
|
32
33
|
Number(sdk_gov_1.LEVERAGE_DECIMALS));
|
|
33
34
|
}
|
|
34
|
-
static liquidationPrice({ prices, liquidationThresholds, borrowed, underlyingToken,
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const underlyingPrice = prices[
|
|
39
|
-
const borrowedMoney = price_1.PriceUtils.calcTotalPrice(underlyingPrice, borrowed,
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const lpLT = liquidationThresholds[
|
|
44
|
-
const lpPrice = prices[
|
|
45
|
-
const lpMoney = price_1.PriceUtils.calcTotalPrice(lpPrice,
|
|
35
|
+
static liquidationPrice({ prices, liquidationThresholds, borrowed, underlyingToken, targetToken, assets, }) {
|
|
36
|
+
const underlyingTokenLC = underlyingToken.toLowerCase();
|
|
37
|
+
const [, underlyingDecimals = 18] = (0, sdk_gov_1.extractTokenData)(underlyingTokenLC);
|
|
38
|
+
const { balance: underlyingBalance = 0n } = assets[underlyingTokenLC] || {};
|
|
39
|
+
const underlyingPrice = prices[underlyingTokenLC] || sdk_gov_1.PRICE_DECIMALS;
|
|
40
|
+
const borrowedMoney = price_1.PriceUtils.calcTotalPrice(underlyingPrice, math_1.BigIntMath.max(0n, borrowed - underlyingBalance), underlyingDecimals);
|
|
41
|
+
const targetTokenLC = targetToken.toLowerCase();
|
|
42
|
+
const [, targetDecimals = 18] = (0, sdk_gov_1.extractTokenData)(targetTokenLC);
|
|
43
|
+
const { balance: targetBalance = 0n } = assets[targetTokenLC] || {};
|
|
44
|
+
const lpLT = liquidationThresholds[targetTokenLC] || 0n;
|
|
45
|
+
const lpPrice = prices[targetTokenLC] || sdk_gov_1.PRICE_DECIMALS;
|
|
46
|
+
const lpMoney = price_1.PriceUtils.calcTotalPrice(lpPrice, targetBalance, targetDecimals);
|
|
46
47
|
const lpLTMoney = (lpMoney * lpLT) / sdk_gov_1.PERCENTAGE_FACTOR;
|
|
47
48
|
if (lpLTMoney > 0) {
|
|
48
49
|
const lqPrice = (borrowedMoney * sdk_gov_1.WAD) / lpLTMoney;
|
|
@@ -58,9 +59,9 @@ class Strategy {
|
|
|
58
59
|
});
|
|
59
60
|
const sorted = ltByCM.sort(([, ltA], [, ltB]) => {
|
|
60
61
|
if (ltA > ltB)
|
|
61
|
-
return 1;
|
|
62
|
-
if (ltB > ltA)
|
|
63
62
|
return -1;
|
|
63
|
+
if (ltB > ltA)
|
|
64
|
+
return 1;
|
|
64
65
|
return 0;
|
|
65
66
|
});
|
|
66
67
|
const [cm = "", lt = 0n] = sorted[0] || [];
|