@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
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
pragma solidity ^0.8.0;
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
interface IThenaGaugeV2 {
|
|
7
6
|
function emergency() external returns (bool);
|
|
8
7
|
|
|
@@ -15,4 +14,4 @@ interface IThenaGaugeV2 {
|
|
|
15
14
|
function getReward() external;
|
|
16
15
|
|
|
17
16
|
function balanceOf(address account) external view returns (uint256);
|
|
18
|
-
}
|
|
17
|
+
}
|
|
@@ -16,15 +16,13 @@ interface IThenaPair {
|
|
|
16
16
|
function getReserves() external view returns (uint _reserve0, uint _reserve1, uint _blockTimestampLast);
|
|
17
17
|
function getAmountOut(uint, address) external view returns (uint);
|
|
18
18
|
|
|
19
|
-
function name() external view returns(string memory);
|
|
20
|
-
function symbol() external view returns(string memory);
|
|
19
|
+
function name() external view returns (string memory);
|
|
20
|
+
function symbol() external view returns (string memory);
|
|
21
21
|
function totalSupply() external view returns (uint);
|
|
22
22
|
function decimals() external view returns (uint8);
|
|
23
23
|
|
|
24
24
|
function claimable0(address _user) external view returns (uint);
|
|
25
25
|
function claimable1(address _user) external view returns (uint);
|
|
26
26
|
|
|
27
|
-
function isStable() external view returns(bool);
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
function isStable() external view returns (bool);
|
|
30
28
|
}
|
|
@@ -12,42 +12,53 @@ library LimitMathCore {
|
|
|
12
12
|
using PMath for uint256;
|
|
13
13
|
using PMath for int256;
|
|
14
14
|
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
function calcBatch(
|
|
16
|
+
FillOrderParams[] memory params,
|
|
17
|
+
address YT,
|
|
18
|
+
uint256 lnFeeRateRoot
|
|
19
|
+
) internal returns (IPLimitOrderType.FillResults memory out) {
|
|
20
|
+
return
|
|
21
|
+
calcBatch(
|
|
22
|
+
params,
|
|
23
|
+
IPYieldToken(YT).expiry() - block.timestamp,
|
|
24
|
+
IPYieldToken(YT).pyIndexCurrent(),
|
|
25
|
+
lnFeeRateRoot
|
|
26
|
+
);
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
// --- PURE FUNCTIONS ---
|
|
25
|
-
function
|
|
30
|
+
function calcBatch(
|
|
26
31
|
FillOrderParams[] memory params,
|
|
27
32
|
uint256 timeToExpiry,
|
|
28
33
|
uint256 pyIndex,
|
|
29
34
|
uint256 lnFeeRateRoot
|
|
30
|
-
) internal pure returns (
|
|
35
|
+
) internal pure returns (IPLimitOrderType.FillResults memory out) {
|
|
31
36
|
uint256 len = params.length;
|
|
32
37
|
out.netMakings = new uint256[](len);
|
|
33
38
|
out.netTakings = new uint256[](len);
|
|
34
39
|
out.netFees = new uint256[](len);
|
|
35
40
|
out.notionalVolumes = new uint256[](len);
|
|
36
41
|
|
|
37
|
-
function
|
|
38
|
-
|
|
42
|
+
function(uint256, uint256, PYIndex, uint256)
|
|
43
|
+
internal
|
|
44
|
+
pure
|
|
45
|
+
returns (uint256, uint256, uint256) calc = getCalcFunctions(params[0].order.orderType);
|
|
39
46
|
|
|
40
47
|
uint256 feeRate = impliedRateToExchangeRate(lnFeeRateRoot, timeToExpiry);
|
|
41
48
|
|
|
42
|
-
for (uint256 i = 0; i < len; i
|
|
49
|
+
for (uint256 i = 0; i < len; i++) {
|
|
43
50
|
FillOrderParams memory param = params[i];
|
|
44
51
|
if (param.makingAmount == 0) continue; // nothing changes
|
|
45
52
|
|
|
46
53
|
uint256 exchangeRate = impliedRateToExchangeRate(param.order.lnImpliedRate, timeToExpiry);
|
|
47
54
|
|
|
48
55
|
out.netMakings[i] = param.makingAmount;
|
|
49
|
-
(out.netTakings[i], out.netFees[i], out.notionalVolumes[i]) =
|
|
50
|
-
|
|
56
|
+
(out.netTakings[i], out.netFees[i], out.notionalVolumes[i]) = calc(
|
|
57
|
+
out.netMakings[i],
|
|
58
|
+
exchangeRate,
|
|
59
|
+
PYIndex.wrap(pyIndex),
|
|
60
|
+
feeRate
|
|
61
|
+
);
|
|
51
62
|
|
|
52
63
|
require(out.netTakings[i] > 0, "LOP: can't swap 0 amount");
|
|
53
64
|
|
|
@@ -58,28 +69,30 @@ library LimitMathCore {
|
|
|
58
69
|
}
|
|
59
70
|
}
|
|
60
71
|
|
|
61
|
-
function
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
72
|
+
function calcSyForPt(
|
|
73
|
+
uint256 makeSy,
|
|
74
|
+
uint256 r,
|
|
75
|
+
PYIndex index,
|
|
76
|
+
uint256 f
|
|
77
|
+
) internal pure returns (uint256 takePt, uint256 fee, uint256 notionalVolume) {
|
|
66
78
|
// takePt = makeSy * index * r
|
|
67
|
-
// fee = makeSy * (f - 1)
|
|
79
|
+
// fee = makeSy * (f - 1) / f
|
|
68
80
|
// notionalVolume = makeSy
|
|
69
81
|
|
|
70
82
|
takePt = index.syToAsset(makeSy).mulDown(r);
|
|
71
|
-
fee = makeSy * (f - PMath.ONE) / f;
|
|
83
|
+
fee = (makeSy * (f - PMath.ONE)) / f;
|
|
72
84
|
notionalVolume = makeSy;
|
|
73
85
|
}
|
|
74
86
|
|
|
75
|
-
function
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
87
|
+
function calcPtForSy(
|
|
88
|
+
uint256 makePt,
|
|
89
|
+
uint256 r,
|
|
90
|
+
PYIndex index,
|
|
91
|
+
uint256 f
|
|
92
|
+
) internal pure returns (uint256 takeSy, uint256 fee, uint256 notionalVolume) {
|
|
80
93
|
// takeAsset = make / r
|
|
81
94
|
// takeSy = takeAsset / index
|
|
82
|
-
// fee = takeSy * (f-1)
|
|
95
|
+
// fee = takeSy * (f-1)
|
|
83
96
|
// notionalVolume = takeSy
|
|
84
97
|
|
|
85
98
|
takeSy = index.assetToSy(makePt.divDown(r));
|
|
@@ -87,35 +100,37 @@ library LimitMathCore {
|
|
|
87
100
|
notionalVolume = takeSy;
|
|
88
101
|
}
|
|
89
102
|
|
|
90
|
-
function
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
103
|
+
function calcSyForYt(
|
|
104
|
+
uint256 makeSy,
|
|
105
|
+
uint256 r,
|
|
106
|
+
PYIndex index,
|
|
107
|
+
uint256 f
|
|
108
|
+
) internal pure returns (uint256 takeYt, uint256 fee, uint256 notionalVolume) {
|
|
95
109
|
// pt = makeSy * index * r
|
|
96
110
|
// yt = pt / (r-1)
|
|
97
|
-
// fee = makeSy * (
|
|
111
|
+
// fee = makeSy * (f-1) / (r-1)
|
|
98
112
|
// notionalVolume = makeSy / (r-1)
|
|
99
113
|
uint256 pt_yt_ratio = r - PMath.ONE;
|
|
100
114
|
|
|
101
|
-
takeYt = index.syToAsset(makeSy) * r / pt_yt_ratio;
|
|
102
|
-
fee = makeSy * (f - PMath.ONE) / pt_yt_ratio;
|
|
115
|
+
takeYt = (index.syToAsset(makeSy) * r) / pt_yt_ratio;
|
|
116
|
+
fee = (makeSy * (f - PMath.ONE)) / pt_yt_ratio;
|
|
103
117
|
notionalVolume = makeSy.divDown(pt_yt_ratio);
|
|
104
118
|
}
|
|
105
119
|
|
|
106
|
-
function
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
120
|
+
function calcYtForSy(
|
|
121
|
+
uint256 makeYt,
|
|
122
|
+
uint256 r,
|
|
123
|
+
PYIndex index,
|
|
124
|
+
uint256 f
|
|
125
|
+
) internal pure returns (uint256 takeSy, uint256 fee, uint256 notionalVolume) {
|
|
111
126
|
// pt = yt * (r-1)
|
|
112
127
|
// takeSy = pt / r / index
|
|
113
|
-
// feeSy = takeSy * (f-1) / (r-1)
|
|
128
|
+
// feeSy = takeSy * (f-1) / f / (r-1)
|
|
114
129
|
// notionalVolume = takeSy / (r-1)
|
|
115
130
|
uint256 pt_yt_ratio = r - PMath.ONE;
|
|
116
131
|
|
|
117
|
-
takeSy = index.assetToSy(makeYt * pt_yt_ratio / r);
|
|
118
|
-
fee = (takeSy * (f - PMath.ONE) / f).divDown(pt_yt_ratio);
|
|
132
|
+
takeSy = index.assetToSy((makeYt * pt_yt_ratio) / r);
|
|
133
|
+
fee = ((takeSy * (f - PMath.ONE)) / f).divDown(pt_yt_ratio);
|
|
119
134
|
notionalVolume = takeSy.divDown(pt_yt_ratio);
|
|
120
135
|
}
|
|
121
136
|
|
|
@@ -123,27 +138,21 @@ library LimitMathCore {
|
|
|
123
138
|
return MarketMathCore._getExchangeRateFromImpliedRate(lnRate, timeToExpiry).Uint();
|
|
124
139
|
}
|
|
125
140
|
|
|
126
|
-
function
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function getCalcFunctions(IPOrderMixinType.OrderType t)
|
|
141
|
+
function getCalcFunctions(
|
|
142
|
+
IPLimitOrderType.OrderType t
|
|
143
|
+
)
|
|
133
144
|
internal
|
|
134
145
|
pure
|
|
135
|
-
returns (
|
|
136
|
-
function (uint256, uint256, PYIndex, uint256) internal pure returns (uint256, uint256, uint256) calcNormal
|
|
137
|
-
)
|
|
146
|
+
returns (function(uint256, uint256, PYIndex, uint256) internal pure returns (uint256, uint256, uint256) calc)
|
|
138
147
|
{
|
|
139
|
-
if (t ==
|
|
140
|
-
return (
|
|
141
|
-
} else if (t ==
|
|
142
|
-
return (
|
|
143
|
-
} else if (t ==
|
|
144
|
-
return (
|
|
148
|
+
if (t == IPLimitOrderType.OrderType.SY_FOR_PT) {
|
|
149
|
+
return (calcSyForPt);
|
|
150
|
+
} else if (t == IPLimitOrderType.OrderType.PT_FOR_SY) {
|
|
151
|
+
return (calcPtForSy);
|
|
152
|
+
} else if (t == IPLimitOrderType.OrderType.SY_FOR_YT) {
|
|
153
|
+
return (calcSyForYt);
|
|
145
154
|
} else {
|
|
146
|
-
return (
|
|
155
|
+
return (calcYtForSy);
|
|
147
156
|
}
|
|
148
157
|
}
|
|
149
158
|
}
|
|
@@ -12,7 +12,7 @@ import "./helpers/NonceManager.sol";
|
|
|
12
12
|
import "../interfaces/IWETH.sol";
|
|
13
13
|
import {LimitMathCore as LimitMath} from "./LimitMathCore.sol";
|
|
14
14
|
|
|
15
|
-
abstract contract
|
|
15
|
+
abstract contract LimitRouterBase is
|
|
16
16
|
EIP712Upgradeable,
|
|
17
17
|
IPLimitRouter,
|
|
18
18
|
BoringOwnableUpgradeable,
|
|
@@ -22,9 +22,10 @@ abstract contract PendleOrderMixin is
|
|
|
22
22
|
using SafeERC20 for IERC20;
|
|
23
23
|
using PMath for uint256;
|
|
24
24
|
|
|
25
|
-
bytes32 internal constant LIMIT_ORDER_TYPEHASH =
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
bytes32 internal constant LIMIT_ORDER_TYPEHASH =
|
|
26
|
+
keccak256(
|
|
27
|
+
"Order(uint256 salt,uint256 expiry,uint256 nonce,uint8 orderType,address token,address YT,address maker,address receiver,uint256 makingAmount,uint256 lnImpliedRate,uint256 failSafeRate,bytes permit)"
|
|
28
|
+
);
|
|
28
29
|
|
|
29
30
|
uint128 internal constant _ORDER_DOES_NOT_EXIST = 0;
|
|
30
31
|
uint128 internal constant _ORDER_FILLED = 1;
|
|
@@ -53,22 +54,24 @@ abstract contract PendleOrderMixin is
|
|
|
53
54
|
setFeeRecipient(_feeRecipient);
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
function
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
function fill(
|
|
58
|
+
FillOrderParams[] memory params,
|
|
59
|
+
address receiver,
|
|
60
|
+
uint256 maxTaking,
|
|
61
|
+
bytes calldata /*optData*/,
|
|
62
|
+
bytes memory callback
|
|
63
|
+
) external returns (uint256 actualMaking, uint256 actualTaking, uint256 totalFee, bytes memory callbackReturn) {
|
|
60
64
|
_validateOrdersSkipSig(params);
|
|
61
65
|
OrderType orderType = params[0].order.orderType;
|
|
62
66
|
if (orderType == OrderType.SY_FOR_PT || orderType == OrderType.SY_FOR_YT) {
|
|
63
|
-
return
|
|
67
|
+
return fillTokenForPY(Args(orderType, params, receiver, maxTaking, callback));
|
|
64
68
|
} else {
|
|
65
|
-
return
|
|
69
|
+
return fillPYForToken(Args(orderType, params, receiver, maxTaking, callback));
|
|
66
70
|
}
|
|
67
71
|
}
|
|
68
72
|
|
|
69
73
|
// ----------------- Core logic -----------------
|
|
70
74
|
|
|
71
|
-
// solhint-disable-next-line
|
|
72
75
|
struct Args {
|
|
73
76
|
OrderType orderType;
|
|
74
77
|
FillOrderParams[] params;
|
|
@@ -77,16 +80,15 @@ abstract contract PendleOrderMixin is
|
|
|
77
80
|
bytes callback;
|
|
78
81
|
}
|
|
79
82
|
|
|
80
|
-
function
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
{
|
|
83
|
+
function fillTokenForPY(
|
|
84
|
+
Args memory a
|
|
85
|
+
) internal returns (uint256 actualMaking, uint256 actualTaking, uint256 totalFee, bytes memory callbackReturn) {
|
|
84
86
|
(address SY, address PT, address YT, bytes32[] memory orderHashes) = _checkSig_updMakingAndStatus(a.params);
|
|
85
87
|
|
|
86
88
|
// Token => This
|
|
87
89
|
uint256[] memory fromMakers = _transferFromMakers_mintSy_updMakings(SY, a.params);
|
|
88
90
|
|
|
89
|
-
|
|
91
|
+
FillResults memory out = LimitMath.calcBatch(a.params, YT, getLnFeeRateRoot(YT));
|
|
90
92
|
(actualMaking, actualTaking, totalFee) = (out.totalMaking - out.totalFee, out.totalTaking, out.totalFee);
|
|
91
93
|
|
|
92
94
|
require(actualTaking <= a.maxTaking, "LOP: maxTaking exceeded");
|
|
@@ -96,8 +98,12 @@ abstract contract PendleOrderMixin is
|
|
|
96
98
|
|
|
97
99
|
// callback to Taker
|
|
98
100
|
if (a.callback.length > 0) {
|
|
99
|
-
callbackReturn =
|
|
100
|
-
|
|
101
|
+
callbackReturn = IPLimitRouterCallback(msg.sender).limitRouterCallback(
|
|
102
|
+
actualMaking,
|
|
103
|
+
actualTaking,
|
|
104
|
+
totalFee,
|
|
105
|
+
a.callback
|
|
106
|
+
);
|
|
101
107
|
}
|
|
102
108
|
|
|
103
109
|
// Taker => Makers
|
|
@@ -111,13 +117,12 @@ abstract contract PendleOrderMixin is
|
|
|
111
117
|
_checkSafety_emitEvents(a.params, orderHashes, fromMakers, out.netTakings, out.netFees, out.notionalVolumes);
|
|
112
118
|
}
|
|
113
119
|
|
|
114
|
-
function
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
{
|
|
120
|
+
function fillPYForToken(
|
|
121
|
+
Args memory a
|
|
122
|
+
) internal returns (uint256 actualMaking, uint256 actualTaking, uint256 totalFee, bytes memory callbackReturn) {
|
|
118
123
|
(address SY, address PT, address YT, bytes32[] memory orderHashes) = _checkSig_updMakingAndStatus(a.params);
|
|
119
124
|
|
|
120
|
-
|
|
125
|
+
FillResults memory out = LimitMath.calcBatch(a.params, YT, getLnFeeRateRoot(YT));
|
|
121
126
|
(actualMaking, actualTaking, totalFee) = (out.totalMaking, out.totalTaking + out.totalFee, out.totalFee);
|
|
122
127
|
|
|
123
128
|
require(actualTaking <= a.maxTaking, "LOP: maxTaking exceeded");
|
|
@@ -128,8 +133,12 @@ abstract contract PendleOrderMixin is
|
|
|
128
133
|
|
|
129
134
|
// callback to Taker
|
|
130
135
|
if (a.callback.length > 0) {
|
|
131
|
-
callbackReturn =
|
|
132
|
-
|
|
136
|
+
callbackReturn = IPLimitRouterCallback(msg.sender).limitRouterCallback(
|
|
137
|
+
actualMaking,
|
|
138
|
+
actualTaking,
|
|
139
|
+
totalFee,
|
|
140
|
+
a.callback
|
|
141
|
+
);
|
|
133
142
|
}
|
|
134
143
|
|
|
135
144
|
// Taker => This
|
|
@@ -155,7 +164,7 @@ abstract contract PendleOrderMixin is
|
|
|
155
164
|
uint256 expiry = IPYieldToken(YT).expiry();
|
|
156
165
|
require(block.timestamp < expiry, "LOP: PY expired");
|
|
157
166
|
|
|
158
|
-
for (uint256 i = 0; i < len; i
|
|
167
|
+
for (uint256 i = 0; i < len; i++) {
|
|
159
168
|
Order memory order = params[i].order;
|
|
160
169
|
|
|
161
170
|
require(order.orderType == orderType, "LOP: not same orderType");
|
|
@@ -165,18 +174,19 @@ abstract contract PendleOrderMixin is
|
|
|
165
174
|
}
|
|
166
175
|
}
|
|
167
176
|
|
|
168
|
-
function _checkSig_updMakingAndStatus(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
{
|
|
177
|
+
function _checkSig_updMakingAndStatus(
|
|
178
|
+
FillOrderParams[] memory params
|
|
179
|
+
) internal returns (address SY, address PT, address YT, bytes32[] memory orderHashes) {
|
|
172
180
|
uint256 len = params.length;
|
|
173
181
|
orderHashes = new bytes32[](len);
|
|
174
182
|
|
|
175
|
-
for (uint256 i = 0; i < len; i
|
|
183
|
+
for (uint256 i = 0; i < len; i++) {
|
|
176
184
|
FillOrderParams memory param = params[i];
|
|
177
185
|
|
|
178
|
-
(bytes32 orderHash, uint256 remainingMakerAmount, uint256 filledMakerAmount) =
|
|
179
|
-
|
|
186
|
+
(bytes32 orderHash, uint256 remainingMakerAmount, uint256 filledMakerAmount) = _checkSig(
|
|
187
|
+
param.order,
|
|
188
|
+
param.signature
|
|
189
|
+
);
|
|
180
190
|
uint256 netMaking = PMath.min(param.makingAmount, remainingMakerAmount);
|
|
181
191
|
|
|
182
192
|
unchecked {
|
|
@@ -207,11 +217,11 @@ abstract contract PendleOrderMixin is
|
|
|
207
217
|
) internal {
|
|
208
218
|
uint256 len = hashes.length;
|
|
209
219
|
|
|
210
|
-
for (uint256 i = 0; i < len; i
|
|
220
|
+
for (uint256 i = 0; i < len; i++) {
|
|
211
221
|
require(fromMakers[i].mulDown(params[i].order.failSafeRate) <= toMakers[i], "LOP: fail safe");
|
|
212
222
|
}
|
|
213
223
|
|
|
214
|
-
for (uint256 i = 0; i < len; i
|
|
224
|
+
for (uint256 i = 0; i < len; i++) {
|
|
215
225
|
Order memory order = params[i].order;
|
|
216
226
|
emit OrderFilled(
|
|
217
227
|
hashes[i],
|
|
@@ -226,7 +236,10 @@ abstract contract PendleOrderMixin is
|
|
|
226
236
|
}
|
|
227
237
|
}
|
|
228
238
|
|
|
229
|
-
function _checkSig(
|
|
239
|
+
function _checkSig(
|
|
240
|
+
Order memory order,
|
|
241
|
+
bytes memory signature
|
|
242
|
+
)
|
|
230
243
|
internal
|
|
231
244
|
view
|
|
232
245
|
returns (
|
|
@@ -256,17 +269,17 @@ abstract contract PendleOrderMixin is
|
|
|
256
269
|
|
|
257
270
|
// ----------------- simple helper functions functions -----------------
|
|
258
271
|
|
|
259
|
-
function _transferFromMakers_mintSy_updMakings(
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
{
|
|
272
|
+
function _transferFromMakers_mintSy_updMakings(
|
|
273
|
+
address SY,
|
|
274
|
+
FillOrderParams[] memory params
|
|
275
|
+
) internal returns (uint256[] memory fromMakers) {
|
|
263
276
|
uint256 len = params.length;
|
|
264
277
|
fromMakers = new uint256[](len);
|
|
265
278
|
|
|
266
279
|
for ((uint256 l, uint256 r) = (0, 0); l < len; l = r) {
|
|
267
280
|
address sharedToken = params[l].order.token;
|
|
268
281
|
uint256 totalMaking = 0;
|
|
269
|
-
for (; r < len && params[r].order.token == sharedToken; r
|
|
282
|
+
for (; r < len && params[r].order.token == sharedToken; r++) {
|
|
270
283
|
_transferIn(sharedToken, params[r].order.maker, params[r].makingAmount);
|
|
271
284
|
totalMaking += params[r].makingAmount;
|
|
272
285
|
fromMakers[r] = params[r].makingAmount;
|
|
@@ -275,7 +288,7 @@ abstract contract PendleOrderMixin is
|
|
|
275
288
|
if (sharedToken == SY || totalMaking == 0) continue;
|
|
276
289
|
|
|
277
290
|
uint256 totalSy = __mintSy_Single(SY, sharedToken, totalMaking);
|
|
278
|
-
for (uint256 i = l; i < r; i
|
|
291
|
+
for (uint256 i = l; i < r; i++) {
|
|
279
292
|
params[i].makingAmount = (params[i].makingAmount * totalSy) / totalMaking;
|
|
280
293
|
}
|
|
281
294
|
}
|
|
@@ -288,13 +301,19 @@ abstract contract PendleOrderMixin is
|
|
|
288
301
|
}
|
|
289
302
|
_safeApproveInf(token, SY);
|
|
290
303
|
return
|
|
291
|
-
IStandardizedYield(SY).deposit{value: token == NATIVE ? netTokenIn : 0}(
|
|
304
|
+
IStandardizedYield(SY).deposit{value: token == NATIVE ? netTokenIn : 0}(
|
|
305
|
+
address(this),
|
|
306
|
+
token,
|
|
307
|
+
netTokenIn,
|
|
308
|
+
0
|
|
309
|
+
);
|
|
292
310
|
}
|
|
293
311
|
|
|
294
|
-
function _redeemSy_transferToMakers(
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
312
|
+
function _redeemSy_transferToMakers(
|
|
313
|
+
address SY,
|
|
314
|
+
FillOrderParams[] memory params,
|
|
315
|
+
uint256[] memory netSyOuts
|
|
316
|
+
) internal returns (uint256[] memory toMakers) {
|
|
298
317
|
// netSyOuts all > 0, guarantee in LimitMath
|
|
299
318
|
|
|
300
319
|
uint256 len = params.length;
|
|
@@ -304,12 +323,12 @@ abstract contract PendleOrderMixin is
|
|
|
304
323
|
address sharedToken = params[l].order.token;
|
|
305
324
|
uint256 totalSy = 0;
|
|
306
325
|
|
|
307
|
-
for (; r < len && __stillShared(sharedToken, params[r].order.token); r
|
|
326
|
+
for (; r < len && __stillShared(sharedToken, params[r].order.token); r++) {
|
|
308
327
|
totalSy += netSyOuts[r];
|
|
309
328
|
}
|
|
310
329
|
|
|
311
330
|
if (sharedToken == SY) {
|
|
312
|
-
for (uint256 i = l; i < r; i
|
|
331
|
+
for (uint256 i = l; i < r; i++) {
|
|
313
332
|
_transferOut(SY, params[i].order.receiver, netSyOuts[i]);
|
|
314
333
|
toMakers[i] = netSyOuts[i];
|
|
315
334
|
}
|
|
@@ -320,7 +339,7 @@ abstract contract PendleOrderMixin is
|
|
|
320
339
|
toMakers[l] = __redeemSy_Single(params[l].order.receiver, SY, sharedToken, netSyOuts[l]);
|
|
321
340
|
} else {
|
|
322
341
|
uint256 totalToken = __redeemSy_Single(address(this), SY, sharedToken, totalSy);
|
|
323
|
-
for (uint256 i = l; i < r; i
|
|
342
|
+
for (uint256 i = l; i < r; i++) {
|
|
324
343
|
address token = params[i].order.token;
|
|
325
344
|
toMakers[i] = (netSyOuts[i] * totalToken) / totalSy;
|
|
326
345
|
if (sharedToken != token) {
|
|
@@ -334,14 +353,18 @@ abstract contract PendleOrderMixin is
|
|
|
334
353
|
}
|
|
335
354
|
|
|
336
355
|
function __stillShared(address currentShared, address nextToken) private view returns (bool) {
|
|
337
|
-
return
|
|
338
|
-
|
|
356
|
+
return
|
|
357
|
+
(currentShared == nextToken) ||
|
|
358
|
+
(currentShared == NATIVE && nextToken == WNATIVE) ||
|
|
359
|
+
(currentShared == WNATIVE && nextToken == NATIVE);
|
|
339
360
|
}
|
|
340
361
|
|
|
341
|
-
function __redeemSy_Single(
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
362
|
+
function __redeemSy_Single(
|
|
363
|
+
address receiver,
|
|
364
|
+
address SY,
|
|
365
|
+
address tokenOut,
|
|
366
|
+
uint256 netSyIn
|
|
367
|
+
) private returns (uint256 netTokenOut) {
|
|
345
368
|
if (tokenOut == NATIVE || tokenOut == WNATIVE) {
|
|
346
369
|
address otherToken = tokenOut == NATIVE ? WNATIVE : NATIVE;
|
|
347
370
|
address tokenRedeemSy = IStandardizedYield(SY).isValidTokenOut(tokenOut) ? tokenOut : otherToken;
|
|
@@ -360,36 +383,30 @@ abstract contract PendleOrderMixin is
|
|
|
360
383
|
}
|
|
361
384
|
}
|
|
362
385
|
|
|
363
|
-
function _inc1(uint256 i) internal pure returns (uint256) {
|
|
364
|
-
unchecked {
|
|
365
|
-
return i + 1;
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
|
|
369
386
|
// ! Allow self-fill of orders
|
|
370
|
-
function _transferFromMakers(
|
|
371
|
-
|
|
372
|
-
|
|
387
|
+
function _transferFromMakers(
|
|
388
|
+
IERC20 token,
|
|
389
|
+
FillOrderParams[] memory params,
|
|
390
|
+
address to,
|
|
391
|
+
uint256[] memory netIn
|
|
392
|
+
) internal {
|
|
373
393
|
uint256 len = params.length;
|
|
374
|
-
for (uint256 i = 0; i < len; i
|
|
394
|
+
for (uint256 i = 0; i < len; i++) {
|
|
375
395
|
if (params[i].order.maker == to) continue;
|
|
376
396
|
token.safeTransferFrom(params[i].order.maker, to, netIn[i]);
|
|
377
397
|
}
|
|
378
398
|
}
|
|
379
399
|
|
|
380
|
-
function _transferToMakers(
|
|
381
|
-
|
|
382
|
-
|
|
400
|
+
function _transferToMakers(
|
|
401
|
+
IERC20 token,
|
|
402
|
+
address payer,
|
|
403
|
+
FillOrderParams[] memory params,
|
|
404
|
+
uint256[] memory netOut
|
|
405
|
+
) internal {
|
|
383
406
|
uint256 len = params.length;
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
}
|
|
388
|
-
} else {
|
|
389
|
-
for (uint256 i = 0; i < len; i = _inc1(i)) {
|
|
390
|
-
if (payer == params[i].order.receiver) continue;
|
|
391
|
-
token.safeTransferFrom(payer, params[i].order.receiver, netOut[i]);
|
|
392
|
-
}
|
|
407
|
+
for (uint256 i = 0; i < len; i++) {
|
|
408
|
+
if (payer == params[i].order.receiver) continue;
|
|
409
|
+
token.safeTransferFrom(payer, params[i].order.receiver, netOut[i]);
|
|
393
410
|
}
|
|
394
411
|
}
|
|
395
412
|
|
|
@@ -415,7 +432,7 @@ abstract contract PendleOrderMixin is
|
|
|
415
432
|
uint256 len = YTs.length;
|
|
416
433
|
require(len == lnFeeRateRoots.length, "LOP: length mismatch");
|
|
417
434
|
|
|
418
|
-
for (uint256 i = 0; i < len; i
|
|
435
|
+
for (uint256 i = 0; i < len; i++) {
|
|
419
436
|
require(lnFeeRateRoots[i] > 0, "LOP: zero fee not allowed");
|
|
420
437
|
__lnFeeRateRoot[YTs[i]] = lnFeeRateRoots[i];
|
|
421
438
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
2
|
pragma solidity ^0.8.17;
|
|
3
3
|
|
|
4
|
-
import "./
|
|
4
|
+
import "./LimitRouterBase.sol";
|
|
5
5
|
import "../core/libraries/Errors.sol";
|
|
6
6
|
|
|
7
|
-
contract PendleLimitRouter is
|
|
7
|
+
contract PendleLimitRouter is LimitRouterBase {
|
|
8
8
|
using Address for address;
|
|
9
9
|
|
|
10
|
-
constructor(address _WNATIVE)
|
|
10
|
+
constructor(address _WNATIVE) LimitRouterBase(_WNATIVE) {
|
|
11
11
|
_disableInitializers();
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -29,11 +29,9 @@ contract PendleLimitRouter is PendleOrderMixin {
|
|
|
29
29
|
emit OrderCanceled(msg.sender, orderHash);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
function orderStatusesRaw(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
returns (uint256[] memory remainingsRaw, uint256[] memory filledAmounts)
|
|
36
|
-
{
|
|
32
|
+
function orderStatusesRaw(
|
|
33
|
+
bytes32[] memory orderHashes
|
|
34
|
+
) public view returns (uint256[] memory remainingsRaw, uint256[] memory filledAmounts) {
|
|
37
35
|
uint256 len = orderHashes.length;
|
|
38
36
|
remainingsRaw = new uint256[](len);
|
|
39
37
|
filledAmounts = new uint256[](len);
|
|
@@ -44,11 +42,9 @@ contract PendleLimitRouter is PendleOrderMixin {
|
|
|
44
42
|
}
|
|
45
43
|
}
|
|
46
44
|
|
|
47
|
-
function orderStatuses(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
returns (uint256[] memory remainings, uint256[] memory filledAmounts)
|
|
51
|
-
{
|
|
45
|
+
function orderStatuses(
|
|
46
|
+
bytes32[] memory orderHashes
|
|
47
|
+
) external view returns (uint256[] memory remainings, uint256[] memory filledAmounts) {
|
|
52
48
|
(remainings, filledAmounts) = orderStatusesRaw(orderHashes);
|
|
53
49
|
for (uint256 i = 0; i < remainings.length; i++) {
|
|
54
50
|
require(remainings[i] != _ORDER_DOES_NOT_EXIST, "LOP: Unknown order");
|