@pendle/core-v2 0.7.1-beta-2 → 0.8.0-beta-2
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/SuperComposableYield/SCY-implementations/AaveV3/PendleAaveV3SCY.sol/PendleAaveV3SCY.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/AaveV3/PendleAaveV3SCY.sol/PendleAaveV3SCY.json +33 -17
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/AaveV3/WadRayMath.sol/WadRayMath.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/AaveV3/WadRayMath.sol/WadRayMath.json +2 -2
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.json +2 -2
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenSCY.sol/PendleQiTokenSCY.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenSCY.sol/PendleQiTokenSCY.json +33 -17
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleERC4626SCY.sol/PendleERC4626SCY.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleERC4626SCY.sol/PendleERC4626SCY.json +33 -17
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleWstEthSCY.sol/PendleWstEthSCY.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleWstEthSCY.sol/PendleWstEthSCY.json +33 -17
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleYearnVaultScy.sol/PendleYearnVaultSCY.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleYearnVaultScy.sol/PendleYearnVaultSCY.json +33 -17
- package/build/artifacts/contracts/SuperComposableYield/base-implementations/SCYBase.sol/SCYBase.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/base-implementations/SCYBase.sol/SCYBase.json +31 -15
- package/build/artifacts/contracts/SuperComposableYield/base-implementations/SCYBaseWithRewards.sol/SCYBaseWithRewards.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/base-implementations/SCYBaseWithRewards.sol/SCYBaseWithRewards.json +31 -15
- package/build/artifacts/contracts/core/LiquidityMining/CelerAbstracts/CelerReceiverUpg.sol/CelerReceiverUpg.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/CelerAbstracts/CelerSenderUpg.sol/CelerSenderUpg.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol/PendleGaugeControllerBaseUpg.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerMainchain.sol/PendleGaugeControllerMainchainUpg.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerMainchain.sol/PendleGaugeControllerMainchainUpg.json +2 -2
- package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerSidechain.sol/PendleGaugeControllerSidechainUpg.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerSidechain.sol/PendleGaugeControllerSidechainUpg.json +2 -2
- package/build/artifacts/contracts/core/LiquidityMining/PendleGauge.sol/PendleGauge.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/PendleGauge.sol/PendleGauge.json +0 -26
- package/build/artifacts/contracts/core/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.json +2 -2
- package/build/artifacts/contracts/core/LiquidityMining/VotingController/VotingControllerStorageUpg.sol/VotingControllerStorageUpg.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.json +2 -2
- package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.json +2 -2
- package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol/VotingEscrowTokenBase.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 +125 -111
- 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/PendleERC20.sol/PendleERC20.dbg.json +1 -1
- package/build/artifacts/contracts/core/PendleERC20.sol/PendleERC20.json +2 -2
- package/build/artifacts/contracts/core/PendleERC20Permit.sol/PendleERC20Permit.dbg.json +1 -1
- package/build/artifacts/contracts/core/PendleERC20Permit.sol/PendleERC20Permit.json +2 -2
- package/build/artifacts/contracts/core/PendleRouter.sol/PendleRouter.dbg.json +1 -1
- package/build/artifacts/contracts/core/PendleRouter.sol/PendleRouter.json +2 -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 +77 -2
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.json +51 -20
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.json +72 -93
- package/build/artifacts/contracts/core/actions/ActionCallback.sol/ActionCallback.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/ActionCallback.sol/ActionCallback.json +2 -2
- package/build/artifacts/contracts/core/actions/ActionCore.sol/ActionCore.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/ActionCore.sol/ActionCore.json +3 -3
- package/build/artifacts/contracts/core/actions/ActionYT.sol/ActionYT.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/ActionYT.sol/ActionYT.json +2 -2
- package/build/artifacts/contracts/core/actions/base/ActionSCYAndPTBase.sol/ActionSCYAndPTBase.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/base/ActionSCYAndPYBase.sol/ActionSCYAndPYBase.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/base/ActionSCYAndYTBase.sol/ActionSCYAndYTBase.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/base/CallbackHelper.sol/CallbackHelper.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IAToken.sol/IAToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IAavePool.sol/IAavePool.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IAaveRewardsController.sol/IAaveRewardsController.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IBenQiComptroller.sol/IBenQiComptroller.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IBenQiInterestRateModel.sol/IBenQiInterestRateModel.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ICelerMessageBus.sol/ICelerMessageBus.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ICelerMessageReceiverApp.sol/ICelerMessageReceiverApp.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IERC4626.sol/IERC4626.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IJoePair.sol/IJoePair.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IJoeRouter01.sol/IJoeRouter01.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IJoeRouter02.sol/IJoeRouter02.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionCore.sol/IPActionCore.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionCore.sol/IPActionCore.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionYT.sol/IPActionYT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.json +1 -1
- package/build/artifacts/contracts/interfaces/IPGaugeController.sol/IPGaugeController.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPGaugeControllerMainchain.sol/IPGaugeControllerMainchain.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPGovernanceManager.sol/IPGovernanceManager.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPInterestManagerYT.sol/IPInterestManagerYT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.json +48 -83
- package/build/artifacts/contracts/interfaces/IPMarketFactory.sol/IPMarketFactory.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMarketSwapCallback.sol/IPMarketSwapCallback.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPPermissionsV2Upg.sol/IPermissionsV2Upg.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPPrincipalToken.sol/IPPrincipalToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPRouterStatic.sol/IPRouterStatic.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPVeToken.sol/IPVeToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPVotingController.sol/IPVotingController.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPVotingEscrow.sol/IPVotingEscrow.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 +30 -4
- package/build/artifacts/contracts/interfaces/IPYieldToken.sol/IPYieldToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPYieldToken.sol/IPYieldToken.json +8 -92
- package/build/artifacts/contracts/interfaces/IQiAvax.sol/IQiAvax.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IQiErc20.sol/IQiErc20.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IQiToken.sol/IQiToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IREDACTEDStaking.sol/IREDACTEDStaking.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IRewardManager.sol/IRewardManager.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ISuperComposableYield.sol/ISuperComposableYield.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ISuperComposableYield.sol/ISuperComposableYield.json +31 -2
- package/build/artifacts/contracts/interfaces/IWETH.sol/IWETH.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IWXBTRFLY.sol/IWXBTRFLY.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IWstETH.sol/IWstETH.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IYearnVault.sol/IYearnVault.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/RewardManager.sol/RewardManager.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/RewardManagerAbstract.sol/RewardManagerAbstract.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/SCY/SCYIndex.sol/SCYIndexLib.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/SCY/SCYIndex.sol/SCYIndexLib.json +2 -2
- package/build/artifacts/contracts/libraries/SCY/SCYUtils.sol/SCYUtils.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/SCY/SCYUtils.sol/SCYUtils.json +2 -2
- package/build/artifacts/contracts/libraries/VeBalanceLib.sol/VeBalanceLib.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/VeBalanceLib.sol/VeBalanceLib.json +2 -2
- package/build/artifacts/contracts/libraries/VeHistoryLib.sol/Checkpoints.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/VeHistoryLib.sol/Checkpoints.json +2 -2
- package/build/artifacts/contracts/libraries/helpers/ArrayLib.sol/ArrayLib.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/helpers/ArrayLib.sol/ArrayLib.json +2 -2
- package/build/artifacts/contracts/libraries/helpers/ExpiryUtilsLib.sol/ExpiryUtils.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/helpers/ExpiryUtilsLib.sol/ExpiryUtils.json +2 -2
- package/build/artifacts/contracts/libraries/helpers/MiniHelpers.sol/MiniHelpers.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/helpers/MiniHelpers.sol/MiniHelpers.json +2 -2
- package/build/artifacts/contracts/libraries/helpers/SSTORE2Deployer.sol/SSTORE2Deployer.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/helpers/SSTORE2Deployer.sol/SSTORE2Deployer.json +2 -2
- package/build/artifacts/contracts/libraries/helpers/TokenHelper.sol/TokenHelper.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/math/LogExpMath.sol/LogExpMath.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/math/LogExpMath.sol/LogExpMath.json +2 -2
- package/build/artifacts/contracts/libraries/math/MarketApproxLib.sol/MarketApproxLib.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/math/MarketApproxLib.sol/MarketApproxLib.json +2 -2
- package/build/artifacts/contracts/libraries/math/MarketMathCore.sol/MarketMathCore.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/math/MarketMathCore.sol/MarketMathCore.json +2 -2
- package/build/artifacts/contracts/libraries/math/Math.sol/Math.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/math/Math.sol/Math.json +2 -2
- package/build/artifacts/contracts/libraries/math/WeekMath.sol/WeekMath.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/math/WeekMath.sol/WeekMath.json +2 -2
- package/build/artifacts/contracts/libraries/solmate/SSTORE2.sol/SSTORE2.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/solmate/SSTORE2.sol/SSTORE2.json +2 -2
- package/build/artifacts/contracts/libraries/traderjoe/JoeLibrary.sol/JoeLibrary.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/traderjoe/JoeLibrary.sol/JoeLibrary.json +2 -2
- package/build/artifacts/contracts/libraries/traderjoe/PendleJoeSwapHelperUpg.sol/PendleJoeSwapHelperUpg.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.json +2 -2
- package/build/artifacts/contracts/periphery/PendleGovernanceManager.sol/PendleGovernanceManager.dbg.json +1 -1
- package/build/artifacts/contracts/periphery/PendleGovernanceManager.sol/PendleGovernanceManager.json +2 -2
- package/build/artifacts/contracts/periphery/PermissionsV2Upg.sol/PermissionsV2Upg.dbg.json +1 -1
- package/contracts/SuperComposableYield/SCY-implementations/AaveV3/PendleAaveV3SCY.sol +16 -12
- package/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenHelper.sol +3 -3
- package/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenSCY.sol +20 -0
- package/contracts/SuperComposableYield/SCY-implementations/PendleERC4626SCY.sol +20 -0
- package/contracts/SuperComposableYield/SCY-implementations/PendleWstEthSCY.sol +20 -0
- package/contracts/SuperComposableYield/SCY-implementations/PendleYearnVaultScy.sol +36 -5
- package/contracts/SuperComposableYield/base-implementations/SCYBase.sol +64 -42
- package/contracts/SuperComposableYield/base-implementations/SCYBaseWithRewards.sol +0 -7
- package/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol +1 -1
- package/contracts/core/LiquidityMining/PendleGauge.sol +24 -8
- package/contracts/core/LiquidityMining/VotingController/PendleVotingControllerUpg.sol +47 -96
- package/contracts/core/LiquidityMining/VotingController/VotingControllerStorageUpg.sol +86 -73
- package/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol +17 -16
- package/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol +1 -1
- package/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol +3 -4
- package/contracts/core/Market/PendleMarket.sol +34 -64
- package/contracts/core/PendleRouter.sol +1 -1
- package/contracts/core/YieldContracts/InterestManagerYT.sol +11 -8
- package/contracts/core/YieldContracts/PendlePrincipalToken.sol +3 -3
- package/contracts/core/YieldContracts/PendleYieldContractFactory.sol +18 -12
- package/contracts/core/YieldContracts/PendleYieldToken.sol +191 -138
- package/contracts/core/actions/ActionCallback.sol +12 -13
- package/contracts/core/actions/ActionCore.sol +84 -22
- package/contracts/core/actions/ActionYT.sol +33 -15
- package/contracts/core/actions/base/ActionSCYAndPTBase.sol +6 -17
- package/contracts/core/actions/base/ActionSCYAndPYBase.sol +20 -50
- package/contracts/core/actions/base/ActionSCYAndYTBase.sol +6 -13
- package/contracts/interfaces/IPActionCore.sol +72 -1
- package/contracts/interfaces/IPActionYT.sol +15 -0
- package/contracts/interfaces/IPMarket.sol +7 -26
- package/contracts/interfaces/IPRouterStatic.sol +7 -2
- package/contracts/interfaces/IPVeToken.sol +0 -2
- package/contracts/interfaces/IPVotingEscrow.sol +1 -1
- package/contracts/interfaces/IPYieldContractFactory.sol +6 -2
- package/contracts/interfaces/IPYieldToken.sol +21 -11
- package/contracts/interfaces/ISuperComposableYield.sol +22 -28
- package/contracts/interfaces/IYearnVault.sol +13 -1
- package/contracts/libraries/RewardManager.sol +9 -6
- package/contracts/libraries/RewardManagerAbstract.sol +6 -8
- package/contracts/libraries/SCY/SCYIndex.sol +17 -0
- package/contracts/libraries/SCY/SCYUtils.sol +16 -0
- package/contracts/libraries/VeBalanceLib.sol +0 -1
- package/contracts/libraries/helpers/ArrayLib.sol +11 -0
- package/contracts/libraries/helpers/TokenHelper.sol +6 -5
- package/contracts/libraries/math/MarketApproxLib.sol +91 -36
- package/contracts/libraries/math/MarketMathCore.sol +21 -25
- package/contracts/libraries/math/Math.sol +0 -7
- package/contracts/offchain-helpers/RouterStatic.sol +139 -7
- package/deployments/43113-core.json +11 -11
- package/deployments/43113-markets/benqi-market-0x9f080Af83E84099ED92b1b9b4B4BbE4400f2A3CB.json +7 -0
- package/deployments/80001-core.json +10 -10
- package/deployments/80001-markets/benqi-market-0x78699fa58C484e9867B8047A12E959ccB8BaD90E.json +7 -0
- package/package.json +2 -2
- package/typechain-types/ActionCore.ts +8 -8
- package/typechain-types/CelerReceiver.ts +267 -0
- package/typechain-types/CelerSender.ts +164 -0
- package/typechain-types/IPActionCore.ts +8 -8
- package/typechain-types/IPAllAction.ts +8 -8
- package/typechain-types/IPMarket.ts +66 -109
- package/typechain-types/IPVotingEscrowController.ts +154 -0
- package/typechain-types/IPYieldContractFactory.ts +34 -0
- package/typechain-types/IPYieldToken.ts +12 -112
- package/typechain-types/ISuperComposableYield.ts +54 -10
- package/typechain-types/PendleAaveV3SCY.ts +54 -29
- package/typechain-types/PendleBtrflyScy.ts +56 -58
- package/typechain-types/PendleERC4626SCY.ts +54 -29
- package/typechain-types/PendleGauge.ts +0 -32
- package/typechain-types/PendleGaugeController.ts +282 -0
- package/typechain-types/PendleGaugeControllerMainchain.ts +346 -0
- package/typechain-types/PendleGaugeControllerSidechain.ts +460 -0
- package/typechain-types/PendleJoeLpSCY.ts +56 -58
- package/typechain-types/PendleMarket.ts +169 -140
- package/typechain-types/PendlePrincipalToken.ts +104 -0
- package/typechain-types/PendleQiTokenSCY.ts +54 -29
- package/typechain-types/PendleVotingController.ts +865 -0
- package/typechain-types/PendleWstEthSCY.ts +54 -29
- package/typechain-types/PendleYearnVaultSCY.ts +54 -29
- package/typechain-types/PendleYieldContractFactory.ts +66 -19
- package/typechain-types/PendleYieldToken.ts +122 -158
- package/typechain-types/SCYBase.ts +54 -29
- package/typechain-types/SCYBaseWithRewards.ts +54 -29
- package/typechain-types/VotingControllerStorage.ts +410 -0
- package/typechain-types/VotingEscrowController.ts +154 -0
- package/typechain-types/VotingEscrowToken.ts +335 -0
- package/typechain-types/factories/ActionCallback__factory.ts +1 -1
- package/typechain-types/factories/ActionCore__factory.ts +2 -2
- package/typechain-types/factories/ActionYT__factory.ts +1 -1
- package/typechain-types/factories/CelerReceiver__factory.ts +140 -0
- package/typechain-types/factories/CelerSender__factory.ts +67 -0
- package/typechain-types/factories/ERC20__factory.ts +1 -1
- package/typechain-types/factories/IPActionCore__factory.ts +1 -1
- package/typechain-types/factories/IPAllAction__factory.ts +1 -1
- package/typechain-types/factories/IPMarket__factory.ts +48 -83
- package/typechain-types/factories/IPVotingEscrowController__factory.ts +80 -0
- package/typechain-types/factories/IPYieldContractFactory__factory.ts +30 -4
- package/typechain-types/factories/IPYieldToken__factory.ts +6 -90
- package/typechain-types/factories/ISuperComposableYield__factory.ts +31 -2
- package/typechain-types/factories/PendleAaveV3SCY__factory.ts +32 -16
- package/typechain-types/factories/PendleBtrflyScy__factory.ts +52 -28
- package/typechain-types/factories/PendleERC20Permit__factory.ts +1 -1
- package/typechain-types/factories/PendleERC20__factory.ts +1 -1
- package/typechain-types/factories/PendleERC4626SCY__factory.ts +32 -16
- package/typechain-types/factories/PendleGaugeControllerMainchainUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleGaugeControllerMainchain__factory.ts +269 -0
- package/typechain-types/factories/PendleGaugeControllerSidechainUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleGaugeControllerSidechain__factory.ts +328 -0
- package/typechain-types/factories/PendleGaugeController__factory.ts +149 -0
- package/typechain-types/factories/PendleGauge__factory.ts +0 -26
- package/typechain-types/factories/PendleGovernanceManager__factory.ts +1 -1
- package/typechain-types/factories/PendleJoeLpSCY__factory.ts +34 -28
- package/typechain-types/factories/PendleMarketFactory__factory.ts +1 -1
- package/typechain-types/factories/PendleMarket__factory.ts +124 -110
- package/typechain-types/factories/PendlePrincipalToken__factory.ts +76 -1
- package/typechain-types/factories/PendleQiTokenHelper__factory.ts +1 -1
- package/typechain-types/factories/PendleQiTokenSCY__factory.ts +32 -16
- package/typechain-types/factories/PendleRouter__factory.ts +1 -1
- package/typechain-types/factories/PendleVotingControllerUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleVotingController__factory.ts +584 -0
- package/typechain-types/factories/PendleWstEthSCY__factory.ts +32 -16
- package/typechain-types/factories/PendleYearnVaultSCY__factory.ts +32 -16
- package/typechain-types/factories/PendleYieldContractFactory__factory.ts +54 -19
- package/typechain-types/factories/PendleYieldToken__factory.ts +70 -91
- package/typechain-types/factories/RouterStatic__factory.ts +1 -1
- package/typechain-types/factories/SCYBaseWithRewards__factory.ts +31 -15
- package/typechain-types/factories/SCYBase__factory.ts +31 -15
- package/typechain-types/factories/VotingControllerStorage__factory.ts +298 -0
- package/typechain-types/factories/VotingEscrowController__factory.ts +80 -0
- package/typechain-types/factories/VotingEscrowPendleMainchain__factory.ts +1 -1
- package/typechain-types/factories/VotingEscrowPendleSidechain__factory.ts +1 -1
- package/typechain-types/factories/VotingEscrowToken__factory.ts +225 -0
- package/typechain-types/hardhat.d.ts +0 -27
- package/typechain-types/index.ts +0 -6
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleBtrflySCY.sol/PendleBtrflyScy.dbg.json +0 -4
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleBtrflySCY.sol/PendleBtrflyScy.json +0 -635
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleJoeLpSCY.sol/PendleJoeLpSCY.dbg.json +0 -4
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleJoeLpSCY.sol/PendleJoeLpSCY.json +0 -653
- package/build/artifacts/contracts/interfaces/IPMarketAddRemoveCallback.sol/IPMarketAddRemoveCallback.dbg.json +0 -4
- package/build/artifacts/contracts/interfaces/IPMarketAddRemoveCallback.sol/IPMarketAddRemoveCallback.json +0 -67
- package/build/artifacts/contracts/libraries/solmate/Bytes32AddressLib.sol/Bytes32AddressLib.dbg.json +0 -4
- package/build/artifacts/contracts/libraries/solmate/Bytes32AddressLib.sol/Bytes32AddressLib.json +0 -10
- package/contracts/SuperComposableYield/SCY-implementations/PendleBtrflySCY.sol +0 -123
- package/contracts/SuperComposableYield/SCY-implementations/PendleJoeLpSCY.sol +0 -245
- package/contracts/interfaces/IPMarketAddRemoveCallback.sol +0 -18
- package/contracts/libraries/solmate/Bytes32AddressLib.sol +0 -14
- package/deployments/43113-markets/benqi-market.json +0 -7
- package/deployments/80001-markets/benqi-market.json +0 -7
|
@@ -46,13 +46,13 @@ contract PendleYieldContractFactory is PermissionsV2Upg, Initializable, IPYieldC
|
|
|
46
46
|
|
|
47
47
|
address public pendleYtCreationCodePointer;
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
// 1 SLOT
|
|
50
|
+
uint128 public interestFeeRate; // a fixed point number
|
|
51
|
+
uint128 public rewardFeeRate; // a fixed point number
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
// 1 SLOT
|
|
54
|
+
address public treasury;
|
|
55
|
+
uint96 public expiryDivisor;
|
|
56
56
|
|
|
57
57
|
// SCY => expiry => address
|
|
58
58
|
mapping(address => mapping(uint256 => address)) public getPT;
|
|
@@ -61,15 +61,16 @@ contract PendleYieldContractFactory is PermissionsV2Upg, Initializable, IPYieldC
|
|
|
61
61
|
mapping(address => bool) public isYT;
|
|
62
62
|
|
|
63
63
|
constructor(
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
uint96 _expiryDivisor,
|
|
65
|
+
uint128 _interestFeeRate,
|
|
66
|
+
uint128 _rewardFeeRate,
|
|
66
67
|
address _treasury,
|
|
67
68
|
address _governanceManager
|
|
68
69
|
) PermissionsV2Upg(_governanceManager) {
|
|
69
70
|
setExpiryDivisor(_expiryDivisor);
|
|
70
71
|
setInterestFeeRate(_interestFeeRate);
|
|
72
|
+
setRewardFeeRate(_rewardFeeRate);
|
|
71
73
|
setTreasury(_treasury);
|
|
72
|
-
numContractDeployed++;
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
function initialize(bytes memory _pendleYtCreationCode) external initializer {
|
|
@@ -130,20 +131,25 @@ contract PendleYieldContractFactory is PermissionsV2Upg, Initializable, IPYieldC
|
|
|
130
131
|
emit CreateYieldContract(SCY, PT, YT, expiry);
|
|
131
132
|
}
|
|
132
133
|
|
|
133
|
-
function setExpiryDivisor(
|
|
134
|
+
function setExpiryDivisor(uint96 newExpiryDivisor) public onlyGovernance {
|
|
134
135
|
require(newExpiryDivisor != 0, "zero value");
|
|
135
136
|
expiryDivisor = newExpiryDivisor;
|
|
136
137
|
emit SetExpiryDivisor(newExpiryDivisor);
|
|
137
138
|
}
|
|
138
139
|
|
|
139
|
-
function setInterestFeeRate(
|
|
140
|
+
function setInterestFeeRate(uint128 newInterestFeeRate) public onlyGovernance {
|
|
140
141
|
interestFeeRate = newInterestFeeRate;
|
|
141
142
|
emit SetInterestFeeRate(newInterestFeeRate);
|
|
142
143
|
}
|
|
143
144
|
|
|
145
|
+
function setRewardFeeRate(uint128 newInterestFeeRate) public onlyGovernance {
|
|
146
|
+
rewardFeeRate = newInterestFeeRate;
|
|
147
|
+
emit SetInterestFeeRate(newInterestFeeRate);
|
|
148
|
+
}
|
|
149
|
+
|
|
144
150
|
function setTreasury(address newTreasury) public onlyGovernance {
|
|
145
151
|
require(newTreasury != address(0), "zero address");
|
|
146
152
|
treasury = newTreasury;
|
|
147
|
-
emit SetTreasury(
|
|
153
|
+
emit SetTreasury(newTreasury);
|
|
148
154
|
}
|
|
149
155
|
}
|
|
@@ -13,20 +13,17 @@ import "../../interfaces/IPYieldContractFactory.sol";
|
|
|
13
13
|
import "../../libraries/SCY/SCYUtils.sol";
|
|
14
14
|
import "../../libraries/helpers/MiniHelpers.sol";
|
|
15
15
|
import "../../libraries/RewardManagerAbstract.sol";
|
|
16
|
-
import "../
|
|
16
|
+
import "../PendleERC20Permit.sol";
|
|
17
17
|
import "./InterestManagerYT.sol";
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
It has been proven and tested that totalScyRedeemable will not change over time, unless users redeem their interest or redeemPY.
|
|
24
|
-
|
|
25
|
-
Due to this, it is required to update users' accruedReward STRICTLY BEFORE redeeming their interest.
|
|
19
|
+
/**
|
|
20
|
+
Invariances to maintain:
|
|
21
|
+
- address(0) & address(this) should never have any rewards & activeBalance accounting done. This is
|
|
22
|
+
guaranteed by address(0) & address(this) check in each updateForTwo function
|
|
26
23
|
*/
|
|
27
24
|
contract PendleYieldToken is
|
|
28
25
|
IPYieldToken,
|
|
29
|
-
|
|
26
|
+
PendleERC20Permit,
|
|
30
27
|
RewardManagerAbstract,
|
|
31
28
|
InterestManagerYT
|
|
32
29
|
{
|
|
@@ -34,10 +31,11 @@ contract PendleYieldToken is
|
|
|
34
31
|
using SafeERC20 for IERC20;
|
|
35
32
|
using ArrayLib for uint256[];
|
|
36
33
|
|
|
37
|
-
struct
|
|
38
|
-
bool isFinalized;
|
|
34
|
+
struct PostExpiryData {
|
|
39
35
|
uint128 firstScyIndex;
|
|
40
|
-
|
|
36
|
+
uint128 totalScyInterestForTreasury;
|
|
37
|
+
mapping(address => uint256) firstRewardIndex;
|
|
38
|
+
mapping(address => uint256) userRewardOwed;
|
|
41
39
|
}
|
|
42
40
|
|
|
43
41
|
address public immutable SCY;
|
|
@@ -48,9 +46,10 @@ contract PendleYieldToken is
|
|
|
48
46
|
uint128 public scyReserve;
|
|
49
47
|
uint128 internal _scyIndexStored;
|
|
50
48
|
|
|
51
|
-
|
|
49
|
+
PostExpiryData public postExpiry;
|
|
52
50
|
|
|
53
|
-
modifier
|
|
51
|
+
modifier updateData() {
|
|
52
|
+
if (isExpired()) _setPostExpiryData();
|
|
54
53
|
_;
|
|
55
54
|
_updateScyReserve();
|
|
56
55
|
}
|
|
@@ -62,7 +61,7 @@ contract PendleYieldToken is
|
|
|
62
61
|
string memory _symbol,
|
|
63
62
|
uint8 __decimals,
|
|
64
63
|
uint256 _expiry
|
|
65
|
-
)
|
|
64
|
+
) PendleERC20Permit(_name, _symbol, __decimals) {
|
|
66
65
|
SCY = _SCY;
|
|
67
66
|
PT = _PT;
|
|
68
67
|
expiry = _expiry;
|
|
@@ -73,7 +72,7 @@ contract PendleYieldToken is
|
|
|
73
72
|
function mintPY(address receiverPT, address receiverYT)
|
|
74
73
|
external
|
|
75
74
|
nonReentrant
|
|
76
|
-
|
|
75
|
+
updateData
|
|
77
76
|
returns (uint256 amountPYOut)
|
|
78
77
|
{
|
|
79
78
|
require(!isExpired(), "yield contract expired");
|
|
@@ -85,114 +84,109 @@ contract PendleYieldToken is
|
|
|
85
84
|
_mint(receiverYT, amountPYOut);
|
|
86
85
|
|
|
87
86
|
IPPrincipalToken(PT).mintByYT(receiverPT, amountPYOut);
|
|
88
|
-
|
|
89
|
-
emit Mint(msg.sender, receiverPT, receiverYT, amountPYOut);
|
|
90
87
|
}
|
|
91
88
|
|
|
92
89
|
/// @dev this function converts PY tokens into scy, but interests & rewards are not redeemed at the same time
|
|
93
90
|
function redeemPY(address receiver)
|
|
94
91
|
external
|
|
95
92
|
nonReentrant
|
|
96
|
-
|
|
93
|
+
updateData
|
|
97
94
|
returns (uint256 amountScyOut)
|
|
98
95
|
{
|
|
99
96
|
address[] memory receivers = new address[](1);
|
|
100
97
|
uint256[] memory amounts = new uint256[](1);
|
|
101
|
-
(receivers[0], amounts[0]) = (receiver,
|
|
98
|
+
(receivers[0], amounts[0]) = (receiver, _getAmountPYToRedeem());
|
|
102
99
|
|
|
103
|
-
|
|
100
|
+
uint256[] memory amountScyOuts;
|
|
101
|
+
amountScyOuts = _redeemPY(receivers, amounts);
|
|
104
102
|
|
|
105
|
-
|
|
103
|
+
amountScyOut = amountScyOuts[0];
|
|
106
104
|
}
|
|
107
105
|
|
|
108
106
|
/// @dev this function limit how much each receiver will receive. For example, if the totalOut is 100,
|
|
109
107
|
/// and the max are 50 30 INF, the first receiver will receive 50, the second will receive 30, and the third will receive 20.
|
|
110
108
|
/// @dev intended to mostly be used by Pendle router
|
|
111
|
-
function
|
|
109
|
+
function redeemPYMulti(address[] calldata receivers, uint256[] calldata amountPYToRedeems)
|
|
112
110
|
external
|
|
113
111
|
nonReentrant
|
|
114
|
-
|
|
115
|
-
returns (uint256
|
|
112
|
+
updateData
|
|
113
|
+
returns (uint256[] memory amountScyOuts)
|
|
116
114
|
{
|
|
117
|
-
(
|
|
115
|
+
require(receivers.length == amountPYToRedeems.length, "not same length");
|
|
116
|
+
require(receivers.length != 0, "empty array");
|
|
117
|
+
amountScyOuts = _redeemPY(receivers, amountPYToRedeems);
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
/**
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
121
|
+
* @dev With YT yielding interest in the form of SCY, which is redeemable by users, the reward
|
|
122
|
+
distribution should be based on the amount of SCYs that their YT currently represent, plus their
|
|
123
|
+
dueInterest. It has been proven and tested that _rewardSharesUser will not change over time,
|
|
124
|
+
unless users redeem their dueInterest or redeemPY. Due to this, it is required to update users'
|
|
125
|
+
accruedReward STRICTLY BEFORE transferring out their interest.
|
|
126
|
+
*/
|
|
127
|
+
function redeemDueInterestAndRewards(
|
|
128
|
+
address user,
|
|
129
|
+
bool redeemInterest,
|
|
130
|
+
bool redeemRewards
|
|
131
|
+
) external nonReentrant updateData returns (uint256 interestOut, uint256[] memory rewardsOut) {
|
|
132
|
+
require(redeemInterest || redeemRewards, "nothing to redeem");
|
|
133
|
+
|
|
134
|
+
// if redeemRewards == true, this line must be here for obvious reason
|
|
135
|
+
// if redeemInterest == true, this line must be here because of the reason above
|
|
129
136
|
_updateAndDistributeRewards(user);
|
|
130
|
-
_distributeInterest(user);
|
|
131
|
-
rewardsOut = _doTransferOutRewards(user, user);
|
|
132
|
-
interestOut = _doTransferOutInterest(user, SCY, factory);
|
|
133
137
|
|
|
134
|
-
|
|
135
|
-
|
|
138
|
+
if (redeemRewards) {
|
|
139
|
+
rewardsOut = _doTransferOutRewards(user, user);
|
|
140
|
+
emit RedeemRewards(user, rewardsOut);
|
|
141
|
+
} else {
|
|
142
|
+
address[] memory tokens = getRewardTokens();
|
|
143
|
+
rewardsOut = new uint256[](tokens.length);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (redeemInterest) {
|
|
147
|
+
_distributeInterest(user);
|
|
148
|
+
interestOut = _doTransferOutInterest(user, SCY, factory);
|
|
149
|
+
emit RedeemInterest(user, interestOut);
|
|
150
|
+
} else {
|
|
151
|
+
interestOut = 0;
|
|
152
|
+
}
|
|
136
153
|
}
|
|
137
154
|
|
|
138
|
-
|
|
139
|
-
* @dev as mentioned in doc, _updateAndDistributeRewards should be placed strictly before every _distributeInterest
|
|
140
|
-
*/
|
|
141
|
-
function redeemDueInterest(address user)
|
|
155
|
+
function redeemInterestAndRewardsPostExpiryForTreasury()
|
|
142
156
|
external
|
|
143
157
|
nonReentrant
|
|
144
|
-
|
|
145
|
-
returns (uint256 interestOut)
|
|
158
|
+
updateData
|
|
159
|
+
returns (uint256 interestOut, uint256[] memory rewardsOut)
|
|
146
160
|
{
|
|
147
|
-
|
|
148
|
-
_distributeInterest(user);
|
|
161
|
+
require(isExpired(), "not expired");
|
|
149
162
|
|
|
150
|
-
|
|
163
|
+
address treasury = IPYieldContractFactory(factory).treasury();
|
|
151
164
|
|
|
152
|
-
|
|
153
|
-
|
|
165
|
+
address[] memory tokens = getRewardTokens();
|
|
166
|
+
rewardsOut = new uint256[](tokens.length);
|
|
154
167
|
|
|
155
|
-
|
|
156
|
-
function redeemDueRewards(address user)
|
|
157
|
-
external
|
|
158
|
-
nonReentrant
|
|
159
|
-
returns (uint256[] memory rewardsOut)
|
|
160
|
-
{
|
|
161
|
-
_updateAndDistributeRewards(user);
|
|
162
|
-
rewardsOut = _doTransferOutRewards(user, user);
|
|
163
|
-
emit RedeemRewards(user, rewardsOut);
|
|
164
|
-
}
|
|
168
|
+
_redeemExternalReward();
|
|
165
169
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
function redeemRewardsAfterExpiryForTreasury()
|
|
170
|
-
external
|
|
171
|
-
nonReentrant
|
|
172
|
-
returns (uint256[] memory rewardsOut)
|
|
173
|
-
{
|
|
174
|
-
require(isExpired(), "not expired");
|
|
175
|
-
address[] memory rewardTokens = _getRewardTokens();
|
|
176
|
-
uint256[] memory preBalances = _selfBalances(rewardTokens);
|
|
170
|
+
for (uint256 i = 0; i < tokens.length; i++) {
|
|
171
|
+
rewardsOut[i] = _selfBalance(tokens[i]) - postExpiry.userRewardOwed[tokens[i]];
|
|
172
|
+
}
|
|
177
173
|
|
|
178
|
-
|
|
174
|
+
_transferOut(tokens, treasury, rewardsOut);
|
|
179
175
|
|
|
180
|
-
|
|
181
|
-
|
|
176
|
+
interestOut = postExpiry.totalScyInterestForTreasury;
|
|
177
|
+
postExpiry.totalScyInterestForTreasury = 0;
|
|
178
|
+
_transferOut(SCY, treasury, interestOut);
|
|
182
179
|
}
|
|
183
180
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
if (!isExpired() || afterExpiry.isFinalized) return;
|
|
187
|
-
afterExpiry.isFinalized = true;
|
|
188
|
-
afterExpiry.firstScyIndex = scyIndexCurrent().Uint128();
|
|
189
|
-
(, afterExpiry.firstRewardIndexes) = _updateRewardIndex();
|
|
181
|
+
function rewardIndexesCurrent() external override returns (uint256[] memory) {
|
|
182
|
+
return ISuperComposableYield(SCY).rewardIndexesCurrent();
|
|
190
183
|
}
|
|
191
184
|
|
|
192
185
|
/// @dev maximize the current rate with the previous rate to guarantee non-decreasing rate
|
|
193
186
|
function scyIndexCurrent() public returns (uint256 currentIndex) {
|
|
194
187
|
currentIndex = Math.max(ISuperComposableYield(SCY).exchangeRate(), _scyIndexStored);
|
|
195
188
|
_scyIndexStored = currentIndex.Uint128();
|
|
189
|
+
emit NewInterestIndex(currentIndex);
|
|
196
190
|
}
|
|
197
191
|
|
|
198
192
|
function scyIndexStored() public view returns (uint256) {
|
|
@@ -203,22 +197,55 @@ contract PendleYieldToken is
|
|
|
203
197
|
return MiniHelpers.isCurrentlyExpired(expiry);
|
|
204
198
|
}
|
|
205
199
|
|
|
206
|
-
function
|
|
207
|
-
|
|
208
|
-
|
|
200
|
+
function getPostExpiryData()
|
|
201
|
+
external
|
|
202
|
+
view
|
|
203
|
+
returns (
|
|
204
|
+
uint256 firstScyIndex,
|
|
205
|
+
uint256 totalScyInterestForTreasury,
|
|
206
|
+
uint256[] memory firstRewardIndexes,
|
|
207
|
+
uint256[] memory userRewardOwed
|
|
208
|
+
)
|
|
209
209
|
{
|
|
210
|
-
|
|
211
|
-
IPPrincipalToken(PT).burnByYT(address(this), amountPYToRedeem);
|
|
212
|
-
if (!isExpired()) _burn(address(this), amountPYToRedeem);
|
|
210
|
+
require(postExpiry.firstScyIndex != 0, "PostExpiry data not set");
|
|
213
211
|
|
|
214
|
-
|
|
212
|
+
firstScyIndex = postExpiry.firstScyIndex;
|
|
213
|
+
totalScyInterestForTreasury = postExpiry.totalScyInterestForTreasury;
|
|
215
214
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
215
|
+
address[] memory tokens = getRewardTokens();
|
|
216
|
+
firstRewardIndexes = new uint256[](tokens.length);
|
|
217
|
+
userRewardOwed = new uint256[](tokens.length);
|
|
218
|
+
|
|
219
|
+
for (uint256 i = 0; i < tokens.length; ++i) {
|
|
220
|
+
firstRewardIndexes[i] = postExpiry.firstRewardIndex[tokens[i]];
|
|
221
|
+
userRewardOwed[i] = postExpiry.userRewardOwed[tokens[i]];
|
|
219
222
|
}
|
|
223
|
+
}
|
|
220
224
|
|
|
221
|
-
|
|
225
|
+
function _redeemPY(address[] memory receivers, uint256[] memory amountPYToRedeems)
|
|
226
|
+
internal
|
|
227
|
+
returns (uint256[] memory amountScyOuts)
|
|
228
|
+
{
|
|
229
|
+
uint256 totalAmountPYToRedeem = amountPYToRedeems.sum();
|
|
230
|
+
IPPrincipalToken(PT).burnByYT(address(this), totalAmountPYToRedeem);
|
|
231
|
+
if (!isExpired()) _burn(address(this), totalAmountPYToRedeem);
|
|
232
|
+
|
|
233
|
+
uint256 index = scyIndexCurrent();
|
|
234
|
+
uint256 totalScyInterestPostExpiry;
|
|
235
|
+
amountScyOuts = new uint256[](receivers.length);
|
|
236
|
+
|
|
237
|
+
for (uint256 i = 0; i < receivers.length; i++) {
|
|
238
|
+
uint256 scyInterestPostExpiry;
|
|
239
|
+
(amountScyOuts[i], scyInterestPostExpiry) = _calcScyRedeemableFromPY(
|
|
240
|
+
amountPYToRedeems[i],
|
|
241
|
+
index
|
|
242
|
+
);
|
|
243
|
+
_transferOut(SCY, receivers[i], amountScyOuts[i]);
|
|
244
|
+
totalScyInterestPostExpiry += scyInterestPostExpiry;
|
|
245
|
+
}
|
|
246
|
+
if (totalScyInterestPostExpiry != 0) {
|
|
247
|
+
postExpiry.totalScyInterestForTreasury += totalScyInterestPostExpiry.Uint128();
|
|
248
|
+
}
|
|
222
249
|
}
|
|
223
250
|
|
|
224
251
|
function _calcPYToMint(uint256 amountScy) internal returns (uint256 amountPY) {
|
|
@@ -228,44 +255,59 @@ contract PendleYieldToken is
|
|
|
228
255
|
|
|
229
256
|
function _calcScyRedeemableFromPY(uint256 amountPY)
|
|
230
257
|
internal
|
|
231
|
-
returns (uint256 scyToUser, uint256
|
|
258
|
+
returns (uint256 scyToUser, uint256 scyInterestPostExpiry)
|
|
232
259
|
{
|
|
260
|
+
return _calcScyRedeemableFromPY(amountPY, scyIndexCurrent());
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function _calcScyRedeemableFromPY(uint256 amountPY, uint256 indexCurrent)
|
|
264
|
+
internal
|
|
265
|
+
view
|
|
266
|
+
returns (uint256 scyToUser, uint256 scyInterestPostExpiry)
|
|
267
|
+
{
|
|
268
|
+
scyToUser = SCYUtils.assetToScy(indexCurrent, amountPY);
|
|
233
269
|
if (isExpired()) {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
scyToUser = SCYUtils.assetToScy(scyIndexCurrent(), amountPY);
|
|
237
|
-
scyInterestAfterExpiry = totalScyRedeemable - scyToUser;
|
|
238
|
-
} else {
|
|
239
|
-
scyToUser = SCYUtils.assetToScy(scyIndexCurrent(), amountPY);
|
|
270
|
+
uint256 totalScyRedeemable = SCYUtils.assetToScy(postExpiry.firstScyIndex, amountPY);
|
|
271
|
+
scyInterestPostExpiry = totalScyRedeemable - scyToUser;
|
|
240
272
|
}
|
|
241
273
|
}
|
|
242
274
|
|
|
243
275
|
function _getAmountPYToRedeem() internal view returns (uint256) {
|
|
244
|
-
if (!isExpired())
|
|
245
|
-
|
|
246
|
-
else return IERC20(PT).balanceOf(address(this));
|
|
276
|
+
if (!isExpired()) return Math.min(_selfBalance(PT), balanceOf(address(this)));
|
|
277
|
+
else return _selfBalance(PT);
|
|
247
278
|
}
|
|
248
279
|
|
|
249
280
|
function _updateScyReserve() internal virtual {
|
|
250
|
-
scyReserve =
|
|
281
|
+
scyReserve = _selfBalance(SCY).Uint128();
|
|
251
282
|
}
|
|
252
283
|
|
|
253
284
|
function _getFloatingScyAmount() internal view returns (uint256 amount) {
|
|
254
|
-
amount =
|
|
285
|
+
amount = _selfBalance(SCY) - scyReserve;
|
|
255
286
|
require(amount > 0, "RECEIVE_ZERO");
|
|
256
287
|
}
|
|
257
288
|
|
|
289
|
+
function _setPostExpiryData() internal {
|
|
290
|
+
PostExpiryData storage local = postExpiry;
|
|
291
|
+
if (local.firstScyIndex != 0) return; // already set
|
|
292
|
+
|
|
293
|
+
_redeemExternalReward(); // do a final redeem. All the future reward income will belong to the treasury
|
|
294
|
+
|
|
295
|
+
local.firstScyIndex = scyIndexCurrent().Uint128();
|
|
296
|
+
address[] memory rewardTokens = ISuperComposableYield(SCY).getRewardTokens();
|
|
297
|
+
uint256[] memory rewardIndexes = ISuperComposableYield(SCY).rewardIndexesCurrent();
|
|
298
|
+
for (uint256 i = 0; i < rewardTokens.length; i++) {
|
|
299
|
+
local.firstRewardIndex[rewardTokens[i]] = rewardIndexes[i];
|
|
300
|
+
local.userRewardOwed[rewardTokens[i]] = _selfBalance(rewardTokens[i]);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
258
304
|
/*///////////////////////////////////////////////////////////////
|
|
259
305
|
INTEREST-RELATED
|
|
260
306
|
//////////////////////////////////////////////////////////////*/
|
|
261
307
|
|
|
262
308
|
function _getInterestIndex() internal virtual override returns (uint256 index) {
|
|
263
|
-
if (isExpired())
|
|
264
|
-
|
|
265
|
-
index = afterExpiry.firstScyIndex;
|
|
266
|
-
} else {
|
|
267
|
-
index = scyIndexCurrent();
|
|
268
|
-
}
|
|
309
|
+
if (isExpired()) index = postExpiry.firstScyIndex;
|
|
310
|
+
else index = scyIndexCurrent();
|
|
269
311
|
}
|
|
270
312
|
|
|
271
313
|
function _YTbalance(address user) internal view override returns (uint256) {
|
|
@@ -276,27 +318,49 @@ contract PendleYieldToken is
|
|
|
276
318
|
REWARDS-RELATED
|
|
277
319
|
//////////////////////////////////////////////////////////////*/
|
|
278
320
|
|
|
321
|
+
function getRewardTokens() public view returns (address[] memory) {
|
|
322
|
+
return ISuperComposableYield(SCY).getRewardTokens();
|
|
323
|
+
}
|
|
324
|
+
|
|
279
325
|
function _doTransferOutRewards(address user, address receiver)
|
|
280
326
|
internal
|
|
281
327
|
virtual
|
|
282
328
|
override
|
|
283
329
|
returns (uint256[] memory rewardAmounts)
|
|
284
330
|
{
|
|
285
|
-
|
|
331
|
+
address[] memory tokens = getRewardTokens();
|
|
286
332
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
333
|
+
if (isExpired()) {
|
|
334
|
+
// post-expiry, all incoming rewards will go to the treasury
|
|
335
|
+
// hence, we can save users one _redeemExternal here
|
|
336
|
+
for (uint256 i = 0; i < tokens.length; i++)
|
|
337
|
+
postExpiry.userRewardOwed[tokens[i]] -= userReward[tokens[i]][user].accrued;
|
|
338
|
+
rewardAmounts = __doTransferOutRewardsLocal(tokens, user, receiver);
|
|
339
|
+
} else {
|
|
340
|
+
_redeemExternalReward();
|
|
341
|
+
rewardAmounts = __doTransferOutRewardsLocal(tokens, user, receiver);
|
|
295
342
|
}
|
|
296
343
|
}
|
|
297
344
|
|
|
298
|
-
function
|
|
299
|
-
|
|
345
|
+
function __doTransferOutRewardsLocal(
|
|
346
|
+
address[] memory tokens,
|
|
347
|
+
address user,
|
|
348
|
+
address receiver
|
|
349
|
+
) internal returns (uint256[] memory rewardAmounts) {
|
|
350
|
+
address treasury = IPYieldContractFactory(factory).treasury();
|
|
351
|
+
uint256 feeRate = IPYieldContractFactory(factory).rewardFeeRate();
|
|
352
|
+
|
|
353
|
+
rewardAmounts = new uint256[](tokens.length);
|
|
354
|
+
for (uint256 i = 0; i < tokens.length; i++) {
|
|
355
|
+
uint256 rewardPreFee = userReward[tokens[i]][user].accrued;
|
|
356
|
+
userReward[tokens[i]][user].accrued = 0;
|
|
357
|
+
|
|
358
|
+
uint256 feeAmount = rewardPreFee.mulDown(feeRate);
|
|
359
|
+
rewardAmounts[i] = rewardPreFee - feeAmount;
|
|
360
|
+
|
|
361
|
+
_transferOut(tokens[i], treasury, feeAmount);
|
|
362
|
+
_transferOut(tokens[i], receiver, rewardAmounts[i]);
|
|
363
|
+
}
|
|
300
364
|
}
|
|
301
365
|
|
|
302
366
|
function _redeemExternalReward() internal virtual override {
|
|
@@ -310,40 +374,29 @@ contract PendleYieldToken is
|
|
|
310
374
|
return SCYUtils.assetToScy(index, balanceOf(user)) + userInterest[user].accrued;
|
|
311
375
|
}
|
|
312
376
|
|
|
313
|
-
function _rewardSharesTotal() internal view virtual override returns (uint256) {
|
|
314
|
-
return scyReserve;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
function _getRewardTokens() internal view override returns (address[] memory) {
|
|
318
|
-
return ISuperComposableYield(SCY).getRewardTokens();
|
|
319
|
-
}
|
|
320
|
-
|
|
321
377
|
function _updateRewardIndex()
|
|
322
378
|
internal
|
|
323
379
|
override
|
|
324
380
|
returns (address[] memory tokens, uint256[] memory indexes)
|
|
325
381
|
{
|
|
326
|
-
tokens =
|
|
382
|
+
tokens = getRewardTokens();
|
|
327
383
|
if (isExpired()) {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
384
|
+
indexes = new uint256[](tokens.length);
|
|
385
|
+
for (uint256 i = 0; i < tokens.length; i++)
|
|
386
|
+
indexes[i] = postExpiry.firstRewardIndex[tokens[i]];
|
|
331
387
|
} else {
|
|
332
|
-
indexes = rewardIndexesCurrent();
|
|
388
|
+
indexes = ISuperComposableYield(SCY).rewardIndexesCurrent();
|
|
333
389
|
}
|
|
334
390
|
}
|
|
335
391
|
|
|
336
|
-
function rewardIndexesCurrent() public override returns (uint256[] memory) {
|
|
337
|
-
return ISuperComposableYield(SCY).rewardIndexesCurrent();
|
|
338
|
-
}
|
|
339
|
-
|
|
340
392
|
//solhint-disable-next-line ordering
|
|
341
393
|
function _beforeTokenTransfer(
|
|
342
394
|
address from,
|
|
343
395
|
address to,
|
|
344
396
|
uint256
|
|
345
397
|
) internal override {
|
|
346
|
-
|
|
398
|
+
_setPostExpiryData();
|
|
347
399
|
_updateAndDistributeRewardsForTwo(from, to);
|
|
400
|
+
_distributeInterestForTwo(from, to);
|
|
348
401
|
}
|
|
349
402
|
}
|
|
@@ -3,7 +3,6 @@ pragma solidity 0.8.15;
|
|
|
3
3
|
|
|
4
4
|
import "../../interfaces/IPMarketFactory.sol";
|
|
5
5
|
import "../../interfaces/IPMarket.sol";
|
|
6
|
-
import "../../interfaces/IPMarketAddRemoveCallback.sol";
|
|
7
6
|
import "../../interfaces/IPMarketSwapCallback.sol";
|
|
8
7
|
import "../../libraries/SCY/SCYUtils.sol";
|
|
9
8
|
import "../../libraries/math/MarketApproxLib.sol";
|
|
@@ -93,9 +92,7 @@ contract ActionCallback is IPMarketSwapCallback, CallbackHelper {
|
|
|
93
92
|
/// ------------------------------------------------------------
|
|
94
93
|
SCYIndex scyIndex = SCY.newIndex();
|
|
95
94
|
uint256 ptOwed = ptToAccount.abs();
|
|
96
|
-
uint256 totalScyNeed = scyIndex.
|
|
97
|
-
// to guard against precision issue of lacking a few units of SCY. rawDivUp is not Fixed-Point division
|
|
98
|
-
totalScyNeed += SCYIndex.unwrap(scyIndex).rawDivUp(SCYUtils.ONE);
|
|
95
|
+
uint256 totalScyNeed = scyIndex.assetToScyUp(ptOwed);
|
|
99
96
|
|
|
100
97
|
/// ------------------------------------------------------------
|
|
101
98
|
/// calc netScyToPull
|
|
@@ -116,24 +113,26 @@ contract ActionCallback is IPMarketSwapCallback, CallbackHelper {
|
|
|
116
113
|
/// @dev refer to _swapExactYtForScy or _swapYtForExactScy
|
|
117
114
|
function _callbackSwapYtForScy(
|
|
118
115
|
address market,
|
|
119
|
-
int256
|
|
116
|
+
int256 ptToAccount,
|
|
120
117
|
int256 scyToAccount,
|
|
121
118
|
bytes calldata data
|
|
122
119
|
) internal {
|
|
123
120
|
(address receiver, uint256 minScyOut) = _decodeSwapYtForScy(data);
|
|
124
|
-
(, , IPYieldToken YT) = IPMarket(market).readTokens();
|
|
121
|
+
(ISuperComposableYield SCY, , IPYieldToken YT) = IPMarket(market).readTokens();
|
|
122
|
+
SCYIndex scyIndex = SCY.newIndex();
|
|
125
123
|
|
|
126
124
|
uint256 scyOwed = scyToAccount.neg().Uint();
|
|
127
125
|
|
|
128
126
|
address[] memory receivers = new address[](2);
|
|
129
|
-
uint256[] memory
|
|
130
|
-
|
|
131
|
-
(receivers[0], amounts[0]) = (market, scyOwed);
|
|
132
|
-
(receivers[1], amounts[1]) = (receiver, type(uint256).max);
|
|
127
|
+
uint256[] memory amountPYToRedeems = new uint256[](2);
|
|
133
128
|
|
|
134
|
-
|
|
135
|
-
|
|
129
|
+
(receivers[0], amountPYToRedeems[0]) = (market, scyIndex.scyToAssetUp(scyOwed));
|
|
130
|
+
(receivers[1], amountPYToRedeems[1]) = (
|
|
131
|
+
receiver,
|
|
132
|
+
ptToAccount.Uint() - amountPYToRedeems[0]
|
|
133
|
+
);
|
|
136
134
|
|
|
137
|
-
|
|
135
|
+
uint256[] memory amountScyOuts = YT.redeemPYMulti(receivers, amountPYToRedeems);
|
|
136
|
+
require(amountScyOuts[1] >= minScyOut, "insufficient SCY out");
|
|
138
137
|
}
|
|
139
138
|
}
|