@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
|
@@ -18,7 +18,11 @@ library PendleLpOracleLib {
|
|
|
18
18
|
function getLpToAssetRate(IPMarket market, uint32 duration) internal view returns (uint256) {
|
|
19
19
|
(uint256 syIndex, uint256 pyIndex) = PendlePtOracleLib.getSYandPYIndexCurrent(market);
|
|
20
20
|
uint256 lpToAssetRateRaw = _getLpToAssetRateRaw(market, duration, pyIndex);
|
|
21
|
-
|
|
21
|
+
if (syIndex >= pyIndex) {
|
|
22
|
+
return lpToAssetRateRaw;
|
|
23
|
+
} else {
|
|
24
|
+
return (lpToAssetRateRaw * syIndex) / pyIndex;
|
|
25
|
+
}
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
function _getLpToAssetRateRaw(
|
|
@@ -28,20 +32,15 @@ library PendleLpOracleLib {
|
|
|
28
32
|
) private view returns (uint256 lpToAssetRateRaw) {
|
|
29
33
|
MarketState memory state = market.readState(address(0));
|
|
30
34
|
|
|
31
|
-
MarketPreCompute memory comp = state.getMarketPreCompute(
|
|
32
|
-
PYIndex.wrap(pyIndex),
|
|
33
|
-
block.timestamp
|
|
34
|
-
);
|
|
35
|
-
|
|
36
35
|
int256 totalHypotheticalAsset;
|
|
37
36
|
if (state.expiry <= block.timestamp) {
|
|
38
37
|
// 1 PT = 1 Asset post-expiry
|
|
39
|
-
totalHypotheticalAsset = state.totalPt +
|
|
38
|
+
totalHypotheticalAsset = state.totalPt + PYIndexLib.syToAsset(PYIndex.wrap(pyIndex), state.totalSy);
|
|
40
39
|
} else {
|
|
40
|
+
MarketPreCompute memory comp = state.getMarketPreCompute(PYIndex.wrap(pyIndex), block.timestamp);
|
|
41
|
+
|
|
41
42
|
(int256 rateOracle, int256 rateHypTrade) = _getPtRatesRaw(market, state, duration);
|
|
42
|
-
int256 cParam = LogExpMath.exp(
|
|
43
|
-
comp.rateScalar.mulDown((rateOracle - comp.rateAnchor))
|
|
44
|
-
);
|
|
43
|
+
int256 cParam = LogExpMath.exp(comp.rateScalar.mulDown((rateOracle - comp.rateAnchor)));
|
|
45
44
|
|
|
46
45
|
int256 tradeSize = (cParam.mulDown(comp.totalAsset) - state.totalPt).divDown(
|
|
47
46
|
PMath.IONE + cParam.divDown(rateHypTrade)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
-
pragma solidity 0.8.17;
|
|
2
|
+
pragma solidity ^0.8.17;
|
|
3
3
|
|
|
4
4
|
import "./PendlePtOracleLib.sol";
|
|
5
5
|
import "../interfaces/IPPtOracle.sol";
|
|
@@ -40,10 +40,7 @@ contract PendlePtOracle is BoringOwnableUpgradeable, IPPtOracle {
|
|
|
40
40
|
* @param market market to get rate from
|
|
41
41
|
* @param duration twap duration
|
|
42
42
|
*/
|
|
43
|
-
function getPtToAssetRate(
|
|
44
|
-
address market,
|
|
45
|
-
uint32 duration
|
|
46
|
-
) external view returns (uint256 ptToAssetRate) {
|
|
43
|
+
function getPtToAssetRate(address market, uint32 duration) external view returns (uint256 ptToAssetRate) {
|
|
47
44
|
ptToAssetRate = IPMarket(market).getPtToAssetRate(duration);
|
|
48
45
|
}
|
|
49
46
|
|
|
@@ -60,20 +57,10 @@ contract PendlePtOracle is BoringOwnableUpgradeable, IPPtOracle {
|
|
|
60
57
|
)
|
|
61
58
|
external
|
|
62
59
|
view
|
|
63
|
-
returns (
|
|
64
|
-
bool increaseCardinalityRequired,
|
|
65
|
-
uint16 cardinalityRequired,
|
|
66
|
-
bool oldestObservationSatisfied
|
|
67
|
-
)
|
|
60
|
+
returns (bool increaseCardinalityRequired, uint16 cardinalityRequired, bool oldestObservationSatisfied)
|
|
68
61
|
{
|
|
69
|
-
(
|
|
70
|
-
|
|
71
|
-
,
|
|
72
|
-
,
|
|
73
|
-
uint16 observationIndex,
|
|
74
|
-
uint16 observationCardinality,
|
|
75
|
-
uint16 cardinalityReserved
|
|
76
|
-
) = IPMarket(market)._storage();
|
|
62
|
+
(, , , uint16 observationIndex, uint16 observationCardinality, uint16 cardinalityReserved) = IPMarket(market)
|
|
63
|
+
._storage();
|
|
77
64
|
|
|
78
65
|
// checkIncreaseCardinalityRequired
|
|
79
66
|
cardinalityRequired = _calcCardinalityRequiredRequired(duration);
|
|
@@ -90,7 +77,9 @@ contract PendlePtOracle is BoringOwnableUpgradeable, IPPtOracle {
|
|
|
90
77
|
}
|
|
91
78
|
|
|
92
79
|
function _calcCardinalityRequiredRequired(uint32 duration) internal view returns (uint16) {
|
|
93
|
-
uint32 cardinalityRequired = (duration * BLOCK_CYCLE_DENOMINATOR) /
|
|
80
|
+
uint32 cardinalityRequired = (duration * BLOCK_CYCLE_DENOMINATOR + blockCycleNumerator - 1) /
|
|
81
|
+
blockCycleNumerator +
|
|
82
|
+
1;
|
|
94
83
|
if (cardinalityRequired > type(uint16).max) {
|
|
95
84
|
revert TwapDurationTooLarge(duration, cardinalityRequired);
|
|
96
85
|
}
|
|
@@ -16,7 +16,11 @@ library PendlePtOracleLib {
|
|
|
16
16
|
*/
|
|
17
17
|
function getPtToAssetRate(IPMarket market, uint32 duration) internal view returns (uint256) {
|
|
18
18
|
(uint256 syIndex, uint256 pyIndex) = getSYandPYIndexCurrent(market);
|
|
19
|
-
|
|
19
|
+
if (syIndex >= pyIndex) {
|
|
20
|
+
return getPtToAssetRateRaw(market, duration);
|
|
21
|
+
} else {
|
|
22
|
+
return (getPtToAssetRateRaw(market, duration) * syIndex) / pyIndex;
|
|
23
|
+
}
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
function getPtToAssetRateRaw(IPMarket market, uint32 duration) internal view returns (uint256) {
|
|
@@ -27,17 +31,12 @@ library PendlePtOracleLib {
|
|
|
27
31
|
} else {
|
|
28
32
|
uint256 lnImpliedRate = _getMarketLnImpliedRate(market, duration);
|
|
29
33
|
uint256 timeToExpiry = expiry - block.timestamp;
|
|
30
|
-
uint256 assetToPtRate =
|
|
31
|
-
MarketMathCore._getExchangeRateFromImpliedRate(lnImpliedRate, timeToExpiry).Uint();
|
|
34
|
+
uint256 assetToPtRate = MarketMathCore._getExchangeRateFromImpliedRate(lnImpliedRate, timeToExpiry).Uint();
|
|
32
35
|
return PMath.ONE.divDown(assetToPtRate);
|
|
33
36
|
}
|
|
34
37
|
}
|
|
35
38
|
|
|
36
|
-
function getSYandPYIndexCurrent(IPMarket market)
|
|
37
|
-
internal
|
|
38
|
-
view
|
|
39
|
-
returns (uint256 syIndex, uint256 pyIndex)
|
|
40
|
-
{
|
|
39
|
+
function getSYandPYIndexCurrent(IPMarket market) internal view returns (uint256 syIndex, uint256 pyIndex) {
|
|
41
40
|
(IStandardizedYield SY, , IPYieldToken YT) = market.readTokens();
|
|
42
41
|
|
|
43
42
|
syIndex = SY.exchangeRate();
|
|
@@ -50,11 +49,7 @@ library PendlePtOracleLib {
|
|
|
50
49
|
}
|
|
51
50
|
}
|
|
52
51
|
|
|
53
|
-
function _getMarketLnImpliedRate(IPMarket market, uint32 duration)
|
|
54
|
-
private
|
|
55
|
-
view
|
|
56
|
-
returns (uint256)
|
|
57
|
-
{
|
|
52
|
+
function _getMarketLnImpliedRate(IPMarket market, uint32 duration) private view returns (uint256) {
|
|
58
53
|
uint32[] memory durations = new uint32[](2);
|
|
59
54
|
durations[0] = duration;
|
|
60
55
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
-
pragma solidity 0.8.17;
|
|
2
|
+
pragma solidity ^0.8.17;
|
|
3
3
|
|
|
4
4
|
import "../PendleLpOracleLib.sol";
|
|
5
5
|
import "../../interfaces/IPPtOracle.sol";
|
|
@@ -18,19 +18,15 @@ contract PendleLpGlpOracle {
|
|
|
18
18
|
address public immutable glpManager;
|
|
19
19
|
error OracleNotReady(bool increaseCardinalityRequired, bool oldestObservationSatisfied);
|
|
20
20
|
|
|
21
|
-
constructor(
|
|
22
|
-
address _ptOracle,
|
|
23
|
-
uint32 _twapDuration,
|
|
24
|
-
address _market,
|
|
25
|
-
address _glpManager
|
|
26
|
-
) {
|
|
21
|
+
constructor(address _ptOracle, uint32 _twapDuration, address _market, address _glpManager) {
|
|
27
22
|
twapDuration = _twapDuration;
|
|
28
23
|
market = _market;
|
|
29
24
|
glpManager = _glpManager;
|
|
30
25
|
|
|
31
|
-
(bool increaseCardinalityRequired, , bool oldestObservationSatisfied) = IPPtOracle(
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
(bool increaseCardinalityRequired, , bool oldestObservationSatisfied) = IPPtOracle(_ptOracle).getOracleState(
|
|
27
|
+
market,
|
|
28
|
+
twapDuration
|
|
29
|
+
);
|
|
34
30
|
|
|
35
31
|
if (increaseCardinalityRequired || !oldestObservationSatisfied) {
|
|
36
32
|
revert OracleNotReady(increaseCardinalityRequired, oldestObservationSatisfied);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
-
pragma solidity 0.8.17;
|
|
2
|
+
pragma solidity ^0.8.17;
|
|
3
3
|
|
|
4
4
|
import "../PendlePtOracleLib.sol";
|
|
5
5
|
import "../../interfaces/IPPtOracle.sol";
|
|
@@ -21,19 +21,15 @@ contract PendlePtGlpOracle {
|
|
|
21
21
|
address public immutable glpManager;
|
|
22
22
|
error OracleNotReady(bool increaseCardinalityRequired, bool oldestObservationSatisfied);
|
|
23
23
|
|
|
24
|
-
constructor(
|
|
25
|
-
address _ptOracle,
|
|
26
|
-
uint32 _twapDuration,
|
|
27
|
-
address _market,
|
|
28
|
-
address _glpManager
|
|
29
|
-
) {
|
|
24
|
+
constructor(address _ptOracle, uint32 _twapDuration, address _market, address _glpManager) {
|
|
30
25
|
twapDuration = _twapDuration;
|
|
31
26
|
market = _market;
|
|
32
27
|
glpManager = _glpManager;
|
|
33
28
|
|
|
34
|
-
(bool increaseCardinalityRequired, , bool oldestObservationSatisfied) = IPPtOracle(
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
(bool increaseCardinalityRequired, , bool oldestObservationSatisfied) = IPPtOracle(_ptOracle).getOracleState(
|
|
30
|
+
market,
|
|
31
|
+
twapDuration
|
|
32
|
+
);
|
|
37
33
|
|
|
38
34
|
if (increaseCardinalityRequired || !oldestObservationSatisfied) {
|
|
39
35
|
revert OracleNotReady(increaseCardinalityRequired, oldestObservationSatisfied);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
-
pragma solidity 0.8.17;
|
|
2
|
+
pragma solidity ^0.8.17;
|
|
3
3
|
|
|
4
4
|
import "../../interfaces/IPPtOracle.sol";
|
|
5
5
|
import "../../core/libraries/math/PMath.sol";
|
|
6
|
-
import {
|
|
6
|
+
import {AggregatorV2V3Interface as IChainlinkAggregator} from "@chainlink/contracts/src/v0.8/interfaces/AggregatorV2V3Interface.sol";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @notice The returned price from this contract is multiply with the default USD price of asset
|
|
@@ -20,21 +20,17 @@ contract PendlePtUsdChainlinkOracle {
|
|
|
20
20
|
|
|
21
21
|
error OracleNotReady(bool increaseCardinalityRequired, bool oldestObservationSatisfied);
|
|
22
22
|
|
|
23
|
-
constructor(
|
|
24
|
-
address _ptOracle,
|
|
25
|
-
uint32 _twapDuration,
|
|
26
|
-
address _market,
|
|
27
|
-
address _feed
|
|
28
|
-
) {
|
|
23
|
+
constructor(address _ptOracle, uint32 _twapDuration, address _market, address _feed) {
|
|
29
24
|
ptOracle = _ptOracle;
|
|
30
25
|
twapDuration = _twapDuration;
|
|
31
26
|
market = _market;
|
|
32
27
|
feed = _feed;
|
|
33
28
|
feedDecimals = IChainlinkAggregator(feed).decimals();
|
|
34
29
|
|
|
35
|
-
(bool increaseCardinalityRequired, , bool oldestObservationSatisfied) = IPPtOracle(
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
(bool increaseCardinalityRequired, , bool oldestObservationSatisfied) = IPPtOracle(_ptOracle).getOracleState(
|
|
31
|
+
market,
|
|
32
|
+
twapDuration
|
|
33
|
+
);
|
|
38
34
|
|
|
39
35
|
if (increaseCardinalityRequired || !oldestObservationSatisfied) {
|
|
40
36
|
revert OracleNotReady(increaseCardinalityRequired, oldestObservationSatisfied);
|
|
@@ -49,10 +45,7 @@ contract PendlePtUsdChainlinkOracle {
|
|
|
49
45
|
|
|
50
46
|
function _getUnderlyingAssetPrice() internal view virtual returns (uint256) {
|
|
51
47
|
uint256 rawPrice = uint256(IChainlinkAggregator(feed).latestAnswer());
|
|
52
|
-
return
|
|
53
|
-
feedDecimals < 18
|
|
54
|
-
? rawPrice * 10**(18 - feedDecimals)
|
|
55
|
-
: rawPrice / 10**(feedDecimals - 18);
|
|
48
|
+
return feedDecimals < 18 ? rawPrice * 10 ** (18 - feedDecimals) : rawPrice / 10 ** (feedDecimals - 18);
|
|
56
49
|
}
|
|
57
50
|
|
|
58
51
|
function decimals() external pure virtual returns (uint8) {
|
|
@@ -21,12 +21,12 @@ contract ActionAddRemoveLiqV3 is IPActionAddRemoveLiqV3, ActionBase {
|
|
|
21
21
|
uint256 netPtDesired,
|
|
22
22
|
uint256 minLpOut
|
|
23
23
|
) external payable returns (uint256 netLpOut, uint256 netPtUsed, uint256 netSyInterm) {
|
|
24
|
-
(IStandardizedYield SY, IPPrincipalToken PT,) = IPMarket(market).readTokens();
|
|
24
|
+
(IStandardizedYield SY, IPPrincipalToken PT, ) = IPMarket(market).readTokens();
|
|
25
25
|
|
|
26
26
|
netSyInterm = _mintSyFromToken(market, address(SY), 1, input);
|
|
27
27
|
uint256 netSyUsed;
|
|
28
28
|
|
|
29
|
-
(
|
|
29
|
+
(, , netSyUsed, netPtUsed) = _readMarket(market).addLiquidity(netSyInterm, netPtDesired, block.timestamp);
|
|
30
30
|
|
|
31
31
|
if (netSyInterm != netSyUsed) {
|
|
32
32
|
revert Errors.RouterNotAllSyUsed(netSyInterm, netSyUsed);
|
|
@@ -34,12 +34,19 @@ contract ActionAddRemoveLiqV3 is IPActionAddRemoveLiqV3, ActionBase {
|
|
|
34
34
|
|
|
35
35
|
// SY has been minted and transferred to the market
|
|
36
36
|
_transferFrom(PT, msg.sender, market, netPtUsed);
|
|
37
|
-
(netLpOut
|
|
37
|
+
(netLpOut, , ) = IPMarket(market).mint(receiver, netSyUsed, netPtUsed);
|
|
38
38
|
|
|
39
39
|
if (netLpOut < minLpOut) revert Errors.RouterInsufficientLpOut(netLpOut, minLpOut);
|
|
40
40
|
|
|
41
41
|
emit AddLiquidityDualTokenAndPt(
|
|
42
|
-
msg.sender,
|
|
42
|
+
msg.sender,
|
|
43
|
+
market,
|
|
44
|
+
input.tokenIn,
|
|
45
|
+
receiver,
|
|
46
|
+
input.netTokenIn,
|
|
47
|
+
netPtUsed,
|
|
48
|
+
netLpOut,
|
|
49
|
+
netSyInterm
|
|
43
50
|
);
|
|
44
51
|
}
|
|
45
52
|
|
|
@@ -50,15 +57,18 @@ contract ActionAddRemoveLiqV3 is IPActionAddRemoveLiqV3, ActionBase {
|
|
|
50
57
|
uint256 netPtDesired,
|
|
51
58
|
uint256 minLpOut
|
|
52
59
|
) external returns (uint256 netLpOut, uint256 netSyUsed, uint256 netPtUsed) {
|
|
53
|
-
(IStandardizedYield SY, IPPrincipalToken PT,) = IPMarket(market).readTokens();
|
|
60
|
+
(IStandardizedYield SY, IPPrincipalToken PT, ) = IPMarket(market).readTokens();
|
|
54
61
|
|
|
55
62
|
// calculate the amount of SY and PT to be used
|
|
56
|
-
(, netLpOut, netSyUsed, netPtUsed) =
|
|
57
|
-
|
|
63
|
+
(, netLpOut, netSyUsed, netPtUsed) = _readMarket(market).addLiquidity(
|
|
64
|
+
netSyDesired,
|
|
65
|
+
netPtDesired,
|
|
66
|
+
block.timestamp
|
|
67
|
+
);
|
|
58
68
|
|
|
59
69
|
_transferFrom(SY, msg.sender, market, netSyUsed);
|
|
60
70
|
_transferFrom(PT, msg.sender, market, netPtUsed);
|
|
61
|
-
(netLpOut
|
|
71
|
+
(netLpOut, , ) = IPMarket(market).mint(receiver, netSyUsed, netPtUsed);
|
|
62
72
|
|
|
63
73
|
if (netLpOut < minLpOut) revert Errors.RouterInsufficientLpOut(netLpOut, minLpOut);
|
|
64
74
|
|
|
@@ -82,24 +92,31 @@ contract ActionAddRemoveLiqV3 is IPActionAddRemoveLiqV3, ActionBase {
|
|
|
82
92
|
uint256 netSyReceived;
|
|
83
93
|
|
|
84
94
|
if (!_isEmptyLimit(limit)) {
|
|
85
|
-
(netPtLeft, netSyReceived, netSyFee,) = _fillLimit(market, PT, netPtLeft, limit);
|
|
95
|
+
(netPtLeft, netSyReceived, netSyFee, ) = _fillLimit(market, PT, netPtLeft, limit);
|
|
86
96
|
_transferOut(address(PT), market, netPtLeft);
|
|
87
97
|
}
|
|
88
98
|
|
|
89
|
-
(uint256 netPtSwapMarket
|
|
90
|
-
YT.newIndex(),
|
|
99
|
+
(uint256 netPtSwapMarket, , ) = _readMarket(market).approxSwapPtToAddLiquidity(
|
|
100
|
+
YT.newIndex(),
|
|
101
|
+
netPtLeft,
|
|
102
|
+
netSyReceived,
|
|
103
|
+
block.timestamp,
|
|
104
|
+
guessPtSwapToSy
|
|
91
105
|
);
|
|
92
106
|
|
|
93
107
|
// execute the swap
|
|
94
|
-
(uint256 netSyOutMarket, uint256 netSyFeeMarket) =
|
|
95
|
-
|
|
108
|
+
(uint256 netSyOutMarket, uint256 netSyFeeMarket) = IPMarket(market).swapExactPtForSy(
|
|
109
|
+
market,
|
|
110
|
+
netPtSwapMarket,
|
|
111
|
+
EMPTY_BYTES
|
|
112
|
+
);
|
|
96
113
|
|
|
97
114
|
netPtLeft -= netPtSwapMarket;
|
|
98
115
|
netSyReceived += netSyOutMarket;
|
|
99
116
|
netSyFee += netSyFeeMarket;
|
|
100
117
|
|
|
101
118
|
// execute the addLiquidity
|
|
102
|
-
(netLpOut
|
|
119
|
+
(netLpOut, , ) = IPMarket(market).mint(receiver, netSyReceived, netPtLeft);
|
|
103
120
|
|
|
104
121
|
if (netLpOut < minLpOut) revert Errors.RouterInsufficientLpOut(netLpOut, minLpOut);
|
|
105
122
|
|
|
@@ -120,15 +137,29 @@ contract ActionAddRemoveLiqV3 is IPActionAddRemoveLiqV3, ActionBase {
|
|
|
120
137
|
TokenInput calldata input,
|
|
121
138
|
LimitOrderData calldata limit
|
|
122
139
|
) external payable returns (uint256 netLpOut, uint256 netSyFee, uint256 netSyInterm) {
|
|
123
|
-
(IStandardizedYield SY
|
|
140
|
+
(IStandardizedYield SY, , IPYieldToken YT) = IPMarket(market).readTokens();
|
|
124
141
|
|
|
125
142
|
netSyInterm = _mintSyFromToken(_entry_addLiquiditySingleSy(market, limit), address(SY), 1, input);
|
|
126
143
|
|
|
127
|
-
(netLpOut, netSyFee) =
|
|
128
|
-
|
|
144
|
+
(netLpOut, netSyFee) = _addLiquiditySingleSy(
|
|
145
|
+
receiver,
|
|
146
|
+
market,
|
|
147
|
+
SY,
|
|
148
|
+
YT,
|
|
149
|
+
netSyInterm,
|
|
150
|
+
minLpOut,
|
|
151
|
+
guessPtReceivedFromSy,
|
|
152
|
+
limit
|
|
153
|
+
);
|
|
129
154
|
|
|
130
155
|
emit AddLiquiditySingleToken(
|
|
131
|
-
msg.sender,
|
|
156
|
+
msg.sender,
|
|
157
|
+
market,
|
|
158
|
+
input.tokenIn,
|
|
159
|
+
receiver,
|
|
160
|
+
input.netTokenIn,
|
|
161
|
+
netLpOut,
|
|
162
|
+
netSyInterm
|
|
132
163
|
);
|
|
133
164
|
}
|
|
134
165
|
|
|
@@ -140,12 +171,20 @@ contract ActionAddRemoveLiqV3 is IPActionAddRemoveLiqV3, ActionBase {
|
|
|
140
171
|
ApproxParams calldata guessPtReceivedFromSy,
|
|
141
172
|
LimitOrderData calldata limit
|
|
142
173
|
) external returns (uint256 netLpOut, uint256 netSyFee) {
|
|
143
|
-
(IStandardizedYield SY
|
|
174
|
+
(IStandardizedYield SY, , IPYieldToken YT) = IPMarket(market).readTokens();
|
|
144
175
|
|
|
145
176
|
_transferFrom(SY, msg.sender, _entry_addLiquiditySingleSy(market, limit), netSyIn);
|
|
146
177
|
|
|
147
|
-
(netLpOut, netSyFee) =
|
|
148
|
-
|
|
178
|
+
(netLpOut, netSyFee) = _addLiquiditySingleSy(
|
|
179
|
+
receiver,
|
|
180
|
+
market,
|
|
181
|
+
SY,
|
|
182
|
+
YT,
|
|
183
|
+
netSyIn,
|
|
184
|
+
minLpOut,
|
|
185
|
+
guessPtReceivedFromSy,
|
|
186
|
+
limit
|
|
187
|
+
);
|
|
149
188
|
|
|
150
189
|
emit AddLiquiditySingleSy(msg.sender, market, receiver, netSyIn, netLpOut);
|
|
151
190
|
}
|
|
@@ -168,22 +207,29 @@ contract ActionAddRemoveLiqV3 is IPActionAddRemoveLiqV3, ActionBase {
|
|
|
168
207
|
uint256 netPtReceived;
|
|
169
208
|
|
|
170
209
|
if (!_isEmptyLimit(limit)) {
|
|
171
|
-
(netSyLeft, netPtReceived, netSyFee,) = _fillLimit(market, SY, netSyLeft, limit);
|
|
210
|
+
(netSyLeft, netPtReceived, netSyFee, ) = _fillLimit(market, SY, netSyLeft, limit);
|
|
172
211
|
_transferOut(address(SY), market, netSyLeft);
|
|
173
212
|
}
|
|
174
213
|
|
|
175
|
-
(uint256 netPtOutMarket
|
|
176
|
-
YT.newIndex(),
|
|
214
|
+
(uint256 netPtOutMarket, , ) = _readMarket(market).approxSwapSyToAddLiquidity(
|
|
215
|
+
YT.newIndex(),
|
|
216
|
+
netSyLeft,
|
|
217
|
+
netPtReceived,
|
|
218
|
+
block.timestamp,
|
|
219
|
+
guessPtReceivedFromSy
|
|
177
220
|
);
|
|
178
221
|
|
|
179
|
-
(uint256 netSySwapMarket, uint256 netSyFeeMarket) =
|
|
180
|
-
|
|
222
|
+
(uint256 netSySwapMarket, uint256 netSyFeeMarket) = IPMarket(market).swapSyForExactPt(
|
|
223
|
+
market,
|
|
224
|
+
netPtOutMarket,
|
|
225
|
+
EMPTY_BYTES
|
|
226
|
+
);
|
|
181
227
|
|
|
182
228
|
netSyLeft -= netSySwapMarket;
|
|
183
229
|
netPtReceived += netPtOutMarket;
|
|
184
230
|
netSyFee += netSyFeeMarket;
|
|
185
231
|
|
|
186
|
-
(netLpOut
|
|
232
|
+
(netLpOut, , ) = IPMarket(market).mint(receiver, netSyLeft, netPtReceived);
|
|
187
233
|
|
|
188
234
|
if (netLpOut < minLpOut) revert Errors.RouterInsufficientLpOut(netLpOut, minLpOut);
|
|
189
235
|
}
|
|
@@ -197,15 +243,30 @@ contract ActionAddRemoveLiqV3 is IPActionAddRemoveLiqV3, ActionBase {
|
|
|
197
243
|
uint256 minYtOut,
|
|
198
244
|
TokenInput calldata input
|
|
199
245
|
) external payable returns (uint256 netLpOut, uint256 netYtOut, uint256 netSyMintPy, uint256 netSyInterm) {
|
|
200
|
-
(IStandardizedYield SY
|
|
246
|
+
(IStandardizedYield SY, , IPYieldToken YT) = IPMarket(market).readTokens();
|
|
201
247
|
|
|
202
248
|
netSyInterm = _mintSyFromToken(address(this), address(SY), 1, input);
|
|
203
249
|
|
|
204
|
-
(netLpOut, netYtOut, netSyMintPy) =
|
|
205
|
-
|
|
250
|
+
(netLpOut, netYtOut, netSyMintPy) = _addLiquiditySingleSyKeepYt(
|
|
251
|
+
receiver,
|
|
252
|
+
market,
|
|
253
|
+
SY,
|
|
254
|
+
YT,
|
|
255
|
+
netSyInterm,
|
|
256
|
+
minLpOut,
|
|
257
|
+
minYtOut
|
|
258
|
+
);
|
|
206
259
|
|
|
207
260
|
emit AddLiquiditySingleTokenKeepYt(
|
|
208
|
-
msg.sender,
|
|
261
|
+
msg.sender,
|
|
262
|
+
market,
|
|
263
|
+
input.tokenIn,
|
|
264
|
+
receiver,
|
|
265
|
+
input.netTokenIn,
|
|
266
|
+
netLpOut,
|
|
267
|
+
netYtOut,
|
|
268
|
+
netSyMintPy,
|
|
269
|
+
netSyInterm
|
|
209
270
|
);
|
|
210
271
|
}
|
|
211
272
|
|
|
@@ -216,12 +277,19 @@ contract ActionAddRemoveLiqV3 is IPActionAddRemoveLiqV3, ActionBase {
|
|
|
216
277
|
uint256 minLpOut,
|
|
217
278
|
uint256 minYtOut
|
|
218
279
|
) external returns (uint256 netLpOut, uint256 netYtOut, uint256 netSyMintPy) {
|
|
219
|
-
(IStandardizedYield SY
|
|
280
|
+
(IStandardizedYield SY, , IPYieldToken YT) = IPMarket(market).readTokens();
|
|
220
281
|
|
|
221
282
|
_transferIn(address(SY), msg.sender, netSyIn);
|
|
222
283
|
|
|
223
|
-
(netLpOut, netYtOut, netSyMintPy) =
|
|
224
|
-
|
|
284
|
+
(netLpOut, netYtOut, netSyMintPy) = _addLiquiditySingleSyKeepYt(
|
|
285
|
+
receiver,
|
|
286
|
+
market,
|
|
287
|
+
SY,
|
|
288
|
+
YT,
|
|
289
|
+
netSyIn,
|
|
290
|
+
minLpOut,
|
|
291
|
+
minYtOut
|
|
292
|
+
);
|
|
225
293
|
|
|
226
294
|
emit AddLiquiditySingleSyKeepYt(msg.sender, market, receiver, netSyIn, netSyMintPy, netLpOut, netYtOut);
|
|
227
295
|
}
|
|
@@ -240,7 +308,8 @@ contract ActionAddRemoveLiqV3 is IPActionAddRemoveLiqV3, ActionBase {
|
|
|
240
308
|
PYIndex pyIndex = YT.newIndex();
|
|
241
309
|
|
|
242
310
|
netSyMintPy =
|
|
243
|
-
(netSyIn * state.totalPt.Uint()) /
|
|
311
|
+
(netSyIn * state.totalPt.Uint()) /
|
|
312
|
+
(state.totalPt.Uint() + pyIndex.syToAsset(state.totalSy.Uint()));
|
|
244
313
|
|
|
245
314
|
uint256 netSyAddLiquidity = netSyIn - netSyMintPy;
|
|
246
315
|
|
|
@@ -253,7 +322,7 @@ contract ActionAddRemoveLiqV3 is IPActionAddRemoveLiqV3, ActionBase {
|
|
|
253
322
|
// PT goes to market, YT goes to receiver
|
|
254
323
|
netYtOut = YT.mintPY(market, receiver);
|
|
255
324
|
|
|
256
|
-
(netLpOut
|
|
325
|
+
(netLpOut, , ) = IPMarket(market).mint(receiver, netSyAddLiquidity, netYtOut);
|
|
257
326
|
|
|
258
327
|
if (netLpOut < minLpOut) revert Errors.RouterInsufficientLpOut(netLpOut, minLpOut);
|
|
259
328
|
if (netYtOut < minYtOut) revert Errors.RouterInsufficientYtOut(netYtOut, minYtOut);
|
|
@@ -268,7 +337,7 @@ contract ActionAddRemoveLiqV3 is IPActionAddRemoveLiqV3, ActionBase {
|
|
|
268
337
|
TokenOutput calldata output,
|
|
269
338
|
uint256 minPtOut
|
|
270
339
|
) external returns (uint256 netTokenOut, uint256 netPtOut, uint256 netSyInterm) {
|
|
271
|
-
(IStandardizedYield SY
|
|
340
|
+
(IStandardizedYield SY, , ) = IPMarket(market).readTokens();
|
|
272
341
|
|
|
273
342
|
// burn LP, SY sent to SY, PT sent to receiver
|
|
274
343
|
_transferFrom(IERC20(market), msg.sender, market, netLpToRemove);
|
|
@@ -279,7 +348,14 @@ contract ActionAddRemoveLiqV3 is IPActionAddRemoveLiqV3, ActionBase {
|
|
|
279
348
|
// redeem SY to token
|
|
280
349
|
netTokenOut = _redeemSyToToken(receiver, address(SY), netSyInterm, output, false);
|
|
281
350
|
emit RemoveLiquidityDualTokenAndPt(
|
|
282
|
-
msg.sender,
|
|
351
|
+
msg.sender,
|
|
352
|
+
market,
|
|
353
|
+
output.tokenOut,
|
|
354
|
+
receiver,
|
|
355
|
+
netLpToRemove,
|
|
356
|
+
netPtOut,
|
|
357
|
+
netTokenOut,
|
|
358
|
+
netSyInterm
|
|
283
359
|
);
|
|
284
360
|
}
|
|
285
361
|
|
|
@@ -313,13 +389,22 @@ contract ActionAddRemoveLiqV3 is IPActionAddRemoveLiqV3, ActionBase {
|
|
|
313
389
|
|
|
314
390
|
// execute the burn
|
|
315
391
|
_transferFrom(IERC20(market), msg.sender, market, netLpToRemove);
|
|
316
|
-
(uint256 netSyOutBurn, uint256 netPtOutBurn) =
|
|
317
|
-
|
|
392
|
+
(uint256 netSyOutBurn, uint256 netPtOutBurn) = IPMarket(market).burn(
|
|
393
|
+
_entry_swapExactSyForPt(market, limit),
|
|
394
|
+
receiver,
|
|
395
|
+
netLpToRemove
|
|
396
|
+
);
|
|
318
397
|
netSyLeft += netSyOutBurn;
|
|
319
398
|
netPtOut += netPtOutBurn;
|
|
320
399
|
|
|
321
|
-
(uint256 netPtOutSwap, uint256 netSyFeeSwap) =
|
|
322
|
-
|
|
400
|
+
(uint256 netPtOutSwap, uint256 netSyFeeSwap) = _swapExactSyForPt(
|
|
401
|
+
receiver,
|
|
402
|
+
market,
|
|
403
|
+
netSyLeft,
|
|
404
|
+
0,
|
|
405
|
+
guessPtReceivedFromSy,
|
|
406
|
+
limit
|
|
407
|
+
);
|
|
323
408
|
netPtOut += netPtOutSwap;
|
|
324
409
|
netSyFee += netSyFeeSwap;
|
|
325
410
|
|
|
@@ -337,7 +422,7 @@ contract ActionAddRemoveLiqV3 is IPActionAddRemoveLiqV3, ActionBase {
|
|
|
337
422
|
TokenOutput calldata output,
|
|
338
423
|
LimitOrderData calldata limit
|
|
339
424
|
) external returns (uint256 netTokenOut, uint256 netSyFee, uint256 netSyInterm) {
|
|
340
|
-
(IStandardizedYield SY
|
|
425
|
+
(IStandardizedYield SY, , ) = IPMarket(market).readTokens();
|
|
341
426
|
|
|
342
427
|
_transferFrom(IERC20(market), msg.sender, market, netLpToRemove);
|
|
343
428
|
|
|
@@ -346,7 +431,13 @@ contract ActionAddRemoveLiqV3 is IPActionAddRemoveLiqV3, ActionBase {
|
|
|
346
431
|
netTokenOut = _redeemSyToToken(receiver, address(SY), netSyInterm, output, false);
|
|
347
432
|
|
|
348
433
|
emit RemoveLiquiditySingleToken(
|
|
349
|
-
msg.sender,
|
|
434
|
+
msg.sender,
|
|
435
|
+
market,
|
|
436
|
+
output.tokenOut,
|
|
437
|
+
receiver,
|
|
438
|
+
netLpToRemove,
|
|
439
|
+
netTokenOut,
|
|
440
|
+
netSyInterm
|
|
350
441
|
);
|
|
351
442
|
}
|
|
352
443
|
|
|
@@ -380,12 +471,13 @@ contract ActionAddRemoveLiqV3 is IPActionAddRemoveLiqV3, ActionBase {
|
|
|
380
471
|
if (netSyOut < minSyOut) revert Errors.RouterInsufficientSyOut(netSyOut, minSyOut);
|
|
381
472
|
}
|
|
382
473
|
|
|
383
|
-
function __removeLpToSyAfterExpiry(
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
(
|
|
474
|
+
function __removeLpToSyAfterExpiry(
|
|
475
|
+
address receiver,
|
|
476
|
+
address market,
|
|
477
|
+
uint256 netLpToRemove
|
|
478
|
+
) internal returns (uint256 netSyOut) {
|
|
479
|
+
(, , IPYieldToken YT) = IPMarket(market).readTokens();
|
|
480
|
+
(uint256 syFromBurn, ) = IPMarket(market).burn(receiver, address(YT), netLpToRemove);
|
|
389
481
|
netSyOut = syFromBurn + YT.redeemPY(receiver);
|
|
390
482
|
}
|
|
391
483
|
|
|
@@ -397,8 +489,11 @@ contract ActionAddRemoveLiqV3 is IPActionAddRemoveLiqV3, ActionBase {
|
|
|
397
489
|
) internal returns (uint256 netSyOut, uint256 netSyFee) {
|
|
398
490
|
uint256 netPtLeft;
|
|
399
491
|
|
|
400
|
-
(uint256 netSyOutBurn, uint256 netPtOutBurn) =
|
|
401
|
-
|
|
492
|
+
(uint256 netSyOutBurn, uint256 netPtOutBurn) = IPMarket(market).burn(
|
|
493
|
+
receiver,
|
|
494
|
+
_entry_swapExactPtForSy(market, limit),
|
|
495
|
+
netLpToRemove
|
|
496
|
+
);
|
|
402
497
|
netSyOut += netSyOutBurn;
|
|
403
498
|
netPtLeft += netPtOutBurn;
|
|
404
499
|
|
|
@@ -7,7 +7,7 @@ import "./base/CallbackHelper.sol";
|
|
|
7
7
|
|
|
8
8
|
import "../core/libraries/TokenHelper.sol";
|
|
9
9
|
|
|
10
|
-
contract ActionCallbackV3 is
|
|
10
|
+
contract ActionCallbackV3 is IPLimitOrderType, IPActionCallbackV3, CallbackHelper, TokenHelper {
|
|
11
11
|
using PMath for int256;
|
|
12
12
|
using PMath for uint256;
|
|
13
13
|
using PYIndexLib for PYIndex;
|
|
@@ -28,14 +28,21 @@ contract ActionCallbackV3 is IPOrderMixinType, IPActionCallbackV3, CallbackHelpe
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
function
|
|
31
|
+
function limitRouterCallback(
|
|
32
|
+
uint256 actualMaking,
|
|
33
|
+
uint256 actualTaking,
|
|
34
|
+
uint256,
|
|
35
|
+
/*totalFee*/ bytes memory data
|
|
36
|
+
)
|
|
32
37
|
external
|
|
33
38
|
returns (
|
|
34
39
|
bytes memory // encode as netTransferToLimit, netOutputFromLimit
|
|
35
40
|
)
|
|
36
41
|
{
|
|
37
|
-
(OrderType orderType, IPYieldToken YT, uint256 netRemaining, address receiver) =
|
|
38
|
-
|
|
42
|
+
(OrderType orderType, IPYieldToken YT, uint256 netRemaining, address receiver) = abi.decode(
|
|
43
|
+
data,
|
|
44
|
+
(OrderType, IPYieldToken, uint256, address)
|
|
45
|
+
);
|
|
39
46
|
|
|
40
47
|
if (orderType == OrderType.SY_FOR_PT || orderType == OrderType.SY_FOR_YT) {
|
|
41
48
|
PYIndex index = YT.newIndex();
|