@pendle/core-v2 0.13.1-testnet → 0.14.0-testnet
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/PendleGaugeControllerBaseUpg.sol/PendleGaugeControllerBaseUpg.json +89 -0
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.json +91 -2
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.json +91 -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 +2 -2
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol/VotingEscrowTokenBase.dbg.json +1 -1
- 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/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 +26 -26
- package/build/artifacts/contracts/core/Market/PendleMarketFactory.sol/PendleMarketFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/PendleMarketFactory.sol/PendleMarketFactory.json +2 -2
- package/build/artifacts/contracts/core/RewardManager/RewardManager.sol/RewardManager.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/PYIndex.sol/PYIndexLib.dbg.json +4 -0
- package/build/artifacts/contracts/core/{SuperComposableYield → StandardizedYield}/PYIndex.sol/PYIndexLib.json +3 -3
- package/build/artifacts/contracts/core/StandardizedYield/SYBase.sol/SYBase.dbg.json +4 -0
- package/build/artifacts/contracts/core/{SuperComposableYield/SCYBase.sol/SCYBase.json → StandardizedYield/SYBase.sol/SYBase.json} +11 -11
- package/build/artifacts/contracts/core/StandardizedYield/SYBaseWithRewards.sol/SYBaseWithRewards.dbg.json +4 -0
- package/build/artifacts/contracts/core/{SuperComposableYield/SCYBaseWithRewards.sol/SCYBaseWithRewards.json → StandardizedYield/SYBaseWithRewards.sol/SYBaseWithRewards.json} +11 -11
- package/build/artifacts/contracts/core/StandardizedYield/SYUtils.sol/SYUtils.dbg.json +4 -0
- package/build/artifacts/contracts/core/{SuperComposableYield/SCYUtils.sol/SCYUtils.json → StandardizedYield/SYUtils.sol/SYUtils.json} +4 -4
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.dbg.json +4 -0
- package/build/artifacts/contracts/core/{SuperComposableYield → StandardizedYield}/implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.json +3 -3
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol/PendleQiTokenSY.dbg.json +4 -0
- package/build/artifacts/contracts/core/{SuperComposableYield/implementations/BenQi/PendleQiTokenSCY.sol/PendleQiTokenSCY.json → StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol/PendleQiTokenSY.json} +17 -17
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/ConvexCurveLP/Pendle3CrvAndTokenSY.sol/Pendle3CrvAndTokenSY.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/ConvexCurveLP/Pendle3CrvAndTokenSY.sol/Pendle3CrvAndTokenSY.json +1028 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/ConvexCurveLP/PendleConvexLPSY.sol/PendleConvexLPSY.dbg.json +4 -0
- package/build/artifacts/contracts/core/{SuperComposableYield/implementations/Convex/ConvexCurveLP/PendleConvexCurveLPSCY.sol/PendleConvexCurveLPSCY.json → StandardizedYield/implementations/Convex/ConvexCurveLP/PendleConvexLPSY.sol/PendleConvexLPSY.json} +47 -47
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/Pendle3CrvHelper.sol/Pendle3CrvHelper.dbg.json +4 -0
- package/build/artifacts/contracts/core/{SuperComposableYield → StandardizedYield}/implementations/Convex/Pendle3CrvHelper.sol/Pendle3CrvHelper.json +5 -5
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol/PendleWstEthSY.dbg.json +4 -0
- package/build/artifacts/contracts/core/{SuperComposableYield/implementations/PendleWstEthSCY.sol/PendleWstEthSCY.json → StandardizedYield/implementations/PendleWstEthSY.sol/PendleWstEthSY.json} +13 -13
- 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 +4 -4
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.json +4 -4
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.json +24 -24
- package/build/artifacts/contracts/core/libraries/Errors.sol/Errors.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/Errors.sol/Errors.json +28 -28
- package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.json +30 -30
- package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.json +34 -34
- package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.json +20 -20
- package/build/artifacts/contracts/interfaces/IPActionSwapPTYT.sol/IPActionSwapPTYT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapPTYT.sol/IPActionSwapPTYT.json +2 -2
- package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.json +20 -20
- package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.json +106 -106
- package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.json +18 -18
- package/build/artifacts/contracts/interfaces/IPMarketSwapCallback.sol/IPMarketSwapCallback.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMarketSwapCallback.sol/IPMarketSwapCallback.json +1 -1
- package/build/artifacts/contracts/interfaces/IPPrincipalToken.sol/IPPrincipalToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPPrincipalToken.sol/IPPrincipalToken.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 +3 -3
- package/build/artifacts/contracts/interfaces/IPYieldToken.sol/IPYieldToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPYieldToken.sol/IPYieldToken.json +6 -6
- package/build/artifacts/contracts/interfaces/IStandardizedYield.sol/IStandardizedYield.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/{ISuperComposableYield.sol/ISuperComposableYield.json → IStandardizedYield.sol/IStandardizedYield.json} +5 -5
- package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.json +7 -7
- package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.json +116 -116
- package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.json +35 -35
- package/build/artifacts/contracts/router/ActionCallback.sol/ActionCallback.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionCallback.sol/ActionCallback.json +12 -12
- package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.json +41 -41
- 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 -28
- package/build/artifacts/contracts/router/ActionSwapPTYT.sol/ActionSwapPTYT.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionSwapPTYT.sol/ActionSwapPTYT.json +4 -4
- package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.json +22 -22
- package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.dbg.json +1 -1
- package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.json +2 -2
- package/build/artifacts/contracts/router/base/ActionBaseMintRedeem.sol/ActionBaseMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/router/base/CallbackHelper.sol/CallbackHelper.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/KyberSwapHelper.sol/KyberSwapHelper.dbg.json +1 -1
- package/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol +96 -27
- package/contracts/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol +40 -12
- package/contracts/LiquidityMining/CrossChainMsg/PendleMsgSenderAppUpg.sol +24 -5
- package/contracts/LiquidityMining/CrossChainMsg/libraries/ExcessivelySafeCall.sol +133 -0
- package/contracts/LiquidityMining/CrossChainMsg/libraries/LayerZeroHelper.sol +33 -0
- package/contracts/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol +8 -1
- package/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol +3 -3
- package/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol +2 -7
- package/contracts/core/Market/MarketMathCore.sol +50 -53
- package/contracts/core/Market/PendleGauge.sol +8 -8
- package/contracts/core/Market/PendleMarket.sol +49 -49
- package/contracts/core/Market/PendleMarketFactory.sol +1 -1
- package/contracts/core/RewardManager/RewardManager.sol +1 -1
- package/contracts/core/{SuperComposableYield → StandardizedYield}/PYIndex.sol +16 -16
- package/contracts/core/{SuperComposableYield/SCYBase.sol → StandardizedYield/SYBase.sol} +17 -17
- package/contracts/core/{SuperComposableYield/SCYBaseWithRewards.sol → StandardizedYield/SYBaseWithRewards.sol} +9 -9
- package/contracts/core/StandardizedYield/SYUtils.sol +26 -0
- package/contracts/core/{SuperComposableYield → StandardizedYield}/implementations/BenQi/PendleQiTokenHelper.sol +1 -1
- package/contracts/core/{SuperComposableYield/implementations/BenQi/PendleQiTokenSCY.sol → StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol} +10 -10
- package/contracts/core/StandardizedYield/implementations/Convex/ConvexCurveLP/Pendle3CrvAndTokenSY.sol +167 -0
- package/contracts/core/{SuperComposableYield/implementations/Convex/ConvexCurveLP/PendleConvexCurveLPSCY.sol → StandardizedYield/implementations/Convex/ConvexCurveLP/PendleConvexLPSY.sol} +51 -70
- package/contracts/core/{SuperComposableYield → StandardizedYield}/implementations/Convex/Pendle3CrvHelper.sol +7 -7
- package/contracts/core/{SuperComposableYield/implementations/PendleWstEthSCY.sol → StandardizedYield/implementations/PendleWstEthSY.sol} +5 -5
- package/contracts/core/YieldContracts/InterestManagerYT.sol +7 -7
- package/contracts/core/YieldContracts/PendlePrincipalToken.sol +3 -3
- package/contracts/core/YieldContracts/PendleYieldContractFactory.sol +15 -15
- package/contracts/core/YieldContracts/PendleYieldToken.sol +71 -71
- package/contracts/core/libraries/Errors.sol +23 -21
- package/contracts/core/libraries/TokenHelper.sol +0 -33
- package/contracts/interfaces/Curve/ICrvPool.sol +2 -0
- package/contracts/interfaces/ILayerZeroEndpoint.sol +39 -0
- package/contracts/interfaces/ILayerZeroReceiver.sol +12 -0
- package/contracts/interfaces/IPActionAddRemoveLiq.sol +27 -27
- package/contracts/interfaces/IPActionMintRedeem.sol +30 -30
- package/contracts/interfaces/IPActionSwapPT.sol +16 -16
- package/contracts/interfaces/IPActionSwapPTYT.sol +2 -2
- package/contracts/interfaces/IPActionSwapYT.sol +16 -16
- package/contracts/interfaces/IPMarket.sol +14 -19
- package/contracts/interfaces/IPMarketSwapCallback.sol +1 -1
- package/contracts/interfaces/IPMsgSendEndpoint.sol +4 -2
- package/contracts/interfaces/IPPrincipalToken.sol +1 -1
- package/contracts/interfaces/IPYieldContractFactory.sol +3 -3
- package/contracts/interfaces/IPYieldToken.sol +7 -9
- package/contracts/interfaces/{ISuperComposableYield.sol → IStandardizedYield.sol} +6 -6
- package/contracts/offchain-helpers/MarketMathStatic.sol +116 -131
- package/contracts/offchain-helpers/RouterStatic.sol +80 -93
- package/contracts/router/ActionAddRemoveLiq.sol +99 -111
- package/contracts/router/ActionCallback.sol +46 -46
- package/contracts/router/ActionMintRedeem.sol +58 -58
- package/contracts/router/ActionSwapPT.sol +61 -69
- package/contracts/router/ActionSwapPTYT.sol +7 -7
- package/contracts/router/ActionSwapYT.sol +72 -79
- package/contracts/router/PendleRouter.sol +16 -16
- package/contracts/router/base/ActionBaseMintRedeem.sol +43 -43
- package/contracts/router/base/CallbackHelper.sol +20 -20
- package/contracts/router/base/MarketApproxLib.sol +166 -143
- package/contracts/router/kyberswap/KyberSwapHelper.sol +2 -2
- package/deployments/43113-core.json +16 -0
- package/{contracts/deployments → deployments}/43113-helper.json +0 -0
- package/deployments/43113-markets/benqi-market-QI-USDC-FEB-2ND.json +8 -0
- package/deployments/43113-markets/benqi-market-QI-WETH-DEC-1ST.json +8 -0
- package/{contracts/deployments → deployments}/43113-testenv.json +0 -0
- package/deployments/80001-core.json +15 -0
- package/{contracts/deployments → deployments}/80001-testenv.json +0 -0
- package/package.json +2 -2
- package/typechain-types/ActionAddRemoveLiq.ts +127 -129
- package/typechain-types/ActionCallback.ts +5 -5
- package/typechain-types/ActionMintRedeem.ts +139 -141
- package/typechain-types/ActionSwapPT.ts +73 -73
- package/typechain-types/ActionSwapPTYT.ts +2 -2
- package/typechain-types/ActionSwapYT.ts +73 -73
- package/typechain-types/IPActionAddRemoveLiq.ts +127 -129
- package/typechain-types/IPActionMintRedeem.ts +139 -141
- package/typechain-types/IPActionSwapPT.ts +73 -73
- package/typechain-types/IPActionSwapPTYT.ts +2 -2
- package/typechain-types/IPActionSwapYT.ts +73 -73
- package/typechain-types/IPAllAction.ts +402 -406
- package/typechain-types/IPMarket.ts +51 -54
- package/typechain-types/IPMarketSwapCallback.ts +5 -5
- package/typechain-types/IPPrincipalToken.ts +8 -8
- package/typechain-types/IPYieldContractFactory.ts +13 -13
- package/typechain-types/IPYieldToken.ts +17 -17
- package/typechain-types/IStandardizedYield.ts +895 -0
- package/typechain-types/MarketMathStatic.ts +27 -27
- package/typechain-types/Pendle3CrvAndTokenSY.ts +1243 -0
- package/typechain-types/Pendle3CrvHelper.ts +13 -13
- package/typechain-types/PendleConvexLPSY.ts +1189 -0
- package/typechain-types/PendleGaugeControllerBaseUpg.ts +125 -0
- package/typechain-types/PendleGaugeControllerMainchainUpg.ts +125 -0
- package/typechain-types/PendleGaugeControllerSidechainUpg.ts +124 -0
- package/typechain-types/PendleMarket.ts +54 -57
- package/typechain-types/PendlePrincipalToken.ts +8 -8
- package/typechain-types/PendleQiTokenSY.ts +1166 -0
- package/typechain-types/PendleWstEthSY.ts +1040 -0
- package/typechain-types/PendleYieldContractFactory.ts +8 -8
- package/typechain-types/PendleYieldToken.ts +41 -44
- package/typechain-types/RouterStatic.ts +196 -196
- package/typechain-types/SYBase.ts +1001 -0
- package/typechain-types/SYBaseWithRewards.ts +1094 -0
- package/typechain-types/factories/ActionAddRemoveLiq__factory.ts +34 -34
- package/typechain-types/factories/ActionCallback__factory.ts +11 -11
- package/typechain-types/factories/ActionMintRedeem__factory.ts +38 -38
- package/typechain-types/factories/ActionMisc__factory.ts +1 -1
- package/typechain-types/factories/ActionSwapPTYT__factory.ts +3 -3
- package/typechain-types/factories/ActionSwapPT__factory.ts +27 -27
- package/typechain-types/factories/ActionSwapYT__factory.ts +21 -21
- package/typechain-types/factories/Errors__factory.ts +27 -27
- package/typechain-types/factories/IPActionAddRemoveLiq__factory.ts +30 -30
- package/typechain-types/factories/IPActionMintRedeem__factory.ts +34 -34
- package/typechain-types/factories/IPActionSwapPTYT__factory.ts +2 -2
- package/typechain-types/factories/IPActionSwapPT__factory.ts +20 -20
- package/typechain-types/factories/IPActionSwapYT__factory.ts +20 -20
- package/typechain-types/factories/IPAllAction__factory.ts +106 -106
- package/typechain-types/factories/IPMarketSwapCallback__factory.ts +1 -1
- package/typechain-types/factories/IPMarket__factory.ts +18 -18
- package/typechain-types/factories/IPPrincipalToken__factory.ts +1 -1
- package/typechain-types/factories/IPYieldContractFactory__factory.ts +3 -3
- package/typechain-types/factories/IPYieldToken__factory.ts +6 -6
- package/typechain-types/factories/IStandardizedYield__factory.ts +658 -0
- package/typechain-types/factories/MarketMathStatic__factory.ts +6 -6
- package/typechain-types/factories/OracleLib__factory.ts +1 -1
- package/typechain-types/factories/Pendle3CrvAndTokenSY__factory.ts +1124 -0
- package/typechain-types/factories/Pendle3CrvHelper__factory.ts +3 -3
- package/typechain-types/factories/PendleConvexLPSY__factory.ts +963 -0
- package/typechain-types/factories/PendleFeeDistributorFactory__factory.ts +1 -1
- package/typechain-types/factories/PendleFeeDistributor__factory.ts +1 -1
- package/typechain-types/factories/PendleGaugeControllerBaseUpg__factory.ts +89 -0
- package/typechain-types/factories/PendleGaugeControllerMainchainUpg__factory.ts +90 -1
- package/typechain-types/factories/PendleGaugeControllerSidechainUpg__factory.ts +90 -1
- package/typechain-types/factories/PendleMarketFactory__factory.ts +1 -1
- package/typechain-types/factories/PendleMarket__factory.ts +21 -21
- 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 +7 -7
- package/typechain-types/factories/PendleQiTokenHelper__factory.ts +1 -1
- package/typechain-types/factories/PendleQiTokenSY__factory.ts +1095 -0
- package/typechain-types/factories/PendleRouter__factory.ts +1 -1
- package/typechain-types/factories/PendleVotingControllerUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleWstEthSY__factory.ts +924 -0
- package/typechain-types/factories/PendleYieldContractFactory__factory.ts +3 -3
- package/typechain-types/factories/PendleYieldToken__factory.ts +27 -27
- package/typechain-types/factories/RouterStatic__factory.ts +57 -57
- package/typechain-types/factories/SYBaseWithRewards__factory.ts +867 -0
- package/typechain-types/factories/SYBase__factory.ts +795 -0
- package/typechain-types/factories/VotingEscrowPendleMainchain__factory.ts +1 -1
- package/typechain-types/factories/VotingEscrowPendleSidechain__factory.ts +1 -1
- package/typechain-types/hardhat.d.ts +33 -51
- package/typechain-types/index.ts +14 -18
- package/build/artifacts/contracts/core/SuperComposableYield/PYIndex.sol/PYIndexLib.dbg.json +0 -4
- package/build/artifacts/contracts/core/SuperComposableYield/SCYBase.sol/SCYBase.dbg.json +0 -4
- package/build/artifacts/contracts/core/SuperComposableYield/SCYBaseWithRewards.sol/SCYBaseWithRewards.dbg.json +0 -4
- package/build/artifacts/contracts/core/SuperComposableYield/SCYUtils.sol/SCYUtils.dbg.json +0 -4
- package/build/artifacts/contracts/core/SuperComposableYield/implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.dbg.json +0 -4
- package/build/artifacts/contracts/core/SuperComposableYield/implementations/BenQi/PendleQiTokenSCY.sol/PendleQiTokenSCY.dbg.json +0 -4
- package/build/artifacts/contracts/core/SuperComposableYield/implementations/Convex/ConvexCurveLP/Pendle3CrvAndTokenSCY.sol/Pendle3CrvAndTokenSCY.dbg.json +0 -4
- package/build/artifacts/contracts/core/SuperComposableYield/implementations/Convex/ConvexCurveLP/Pendle3CrvAndTokenSCY.sol/Pendle3CrvAndTokenSCY.json +0 -1030
- package/build/artifacts/contracts/core/SuperComposableYield/implementations/Convex/ConvexCurveLP/PendleConvexCurveLP2PoolSCY.sol/PendleConvexCurveLP2PoolSCY.dbg.json +0 -4
- package/build/artifacts/contracts/core/SuperComposableYield/implementations/Convex/ConvexCurveLP/PendleConvexCurveLP2PoolSCY.sol/PendleConvexCurveLP2PoolSCY.json +0 -1025
- package/build/artifacts/contracts/core/SuperComposableYield/implementations/Convex/ConvexCurveLP/PendleConvexCurveLPSCY.sol/PendleConvexCurveLPSCY.dbg.json +0 -4
- package/build/artifacts/contracts/core/SuperComposableYield/implementations/Convex/Pendle3CrvHelper.sol/Pendle3CrvHelper.dbg.json +0 -4
- package/build/artifacts/contracts/core/SuperComposableYield/implementations/PendleWstEthSCY.sol/PendleWstEthSCY.dbg.json +0 -4
- package/build/artifacts/contracts/interfaces/ISuperComposableYield.sol/ISuperComposableYield.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 -190
- package/contracts/core/SuperComposableYield/SCYUtils.sol +0 -34
- package/contracts/core/SuperComposableYield/implementations/Convex/ConvexCurveLP/Pendle3CrvAndTokenSCY.sol +0 -135
- package/contracts/core/SuperComposableYield/implementations/Convex/ConvexCurveLP/PendleConvexCurveLP2PoolSCY.sol +0 -96
- package/contracts/deployments/43113-core.json +0 -16
- package/contracts/deployments/43113-markets/benqi-market-QI-USDC-FEB-2ND.json +0 -8
- package/contracts/deployments/43113-markets/benqi-market-QI-WETH-DEC-1ST.json +0 -8
- package/contracts/deployments/80001-core.json +0 -15
- package/contracts/deployments/80001-markets/benqi-market-QI-USDC-FEB-2ND.json +0 -8
- package/contracts/deployments/80001-markets/benqi-market-QI-WETH-DEC-1ST.json +0 -8
- package/contracts/interfaces/ICelerMessageBus.sol +0 -28
- package/contracts/interfaces/ICelerMessageReceiverApp.sol +0 -25
- package/contracts/offchain-helpers/ImplicitSwapfeeContract.sol +0 -26
|
@@ -10,6 +10,7 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
10
10
|
using MarketMathCore for MarketState;
|
|
11
11
|
using Math for uint256;
|
|
12
12
|
using Math for int256;
|
|
13
|
+
using SafeERC20 for IERC20;
|
|
13
14
|
|
|
14
15
|
/// @dev since this contract will be proxied, it must not contains non-immutable variables
|
|
15
16
|
constructor(address _kyberSwapRouter)
|
|
@@ -17,33 +18,26 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
17
18
|
{}
|
|
18
19
|
|
|
19
20
|
/// @dev refer to the internal function
|
|
20
|
-
function
|
|
21
|
+
function mintSyFromToken(
|
|
21
22
|
address receiver,
|
|
22
|
-
address
|
|
23
|
-
uint256
|
|
23
|
+
address SY,
|
|
24
|
+
uint256 minSyOut,
|
|
24
25
|
TokenInput calldata input
|
|
25
|
-
) external payable returns (uint256
|
|
26
|
-
|
|
26
|
+
) external payable returns (uint256 netSyOut) {
|
|
27
|
+
netSyOut = _mintSyFromToken(receiver, SY, minSyOut, input);
|
|
27
28
|
|
|
28
|
-
emit
|
|
29
|
-
msg.sender,
|
|
30
|
-
receiver,
|
|
31
|
-
SCY,
|
|
32
|
-
input.tokenIn,
|
|
33
|
-
input.netTokenIn,
|
|
34
|
-
netScyOut
|
|
35
|
-
);
|
|
29
|
+
emit MintSyFromToken(msg.sender, receiver, SY, input.tokenIn, input.netTokenIn, netSyOut);
|
|
36
30
|
}
|
|
37
31
|
|
|
38
32
|
/// @dev refer to the internal function
|
|
39
|
-
function
|
|
33
|
+
function redeemSyToToken(
|
|
40
34
|
address receiver,
|
|
41
|
-
address
|
|
42
|
-
uint256
|
|
35
|
+
address SY,
|
|
36
|
+
uint256 netSyIn,
|
|
43
37
|
TokenOutput calldata output
|
|
44
38
|
) external returns (uint256 netTokenOut) {
|
|
45
|
-
netTokenOut =
|
|
46
|
-
emit
|
|
39
|
+
netTokenOut = _redeemSyToToken(receiver, SY, netSyIn, output, true);
|
|
40
|
+
emit RedeemSyToToken(msg.sender, receiver, SY, netSyIn, output.tokenOut, netTokenOut);
|
|
47
41
|
}
|
|
48
42
|
|
|
49
43
|
/// @dev refer to the internal function
|
|
@@ -68,43 +62,43 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
68
62
|
emit RedeemPyToToken(msg.sender, receiver, YT, netPyIn, output.tokenOut, netTokenOut);
|
|
69
63
|
}
|
|
70
64
|
|
|
71
|
-
function
|
|
65
|
+
function mintPyFromSy(
|
|
72
66
|
address receiver,
|
|
73
67
|
address YT,
|
|
74
|
-
uint256
|
|
68
|
+
uint256 netSyIn,
|
|
75
69
|
uint256 minPyOut
|
|
76
70
|
) external returns (uint256 netPyOut) {
|
|
77
|
-
netPyOut =
|
|
78
|
-
emit
|
|
71
|
+
netPyOut = _mintPyFromSy(receiver, YT, netSyIn, minPyOut, true);
|
|
72
|
+
emit MintPyFromSy(msg.sender, receiver, YT, netSyIn, netPyOut);
|
|
79
73
|
}
|
|
80
74
|
|
|
81
|
-
function
|
|
75
|
+
function redeemPyToSy(
|
|
82
76
|
address receiver,
|
|
83
77
|
address YT,
|
|
84
78
|
uint256 netPyIn,
|
|
85
|
-
uint256
|
|
86
|
-
) external returns (uint256
|
|
87
|
-
|
|
88
|
-
emit
|
|
79
|
+
uint256 minSyOut
|
|
80
|
+
) external returns (uint256 netSyOut) {
|
|
81
|
+
netSyOut = _redeemPyToSy(receiver, YT, netPyIn, minSyOut, true);
|
|
82
|
+
emit RedeemPyToSy(msg.sender, receiver, YT, netPyIn, netSyOut);
|
|
89
83
|
}
|
|
90
84
|
|
|
91
85
|
function redeemDueInterestAndRewards(
|
|
92
86
|
address user,
|
|
93
|
-
address[] calldata
|
|
87
|
+
address[] calldata sys,
|
|
94
88
|
address[] calldata yts,
|
|
95
89
|
address[] calldata markets
|
|
96
90
|
)
|
|
97
91
|
external
|
|
98
92
|
returns (
|
|
99
|
-
uint256[][] memory
|
|
93
|
+
uint256[][] memory syRewards,
|
|
100
94
|
uint256[] memory ytInterests,
|
|
101
95
|
uint256[][] memory ytRewards,
|
|
102
96
|
uint256[][] memory marketRewards
|
|
103
97
|
)
|
|
104
98
|
{
|
|
105
|
-
|
|
106
|
-
for (uint256 i = 0; i <
|
|
107
|
-
|
|
99
|
+
syRewards = new uint256[][](sys.length);
|
|
100
|
+
for (uint256 i = 0; i < sys.length; ++i) {
|
|
101
|
+
syRewards[i] = IStandardizedYield(sys[i]).claimRewards(user);
|
|
108
102
|
}
|
|
109
103
|
|
|
110
104
|
ytInterests = new uint256[](yts.length);
|
|
@@ -123,10 +117,10 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
123
117
|
}
|
|
124
118
|
emit RedeemDueInterestAndRewards(
|
|
125
119
|
user,
|
|
126
|
-
|
|
120
|
+
sys,
|
|
127
121
|
yts,
|
|
128
122
|
markets,
|
|
129
|
-
|
|
123
|
+
syRewards,
|
|
130
124
|
ytInterests,
|
|
131
125
|
ytRewards,
|
|
132
126
|
marketRewards
|
|
@@ -139,7 +133,7 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
139
133
|
}
|
|
140
134
|
|
|
141
135
|
function redeemDueInterestAndRewardsThenSwapAll(
|
|
142
|
-
address[] calldata
|
|
136
|
+
address[] calldata sys,
|
|
143
137
|
RouterYtRedeemStruct calldata dataYT,
|
|
144
138
|
address[] calldata markets,
|
|
145
139
|
RouterSwapAllStruct calldata dataSwap
|
|
@@ -147,18 +141,18 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
147
141
|
if (dataSwap.tokens.length != dataSwap.kybercalls.length)
|
|
148
142
|
revert Errors.ArrayLengthMismatch();
|
|
149
143
|
|
|
150
|
-
if (dataYT.
|
|
144
|
+
if (dataYT.tokenRedeemSys.length != dataYT.syAddrs.length)
|
|
151
145
|
revert Errors.ArrayLengthMismatch();
|
|
152
146
|
|
|
153
147
|
RouterTokenAmounts memory tokensOut = _newRouterTokenAmounts(dataSwap.tokens);
|
|
154
|
-
RouterTokenAmounts memory
|
|
148
|
+
RouterTokenAmounts memory sysOut = _newRouterTokenAmounts(dataYT.syAddrs);
|
|
155
149
|
|
|
156
|
-
// redeem
|
|
157
|
-
for (uint256 i = 0; i <
|
|
158
|
-
|
|
150
|
+
// redeem SY
|
|
151
|
+
for (uint256 i = 0; i < sys.length; ++i) {
|
|
152
|
+
IStandardizedYield SY = IStandardizedYield(sys[i]);
|
|
159
153
|
|
|
160
|
-
address[] memory rewardTokens =
|
|
161
|
-
uint256[] memory rewardAmounts =
|
|
154
|
+
address[] memory rewardTokens = SY.getRewardTokens();
|
|
155
|
+
uint256[] memory rewardAmounts = SY.claimRewards(msg.sender);
|
|
162
156
|
_addTokenAmounts(tokensOut, rewardTokens, rewardAmounts);
|
|
163
157
|
}
|
|
164
158
|
|
|
@@ -169,10 +163,10 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
169
163
|
(uint256 interestAmount, uint256[] memory rewardAmounts) = YT
|
|
170
164
|
.redeemDueInterestAndRewards(msg.sender, true, true);
|
|
171
165
|
|
|
172
|
-
address
|
|
166
|
+
address syAddr = YT.SY();
|
|
173
167
|
address[] memory rewardTokens = YT.getRewardTokens();
|
|
174
168
|
|
|
175
|
-
_addTokenAmount(
|
|
169
|
+
_addTokenAmount(sysOut, syAddr, interestAmount);
|
|
176
170
|
_addTokenAmounts(tokensOut, rewardTokens, rewardAmounts);
|
|
177
171
|
}
|
|
178
172
|
|
|
@@ -186,8 +180,14 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
186
180
|
}
|
|
187
181
|
|
|
188
182
|
// guaranteed no ETH, all rewards are ERC20
|
|
189
|
-
|
|
190
|
-
|
|
183
|
+
for (uint256 i = 0; i < tokensOut.tokens.length; ++i) {
|
|
184
|
+
IERC20(tokensOut.tokens[i]).safeTransferFrom(
|
|
185
|
+
msg.sender,
|
|
186
|
+
address(this),
|
|
187
|
+
tokensOut.amounts[i]
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
_redeemAllSys(sysOut, dataYT.tokenRedeemSys, tokensOut);
|
|
191
191
|
|
|
192
192
|
// now swap all to outputToken
|
|
193
193
|
netTokenOut = _swapAllToOutputToken(tokensOut, dataSwap);
|
|
@@ -199,7 +199,7 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
199
199
|
|
|
200
200
|
emit RedeemDueInterestAndRewardsThenSwapAll(
|
|
201
201
|
msg.sender,
|
|
202
|
-
|
|
202
|
+
sys,
|
|
203
203
|
dataYT.yts,
|
|
204
204
|
markets,
|
|
205
205
|
dataSwap.outputToken,
|
|
@@ -215,25 +215,25 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
215
215
|
return RouterTokenAmounts(tokens, new uint256[](tokens.length));
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
/// @dev pull
|
|
219
|
-
function
|
|
220
|
-
RouterTokenAmounts memory
|
|
221
|
-
address[] calldata
|
|
218
|
+
/// @dev pull SYs from users & redeem them, then add to tokensOut
|
|
219
|
+
function _redeemAllSys(
|
|
220
|
+
RouterTokenAmounts memory sys,
|
|
221
|
+
address[] calldata tokenRedeemSys,
|
|
222
222
|
RouterTokenAmounts memory tokensOut
|
|
223
223
|
) internal {
|
|
224
|
-
for (uint256 i = 0; i <
|
|
225
|
-
if (
|
|
224
|
+
for (uint256 i = 0; i < sys.tokens.length; ++i) {
|
|
225
|
+
if (sys.amounts[i] == 0) continue;
|
|
226
226
|
|
|
227
|
-
|
|
228
|
-
uint256 amountOut =
|
|
227
|
+
IERC20(sys.tokens[i]).safeTransferFrom(msg.sender, sys.tokens[i], sys.amounts[i]);
|
|
228
|
+
uint256 amountOut = IStandardizedYield(sys.tokens[i]).redeem(
|
|
229
229
|
address(this),
|
|
230
|
-
|
|
231
|
-
|
|
230
|
+
sys.amounts[i],
|
|
231
|
+
tokenRedeemSys[i],
|
|
232
232
|
1,
|
|
233
233
|
true
|
|
234
234
|
);
|
|
235
235
|
|
|
236
|
-
_addTokenAmount(tokensOut,
|
|
236
|
+
_addTokenAmount(tokensOut, tokenRedeemSys[i], amountOut);
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
|
|
@@ -20,43 +20,39 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
|
|
|
20
20
|
ActionBaseMintRedeem(_kyberSwapRouter) //solhint-disable-next-line no-empty-blocks
|
|
21
21
|
{}
|
|
22
22
|
|
|
23
|
-
function
|
|
23
|
+
function swapExactPtForSy(
|
|
24
24
|
address receiver,
|
|
25
25
|
address market,
|
|
26
26
|
uint256 exactPtIn,
|
|
27
|
-
uint256
|
|
28
|
-
) external returns (uint256
|
|
27
|
+
uint256 minSyOut
|
|
28
|
+
) external returns (uint256 netSyOut, uint256 netSyFee) {
|
|
29
29
|
(, IPPrincipalToken PT, ) = IPMarket(market).readTokens();
|
|
30
30
|
IERC20(address(PT)).safeTransferFrom(msg.sender, market, exactPtIn);
|
|
31
31
|
|
|
32
|
-
(
|
|
33
|
-
receiver,
|
|
34
|
-
exactPtIn,
|
|
35
|
-
EMPTY_BYTES
|
|
36
|
-
);
|
|
32
|
+
(netSyOut, netSyFee) = IPMarket(market).swapExactPtForSy(receiver, exactPtIn, EMPTY_BYTES);
|
|
37
33
|
|
|
38
|
-
if (
|
|
34
|
+
if (netSyOut < minSyOut) revert Errors.RouterInsufficientSyOut(netSyOut, minSyOut);
|
|
39
35
|
|
|
40
|
-
emit
|
|
36
|
+
emit SwapPtAndSy(msg.sender, market, receiver, exactPtIn.neg(), netSyOut.Int());
|
|
41
37
|
}
|
|
42
38
|
|
|
43
39
|
/**
|
|
44
|
-
* @notice Note that the amount of
|
|
45
|
-
guaranteed that the `
|
|
40
|
+
* @notice Note that the amount of SY out will be a bit more than `exactSyOut`, since an approximation is used. It's
|
|
41
|
+
guaranteed that the `netSyOut` is at least `exactSyOut`
|
|
46
42
|
*/
|
|
47
|
-
function
|
|
43
|
+
function swapPtForExactSy(
|
|
48
44
|
address receiver,
|
|
49
45
|
address market,
|
|
50
|
-
uint256
|
|
46
|
+
uint256 exactSyOut,
|
|
51
47
|
uint256 maxPtIn,
|
|
52
48
|
ApproxParams calldata guessPtIn
|
|
53
|
-
) external returns (uint256 netPtIn, uint256
|
|
49
|
+
) external returns (uint256 netPtIn, uint256 netSyFee) {
|
|
54
50
|
MarketState memory state = IPMarket(market).readState();
|
|
55
51
|
(, IPPrincipalToken PT, IPYieldToken YT) = IPMarket(market).readTokens();
|
|
56
52
|
|
|
57
|
-
(netPtIn, , ) = state.
|
|
53
|
+
(netPtIn, , ) = state.approxSwapPtForExactSy(
|
|
58
54
|
YT.newIndex(),
|
|
59
|
-
|
|
55
|
+
exactSyOut,
|
|
60
56
|
block.timestamp,
|
|
61
57
|
guessPtIn
|
|
62
58
|
);
|
|
@@ -65,67 +61,63 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
|
|
|
65
61
|
|
|
66
62
|
IERC20(PT).safeTransferFrom(msg.sender, market, netPtIn);
|
|
67
63
|
|
|
68
|
-
uint256
|
|
69
|
-
(
|
|
70
|
-
receiver,
|
|
71
|
-
netPtIn,
|
|
72
|
-
EMPTY_BYTES
|
|
73
|
-
);
|
|
64
|
+
uint256 netSyOut;
|
|
65
|
+
(netSyOut, netSyFee) = IPMarket(market).swapExactPtForSy(receiver, netPtIn, EMPTY_BYTES);
|
|
74
66
|
|
|
75
67
|
// fail-safe
|
|
76
|
-
if (
|
|
68
|
+
if (netSyOut < exactSyOut) assert(false);
|
|
77
69
|
|
|
78
|
-
emit
|
|
70
|
+
emit SwapPtAndSy(msg.sender, market, receiver, netPtIn.neg(), exactSyOut.Int());
|
|
79
71
|
}
|
|
80
72
|
|
|
81
|
-
function
|
|
73
|
+
function swapSyForExactPt(
|
|
82
74
|
address receiver,
|
|
83
75
|
address market,
|
|
84
76
|
uint256 exactPtOut,
|
|
85
|
-
uint256
|
|
86
|
-
) external returns (uint256
|
|
77
|
+
uint256 maxSyIn
|
|
78
|
+
) external returns (uint256 netSyIn, uint256 netSyFee) {
|
|
87
79
|
MarketState memory state = IPMarket(market).readState();
|
|
88
|
-
(
|
|
80
|
+
(IStandardizedYield SY, , IPYieldToken YT) = IPMarket(market).readTokens();
|
|
89
81
|
|
|
90
|
-
(
|
|
82
|
+
(netSyIn, ) = state.swapSyForExactPt(YT.newIndex(), exactPtOut, block.timestamp);
|
|
91
83
|
|
|
92
|
-
if (
|
|
84
|
+
if (netSyIn > maxSyIn) revert Errors.RouterExceededLimitSyIn(netSyIn, maxSyIn);
|
|
93
85
|
|
|
94
|
-
IERC20(
|
|
86
|
+
IERC20(SY).safeTransferFrom(msg.sender, market, netSyIn);
|
|
95
87
|
|
|
96
|
-
(,
|
|
88
|
+
(, netSyFee) = IPMarket(market).swapSyForExactPt(receiver, exactPtOut, EMPTY_BYTES); // ignore return
|
|
97
89
|
|
|
98
|
-
// no fail-safe since exactly
|
|
99
|
-
emit
|
|
90
|
+
// no fail-safe since exactly netSyIn will go into the market
|
|
91
|
+
emit SwapPtAndSy(msg.sender, market, receiver, exactPtOut.Int(), netSyIn.neg());
|
|
100
92
|
}
|
|
101
93
|
|
|
102
|
-
function
|
|
94
|
+
function swapExactSyForPt(
|
|
103
95
|
address receiver,
|
|
104
96
|
address market,
|
|
105
|
-
uint256
|
|
97
|
+
uint256 exactSyIn,
|
|
106
98
|
uint256 minPtOut,
|
|
107
99
|
ApproxParams calldata guessPtOut
|
|
108
|
-
) external returns (uint256 netPtOut, uint256
|
|
109
|
-
(
|
|
100
|
+
) external returns (uint256 netPtOut, uint256 netSyFee) {
|
|
101
|
+
(IStandardizedYield SY, , IPYieldToken YT) = IPMarket(market).readTokens();
|
|
110
102
|
|
|
111
|
-
IERC20(
|
|
103
|
+
IERC20(SY).safeTransferFrom(msg.sender, market, exactSyIn);
|
|
112
104
|
|
|
113
|
-
(netPtOut,
|
|
105
|
+
(netPtOut, netSyFee) = _swapExactSyForPt(
|
|
114
106
|
receiver,
|
|
115
107
|
market,
|
|
116
108
|
YT,
|
|
117
|
-
|
|
109
|
+
exactSyIn,
|
|
118
110
|
minPtOut,
|
|
119
111
|
guessPtOut
|
|
120
112
|
);
|
|
121
113
|
|
|
122
|
-
emit
|
|
114
|
+
emit SwapPtAndSy(msg.sender, market, receiver, netPtOut.Int(), exactSyIn.neg());
|
|
123
115
|
}
|
|
124
116
|
|
|
125
117
|
/**
|
|
126
|
-
* @notice swap from any ERC20 tokens, through Uniswap's forks, to get baseTokens to make
|
|
127
|
-
from
|
|
128
|
-
* @dev simply a combination of
|
|
118
|
+
* @notice swap from any ERC20 tokens, through Uniswap's forks, to get baseTokens to make SY, then swap
|
|
119
|
+
from SY to PT
|
|
120
|
+
* @dev simply a combination of _mintSyFromToken & _swapExactSyForPt
|
|
129
121
|
*/
|
|
130
122
|
function swapExactTokenForPt(
|
|
131
123
|
address receiver,
|
|
@@ -133,18 +125,18 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
|
|
|
133
125
|
uint256 minPtOut,
|
|
134
126
|
ApproxParams calldata guessPtOut,
|
|
135
127
|
TokenInput calldata input
|
|
136
|
-
) external payable returns (uint256 netPtOut, uint256
|
|
137
|
-
(
|
|
128
|
+
) external payable returns (uint256 netPtOut, uint256 netSyFee) {
|
|
129
|
+
(IStandardizedYield SY, , IPYieldToken YT) = IPMarket(market).readTokens();
|
|
138
130
|
|
|
139
|
-
// all output
|
|
140
|
-
uint256
|
|
131
|
+
// all output SY is transferred directly to the market
|
|
132
|
+
uint256 netSyUseToBuyPt = _mintSyFromToken(address(market), address(SY), 1, input);
|
|
141
133
|
|
|
142
|
-
//
|
|
143
|
-
(netPtOut,
|
|
134
|
+
// SY is already in the market, hence doPull = false
|
|
135
|
+
(netPtOut, netSyFee) = _swapExactSyForPt(
|
|
144
136
|
receiver,
|
|
145
137
|
market,
|
|
146
138
|
YT,
|
|
147
|
-
|
|
139
|
+
netSyUseToBuyPt,
|
|
148
140
|
minPtOut,
|
|
149
141
|
guessPtOut
|
|
150
142
|
);
|
|
@@ -160,29 +152,29 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
|
|
|
160
152
|
}
|
|
161
153
|
|
|
162
154
|
/**
|
|
163
|
-
* @notice swap from PT to
|
|
164
|
-
* @dev simply a combination of
|
|
155
|
+
* @notice swap from PT to SY, then redeem SY to baseToken & swap through Uniswap's forks to get tokenOut
|
|
156
|
+
* @dev simply a combination of _swapExactPtForSy & _redeemSyToToken
|
|
165
157
|
*/
|
|
166
158
|
function swapExactPtForToken(
|
|
167
159
|
address receiver,
|
|
168
160
|
address market,
|
|
169
161
|
uint256 exactPtIn,
|
|
170
162
|
TokenOutput calldata output
|
|
171
|
-
) external returns (uint256 netTokenOut, uint256
|
|
172
|
-
(
|
|
163
|
+
) external returns (uint256 netTokenOut, uint256 netSyFee) {
|
|
164
|
+
(IStandardizedYield SY, IPPrincipalToken PT, ) = IPMarket(market).readTokens();
|
|
173
165
|
|
|
174
166
|
IERC20(address(PT)).safeTransferFrom(msg.sender, market, exactPtIn);
|
|
175
167
|
|
|
176
|
-
// all output
|
|
177
|
-
uint256
|
|
178
|
-
(
|
|
179
|
-
address(
|
|
168
|
+
// all output SY is directly transferred to the SY contract
|
|
169
|
+
uint256 netSyReceived;
|
|
170
|
+
(netSyReceived, netSyFee) = IPMarket(market).swapExactPtForSy(
|
|
171
|
+
address(SY),
|
|
180
172
|
exactPtIn,
|
|
181
173
|
EMPTY_BYTES
|
|
182
174
|
);
|
|
183
175
|
|
|
184
|
-
// since all
|
|
185
|
-
netTokenOut =
|
|
176
|
+
// since all SY is already at the SY contract, doPull = false
|
|
177
|
+
netTokenOut = _redeemSyToToken(receiver, address(SY), netSyReceived, output, false);
|
|
186
178
|
|
|
187
179
|
emit SwapPtAndToken(
|
|
188
180
|
msg.sender,
|
|
@@ -194,26 +186,26 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
|
|
|
194
186
|
);
|
|
195
187
|
}
|
|
196
188
|
|
|
197
|
-
function
|
|
189
|
+
function _swapExactSyForPt(
|
|
198
190
|
address receiver,
|
|
199
191
|
address market,
|
|
200
192
|
IPYieldToken YT,
|
|
201
|
-
uint256
|
|
193
|
+
uint256 exactSyIn,
|
|
202
194
|
uint256 minPtOut,
|
|
203
195
|
ApproxParams calldata guessPtOut
|
|
204
|
-
) internal returns (uint256 netPtOut, uint256
|
|
196
|
+
) internal returns (uint256 netPtOut, uint256 netSyFee) {
|
|
205
197
|
MarketState memory state = IPMarket(market).readState();
|
|
206
198
|
|
|
207
|
-
(netPtOut, ) = state.
|
|
199
|
+
(netPtOut, ) = state.approxSwapExactSyForPt(
|
|
208
200
|
YT.newIndex(),
|
|
209
|
-
|
|
201
|
+
exactSyIn,
|
|
210
202
|
block.timestamp,
|
|
211
203
|
guessPtOut
|
|
212
204
|
);
|
|
213
205
|
|
|
214
206
|
if (netPtOut < minPtOut) revert Errors.RouterInsufficientPtOut(netPtOut, minPtOut);
|
|
215
207
|
|
|
216
|
-
(,
|
|
208
|
+
(, netSyFee) = IPMarket(market).swapSyForExactPt(receiver, netPtOut, EMPTY_BYTES);
|
|
217
209
|
// no fail-safe since exactly netPtOut >= minPtOut will be out
|
|
218
210
|
}
|
|
219
211
|
}
|
|
@@ -13,7 +13,7 @@ contract ActionSwapPTYT is IPActionSwapPTYT, CallbackHelper {
|
|
|
13
13
|
using Math for int256;
|
|
14
14
|
using SafeERC20 for IERC20;
|
|
15
15
|
using PYIndexLib for IPYieldToken;
|
|
16
|
-
using SafeERC20 for
|
|
16
|
+
using SafeERC20 for IStandardizedYield;
|
|
17
17
|
using SafeERC20 for IPYieldToken;
|
|
18
18
|
using SafeERC20 for IPPrincipalToken;
|
|
19
19
|
|
|
@@ -29,14 +29,14 @@ contract ActionSwapPTYT is IPActionSwapPTYT, CallbackHelper {
|
|
|
29
29
|
uint256 exactPtIn,
|
|
30
30
|
uint256 minYtOut,
|
|
31
31
|
ApproxParams calldata guessTotalPtToSwap
|
|
32
|
-
) external returns (uint256 netYtOut, uint256
|
|
32
|
+
) external returns (uint256 netYtOut, uint256 netSyFee) {
|
|
33
33
|
(, IPPrincipalToken PT, IPYieldToken YT) = IPMarket(market).readTokens();
|
|
34
34
|
MarketState memory state = IPMarket(market).readState();
|
|
35
35
|
|
|
36
36
|
PT.safeTransferFrom(msg.sender, market, exactPtIn);
|
|
37
37
|
|
|
38
38
|
uint256 totalPtToSwap;
|
|
39
|
-
(netYtOut, totalPtToSwap,
|
|
39
|
+
(netYtOut, totalPtToSwap, netSyFee) = state.approxSwapExactPtForYt(
|
|
40
40
|
YT.newIndex(),
|
|
41
41
|
exactPtIn,
|
|
42
42
|
block.timestamp,
|
|
@@ -45,7 +45,7 @@ contract ActionSwapPTYT is IPActionSwapPTYT, CallbackHelper {
|
|
|
45
45
|
|
|
46
46
|
if (netYtOut < minYtOut) revert Errors.RouterInsufficientYtOut(netYtOut, minYtOut);
|
|
47
47
|
|
|
48
|
-
IPMarket(market).
|
|
48
|
+
IPMarket(market).swapExactPtForSy(
|
|
49
49
|
address(YT),
|
|
50
50
|
totalPtToSwap,
|
|
51
51
|
_encodeSwapExactPtForYt(receiver, exactPtIn, minYtOut)
|
|
@@ -60,14 +60,14 @@ contract ActionSwapPTYT is IPActionSwapPTYT, CallbackHelper {
|
|
|
60
60
|
uint256 exactYtIn,
|
|
61
61
|
uint256 minPtOut,
|
|
62
62
|
ApproxParams calldata guessTotalPtSwapped
|
|
63
|
-
) external returns (uint256 netPtOut, uint256
|
|
63
|
+
) external returns (uint256 netPtOut, uint256 netSyFee) {
|
|
64
64
|
(, , IPYieldToken YT) = IPMarket(market).readTokens();
|
|
65
65
|
MarketState memory state = IPMarket(market).readState();
|
|
66
66
|
|
|
67
67
|
YT.safeTransferFrom(msg.sender, address(YT), exactYtIn);
|
|
68
68
|
|
|
69
69
|
uint256 totalPtSwapped;
|
|
70
|
-
(netPtOut, totalPtSwapped,
|
|
70
|
+
(netPtOut, totalPtSwapped, netSyFee) = state.approxSwapExactYtForPt(
|
|
71
71
|
YT.newIndex(),
|
|
72
72
|
exactYtIn,
|
|
73
73
|
block.timestamp,
|
|
@@ -76,7 +76,7 @@ contract ActionSwapPTYT is IPActionSwapPTYT, CallbackHelper {
|
|
|
76
76
|
|
|
77
77
|
if (netPtOut < minPtOut) revert Errors.RouterInsufficientPtOut(netPtOut, minPtOut);
|
|
78
78
|
|
|
79
|
-
IPMarket(market).
|
|
79
|
+
IPMarket(market).swapSyForExactPt(
|
|
80
80
|
address(this),
|
|
81
81
|
totalPtSwapped,
|
|
82
82
|
_encodeSwapExactYtForPt(receiver, exactYtIn, minPtOut)
|