@pendle/core-v2 3.0.0-beta-11 → 3.0.0-beta-12
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/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol +5 -23
- package/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiverAppUpg.sol +2 -5
- package/contracts/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol +6 -20
- package/contracts/LiquidityMining/CrossChainMsg/PendleMsgSenderAppUpg.sol +6 -27
- package/contracts/LiquidityMining/CrossChainMsg/libraries/ExcessivelySafeCall.sol +1 -2
- package/contracts/LiquidityMining/CrossChainMsg/libraries/LayerZeroHelper.sol +1 -1
- package/contracts/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol +16 -17
- package/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol +6 -7
- package/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol +7 -8
- package/contracts/LiquidityMining/PendleMerkleDistributor.sol +2 -11
- package/contracts/LiquidityMining/VeDistributor/PendleFeeDistributor.sol +14 -37
- package/contracts/LiquidityMining/VeDistributor/PendleFeeDistributorV2.sol +19 -34
- package/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol +4 -14
- package/contracts/LiquidityMining/VotingController/VotingControllerStorageUpg.sol +4 -16
- package/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol +11 -39
- package/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol +3 -10
- package/contracts/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol +1 -1
- package/contracts/LiquidityMining/libraries/VeBalanceLib.sol +5 -20
- package/contracts/LiquidityMining/libraries/VeHistoryLib.sol +1 -3
- package/contracts/core/Market/MarketMathCore.sol +12 -37
- package/contracts/core/Market/OracleLib.sol +6 -24
- package/contracts/core/Market/PendleExternalRewardDistributor.sol +4 -10
- package/contracts/core/Market/PendleGauge.sol +3 -9
- package/contracts/core/Market/PendleMarket.sol +14 -39
- package/contracts/core/Market/PendleMarketFactory.sol +14 -21
- package/contracts/core/Market/v2/PendleGaugeV2.sol +8 -24
- package/contracts/core/Market/v2/PendleMarketFactoryV2.sol +7 -27
- package/contracts/core/Market/v2/PendleMarketV2.sol +13 -36
- package/contracts/core/Market/v3/PendleMarketFactoryV3.sol +137 -0
- package/contracts/core/Market/v3/PendleMarketV3.sol +360 -0
- package/contracts/core/RewardManager/PendleLinearDistributor.sol +143 -0
- package/contracts/core/RewardManager/RewardManager.sol +14 -7
- package/contracts/core/RewardManager/RewardManagerAbstract.sol +5 -17
- package/contracts/core/StandardizedYield/SYBase.sol +10 -40
- package/contracts/core/StandardizedYield/SYBaseUpg.sol +197 -0
- package/contracts/core/StandardizedYield/SYBaseWithRewards.sol +9 -41
- package/contracts/core/StandardizedYield/SYBaseWithRewardsUpg.sol +88 -0
- package/contracts/core/StandardizedYield/SYUtils.sol +1 -4
- package/contracts/core/StandardizedYield/StEthHelper.sol +3 -9
- package/contracts/core/StandardizedYield/implementations/AaveV3/PendleAaveV3SY.sol +94 -0
- package/contracts/core/StandardizedYield/implementations/AaveV3/libraries/AaveAdapterLib.sol +19 -0
- package/contracts/core/StandardizedYield/implementations/AaveV3/libraries/WadRayMath.sol +126 -0
- package/contracts/core/StandardizedYield/implementations/Ankr/PendleAnkrBNBSY.sol +4 -12
- package/contracts/core/StandardizedYield/implementations/Ape/sAPE.sol +5 -19
- package/contracts/core/StandardizedYield/implementations/BalancerStable/AuraEthxBbAWethSY.sol +4 -14
- package/contracts/core/StandardizedYield/implementations/BalancerStable/AuraSwEthBbAWethSYV2.sol +4 -14
- package/contracts/core/StandardizedYield/implementations/BalancerStable/{PendleAuraWethVethSY.sol → AuraWethVethSYUpg.sol} +13 -20
- package/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraBbAWethSwethSY.sol +3 -7
- package/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethAnkrethSYV2.sol +12 -29
- package/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethRocketEthSYV2.sol +12 -29
- package/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethStafiEthSY.sol +12 -29
- package/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethWstethSYV2.sol +14 -39
- package/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWstethAnkreth.sol +7 -28
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/ComposableStable/ComposableStableMath.sol +13 -30
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/ComposableStable/ComposableStablePreviewProxy.sol +1 -1
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/ComposableStable/ComposableStablePreviewV4.sol +50 -153
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/ComposableStable/ComposableStablePreviewV5.sol +50 -157
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/Linear/BbAPoolHelper.sol +4 -16
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/Linear/LinearMath.sol +6 -25
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/Linear/LinearPreview.sol +36 -34
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/MetaStable/MetaStableMath.sol +4 -13
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/MetaStable/MetaStablePreview.sol +20 -58
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/PendleAuraBalancerStableLPSYV2.sol +28 -79
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/PendleAuraBalancerStableLPSYV3Upg.sol +310 -0
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/StablePoolUserData.sol +1 -3
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/StablePreviewBase.sol +2 -6
- package/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenHelper.sol +5 -13
- package/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol +9 -29
- package/contracts/core/StandardizedYield/implementations/CamelotV1Volatile/CamelotRewardHelper.sol +2 -8
- package/contracts/core/StandardizedYield/implementations/CamelotV1Volatile/CamelotV1VolatileCommon.sol +1 -5
- package/contracts/core/StandardizedYield/implementations/CamelotV1Volatile/CamelotV1VolatileLpHelper.sol +8 -19
- package/contracts/core/StandardizedYield/implementations/CamelotV1Volatile/CamelotV1VolatilePreview.sol +7 -25
- package/contracts/core/StandardizedYield/implementations/CamelotV1Volatile/PendleCamelotV1VolatileSY.sol +8 -27
- package/contracts/core/StandardizedYield/implementations/ChainlinkRelayer/PendleChainlinkReceiver.sol +2 -2
- package/contracts/core/StandardizedYield/implementations/ChainlinkRelayer/PendleChainlinkRelayer.sol +4 -9
- package/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol +3 -15
- package/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol +5 -23
- package/contracts/core/StandardizedYield/implementations/Convex/base/Curve3CrvPoolHelper.sol +10 -40
- package/contracts/core/StandardizedYield/implementations/Convex/base/CurveFraxUsdcPoolHelper.sol +2 -8
- package/contracts/core/StandardizedYield/implementations/Convex/base/CurveUsdd3CrvPoolHelper.sol +2 -7
- package/contracts/core/StandardizedYield/implementations/Convex/base/PendleConvexLPSY.sol +5 -20
- package/contracts/core/StandardizedYield/implementations/Flux/FluxTokenLib.sol +6 -4
- package/contracts/core/StandardizedYield/implementations/Flux/PendleFluxLendingSY.sol +3 -11
- package/contracts/core/StandardizedYield/implementations/GLP/GLPPreviewHelper.sol +3 -9
- package/contracts/core/StandardizedYield/implementations/GLP/GMTokenPricingHelper.sol +115 -0
- package/contracts/core/StandardizedYield/implementations/GLP/PendleGMV2TokenSY.sol +134 -0
- package/contracts/core/StandardizedYield/implementations/GLP/PendleGlpSY.sol +5 -19
- package/contracts/core/StandardizedYield/implementations/HMX/HLPPricingHelper.sol +3 -4
- package/contracts/core/StandardizedYield/implementations/HMX/PendleHlpSY.sol +18 -25
- package/contracts/core/StandardizedYield/implementations/Kyber/KyberMathHelper.sol +425 -0
- package/contracts/core/StandardizedYield/implementations/Kyber/KyberNftManagerBaseUpg.sol +438 -0
- package/contracts/core/StandardizedYield/implementations/Kyber/PendleKyberElasticSYUpg.sol +155 -0
- package/contracts/core/StandardizedYield/implementations/Kyber/libraries/FullMath.sol +123 -0
- package/contracts/core/StandardizedYield/implementations/Kyber/libraries/LiqDeltaMath.sol +17 -0
- package/contracts/core/StandardizedYield/implementations/Kyber/libraries/LiquidityMath.sol +74 -0
- package/contracts/core/StandardizedYield/implementations/Kyber/libraries/MathConstants.sol +19 -0
- package/contracts/core/StandardizedYield/implementations/Kyber/libraries/QtyDeltaMath.sol +103 -0
- package/contracts/core/StandardizedYield/implementations/Kyber/libraries/QuadMath.sol +31 -0
- package/contracts/core/StandardizedYield/implementations/Kyber/libraries/ReinvestmentMath.sol +26 -0
- package/contracts/core/StandardizedYield/implementations/Kyber/libraries/SafeCast.sol +73 -0
- package/contracts/core/StandardizedYield/implementations/Kyber/libraries/SwapMath.sol +272 -0
- package/contracts/core/StandardizedYield/implementations/Kyber/libraries/TickMath.sol +223 -0
- package/contracts/core/StandardizedYield/implementations/MUX/MlpPricingHelper.sol +26 -0
- package/contracts/core/StandardizedYield/implementations/MUX/PendleMlpSY.sol +195 -0
- package/contracts/core/StandardizedYield/implementations/MantleStakedEth/PendleMantleStakedEthSY.sol +12 -41
- package/contracts/core/StandardizedYield/implementations/MantleStakedEth/PendleOracleForSyProxy.sol +1 -1
- package/contracts/core/StandardizedYield/implementations/PendleArbitrumStakedEthSY.sol +13 -42
- package/contracts/core/StandardizedYield/implementations/PendleBridgedLSDSY.sol +4 -11
- package/contracts/core/StandardizedYield/implementations/PendleERC4626SY.sol +4 -16
- package/contracts/core/StandardizedYield/implementations/PendleEUSDSY.sol +3 -11
- package/contracts/core/StandardizedYield/implementations/PendleGdaiSY.sol +3 -11
- package/contracts/core/StandardizedYield/implementations/PendleLooksStakingSY.sol +5 -18
- package/contracts/core/StandardizedYield/implementations/PendleSfrxEthSY.sol +3 -7
- package/contracts/core/StandardizedYield/implementations/PendleStargateLPSY.sol +5 -18
- package/contracts/core/StandardizedYield/implementations/PendleWbEthSY.sol +3 -10
- package/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol +4 -12
- package/contracts/core/StandardizedYield/implementations/Silo/PendleSiloWithIncentiveSY.sol +157 -0
- package/contracts/core/StandardizedYield/implementations/Stader/PendleETHXSY.sol +4 -12
- package/contracts/core/StandardizedYield/implementations/Swell/PendleSwETH.sol +4 -12
- package/contracts/core/StandardizedYield/implementations/Thena/PendleThenaSY.sol +9 -29
- package/contracts/core/StandardizedYield/implementations/Thena/ThenaLpHelper.sol +3 -10
- package/contracts/core/StandardizedYield/implementations/Thena/ThenaMath.sol +9 -30
- package/contracts/core/StandardizedYield/implementations/Thena/ThenaPreview.sol +10 -40
- package/contracts/core/YieldContracts/InterestManagerYT.sol +6 -8
- package/contracts/core/YieldContracts/PendlePrincipalToken.sol +1 -1
- package/contracts/core/YieldContracts/PendleYieldContractFactory.sol +2 -3
- package/contracts/core/YieldContracts/PendleYieldToken.sol +17 -44
- package/contracts/core/YieldContractsV2/InterestManagerYTV2.sol +5 -14
- package/contracts/core/YieldContractsV2/PendlePrincipalTokenV2.sol +1 -1
- package/contracts/core/YieldContractsV2/PendleYieldContractFactoryV2.sol +2 -3
- package/contracts/core/YieldContractsV2/PendleYieldTokenV2.sol +13 -48
- package/contracts/core/erc20/PendleERC20.sol +2 -8
- package/contracts/core/erc20/PendleERC20Permit.sol +2 -6
- package/contracts/core/erc20/PendleERC20PermitUpg.sol +82 -0
- package/contracts/core/erc20/PendleERC20Upg.sol +334 -0
- package/contracts/core/libraries/ArrayLib.sol +7 -8
- package/contracts/core/libraries/BaseSplitCodeFactory.sol +1 -6
- package/contracts/core/libraries/Errors.sol +19 -1
- package/contracts/core/libraries/ExpiryUtilsLib.sol +3 -26
- package/contracts/core/libraries/StringLib.sol +5 -21
- package/contracts/core/libraries/TokenHelper.sol +3 -3
- package/contracts/core/libraries/math/LogExpMath.sol +1 -4
- package/contracts/core/libraries/math/PMath.sol +13 -15
- package/contracts/interfaces/AaveV3/IAaveV3AToken.sol +15 -0
- package/contracts/interfaces/AaveV3/IAaveV3Pool.sol +11 -0
- package/contracts/interfaces/Balancer/IComposableStable.sol +3 -4
- package/contracts/interfaces/Balancer/IERC4626LinearPool.sol +2 -10
- package/contracts/interfaces/Balancer/IMetaStablePool.sol +3 -11
- package/contracts/interfaces/Balancer/IVault.sol +3 -8
- package/contracts/interfaces/BinanceEth/IWBETH.sol +1 -1
- package/contracts/interfaces/Camelot/ICamelotNFTFactory.sol +1 -3
- package/contracts/interfaces/Camelot/ICamelotNFTHandler.sol +2 -10
- package/contracts/interfaces/Camelot/ICamelotNitroPool.sol +0 -1
- package/contracts/interfaces/Camelot/ICamelotNitroPoolFactory.sol +3 -12
- package/contracts/interfaces/Camelot/ICamelotPair.sol +5 -25
- package/contracts/interfaces/Camelot/ICamelotRouter.sol +1 -5
- package/contracts/interfaces/Camelot/IXGrail.sol +3 -11
- package/contracts/interfaces/ConvexCurve/IBooster.sol +1 -3
- package/contracts/interfaces/Curve/ICrvPool.sol +3 -12
- package/contracts/interfaces/Curve/ITriCrvPool.sol +2 -9
- package/contracts/interfaces/Flux/IFluxErc20.sol +1 -1
- package/contracts/interfaces/Flux/IFluxInterestRateModel.sol +1 -5
- package/contracts/interfaces/GMX/IGMXPriceHelper.sol +6 -0
- package/contracts/interfaces/GMX/IGMXVault.sol +2 -9
- package/contracts/interfaces/GMX/IRewardRouterV2.sol +1 -4
- package/contracts/interfaces/HMX/IHLPStaking.sol +1 -1
- package/contracts/interfaces/HMX/IHMXCalculator.sol +1 -1
- package/contracts/interfaces/HMX/IHMXCompounder.sol +1 -1
- package/contracts/interfaces/HMX/IHMXStaking.sol +1 -1
- package/contracts/interfaces/HMX/IHMXVester.sol +1 -1
- package/contracts/interfaces/IApeStaking.sol +3 -9
- package/contracts/interfaces/IBenQiInterestRateModel.sol +1 -5
- package/contracts/interfaces/IDiamondCut.sol +1 -5
- package/contracts/interfaces/IDiamondLoupe.sol +1 -3
- package/contracts/interfaces/ILayerZeroReceiver.sol +1 -6
- package/contracts/interfaces/IPActionAddRemoveLiqV3.sol +10 -2
- package/contracts/interfaces/IPActionInfoStatic.sol +4 -7
- package/contracts/interfaces/IPActionMarketAuxStatic.sol +5 -9
- package/contracts/interfaces/IPActionMarketCoreStatic.sol +118 -58
- package/contracts/interfaces/IPActionMintRedeemStatic.sol +38 -21
- package/contracts/interfaces/IPActionMiscV3.sol +51 -26
- package/contracts/interfaces/IPActionStorageStatic.sol +5 -1
- package/contracts/interfaces/IPAllActionTypeV3.sol +1 -0
- package/contracts/interfaces/IPBulkSeller.sol +49 -0
- package/contracts/interfaces/IPBulkSellerFactory.sol +12 -0
- package/contracts/interfaces/IPBulkSellerSYCallback.sol +6 -0
- package/contracts/interfaces/IPFeeDistributor.sol +1 -3
- package/contracts/interfaces/IPFeeDistributorV2.sol +8 -7
- package/contracts/interfaces/IPGaugeController.sol +2 -8
- package/contracts/interfaces/IPGaugeControllerMainchain.sol +1 -5
- package/contracts/interfaces/IPInterestManagerYT.sol +3 -3
- package/contracts/interfaces/IPInterestManagerYTV2.sol +1 -4
- package/contracts/interfaces/IPLimitRouter.sol +24 -19
- package/contracts/interfaces/IPLinearDistributor.sol +21 -0
- package/contracts/interfaces/IPMarket.sol +4 -17
- package/contracts/interfaces/IPMarketFactory.sol +2 -13
- package/contracts/interfaces/IPMarketFactoryV3.sol +24 -0
- package/contracts/interfaces/IPMarketV3.sol +8 -0
- package/contracts/interfaces/IPOffchainStorage.sol +11 -0
- package/contracts/interfaces/IPPriceFeed.sol +6 -0
- package/contracts/interfaces/IPPtOracle.sol +2 -9
- package/contracts/interfaces/IPRouterHelper.sol +11 -7
- package/contracts/interfaces/IPRouterStatic.sol +1 -3
- package/contracts/interfaces/IPVotingController.sol +7 -19
- package/contracts/interfaces/IPVotingEscrowMainchain.sol +2 -8
- package/contracts/interfaces/IPYieldToken.sol +2 -8
- package/contracts/interfaces/IPYieldTokenV2.sol +1 -6
- package/contracts/interfaces/IPendlePreviewHelper.sol +2 -8
- package/contracts/interfaces/IRewardManager.sol +1 -4
- package/contracts/interfaces/IStETH.sol +1 -4
- package/contracts/interfaces/IStandardizedYield.sol +9 -16
- package/contracts/interfaces/IStargateLP.sol +0 -3
- package/contracts/interfaces/IStargateRouter.sol +1 -5
- package/contracts/interfaces/Kyber/IKyberElasticFactory.sol +157 -0
- package/contracts/interfaces/Kyber/IKyberElasticPool.sol +101 -0
- package/contracts/interfaces/Kyber/IKyberElasticRouter.sol +98 -0
- package/contracts/interfaces/Kyber/IKyberLiquidityMining.sol +209 -0
- package/contracts/interfaces/Kyber/IKyberMathHelper.sol +28 -0
- package/contracts/interfaces/Kyber/IKyberPositionManager.sol +179 -0
- package/contracts/interfaces/Lybra/IEUSD.sol +1 -1
- package/contracts/interfaces/MUX/IMUXRewardRouter.sol +139 -0
- package/contracts/interfaces/Silo/ISilo.sol +298 -0
- package/contracts/interfaces/Silo/ISiloIncentiveController.sol +16 -0
- package/contracts/interfaces/Silo/ISiloLens.sol +6 -0
- package/contracts/interfaces/Stader/IStaderStakeManager.sol +2 -2
- package/contracts/interfaces/Thena/IThenaFactory.sol +1 -5
- package/contracts/interfaces/Thena/IThenaGaugeV2.sol +1 -2
- package/contracts/interfaces/Thena/IThenaPair.sol +3 -5
- package/contracts/limit/LimitMathCore.sol +69 -60
- package/contracts/limit/{PendleOrderMixin.sol → LimitRouterBase.sol} +96 -79
- package/contracts/limit/PendleLimitRouter.sol +9 -13
- package/contracts/offchain-helpers/AutomateReady.sol +17 -32
- package/contracts/offchain-helpers/BaseSplitCodeFactoryContract.sol +6 -3
- package/contracts/offchain-helpers/BoringLpSeller.sol +4 -17
- package/contracts/offchain-helpers/BoringPtSeller.sol +2 -7
- package/contracts/offchain-helpers/Broadcaster.sol +1 -1
- package/contracts/offchain-helpers/BytesLib.sol +26 -14
- package/contracts/offchain-helpers/EmptyUUPS.sol +0 -1
- package/contracts/offchain-helpers/LegacyNFTHelper.sol +4 -23
- package/contracts/offchain-helpers/LimitBackendHelper.sol +25 -16
- package/contracts/offchain-helpers/MarketExchangeRateLib.sol +2 -13
- package/contracts/offchain-helpers/Multicall2.sol +2 -7
- package/contracts/offchain-helpers/PendleMulticallV1.sol +7 -7
- package/contracts/offchain-helpers/PendleMulticallV2.sol +12 -13
- package/contracts/offchain-helpers/PendleOffchainStorage.sol +59 -0
- package/contracts/offchain-helpers/SimulateHelper.sol +6 -7
- package/contracts/offchain-helpers/errors/SDKErrorsDirectory.sol +15 -1
- package/contracts/oracles/PendleLpOracleLib.sol +9 -10
- package/contracts/oracles/PendlePtOracle.sol +8 -19
- package/contracts/oracles/PendlePtOracleLib.sol +8 -13
- package/contracts/oracles/samples/PendleLpGlpOracle.sol +6 -10
- package/contracts/oracles/samples/PendlePtGlpOracle.sol +6 -10
- package/contracts/oracles/samples/PendlePtUsdChainlinkOracle.sol +8 -15
- package/contracts/router/ActionAddRemoveLiqV3.sol +147 -52
- package/contracts/router/ActionCallbackV3.sol +11 -4
- package/contracts/router/ActionMiscV3.sol +43 -33
- package/contracts/router/ActionSwapPTV3.sol +18 -6
- package/contracts/router/ActionSwapYTV3.sol +42 -14
- package/contracts/router/PendleRouterHelper.sol +72 -40
- package/contracts/router/PendleRouterV3.sol +50 -50
- package/contracts/router/base/ActionBase.sol +86 -43
- package/contracts/router/base/CallbackHelper.sol +18 -20
- package/contracts/router/base/MarketApproxLib.sol +36 -32
- package/contracts/router/swap-aggregator/PendleSwap.sol +31 -7
- package/contracts/router/swap-aggregator/kyberswap/interfaces/IAggregationExecutorOptimistic.sol +63 -0
- package/contracts/router/swap-aggregator/kyberswap/interfaces/IExecutorHelper.sol +314 -0
- package/contracts/router/swap-aggregator/kyberswap/interfaces/IExecutorHelperL2.sol +560 -0
- package/contracts/router/swap-aggregator/kyberswap/{IMetaAggregationRouterV2.sol → interfaces/IMetaAggregationRouterV2.sol} +11 -6
- package/contracts/router/swap-aggregator/kyberswap/{KyberInputScalingHelper.sol → l1-contracts/InputScalingHelper.sol} +70 -19
- package/contracts/router/swap-aggregator/kyberswap/{ScalingDataLib.sol → l1-contracts/ScalingDataLib.sol} +111 -53
- package/contracts/router/swap-aggregator/kyberswap/l2-contracts/BytesHelper.sol +29 -0
- package/contracts/router/swap-aggregator/kyberswap/l2-contracts/CalldataReader.sol +149 -0
- package/contracts/router/swap-aggregator/kyberswap/l2-contracts/CalldataWriter.sol +118 -0
- package/contracts/router/swap-aggregator/kyberswap/l2-contracts/Common.sol +42 -0
- package/contracts/router/swap-aggregator/kyberswap/l2-contracts/DexScaler.sol +382 -0
- package/contracts/router/swap-aggregator/kyberswap/l2-contracts/ExecutorReader.sol +61 -0
- package/contracts/router/swap-aggregator/kyberswap/l2-contracts/InputScalingHelperL2.sol +329 -0
- package/contracts/router/swap-aggregator/kyberswap/l2-contracts/ScalingDataL2Lib.sol +173 -0
- package/contracts/router/swap-aggregator/oneinch/I1inchAggregationRouterV5.sol +4 -10
- package/contracts/router/swap-aggregator/oneinch/OneInchAggregationRouterHelper.sol +20 -14
- package/deployments/1-core.json +5 -2
- package/deployments/1-markets/EPENDLE-SEP2024.json +12 -0
- package/deployments/1-markets/SFRAX-MARCH2024.json +10 -0
- package/deployments/1-markets/SILO-CRVUSD-MARCH2024.json +10 -0
- package/deployments/10-core.json +6 -3
- package/deployments/42161-core.json +5 -2
- package/deployments/42161-markets/AAVE-USDC-JUNE2024.json +11 -0
- package/deployments/42161-markets/ARBSILO-USDC-FEB2024.json +10 -0
- package/deployments/42161-markets/GM-ARB-USDC-MARCH2024.json +10 -0
- package/deployments/42161-markets/KYBER-AXLWSTETH-WSTETH-MARCH2024.json +10 -0
- package/deployments/42161-markets/MLP-MARCH2024.json +10 -0
- package/deployments/42161-markets/WSTETH-ARBITRUM-MARCH2024.json +11 -0
- package/deployments/42161-markets/WSTETHSILO-ETH-MARCH2024.json +11 -0
- package/deployments/56-core.json +5 -2
- package/deployments/merkle-distribution/2023-10-26.json +7300 -0
- package/deployments/merkle-distribution/2023-11-30.json +7730 -0
- package/package.json +8 -8
- package/contracts/limit/helpers/ArgumentsDecoder.sol +0 -47
- package/contracts/limit/helpers/Permitable.sol +0 -48
- package/contracts/limit/helpers/RevertReasonParser.sol +0 -75
- package/contracts/offchain-helpers/ChainlinkRelayerGelato.sol +0 -37
- package/contracts/offchain-helpers/PtAndLpToAsset.sol +0 -62
- package/contracts/offchain-helpers/router-static/PendleRouterStatic.sol +0 -19
- package/contracts/offchain-helpers/router-static/base/ActionInfoStatic.sol +0 -112
- package/contracts/offchain-helpers/router-static/base/ActionLimitOrdersStatic.sol +0 -145
- package/contracts/offchain-helpers/router-static/base/ActionMarketAuxStatic.sol +0 -171
- package/contracts/offchain-helpers/router-static/base/ActionMarketCoreStatic.sol +0 -582
- package/contracts/offchain-helpers/router-static/base/ActionMintRedeemStatic.sol +0 -116
- package/contracts/offchain-helpers/router-static/base/ActionStorageStatic.sol +0 -64
- package/contracts/offchain-helpers/router-static/base/ActionVePendleStatic.sol +0 -53
- package/contracts/offchain-helpers/router-static/base/StorageLayout.sol +0 -18
- package/contracts/router/swap-aggregator/kyberswap/IExecutorHelper.sol +0 -231
- package/deployments/1-markets/BALANCER-LP-AURA-VETH-WETH-SEP2024.json +0 -8
- /package/contracts/router/swap-aggregator/kyberswap/{IAggregationExecutor.sol → interfaces/IAggregationExecutor.sol} +0 -0
- /package/deployments/1-markets/{BALANCER-LP-AURA-BBAWETHSWETH-SEP-26-2024.json → deprecated/BALANCER-LP-AURA-BBAWETHSWETH-SEP-26-2024.json} +0 -0
- /package/deployments/1-markets/{BALANCER-LP-AURA-ETHX-BBAWETH-SEP-26-2024.json → deprecated/BALANCER-LP-AURA-ETHX-BBAWETH-SEP-26-2024.json} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
-
pragma solidity 0.8.17;
|
|
2
|
+
pragma solidity ^0.8.17;
|
|
3
3
|
|
|
4
4
|
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
5
5
|
import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
|
|
@@ -123,19 +123,10 @@ contract MetaStablePreview is StablePreviewBase, BoringOwnableUpgradeable, UUPSU
|
|
|
123
123
|
) internal view returns (uint256, uint256[] memory, uint256[] memory) {
|
|
124
124
|
// skip _updateOracle
|
|
125
125
|
|
|
126
|
-
uint256[] memory dueProtocolFeeAmounts = _getDueProtocolFeeAmounts(
|
|
127
|
-
balances,
|
|
128
|
-
protocolSwapFeePercentage,
|
|
129
|
-
imd
|
|
130
|
-
);
|
|
126
|
+
uint256[] memory dueProtocolFeeAmounts = _getDueProtocolFeeAmounts(balances, protocolSwapFeePercentage, imd);
|
|
131
127
|
|
|
132
128
|
_mutateAmounts(balances, dueProtocolFeeAmounts, FixedPoint.sub);
|
|
133
|
-
(uint256 bptAmountOut, uint256[] memory amountsIn) = _doJoin(
|
|
134
|
-
balances,
|
|
135
|
-
scalingFactors,
|
|
136
|
-
userData,
|
|
137
|
-
imd
|
|
138
|
-
);
|
|
129
|
+
(uint256 bptAmountOut, uint256[] memory amountsIn) = _doJoin(balances, scalingFactors, userData, imd);
|
|
139
130
|
|
|
140
131
|
// skip _updateInvariantAfterJoin
|
|
141
132
|
|
|
@@ -156,19 +147,11 @@ contract MetaStablePreview is StablePreviewBase, BoringOwnableUpgradeable, UUPSU
|
|
|
156
147
|
internal
|
|
157
148
|
view
|
|
158
149
|
virtual
|
|
159
|
-
returns (
|
|
160
|
-
uint256 bptAmountIn,
|
|
161
|
-
uint256[] memory amountsOut,
|
|
162
|
-
uint256[] memory dueProtocolFeeAmounts
|
|
163
|
-
)
|
|
150
|
+
returns (uint256 bptAmountIn, uint256[] memory amountsOut, uint256[] memory dueProtocolFeeAmounts)
|
|
164
151
|
{
|
|
165
152
|
// skip _updateOracle
|
|
166
153
|
|
|
167
|
-
dueProtocolFeeAmounts = _getDueProtocolFeeAmounts(
|
|
168
|
-
balances,
|
|
169
|
-
protocolSwapFeePercentage,
|
|
170
|
-
imd
|
|
171
|
-
);
|
|
154
|
+
dueProtocolFeeAmounts = _getDueProtocolFeeAmounts(balances, protocolSwapFeePercentage, imd);
|
|
172
155
|
|
|
173
156
|
_mutateAmounts(balances, dueProtocolFeeAmounts, FixedPoint.sub);
|
|
174
157
|
|
|
@@ -202,16 +185,14 @@ contract MetaStablePreview is StablePreviewBase, BoringOwnableUpgradeable, UUPSU
|
|
|
202
185
|
}
|
|
203
186
|
}
|
|
204
187
|
|
|
205
|
-
(uint256 _lastInvariant, uint256 _lastInvariantAmp) = IMetaStablePool(imd.LP)
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
protocolSwapFeePercentage
|
|
214
|
-
);
|
|
188
|
+
(uint256 _lastInvariant, uint256 _lastInvariantAmp) = IMetaStablePool(imd.LP).getLastInvariant();
|
|
189
|
+
dueProtocolFeeAmounts[chosenTokenIndex] = MetaStableMath._calcDueTokenProtocolSwapFeeAmount(
|
|
190
|
+
_lastInvariantAmp,
|
|
191
|
+
balances,
|
|
192
|
+
_lastInvariant,
|
|
193
|
+
chosenTokenIndex,
|
|
194
|
+
protocolSwapFeePercentage
|
|
195
|
+
);
|
|
215
196
|
|
|
216
197
|
return dueProtocolFeeAmounts;
|
|
217
198
|
}
|
|
@@ -296,31 +277,21 @@ contract MetaStablePreview is StablePreviewBase, BoringOwnableUpgradeable, UUPSU
|
|
|
296
277
|
return scalingFactors;
|
|
297
278
|
}
|
|
298
279
|
|
|
299
|
-
function _priceRate(
|
|
300
|
-
uint256[] memory caches,
|
|
301
|
-
uint256 index
|
|
302
|
-
) internal view virtual returns (uint256) {
|
|
280
|
+
function _priceRate(uint256[] memory caches, uint256 index) internal view virtual returns (uint256) {
|
|
303
281
|
return caches[index] == 0 ? FixedPoint.ONE : caches[index];
|
|
304
282
|
}
|
|
305
283
|
|
|
306
|
-
function _cachePriceRatesIfNecessary(
|
|
307
|
-
ImmutableData memory imd
|
|
308
|
-
) internal view returns (uint256[] memory res) {
|
|
284
|
+
function _cachePriceRatesIfNecessary(ImmutableData memory imd) internal view returns (uint256[] memory res) {
|
|
309
285
|
res = new uint256[](2);
|
|
310
286
|
res[0] = _cachePriceRateIfNecessary(0, imd);
|
|
311
287
|
res[1] = _cachePriceRateIfNecessary(1, imd);
|
|
312
288
|
}
|
|
313
289
|
|
|
314
|
-
function _cachePriceRateIfNecessary(
|
|
315
|
-
uint256 index,
|
|
316
|
-
ImmutableData memory imd
|
|
317
|
-
) internal view returns (uint256 res) {
|
|
290
|
+
function _cachePriceRateIfNecessary(uint256 index, ImmutableData memory imd) internal view returns (uint256 res) {
|
|
318
291
|
if (!_hasRateProvider(imd, index)) return res;
|
|
319
292
|
|
|
320
293
|
uint256 expires;
|
|
321
|
-
(res, , expires) = IMetaStablePool(imd.LP).getPriceRateCache(
|
|
322
|
-
IERC20(imd.poolTokens[index])
|
|
323
|
-
);
|
|
294
|
+
(res, , expires) = IMetaStablePool(imd.LP).getPriceRateCache(IERC20(imd.poolTokens[index]));
|
|
324
295
|
|
|
325
296
|
if (block.timestamp > expires) {
|
|
326
297
|
res = IRateProvider(imd.rateProviders[index]).getRate();
|
|
@@ -331,10 +302,7 @@ contract MetaStablePreview is StablePreviewBase, BoringOwnableUpgradeable, UUPSU
|
|
|
331
302
|
Helpers functions
|
|
332
303
|
//////////////////////////////////////////////////////////////*/
|
|
333
304
|
|
|
334
|
-
function _upscaleArray(
|
|
335
|
-
uint256[] memory amounts,
|
|
336
|
-
uint256[] memory scalingFactors
|
|
337
|
-
) internal pure {
|
|
305
|
+
function _upscaleArray(uint256[] memory amounts, uint256[] memory scalingFactors) internal pure {
|
|
338
306
|
require(amounts.length == scalingFactors.length, "Array length mismatch");
|
|
339
307
|
|
|
340
308
|
uint256 length = amounts.length;
|
|
@@ -343,10 +311,7 @@ contract MetaStablePreview is StablePreviewBase, BoringOwnableUpgradeable, UUPSU
|
|
|
343
311
|
}
|
|
344
312
|
}
|
|
345
313
|
|
|
346
|
-
function _downscaleDownArray(
|
|
347
|
-
uint256[] memory amounts,
|
|
348
|
-
uint256[] memory scalingFactors
|
|
349
|
-
) internal pure {
|
|
314
|
+
function _downscaleDownArray(uint256[] memory amounts, uint256[] memory scalingFactors) internal pure {
|
|
350
315
|
require(amounts.length == scalingFactors.length, "Array length mismatch");
|
|
351
316
|
|
|
352
317
|
uint256 length = amounts.length;
|
|
@@ -365,10 +330,7 @@ contract MetaStablePreview is StablePreviewBase, BoringOwnableUpgradeable, UUPSU
|
|
|
365
330
|
}
|
|
366
331
|
}
|
|
367
332
|
|
|
368
|
-
function _hasRateProvider(
|
|
369
|
-
ImmutableData memory imd,
|
|
370
|
-
uint256 index
|
|
371
|
-
) internal pure returns (bool) {
|
|
333
|
+
function _hasRateProvider(ImmutableData memory imd, uint256 index) internal pure returns (bool) {
|
|
372
334
|
return address(imd.rateProviders[index]) != address(0);
|
|
373
335
|
}
|
|
374
336
|
}
|
|
@@ -58,11 +58,7 @@ abstract contract PendleAuraBalancerStableLPSYV2 is SYBaseWithRewards {
|
|
|
58
58
|
gasForReentrancyCheck = DEFAULT_GAS_REENTRANCY_CHECK;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
function _getPoolInfo(uint256 _auraPid)
|
|
62
|
-
internal
|
|
63
|
-
view
|
|
64
|
-
returns (address _auraLp, address _auraRewardManager)
|
|
65
|
-
{
|
|
61
|
+
function _getPoolInfo(uint256 _auraPid) internal view returns (address _auraLp, address _auraRewardManager) {
|
|
66
62
|
if (_auraPid > IBooster(AURA_BOOSTER).poolLength()) revert Errors.SYBalancerInvalidPid();
|
|
67
63
|
(_auraLp, , , _auraRewardManager, , ) = IBooster(AURA_BOOSTER).poolInfo(_auraPid);
|
|
68
64
|
}
|
|
@@ -74,12 +70,7 @@ abstract contract PendleAuraBalancerStableLPSYV2 is SYBaseWithRewards {
|
|
|
74
70
|
/**
|
|
75
71
|
* @notice Either wraps LP, or also joins pool using exact tokenIn
|
|
76
72
|
*/
|
|
77
|
-
function _deposit(address tokenIn, uint256 amount)
|
|
78
|
-
internal
|
|
79
|
-
virtual
|
|
80
|
-
override
|
|
81
|
-
returns (uint256 amountSharesOut)
|
|
82
|
-
{
|
|
73
|
+
function _deposit(address tokenIn, uint256 amount) internal virtual override returns (uint256 amountSharesOut) {
|
|
83
74
|
if (tokenIn == balLp) {
|
|
84
75
|
amountSharesOut = amount;
|
|
85
76
|
} else {
|
|
@@ -134,13 +125,8 @@ abstract contract PendleAuraBalancerStableLPSYV2 is SYBaseWithRewards {
|
|
|
134
125
|
function _checkBalancerReadOnlyReentrancy() internal view {
|
|
135
126
|
IVault.UserBalanceOp[] memory noop = new IVault.UserBalanceOp[](0);
|
|
136
127
|
|
|
137
|
-
(bool isSuccess, bytes memory response) = BALANCER_VAULT.staticcall{
|
|
138
|
-
|
|
139
|
-
}(
|
|
140
|
-
abi.encodeWithSignature(
|
|
141
|
-
"manageUserBalance((uint8,address,uint256,address,address)[])",
|
|
142
|
-
noop
|
|
143
|
-
)
|
|
128
|
+
(bool isSuccess, bytes memory response) = BALANCER_VAULT.staticcall{gas: gasForReentrancyCheck}(
|
|
129
|
+
abi.encodeWithSignature("manageUserBalance((uint8,address,uint256,address,address)[])", noop)
|
|
144
130
|
);
|
|
145
131
|
|
|
146
132
|
assert(!isSuccess);
|
|
@@ -156,33 +142,22 @@ abstract contract PendleAuraBalancerStableLPSYV2 is SYBaseWithRewards {
|
|
|
156
142
|
BALANCER-RELATED FUNCTIONS
|
|
157
143
|
//////////////////////////////////////////////////////////////*/
|
|
158
144
|
|
|
159
|
-
function _depositToBalancer(address tokenIn, uint256 amountTokenToDeposit)
|
|
160
|
-
|
|
161
|
-
virtual
|
|
162
|
-
returns (uint256)
|
|
163
|
-
{
|
|
164
|
-
IVault.JoinPoolRequest memory request = _assembleJoinRequest(
|
|
165
|
-
tokenIn,
|
|
166
|
-
amountTokenToDeposit
|
|
167
|
-
);
|
|
145
|
+
function _depositToBalancer(address tokenIn, uint256 amountTokenToDeposit) internal virtual returns (uint256) {
|
|
146
|
+
IVault.JoinPoolRequest memory request = _assembleJoinRequest(tokenIn, amountTokenToDeposit);
|
|
168
147
|
IVault(BALANCER_VAULT).joinPool(balPoolId, address(this), address(this), request);
|
|
169
148
|
|
|
170
149
|
// amount shares out = amount LP received
|
|
171
150
|
return _selfBalance(balLp);
|
|
172
151
|
}
|
|
173
152
|
|
|
174
|
-
function _assembleJoinRequest(
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
returns (IVault.JoinPoolRequest memory request)
|
|
179
|
-
{
|
|
153
|
+
function _assembleJoinRequest(
|
|
154
|
+
address tokenIn,
|
|
155
|
+
uint256 amountTokenToDeposit
|
|
156
|
+
) internal view virtual returns (IVault.JoinPoolRequest memory request) {
|
|
180
157
|
// max amounts in
|
|
181
158
|
address[] memory assets = _getPoolTokenAddresses();
|
|
182
159
|
|
|
183
|
-
uint256 amountsLength = _getBPTIndex() < type(uint256).max
|
|
184
|
-
? assets.length - 1
|
|
185
|
-
: assets.length;
|
|
160
|
+
uint256 amountsLength = _getBPTIndex() < type(uint256).max ? assets.length - 1 : assets.length;
|
|
186
161
|
|
|
187
162
|
uint256[] memory amountsIn = new uint256[](amountsLength);
|
|
188
163
|
uint256[] memory maxAmountsIn = new uint256[](assets.length);
|
|
@@ -192,9 +167,7 @@ abstract contract PendleAuraBalancerStableLPSYV2 is SYBaseWithRewards {
|
|
|
192
167
|
maxAmountsIn[index] = amountsIn[indexSkipBPT] = amountTokenToDeposit;
|
|
193
168
|
|
|
194
169
|
// encode user data
|
|
195
|
-
StablePoolUserData.JoinKind joinKind = StablePoolUserData
|
|
196
|
-
.JoinKind
|
|
197
|
-
.EXACT_TOKENS_IN_FOR_BPT_OUT;
|
|
170
|
+
StablePoolUserData.JoinKind joinKind = StablePoolUserData.JoinKind.EXACT_TOKENS_IN_FOR_BPT_OUT;
|
|
198
171
|
uint256 minimumBPT = 0;
|
|
199
172
|
|
|
200
173
|
bytes memory userData = abi.encode(joinKind, amountsIn, minimumBPT);
|
|
@@ -218,19 +191,15 @@ abstract contract PendleAuraBalancerStableLPSYV2 is SYBaseWithRewards {
|
|
|
218
191
|
return balanceAfter - balanceBefore;
|
|
219
192
|
}
|
|
220
193
|
|
|
221
|
-
function _assembleExitRequest(
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
returns (IVault.ExitPoolRequest memory request)
|
|
226
|
-
{
|
|
194
|
+
function _assembleExitRequest(
|
|
195
|
+
address tokenOut,
|
|
196
|
+
uint256 amountLpToRedeem
|
|
197
|
+
) internal view virtual returns (IVault.ExitPoolRequest memory request) {
|
|
227
198
|
address[] memory assets = _getPoolTokenAddresses();
|
|
228
199
|
uint256[] memory minAmountsOut = new uint256[](assets.length);
|
|
229
200
|
|
|
230
201
|
// encode user data
|
|
231
|
-
StablePoolUserData.ExitKind exitKind = StablePoolUserData
|
|
232
|
-
.ExitKind
|
|
233
|
-
.EXACT_BPT_IN_FOR_ONE_TOKEN_OUT;
|
|
202
|
+
StablePoolUserData.ExitKind exitKind = StablePoolUserData.ExitKind.EXACT_BPT_IN_FOR_ONE_TOKEN_OUT;
|
|
234
203
|
uint256 bptAmountIn = amountLpToRedeem;
|
|
235
204
|
uint256 exitTokenIndex = assets.find(tokenOut);
|
|
236
205
|
|
|
@@ -255,20 +224,14 @@ abstract contract PendleAuraBalancerStableLPSYV2 is SYBaseWithRewards {
|
|
|
255
224
|
PREVIEW FUNCTIONS
|
|
256
225
|
//////////////////////////////////////////////////////////////*/
|
|
257
226
|
|
|
258
|
-
function _previewDeposit(
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
override
|
|
263
|
-
returns (uint256 amountSharesOut)
|
|
264
|
-
{
|
|
227
|
+
function _previewDeposit(
|
|
228
|
+
address tokenIn,
|
|
229
|
+
uint256 amountTokenToDeposit
|
|
230
|
+
) internal view virtual override returns (uint256 amountSharesOut) {
|
|
265
231
|
if (tokenIn == balLp) {
|
|
266
232
|
amountSharesOut = amountTokenToDeposit;
|
|
267
233
|
} else {
|
|
268
|
-
IVault.JoinPoolRequest memory request = _assembleJoinRequest(
|
|
269
|
-
tokenIn,
|
|
270
|
-
amountTokenToDeposit
|
|
271
|
-
);
|
|
234
|
+
IVault.JoinPoolRequest memory request = _assembleJoinRequest(tokenIn, amountTokenToDeposit);
|
|
272
235
|
amountSharesOut = previewHelper.joinPoolPreview(
|
|
273
236
|
balPoolId,
|
|
274
237
|
address(this),
|
|
@@ -279,20 +242,14 @@ abstract contract PendleAuraBalancerStableLPSYV2 is SYBaseWithRewards {
|
|
|
279
242
|
}
|
|
280
243
|
}
|
|
281
244
|
|
|
282
|
-
function _previewRedeem(
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
override
|
|
287
|
-
returns (uint256 amountTokenOut)
|
|
288
|
-
{
|
|
245
|
+
function _previewRedeem(
|
|
246
|
+
address tokenOut,
|
|
247
|
+
uint256 amountSharesToRedeem
|
|
248
|
+
) internal view virtual override returns (uint256 amountTokenOut) {
|
|
289
249
|
if (tokenOut == balLp) {
|
|
290
250
|
amountTokenOut = amountSharesToRedeem;
|
|
291
251
|
} else {
|
|
292
|
-
IVault.ExitPoolRequest memory request = _assembleExitRequest(
|
|
293
|
-
tokenOut,
|
|
294
|
-
amountSharesToRedeem
|
|
295
|
-
);
|
|
252
|
+
IVault.ExitPoolRequest memory request = _assembleExitRequest(tokenOut, amountSharesToRedeem);
|
|
296
253
|
|
|
297
254
|
amountTokenOut = previewHelper.exitPoolPreview(
|
|
298
255
|
balPoolId,
|
|
@@ -360,15 +317,7 @@ abstract contract PendleAuraBalancerStableLPSYV2 is SYBaseWithRewards {
|
|
|
360
317
|
|
|
361
318
|
function isValidTokenOut(address token) public view virtual override returns (bool);
|
|
362
319
|
|
|
363
|
-
function assetInfo()
|
|
364
|
-
external
|
|
365
|
-
view
|
|
366
|
-
returns (
|
|
367
|
-
AssetType assetType,
|
|
368
|
-
address assetAddress,
|
|
369
|
-
uint8 assetDecimals
|
|
370
|
-
)
|
|
371
|
-
{
|
|
320
|
+
function assetInfo() external view returns (AssetType assetType, address assetAddress, uint8 assetDecimals) {
|
|
372
321
|
return (AssetType.LIQUIDITY, balLp, IERC20Metadata(balLp).decimals());
|
|
373
322
|
}
|
|
374
323
|
}
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
pragma solidity ^0.8.17;
|
|
3
|
+
|
|
4
|
+
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
5
|
+
|
|
6
|
+
import "../../../../../interfaces/Balancer/IVault.sol";
|
|
7
|
+
import "../../../../../interfaces/Balancer/IRateProvider.sol";
|
|
8
|
+
import "../../../../../interfaces/Balancer/IBasePool.sol";
|
|
9
|
+
import "../../../../../interfaces/Balancer/IBalancerStablePreview.sol";
|
|
10
|
+
import "../../../../../interfaces/ConvexCurve/IBooster.sol";
|
|
11
|
+
import "../../../../../interfaces/ConvexCurve/IRewards.sol";
|
|
12
|
+
|
|
13
|
+
import "./StablePoolUserData.sol";
|
|
14
|
+
import "../../../../libraries/ArrayLib.sol";
|
|
15
|
+
import "../../../SYBaseWithRewardsUpg.sol";
|
|
16
|
+
|
|
17
|
+
abstract contract PendleAuraBalancerStableLPSYV3Upg is SYBaseWithRewardsUpg {
|
|
18
|
+
using ArrayLib for address[];
|
|
19
|
+
|
|
20
|
+
address internal constant BAL_TOKEN = 0xba100000625a3754423978a60c9317c58a424e3D;
|
|
21
|
+
address internal constant AURA_TOKEN = 0xC0c293ce456fF0ED870ADd98a0828Dd4d2903DBF;
|
|
22
|
+
address internal constant AURA_BOOSTER = 0xA57b8d98dAE62B26Ec3bcC4a365338157060B234;
|
|
23
|
+
address internal constant BALANCER_VAULT = 0xBA12222222228d8Ba445958a75a0704d566BF2C8;
|
|
24
|
+
uint256 internal constant DEFAULT_GAS_REENTRANCY_CHECK = 7000;
|
|
25
|
+
|
|
26
|
+
address public immutable balLp;
|
|
27
|
+
bytes32 public immutable balPoolId;
|
|
28
|
+
|
|
29
|
+
uint256 public immutable auraPid;
|
|
30
|
+
address public immutable auraRewardManager;
|
|
31
|
+
|
|
32
|
+
IBalancerStablePreview public immutable previewHelper;
|
|
33
|
+
|
|
34
|
+
uint256 public gasForReentrancyCheck;
|
|
35
|
+
address[] public extraRewards;
|
|
36
|
+
|
|
37
|
+
uint256[100] private __gap;
|
|
38
|
+
|
|
39
|
+
constructor(address _balLp, uint256 _auraPid, IBalancerStablePreview _previewHelper) SYBaseUpg(_balLp) {
|
|
40
|
+
balPoolId = IBasePool(_balLp).getPoolId();
|
|
41
|
+
auraPid = _auraPid;
|
|
42
|
+
|
|
43
|
+
(balLp, auraRewardManager) = _getPoolInfo(_auraPid);
|
|
44
|
+
if (balLp != _balLp) revert Errors.SYBalancerInvalidPid();
|
|
45
|
+
|
|
46
|
+
previewHelper = _previewHelper;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function __PendleAuraBalancerStableLPSYV3Upg_init(
|
|
50
|
+
string memory _name,
|
|
51
|
+
string memory _symbol
|
|
52
|
+
) internal onlyInitializing {
|
|
53
|
+
__SYBaseUpg_init(_name, _symbol);
|
|
54
|
+
|
|
55
|
+
_safeApproveInf(balLp, AURA_BOOSTER);
|
|
56
|
+
address[] memory tokens = _getPoolTokenAddresses();
|
|
57
|
+
for (uint256 i = 0; i < tokens.length; ++i) {
|
|
58
|
+
_safeApproveInf(tokens[i], BALANCER_VAULT);
|
|
59
|
+
}
|
|
60
|
+
gasForReentrancyCheck = DEFAULT_GAS_REENTRANCY_CHECK;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function _getPoolInfo(uint256 _auraPid) internal view returns (address _auraLp, address _auraRewardManager) {
|
|
64
|
+
if (_auraPid > IBooster(AURA_BOOSTER).poolLength()) revert Errors.SYBalancerInvalidPid();
|
|
65
|
+
(_auraLp, , , _auraRewardManager, , ) = IBooster(AURA_BOOSTER).poolInfo(_auraPid);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/*///////////////////////////////////////////////////////////////
|
|
69
|
+
DEPOSIT/REDEEM USING BASE TOKENS
|
|
70
|
+
//////////////////////////////////////////////////////////////*/
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @notice Either wraps LP, or also joins pool using exact tokenIn
|
|
74
|
+
*/
|
|
75
|
+
function _deposit(address tokenIn, uint256 amount) internal virtual override returns (uint256 amountSharesOut) {
|
|
76
|
+
if (tokenIn == balLp) {
|
|
77
|
+
amountSharesOut = amount;
|
|
78
|
+
} else {
|
|
79
|
+
amountSharesOut = _depositToBalancer(tokenIn, amount);
|
|
80
|
+
}
|
|
81
|
+
IBooster(AURA_BOOSTER).deposit(auraPid, amountSharesOut, true);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @notice Either unwraps LP, or also exits pool using exact LP for only `tokenOut`
|
|
86
|
+
*/
|
|
87
|
+
function _redeem(
|
|
88
|
+
address receiver,
|
|
89
|
+
address tokenOut,
|
|
90
|
+
uint256 amountSharesToRedeem
|
|
91
|
+
) internal virtual override returns (uint256 amountTokenOut) {
|
|
92
|
+
IRewards(auraRewardManager).withdrawAndUnwrap(amountSharesToRedeem, false);
|
|
93
|
+
|
|
94
|
+
if (tokenOut == balLp) {
|
|
95
|
+
amountTokenOut = amountSharesToRedeem;
|
|
96
|
+
_transferOut(tokenOut, receiver, amountTokenOut);
|
|
97
|
+
} else {
|
|
98
|
+
amountTokenOut = _redeemFromBalancer(receiver, tokenOut, amountSharesToRedeem);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function exchangeRate() external view override returns (uint256) {
|
|
103
|
+
_checkBalancerReadOnlyReentrancy();
|
|
104
|
+
return IRateProvider(balLp).getRate();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/*
|
|
108
|
+
* The `manageUserBalance` function is a non-view function that includes a reentrancy guard
|
|
109
|
+
in the form of `_require(_status != _ENTERED, Errors.REENTRANCY);`. To prevent
|
|
110
|
+
read-only reentrancy, it's important to ensure that our `manageUserBalance` has enough gas
|
|
111
|
+
to reach this check, so that it can fail if necessary.
|
|
112
|
+
|
|
113
|
+
* On the way to the check, there's at most one `COLD_SLOAD` plus miscellaneous decoding &
|
|
114
|
+
require, which we've found through testing to cost no more than 3200 gas. Therefore,
|
|
115
|
+
attaching 7000 gas should guarantee that it's always possible to reach the check.
|
|
116
|
+
|
|
117
|
+
* Once we've reached the check, one of two scenarios can occur:
|
|
118
|
+
1. The call doesn't pass the check, and reverts with error `BAL#400` ⇒ `response.length = 100`.
|
|
119
|
+
2. The call passes the check. Then, the call can either:
|
|
120
|
+
a. continue on to set the `status` variable to 2, causing the EVM to revert (since
|
|
121
|
+
the sub-call is a `staticcall`), and `response.length == 0`
|
|
122
|
+
b. run out of gas, which will also lead to a revert with `response.length == 0`
|
|
123
|
+
In both cases, to differentiate between 1 and 2, we check `response.length != 0`. If it's
|
|
124
|
+
true, then it's a read-only reentrancy. Otherwise, we're good (and we can ignore
|
|
125
|
+
differentiating between 2a and 2b).
|
|
126
|
+
*/
|
|
127
|
+
function _checkBalancerReadOnlyReentrancy() internal view {
|
|
128
|
+
IVault.UserBalanceOp[] memory noop = new IVault.UserBalanceOp[](0);
|
|
129
|
+
|
|
130
|
+
(bool isSuccess, bytes memory response) = BALANCER_VAULT.staticcall{gas: gasForReentrancyCheck}(
|
|
131
|
+
abi.encodeWithSignature("manageUserBalance((uint8,address,uint256,address,address)[])", noop)
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
assert(!isSuccess);
|
|
135
|
+
if (response.length != 0) revert Errors.SYBalancerReentrancy();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function setGasForReentrancyCheck(uint256 newGas) external onlyOwner {
|
|
139
|
+
require(newGas >= DEFAULT_GAS_REENTRANCY_CHECK, "lower than default");
|
|
140
|
+
gasForReentrancyCheck = newGas;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/*///////////////////////////////////////////////////////////////
|
|
144
|
+
BALANCER-RELATED FUNCTIONS
|
|
145
|
+
//////////////////////////////////////////////////////////////*/
|
|
146
|
+
|
|
147
|
+
function _depositToBalancer(address tokenIn, uint256 amountTokenToDeposit) internal virtual returns (uint256) {
|
|
148
|
+
IVault.JoinPoolRequest memory request = _assembleJoinRequest(tokenIn, amountTokenToDeposit);
|
|
149
|
+
IVault(BALANCER_VAULT).joinPool(balPoolId, address(this), address(this), request);
|
|
150
|
+
|
|
151
|
+
// amount shares out = amount LP received
|
|
152
|
+
return _selfBalance(balLp);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function _assembleJoinRequest(
|
|
156
|
+
address tokenIn,
|
|
157
|
+
uint256 amountTokenToDeposit
|
|
158
|
+
) internal view virtual returns (IVault.JoinPoolRequest memory request) {
|
|
159
|
+
// max amounts in
|
|
160
|
+
address[] memory assets = _getPoolTokenAddresses();
|
|
161
|
+
|
|
162
|
+
uint256 amountsLength = _getBPTIndex() < type(uint256).max ? assets.length - 1 : assets.length;
|
|
163
|
+
|
|
164
|
+
uint256[] memory amountsIn = new uint256[](amountsLength);
|
|
165
|
+
uint256[] memory maxAmountsIn = new uint256[](assets.length);
|
|
166
|
+
|
|
167
|
+
uint256 index = assets.find(tokenIn);
|
|
168
|
+
uint256 indexSkipBPT = index > _getBPTIndex() ? index - 1 : index;
|
|
169
|
+
maxAmountsIn[index] = amountsIn[indexSkipBPT] = amountTokenToDeposit;
|
|
170
|
+
|
|
171
|
+
// encode user data
|
|
172
|
+
StablePoolUserData.JoinKind joinKind = StablePoolUserData.JoinKind.EXACT_TOKENS_IN_FOR_BPT_OUT;
|
|
173
|
+
uint256 minimumBPT = 0;
|
|
174
|
+
|
|
175
|
+
bytes memory userData = abi.encode(joinKind, amountsIn, minimumBPT);
|
|
176
|
+
|
|
177
|
+
// assemble joinpoolrequest
|
|
178
|
+
request = IVault.JoinPoolRequest(assets, maxAmountsIn, userData, false);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function _redeemFromBalancer(
|
|
182
|
+
address receiver,
|
|
183
|
+
address tokenOut,
|
|
184
|
+
uint256 amountLpToRedeem
|
|
185
|
+
) internal virtual returns (uint256) {
|
|
186
|
+
uint256 balanceBefore = IERC20(tokenOut).balanceOf(receiver);
|
|
187
|
+
|
|
188
|
+
IVault.ExitPoolRequest memory request = _assembleExitRequest(tokenOut, amountLpToRedeem);
|
|
189
|
+
IVault(BALANCER_VAULT).exitPool(balPoolId, address(this), payable(receiver), request);
|
|
190
|
+
|
|
191
|
+
// calculate amount of tokens out
|
|
192
|
+
uint256 balanceAfter = IERC20(tokenOut).balanceOf(receiver);
|
|
193
|
+
return balanceAfter - balanceBefore;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function _assembleExitRequest(
|
|
197
|
+
address tokenOut,
|
|
198
|
+
uint256 amountLpToRedeem
|
|
199
|
+
) internal view virtual returns (IVault.ExitPoolRequest memory request) {
|
|
200
|
+
address[] memory assets = _getPoolTokenAddresses();
|
|
201
|
+
uint256[] memory minAmountsOut = new uint256[](assets.length);
|
|
202
|
+
|
|
203
|
+
// encode user data
|
|
204
|
+
StablePoolUserData.ExitKind exitKind = StablePoolUserData.ExitKind.EXACT_BPT_IN_FOR_ONE_TOKEN_OUT;
|
|
205
|
+
uint256 bptAmountIn = amountLpToRedeem;
|
|
206
|
+
uint256 exitTokenIndex = assets.find(tokenOut);
|
|
207
|
+
|
|
208
|
+
// must drop BPT index as well
|
|
209
|
+
exitTokenIndex = _getBPTIndex() < exitTokenIndex ? exitTokenIndex - 1 : exitTokenIndex;
|
|
210
|
+
|
|
211
|
+
bytes memory userData = abi.encode(exitKind, bptAmountIn, exitTokenIndex);
|
|
212
|
+
|
|
213
|
+
// assemble exitpoolrequest
|
|
214
|
+
request = IVault.ExitPoolRequest(assets, minAmountsOut, userData, false);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/// @dev this should return tokens in the same order as `IVault.getPoolTokens()`
|
|
218
|
+
function _getPoolTokenAddresses() internal view virtual returns (address[] memory res);
|
|
219
|
+
|
|
220
|
+
/// @dev should be overriden if and only if BPT is one of the pool tokens
|
|
221
|
+
function _getBPTIndex() internal view virtual returns (uint256) {
|
|
222
|
+
return type(uint256).max;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/*///////////////////////////////////////////////////////////////
|
|
226
|
+
PREVIEW FUNCTIONS
|
|
227
|
+
//////////////////////////////////////////////////////////////*/
|
|
228
|
+
|
|
229
|
+
function _previewDeposit(
|
|
230
|
+
address tokenIn,
|
|
231
|
+
uint256 amountTokenToDeposit
|
|
232
|
+
) internal view virtual override returns (uint256 amountSharesOut) {
|
|
233
|
+
if (tokenIn == balLp) {
|
|
234
|
+
amountSharesOut = amountTokenToDeposit;
|
|
235
|
+
} else {
|
|
236
|
+
IVault.JoinPoolRequest memory request = _assembleJoinRequest(tokenIn, amountTokenToDeposit);
|
|
237
|
+
amountSharesOut = previewHelper.joinPoolPreview(
|
|
238
|
+
balPoolId,
|
|
239
|
+
address(this),
|
|
240
|
+
address(this),
|
|
241
|
+
request,
|
|
242
|
+
_getImmutablePoolData()
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function _previewRedeem(
|
|
248
|
+
address tokenOut,
|
|
249
|
+
uint256 amountSharesToRedeem
|
|
250
|
+
) internal view virtual override returns (uint256 amountTokenOut) {
|
|
251
|
+
if (tokenOut == balLp) {
|
|
252
|
+
amountTokenOut = amountSharesToRedeem;
|
|
253
|
+
} else {
|
|
254
|
+
IVault.ExitPoolRequest memory request = _assembleExitRequest(tokenOut, amountSharesToRedeem);
|
|
255
|
+
|
|
256
|
+
amountTokenOut = previewHelper.exitPoolPreview(
|
|
257
|
+
balPoolId,
|
|
258
|
+
address(this),
|
|
259
|
+
address(this),
|
|
260
|
+
request,
|
|
261
|
+
_getImmutablePoolData()
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function _getImmutablePoolData() internal view virtual returns (bytes memory);
|
|
267
|
+
|
|
268
|
+
/*///////////////////////////////////////////////////////////////
|
|
269
|
+
REWARDS-RELATED
|
|
270
|
+
//////////////////////////////////////////////////////////////*/
|
|
271
|
+
|
|
272
|
+
/// @notice allows owner to add new reward tokens in in case Aura does so with their pools
|
|
273
|
+
function addRewardTokens(address token) external virtual onlyOwner {
|
|
274
|
+
extraRewards.push(token);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function extraRewardsLength() external view virtual returns (uint256) {
|
|
278
|
+
return extraRewards.length;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function _getRewardTokens() internal view virtual override returns (address[] memory res) {
|
|
282
|
+
uint256 extraRewardsLen = extraRewards.length;
|
|
283
|
+
res = new address[](2 + extraRewardsLen);
|
|
284
|
+
res[0] = BAL_TOKEN;
|
|
285
|
+
res[1] = AURA_TOKEN;
|
|
286
|
+
for (uint256 i = 0; i < extraRewardsLen; i++) {
|
|
287
|
+
res[2 + i] = extraRewards[i];
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function _redeemExternalReward() internal virtual override {
|
|
292
|
+
IRewards(auraRewardManager).getReward(address(this), true);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/*///////////////////////////////////////////////////////////////
|
|
296
|
+
MISC FUNCTIONS FOR METADATA
|
|
297
|
+
//////////////////////////////////////////////////////////////*/
|
|
298
|
+
|
|
299
|
+
function getTokensIn() public view virtual override returns (address[] memory res);
|
|
300
|
+
|
|
301
|
+
function getTokensOut() public view virtual override returns (address[] memory res);
|
|
302
|
+
|
|
303
|
+
function isValidTokenIn(address token) public view virtual override returns (bool);
|
|
304
|
+
|
|
305
|
+
function isValidTokenOut(address token) public view virtual override returns (bool);
|
|
306
|
+
|
|
307
|
+
function assetInfo() external view returns (AssetType assetType, address assetAddress, uint8 assetDecimals) {
|
|
308
|
+
return (AssetType.LIQUIDITY, balLp, IERC20Metadata(balLp).decimals());
|
|
309
|
+
}
|
|
310
|
+
}
|
package/contracts/core/StandardizedYield/implementations/BalancerStable/base/StablePoolUserData.sol
CHANGED
|
@@ -18,9 +18,7 @@ library StablePoolUserData {
|
|
|
18
18
|
(, amountsIn, minBPTAmountOut) = abi.decode(self, (JoinKind, uint256[], uint256));
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
function exactBptInForTokenOut(
|
|
22
|
-
bytes memory self
|
|
23
|
-
) internal pure returns (uint256 bptAmountIn, uint256 tokenIndex) {
|
|
21
|
+
function exactBptInForTokenOut(bytes memory self) internal pure returns (uint256 bptAmountIn, uint256 tokenIndex) {
|
|
24
22
|
(, bptAmountIn, tokenIndex) = abi.decode(self, (ExitKind, uint256, uint256));
|
|
25
23
|
}
|
|
26
24
|
}
|
package/contracts/core/StandardizedYield/implementations/BalancerStable/base/StablePreviewBase.sol
CHANGED
|
@@ -66,10 +66,7 @@ abstract contract StablePreviewBase is IBalancerStablePreview {
|
|
|
66
66
|
bytes memory data
|
|
67
67
|
) private view returns (uint256 amountBptOrTokensOut) {
|
|
68
68
|
IERC20[] memory tokens = _translateToIERC20(change.assets);
|
|
69
|
-
(uint256[] memory balances, uint256 lastChangeBlock) = _validateTokensAndGetBalances(
|
|
70
|
-
poolId,
|
|
71
|
-
tokens
|
|
72
|
-
);
|
|
69
|
+
(uint256[] memory balances, uint256 lastChangeBlock) = _validateTokensAndGetBalances(poolId, tokens);
|
|
73
70
|
|
|
74
71
|
amountBptOrTokensOut = _callPoolBalanceChange(
|
|
75
72
|
kind,
|
|
@@ -126,8 +123,7 @@ abstract contract StablePreviewBase is IBalancerStablePreview {
|
|
|
126
123
|
bytes32 poolId,
|
|
127
124
|
IERC20[] memory //expectedTokens
|
|
128
125
|
) private view returns (uint256[] memory, uint256) {
|
|
129
|
-
(, uint256[] memory balances, uint256 lastChangeBlock) = IVault(BALANCER_VAULT)
|
|
130
|
-
.getPoolTokens(poolId);
|
|
126
|
+
(, uint256[] memory balances, uint256 lastChangeBlock) = IVault(BALANCER_VAULT).getPoolTokens(poolId);
|
|
131
127
|
return (balances, lastChangeBlock);
|
|
132
128
|
}
|
|
133
129
|
|