@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
|
@@ -3,17 +3,17 @@ pragma solidity ^0.8.14;
|
|
|
3
3
|
|
|
4
4
|
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
enum Module {
|
|
7
|
+
RESOLVER,
|
|
8
|
+
TIME,
|
|
9
|
+
PROXY,
|
|
10
|
+
SINGLE_EXEC
|
|
11
|
+
}
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
struct ModuleData {
|
|
14
|
+
Module[] modules;
|
|
15
|
+
bytes[] args;
|
|
16
|
+
}
|
|
17
17
|
|
|
18
18
|
interface IAutomate {
|
|
19
19
|
function createTask(
|
|
@@ -33,17 +33,9 @@ interface IAutomate {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
interface ITaskTreasuryUpgradable {
|
|
36
|
-
function depositFunds(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
uint256 amount
|
|
40
|
-
) external payable;
|
|
41
|
-
|
|
42
|
-
function withdrawFunds(
|
|
43
|
-
address payable receiver,
|
|
44
|
-
address token,
|
|
45
|
-
uint256 amount
|
|
46
|
-
) external;
|
|
36
|
+
function depositFunds(address receiver, address token, uint256 amount) external payable;
|
|
37
|
+
|
|
38
|
+
function withdrawFunds(address payable receiver, address token, uint256 amount) external;
|
|
47
39
|
}
|
|
48
40
|
|
|
49
41
|
interface IOpsProxyFactory {
|
|
@@ -61,8 +53,7 @@ abstract contract AutomateReady {
|
|
|
61
53
|
address public immutable dedicatedMsgSender;
|
|
62
54
|
address private immutable _gelato;
|
|
63
55
|
address internal constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
|
|
64
|
-
address private constant OPS_PROXY_FACTORY =
|
|
65
|
-
0xC815dB16D4be6ddf2685C201937905aBf338F5D7;
|
|
56
|
+
address private constant OPS_PROXY_FACTORY = 0xC815dB16D4be6ddf2685C201937905aBf338F5D7;
|
|
66
57
|
|
|
67
58
|
/**
|
|
68
59
|
* @dev
|
|
@@ -81,9 +72,7 @@ abstract contract AutomateReady {
|
|
|
81
72
|
constructor(address _automate, address _taskCreator) {
|
|
82
73
|
automate = IAutomate(_automate);
|
|
83
74
|
_gelato = IAutomate(_automate).gelato();
|
|
84
|
-
(dedicatedMsgSender,) = IOpsProxyFactory(OPS_PROXY_FACTORY).getProxyOf(
|
|
85
|
-
_taskCreator
|
|
86
|
-
);
|
|
75
|
+
(dedicatedMsgSender, ) = IOpsProxyFactory(OPS_PROXY_FACTORY).getProxyOf(_taskCreator);
|
|
87
76
|
}
|
|
88
77
|
|
|
89
78
|
/**
|
|
@@ -94,18 +83,14 @@ abstract contract AutomateReady {
|
|
|
94
83
|
*/
|
|
95
84
|
function _transfer(uint256 _fee, address _feeToken) internal {
|
|
96
85
|
if (_feeToken == ETH) {
|
|
97
|
-
(bool success,) = _gelato.call{value: _fee}("");
|
|
86
|
+
(bool success, ) = _gelato.call{value: _fee}("");
|
|
98
87
|
require(success, "_transfer: ETH transfer failed");
|
|
99
88
|
} else {
|
|
100
89
|
SafeERC20.safeTransfer(IERC20(_feeToken), _gelato, _fee);
|
|
101
90
|
}
|
|
102
91
|
}
|
|
103
92
|
|
|
104
|
-
function _getFeeDetails()
|
|
105
|
-
internal
|
|
106
|
-
view
|
|
107
|
-
returns (uint256 fee, address feeToken)
|
|
108
|
-
{
|
|
93
|
+
function _getFeeDetails() internal view returns (uint256 fee, address feeToken) {
|
|
109
94
|
(fee, feeToken) = automate.getFeeDetails();
|
|
110
95
|
}
|
|
111
96
|
}
|
|
@@ -17,7 +17,10 @@ contract BaseSplitCodeFactoryContract is BoringOwnableUpgradeable {
|
|
|
17
17
|
__BoringOwnable_init();
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
function deploy(
|
|
20
|
+
function deploy(
|
|
21
|
+
string memory name,
|
|
22
|
+
bytes calldata creationCode
|
|
23
|
+
)
|
|
21
24
|
external
|
|
22
25
|
onlyOwner
|
|
23
26
|
returns (
|
|
@@ -27,8 +30,8 @@ contract BaseSplitCodeFactoryContract is BoringOwnableUpgradeable {
|
|
|
27
30
|
uint256 creationCodeSizeB
|
|
28
31
|
)
|
|
29
32
|
{
|
|
30
|
-
(creationCodeContractA, creationCodeSizeA, creationCodeContractB, creationCodeSizeB) =
|
|
31
|
-
|
|
33
|
+
(creationCodeContractA, creationCodeSizeA, creationCodeContractB, creationCodeSizeB) = BaseSplitCodeFactory
|
|
34
|
+
.setCreationCode(creationCode);
|
|
32
35
|
emit Deployed(name, creationCodeContractA, creationCodeSizeA, creationCodeContractB, creationCodeSizeB);
|
|
33
36
|
}
|
|
34
37
|
}
|
|
@@ -12,13 +12,8 @@ abstract contract BoringLpSeller {
|
|
|
12
12
|
/// @param netLpIn amount of Lp to sell
|
|
13
13
|
/// @param tokenOut should be included in SY.getTokensOut()
|
|
14
14
|
/// @return netTokenOut amount of token out
|
|
15
|
-
function _sellLpForToken(
|
|
16
|
-
|
|
17
|
-
uint256 netLpIn,
|
|
18
|
-
address tokenOut
|
|
19
|
-
) internal returns (uint256 netTokenOut) {
|
|
20
|
-
(IStandardizedYield SY, IPPrincipalToken PT, IPYieldToken YT) = IPMarket(market)
|
|
21
|
-
.readTokens();
|
|
15
|
+
function _sellLpForToken(address market, uint256 netLpIn, address tokenOut) internal returns (uint256 netTokenOut) {
|
|
16
|
+
(IStandardizedYield SY, IPPrincipalToken PT, IPYieldToken YT) = IPMarket(market).readTokens();
|
|
22
17
|
|
|
23
18
|
IPMarket(market).transfer(market, netLpIn);
|
|
24
19
|
|
|
@@ -29,16 +24,8 @@ abstract contract BoringLpSeller {
|
|
|
29
24
|
uint256 netSyFromPt = YT.redeemPY(address(SY));
|
|
30
25
|
netSyToRedeem = netSyRemoved + netSyFromPt;
|
|
31
26
|
} else {
|
|
32
|
-
(uint256 netSyRemoved, uint256 netPtRemoved) = IPMarket(market).burn(
|
|
33
|
-
|
|
34
|
-
market,
|
|
35
|
-
netLpIn
|
|
36
|
-
);
|
|
37
|
-
(uint256 netSySwappedOut, ) = IPMarket(market).swapExactPtForSy(
|
|
38
|
-
address(SY),
|
|
39
|
-
netPtRemoved,
|
|
40
|
-
EMPTY_BYTES
|
|
41
|
-
);
|
|
27
|
+
(uint256 netSyRemoved, uint256 netPtRemoved) = IPMarket(market).burn(address(SY), market, netLpIn);
|
|
28
|
+
(uint256 netSySwappedOut, ) = IPMarket(market).swapExactPtForSy(address(SY), netPtRemoved, EMPTY_BYTES);
|
|
42
29
|
netSyToRedeem = netSyRemoved + netSySwappedOut;
|
|
43
30
|
}
|
|
44
31
|
|
|
@@ -12,13 +12,8 @@ abstract contract BoringPtSeller {
|
|
|
12
12
|
/// @param netPtIn amount of Pt to sell
|
|
13
13
|
/// @param tokenOut should be included in SY.getTokensOut()
|
|
14
14
|
/// @return netTokenOut amount of token out
|
|
15
|
-
function _sellPtForToken(
|
|
16
|
-
|
|
17
|
-
uint256 netPtIn,
|
|
18
|
-
address tokenOut
|
|
19
|
-
) internal returns (uint256 netTokenOut) {
|
|
20
|
-
(IStandardizedYield SY, IPPrincipalToken PT, IPYieldToken YT) = IPMarket(market)
|
|
21
|
-
.readTokens();
|
|
15
|
+
function _sellPtForToken(address market, uint256 netPtIn, address tokenOut) internal returns (uint256 netTokenOut) {
|
|
16
|
+
(IStandardizedYield SY, IPPrincipalToken PT, IPYieldToken YT) = IPMarket(market).readTokens();
|
|
22
17
|
|
|
23
18
|
uint256 netSyOut;
|
|
24
19
|
if (PT.isExpired()) {
|
|
@@ -28,7 +28,7 @@ contract Broadcaster is Initializable, BoringOwnableUpgradeable, UUPSUpgradeable
|
|
|
28
28
|
lastBroadcastedWeek = currentWeek;
|
|
29
29
|
|
|
30
30
|
votingController.finalizeEpoch();
|
|
31
|
-
for (uint256 i = 0; i < chainIds.length;) {
|
|
31
|
+
for (uint256 i = 0; i < chainIds.length; ) {
|
|
32
32
|
uint64 chainId = chainIds[i];
|
|
33
33
|
uint256 fee = votingController.getBroadcastResultFee(chainId);
|
|
34
34
|
votingController.broadcastResults{value: fee}(chainId);
|
|
@@ -57,10 +57,14 @@ library BytesLib {
|
|
|
57
57
|
// length of the arrays.
|
|
58
58
|
end := add(mc, length)
|
|
59
59
|
|
|
60
|
-
for {
|
|
60
|
+
for {
|
|
61
|
+
let cc := add(_postBytes, 0x20)
|
|
62
|
+
} lt(mc, end) {
|
|
61
63
|
mc := add(mc, 0x20)
|
|
62
64
|
cc := add(cc, 0x20)
|
|
63
|
-
} {
|
|
65
|
+
} {
|
|
66
|
+
mstore(mc, mload(cc))
|
|
67
|
+
}
|
|
64
68
|
|
|
65
69
|
// Update the free-memory pointer by padding our last write location
|
|
66
70
|
// to 32 bytes: add 31 bytes to the end of tempBytes to move to the
|
|
@@ -168,7 +172,9 @@ library BytesLib {
|
|
|
168
172
|
} lt(mc, end) {
|
|
169
173
|
sc := add(sc, 1)
|
|
170
174
|
mc := add(mc, 0x20)
|
|
171
|
-
} {
|
|
175
|
+
} {
|
|
176
|
+
sstore(sc, mload(mc))
|
|
177
|
+
}
|
|
172
178
|
|
|
173
179
|
mask := exp(0x100, sub(mc, end))
|
|
174
180
|
|
|
@@ -200,7 +206,9 @@ library BytesLib {
|
|
|
200
206
|
} lt(mc, end) {
|
|
201
207
|
sc := add(sc, 1)
|
|
202
208
|
mc := add(mc, 0x20)
|
|
203
|
-
} {
|
|
209
|
+
} {
|
|
210
|
+
sstore(sc, mload(mc))
|
|
211
|
+
}
|
|
204
212
|
|
|
205
213
|
mask := exp(0x100, sub(mc, end))
|
|
206
214
|
|
|
@@ -246,7 +254,9 @@ library BytesLib {
|
|
|
246
254
|
} lt(mc, end) {
|
|
247
255
|
mc := add(mc, 0x20)
|
|
248
256
|
cc := add(cc, 0x20)
|
|
249
|
-
} {
|
|
257
|
+
} {
|
|
258
|
+
mstore(mc, mload(cc))
|
|
259
|
+
}
|
|
250
260
|
|
|
251
261
|
mstore(tempBytes, _length)
|
|
252
262
|
|
|
@@ -385,10 +395,9 @@ library BytesLib {
|
|
|
385
395
|
let mc := add(_preBytes, 0x20)
|
|
386
396
|
let end := add(mc, length)
|
|
387
397
|
|
|
388
|
-
for {
|
|
389
|
-
|
|
390
|
-
// while(uint256(mc < end) + cb == 2)
|
|
391
|
-
eq(add(lt(mc, end), cb), 2) {
|
|
398
|
+
for {
|
|
399
|
+
let cc := add(_postBytes, 0x20)
|
|
400
|
+
} eq(add(lt(mc, end), cb), 2) { // while(uint256(mc < end) + cb == 2) // the next line is the loop condition:
|
|
392
401
|
mc := add(mc, 0x20)
|
|
393
402
|
cc := add(cc, 0x20)
|
|
394
403
|
} {
|
|
@@ -451,10 +460,11 @@ library BytesLib {
|
|
|
451
460
|
let numTailBytes := and(length, 0x1f)
|
|
452
461
|
let mcRem := mload(mc)
|
|
453
462
|
let ccRem := mload(cc)
|
|
454
|
-
for {
|
|
455
|
-
|
|
456
|
-
// while(uint256(i < numTailBytes) + cb == 2)
|
|
457
|
-
|
|
463
|
+
for {
|
|
464
|
+
let i := 0
|
|
465
|
+
} eq(add(lt(i, numTailBytes), cb), 2) { // while(uint256(i < numTailBytes) + cb == 2) // the next line is the loop condition:
|
|
466
|
+
i := add(i, 1)
|
|
467
|
+
} {
|
|
458
468
|
if iszero(eq(byte(i, mcRem), byte(i, ccRem))) {
|
|
459
469
|
// unsuccess:
|
|
460
470
|
success := 0
|
|
@@ -515,7 +525,9 @@ library BytesLib {
|
|
|
515
525
|
|
|
516
526
|
// the next line is the loop condition:
|
|
517
527
|
// while(uint256(mc < end) + cb == 2)
|
|
518
|
-
for {
|
|
528
|
+
for {
|
|
529
|
+
|
|
530
|
+
} eq(add(lt(mc, end), cb), 2) {
|
|
519
531
|
sc := add(sc, 1)
|
|
520
532
|
mc := add(mc, 0x20)
|
|
521
533
|
} {
|
|
@@ -26,23 +26,14 @@ interface StarNFTV1 {
|
|
|
26
26
|
uint256[] ids,
|
|
27
27
|
uint256[] values
|
|
28
28
|
);
|
|
29
|
-
event TransferSingle(
|
|
30
|
-
address indexed operator,
|
|
31
|
-
address indexed from,
|
|
32
|
-
address indexed to,
|
|
33
|
-
uint256 id,
|
|
34
|
-
uint256 value
|
|
35
|
-
);
|
|
29
|
+
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
|
|
36
30
|
event URI(string value, uint256 indexed id);
|
|
37
31
|
|
|
38
32
|
function addMinter(address minter) external;
|
|
39
33
|
|
|
40
34
|
function balanceOf(address account, uint256 id) external view returns (uint256);
|
|
41
35
|
|
|
42
|
-
function balanceOfBatch(address[] memory accounts, uint256[] memory ids)
|
|
43
|
-
external
|
|
44
|
-
view
|
|
45
|
-
returns (uint256[] memory);
|
|
36
|
+
function balanceOfBatch(address[] memory accounts, uint256[] memory ids) external view returns (uint256[] memory);
|
|
46
37
|
|
|
47
38
|
function baseURI() external view returns (string memory);
|
|
48
39
|
|
|
@@ -56,11 +47,7 @@ interface StarNFTV1 {
|
|
|
56
47
|
|
|
57
48
|
function mint(address account, uint256 powah) external returns (uint256);
|
|
58
49
|
|
|
59
|
-
function mintBatch(
|
|
60
|
-
address account,
|
|
61
|
-
uint256 amount,
|
|
62
|
-
uint256[] memory powahArr
|
|
63
|
-
) external returns (uint256[] memory);
|
|
50
|
+
function mintBatch(address account, uint256 amount, uint256[] memory powahArr) external returns (uint256[] memory);
|
|
64
51
|
|
|
65
52
|
function minters(address) external view returns (bool);
|
|
66
53
|
|
|
@@ -78,13 +65,7 @@ interface StarNFTV1 {
|
|
|
78
65
|
bytes memory data
|
|
79
66
|
) external;
|
|
80
67
|
|
|
81
|
-
function safeTransferFrom(
|
|
82
|
-
address from,
|
|
83
|
-
address to,
|
|
84
|
-
uint256 id,
|
|
85
|
-
uint256 amount,
|
|
86
|
-
bytes memory data
|
|
87
|
-
) external;
|
|
68
|
+
function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes memory data) external;
|
|
88
69
|
|
|
89
70
|
function setApprovalForAll(address operator, bool approved) external;
|
|
90
71
|
|
|
@@ -19,11 +19,11 @@ contract LimitBackendHelper is TokenHelper {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
/// @notice vanilla read
|
|
22
|
-
function readSingleToken(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
{
|
|
22
|
+
function readSingleToken(
|
|
23
|
+
address token,
|
|
24
|
+
address[] calldata owners,
|
|
25
|
+
address spender
|
|
26
|
+
) public view returns (uint256[] memory balances, uint256[] memory allowances) {
|
|
27
27
|
balances = new uint256[](owners.length);
|
|
28
28
|
allowances = new uint256[](owners.length);
|
|
29
29
|
for (uint256 i = 0; i < owners.length; i++) {
|
|
@@ -33,11 +33,11 @@ contract LimitBackendHelper is TokenHelper {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/// @notice auto return balances and allowances the input tokens of the orders, based on type
|
|
36
|
-
function readMultiTokens(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
{
|
|
36
|
+
function readMultiTokens(
|
|
37
|
+
address[] calldata tokens,
|
|
38
|
+
address[] calldata owners,
|
|
39
|
+
address spender
|
|
40
|
+
) public view returns (uint256[] memory balances, uint256[] memory allowances) {
|
|
41
41
|
require(tokens.length == owners.length, "Length mismatch");
|
|
42
42
|
balances = new uint256[](owners.length);
|
|
43
43
|
allowances = new uint256[](owners.length);
|
|
@@ -62,7 +62,11 @@ contract LimitBackendHelper is TokenHelper {
|
|
|
62
62
|
for (uint256 i = 0; i < length; i++) {
|
|
63
63
|
(, bytes memory result) = original.delegatecall(
|
|
64
64
|
abi.encodeWithSignature(
|
|
65
|
-
"mintSyFromTokenRevert(address,address,address,uint256)",
|
|
65
|
+
"mintSyFromTokenRevert(address,address,address,uint256)",
|
|
66
|
+
makers[i],
|
|
67
|
+
SY,
|
|
68
|
+
tokens[i],
|
|
69
|
+
amounts[i]
|
|
66
70
|
)
|
|
67
71
|
);
|
|
68
72
|
minted[i] = parseMinted(result);
|
|
@@ -82,10 +86,12 @@ contract LimitBackendHelper is TokenHelper {
|
|
|
82
86
|
}
|
|
83
87
|
}
|
|
84
88
|
|
|
85
|
-
function mintSyFromTokenRevert(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
function mintSyFromTokenRevert(
|
|
90
|
+
address maker,
|
|
91
|
+
address SY,
|
|
92
|
+
address token,
|
|
93
|
+
uint256 makingAmount
|
|
94
|
+
) public returns (uint256) {
|
|
89
95
|
_transferIn(token, maker, makingAmount);
|
|
90
96
|
if (token == WNATIVE && !IStandardizedYield(SY).isValidTokenIn(WNATIVE)) {
|
|
91
97
|
_wrap_unwrap_ETH(WNATIVE, NATIVE, makingAmount);
|
|
@@ -93,7 +99,10 @@ contract LimitBackendHelper is TokenHelper {
|
|
|
93
99
|
}
|
|
94
100
|
_safeApproveInf(token, SY);
|
|
95
101
|
uint256 minted = IStandardizedYield(SY).deposit{value: token == NATIVE ? makingAmount : 0}(
|
|
96
|
-
address(this),
|
|
102
|
+
address(this),
|
|
103
|
+
token,
|
|
104
|
+
makingAmount,
|
|
105
|
+
0
|
|
97
106
|
);
|
|
98
107
|
revert Errors.SimulationResults(true, abi.encode(minted));
|
|
99
108
|
}
|
|
@@ -11,21 +11,10 @@ library MarketExchangeRateLib {
|
|
|
11
11
|
|
|
12
12
|
function getMarketExchangeRate(address market) internal view returns (uint256) {
|
|
13
13
|
MarketState memory state = IPMarket(market).readState(address(0));
|
|
14
|
-
MarketPreCompute memory comp = state.getMarketPreCompute(
|
|
15
|
-
_getPYIndexCurrent(market),
|
|
16
|
-
block.timestamp
|
|
17
|
-
);
|
|
14
|
+
MarketPreCompute memory comp = state.getMarketPreCompute(_getPYIndexCurrent(market), block.timestamp);
|
|
18
15
|
|
|
19
16
|
return
|
|
20
|
-
MarketMathCore
|
|
21
|
-
._getExchangeRate(
|
|
22
|
-
state.totalPt,
|
|
23
|
-
comp.totalAsset,
|
|
24
|
-
comp.rateScalar,
|
|
25
|
-
comp.rateAnchor,
|
|
26
|
-
0
|
|
27
|
-
)
|
|
28
|
-
.Uint();
|
|
17
|
+
MarketMathCore._getExchangeRate(state.totalPt, comp.totalAsset, comp.rateScalar, comp.rateAnchor, 0).Uint();
|
|
29
18
|
}
|
|
30
19
|
|
|
31
20
|
function _getPYIndexCurrent(address market) private view returns (PYIndex) {
|
|
@@ -16,9 +16,7 @@ contract Multicall2 {
|
|
|
16
16
|
bytes returnData;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
function aggregate(
|
|
20
|
-
Call[] memory calls
|
|
21
|
-
) public returns (uint256 blockNumber, bytes[] memory returnData) {
|
|
19
|
+
function aggregate(Call[] memory calls) public returns (uint256 blockNumber, bytes[] memory returnData) {
|
|
22
20
|
blockNumber = block.number;
|
|
23
21
|
returnData = new bytes[](calls.length);
|
|
24
22
|
for (uint256 i = 0; i < calls.length; i++) {
|
|
@@ -66,10 +64,7 @@ contract Multicall2 {
|
|
|
66
64
|
blockHash = blockhash(block.number - 1);
|
|
67
65
|
}
|
|
68
66
|
|
|
69
|
-
function tryAggregate(
|
|
70
|
-
bool requireSuccess,
|
|
71
|
-
Call[] memory calls
|
|
72
|
-
) public returns (Result[] memory returnData) {
|
|
67
|
+
function tryAggregate(bool requireSuccess, Call[] memory calls) public returns (Result[] memory returnData) {
|
|
73
68
|
returnData = new Result[](calls.length);
|
|
74
69
|
for (uint256 i = 0; i < calls.length; i++) {
|
|
75
70
|
(bool success, bytes memory ret) = calls[i].target.call(calls[i].callData);
|
|
@@ -15,7 +15,7 @@ contract PendleMulticallV1 {
|
|
|
15
15
|
function aggregate(Call[] calldata calls) public payable virtual {
|
|
16
16
|
uint256 length = calls.length;
|
|
17
17
|
Call calldata call;
|
|
18
|
-
for (uint256 i = 0; i < length;) {
|
|
18
|
+
for (uint256 i = 0; i < length; ) {
|
|
19
19
|
call = calls[i];
|
|
20
20
|
|
|
21
21
|
(bool success, bytes memory resp) = call.target.call(call.callData);
|
|
@@ -31,15 +31,15 @@ contract PendleMulticallV1 {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
function tryAggregate(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
{
|
|
34
|
+
function tryAggregate(
|
|
35
|
+
bool requireSuccess,
|
|
36
|
+
uint256 gasLimit,
|
|
37
|
+
Call[] calldata calls
|
|
38
|
+
) public payable returns (Result[] memory returnData) {
|
|
39
39
|
uint256 length = calls.length;
|
|
40
40
|
returnData = new Result[](length);
|
|
41
41
|
Call calldata call;
|
|
42
|
-
for (uint256 i = 0; i < length;) {
|
|
42
|
+
for (uint256 i = 0; i < length; ) {
|
|
43
43
|
call = calls[i];
|
|
44
44
|
|
|
45
45
|
(bool success, bytes memory resp) = call.target.call{gas: gasLimit}(calls[i].callData);
|
|
@@ -17,7 +17,7 @@ contract PendleMulticallV2 {
|
|
|
17
17
|
function aggregate(Call[] calldata calls) public payable virtual {
|
|
18
18
|
uint256 length = calls.length;
|
|
19
19
|
Call calldata call;
|
|
20
|
-
for (uint256 i = 0; i < length;) {
|
|
20
|
+
for (uint256 i = 0; i < length; ) {
|
|
21
21
|
call = calls[i];
|
|
22
22
|
|
|
23
23
|
(bool success, bytes memory resp) = call.target.call(call.callData);
|
|
@@ -33,15 +33,15 @@ contract PendleMulticallV2 {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
function tryAggregate(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
{
|
|
36
|
+
function tryAggregate(
|
|
37
|
+
bool requireSuccess,
|
|
38
|
+
uint256 gasLimit,
|
|
39
|
+
Call[] calldata calls
|
|
40
|
+
) public payable returns (Result[] memory returnData) {
|
|
41
41
|
uint256 length = calls.length;
|
|
42
42
|
returnData = new Result[](length);
|
|
43
43
|
Call calldata call;
|
|
44
|
-
for (uint256 i = 0; i < length;) {
|
|
44
|
+
for (uint256 i = 0; i < length; ) {
|
|
45
45
|
call = calls[i];
|
|
46
46
|
|
|
47
47
|
(bool success, bytes memory resp) = call.target.call{gas: gasLimit}(calls[i].callData);
|
|
@@ -59,15 +59,14 @@ contract PendleMulticallV2 {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
function tryAggregateRevert(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
{
|
|
62
|
+
function tryAggregateRevert(
|
|
63
|
+
uint256 gasLimit,
|
|
64
|
+
Call[] calldata calls
|
|
65
|
+
) public payable returns (bytes[] memory returnData) {
|
|
67
66
|
uint256 length = calls.length;
|
|
68
67
|
returnData = new bytes[](length);
|
|
69
68
|
Call calldata call;
|
|
70
|
-
for (uint256 i = 0; i < length;) {
|
|
69
|
+
for (uint256 i = 0; i < length; ) {
|
|
71
70
|
call = calls[i];
|
|
72
71
|
|
|
73
72
|
(, returnData[i]) = address(this).delegatecall{gas: gasLimit}(
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.17;
|
|
3
|
+
|
|
4
|
+
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
|
|
5
|
+
import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
|
|
6
|
+
import "../interfaces/IPOffchainStorage.sol";
|
|
7
|
+
|
|
8
|
+
contract PendleOffchainStorage is IPOffchainStorage, UUPSUpgradeable, AccessControlUpgradeable {
|
|
9
|
+
bytes32 public constant MAINTAINER = keccak256("MAINTAINER");
|
|
10
|
+
|
|
11
|
+
constructor() initializer {}
|
|
12
|
+
|
|
13
|
+
modifier onlyMaintainer() {
|
|
14
|
+
require(isMaintainer(msg.sender), "not maintainer");
|
|
15
|
+
_;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function isMaintainer(address addr) public view returns (bool) {
|
|
19
|
+
return (hasRole(DEFAULT_ADMIN_ROLE, addr) || hasRole(MAINTAINER, addr));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/*///////////////////////////////////////////////////////////////
|
|
23
|
+
CORE
|
|
24
|
+
//////////////////////////////////////////////////////////////*/
|
|
25
|
+
|
|
26
|
+
mapping(bytes32 => bytes) internal _storage;
|
|
27
|
+
|
|
28
|
+
function setStorageUint256(bytes32 key, uint256 value) external onlyMaintainer {
|
|
29
|
+
_setStorage(key, abi.encode(value));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function setStorage(bytes32 key, bytes memory value) external onlyMaintainer {
|
|
33
|
+
_setStorage(key, value);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function getUint256(bytes32 key) external view returns (uint256) {
|
|
37
|
+
return abi.decode(_storage[key], (uint256));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function _setStorage(bytes32 key, bytes memory value) internal {
|
|
41
|
+
_storage[key] = value;
|
|
42
|
+
emit SetStorage(key, value);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// TODO: update more getSomething functions later when theres a need
|
|
46
|
+
|
|
47
|
+
/*///////////////////////////////////////////////////////////////
|
|
48
|
+
UPGRADABLE RELATED
|
|
49
|
+
//////////////////////////////////////////////////////////////*/
|
|
50
|
+
function initialize() external initializer {
|
|
51
|
+
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function _authorizeUpgrade(address) internal view override {
|
|
55
|
+
require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "not admin");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
uint256[49] private __gap;
|
|
59
|
+
}
|
|
@@ -10,18 +10,17 @@ contract SimulateHelper {
|
|
|
10
10
|
original = address(this);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
function multicallRevert(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
{
|
|
13
|
+
function multicallRevert(
|
|
14
|
+
uint256 gasLimit,
|
|
15
|
+
address[] calldata targets,
|
|
16
|
+
bytes[] calldata callDatas
|
|
17
|
+
) public payable virtual returns (bytes[] memory res, uint256[] memory gasUsed) {
|
|
19
18
|
require(targets.length == callDatas.length, "length mismatch");
|
|
20
19
|
|
|
21
20
|
uint256 length = callDatas.length;
|
|
22
21
|
res = new bytes[](length);
|
|
23
22
|
gasUsed = new uint256[](length);
|
|
24
|
-
for (uint256 i = 0; i < length;) {
|
|
23
|
+
for (uint256 i = 0; i < length; ) {
|
|
25
24
|
uint256 gasBefore = gasleft();
|
|
26
25
|
(, res[i]) = original.delegatecall{gas: gasLimit}(
|
|
27
26
|
abi.encodeWithSignature("simulate(address,bytes)", targets[i], callDatas[i])
|
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
pragma solidity ^0.8.0;
|
|
2
2
|
|
|
3
3
|
library SDKErrorsDirectory {
|
|
4
|
+
error BulkInsufficientSyForTrade(uint256 currentAmount, uint256 requiredAmount);
|
|
5
|
+
error BulkInsufficientTokenForTrade(uint256 currentAmount, uint256 requiredAmount);
|
|
6
|
+
error BulkInSufficientSyOut(uint256 actualSyOut, uint256 requiredSyOut);
|
|
7
|
+
error BulkInSufficientTokenOut(uint256 actualTokenOut, uint256 requiredTokenOut);
|
|
8
|
+
error BulkInsufficientSyReceived(uint256 actualBalance, uint256 requiredBalance);
|
|
9
|
+
error BulkNotMaintainer();
|
|
10
|
+
error BulkNotAdmin();
|
|
11
|
+
error BulkSellerAlreadyExisted(address token, address SY, address bulk);
|
|
12
|
+
error BulkSellerInvalidToken(address token, address SY);
|
|
13
|
+
error BulkBadRateTokenToSy(uint256 actualRate, uint256 currentRate, uint256 eps);
|
|
14
|
+
error BulkBadRateSyToToken(uint256 actualRate, uint256 currentRate, uint256 eps);
|
|
4
15
|
error ApproxFail();
|
|
5
16
|
error ApproxParamsInvalid(uint256 guessMin, uint256 guessMax, uint256 eps);
|
|
6
17
|
error ApproxBinarySearchInputInvalid(
|
|
7
|
-
uint256 approxGuessMin,
|
|
18
|
+
uint256 approxGuessMin,
|
|
19
|
+
uint256 approxGuessMax,
|
|
20
|
+
uint256 minGuessMin,
|
|
21
|
+
uint256 maxGuessMax
|
|
8
22
|
);
|
|
9
23
|
error MarketExpired();
|
|
10
24
|
error MarketZeroAmountsInput();
|