@pendle/core-v2 0.16.5-testnet → 0.17.0-daily
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/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol/PendleMsgReceiveEndpointUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol/PendleMsgReceiveEndpointUpg.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiverAppUpg.sol/PendleMsgReceiverAppUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol/PendleMsgSendEndpointUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol/PendleMsgSendEndpointUpg.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSenderAppUpg.sol/PendleMsgSenderAppUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/FeeDistributor/EpochResultManager.sol/EpochResultManager.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributorFactory.sol/PendleFeeDistributorFactory.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributorFactory.sol/PendleFeeDistributorFactory.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol/PendleGaugeControllerBaseUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/VotingController/VotingControllerStorageUpg.sol/VotingControllerStorageUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.json +16 -5
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol/VotingEscrowTokenBase.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol/VotingEscrowTokenBase.json +0 -13
- package/build/artifacts/contracts/LiquidityMining/libraries/VeBalanceLib.sol/VeBalanceLib.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/libraries/VeBalanceLib.sol/VeBalanceLib.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/CheckpointHelper.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/CheckpointHelper.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/Checkpoints.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/Checkpoints.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/libraries/WeekMath.sol/WeekMath.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/libraries/WeekMath.sol/WeekMath.json +2 -2
- package/build/artifacts/contracts/core/BulkSeller/BulkSeller.sol/BulkSeller.dbg.json +1 -1
- package/build/artifacts/contracts/core/BulkSeller/BulkSeller.sol/BulkSeller.json +7 -54
- package/build/artifacts/contracts/core/BulkSeller/BulkSellerFactory.sol/BulkSellerFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/BulkSeller/BulkSellerFactory.sol/BulkSellerFactory.json +27 -2
- package/build/artifacts/contracts/core/BulkSeller/BulkSellerMathCore.sol/BulkSellerMathCore.dbg.json +1 -1
- package/build/artifacts/contracts/core/BulkSeller/BulkSellerMathCore.sol/BulkSellerMathCore.json +2 -2
- package/build/artifacts/contracts/core/Market/MarketMathCore.sol/MarketMathCore.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/MarketMathCore.sol/MarketMathCore.json +2 -2
- package/build/artifacts/contracts/core/Market/OracleLib.sol/OracleLib.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/OracleLib.sol/OracleLib.json +2 -2
- package/build/artifacts/contracts/core/Market/PendleGauge.sol/PendleGauge.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/PendleMarket.sol/PendleMarket.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/PendleMarket.sol/PendleMarket.json +25 -13
- package/build/artifacts/contracts/core/Market/PendleMarketFactory.sol/PendleMarketFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/PendleMarketFactory.sol/PendleMarketFactory.json +221 -50
- package/build/artifacts/contracts/core/StandardizedYield/PYIndex.sol/PYIndexLib.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/PYIndex.sol/PYIndexLib.json +2 -2
- package/build/artifacts/contracts/core/StandardizedYield/SYBase.sol/SYBase.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/SYBase.sol/SYBase.json +141 -0
- package/build/artifacts/contracts/core/StandardizedYield/SYBaseWithRewards.sol/SYBaseWithRewards.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/SYBaseWithRewards.sol/SYBaseWithRewards.json +141 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.json +2 -2
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol/PendleQiTokenSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol/PendleQiTokenSY.json +143 -2
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol/PendleCurveFraxUsdcSY.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol/PendleCurveFraxUsdcSY.json +1144 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol/PendleCurveUsdd3CrvSY.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol/PendleCurveUsdd3CrvSY.json +1209 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/Curve3CrvPoolHelper.sol/Curve3CrvPoolHelper.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/Curve3CrvPoolHelper.sol/Curve3CrvPoolHelper.json +10 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/CurveFraxUsdcPoolHelper.sol/CurveFraxUsdcPoolHelper.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/CurveFraxUsdcPoolHelper.sol/CurveFraxUsdcPoolHelper.json +3 -82
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/CurveUsdd3CrvPoolHelper.sol/CurveUsdd3CrvPoolHelper.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/CurveUsdd3CrvPoolHelper.sol/CurveUsdd3CrvPoolHelper.json +10 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/PendleConvexLPSY.sol/PendleConvexLPSY.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/{ConvexCurveLP → base}/PendleConvexLPSY.sol/PendleConvexLPSY.json +142 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleLooksStakingSY.sol/PendleLooksStakingSY.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleLooksStakingSY.sol/PendleLooksStakingSY.json +997 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol/PendleWstEthSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol/PendleWstEthSY.json +143 -2
- package/build/artifacts/contracts/core/YieldContracts/InterestManagerYT.sol/InterestManagerYT.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendlePrincipalToken.sol/PendlePrincipalToken.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendlePrincipalToken.sol/PendlePrincipalToken.json +2 -2
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.json +83 -10
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.json +35 -4
- package/build/artifacts/contracts/core/erc20/PendleERC20.sol/PendleERC20.dbg.json +1 -1
- package/build/artifacts/contracts/core/erc20/PendleERC20.sol/PendleERC20.json +2 -2
- package/build/artifacts/contracts/core/erc20/PendleERC20Permit.sol/PendleERC20Permit.dbg.json +1 -1
- package/build/artifacts/contracts/core/erc20/PendleERC20Permit.sol/PendleERC20Permit.json +2 -2
- package/build/artifacts/contracts/core/libraries/BaseSplitCodeFactory.sol/BaseSplitCodeFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/BaseSplitCodeFactory.sol/BaseSplitCodeFactory.json +3 -38
- package/build/artifacts/contracts/core/libraries/BaseSplitCodeFactory.sol/CodeDeployer.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/BaseSplitCodeFactory.sol/CodeDeployer.json +2 -2
- package/build/artifacts/contracts/core/libraries/BoringOwnableUpgradeable.sol/BoringOwnableUpgradeable.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/BoringOwnableUpgradeable.sol/BoringOwnableUpgradeableData.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/BoringOwnableUpgradeable.sol/BoringOwnableUpgradeableData.json +2 -2
- package/build/artifacts/contracts/core/libraries/Errors.sol/Errors.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/Errors.sol/Errors.json +131 -31
- package/build/artifacts/contracts/interfaces/ConvexCurve/IBooster.sol/IBooster.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ConvexCurve/IBooster.sol/IBooster.json +1 -1
- package/build/artifacts/contracts/interfaces/Curve/ICrvPool.sol/ICrvPool.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Curve/ICrvPool.sol/ICrvPool.json +14 -7
- package/build/artifacts/contracts/interfaces/Curve/ITriCrvPool.sol/ITriCrvPool.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/Curve/ITriCrvPool.sol/ITriCrvPool.json +213 -0
- package/build/artifacts/contracts/interfaces/IERC4626.sol/IERC4626.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IERC4626.sol/IERC4626.json +1 -1
- package/build/artifacts/contracts/interfaces/ILooksFeeSharing.sol/ILooksFeeSharing.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/ILooksFeeSharing.sol/ILooksFeeSharing.json +30 -0
- package/build/artifacts/contracts/interfaces/ILooksStaking.sol/ILooksStaking.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/ILooksStaking.sol/ILooksStaking.json +76 -0
- package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.json +8 -8
- package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.json +18 -18
- package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapPTYT.sol/IPActionSwapPTYT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.json +2 -2
- package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.json +28 -28
- package/build/artifacts/contracts/interfaces/IPBulkSeller.sol/IPBulkSeller.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPBulkSeller.sol/IPBulkSeller.json +0 -38
- package/build/artifacts/contracts/interfaces/IPBulkSellerFactory.sol/IPBulkSellerFactory.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPBulkSellerFactory.sol/IPBulkSellerFactory.json +25 -0
- package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.json +17 -5
- package/build/artifacts/contracts/interfaces/IPMarketFactory.sol/IPMarketFactory.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMarketFactory.sol/IPMarketFactory.json +50 -19
- package/build/artifacts/contracts/interfaces/IPMsgSendEndpoint.sol/IPMsgSendEndpoint.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMsgSendEndpoint.sol/IPMsgSendEndpoint.json +1 -1
- package/build/artifacts/contracts/interfaces/IPVotingController.sol/IPVotingController.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPVotingEscrowMainchain.sol/IPVotingEscrowMainchain.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPYieldContractFactory.sol/IPYieldContractFactory.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPYieldContractFactory.sol/IPYieldContractFactory.json +7 -7
- package/build/artifacts/contracts/interfaces/IPYieldToken.sol/IPYieldToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPYieldToken.sol/IPYieldToken.json +13 -0
- package/build/artifacts/contracts/interfaces/IStandardizedYield.sol/IStandardizedYield.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/BaseSplitCodeFactoryContract.sol/BaseSplitCodeFactoryContract.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/BaseSplitCodeFactoryContract.sol/BaseSplitCodeFactoryContract.json +2 -2
- package/build/artifacts/contracts/offchain-helpers/BulkSellerOffchain.sol/BulkSellerOffchain.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/BulkSellerOffchain.sol/BulkSellerOffchain.json +71 -13
- package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.json +28 -46
- package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.json +138 -62
- package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.json +37 -11
- package/build/artifacts/contracts/router/ActionCallback.sol/ActionCallback.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionCallback.sol/ActionCallback.json +2 -2
- package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.json +20 -20
- package/build/artifacts/contracts/router/ActionMisc.sol/ActionMisc.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionMisc.sol/ActionMisc.json +2 -2
- package/build/artifacts/contracts/router/ActionSwapPT.sol/ActionSwapPT.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionSwapPT.sol/ActionSwapPT.json +28 -2
- package/build/artifacts/contracts/router/ActionSwapPTYT.sol/ActionSwapPTYT.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionSwapPTYT.sol/ActionSwapPTYT.json +29 -3
- package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.json +30 -4
- package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.dbg.json +1 -1
- package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.json +2 -186
- package/build/artifacts/contracts/router/base/ActionBaseMintRedeem.sol/ActionBaseMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtInLib.dbg.json +1 -1
- package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtInLib.json +2 -2
- package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtOutLib.dbg.json +1 -1
- package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtOutLib.json +2 -2
- package/build/artifacts/contracts/router/kyberswap/AggregationRouterHelper.sol/AggregationRouterHelper.dbg.json +1 -1
- package/build/artifacts/contracts/router/kyberswap/AggregationRouterHelper.sol/AggregationRouterHelper.json +2 -2
- package/build/artifacts/contracts/router/kyberswap/KyberSwapHelper.sol/KyberSwapHelper.dbg.json +1 -1
- package/contracts/LiquidityMining/CrossChainMsg/PendleMsgSenderAppUpg.sol +1 -1
- package/contracts/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol +1 -1
- package/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol +3 -6
- package/contracts/LiquidityMining/VotingController/VotingControllerStorageUpg.sol +1 -1
- package/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol +7 -4
- package/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol +10 -5
- package/contracts/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol +3 -6
- package/contracts/LiquidityMining/libraries/VeHistoryLib.sol +0 -5
- package/contracts/LiquidityMining/libraries/WeekMath.sol +1 -1
- package/contracts/core/BulkSeller/BulkSeller.sol +0 -15
- package/contracts/core/BulkSeller/BulkSellerFactory.sol +7 -6
- package/contracts/core/Market/MarketMathCore.sol +52 -11
- package/contracts/core/Market/PendleMarket.sol +35 -22
- package/contracts/core/Market/PendleMarketFactory.sol +67 -35
- package/contracts/core/StandardizedYield/SYBase.sol +26 -3
- package/contracts/core/StandardizedYield/SYBaseWithRewards.sol +3 -1
- package/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol +102 -0
- package/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol +160 -0
- package/contracts/core/StandardizedYield/implementations/Convex/README.md +29 -0
- package/contracts/core/StandardizedYield/implementations/Convex/base/Curve3CrvPoolHelper.sol +215 -0
- package/contracts/core/StandardizedYield/implementations/Convex/base/CurveFraxUsdcPoolHelper.sol +46 -26
- package/contracts/core/StandardizedYield/implementations/Convex/base/CurveUsdd3CrvPoolHelper.sol +152 -0
- package/contracts/core/StandardizedYield/implementations/Convex/{ConvexCurveLP → base}/PendleConvexLPSY.sol +0 -0
- package/contracts/core/StandardizedYield/implementations/PendleLooksStakingSY.sol +128 -0
- package/contracts/core/YieldContracts/PendlePrincipalToken.sol +3 -3
- package/contracts/core/YieldContracts/PendleYieldContractFactory.sol +30 -12
- package/contracts/core/YieldContracts/PendleYieldToken.sol +79 -22
- package/contracts/core/erc20/PendleERC20.sol +4 -7
- package/contracts/core/libraries/BaseSplitCodeFactory.sol +1 -1
- package/contracts/core/libraries/BoringOwnableUpgradeable.sol +1 -1
- package/contracts/core/libraries/Errors.sol +18 -2
- package/contracts/interfaces/ConvexCurve/IBooster.sol +1 -1
- package/contracts/interfaces/Curve/ICrvPool.sol +3 -4
- package/contracts/interfaces/Curve/ITriCrvPool.sol +41 -0
- package/contracts/interfaces/IERC4626.sol +1 -1
- package/contracts/interfaces/ILooksFeeSharing.sol +5 -0
- package/contracts/interfaces/ILooksStaking.sol +13 -0
- package/contracts/interfaces/IPActionAddRemoveLiq.sol +4 -4
- package/contracts/interfaces/IPActionMintRedeem.sol +8 -8
- package/contracts/interfaces/IPActionSwapYT.sol +2 -2
- package/contracts/interfaces/IPBulkSeller.sol +0 -4
- package/contracts/interfaces/IPMarket.sol +20 -4
- package/contracts/interfaces/IPMarketFactory.sol +15 -5
- package/contracts/interfaces/IPMsgSendEndpoint.sol +1 -1
- package/contracts/interfaces/IPYieldContractFactory.sol +2 -2
- package/contracts/interfaces/IPYieldToken.sol +2 -0
- package/contracts/interfaces/IStandardizedYield.sol +15 -10
- package/contracts/offchain-helpers/BulkSellerOffchain.sol +17 -8
- package/contracts/offchain-helpers/MarketMathStatic.sol +35 -96
- package/contracts/offchain-helpers/RouterStatic.sol +49 -9
- package/contracts/router/ActionAddRemoveLiq.sol +102 -10
- package/contracts/router/ActionMintRedeem.sol +44 -4
- package/contracts/router/ActionSwapPT.sol +41 -11
- package/contracts/router/ActionSwapPTYT.sol +32 -7
- package/contracts/router/ActionSwapYT.sol +49 -33
- package/contracts/router/PendleRouter.sol +3 -11
- package/contracts/router/base/MarketApproxLib.sol +65 -22
- package/deployments/43113-core.json +19 -14
- package/deployments/43113-markets/WETH-FEB-2ND.json +10 -0
- package/package.json +7 -7
- package/typechain-types/AccessControlUpgradeable.ts +369 -0
- package/typechain-types/ActionAddRemoveLiq.ts +18 -18
- package/typechain-types/ActionMintRedeem.ts +30 -30
- package/typechain-types/ActionSwapPTYT.ts +5 -5
- package/typechain-types/ActionSwapYT.ts +5 -5
- package/typechain-types/BulkSeller.ts +5 -91
- package/typechain-types/BulkSellerFactory.ts +21 -0
- package/typechain-types/BulkSellerOffchain.ts +134 -0
- package/typechain-types/ContextUpgradeable.ts +68 -0
- package/typechain-types/ERC165Upgradeable.ts +113 -0
- package/typechain-types/IAccessControlUpgradeable.ts +305 -0
- package/typechain-types/IBooster.ts +9 -3
- package/typechain-types/ICrvPool.ts +4 -9
- package/typechain-types/IERC165Upgradeable.ts +102 -0
- package/typechain-types/IERC4626.ts +5 -5
- package/typechain-types/ILooksStaking.ts +27 -0
- package/typechain-types/IPActionAddRemoveLiq.ts +13 -13
- package/typechain-types/IPActionMintRedeem.ts +30 -30
- package/typechain-types/IPActionSwapYT.ts +5 -5
- package/typechain-types/IPAllAction.ts +48 -48
- package/typechain-types/IPBulkSeller.ts +0 -68
- package/typechain-types/IPBulkSellerFactory.ts +21 -0
- package/typechain-types/IPMarket.ts +26 -16
- package/typechain-types/IPMarketFactory.ts +70 -37
- package/typechain-types/IPMsgSendEndpoint.ts +1 -1
- package/typechain-types/IPYieldContractFactory.ts +11 -11
- package/typechain-types/IPYieldToken.ts +21 -0
- package/typechain-types/MarketMathStatic.ts +0 -67
- package/typechain-types/Pausable.ts +101 -0
- package/typechain-types/PendleConvexLPSY.ts +204 -0
- package/typechain-types/PendleCurveFraxUsdcSY.ts +204 -0
- package/typechain-types/PendleCurveUsdd3CrvSY.ts +204 -0
- package/typechain-types/PendleLooksStakingSY.ts +1256 -0
- package/typechain-types/PendleMarket.ts +26 -16
- package/typechain-types/PendleMarketFactory.ts +316 -92
- package/typechain-types/PendleQiTokenSY.ts +204 -0
- package/typechain-types/PendleRouter.ts +3 -287
- package/typechain-types/PendleWstEthSY.ts +204 -0
- package/typechain-types/PendleYieldContractFactory.ts +63 -18
- package/typechain-types/PendleYieldToken.ts +42 -0
- package/typechain-types/RouterStatic.ts +65 -7
- package/typechain-types/SYBase.ts +204 -0
- package/typechain-types/SYBaseWithRewards.ts +204 -0
- package/typechain-types/VotingEscrowPendleSidechain.ts +8 -8
- package/typechain-types/VotingEscrowTokenBase.ts +0 -21
- package/typechain-types/factories/AccessControlUpgradeable__factory.ts +247 -0
- package/typechain-types/factories/ActionAddRemoveLiq__factory.ts +36 -10
- package/typechain-types/factories/ActionCallback__factory.ts +1 -1
- package/typechain-types/factories/ActionMintRedeem__factory.ts +19 -19
- package/typechain-types/factories/ActionMisc__factory.ts +1 -1
- package/typechain-types/factories/ActionSwapPTYT__factory.ts +28 -2
- package/typechain-types/factories/ActionSwapPT__factory.ts +27 -1
- package/typechain-types/factories/ActionSwapYT__factory.ts +29 -3
- package/typechain-types/factories/AggregationRouterHelper__factory.ts +1 -1
- package/typechain-types/factories/BaseSplitCodeFactoryContract__factory.ts +1 -1
- package/typechain-types/factories/BoringOwnableUpgradeableData__factory.ts +1 -1
- package/typechain-types/factories/BulkSellerFactory__factory.ts +26 -1
- package/typechain-types/factories/BulkSellerOffchain__factory.ts +70 -12
- package/typechain-types/factories/BulkSeller__factory.ts +6 -53
- package/typechain-types/factories/ContextUpgradeable__factory.ts +39 -0
- package/typechain-types/factories/ERC165Upgradeable__factory.ts +58 -0
- package/typechain-types/factories/Errors__factory.ts +130 -30
- package/typechain-types/factories/IAccessControlUpgradeable__factory.ts +202 -0
- package/typechain-types/factories/IBooster__factory.ts +1 -1
- package/typechain-types/factories/ICrvPool__factory.ts +14 -7
- package/typechain-types/factories/IERC165Upgradeable__factory.ts +45 -0
- package/typechain-types/factories/IERC4626__factory.ts +1 -1
- package/typechain-types/factories/ILooksStaking__factory.ts +7 -0
- package/typechain-types/factories/IPActionAddRemoveLiq__factory.ts +8 -8
- package/typechain-types/factories/IPActionMintRedeem__factory.ts +18 -18
- package/typechain-types/factories/IPActionSwapYT__factory.ts +2 -2
- package/typechain-types/factories/IPAllAction__factory.ts +28 -28
- package/typechain-types/factories/IPBulkSellerFactory__factory.ts +25 -0
- package/typechain-types/factories/IPBulkSeller__factory.ts +0 -38
- package/typechain-types/factories/IPMarketFactory__factory.ts +50 -19
- package/typechain-types/factories/IPMarket__factory.ts +17 -5
- package/typechain-types/factories/IPMsgSendEndpoint__factory.ts +1 -1
- package/typechain-types/factories/IPYieldContractFactory__factory.ts +7 -7
- package/typechain-types/factories/IPYieldToken__factory.ts +13 -0
- package/typechain-types/factories/ImplicitSwapfeeContract__factory.ts +1 -1
- package/typechain-types/factories/MarketMathStatic__factory.ts +27 -45
- package/typechain-types/factories/OracleLib__factory.ts +1 -1
- package/typechain-types/factories/Pausable__factory.ts +62 -0
- package/typechain-types/factories/PendleConvexLPSY__factory.ts +141 -0
- package/typechain-types/factories/PendleCurveFraxUsdcSY__factory.ts +142 -1
- package/typechain-types/factories/PendleCurveUsdd3CrvSY__factory.ts +145 -39
- package/typechain-types/factories/PendleERC20Permit__factory.ts +1 -1
- package/typechain-types/factories/PendleERC20__factory.ts +1 -1
- package/typechain-types/factories/PendleFeeDistributorFactory__factory.ts +1 -1
- package/typechain-types/factories/PendleFeeDistributor__factory.ts +1 -1
- package/typechain-types/factories/PendleGaugeControllerMainchainUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleGaugeControllerSidechainUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleLooksStakingSY__factory.ts +1078 -0
- package/typechain-types/factories/PendleMarketFactory__factory.ts +220 -49
- package/typechain-types/factories/PendleMarket__factory.ts +18 -6
- package/typechain-types/factories/PendleMsgReceiveEndpointUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleMsgSendEndpointUpg__factory.ts +1 -1
- package/typechain-types/factories/PendlePrincipalToken__factory.ts +1 -1
- package/typechain-types/factories/PendleQiTokenHelper__factory.ts +1 -1
- package/typechain-types/factories/PendleQiTokenSY__factory.ts +142 -1
- package/typechain-types/factories/PendleRouter__factory.ts +1 -185
- package/typechain-types/factories/PendleVotingControllerUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleWstEthSY__factory.ts +142 -1
- package/typechain-types/factories/PendleYieldContractFactory__factory.ts +82 -9
- package/typechain-types/factories/PendleYieldToken__factory.ts +38 -3
- package/typechain-types/factories/RouterStatic__factory.ts +79 -3
- package/typechain-types/factories/SYBaseWithRewards__factory.ts +141 -0
- package/typechain-types/factories/SYBase__factory.ts +141 -0
- package/typechain-types/factories/VotingEscrowPendleMainchain__factory.ts +1 -1
- package/typechain-types/factories/VotingEscrowPendleSidechain__factory.ts +15 -4
- package/typechain-types/factories/VotingEscrowTokenBase__factory.ts +0 -13
- package/typechain-types/hardhat.d.ts +107 -26
- package/typechain-types/index.ts +24 -6
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/ConvexCurveLP/PendleConvexLPSY.sol/PendleConvexLPSY.dbg.json +0 -4
- package/build/artifacts/contracts/offchain-helpers/ImplicitSwapfeeContract.sol/ImplicitSwapfeeContract.dbg.json +0 -4
- package/build/artifacts/contracts/offchain-helpers/ImplicitSwapfeeContract.sol/ImplicitSwapfeeContract.json +0 -182
- package/contracts/offchain-helpers/ImplicitSwapfeeContract.sol +0 -30
- package/deployments/43113-markets/benqi-market-QI-AVAX-FEB-2ND.json +0 -9
- package/deployments/43113-markets/benqi-market-QI-USDC-FEB-2ND.json +0 -8
- package/deployments/43113-markets/benqi-market-QI-WETH-DEC-1ST.json +0 -9
- package/deployments/80001-core.json +0 -16
- package/deployments/80001-markets/benqi-market-QI-USDC-FEB-2ND.json +0 -8
- package/deployments/80001-markets/benqi-market-QI-WETH-DEC-1ST.json +0 -8
- package/deployments/80001-testenv.json +0 -22
|
@@ -12,7 +12,7 @@ import "./MarketMathStatic.sol";
|
|
|
12
12
|
import "../core/libraries/BoringOwnableUpgradeable.sol";
|
|
13
13
|
import "../LiquidityMining/libraries/VeBalanceLib.sol";
|
|
14
14
|
|
|
15
|
-
import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
|
|
15
|
+
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
|
16
16
|
import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
|
|
17
17
|
|
|
18
18
|
/// EXCLUDED FROM ALL AUDITS, TO BE CALLED ONLY BY PENDLE's SDK
|
|
@@ -20,9 +20,10 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
20
20
|
using Math for uint256;
|
|
21
21
|
using VeBalanceLib for VeBalance;
|
|
22
22
|
using VeBalanceLib for LockedPosition;
|
|
23
|
+
using BulkSellerMathCore for BulkSellerState;
|
|
23
24
|
|
|
24
25
|
uint128 public constant MAX_LOCK_TIME = 104 weeks;
|
|
25
|
-
uint128 public constant MIN_LOCK_TIME = 1
|
|
26
|
+
uint128 public constant MIN_LOCK_TIME = 1 days;
|
|
26
27
|
|
|
27
28
|
struct TokenAmount {
|
|
28
29
|
address token;
|
|
@@ -85,7 +86,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
85
86
|
guessMax: type(uint256).max,
|
|
86
87
|
guessOffchain: 0,
|
|
87
88
|
maxIteration: 256,
|
|
88
|
-
eps:
|
|
89
|
+
eps: 1e14
|
|
89
90
|
});
|
|
90
91
|
}
|
|
91
92
|
|
|
@@ -155,7 +156,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
155
156
|
|
|
156
157
|
pt = address(PT);
|
|
157
158
|
sy = address(SY);
|
|
158
|
-
state = _market.readState();
|
|
159
|
+
state = _market.readState(address(this));
|
|
159
160
|
impliedYield = getPtImpliedYield(market);
|
|
160
161
|
exchangeRate = MarketMathStatic.getExchangeRate(market);
|
|
161
162
|
}
|
|
@@ -244,7 +245,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
244
245
|
(userMarketInfo.assetBalance.assetType, userMarketInfo.assetBalance.assetAddress, ) = SY
|
|
245
246
|
.assetInfo();
|
|
246
247
|
|
|
247
|
-
MarketState memory state = _market.readState();
|
|
248
|
+
MarketState memory state = _market.readState(address(this));
|
|
248
249
|
uint256 totalLp = uint256(state.totalLp);
|
|
249
250
|
|
|
250
251
|
if (totalLp == 0) {
|
|
@@ -733,7 +734,8 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
733
734
|
address bulk
|
|
734
735
|
) public view returns (uint256 amountSy) {
|
|
735
736
|
if (bulk != address(0)) {
|
|
736
|
-
|
|
737
|
+
BulkSellerState memory state = IPBulkSeller(bulk).readState();
|
|
738
|
+
return state.calcSwapExactTokenForSy(amountToken);
|
|
737
739
|
} else {
|
|
738
740
|
return SY.previewDeposit(baseToken, amountToken);
|
|
739
741
|
}
|
|
@@ -746,7 +748,8 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
746
748
|
address bulk
|
|
747
749
|
) public view returns (uint256 amountBaseToken) {
|
|
748
750
|
if (bulk != address(0)) {
|
|
749
|
-
|
|
751
|
+
BulkSellerState memory state = IPBulkSeller(bulk).readState();
|
|
752
|
+
return state.calcSwapExactSyForToken(amountSy);
|
|
750
753
|
} else {
|
|
751
754
|
return SY.previewRedeem(baseToken, amountSy);
|
|
752
755
|
}
|
|
@@ -852,8 +855,45 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
852
855
|
bulk = IPBulkSellerFactory(bulkFactory).get(token, SY);
|
|
853
856
|
if (bulk != address(0)) {
|
|
854
857
|
BulkSellerState memory state = IPBulkSeller(bulk).readState();
|
|
855
|
-
|
|
856
|
-
|
|
858
|
+
if (state.rateTokenToSy != 0 || state.rateSyToToken != 0) {
|
|
859
|
+
totalToken = state.totalToken;
|
|
860
|
+
totalSy = state.totalSy;
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
function getBulkSellerInfo(
|
|
866
|
+
address token,
|
|
867
|
+
address SY,
|
|
868
|
+
uint256 netTokenIn,
|
|
869
|
+
uint256 netSyIn
|
|
870
|
+
)
|
|
871
|
+
external
|
|
872
|
+
view
|
|
873
|
+
returns (
|
|
874
|
+
address bulk,
|
|
875
|
+
uint256 totalToken,
|
|
876
|
+
uint256 totalSy
|
|
877
|
+
)
|
|
878
|
+
{
|
|
879
|
+
bulk = IPBulkSellerFactory(bulkFactory).get(token, SY);
|
|
880
|
+
if (bulk != address(0)) {
|
|
881
|
+
BulkSellerState memory state = IPBulkSeller(bulk).readState();
|
|
882
|
+
if (state.rateTokenToSy != 0 || state.rateSyToToken != 0) {
|
|
883
|
+
totalToken = state.totalToken;
|
|
884
|
+
totalSy = state.totalSy;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
uint256 postFeeRateTokenToSy = state.rateTokenToSy.mulDown(Math.ONE - state.feeRate);
|
|
888
|
+
uint256 postFeeRateSyToToken = state.rateSyToToken.mulDown(Math.ONE - state.feeRate);
|
|
889
|
+
if (
|
|
890
|
+
netTokenIn.mulDown(postFeeRateTokenToSy) > state.totalSy ||
|
|
891
|
+
netSyIn.mulDown(postFeeRateSyToToken) > state.totalToken
|
|
892
|
+
) {
|
|
893
|
+
bulk = address(0);
|
|
894
|
+
totalToken = 0;
|
|
895
|
+
totalSy = 0;
|
|
896
|
+
}
|
|
857
897
|
}
|
|
858
898
|
}
|
|
859
899
|
}
|
|
@@ -6,6 +6,14 @@ import "../interfaces/IPActionAddRemoveLiq.sol";
|
|
|
6
6
|
import "../interfaces/IPMarket.sol";
|
|
7
7
|
import "../core/libraries/Errors.sol";
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* @dev If market is expired, all actions will revert, except for the following:
|
|
11
|
+
* - removeLiquidityDualSyAndPt()
|
|
12
|
+
* - removeLiquidityDualTokenAndPt()
|
|
13
|
+
* - removeLiquiditySingleSy()
|
|
14
|
+
* - removeLiquiditySingleToken()
|
|
15
|
+
* This is because swapping and adding liquidity are not allowed on an expired market.
|
|
16
|
+
*/
|
|
9
17
|
contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
10
18
|
using Math for uint256;
|
|
11
19
|
using Math for int256;
|
|
@@ -20,6 +28,13 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
20
28
|
ActionBaseMintRedeem(_kyberScalingLib) //solhint-disable-next-line no-empty-blocks
|
|
21
29
|
{}
|
|
22
30
|
|
|
31
|
+
/**
|
|
32
|
+
* @notice Adds liquidity to the SY/PT market, granting LP tokens in return
|
|
33
|
+
* @dev Will mint as much LP as possible given no more than `netSyDesired` and `netPtDesired`,
|
|
34
|
+
* while not changing the market's price
|
|
35
|
+
* @dev Only the necessary SY/PT amount will be transferred
|
|
36
|
+
* @dev Reverts if market is expired
|
|
37
|
+
*/
|
|
23
38
|
function addLiquidityDualSyAndPt(
|
|
24
39
|
address receiver,
|
|
25
40
|
address market,
|
|
@@ -37,7 +52,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
37
52
|
(IStandardizedYield SY, IPPrincipalToken PT, ) = IPMarket(market).readTokens();
|
|
38
53
|
|
|
39
54
|
// calculate the amount of SY and PT to be used
|
|
40
|
-
MarketState memory state = IPMarket(market).readState();
|
|
55
|
+
MarketState memory state = IPMarket(market).readState(address(this));
|
|
41
56
|
(, netLpOut, netSyUsed, netPtUsed) = state.addLiquidity(
|
|
42
57
|
netSyDesired,
|
|
43
58
|
netPtDesired,
|
|
@@ -60,7 +75,15 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
60
75
|
}
|
|
61
76
|
|
|
62
77
|
/**
|
|
63
|
-
* @
|
|
78
|
+
* @notice Adds liquidity to SY/PT market using PT + any token.
|
|
79
|
+
* @dev Input token is first swapped to SY-mintable token using Kyber, then SY is minted from
|
|
80
|
+
* such. Finally the SY/PT pair is added to the market
|
|
81
|
+
* @param input data for input token, see {`./kyberswap/KyberSwapHelper.sol`}
|
|
82
|
+
* @param netPtDesired maximum PT to be used
|
|
83
|
+
* @dev Only the necessary PT amount will be transferred
|
|
84
|
+
* @dev All SY minted must be used, otherwise the call will revert. Therefore it is recommended
|
|
85
|
+
* that `netPtDesired` is slightly higher than actual expected.
|
|
86
|
+
* @dev Reverts if market is expired
|
|
64
87
|
*/
|
|
65
88
|
function addLiquidityDualTokenAndPt(
|
|
66
89
|
address receiver,
|
|
@@ -84,7 +107,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
84
107
|
|
|
85
108
|
{
|
|
86
109
|
// calc the amount of SY and PT to be used
|
|
87
|
-
MarketState memory state = IPMarket(market).readState();
|
|
110
|
+
MarketState memory state = IPMarket(market).readState(address(this));
|
|
88
111
|
(, netLpOut, netSyUsed, netPtUsed) = state.addLiquidity(
|
|
89
112
|
netSyDesired,
|
|
90
113
|
netPtDesired,
|
|
@@ -108,14 +131,22 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
108
131
|
emit AddLiquidityDualTokenAndPt(
|
|
109
132
|
msg.sender,
|
|
110
133
|
market,
|
|
111
|
-
receiver,
|
|
112
134
|
input.tokenIn,
|
|
135
|
+
receiver,
|
|
113
136
|
netTokenUsed,
|
|
114
137
|
netPtUsed,
|
|
115
138
|
netLpOut
|
|
116
139
|
);
|
|
117
140
|
}
|
|
118
141
|
|
|
142
|
+
/**
|
|
143
|
+
* @notice Swaps partial PT to SY, then use them to add liquidity to SY/PT pair
|
|
144
|
+
* @param netPtIn amount of PT to be transferred in from caller
|
|
145
|
+
* @param guessPtSwapToSy approximate info for the swap
|
|
146
|
+
* @return netLpOut actual LP output, will not be lower than `minLpOut`
|
|
147
|
+
* @return netSyFee amount of SY fee incurred from the swap
|
|
148
|
+
* @dev Reverts if market is expired
|
|
149
|
+
*/
|
|
119
150
|
function addLiquiditySinglePt(
|
|
120
151
|
address receiver,
|
|
121
152
|
address market,
|
|
@@ -126,7 +157,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
126
157
|
(, IPPrincipalToken PT, IPYieldToken YT) = IPMarket(market).readTokens();
|
|
127
158
|
|
|
128
159
|
// calculate the amount of PT to swap
|
|
129
|
-
MarketState memory state = IPMarket(market).readState();
|
|
160
|
+
MarketState memory state = IPMarket(market).readState(address(this));
|
|
130
161
|
|
|
131
162
|
(uint256 netPtSwap, , ) = state.approxSwapPtToAddLiquidity(
|
|
132
163
|
YT.newIndex(),
|
|
@@ -153,6 +184,14 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
153
184
|
emit AddLiquiditySinglePt(msg.sender, market, receiver, netPtIn, netLpOut);
|
|
154
185
|
}
|
|
155
186
|
|
|
187
|
+
/**
|
|
188
|
+
* @notice Swaps partial SY to PT, then use them to add liquidity to SY/PT pair
|
|
189
|
+
* @param netSyIn amount of SY to be transferred in from caller
|
|
190
|
+
* @param guessPtReceivedFromSy approx. output PT from the swap
|
|
191
|
+
* @return netLpOut actual LP output, will not be lower than `minLpOut`
|
|
192
|
+
* @return netSyFee amount of SY fee incurred from the swap
|
|
193
|
+
* @dev Reverts if market is expired
|
|
194
|
+
*/
|
|
156
195
|
function addLiquiditySingleSy(
|
|
157
196
|
address receiver,
|
|
158
197
|
address market,
|
|
@@ -178,6 +217,15 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
178
217
|
emit AddLiquiditySingleSy(msg.sender, market, receiver, netSyIn, netLpOut);
|
|
179
218
|
}
|
|
180
219
|
|
|
220
|
+
/**
|
|
221
|
+
* @notice Adds liquidity using a single token input. The input token is first swapped through
|
|
222
|
+
* Kyberswap to a SY-mintable token, the rest is the same as `addLiquiditySingleSy()`
|
|
223
|
+
* @param guessPtReceivedFromSy approximate PT output for the SY-to-PT swap
|
|
224
|
+
* @param input data for input token, see {`./kyberswap/KyberSwapHelper.sol`}
|
|
225
|
+
* @return netLpOut actual LP output, will not be lower than `minLpOut`
|
|
226
|
+
* @return netSyFee amount of SY fee incurred from the swap
|
|
227
|
+
* @dev Reverts if market is expired
|
|
228
|
+
*/
|
|
181
229
|
function addLiquiditySingleToken(
|
|
182
230
|
address receiver,
|
|
183
231
|
address market,
|
|
@@ -210,6 +258,11 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
210
258
|
);
|
|
211
259
|
}
|
|
212
260
|
|
|
261
|
+
/**
|
|
262
|
+
* @notice Burns LP token to remove SY/PT liquidity
|
|
263
|
+
* @param netLpToRemove amount of LP to be burned from caller
|
|
264
|
+
* @dev Will work even if market is expired
|
|
265
|
+
*/
|
|
213
266
|
function removeLiquidityDualSyAndPt(
|
|
214
267
|
address receiver,
|
|
215
268
|
address market,
|
|
@@ -234,6 +287,13 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
234
287
|
);
|
|
235
288
|
}
|
|
236
289
|
|
|
290
|
+
/**
|
|
291
|
+
* @notice Burns LP token to remove SY/PT liquidity, then redeems SY, finally (if needed)
|
|
292
|
+
* swaps SY redeemings through Kyberswap to desired output token.
|
|
293
|
+
* @param netLpToRemove amount of LP to be burned from caller
|
|
294
|
+
* @param output data for desired output token, see {`./kyberswap/KyberSwapHelper.sol`}
|
|
295
|
+
* @dev Will work even if market is expired
|
|
296
|
+
*/
|
|
237
297
|
function removeLiquidityDualTokenAndPt(
|
|
238
298
|
address receiver,
|
|
239
299
|
address market,
|
|
@@ -261,31 +321,39 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
261
321
|
emit RemoveLiquidityDualTokenAndPt(
|
|
262
322
|
msg.sender,
|
|
263
323
|
market,
|
|
324
|
+
output.tokenOut,
|
|
264
325
|
receiver,
|
|
265
326
|
netLpToRemove,
|
|
266
327
|
netPtOut,
|
|
267
|
-
output.tokenOut,
|
|
268
328
|
netTokenOut
|
|
269
329
|
);
|
|
270
330
|
}
|
|
271
331
|
|
|
332
|
+
/**
|
|
333
|
+
* @notice Removes SY/PT liquidity, then swaps all resulting SY to return only PT
|
|
334
|
+
* @param netLpToRemove amount of LP to be burned from caller
|
|
335
|
+
* @param guessPtReceivedFromSy approximate info for the swap
|
|
336
|
+
* @return netPtOut total PT output, will not be lower than `minPtOut`
|
|
337
|
+
* @return netSyFee amount of SY fee incurred from the swap
|
|
338
|
+
* @dev Reverts if market is expired
|
|
339
|
+
*/
|
|
272
340
|
function removeLiquiditySinglePt(
|
|
273
341
|
address receiver,
|
|
274
342
|
address market,
|
|
275
343
|
uint256 netLpToRemove,
|
|
276
344
|
uint256 minPtOut,
|
|
277
|
-
ApproxParams calldata
|
|
345
|
+
ApproxParams calldata guessPtReceivedFromSy
|
|
278
346
|
) external returns (uint256 netPtOut, uint256 netSyFee) {
|
|
279
347
|
(, , IPYieldToken YT) = IPMarket(market).readTokens();
|
|
280
348
|
|
|
281
349
|
// calculate the total amount of PT received from burning & selling SY
|
|
282
|
-
MarketState memory state = IPMarket(market).readState();
|
|
350
|
+
MarketState memory state = IPMarket(market).readState(address(this));
|
|
283
351
|
(uint256 syFromBurn, uint256 ptFromBurn) = state.removeLiquidity(netLpToRemove);
|
|
284
352
|
(uint256 ptFromSwap, ) = state.approxSwapExactSyForPt(
|
|
285
353
|
YT.newIndex(),
|
|
286
354
|
syFromBurn,
|
|
287
355
|
block.timestamp,
|
|
288
|
-
|
|
356
|
+
guessPtReceivedFromSy
|
|
289
357
|
);
|
|
290
358
|
|
|
291
359
|
if (ptFromBurn + ptFromSwap < minPtOut)
|
|
@@ -305,6 +373,14 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
305
373
|
emit RemoveLiquiditySinglePt(msg.sender, market, receiver, netLpToRemove, netPtOut);
|
|
306
374
|
}
|
|
307
375
|
|
|
376
|
+
/**
|
|
377
|
+
* @notice Removes SY/PT liquidity, then converts all resulting PT to return only SY
|
|
378
|
+
* @dev Conversion is done with market swap if not expired, or with PT redeeming if expired
|
|
379
|
+
* @param netLpToRemove amount of LP to be burned from caller
|
|
380
|
+
* @return netSyOut total SY output, will not be lower than `minSyOut`
|
|
381
|
+
* @return netSyFee amount of SY fee incurred from the swap
|
|
382
|
+
* @dev Will work even if market is expired
|
|
383
|
+
*/
|
|
308
384
|
function removeLiquiditySingleSy(
|
|
309
385
|
address receiver,
|
|
310
386
|
address market,
|
|
@@ -320,6 +396,18 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
320
396
|
emit RemoveLiquiditySingleSy(msg.sender, market, receiver, netLpToRemove, netSyOut);
|
|
321
397
|
}
|
|
322
398
|
|
|
399
|
+
/**
|
|
400
|
+
* @notice Removes SY/PT liquidity, then converts all to desired output token.
|
|
401
|
+
* @dev inner workings of this function:
|
|
402
|
+
- Removes SY/PT liquidity to only SY (see `removeLiquiditySingleSy()`)
|
|
403
|
+
- Burns SY to redeem SY-mintable tokens
|
|
404
|
+
- (If needed) swaps resulting tokens to desired output token using Kyberswap
|
|
405
|
+
* @param netLpToRemove amount of LP to be burned from caller
|
|
406
|
+
* @param output data for desired output token, see {`./kyberswap/KyberSwapHelper.sol`}
|
|
407
|
+
* @return netTokenOut total token output, will not be lower than `output.minTokenOut`
|
|
408
|
+
* @return netSyFee amount of SY fee incurred from the swap
|
|
409
|
+
* @dev Will work even if market is expired
|
|
410
|
+
*/
|
|
323
411
|
function removeLiquiditySingleToken(
|
|
324
412
|
address receiver,
|
|
325
413
|
address market,
|
|
@@ -353,6 +441,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
353
441
|
);
|
|
354
442
|
}
|
|
355
443
|
|
|
444
|
+
/// @dev swaps SY to PT, then adds liquidity
|
|
356
445
|
function _addLiquiditySingleSy(
|
|
357
446
|
address receiver,
|
|
358
447
|
address market,
|
|
@@ -361,7 +450,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
361
450
|
uint256 minLpOut,
|
|
362
451
|
ApproxParams calldata guessPtReceivedFromSy
|
|
363
452
|
) internal returns (uint256 netLpOut, uint256 netSyFee) {
|
|
364
|
-
MarketState memory state = IPMarket(market).readState();
|
|
453
|
+
MarketState memory state = IPMarket(market).readState(address(this));
|
|
365
454
|
|
|
366
455
|
// calculate the PT amount needed to add liquidity
|
|
367
456
|
(uint256 netPtFromSwap, , ) = state.approxSwapSyToAddLiquidity(
|
|
@@ -384,6 +473,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
384
473
|
if (netLpOut < minLpOut) revert Errors.RouterInsufficientLpOut(netLpOut, minLpOut);
|
|
385
474
|
}
|
|
386
475
|
|
|
476
|
+
/// @dev removes SY/PT liquidity, then converts PT to SY
|
|
387
477
|
function _removeLiquiditySingleSy(
|
|
388
478
|
address receiver,
|
|
389
479
|
address market,
|
|
@@ -399,6 +489,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
399
489
|
if (netSyOut < minSyOut) revert Errors.RouterInsufficientSyOut(netSyOut, minSyOut);
|
|
400
490
|
}
|
|
401
491
|
|
|
492
|
+
/// @dev converts PT to SY post-expiry
|
|
402
493
|
function __removeLpToSyAfterExpiry(
|
|
403
494
|
address receiver,
|
|
404
495
|
address market,
|
|
@@ -409,6 +500,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
409
500
|
netSyOut = syFromBurn + IPYieldToken(YT).redeemPY(receiver);
|
|
410
501
|
}
|
|
411
502
|
|
|
503
|
+
/// @dev swaps PT to SY pre-expiry
|
|
412
504
|
function __removeLpToSyBeforeExpiry(
|
|
413
505
|
address receiver,
|
|
414
506
|
address market,
|
|
@@ -16,6 +16,10 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
16
16
|
ActionBaseMintRedeem(_kyberScalingLib) //solhint-disable-next-line no-empty-blocks
|
|
17
17
|
{}
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* @notice swaps input token for SY-mintable tokens (if needed), then mints SY from such
|
|
21
|
+
* @param input data for input token, see {`./kyberswap/KyberSwapHelper.sol`}
|
|
22
|
+
*/
|
|
19
23
|
function mintSyFromToken(
|
|
20
24
|
address receiver,
|
|
21
25
|
address SY,
|
|
@@ -23,9 +27,14 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
23
27
|
TokenInput calldata input
|
|
24
28
|
) external payable returns (uint256 netSyOut) {
|
|
25
29
|
netSyOut = _mintSyFromToken(receiver, SY, minSyOut, input);
|
|
26
|
-
emit MintSyFromToken(msg.sender,
|
|
30
|
+
emit MintSyFromToken(msg.sender, input.tokenIn, SY, receiver, input.netTokenIn, netSyOut);
|
|
27
31
|
}
|
|
28
32
|
|
|
33
|
+
/**
|
|
34
|
+
* @notice redeems SY for SY-mintable tokens, then (if needed) swaps resulting tokens for
|
|
35
|
+
* desired output token through Kyberswap
|
|
36
|
+
* @param output data for desired output token, see {`./kyberswap/KyberSwapHelper.sol`}
|
|
37
|
+
*/
|
|
29
38
|
function redeemSyToToken(
|
|
30
39
|
address receiver,
|
|
31
40
|
address SY,
|
|
@@ -33,9 +42,16 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
33
42
|
TokenOutput calldata output
|
|
34
43
|
) external returns (uint256 netTokenOut) {
|
|
35
44
|
netTokenOut = _redeemSyToToken(receiver, SY, netSyIn, output, true);
|
|
36
|
-
emit RedeemSyToToken(msg.sender,
|
|
45
|
+
emit RedeemSyToToken(msg.sender, output.tokenOut, SY, receiver, netSyIn, netTokenOut);
|
|
37
46
|
}
|
|
38
47
|
|
|
48
|
+
/**
|
|
49
|
+
* @notice mints PY from any input token
|
|
50
|
+
* @dev swaps input token through Kyberswap to SY-mintable tokens first, then mints SY, finally
|
|
51
|
+
* mints PY from SY
|
|
52
|
+
* @param input data for input token, see {`./kyberswap/KyberSwapHelper.sol`}
|
|
53
|
+
* @dev reverts if PY is expired
|
|
54
|
+
*/
|
|
39
55
|
function mintPyFromToken(
|
|
40
56
|
address receiver,
|
|
41
57
|
address YT,
|
|
@@ -47,9 +63,15 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
47
63
|
uint256 netSyToMint = _mintSyFromToken(YT, SY, 0, input);
|
|
48
64
|
netPyOut = _mintPyFromSy(receiver, YT, netSyToMint, minPyOut, false);
|
|
49
65
|
|
|
50
|
-
emit MintPyFromToken(msg.sender,
|
|
66
|
+
emit MintPyFromToken(msg.sender, input.tokenIn, YT, receiver, input.netTokenIn, netPyOut);
|
|
51
67
|
}
|
|
52
68
|
|
|
69
|
+
/**
|
|
70
|
+
* @notice redeems PY for token
|
|
71
|
+
* @dev redeems PT(+YT) for SY first, then redeems SY, finally swaps resulting tokens to output
|
|
72
|
+
* token through Kyberswap (if needed)
|
|
73
|
+
* @param output data for desired output token, see {`./kyberswap/KyberSwapHelper.sol`}
|
|
74
|
+
*/
|
|
53
75
|
function redeemPyToToken(
|
|
54
76
|
address receiver,
|
|
55
77
|
address YT,
|
|
@@ -61,9 +83,13 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
61
83
|
uint256 netSyToRedeem = _redeemPyToSy(_syOrBulk(SY, output), YT, netPyIn, 1);
|
|
62
84
|
netTokenOut = _redeemSyToToken(receiver, SY, netSyToRedeem, output, false);
|
|
63
85
|
|
|
64
|
-
emit RedeemPyToToken(msg.sender,
|
|
86
|
+
emit RedeemPyToToken(msg.sender, output.tokenOut, YT, receiver, netPyIn, netTokenOut);
|
|
65
87
|
}
|
|
66
88
|
|
|
89
|
+
/**
|
|
90
|
+
* @notice mints PT+YT from input SY
|
|
91
|
+
* @dev reverts if the PY pair is expired
|
|
92
|
+
*/
|
|
67
93
|
function mintPyFromSy(
|
|
68
94
|
address receiver,
|
|
69
95
|
address YT,
|
|
@@ -74,6 +100,7 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
74
100
|
emit MintPyFromSy(msg.sender, receiver, YT, netSyIn, netPyOut);
|
|
75
101
|
}
|
|
76
102
|
|
|
103
|
+
/// @notice redeems PT(+YT) for its corresponding SY
|
|
77
104
|
function redeemPyToSy(
|
|
78
105
|
address receiver,
|
|
79
106
|
address YT,
|
|
@@ -84,6 +111,11 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
84
111
|
emit RedeemPyToSy(msg.sender, receiver, YT, netPyIn, netSyOut);
|
|
85
112
|
}
|
|
86
113
|
|
|
114
|
+
/**
|
|
115
|
+
* @notice A unified interface for redeeming rewards and interests for any SYs,
|
|
116
|
+
* YTs, and markets alike for `user`.
|
|
117
|
+
* @dev returns arrays of amounts claimed for each asset.
|
|
118
|
+
*/
|
|
87
119
|
function redeemDueInterestAndRewards(
|
|
88
120
|
address user,
|
|
89
121
|
address[] calldata sys,
|
|
@@ -134,6 +166,14 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
134
166
|
uint256[] amounts;
|
|
135
167
|
}
|
|
136
168
|
|
|
169
|
+
/**
|
|
170
|
+
* @notice A function to:
|
|
171
|
+
- Redeem all of caller's due interest and rewards in SYs, YTs, and markets
|
|
172
|
+
- Redeem SYs themselves
|
|
173
|
+
- Finally swaps all resulting tokens to `dataSwap.outputToken`
|
|
174
|
+
* @return netTokenOut total token output amount, will not be lower than `dataSwap.minTokenOut`
|
|
175
|
+
* @return amountsSwapped the amounts swapped for each token defined in `dataSwap.tokens`
|
|
176
|
+
*/
|
|
137
177
|
function redeemDueInterestAndRewardsThenSwapAll(
|
|
138
178
|
address[] calldata sys,
|
|
139
179
|
RouterYtRedeemStruct calldata dataYT,
|
|
@@ -6,6 +6,7 @@ import "../interfaces/IPActionSwapPT.sol";
|
|
|
6
6
|
import "../interfaces/IPMarket.sol";
|
|
7
7
|
import "../core/libraries/Errors.sol";
|
|
8
8
|
|
|
9
|
+
/// @dev All swap actions will revert if market is expired
|
|
9
10
|
contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
|
|
10
11
|
using MarketMathCore for MarketState;
|
|
11
12
|
using MarketApproxPtInLib for MarketState;
|
|
@@ -19,6 +20,12 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
|
|
|
19
20
|
ActionBaseMintRedeem(_kyberScalingLib) //solhint-disable-next-line no-empty-blocks
|
|
20
21
|
{}
|
|
21
22
|
|
|
23
|
+
/**
|
|
24
|
+
* @notice swaps exact amount of PT for SY
|
|
25
|
+
* @param exactPtIn will always consume this exact amount of PT for as much SY as possible
|
|
26
|
+
* @return netSyOut amount SY output, will not be less than `minSyOut`
|
|
27
|
+
* @return netSyFee amount SY fee incurred
|
|
28
|
+
*/
|
|
22
29
|
function swapExactPtForSy(
|
|
23
30
|
address receiver,
|
|
24
31
|
address market,
|
|
@@ -36,8 +43,13 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
|
|
|
36
43
|
}
|
|
37
44
|
|
|
38
45
|
/**
|
|
39
|
-
* @notice
|
|
40
|
-
|
|
46
|
+
* @notice swaps some amount of PT for the desired SY amount
|
|
47
|
+
* @param guessPtIn approximation data for input PT amount
|
|
48
|
+
* @param exactSyOut will consume as little PT as possible for this much SY amount
|
|
49
|
+
* @return netPtIn amount of PT used, will not be more than `maxPtIn`
|
|
50
|
+
* @return netSyFee amount SY fee incurred
|
|
51
|
+
* @dev the SY output might be slightly more than `exactSyOut` since an approximation is used.
|
|
52
|
+
* It is guaranteed that exactSyOut <= actualSyOut <= exactSyOut*(100% + guessPtIn.eps)
|
|
41
53
|
*/
|
|
42
54
|
function swapPtForExactSy(
|
|
43
55
|
address receiver,
|
|
@@ -46,7 +58,7 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
|
|
|
46
58
|
uint256 maxPtIn,
|
|
47
59
|
ApproxParams calldata guessPtIn
|
|
48
60
|
) external returns (uint256 netPtIn, uint256 netSyFee) {
|
|
49
|
-
MarketState memory state = IPMarket(market).readState();
|
|
61
|
+
MarketState memory state = IPMarket(market).readState(address(this));
|
|
50
62
|
(, IPPrincipalToken PT, IPYieldToken YT) = IPMarket(market).readTokens();
|
|
51
63
|
|
|
52
64
|
(netPtIn, , ) = state.approxSwapPtForExactSy(
|
|
@@ -69,16 +81,23 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
|
|
|
69
81
|
emit SwapPtAndSy(msg.sender, market, receiver, netPtIn.neg(), exactSyOut.Int());
|
|
70
82
|
}
|
|
71
83
|
|
|
84
|
+
/**
|
|
85
|
+
* @notice swaps SY for exact amount of PT
|
|
86
|
+
* @param exactPtOut will always consume as little SY as possible for this much amount of PT
|
|
87
|
+
* @return netSyIn amount SY used, will not be more than `maxSyIn`
|
|
88
|
+
* @return netSyFee amount SY fee incurred
|
|
89
|
+
* @dev the output amount of PT here is exact, no approximation is used
|
|
90
|
+
*/
|
|
72
91
|
function swapSyForExactPt(
|
|
73
92
|
address receiver,
|
|
74
93
|
address market,
|
|
75
94
|
uint256 exactPtOut,
|
|
76
95
|
uint256 maxSyIn
|
|
77
96
|
) external returns (uint256 netSyIn, uint256 netSyFee) {
|
|
78
|
-
MarketState memory state = IPMarket(market).readState();
|
|
97
|
+
MarketState memory state = IPMarket(market).readState(address(this));
|
|
79
98
|
(IStandardizedYield SY, , IPYieldToken YT) = IPMarket(market).readTokens();
|
|
80
99
|
|
|
81
|
-
(netSyIn, ) = state.swapSyForExactPt(YT.newIndex(), exactPtOut, block.timestamp);
|
|
100
|
+
(netSyIn, , ) = state.swapSyForExactPt(YT.newIndex(), exactPtOut, block.timestamp);
|
|
82
101
|
|
|
83
102
|
if (netSyIn > maxSyIn) revert Errors.RouterExceededLimitSyIn(netSyIn, maxSyIn);
|
|
84
103
|
|
|
@@ -90,6 +109,13 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
|
|
|
90
109
|
emit SwapPtAndSy(msg.sender, market, receiver, exactPtOut.Int(), netSyIn.neg());
|
|
91
110
|
}
|
|
92
111
|
|
|
112
|
+
/**
|
|
113
|
+
* @notice swaps exact amount of SY for as much PT as possible
|
|
114
|
+
* @param exactSyIn will always consume this much amount of SY
|
|
115
|
+
* @param guessPtOut approximation data for output PT amount
|
|
116
|
+
* @return netPtOut amount of PT output, will not be less than `minPtOut`
|
|
117
|
+
* @return netSyFee amount SY fee incurred
|
|
118
|
+
*/
|
|
93
119
|
function swapExactSyForPt(
|
|
94
120
|
address receiver,
|
|
95
121
|
address market,
|
|
@@ -114,9 +140,10 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
|
|
|
114
140
|
}
|
|
115
141
|
|
|
116
142
|
/**
|
|
117
|
-
* @notice swap from any
|
|
118
|
-
|
|
119
|
-
* @
|
|
143
|
+
* @notice swap (through Kyberswap) from any input token for SY-mintable tokens, then mints SY
|
|
144
|
+
* and swaps said SY for PT
|
|
145
|
+
* @param input data for input token, see {`./kyberswap/KyberSwapHelper.sol`}
|
|
146
|
+
* @dev is a combination of `_mintSyFromToken()` and `_swapExactSyForPt()`
|
|
120
147
|
*/
|
|
121
148
|
function swapExactTokenForPt(
|
|
122
149
|
address receiver,
|
|
@@ -151,8 +178,11 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
|
|
|
151
178
|
}
|
|
152
179
|
|
|
153
180
|
/**
|
|
154
|
-
* @notice swap from PT to SY, then redeem SY
|
|
155
|
-
*
|
|
181
|
+
* @notice swap from exact amount of PT to SY, then redeem SY for assets, finally swaps
|
|
182
|
+
* resulting assets through Kyberswap to get desired output token
|
|
183
|
+
* @param exactPtIn will always consume this much PT for as much SY as possible
|
|
184
|
+
* @param output data for desired output token, see {`./kyberswap/KyberSwapHelper.sol`}
|
|
185
|
+
* @dev is a combination of `_swapExactPtForSy()` and `_redeemSyToToken()`
|
|
156
186
|
*/
|
|
157
187
|
function swapExactPtForToken(
|
|
158
188
|
address receiver,
|
|
@@ -193,7 +223,7 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
|
|
|
193
223
|
uint256 minPtOut,
|
|
194
224
|
ApproxParams calldata guessPtOut
|
|
195
225
|
) internal returns (uint256 netPtOut, uint256 netSyFee) {
|
|
196
|
-
MarketState memory state = IPMarket(market).readState();
|
|
226
|
+
MarketState memory state = IPMarket(market).readState(address(this));
|
|
197
227
|
|
|
198
228
|
(netPtOut, ) = state.approxSwapExactSyForPt(
|
|
199
229
|
YT.newIndex(),
|