@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 "../SYBase.sol";
|
|
5
5
|
import "../../../interfaces/BinanceEth/IWBETH.sol";
|
|
@@ -25,10 +25,7 @@ contract PendleWbEthSY is SYBase {
|
|
|
25
25
|
DEPOSIT/REDEEM USING BASE TOKENS
|
|
26
26
|
//////////////////////////////////////////////////////////////*/
|
|
27
27
|
|
|
28
|
-
function _deposit(
|
|
29
|
-
address tokenIn,
|
|
30
|
-
uint256 amountDeposited
|
|
31
|
-
) internal override returns (uint256 amountSharesOut) {
|
|
28
|
+
function _deposit(address tokenIn, uint256 amountDeposited) internal override returns (uint256 amountSharesOut) {
|
|
32
29
|
if (tokenIn == eth) {
|
|
33
30
|
uint256 previousBalance = _selfBalance(wbETH);
|
|
34
31
|
IWBETH(wbETH).deposit(amountDeposited, address(this));
|
|
@@ -98,11 +95,7 @@ contract PendleWbEthSY is SYBase {
|
|
|
98
95
|
return token == wbETH;
|
|
99
96
|
}
|
|
100
97
|
|
|
101
|
-
function assetInfo()
|
|
102
|
-
external
|
|
103
|
-
view
|
|
104
|
-
returns (AssetType assetType, address assetAddress, uint8 assetDecimals)
|
|
105
|
-
{
|
|
98
|
+
function assetInfo() external view returns (AssetType assetType, address assetAddress, uint8 assetDecimals) {
|
|
106
99
|
return (AssetType.TOKEN, eth, 18);
|
|
107
100
|
}
|
|
108
101
|
}
|
|
@@ -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 "../SYBase.sol";
|
|
5
5
|
import "../../../interfaces/IWstETH.sol";
|
|
@@ -48,9 +48,7 @@ contract PendleWstEthSY is SYBase {
|
|
|
48
48
|
} else {
|
|
49
49
|
if (tokenIn == wETH) IWETH(wETH).withdraw(amountDeposited);
|
|
50
50
|
|
|
51
|
-
uint256 amountStEthSharesOut = IStETH(stETH).submit{
|
|
52
|
-
address(0)
|
|
53
|
-
);
|
|
51
|
+
uint256 amountStEthSharesOut = IStETH(stETH).submit{value: amountDeposited}(address(0));
|
|
54
52
|
amountStETH = IStETH(stETH).getPooledEthByShares(amountStEthSharesOut);
|
|
55
53
|
}
|
|
56
54
|
amountSharesOut = IWstETH(wstETH).wrap(amountStETH);
|
|
@@ -101,9 +99,7 @@ contract PendleWstEthSY is SYBase {
|
|
|
101
99
|
if (tokenIn != stETH) {
|
|
102
100
|
uint256 totalShares = IStETH(stETH).getTotalShares();
|
|
103
101
|
uint256 totalPooledEth = IStETH(stETH).getTotalPooledEther();
|
|
104
|
-
uint256 amountStEthSharesOut = IStETH(stETH).getSharesByPooledEth(
|
|
105
|
-
amountTokenToDeposit
|
|
106
|
-
);
|
|
102
|
+
uint256 amountStEthSharesOut = IStETH(stETH).getSharesByPooledEth(amountTokenToDeposit);
|
|
107
103
|
|
|
108
104
|
totalShares += amountStEthSharesOut;
|
|
109
105
|
totalPooledEth += amountTokenToDeposit;
|
|
@@ -146,11 +142,7 @@ contract PendleWstEthSY is SYBase {
|
|
|
146
142
|
return token == stETH || token == wstETH;
|
|
147
143
|
}
|
|
148
144
|
|
|
149
|
-
function assetInfo()
|
|
150
|
-
external
|
|
151
|
-
view
|
|
152
|
-
returns (AssetType assetType, address assetAddress, uint8 assetDecimals)
|
|
153
|
-
{
|
|
145
|
+
function assetInfo() external view returns (AssetType assetType, address assetAddress, uint8 assetDecimals) {
|
|
154
146
|
return (AssetType.TOKEN, stETH, IERC20Metadata(stETH).decimals());
|
|
155
147
|
}
|
|
156
148
|
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
// SPDX-License-Identifier: BUSL-1.1
|
|
2
|
+
pragma solidity ^0.8.17;
|
|
3
|
+
|
|
4
|
+
import "../../SYBaseWithRewards.sol";
|
|
5
|
+
import "../../../../interfaces/Silo/ISiloIncentiveController.sol";
|
|
6
|
+
import "../../../../interfaces/Silo/ISilo.sol";
|
|
7
|
+
import "../../../../interfaces/Silo/ISiloLens.sol";
|
|
8
|
+
import "../../../libraries/ArrayLib.sol";
|
|
9
|
+
import "../../../libraries/math/PMath.sol";
|
|
10
|
+
|
|
11
|
+
contract PendleSiloWithIncentiveSY is SYBaseWithRewards {
|
|
12
|
+
using PMath for uint256;
|
|
13
|
+
|
|
14
|
+
address public immutable asset;
|
|
15
|
+
address public immutable collateralToken;
|
|
16
|
+
address public immutable silo;
|
|
17
|
+
address public immutable incentiveController;
|
|
18
|
+
address public immutable siloLens;
|
|
19
|
+
address public immutable rewardToken;
|
|
20
|
+
|
|
21
|
+
constructor(
|
|
22
|
+
string memory _name,
|
|
23
|
+
string memory _symbol,
|
|
24
|
+
address _asset,
|
|
25
|
+
address _collateralToken,
|
|
26
|
+
address _silo,
|
|
27
|
+
address _incentiveController,
|
|
28
|
+
address _siloLens
|
|
29
|
+
) SYBaseWithRewards(_name, _symbol, _collateralToken) {
|
|
30
|
+
asset = _asset;
|
|
31
|
+
collateralToken = _collateralToken;
|
|
32
|
+
silo = _silo;
|
|
33
|
+
incentiveController = _incentiveController;
|
|
34
|
+
siloLens = _siloLens;
|
|
35
|
+
|
|
36
|
+
rewardToken = ISiloIncentiveController(incentiveController).REWARD_TOKEN();
|
|
37
|
+
|
|
38
|
+
_safeApproveInf(asset, silo);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function _deposit(
|
|
42
|
+
address tokenIn,
|
|
43
|
+
uint256 amountDeposited
|
|
44
|
+
) internal virtual override returns (uint256 amountSharesOut) {
|
|
45
|
+
if (tokenIn == collateralToken) {
|
|
46
|
+
return amountDeposited;
|
|
47
|
+
} else {
|
|
48
|
+
(, amountSharesOut) = ISilo(silo).deposit(asset, amountDeposited, false);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function _redeem(
|
|
53
|
+
address receiver,
|
|
54
|
+
address tokenOut,
|
|
55
|
+
uint256 amountSharesToRedeem
|
|
56
|
+
) internal virtual override returns (uint256 amountTokenOut) {
|
|
57
|
+
if (tokenOut == collateralToken) {
|
|
58
|
+
_transferOut(collateralToken, receiver, amountSharesToRedeem);
|
|
59
|
+
return amountSharesToRedeem;
|
|
60
|
+
} else {
|
|
61
|
+
// Silo withdrawing interface only accepts amount of asset as input
|
|
62
|
+
// Therefore we need to ensure that assetInput.toShareRoundUp() <= amountSharesToRedeem
|
|
63
|
+
|
|
64
|
+
(uint256 td, uint256 ts) = _getSiloInterestData();
|
|
65
|
+
amountTokenOut = (td * amountSharesToRedeem) / ts; // round down should ensure that shares being burned <= amountSharesToRedeem
|
|
66
|
+
|
|
67
|
+
// amountAssetToWithdraw should = withdrawnAmount as withdrawing does not
|
|
68
|
+
// bear any fees
|
|
69
|
+
ISilo(silo).withdraw(asset, amountTokenOut, false);
|
|
70
|
+
_transferOut(tokenOut, receiver, amountTokenOut);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/*///////////////////////////////////////////////////////////////
|
|
75
|
+
EXCHANGE-RATE
|
|
76
|
+
//////////////////////////////////////////////////////////////*/
|
|
77
|
+
|
|
78
|
+
function exchangeRate() public view virtual override returns (uint256) {
|
|
79
|
+
(uint256 td, uint256 ts) = _getSiloInterestData();
|
|
80
|
+
return td.divDown(ts);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/*///////////////////////////////////////////////////////////////
|
|
84
|
+
REWARDS-RELATED
|
|
85
|
+
//////////////////////////////////////////////////////////////*/
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @dev See {IStandardizedYield-getRewardTokens}
|
|
89
|
+
*/
|
|
90
|
+
function _getRewardTokens() internal view override returns (address[] memory) {
|
|
91
|
+
return ArrayLib.create(rewardToken);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function _redeemExternalReward() internal override {
|
|
95
|
+
ISiloIncentiveController(incentiveController).claimRewardsToSelf(
|
|
96
|
+
ArrayLib.create(collateralToken),
|
|
97
|
+
type(uint256).max
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/*///////////////////////////////////////////////////////////////
|
|
102
|
+
SILO DATA FUNCITONS
|
|
103
|
+
//////////////////////////////////////////////////////////////*/
|
|
104
|
+
|
|
105
|
+
function _getSiloInterestData() internal view returns (uint256 totalDeposit, uint256 totalCollateralTokenSupply) {
|
|
106
|
+
totalDeposit = ISiloLens(siloLens).totalDepositsWithInterest(silo, asset);
|
|
107
|
+
totalCollateralTokenSupply = IERC20(collateralToken).totalSupply();
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/*///////////////////////////////////////////////////////////////
|
|
111
|
+
MISC FUNCTIONS FOR METADATA
|
|
112
|
+
//////////////////////////////////////////////////////////////*/
|
|
113
|
+
|
|
114
|
+
function _previewDeposit(
|
|
115
|
+
address tokenIn,
|
|
116
|
+
uint256 amountTokenToDeposit
|
|
117
|
+
) internal view override returns (uint256 amountSharesOut) {
|
|
118
|
+
if (tokenIn == collateralToken) {
|
|
119
|
+
return amountTokenToDeposit;
|
|
120
|
+
} else {
|
|
121
|
+
(uint256 td, uint256 ts) = _getSiloInterestData();
|
|
122
|
+
return (amountTokenToDeposit * ts) / td;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function _previewRedeem(
|
|
127
|
+
address tokenOut,
|
|
128
|
+
uint256 amountSharesToRedeem
|
|
129
|
+
) internal view override returns (uint256 amountTokenOut) {
|
|
130
|
+
if (tokenOut == collateralToken) {
|
|
131
|
+
return amountSharesToRedeem;
|
|
132
|
+
} else {
|
|
133
|
+
(uint256 td, uint256 ts) = _getSiloInterestData();
|
|
134
|
+
return (amountSharesToRedeem * td) / ts;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function getTokensIn() public view virtual override returns (address[] memory) {
|
|
139
|
+
return ArrayLib.create(asset, collateralToken);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function getTokensOut() public view virtual override returns (address[] memory) {
|
|
143
|
+
return ArrayLib.create(asset, collateralToken);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function isValidTokenIn(address token) public view virtual override returns (bool) {
|
|
147
|
+
return token == asset || token == collateralToken;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function isValidTokenOut(address token) public view virtual override returns (bool) {
|
|
151
|
+
return token == asset || token == collateralToken;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function assetInfo() external view returns (AssetType assetType, address assetAddress, uint8 assetDecimals) {
|
|
155
|
+
return (AssetType.TOKEN, asset, IERC20Metadata(asset).decimals());
|
|
156
|
+
}
|
|
157
|
+
}
|
|
@@ -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
|
import "../../SYBase.sol";
|
|
4
4
|
import "../../../libraries/ArrayLib.sol";
|
|
5
5
|
import "../../../../interfaces/Stader/IStaderStakeManager.sol";
|
|
@@ -13,10 +13,7 @@ contract PendleETHXSY is SYBase {
|
|
|
13
13
|
address public immutable stakeManager;
|
|
14
14
|
address public immutable ethx;
|
|
15
15
|
|
|
16
|
-
constructor(
|
|
17
|
-
address _stakeManager,
|
|
18
|
-
address _ethx
|
|
19
|
-
) SYBase("SY Stader Staking ETHx", "SY-ETHx", _ethx) {
|
|
16
|
+
constructor(address _stakeManager, address _ethx) SYBase("SY Stader Staking ETHx", "SY-ETHx", _ethx) {
|
|
20
17
|
stakeManager = _stakeManager;
|
|
21
18
|
ethx = _ethx;
|
|
22
19
|
}
|
|
@@ -30,8 +27,7 @@ contract PendleETHXSY is SYBase {
|
|
|
30
27
|
uint256 amountDeposited
|
|
31
28
|
) internal virtual override returns (uint256 /*amountSharesOut*/) {
|
|
32
29
|
if (tokenIn == NATIVE) {
|
|
33
|
-
return
|
|
34
|
-
IStaderStakeManager(stakeManager).deposit{ value: amountDeposited }(address(this));
|
|
30
|
+
return IStaderStakeManager(stakeManager).deposit{value: amountDeposited}(address(this));
|
|
35
31
|
} else {
|
|
36
32
|
return amountDeposited;
|
|
37
33
|
}
|
|
@@ -100,11 +96,7 @@ contract PendleETHXSY is SYBase {
|
|
|
100
96
|
return token == ethx;
|
|
101
97
|
}
|
|
102
98
|
|
|
103
|
-
function assetInfo()
|
|
104
|
-
external
|
|
105
|
-
pure
|
|
106
|
-
returns (AssetType assetType, address assetAddress, uint8 assetDecimals)
|
|
107
|
-
{
|
|
99
|
+
function assetInfo() external pure returns (AssetType assetType, address assetAddress, uint8 assetDecimals) {
|
|
108
100
|
return (AssetType.TOKEN, NATIVE, 18);
|
|
109
101
|
}
|
|
110
102
|
}
|
|
@@ -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
|
import "../../SYBase.sol";
|
|
4
4
|
import "../../../../interfaces/ISwETH.sol";
|
|
5
5
|
|
|
@@ -8,11 +8,7 @@ contract SwETHSY is SYBase {
|
|
|
8
8
|
|
|
9
9
|
address public immutable swETH;
|
|
10
10
|
|
|
11
|
-
constructor(
|
|
12
|
-
string memory _name,
|
|
13
|
-
string memory _symbol,
|
|
14
|
-
address _swETH
|
|
15
|
-
) SYBase(_name, _symbol, _swETH) {
|
|
11
|
+
constructor(string memory _name, string memory _symbol, address _swETH) SYBase(_name, _symbol, _swETH) {
|
|
16
12
|
swETH = _swETH;
|
|
17
13
|
}
|
|
18
14
|
|
|
@@ -26,7 +22,7 @@ contract SwETHSY is SYBase {
|
|
|
26
22
|
) internal virtual override returns (uint256 /*amountSharesOut*/) {
|
|
27
23
|
if (tokenIn == NATIVE) {
|
|
28
24
|
uint256 preBalance = _selfBalance(swETH);
|
|
29
|
-
ISwETH(swETH).deposit{
|
|
25
|
+
ISwETH(swETH).deposit{value: amountDeposited}();
|
|
30
26
|
return _selfBalance(swETH) - preBalance;
|
|
31
27
|
} else {
|
|
32
28
|
// sweth
|
|
@@ -92,11 +88,7 @@ contract SwETHSY is SYBase {
|
|
|
92
88
|
return token == swETH;
|
|
93
89
|
}
|
|
94
90
|
|
|
95
|
-
function assetInfo()
|
|
96
|
-
external
|
|
97
|
-
pure
|
|
98
|
-
returns (AssetType assetType, address assetAddress, uint8 assetDecimals)
|
|
99
|
-
{
|
|
91
|
+
function assetInfo() external pure returns (AssetType assetType, address assetAddress, uint8 assetDecimals) {
|
|
100
92
|
return (AssetType.TOKEN, NATIVE, 18);
|
|
101
93
|
}
|
|
102
94
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
2
|
|
|
3
|
-
pragma solidity 0.8.17;
|
|
3
|
+
pragma solidity ^0.8.17;
|
|
4
4
|
|
|
5
5
|
import "../../SYBaseWithRewards.sol";
|
|
6
6
|
import "./ThenaLpHelper.sol";
|
|
@@ -39,12 +39,10 @@ contract PendleThenaSY is ThenaLpHelper, SYBaseWithRewards {
|
|
|
39
39
|
/**
|
|
40
40
|
* @dev See {SYBase-_deposit}
|
|
41
41
|
*/
|
|
42
|
-
function _deposit(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
returns (uint256 amountLpDeposited)
|
|
47
|
-
{
|
|
42
|
+
function _deposit(
|
|
43
|
+
address tokenIn,
|
|
44
|
+
uint256 amountDeposited
|
|
45
|
+
) internal virtual override returns (uint256 amountLpDeposited) {
|
|
48
46
|
_withdrawAllFromGauge();
|
|
49
47
|
if (tokenIn == pair) {
|
|
50
48
|
amountLpDeposited = amountDeposited;
|
|
@@ -86,7 +84,7 @@ contract PendleThenaSY is ThenaLpHelper, SYBaseWithRewards {
|
|
|
86
84
|
function _getRewardTokens() internal view virtual override returns (address[] memory res) {
|
|
87
85
|
res = new address[](1 + externalRewardTokens.length);
|
|
88
86
|
res[0] = THENA;
|
|
89
|
-
for(uint256 i = 1; i < res.length; ++i) {
|
|
87
|
+
for (uint256 i = 1; i < res.length; ++i) {
|
|
90
88
|
res[i] = externalRewardTokens[i - 1];
|
|
91
89
|
}
|
|
92
90
|
}
|
|
@@ -99,12 +97,7 @@ contract PendleThenaSY is ThenaLpHelper, SYBaseWithRewards {
|
|
|
99
97
|
PREVIEW-RELATED
|
|
100
98
|
//////////////////////////////////////////////////////////////*/
|
|
101
99
|
|
|
102
|
-
function _previewDeposit(address tokenIn, uint256 amountTokenToDeposit)
|
|
103
|
-
internal
|
|
104
|
-
view
|
|
105
|
-
override
|
|
106
|
-
returns (uint256)
|
|
107
|
-
{
|
|
100
|
+
function _previewDeposit(address tokenIn, uint256 amountTokenToDeposit) internal view override returns (uint256) {
|
|
108
101
|
if (tokenIn == pair) {
|
|
109
102
|
return amountTokenToDeposit;
|
|
110
103
|
} else {
|
|
@@ -112,12 +105,7 @@ contract PendleThenaSY is ThenaLpHelper, SYBaseWithRewards {
|
|
|
112
105
|
}
|
|
113
106
|
}
|
|
114
107
|
|
|
115
|
-
function _previewRedeem(address tokenOut, uint256 amountSharesToRedeem)
|
|
116
|
-
internal
|
|
117
|
-
view
|
|
118
|
-
override
|
|
119
|
-
returns (uint256)
|
|
120
|
-
{
|
|
108
|
+
function _previewRedeem(address tokenOut, uint256 amountSharesToRedeem) internal view override returns (uint256) {
|
|
121
109
|
if (tokenOut == pair) {
|
|
122
110
|
return amountSharesToRedeem;
|
|
123
111
|
} else {
|
|
@@ -151,15 +139,7 @@ contract PendleThenaSY is ThenaLpHelper, SYBaseWithRewards {
|
|
|
151
139
|
return token == token0 || token == token1 || token == pair;
|
|
152
140
|
}
|
|
153
141
|
|
|
154
|
-
function assetInfo()
|
|
155
|
-
external
|
|
156
|
-
view
|
|
157
|
-
returns (
|
|
158
|
-
AssetType assetType,
|
|
159
|
-
address assetAddress,
|
|
160
|
-
uint8 assetDecimals
|
|
161
|
-
)
|
|
162
|
-
{
|
|
142
|
+
function assetInfo() external view returns (AssetType assetType, address assetAddress, uint8 assetDecimals) {
|
|
163
143
|
return (AssetType.LIQUIDITY, pair, IERC20Metadata(pair).decimals());
|
|
164
144
|
}
|
|
165
145
|
|
|
@@ -77,10 +77,7 @@ abstract contract ThenaLpHelper is TokenHelper, ThenaMath {
|
|
|
77
77
|
* ==================================================================
|
|
78
78
|
*/
|
|
79
79
|
|
|
80
|
-
function _addLiquidity(
|
|
81
|
-
uint256 amount0ToAddLiq,
|
|
82
|
-
uint256 amount1ToAddLiq
|
|
83
|
-
) private returns (uint256 amountLpOut) {
|
|
80
|
+
function _addLiquidity(uint256 amount0ToAddLiq, uint256 amount1ToAddLiq) private returns (uint256 amountLpOut) {
|
|
84
81
|
(, , amountLpOut) = IThenaRouter(router).addLiquidity(
|
|
85
82
|
token0,
|
|
86
83
|
token1,
|
|
@@ -94,9 +91,7 @@ abstract contract ThenaLpHelper is TokenHelper, ThenaMath {
|
|
|
94
91
|
);
|
|
95
92
|
}
|
|
96
93
|
|
|
97
|
-
function _removeLiquidity(
|
|
98
|
-
uint256 amountLpToRemove
|
|
99
|
-
) private returns (uint256 amountTokenA, uint256 amountTokenB) {
|
|
94
|
+
function _removeLiquidity(uint256 amountLpToRemove) private returns (uint256 amountTokenA, uint256 amountTokenB) {
|
|
100
95
|
return
|
|
101
96
|
IThenaRouter(router).removeLiquidity(
|
|
102
97
|
token0,
|
|
@@ -133,9 +128,7 @@ abstract contract ThenaLpHelper is TokenHelper, ThenaMath {
|
|
|
133
128
|
* ==================================================================
|
|
134
129
|
*/
|
|
135
130
|
|
|
136
|
-
function _getNormalizedThenaData(
|
|
137
|
-
address tokenIn
|
|
138
|
-
) internal view returns (ThenaData memory data) {
|
|
131
|
+
function _getNormalizedThenaData(address tokenIn) internal view returns (ThenaData memory data) {
|
|
139
132
|
data.pair = pair;
|
|
140
133
|
data.isStable = isStable;
|
|
141
134
|
data.fee = IThenaFactory(factory).getFee(data.isStable);
|
|
@@ -41,25 +41,18 @@ abstract contract ThenaMath {
|
|
|
41
41
|
address tokenIn,
|
|
42
42
|
uint256 amountIn
|
|
43
43
|
) internal view returns (uint256) {
|
|
44
|
-
return
|
|
45
|
-
data.isStable
|
|
46
|
-
? _getStableZapAmount(data, tokenIn, amountIn)
|
|
47
|
-
: _getVolatileZapAmount(data, amountIn);
|
|
44
|
+
return data.isStable ? _getStableZapAmount(data, tokenIn, amountIn) : _getVolatileZapAmount(data, amountIn);
|
|
48
45
|
}
|
|
49
46
|
|
|
50
|
-
function _getVolatileZapAmount(
|
|
51
|
-
|
|
52
|
-
uint256 amountIn
|
|
53
|
-
) private pure returns (uint256) {
|
|
54
|
-
|
|
55
|
-
uint256 numer0 = (TWO - FEE_DENOMINATOR) * data.reserve0 / FEE_DENOMINATOR;
|
|
47
|
+
function _getVolatileZapAmount(ThenaData memory data, uint256 amountIn) private pure returns (uint256) {
|
|
48
|
+
uint256 numer0 = ((TWO - FEE_DENOMINATOR) * data.reserve0) / FEE_DENOMINATOR;
|
|
56
49
|
uint256 numer1 = PMath.square(numer0);
|
|
57
50
|
uint256 numer2 = 4 * PMath.square(ONE - data.fee) * amountIn * data.reserve0;
|
|
58
51
|
|
|
59
52
|
uint256 numer = PMath.sqrt(numer1 + numer2) - numer0;
|
|
60
53
|
uint256 denom = 2 * PMath.square(ONE - data.fee);
|
|
61
54
|
|
|
62
|
-
return numer * FEE_DENOMINATOR / denom;
|
|
55
|
+
return (numer * FEE_DENOMINATOR) / denom;
|
|
63
56
|
}
|
|
64
57
|
|
|
65
58
|
function _getStableZapAmount(
|
|
@@ -71,23 +64,13 @@ abstract contract ThenaMath {
|
|
|
71
64
|
|
|
72
65
|
while (!PMath.isAApproxB(params.guessMin, params.guessMax, binarySearchEps)) {
|
|
73
66
|
params.amountSwapIn = (params.guessMax + params.guessMin) / 2;
|
|
74
|
-
params.amount1ToAddLiq = IThenaPair(data.pair).getAmountOut(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
params.newReserve0 = _getReserveAfterSwap(
|
|
80
|
-
params.amountSwapIn,
|
|
81
|
-
data.reserve0,
|
|
82
|
-
data.fee
|
|
83
|
-
);
|
|
67
|
+
params.amount1ToAddLiq = IThenaPair(data.pair).getAmountOut(params.amountSwapIn, tokenIn);
|
|
68
|
+
|
|
69
|
+
params.newReserve0 = _getReserveAfterSwap(params.amountSwapIn, data.reserve0, data.fee);
|
|
84
70
|
params.newReserve1 = data.reserve1 - params.amount1ToAddLiq;
|
|
85
71
|
params.amount0ToAddLiq = amountIn - params.amountSwapIn;
|
|
86
72
|
|
|
87
|
-
if (
|
|
88
|
-
params.amount0ToAddLiq * params.newReserve1 <
|
|
89
|
-
params.amount1ToAddLiq * params.newReserve0
|
|
90
|
-
) {
|
|
73
|
+
if (params.amount0ToAddLiq * params.newReserve1 < params.amount1ToAddLiq * params.newReserve0) {
|
|
91
74
|
params.guessMax = params.amountSwapIn - 1; // need swap less
|
|
92
75
|
} else {
|
|
93
76
|
params.guessMin = params.amountSwapIn + 1; // swap more
|
|
@@ -112,11 +95,7 @@ abstract contract ThenaMath {
|
|
|
112
95
|
params.guessMax = (params.guessMin * FEE_DENOMINATOR) / (FEE_DENOMINATOR - data.fee);
|
|
113
96
|
}
|
|
114
97
|
|
|
115
|
-
function _getReserveAfterSwap(
|
|
116
|
-
uint256 amountIn,
|
|
117
|
-
uint256 reserve,
|
|
118
|
-
uint256 fee
|
|
119
|
-
) internal pure returns (uint256) {
|
|
98
|
+
function _getReserveAfterSwap(uint256 amountIn, uint256 reserve, uint256 fee) internal pure returns (uint256) {
|
|
120
99
|
return reserve + amountIn - (amountIn * fee) / FEE_DENOMINATOR;
|
|
121
100
|
}
|
|
122
101
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
2
|
|
|
3
|
-
pragma solidity 0.8.17;
|
|
3
|
+
pragma solidity ^0.8.17;
|
|
4
4
|
|
|
5
5
|
import "./ThenaMath.sol";
|
|
6
6
|
|
|
@@ -14,12 +14,7 @@ interface IThenaSY {
|
|
|
14
14
|
function pair() external view returns (address);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
contract ThenaPreview is
|
|
18
|
-
IPendlePreviewHelper,
|
|
19
|
-
ThenaMath,
|
|
20
|
-
BoringOwnableUpgradeable,
|
|
21
|
-
UUPSUpgradeable
|
|
22
|
-
{
|
|
17
|
+
contract ThenaPreview is IPendlePreviewHelper, ThenaMath, BoringOwnableUpgradeable, UUPSUpgradeable {
|
|
23
18
|
using PMath for uint256;
|
|
24
19
|
|
|
25
20
|
address internal immutable factory;
|
|
@@ -35,10 +30,7 @@ contract ThenaPreview is
|
|
|
35
30
|
// solhint-disable-next-line
|
|
36
31
|
function _authorizeUpgrade(address newImplementation) internal override onlyOwner {}
|
|
37
32
|
|
|
38
|
-
function previewDeposit(
|
|
39
|
-
address tokenIn,
|
|
40
|
-
uint256 amountTokenIn
|
|
41
|
-
) external view returns (uint256 amountLpOut) {
|
|
33
|
+
function previewDeposit(address tokenIn, uint256 amountTokenIn) external view returns (uint256 amountLpOut) {
|
|
42
34
|
address pair = IThenaSY(msg.sender).pair();
|
|
43
35
|
|
|
44
36
|
ThenaData memory data = _getNormalizedPairData(pair, tokenIn);
|
|
@@ -79,22 +71,15 @@ contract ThenaPreview is
|
|
|
79
71
|
}
|
|
80
72
|
|
|
81
73
|
// @reference: Camelot
|
|
82
|
-
function _getSwapAmountOut(
|
|
83
|
-
ThenaData memory data,
|
|
84
|
-
uint256 amountIn
|
|
85
|
-
) internal pure returns (uint256) {
|
|
74
|
+
function _getSwapAmountOut(ThenaData memory data, uint256 amountIn) internal pure returns (uint256) {
|
|
86
75
|
if (!data.isStable) {
|
|
87
76
|
amountIn = amountIn * (FEE_DENOMINATOR - data.fee);
|
|
88
77
|
return (amountIn * data.reserve1) / (data.reserve0 * FEE_DENOMINATOR + amountIn);
|
|
89
78
|
} else {
|
|
90
|
-
amountIn = (amountIn - (amountIn * data.fee) / FEE_DENOMINATOR).divDown(
|
|
91
|
-
data.decimals0
|
|
92
|
-
);
|
|
79
|
+
amountIn = (amountIn - (amountIn * data.fee) / FEE_DENOMINATOR).divDown(data.decimals0);
|
|
93
80
|
uint256 reserveA = data.reserve0.divDown(data.decimals0);
|
|
94
81
|
uint256 reserveB = data.reserve1.divDown(data.decimals1);
|
|
95
|
-
uint256 xy = reserveA.mulDown(reserveB).mulDown(
|
|
96
|
-
reserveA.squareDown() + reserveB.squareDown()
|
|
97
|
-
);
|
|
82
|
+
uint256 xy = reserveA.mulDown(reserveB).mulDown(reserveA.squareDown() + reserveB.squareDown());
|
|
98
83
|
uint256 y = reserveB - _get_y(amountIn + reserveA, xy, reserveB);
|
|
99
84
|
return y.mulDown(data.decimals1);
|
|
100
85
|
}
|
|
@@ -117,25 +102,14 @@ contract ThenaPreview is
|
|
|
117
102
|
}
|
|
118
103
|
|
|
119
104
|
uint256 supply = IThenaPair(data.pair).totalSupply();
|
|
120
|
-
return
|
|
121
|
-
PMath.min(
|
|
122
|
-
(amount0ToAddLiq * supply) / data.reserve0,
|
|
123
|
-
(amount1ToAddLiq * supply) / data.reserve1
|
|
124
|
-
);
|
|
105
|
+
return PMath.min((amount0ToAddLiq * supply) / data.reserve0, (amount1ToAddLiq * supply) / data.reserve1);
|
|
125
106
|
}
|
|
126
107
|
|
|
127
|
-
function _quote(
|
|
128
|
-
uint256 amountA,
|
|
129
|
-
uint256 reserveA,
|
|
130
|
-
uint256 reserveB
|
|
131
|
-
) private pure returns (uint256 amountB) {
|
|
108
|
+
function _quote(uint256 amountA, uint256 reserveA, uint256 reserveB) private pure returns (uint256 amountB) {
|
|
132
109
|
amountB = (amountA * reserveB) / reserveA;
|
|
133
110
|
}
|
|
134
111
|
|
|
135
|
-
function _getNormalizedPairData(
|
|
136
|
-
address pair,
|
|
137
|
-
address pivotToken
|
|
138
|
-
) internal view returns (ThenaData memory data) {
|
|
112
|
+
function _getNormalizedPairData(address pair, address pivotToken) internal view returns (ThenaData memory data) {
|
|
139
113
|
data.pair = pair;
|
|
140
114
|
data.isStable = IThenaPair(pair).isStable();
|
|
141
115
|
data.fee = IThenaFactory(factory).getFee(data.isStable);
|
|
@@ -180,11 +154,7 @@ contract ThenaPreview is
|
|
|
180
154
|
}
|
|
181
155
|
|
|
182
156
|
function _f(uint256 x0, uint256 y) internal pure returns (uint256) {
|
|
183
|
-
return
|
|
184
|
-
(x0 * ((((y * y) / 1e18) * y) / 1e18)) /
|
|
185
|
-
1e18 +
|
|
186
|
-
(((((x0 * x0) / 1e18) * x0) / 1e18) * y) /
|
|
187
|
-
1e18;
|
|
157
|
+
return (x0 * ((((y * y) / 1e18) * y) / 1e18)) / 1e18 + (((((x0 * x0) / 1e18) * x0) / 1e18) * y) / 1e18;
|
|
188
158
|
}
|
|
189
159
|
|
|
190
160
|
function _d(uint256 x0, uint256 y) internal pure returns (uint256) {
|
|
@@ -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 "../../interfaces/IPYieldToken.sol";
|
|
5
5
|
import "../../interfaces/IPPrincipalToken.sol";
|
|
@@ -36,10 +36,8 @@ abstract contract InterestManagerYT is TokenHelper, IPInterestManagerYT {
|
|
|
36
36
|
|
|
37
37
|
function _distributeInterestForTwo(address user1, address user2) internal {
|
|
38
38
|
uint256 index = _getInterestIndex();
|
|
39
|
-
if (user1 != address(0) && user1 != address(this))
|
|
40
|
-
|
|
41
|
-
if (user2 != address(0) && user2 != address(this))
|
|
42
|
-
_distributeInterestPrivate(user2, index);
|
|
39
|
+
if (user1 != address(0) && user1 != address(this)) _distributeInterestPrivate(user1, index);
|
|
40
|
+
if (user2 != address(0) && user2 != address(this)) _distributeInterestPrivate(user2, index);
|
|
43
41
|
}
|
|
44
42
|
|
|
45
43
|
function _doTransferOutInterest(
|
|
@@ -58,6 +56,8 @@ abstract contract InterestManagerYT is TokenHelper, IPInterestManagerYT {
|
|
|
58
56
|
|
|
59
57
|
_transferOut(SY, treasury, feeAmount);
|
|
60
58
|
_transferOut(SY, user, interestAmount);
|
|
59
|
+
|
|
60
|
+
emit CollectInterestFee(feeAmount);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
// should only be callable from `_distributeInterestForTwo` & make sure user != address(0) && user != address(this)
|
|
@@ -74,9 +74,7 @@ abstract contract InterestManagerYT is TokenHelper, IPInterestManagerYT {
|
|
|
74
74
|
|
|
75
75
|
uint256 principal = _YTbalance(user);
|
|
76
76
|
|
|
77
|
-
uint256 interestFromYT = (principal * (currentIndex - prevIndex)).divDown(
|
|
78
|
-
prevIndex * currentIndex
|
|
79
|
-
);
|
|
77
|
+
uint256 interestFromYT = (principal * (currentIndex - prevIndex)).divDown(prevIndex * currentIndex);
|
|
80
78
|
|
|
81
79
|
userInterest[user].accrued += interestFromYT.Uint128();
|
|
82
80
|
userInterest[user].index = currentIndex.Uint128();
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
pragma solidity 0.8.17;
|
|
24
|
+
pragma solidity ^0.8.17;
|
|
25
25
|
|
|
26
26
|
import "../../interfaces/IPYieldContractFactory.sol";
|
|
27
27
|
|
|
@@ -106,8 +106,7 @@ contract PendleYieldContractFactory is BoringOwnableUpgradeable, IPYieldContract
|
|
|
106
106
|
uint32 expiry,
|
|
107
107
|
bool doCacheIndexSameBlock
|
|
108
108
|
) external returns (address PT, address YT) {
|
|
109
|
-
if (MiniHelpers.isTimeInThePast(expiry) || expiry % expiryDivisor != 0)
|
|
110
|
-
revert Errors.YCFactoryInvalidExpiry();
|
|
109
|
+
if (MiniHelpers.isTimeInThePast(expiry) || expiry % expiryDivisor != 0) revert Errors.YCFactoryInvalidExpiry();
|
|
111
110
|
|
|
112
111
|
if (getPT[SY][expiry] != address(0)) revert Errors.YCFactoryYieldContractExisted();
|
|
113
112
|
|