@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
|
@@ -6,17 +6,12 @@ import "../erc20/PendleERC20Permit.sol";
|
|
|
6
6
|
|
|
7
7
|
import "../libraries/math/PMath.sol";
|
|
8
8
|
import "../libraries/TokenHelper.sol";
|
|
9
|
+
import "../libraries/ArrayLib.sol";
|
|
9
10
|
import "../libraries/Errors.sol";
|
|
10
11
|
import "../libraries/BoringOwnableUpgradeable.sol";
|
|
11
12
|
import "@openzeppelin/contracts/security/Pausable.sol";
|
|
12
13
|
|
|
13
|
-
abstract contract SYBase is
|
|
14
|
-
IStandardizedYield,
|
|
15
|
-
PendleERC20Permit,
|
|
16
|
-
TokenHelper,
|
|
17
|
-
BoringOwnableUpgradeable,
|
|
18
|
-
Pausable
|
|
19
|
-
{
|
|
14
|
+
abstract contract SYBase is IStandardizedYield, PendleERC20Permit, TokenHelper, BoringOwnableUpgradeable, Pausable {
|
|
20
15
|
using PMath for uint256;
|
|
21
16
|
|
|
22
17
|
address public immutable yieldToken;
|
|
@@ -52,8 +47,7 @@ abstract contract SYBase is
|
|
|
52
47
|
_transferIn(tokenIn, msg.sender, amountTokenToDeposit);
|
|
53
48
|
|
|
54
49
|
amountSharesOut = _deposit(tokenIn, amountTokenToDeposit);
|
|
55
|
-
if (amountSharesOut < minSharesOut)
|
|
56
|
-
revert Errors.SYInsufficientSharesOut(amountSharesOut, minSharesOut);
|
|
50
|
+
if (amountSharesOut < minSharesOut) revert Errors.SYInsufficientSharesOut(amountSharesOut, minSharesOut);
|
|
57
51
|
|
|
58
52
|
_mint(receiver, amountSharesOut);
|
|
59
53
|
emit Deposit(msg.sender, receiver, tokenIn, amountTokenToDeposit, amountSharesOut);
|
|
@@ -79,8 +73,7 @@ abstract contract SYBase is
|
|
|
79
73
|
}
|
|
80
74
|
|
|
81
75
|
amountTokenOut = _redeem(receiver, tokenOut, amountSharesToRedeem);
|
|
82
|
-
if (amountTokenOut < minTokenOut)
|
|
83
|
-
revert Errors.SYInsufficientTokenOut(amountTokenOut, minTokenOut);
|
|
76
|
+
if (amountTokenOut < minTokenOut) revert Errors.SYInsufficientTokenOut(amountTokenOut, minTokenOut);
|
|
84
77
|
emit Redeem(msg.sender, receiver, tokenOut, amountSharesToRedeem, amountTokenOut);
|
|
85
78
|
}
|
|
86
79
|
|
|
@@ -90,10 +83,7 @@ abstract contract SYBase is
|
|
|
90
83
|
* @param amountDeposited amount of base tokens deposited
|
|
91
84
|
* @return amountSharesOut amount of shares minted
|
|
92
85
|
*/
|
|
93
|
-
function _deposit(
|
|
94
|
-
address tokenIn,
|
|
95
|
-
uint256 amountDeposited
|
|
96
|
-
) internal virtual returns (uint256 amountSharesOut);
|
|
86
|
+
function _deposit(address tokenIn, uint256 amountDeposited) internal virtual returns (uint256 amountSharesOut);
|
|
97
87
|
|
|
98
88
|
/**
|
|
99
89
|
* @notice redeems base tokens based on amount of shares to be burned
|
|
@@ -123,31 +113,21 @@ abstract contract SYBase is
|
|
|
123
113
|
/**
|
|
124
114
|
* @dev See {IStandardizedYield-claimRewards}
|
|
125
115
|
*/
|
|
126
|
-
function claimRewards(
|
|
127
|
-
address /*user*/
|
|
128
|
-
) external virtual override returns (uint256[] memory rewardAmounts) {
|
|
116
|
+
function claimRewards(address /*user*/) external virtual override returns (uint256[] memory rewardAmounts) {
|
|
129
117
|
rewardAmounts = new uint256[](0);
|
|
130
118
|
}
|
|
131
119
|
|
|
132
120
|
/**
|
|
133
121
|
* @dev See {IStandardizedYield-getRewardTokens}
|
|
134
122
|
*/
|
|
135
|
-
function getRewardTokens()
|
|
136
|
-
external
|
|
137
|
-
view
|
|
138
|
-
virtual
|
|
139
|
-
override
|
|
140
|
-
returns (address[] memory rewardTokens)
|
|
141
|
-
{
|
|
123
|
+
function getRewardTokens() external view virtual override returns (address[] memory rewardTokens) {
|
|
142
124
|
rewardTokens = new address[](0);
|
|
143
125
|
}
|
|
144
126
|
|
|
145
127
|
/**
|
|
146
128
|
* @dev See {IStandardizedYield-accruedRewards}
|
|
147
129
|
*/
|
|
148
|
-
function accruedRewards(
|
|
149
|
-
address /*user*/
|
|
150
|
-
) external view virtual override returns (uint256[] memory rewardAmounts) {
|
|
130
|
+
function accruedRewards(address /*user*/) external view virtual override returns (uint256[] memory rewardAmounts) {
|
|
151
131
|
rewardAmounts = new uint256[](0);
|
|
152
132
|
}
|
|
153
133
|
|
|
@@ -155,13 +135,7 @@ abstract contract SYBase is
|
|
|
155
135
|
indexes = new uint256[](0);
|
|
156
136
|
}
|
|
157
137
|
|
|
158
|
-
function rewardIndexesStored()
|
|
159
|
-
external
|
|
160
|
-
view
|
|
161
|
-
virtual
|
|
162
|
-
override
|
|
163
|
-
returns (uint256[] memory indexes)
|
|
164
|
-
{
|
|
138
|
+
function rewardIndexesStored() external view virtual override returns (uint256[] memory indexes) {
|
|
165
139
|
indexes = new uint256[](0);
|
|
166
140
|
}
|
|
167
141
|
|
|
@@ -193,11 +167,7 @@ abstract contract SYBase is
|
|
|
193
167
|
_unpause();
|
|
194
168
|
}
|
|
195
169
|
|
|
196
|
-
function _beforeTokenTransfer(
|
|
197
|
-
address,
|
|
198
|
-
address,
|
|
199
|
-
uint256
|
|
200
|
-
) internal virtual override whenNotPaused {}
|
|
170
|
+
function _beforeTokenTransfer(address, address, uint256) internal virtual override whenNotPaused {}
|
|
201
171
|
|
|
202
172
|
function _previewDeposit(
|
|
203
173
|
address tokenIn,
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
pragma solidity ^0.8.17;
|
|
3
|
+
|
|
4
|
+
import "../../interfaces/IStandardizedYield.sol";
|
|
5
|
+
|
|
6
|
+
import "../erc20/PendleERC20PermitUpg.sol";
|
|
7
|
+
|
|
8
|
+
import "../libraries/math/PMath.sol";
|
|
9
|
+
import "../libraries/TokenHelper.sol";
|
|
10
|
+
import "../libraries/Errors.sol";
|
|
11
|
+
import "../libraries/BoringOwnableUpgradeable.sol";
|
|
12
|
+
import "@openzeppelin/contracts/security/Pausable.sol";
|
|
13
|
+
|
|
14
|
+
abstract contract SYBaseUpg is
|
|
15
|
+
IStandardizedYield,
|
|
16
|
+
PendleERC20PermitUpg,
|
|
17
|
+
TokenHelper,
|
|
18
|
+
BoringOwnableUpgradeable,
|
|
19
|
+
Pausable
|
|
20
|
+
{
|
|
21
|
+
using PMath for uint256;
|
|
22
|
+
|
|
23
|
+
address public immutable yieldToken;
|
|
24
|
+
|
|
25
|
+
uint256[100] private __gap;
|
|
26
|
+
|
|
27
|
+
constructor(address _yieldToken) PendleERC20Upg(IERC20Metadata(_yieldToken).decimals()) {
|
|
28
|
+
yieldToken = _yieldToken;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function __SYBaseUpg_init(string memory name_, string memory symbol_) internal onlyInitializing {
|
|
32
|
+
__ERC20PermitUpg_init(name_, symbol_);
|
|
33
|
+
__BoringOwnable_init();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// solhint-disable no-empty-blocks
|
|
37
|
+
receive() external payable {}
|
|
38
|
+
|
|
39
|
+
/*///////////////////////////////////////////////////////////////
|
|
40
|
+
DEPOSIT/REDEEM USING BASE TOKENS
|
|
41
|
+
//////////////////////////////////////////////////////////////*/
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @dev See {IStandardizedYield-deposit}
|
|
45
|
+
*/
|
|
46
|
+
function deposit(
|
|
47
|
+
address receiver,
|
|
48
|
+
address tokenIn,
|
|
49
|
+
uint256 amountTokenToDeposit,
|
|
50
|
+
uint256 minSharesOut
|
|
51
|
+
) external payable nonReentrant returns (uint256 amountSharesOut) {
|
|
52
|
+
if (!isValidTokenIn(tokenIn)) revert Errors.SYInvalidTokenIn(tokenIn);
|
|
53
|
+
if (amountTokenToDeposit == 0) revert Errors.SYZeroDeposit();
|
|
54
|
+
|
|
55
|
+
_transferIn(tokenIn, msg.sender, amountTokenToDeposit);
|
|
56
|
+
|
|
57
|
+
amountSharesOut = _deposit(tokenIn, amountTokenToDeposit);
|
|
58
|
+
if (amountSharesOut < minSharesOut) revert Errors.SYInsufficientSharesOut(amountSharesOut, minSharesOut);
|
|
59
|
+
|
|
60
|
+
_mint(receiver, amountSharesOut);
|
|
61
|
+
emit Deposit(msg.sender, receiver, tokenIn, amountTokenToDeposit, amountSharesOut);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @dev See {IStandardizedYield-redeem}
|
|
66
|
+
*/
|
|
67
|
+
function redeem(
|
|
68
|
+
address receiver,
|
|
69
|
+
uint256 amountSharesToRedeem,
|
|
70
|
+
address tokenOut,
|
|
71
|
+
uint256 minTokenOut,
|
|
72
|
+
bool burnFromInternalBalance
|
|
73
|
+
) external nonReentrant returns (uint256 amountTokenOut) {
|
|
74
|
+
if (!isValidTokenOut(tokenOut)) revert Errors.SYInvalidTokenOut(tokenOut);
|
|
75
|
+
if (amountSharesToRedeem == 0) revert Errors.SYZeroRedeem();
|
|
76
|
+
|
|
77
|
+
if (burnFromInternalBalance) {
|
|
78
|
+
_burn(address(this), amountSharesToRedeem);
|
|
79
|
+
} else {
|
|
80
|
+
_burn(msg.sender, amountSharesToRedeem);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
amountTokenOut = _redeem(receiver, tokenOut, amountSharesToRedeem);
|
|
84
|
+
if (amountTokenOut < minTokenOut) revert Errors.SYInsufficientTokenOut(amountTokenOut, minTokenOut);
|
|
85
|
+
emit Redeem(msg.sender, receiver, tokenOut, amountSharesToRedeem, amountTokenOut);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @notice mint shares based on the deposited base tokens
|
|
90
|
+
* @param tokenIn base token address used to mint shares
|
|
91
|
+
* @param amountDeposited amount of base tokens deposited
|
|
92
|
+
* @return amountSharesOut amount of shares minted
|
|
93
|
+
*/
|
|
94
|
+
function _deposit(address tokenIn, uint256 amountDeposited) internal virtual returns (uint256 amountSharesOut);
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @notice redeems base tokens based on amount of shares to be burned
|
|
98
|
+
* @param tokenOut address of the base token to be redeemed
|
|
99
|
+
* @param amountSharesToRedeem amount of shares to be burned
|
|
100
|
+
* @return amountTokenOut amount of base tokens redeemed
|
|
101
|
+
*/
|
|
102
|
+
function _redeem(
|
|
103
|
+
address receiver,
|
|
104
|
+
address tokenOut,
|
|
105
|
+
uint256 amountSharesToRedeem
|
|
106
|
+
) internal virtual returns (uint256 amountTokenOut);
|
|
107
|
+
|
|
108
|
+
/*///////////////////////////////////////////////////////////////
|
|
109
|
+
EXCHANGE-RATE
|
|
110
|
+
//////////////////////////////////////////////////////////////*/
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @dev See {IStandardizedYield-exchangeRate}
|
|
114
|
+
*/
|
|
115
|
+
function exchangeRate() external view virtual override returns (uint256 res);
|
|
116
|
+
|
|
117
|
+
/*///////////////////////////////////////////////////////////////
|
|
118
|
+
REWARDS-RELATED
|
|
119
|
+
//////////////////////////////////////////////////////////////*/
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @dev See {IStandardizedYield-claimRewards}
|
|
123
|
+
*/
|
|
124
|
+
function claimRewards(address /*user*/) external virtual override returns (uint256[] memory rewardAmounts) {
|
|
125
|
+
rewardAmounts = new uint256[](0);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* @dev See {IStandardizedYield-getRewardTokens}
|
|
130
|
+
*/
|
|
131
|
+
function getRewardTokens() external view virtual override returns (address[] memory rewardTokens) {
|
|
132
|
+
rewardTokens = new address[](0);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* @dev See {IStandardizedYield-accruedRewards}
|
|
137
|
+
*/
|
|
138
|
+
function accruedRewards(address /*user*/) external view virtual override returns (uint256[] memory rewardAmounts) {
|
|
139
|
+
rewardAmounts = new uint256[](0);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function rewardIndexesCurrent() external virtual override returns (uint256[] memory indexes) {
|
|
143
|
+
indexes = new uint256[](0);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function rewardIndexesStored() external view virtual override returns (uint256[] memory indexes) {
|
|
147
|
+
indexes = new uint256[](0);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/*///////////////////////////////////////////////////////////////
|
|
151
|
+
MISC METADATA FUNCTIONS
|
|
152
|
+
//////////////////////////////////////////////////////////////*/
|
|
153
|
+
|
|
154
|
+
function previewDeposit(
|
|
155
|
+
address tokenIn,
|
|
156
|
+
uint256 amountTokenToDeposit
|
|
157
|
+
) external view virtual returns (uint256 amountSharesOut) {
|
|
158
|
+
if (!isValidTokenIn(tokenIn)) revert Errors.SYInvalidTokenIn(tokenIn);
|
|
159
|
+
return _previewDeposit(tokenIn, amountTokenToDeposit);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function previewRedeem(
|
|
163
|
+
address tokenOut,
|
|
164
|
+
uint256 amountSharesToRedeem
|
|
165
|
+
) external view virtual returns (uint256 amountTokenOut) {
|
|
166
|
+
if (!isValidTokenOut(tokenOut)) revert Errors.SYInvalidTokenOut(tokenOut);
|
|
167
|
+
return _previewRedeem(tokenOut, amountSharesToRedeem);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function pause() external onlyOwner {
|
|
171
|
+
_pause();
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function unpause() external onlyOwner {
|
|
175
|
+
_unpause();
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function _beforeTokenTransfer(address, address, uint256) internal virtual override whenNotPaused {}
|
|
179
|
+
|
|
180
|
+
function _previewDeposit(
|
|
181
|
+
address tokenIn,
|
|
182
|
+
uint256 amountTokenToDeposit
|
|
183
|
+
) internal view virtual returns (uint256 amountSharesOut);
|
|
184
|
+
|
|
185
|
+
function _previewRedeem(
|
|
186
|
+
address tokenOut,
|
|
187
|
+
uint256 amountSharesToRedeem
|
|
188
|
+
) internal view virtual returns (uint256 amountTokenOut);
|
|
189
|
+
|
|
190
|
+
function getTokensIn() public view virtual returns (address[] memory res);
|
|
191
|
+
|
|
192
|
+
function getTokensOut() public view virtual returns (address[] memory res);
|
|
193
|
+
|
|
194
|
+
function isValidTokenIn(address token) public view virtual returns (bool);
|
|
195
|
+
|
|
196
|
+
function isValidTokenOut(address token) public view virtual returns (bool);
|
|
197
|
+
}
|
|
@@ -24,13 +24,9 @@ abstract contract SYBaseWithRewards is SYBase, RewardManager {
|
|
|
24
24
|
/**
|
|
25
25
|
* @dev See {IStandardizedYield-claimRewards}
|
|
26
26
|
*/
|
|
27
|
-
function claimRewards(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
override
|
|
31
|
-
nonReentrant
|
|
32
|
-
returns (uint256[] memory rewardAmounts)
|
|
33
|
-
{
|
|
27
|
+
function claimRewards(
|
|
28
|
+
address user
|
|
29
|
+
) external virtual override nonReentrant whenNotPaused returns (uint256[] memory rewardAmounts) {
|
|
34
30
|
_updateAndDistributeRewards(user);
|
|
35
31
|
rewardAmounts = _doTransferOutRewards(user, user);
|
|
36
32
|
|
|
@@ -40,26 +36,14 @@ abstract contract SYBaseWithRewards is SYBase, RewardManager {
|
|
|
40
36
|
/**
|
|
41
37
|
* @dev See {IStandardizedYield-getRewardTokens}
|
|
42
38
|
*/
|
|
43
|
-
function getRewardTokens()
|
|
44
|
-
external
|
|
45
|
-
view
|
|
46
|
-
virtual
|
|
47
|
-
override
|
|
48
|
-
returns (address[] memory rewardTokens)
|
|
49
|
-
{
|
|
39
|
+
function getRewardTokens() external view virtual override returns (address[] memory rewardTokens) {
|
|
50
40
|
rewardTokens = _getRewardTokens();
|
|
51
41
|
}
|
|
52
42
|
|
|
53
43
|
/**
|
|
54
44
|
* @dev See {IStandardizedYield-accruedRewards}
|
|
55
45
|
*/
|
|
56
|
-
function accruedRewards(address user)
|
|
57
|
-
external
|
|
58
|
-
view
|
|
59
|
-
virtual
|
|
60
|
-
override
|
|
61
|
-
returns (uint256[] memory rewardAmounts)
|
|
62
|
-
{
|
|
46
|
+
function accruedRewards(address user) external view virtual override returns (uint256[] memory rewardAmounts) {
|
|
63
47
|
address[] memory rewardTokens = _getRewardTokens();
|
|
64
48
|
rewardAmounts = new uint256[](rewardTokens.length);
|
|
65
49
|
for (uint256 i = 0; i < rewardTokens.length; ) {
|
|
@@ -70,23 +54,11 @@ abstract contract SYBaseWithRewards is SYBase, RewardManager {
|
|
|
70
54
|
}
|
|
71
55
|
}
|
|
72
56
|
|
|
73
|
-
function rewardIndexesCurrent()
|
|
74
|
-
|
|
75
|
-
override
|
|
76
|
-
nonReentrant
|
|
77
|
-
returns (uint256[] memory indexes)
|
|
78
|
-
{
|
|
79
|
-
_updateRewardIndex();
|
|
80
|
-
return rewardIndexesStored();
|
|
57
|
+
function rewardIndexesCurrent() external override nonReentrant whenNotPaused returns (uint256[] memory indexes) {
|
|
58
|
+
(, indexes) = _updateRewardIndex();
|
|
81
59
|
}
|
|
82
60
|
|
|
83
|
-
function rewardIndexesStored()
|
|
84
|
-
public
|
|
85
|
-
view
|
|
86
|
-
virtual
|
|
87
|
-
override
|
|
88
|
-
returns (uint256[] memory indexes)
|
|
89
|
-
{
|
|
61
|
+
function rewardIndexesStored() public view virtual override returns (uint256[] memory indexes) {
|
|
90
62
|
address[] memory rewardTokens = _getRewardTokens();
|
|
91
63
|
indexes = new uint256[](rewardTokens.length);
|
|
92
64
|
for (uint256 i = 0; i < rewardTokens.length; ) {
|
|
@@ -116,11 +88,7 @@ abstract contract SYBaseWithRewards is SYBase, RewardManager {
|
|
|
116
88
|
/*///////////////////////////////////////////////////////////////
|
|
117
89
|
TRANSFER HOOKS
|
|
118
90
|
//////////////////////////////////////////////////////////////*/
|
|
119
|
-
function _beforeTokenTransfer(
|
|
120
|
-
address from,
|
|
121
|
-
address to,
|
|
122
|
-
uint256
|
|
123
|
-
) internal virtual override whenNotPaused {
|
|
91
|
+
function _beforeTokenTransfer(address from, address to, uint256) internal virtual override whenNotPaused {
|
|
124
92
|
_updateAndDistributeRewardsForTwo(from, to);
|
|
125
93
|
}
|
|
126
94
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
pragma solidity ^0.8.17;
|
|
3
|
+
|
|
4
|
+
import "../RewardManager/RewardManager.sol";
|
|
5
|
+
import "./SYBaseUpg.sol";
|
|
6
|
+
|
|
7
|
+
/// NOTE: yieldToken MUST NEVER BE a rewardToken, else the rewardManager will behave erroneously
|
|
8
|
+
abstract contract SYBaseWithRewardsUpg is SYBaseUpg, RewardManager {
|
|
9
|
+
using PMath for uint256;
|
|
10
|
+
using ArrayLib for address[];
|
|
11
|
+
|
|
12
|
+
uint256[100] private __gap;
|
|
13
|
+
|
|
14
|
+
/*///////////////////////////////////////////////////////////////
|
|
15
|
+
REWARDS-RELATED
|
|
16
|
+
//////////////////////////////////////////////////////////////*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @dev See {IStandardizedYield-claimRewards}
|
|
20
|
+
*/
|
|
21
|
+
function claimRewards(
|
|
22
|
+
address user
|
|
23
|
+
) external virtual override nonReentrant whenNotPaused returns (uint256[] memory rewardAmounts) {
|
|
24
|
+
_updateAndDistributeRewards(user);
|
|
25
|
+
rewardAmounts = _doTransferOutRewards(user, user);
|
|
26
|
+
|
|
27
|
+
emit ClaimRewards(user, _getRewardTokens(), rewardAmounts);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @dev See {IStandardizedYield-getRewardTokens}
|
|
32
|
+
*/
|
|
33
|
+
function getRewardTokens() external view virtual override returns (address[] memory rewardTokens) {
|
|
34
|
+
rewardTokens = _getRewardTokens();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @dev See {IStandardizedYield-accruedRewards}
|
|
39
|
+
*/
|
|
40
|
+
function accruedRewards(address user) external view virtual override returns (uint256[] memory rewardAmounts) {
|
|
41
|
+
address[] memory rewardTokens = _getRewardTokens();
|
|
42
|
+
rewardAmounts = new uint256[](rewardTokens.length);
|
|
43
|
+
for (uint256 i = 0; i < rewardTokens.length; ) {
|
|
44
|
+
rewardAmounts[i] = userReward[rewardTokens[i]][user].accrued;
|
|
45
|
+
unchecked {
|
|
46
|
+
i++;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function rewardIndexesCurrent() external override nonReentrant whenNotPaused returns (uint256[] memory indexes) {
|
|
52
|
+
(, indexes) = _updateRewardIndex();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function rewardIndexesStored() public view virtual override returns (uint256[] memory indexes) {
|
|
56
|
+
address[] memory rewardTokens = _getRewardTokens();
|
|
57
|
+
indexes = new uint256[](rewardTokens.length);
|
|
58
|
+
for (uint256 i = 0; i < rewardTokens.length; ) {
|
|
59
|
+
indexes[i] = rewardState[rewardTokens[i]].index;
|
|
60
|
+
unchecked {
|
|
61
|
+
i++;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @notice returns the total number of reward shares
|
|
68
|
+
* @dev this is simply the total supply of shares, as rewards shares are equivalent to SY shares
|
|
69
|
+
*/
|
|
70
|
+
function _rewardSharesTotal() internal view virtual override returns (uint256) {
|
|
71
|
+
return totalSupply();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @notice returns the reward shares of (`user`)
|
|
76
|
+
* @dev this is simply the SY balance of (`user`), as rewards shares are equivalent to SY shares
|
|
77
|
+
*/
|
|
78
|
+
function _rewardSharesUser(address user) internal view virtual override returns (uint256) {
|
|
79
|
+
return balanceOf(user);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/*///////////////////////////////////////////////////////////////
|
|
83
|
+
TRANSFER HOOKS
|
|
84
|
+
//////////////////////////////////////////////////////////////*/
|
|
85
|
+
function _beforeTokenTransfer(address from, address to, uint256) internal virtual override whenNotPaused {
|
|
86
|
+
_updateAndDistributeRewardsForTwo(from, to);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -16,10 +16,7 @@ library SYUtils {
|
|
|
16
16
|
return (assetAmount * ONE) / exchangeRate;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
function assetToSyUp(
|
|
20
|
-
uint256 exchangeRate,
|
|
21
|
-
uint256 assetAmount
|
|
22
|
-
) internal pure returns (uint256) {
|
|
19
|
+
function assetToSyUp(uint256 exchangeRate, uint256 assetAmount) internal pure returns (uint256) {
|
|
23
20
|
return (assetAmount * ONE + exchangeRate - 1) / exchangeRate;
|
|
24
21
|
}
|
|
25
22
|
}
|
|
@@ -16,26 +16,20 @@ abstract contract StEthHelper is TokenHelper {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/// @dev tokenIn must be either ETH, WETH or STETH
|
|
19
|
-
function _depositWstETH(
|
|
20
|
-
address tokenIn,
|
|
21
|
-
uint256 amountDep
|
|
22
|
-
) internal virtual returns (uint256 amountOut) {
|
|
19
|
+
function _depositWstETH(address tokenIn, uint256 amountDep) internal virtual returns (uint256 amountOut) {
|
|
23
20
|
uint256 amountStETH;
|
|
24
21
|
if (tokenIn == STETH) {
|
|
25
22
|
amountStETH = amountDep;
|
|
26
23
|
} else {
|
|
27
24
|
if (tokenIn == WETH) IWETH(WETH).withdraw(amountDep);
|
|
28
25
|
|
|
29
|
-
uint256 amountStEthSharesOut = IStETH(STETH).submit{
|
|
26
|
+
uint256 amountStEthSharesOut = IStETH(STETH).submit{value: amountDep}(address(0));
|
|
30
27
|
amountStETH = IStETH(STETH).getPooledEthByShares(amountStEthSharesOut);
|
|
31
28
|
}
|
|
32
29
|
amountOut = IWstETH(WSTETH).wrap(amountStETH);
|
|
33
30
|
}
|
|
34
31
|
|
|
35
|
-
function _redeemWstETH(
|
|
36
|
-
address receiver,
|
|
37
|
-
uint256 amountRedeem
|
|
38
|
-
) internal virtual returns (uint256 amountTokenOut) {
|
|
32
|
+
function _redeemWstETH(address receiver, uint256 amountRedeem) internal virtual returns (uint256 amountTokenOut) {
|
|
39
33
|
amountTokenOut = IWstETH(WSTETH).unwrap(amountRedeem);
|
|
40
34
|
if (receiver != address(this)) _transferOut(STETH, receiver, amountTokenOut);
|
|
41
35
|
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
pragma solidity 0.8.23;
|
|
3
|
+
|
|
4
|
+
import "../../SYBase.sol";
|
|
5
|
+
import "./libraries/AaveAdapterLib.sol";
|
|
6
|
+
import "../../../../interfaces/AaveV3/IAaveV3AToken.sol";
|
|
7
|
+
import "../../../../interfaces/AaveV3/IAaveV3Pool.sol";
|
|
8
|
+
|
|
9
|
+
// @NOTE: In this contract, we denote the "scaled balance" term as "share"
|
|
10
|
+
contract PendleAaveV3SY is SYBase {
|
|
11
|
+
using PMath for uint256;
|
|
12
|
+
|
|
13
|
+
address public immutable aToken;
|
|
14
|
+
address public immutable aavePool;
|
|
15
|
+
address public immutable underlying;
|
|
16
|
+
|
|
17
|
+
constructor(
|
|
18
|
+
string memory _name,
|
|
19
|
+
string memory _symbol,
|
|
20
|
+
address _aavePool,
|
|
21
|
+
address _aToken
|
|
22
|
+
) SYBase(_name, _symbol, _aToken) {
|
|
23
|
+
aToken = _aToken;
|
|
24
|
+
aavePool = _aavePool;
|
|
25
|
+
underlying = IAaveV3AToken(aToken).UNDERLYING_ASSET_ADDRESS();
|
|
26
|
+
|
|
27
|
+
_safeApproveInf(underlying, _aavePool);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function _deposit(
|
|
31
|
+
address tokenIn,
|
|
32
|
+
uint256 amountDeposited
|
|
33
|
+
) internal virtual override returns (uint256 amountSharesOut) {
|
|
34
|
+
if (tokenIn == underlying) {
|
|
35
|
+
IAaveV3Pool(aavePool).supply(underlying, amountDeposited, address(this), 0);
|
|
36
|
+
}
|
|
37
|
+
amountSharesOut = AaveAdapterLib.calcSharesFromAssetUp(amountDeposited, _getNormalizedIncome());
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function _redeem(
|
|
41
|
+
address receiver,
|
|
42
|
+
address tokenOut,
|
|
43
|
+
uint256 amountSharesToRedeem
|
|
44
|
+
) internal override returns (uint256 amountTokenOut) {
|
|
45
|
+
amountTokenOut = AaveAdapterLib.calcSharesToAssetDown(amountSharesToRedeem, _getNormalizedIncome());
|
|
46
|
+
if (tokenOut == underlying) {
|
|
47
|
+
IAaveV3Pool(aavePool).withdraw(underlying, amountTokenOut, receiver);
|
|
48
|
+
} else {
|
|
49
|
+
_transferOut(aToken, receiver, amountTokenOut);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function exchangeRate() public view virtual override returns (uint256) {
|
|
54
|
+
return _getNormalizedIncome() / 1e9;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function _previewDeposit(
|
|
58
|
+
address,
|
|
59
|
+
uint256 amountTokenToDeposit
|
|
60
|
+
) internal view override returns (uint256 /*amountSharesOut*/) {
|
|
61
|
+
return AaveAdapterLib.calcSharesFromAssetUp(amountTokenToDeposit, _getNormalizedIncome());
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function _previewRedeem(
|
|
65
|
+
address,
|
|
66
|
+
uint256 amountSharesToRedeem
|
|
67
|
+
) internal view override returns (uint256 /*amountTokenOut*/) {
|
|
68
|
+
return AaveAdapterLib.calcSharesToAssetDown(amountSharesToRedeem, _getNormalizedIncome());
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function _getNormalizedIncome() internal view returns (uint256) {
|
|
72
|
+
return IAaveV3Pool(aavePool).getReserveNormalizedIncome(underlying);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function getTokensIn() public view override returns (address[] memory res) {
|
|
76
|
+
return ArrayLib.create(underlying, aToken);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function getTokensOut() public view override returns (address[] memory res) {
|
|
80
|
+
return ArrayLib.create(underlying, aToken);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function isValidTokenIn(address token) public view override returns (bool) {
|
|
84
|
+
return token == aToken || token == underlying;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function isValidTokenOut(address token) public view override returns (bool) {
|
|
88
|
+
return token == aToken || token == underlying;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function assetInfo() external view returns (AssetType assetType, address assetAddress, uint8 assetDecimals) {
|
|
92
|
+
return (AssetType.TOKEN, underlying, IERC20Metadata(underlying).decimals());
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// SPDX-License-Identifier: BUSL-1.1
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
import "./WadRayMath.sol";
|
|
5
|
+
|
|
6
|
+
library AaveAdapterLib {
|
|
7
|
+
// Also denote this function as f(share) for a given (constant) index
|
|
8
|
+
function calcSharesToAssetDown(uint256 amountShares, uint256 index) internal pure returns (uint256) {
|
|
9
|
+
return (amountShares * index) / WadRayMath.RAY;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function calcSharesFromAssetDown(uint256 amountAssets, uint256 index) internal pure returns (uint256) {
|
|
13
|
+
return (amountAssets * WadRayMath.RAY) / index;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function calcSharesFromAssetUp(uint256 amountAssets, uint256 index) internal pure returns (uint256) {
|
|
17
|
+
return WadRayMath.rayDiv(amountAssets, index);
|
|
18
|
+
}
|
|
19
|
+
}
|