@pendle/core-v2 0.7.1-beta-2 → 0.8.0-beta
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 +29 -2
- package/contracts/SuperComposableYield/base-implementations/SCYBase.sol +63 -41
- 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 +32 -62
- 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 +167 -140
- package/contracts/core/actions/ActionCallback.sol +11 -10
- package/contracts/core/actions/ActionCore.sol +84 -22
- package/contracts/core/actions/ActionYT.sol +33 -15
- package/contracts/core/actions/base/ActionSCYAndPTBase.sol +4 -15
- package/contracts/core/actions/base/ActionSCYAndPYBase.sol +20 -50
- package/contracts/core/actions/base/ActionSCYAndYTBase.sol +2 -12
- package/contracts/interfaces/IPActionCore.sol +72 -1
- package/contracts/interfaces/IPActionYT.sol +15 -0
- package/contracts/interfaces/IPMarket.sol +7 -26
- 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 +8 -0
- package/contracts/libraries/RewardManager.sol +9 -6
- package/contracts/libraries/RewardManagerAbstract.sol +6 -8
- package/contracts/libraries/SCY/SCYIndex.sol +10 -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/Math.sol +2 -4
- package/contracts/offchain-helpers/RouterStatic.sol +2 -2
- package/deployments/43113-core.json +11 -11
- package/deployments/43113-markets/benqi-market-0xF3150c14F776c50C9D397054d38979c7B77FC41D.json +7 -0
- package/deployments/80001-core.json +10 -10
- package/deployments/80001-markets/benqi-market-0x150b6eb90Bf636eC0c4328d13d1e1d4adDBAF904.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
|
@@ -17,25 +17,26 @@ abstract contract VotingControllerStorageUpg {
|
|
|
17
17
|
using EnumerableSet for EnumerableSet.AddressSet;
|
|
18
18
|
using Checkpoints for Checkpoints.History;
|
|
19
19
|
|
|
20
|
-
struct
|
|
20
|
+
struct PoolData {
|
|
21
21
|
uint64 chainId;
|
|
22
|
-
uint128
|
|
23
|
-
VeBalance
|
|
22
|
+
uint128 lastSlopeChangeAppliedAt;
|
|
23
|
+
VeBalance totalVote;
|
|
24
24
|
// wTime => slopeChange value
|
|
25
25
|
mapping(uint128 => uint128) slopeChanges;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
struct
|
|
28
|
+
struct UserPoolData {
|
|
29
29
|
uint64 weight;
|
|
30
30
|
VeBalance vote;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
struct UserData {
|
|
34
34
|
uint64 totalVotedWeight;
|
|
35
|
-
mapping(address =>
|
|
35
|
+
mapping(address => UserPoolData) voteForPools;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
struct WeekData {
|
|
39
|
+
bool isEpochFinalized;
|
|
39
40
|
uint128 totalVotes;
|
|
40
41
|
mapping(address => uint128) poolVotes;
|
|
41
42
|
}
|
|
@@ -47,27 +48,26 @@ abstract contract VotingControllerStorageUpg {
|
|
|
47
48
|
|
|
48
49
|
IPVeToken public immutable vePendle;
|
|
49
50
|
|
|
51
|
+
uint128 public immutable deployedWTime;
|
|
52
|
+
|
|
50
53
|
uint128 public pendlePerSec;
|
|
51
54
|
|
|
52
|
-
|
|
55
|
+
EnumerableSet.AddressSet internal allActivePools;
|
|
53
56
|
|
|
54
|
-
EnumerableSet.AddressSet internal
|
|
57
|
+
EnumerableSet.AddressSet internal allRemovedPools;
|
|
55
58
|
|
|
56
59
|
// [chainId] => [pool]
|
|
57
60
|
mapping(uint64 => EnumerableSet.AddressSet) internal chainPools;
|
|
58
61
|
|
|
59
|
-
// [poolAddress] ->
|
|
60
|
-
mapping(address =>
|
|
62
|
+
// [poolAddress] -> PoolData
|
|
63
|
+
mapping(address => PoolData) public poolData;
|
|
61
64
|
|
|
62
65
|
// [wTime] => WeekData
|
|
63
66
|
mapping(uint128 => WeekData) public weekData;
|
|
64
67
|
|
|
65
|
-
// user voting
|
|
68
|
+
// user voting data
|
|
66
69
|
mapping(address => UserData) public userData;
|
|
67
70
|
|
|
68
|
-
// wTime => bool
|
|
69
|
-
mapping(uint128 => bool) public isEpochFinalized;
|
|
70
|
-
|
|
71
71
|
// [user][pool] => checkpoint
|
|
72
72
|
mapping(address => mapping(address => Checkpoints.History)) internal userPoolHistory;
|
|
73
73
|
|
|
@@ -83,8 +83,19 @@ abstract contract VotingControllerStorageUpg {
|
|
|
83
83
|
//////////////////////////////////////////////////////////////*/
|
|
84
84
|
|
|
85
85
|
/// @dev trivial view function
|
|
86
|
-
function
|
|
87
|
-
return
|
|
86
|
+
function getAllAcitvePools() external view returns (address[] memory) {
|
|
87
|
+
return allActivePools.values();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/// @dev trivial view function
|
|
91
|
+
function getAllRemovedPools(uint256 start, uint256 end)
|
|
92
|
+
external
|
|
93
|
+
view
|
|
94
|
+
returns (uint256 lengthOfRemovedPools, address[] memory arr)
|
|
95
|
+
{
|
|
96
|
+
arr = new address[](end - start + 1);
|
|
97
|
+
for (uint256 i = start; i <= end; i++) arr[i] = allRemovedPools.at(i);
|
|
98
|
+
lengthOfRemovedPools = allRemovedPools.length();
|
|
88
99
|
}
|
|
89
100
|
|
|
90
101
|
/// @dev trivial view function
|
|
@@ -96,7 +107,7 @@ abstract contract VotingControllerStorageUpg {
|
|
|
96
107
|
function getUserPoolVote(address user, address pool)
|
|
97
108
|
external
|
|
98
109
|
view
|
|
99
|
-
returns (
|
|
110
|
+
returns (UserPoolData memory)
|
|
100
111
|
{
|
|
101
112
|
return userData[user].voteForPools[pool];
|
|
102
113
|
}
|
|
@@ -119,26 +130,30 @@ abstract contract VotingControllerStorageUpg {
|
|
|
119
130
|
|
|
120
131
|
/**
|
|
121
132
|
* @dev expected behavior:
|
|
122
|
-
- add to
|
|
123
|
-
- set params in
|
|
133
|
+
- add to allActivePools, chainPools
|
|
134
|
+
- set params in poolData
|
|
124
135
|
*/
|
|
125
136
|
function _addPool(uint64 chainId, address pool) internal {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
137
|
+
require(chainPools[chainId].add(pool), "IE");
|
|
138
|
+
require(allActivePools.add(pool), "IE");
|
|
139
|
+
|
|
140
|
+
poolData[pool].chainId = chainId;
|
|
141
|
+
poolData[pool].lastSlopeChangeAppliedAt = WeekMath.getCurrentWeekStart();
|
|
130
142
|
}
|
|
131
143
|
|
|
132
144
|
/**
|
|
133
145
|
* @dev expected behavior:
|
|
134
|
-
- remove from
|
|
135
|
-
-
|
|
146
|
+
- remove from allActivePool, chainPools
|
|
147
|
+
- add to allRemovedPools
|
|
148
|
+
- clear all params in poolData
|
|
136
149
|
*/
|
|
137
150
|
function _removePool(address pool) internal {
|
|
138
|
-
uint64 chainId =
|
|
139
|
-
require(chainPools[chainId].remove(pool), "IE
|
|
140
|
-
require(
|
|
141
|
-
|
|
151
|
+
uint64 chainId = poolData[pool].chainId;
|
|
152
|
+
require(chainPools[chainId].remove(pool), "IE");
|
|
153
|
+
require(allActivePools.remove(pool), "IE");
|
|
154
|
+
require(allRemovedPools.add(pool), "IE");
|
|
155
|
+
|
|
156
|
+
delete poolData[pool];
|
|
142
157
|
}
|
|
143
158
|
|
|
144
159
|
/**
|
|
@@ -154,70 +169,62 @@ abstract contract VotingControllerStorageUpg {
|
|
|
154
169
|
weekData[wTime].poolVotes[pool] = vote;
|
|
155
170
|
}
|
|
156
171
|
|
|
157
|
-
function
|
|
172
|
+
function _setNewVotePoolData(
|
|
158
173
|
address pool,
|
|
159
174
|
VeBalance memory vote,
|
|
160
175
|
uint128 wTime
|
|
161
176
|
) internal {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/// @dev only applicable for current pool, hence no changes for weekData
|
|
167
|
-
function _subtractVotePoolInfo(address pool, VeBalance memory vote) internal {
|
|
168
|
-
PoolInfo storage pInfo = poolInfo[pool];
|
|
169
|
-
pInfo.vote = poolInfo[pool].vote.sub(vote);
|
|
170
|
-
pInfo.slopeChanges[vote.getExpiry()] -= vote.slope;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/// @dev only applicable for current pool, hence no changes for weekData
|
|
174
|
-
function _addVotePoolInfo(address pool, VeBalance memory vote) internal {
|
|
175
|
-
PoolInfo storage pInfo = poolInfo[pool];
|
|
176
|
-
pInfo.vote = poolInfo[pool].vote.add(vote);
|
|
177
|
-
pInfo.slopeChanges[vote.getExpiry()] += vote.slope;
|
|
177
|
+
poolData[pool].totalVote = vote;
|
|
178
|
+
poolData[pool].lastSlopeChangeAppliedAt = wTime;
|
|
178
179
|
}
|
|
179
180
|
|
|
180
|
-
function
|
|
181
|
-
UserData storage uData = userData[user];
|
|
182
|
-
uData.totalVotedWeight -= uData.voteForPools[pool].weight;
|
|
183
|
-
delete uData.voteForPools[pool];
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/// @dev assumption: uData.voteForPools[pool] hasn't been set before
|
|
187
|
-
/// @dev post-condition: totalVotedWeight <= USER_VOTE_MAX_WEIGHT
|
|
188
|
-
function _setVoteUserData(
|
|
181
|
+
function _modifyVoteWeight(
|
|
189
182
|
address user,
|
|
190
183
|
address pool,
|
|
191
|
-
uint64 weight
|
|
192
|
-
|
|
193
|
-
) internal {
|
|
184
|
+
uint64 weight
|
|
185
|
+
) internal returns (VeBalance memory newVote) {
|
|
194
186
|
UserData storage uData = userData[user];
|
|
195
|
-
|
|
196
|
-
|
|
187
|
+
PoolData storage pData = poolData[pool];
|
|
188
|
+
|
|
189
|
+
VeBalance memory oldVote = uData.voteForPools[pool].vote;
|
|
190
|
+
|
|
191
|
+
// REMOVE OLD VOTE
|
|
192
|
+
if (oldVote.bias != 0) {
|
|
193
|
+
if (_isPoolActive(pool) && _isVoteActive(oldVote)) {
|
|
194
|
+
pData.totalVote = pData.totalVote.sub(oldVote);
|
|
195
|
+
pData.slopeChanges[oldVote.getExpiry()] -= oldVote.slope;
|
|
196
|
+
}
|
|
197
|
+
uData.totalVotedWeight -= uData.voteForPools[pool].weight;
|
|
198
|
+
delete uData.voteForPools[pool];
|
|
199
|
+
}
|
|
197
200
|
|
|
198
|
-
|
|
199
|
-
|
|
201
|
+
// ADD NEW VOTE
|
|
202
|
+
if (weight != 0) {
|
|
203
|
+
require(_isPoolActive(pool), "pool not active");
|
|
200
204
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
205
|
+
newVote = _getVotingPowerByWeight(user, weight);
|
|
206
|
+
|
|
207
|
+
pData.totalVote = pData.totalVote.add(newVote);
|
|
208
|
+
pData.slopeChanges[newVote.getExpiry()] += newVote.slope;
|
|
209
|
+
|
|
210
|
+
uData.voteForPools[pool] = UserPoolData(weight, newVote);
|
|
211
|
+
uData.totalVotedWeight += weight;
|
|
212
|
+
require(uData.totalVotedWeight <= USER_VOTE_MAX_WEIGHT, "exceeded max weight");
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
userPoolHistory[user][pool].push(newVote);
|
|
208
216
|
}
|
|
209
217
|
|
|
210
218
|
function _setAllPastEpochsAsFinalized() internal {
|
|
211
219
|
uint128 wTime = WeekMath.getCurrentWeekStart();
|
|
212
|
-
while (wTime >= deployedWTime &&
|
|
213
|
-
|
|
220
|
+
while (wTime >= deployedWTime && weekData[wTime].isEpochFinalized == false) {
|
|
221
|
+
weekData[wTime].isEpochFinalized = true;
|
|
214
222
|
wTime -= WEEK;
|
|
215
223
|
}
|
|
216
224
|
}
|
|
217
225
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
return poolInfo[pool].lastUpdated != 0;
|
|
226
|
+
function _isPoolActive(address pool) internal view returns (bool) {
|
|
227
|
+
return allActivePools.contains(pool);
|
|
221
228
|
}
|
|
222
229
|
|
|
223
230
|
/// @notice check if a vote still counts by checking if the vote is not (x,0) (in case the
|
|
@@ -225,4 +232,10 @@ abstract contract VotingControllerStorageUpg {
|
|
|
225
232
|
function _isVoteActive(VeBalance memory vote) internal view returns (bool) {
|
|
226
233
|
return vote.slope != 0 && !MiniHelpers.isCurrentlyExpired(vote.getExpiry());
|
|
227
234
|
}
|
|
235
|
+
|
|
236
|
+
function _getVotingPowerByWeight(address user, uint64 weight)
|
|
237
|
+
internal
|
|
238
|
+
view
|
|
239
|
+
virtual
|
|
240
|
+
returns (VeBalance memory res);
|
|
228
241
|
}
|
|
@@ -52,7 +52,7 @@ contract VotingEscrowPendleMainchain is IPVotingEscrow, VotingEscrowTokenBase, C
|
|
|
52
52
|
* @dev expected state changes:
|
|
53
53
|
- a new lock with amount = amountToPull + amountExpired, expiry = expiry is created for msg.sender in positionData
|
|
54
54
|
- pendle is taken in if necessary
|
|
55
|
-
- _totalSupply,
|
|
55
|
+
- _totalSupply, lastSlopeChangeAppliedAt, slopeChanges, totalSupplyAt is updated
|
|
56
56
|
- a checkpoint is added
|
|
57
57
|
* @dev broadcast is not bundled since it can be done anytime after
|
|
58
58
|
*/
|
|
@@ -87,13 +87,14 @@ contract VotingEscrowPendleMainchain is IPVotingEscrow, VotingEscrowTokenBase, C
|
|
|
87
87
|
* @dev expected state changes:
|
|
88
88
|
- positionData is cleared
|
|
89
89
|
- pendle is transferred out
|
|
90
|
-
- _totalSupply,
|
|
91
|
-
since these data will automatically hold true when
|
|
90
|
+
- _totalSupply, lastSlopeChangeAppliedAt, slopeChanges, totalSupplyAt all doesn't need to be updated
|
|
91
|
+
since these data will automatically hold true when _applySlopeChange() is called
|
|
92
92
|
- no checkpoint is added
|
|
93
93
|
* @dev broadcast is not bundled since it can be done anytime after
|
|
94
94
|
*/
|
|
95
|
-
function withdraw(
|
|
96
|
-
|
|
95
|
+
function withdraw() external returns (uint128 amount) {
|
|
96
|
+
address user = msg.sender;
|
|
97
|
+
require(_isPositionExpired(user), "position not expired");
|
|
97
98
|
amount = positionData[user].amount;
|
|
98
99
|
|
|
99
100
|
require(amount > 0, "zero position");
|
|
@@ -108,10 +109,10 @@ contract VotingEscrowPendleMainchain is IPVotingEscrow, VotingEscrowTokenBase, C
|
|
|
108
109
|
/**
|
|
109
110
|
* @notice update & return the current totalSupply
|
|
110
111
|
* @dev state changes expected:
|
|
111
|
-
- _totalSupply &
|
|
112
|
+
- _totalSupply & lastSlopeChangeAppliedAt is updated
|
|
112
113
|
*/
|
|
113
114
|
function totalSupplyCurrent() external virtual override returns (uint128) {
|
|
114
|
-
(VeBalance memory supply, ) =
|
|
115
|
+
(VeBalance memory supply, ) = _applySlopeChange();
|
|
115
116
|
return supply.getCurrentValue();
|
|
116
117
|
}
|
|
117
118
|
|
|
@@ -146,7 +147,7 @@ contract VotingEscrowPendleMainchain is IPVotingEscrow, VotingEscrowTokenBase, C
|
|
|
146
147
|
* @dev expected state changes:
|
|
147
148
|
- a new lock with the amount & expiry increase accordingly
|
|
148
149
|
- pendle is taken in if necessary
|
|
149
|
-
- _totalSupply,
|
|
150
|
+
- _totalSupply, lastSlopeChangeAppliedAt, slopeChanges, totalSupplyAt is updated
|
|
150
151
|
- a checkpoint is added
|
|
151
152
|
*/
|
|
152
153
|
function _increasePosition(
|
|
@@ -156,7 +157,7 @@ contract VotingEscrowPendleMainchain is IPVotingEscrow, VotingEscrowTokenBase, C
|
|
|
156
157
|
) internal returns (uint128) {
|
|
157
158
|
LockedPosition memory oldPosition = positionData[user];
|
|
158
159
|
|
|
159
|
-
(VeBalance memory newSupply, ) =
|
|
160
|
+
(VeBalance memory newSupply, ) = _applySlopeChange();
|
|
160
161
|
|
|
161
162
|
if (!MiniHelpers.isCurrentlyExpired(oldPosition.expiry)) {
|
|
162
163
|
// remove old position not yet expired
|
|
@@ -185,11 +186,11 @@ contract VotingEscrowPendleMainchain is IPVotingEscrow, VotingEscrowTokenBase, C
|
|
|
185
186
|
* @notice update the totalSupply, processing all slope changes of past weeks. At the same time, set the finalized
|
|
186
187
|
totalSupplyAt
|
|
187
188
|
* @dev state changes expected:
|
|
188
|
-
- _totalSupply,
|
|
189
|
+
- _totalSupply, lastSlopeChangeAppliedAt, totalSupplyAt is updated
|
|
189
190
|
*/
|
|
190
|
-
function
|
|
191
|
+
function _applySlopeChange() internal returns (VeBalance memory, uint128) {
|
|
191
192
|
VeBalance memory supply = _totalSupply;
|
|
192
|
-
uint128 wTime =
|
|
193
|
+
uint128 wTime = lastSlopeChangeAppliedAt;
|
|
193
194
|
uint128 currentWeekStart = WeekMath.getCurrentWeekStart();
|
|
194
195
|
|
|
195
196
|
if (wTime >= currentWeekStart) {
|
|
@@ -203,16 +204,16 @@ contract VotingEscrowPendleMainchain is IPVotingEscrow, VotingEscrowTokenBase, C
|
|
|
203
204
|
}
|
|
204
205
|
|
|
205
206
|
_totalSupply = supply;
|
|
206
|
-
|
|
207
|
+
lastSlopeChangeAppliedAt = wTime;
|
|
207
208
|
|
|
208
|
-
return (supply,
|
|
209
|
+
return (supply, lastSlopeChangeAppliedAt);
|
|
209
210
|
}
|
|
210
211
|
|
|
211
212
|
/// @notice broadcast position to all chains in chainIds
|
|
212
213
|
function _broadcastPosition(address user, uint256[] calldata chainIds) public payable {
|
|
213
214
|
require(chainIds.length != 0, "empty chainIds");
|
|
214
215
|
|
|
215
|
-
(VeBalance memory supply, uint256 wTime) =
|
|
216
|
+
(VeBalance memory supply, uint256 wTime) = _applySlopeChange();
|
|
216
217
|
|
|
217
218
|
bytes memory userData = (
|
|
218
219
|
user == address(0) ? EMPTY_BYTES : abi.encode(user, positionData[user])
|
|
@@ -230,7 +231,7 @@ contract VotingEscrowPendleMainchain is IPVotingEscrow, VotingEscrowTokenBase, C
|
|
|
230
231
|
}
|
|
231
232
|
|
|
232
233
|
function _afterAddSidechainContract(address, uint256 chainId) internal virtual override {
|
|
233
|
-
(VeBalance memory supply, uint256 wTime) =
|
|
234
|
+
(VeBalance memory supply, uint256 wTime) = _applySlopeChange();
|
|
234
235
|
_broadcast(chainId, wTime, supply, EMPTY_BYTES);
|
|
235
236
|
}
|
|
236
237
|
|
|
@@ -58,7 +58,7 @@ contract VotingEscrowPendleSidechain is VotingEscrowTokenBase, CelerReceiverUpg
|
|
|
58
58
|
|
|
59
59
|
function _setNewTotalSupply(uint128 wTime, VeBalance memory supply) internal {
|
|
60
60
|
assert(wTime == WeekMath.getWeekStartTimestamp(wTime));
|
|
61
|
-
|
|
61
|
+
lastSlopeChangeAppliedAt = wTime;
|
|
62
62
|
_totalSupply = supply;
|
|
63
63
|
emit SetNewTotalSupply(supply);
|
|
64
64
|
}
|
|
@@ -27,16 +27,15 @@ abstract contract VotingEscrowTokenBase is IPVeToken {
|
|
|
27
27
|
uint128 public constant MAX_LOCK_TIME = 104 weeks;
|
|
28
28
|
|
|
29
29
|
VeBalance internal _totalSupply;
|
|
30
|
-
uint128 public
|
|
30
|
+
uint128 public lastSlopeChangeAppliedAt;
|
|
31
31
|
|
|
32
32
|
mapping(address => LockedPosition) public positionData;
|
|
33
33
|
|
|
34
34
|
constructor() {
|
|
35
|
-
|
|
35
|
+
lastSlopeChangeAppliedAt = WeekMath.getCurrentWeekStart();
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
function balanceOf(address user) public view virtual returns (uint128) {
|
|
39
|
-
if (isPositionExpired(user)) return 0;
|
|
40
39
|
return positionData[user].convertToVeBalance().getCurrentValue();
|
|
41
40
|
}
|
|
42
41
|
|
|
@@ -46,7 +45,7 @@ abstract contract VotingEscrowTokenBase is IPVeToken {
|
|
|
46
45
|
|
|
47
46
|
function totalSupplyCurrent() external virtual returns (uint128);
|
|
48
47
|
|
|
49
|
-
function
|
|
48
|
+
function _isPositionExpired(address user) internal view returns (bool) {
|
|
50
49
|
return MiniHelpers.isCurrentlyExpired(positionData[user].expiry);
|
|
51
50
|
}
|
|
52
51
|
}
|
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
2
|
pragma solidity 0.8.15;
|
|
3
3
|
|
|
4
|
+
import "../PendleERC20.sol";
|
|
4
5
|
import "../../interfaces/IPPrincipalToken.sol";
|
|
5
6
|
import "../../interfaces/ISuperComposableYield.sol";
|
|
6
7
|
import "../../interfaces/IPMarket.sol";
|
|
7
8
|
import "../../interfaces/IPMarketFactory.sol";
|
|
8
9
|
import "../../interfaces/IPMarketSwapCallback.sol";
|
|
9
|
-
import "../../interfaces/IPMarketAddRemoveCallback.sol";
|
|
10
10
|
|
|
11
11
|
import "../../libraries/math/LogExpMath.sol";
|
|
12
12
|
import "../../libraries/math/Math.sol";
|
|
13
13
|
import "../../libraries/helpers/MiniHelpers.sol";
|
|
14
14
|
|
|
15
15
|
import "../LiquidityMining/PendleGauge.sol";
|
|
16
|
-
import "../
|
|
16
|
+
import "../PendleERC20Permit.sol";
|
|
17
17
|
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
/**
|
|
20
|
+
Invariances to maintain:
|
|
21
|
+
- Internal balances totalPt & totalScy not interferred by people transferring tokens in directly
|
|
22
|
+
- address(0) & address(this) should never have any rewards & activeBalance accounting done. This is
|
|
23
|
+
guaranteed by address(0) & address(this) check in each updateForTwo function
|
|
24
|
+
*/
|
|
22
25
|
contract PendleMarket is PendleERC20, PendleGauge, IPMarket {
|
|
23
26
|
using Math for uint256;
|
|
24
27
|
using Math for int256;
|
|
@@ -36,9 +39,6 @@ contract PendleMarket is PendleERC20, PendleGauge, IPMarket {
|
|
|
36
39
|
// 1 SLOT = 224 bits
|
|
37
40
|
}
|
|
38
41
|
|
|
39
|
-
uint8 private constant _NOT_ENTERED = 1;
|
|
40
|
-
uint8 private constant _ENTERED = 2;
|
|
41
|
-
|
|
42
42
|
string private constant NAME = "Pendle Market";
|
|
43
43
|
string private constant SYMBOL = "PENDLE-LPT";
|
|
44
44
|
|
|
@@ -81,29 +81,24 @@ contract PendleMarket is PendleERC20, PendleGauge, IPMarket {
|
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
83
|
* @notice PendleMarket allows users to provide in PT & SCY in exchange for LPs, which
|
|
84
|
-
* will grant LP holders more exchange fee over time
|
|
85
|
-
* this market prior to the call for LP to be minted. There is no flashAdd
|
|
86
|
-
* @param data bytes data to be sent in the callback
|
|
84
|
+
* will grant LP holders more exchange fee over time
|
|
87
85
|
*/
|
|
88
|
-
function
|
|
89
|
-
address receiver,
|
|
90
|
-
uint256 scyDesired,
|
|
91
|
-
uint256 ptDesired,
|
|
92
|
-
bytes calldata data
|
|
93
|
-
)
|
|
86
|
+
function mint(address receiver)
|
|
94
87
|
external
|
|
95
88
|
nonReentrant
|
|
96
89
|
notExpired
|
|
97
|
-
returns (
|
|
98
|
-
uint256 lpToAccount,
|
|
99
|
-
uint256 scyUsed,
|
|
100
|
-
uint256 ptUsed
|
|
101
|
-
)
|
|
90
|
+
returns (uint256 lpToAccount)
|
|
102
91
|
{
|
|
103
92
|
MarketState memory market = readState(true);
|
|
104
93
|
SCYIndex index = SCY.newIndex();
|
|
105
94
|
|
|
95
|
+
uint256 scyDesired = IERC20(SCY).balanceOf(address(this)) - market.totalScy.Uint();
|
|
96
|
+
uint256 ptDesired = IERC20(PT).balanceOf(address(this)) - market.totalPt.Uint();
|
|
97
|
+
|
|
106
98
|
uint256 lpToReserve;
|
|
99
|
+
uint256 scyUsed;
|
|
100
|
+
uint256 ptUsed;
|
|
101
|
+
|
|
107
102
|
(lpToReserve, lpToAccount, scyUsed, ptUsed) = market.addLiquidity(
|
|
108
103
|
index,
|
|
109
104
|
scyDesired,
|
|
@@ -121,39 +116,23 @@ contract PendleMarket is PendleERC20, PendleGauge, IPMarket {
|
|
|
121
116
|
|
|
122
117
|
_writeState(market);
|
|
123
118
|
|
|
124
|
-
|
|
125
|
-
require(market.totalScy.Uint() <= IERC20(SCY).balanceOf(address(this)));
|
|
126
|
-
|
|
127
|
-
emit AddLiquidity(receiver, lpToAccount, scyUsed, ptUsed);
|
|
128
|
-
|
|
129
|
-
// no flashAdd, we only do callback after all the tokens have been provided
|
|
130
|
-
if (data.length > 0) {
|
|
131
|
-
IPMarketAddRemoveCallback(msg.sender).addLiquidityCallback(
|
|
132
|
-
lpToAccount,
|
|
133
|
-
scyUsed,
|
|
134
|
-
ptUsed,
|
|
135
|
-
data
|
|
136
|
-
);
|
|
137
|
-
}
|
|
119
|
+
emit Mint(receiver, lpToAccount, scyUsed, ptUsed);
|
|
138
120
|
}
|
|
139
121
|
|
|
140
122
|
/**
|
|
141
123
|
* @notice LP Holders can burn their LP to receive back SCY & PT proportionally
|
|
142
124
|
* to their share of market
|
|
143
|
-
* @dev steps working of this contract
|
|
144
|
-
- SCY & PT will be first transferred out to receiver
|
|
145
|
-
- Callback to msg.sender if data.length > 0
|
|
146
|
-
- Ensure the corresponding amount of LP has been transferred to this contract
|
|
147
|
-
* @param data bytes data to be sent in the callback
|
|
148
125
|
*/
|
|
149
|
-
function
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
uint256
|
|
153
|
-
|
|
154
|
-
) external nonReentrant returns (uint256 scyToAccount, uint256 ptToAccount) {
|
|
126
|
+
function burn(address receiverScy, address receiverPt)
|
|
127
|
+
external
|
|
128
|
+
nonReentrant
|
|
129
|
+
returns (uint256 scyToAccount, uint256 ptToAccount)
|
|
130
|
+
{
|
|
155
131
|
MarketState memory market = readState(true);
|
|
156
132
|
|
|
133
|
+
uint256 lpToRemove = balanceOf(address(this));
|
|
134
|
+
_burn(address(this), lpToRemove);
|
|
135
|
+
|
|
157
136
|
(scyToAccount, ptToAccount) = market.removeLiquidity(lpToRemove, true);
|
|
158
137
|
|
|
159
138
|
IERC20(SCY).safeTransfer(receiverScy, scyToAccount);
|
|
@@ -161,19 +140,7 @@ contract PendleMarket is PendleERC20, PendleGauge, IPMarket {
|
|
|
161
140
|
|
|
162
141
|
_writeState(market);
|
|
163
142
|
|
|
164
|
-
|
|
165
|
-
IPMarketAddRemoveCallback(msg.sender).removeLiquidityCallback(
|
|
166
|
-
lpToRemove,
|
|
167
|
-
scyToAccount,
|
|
168
|
-
ptToAccount,
|
|
169
|
-
data
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
// this checks enough lp has been transferred in
|
|
174
|
-
_burn(address(this), lpToRemove);
|
|
175
|
-
|
|
176
|
-
emit RemoveLiquidity(receiverScy, receiverPt, lpToRemove, scyToAccount, ptToAccount);
|
|
143
|
+
emit Burn(receiverScy, receiverPt, lpToRemove, scyToAccount, ptToAccount);
|
|
177
144
|
}
|
|
178
145
|
|
|
179
146
|
/**
|
|
@@ -209,7 +176,7 @@ contract PendleMarket is PendleERC20, PendleGauge, IPMarket {
|
|
|
209
176
|
}
|
|
210
177
|
|
|
211
178
|
// have received enough PT
|
|
212
|
-
require(market.totalPt.Uint() <= IERC20(PT).balanceOf(address(this)));
|
|
179
|
+
require(market.totalPt.Uint() <= IERC20(PT).balanceOf(address(this)), "insufficient PT");
|
|
213
180
|
|
|
214
181
|
emit Swap(receiver, exactPtIn.neg(), netScyOut.Int(), netScyToReserve);
|
|
215
182
|
}
|
|
@@ -246,7 +213,10 @@ contract PendleMarket is PendleERC20, PendleGauge, IPMarket {
|
|
|
246
213
|
}
|
|
247
214
|
|
|
248
215
|
// have received enough SCY
|
|
249
|
-
require(
|
|
216
|
+
require(
|
|
217
|
+
market.totalScy.Uint() <= IERC20(SCY).balanceOf(address(this)),
|
|
218
|
+
"insufficient SCY"
|
|
219
|
+
);
|
|
250
220
|
|
|
251
221
|
emit Swap(receiver, exactPtOut.Int(), netScyIn.neg(), netScyToReserve);
|
|
252
222
|
}
|
|
@@ -56,7 +56,7 @@ contract PendleRouter is Proxy, Initializable, UUPSUpgradeable, PermissionsV2Upg
|
|
|
56
56
|
sig == IPActionCore.swapExactScyForPt.selector ||
|
|
57
57
|
sig == IPActionCore.swapExactRawTokenForPt.selector ||
|
|
58
58
|
sig == IPActionCore.swapExactPtForRawToken.selector ||
|
|
59
|
-
sig == IPActionCore.
|
|
59
|
+
sig == IPActionCore.redeemDueInterestAndRewards.selector
|
|
60
60
|
) {
|
|
61
61
|
return ACTION_CORE;
|
|
62
62
|
} else if (
|
|
@@ -37,10 +37,11 @@ abstract contract InterestManagerYT is TokenHelper, IPInterestManagerYT {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
function _distributeInterestForTwo(address user1, address user2) internal {
|
|
40
|
-
// no updateRewardIndex since we rely on SCY's rewardIndexes
|
|
41
40
|
uint256 index = _getInterestIndex();
|
|
42
|
-
if (user1 != address(0) && user1 != address(this))
|
|
43
|
-
|
|
41
|
+
if (user1 != address(0) && user1 != address(this))
|
|
42
|
+
_distributeInterestPrivate(user1, index);
|
|
43
|
+
if (user2 != address(0) && user2 != address(this))
|
|
44
|
+
_distributeInterestPrivate(user2, index);
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
function _doTransferOutInterest(
|
|
@@ -48,13 +49,12 @@ abstract contract InterestManagerYT is TokenHelper, IPInterestManagerYT {
|
|
|
48
49
|
address SCY,
|
|
49
50
|
address factory
|
|
50
51
|
) internal returns (uint256 interestAmount) {
|
|
51
|
-
uint256 interestPreFee = userInterest[user].accrued;
|
|
52
|
-
userInterest[user].accrued = 0;
|
|
53
|
-
|
|
54
52
|
address treasury = IPYieldContractFactory(factory).treasury();
|
|
55
|
-
|
|
56
53
|
uint256 feeRate = IPYieldContractFactory(factory).interestFeeRate();
|
|
57
54
|
|
|
55
|
+
uint256 interestPreFee = userInterest[user].accrued;
|
|
56
|
+
userInterest[user].accrued = 0;
|
|
57
|
+
|
|
58
58
|
uint256 feeAmount = interestPreFee.mulDown(feeRate);
|
|
59
59
|
interestAmount = interestPreFee - feeAmount;
|
|
60
60
|
|
|
@@ -62,7 +62,10 @@ abstract contract InterestManagerYT is TokenHelper, IPInterestManagerYT {
|
|
|
62
62
|
_transferOut(SCY, user, interestAmount);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
// should only be callable from `_distributeInterestForTwo` & make sure user != address(0) && user != address(this)
|
|
66
|
+
function _distributeInterestPrivate(address user, uint256 currentIndex) private {
|
|
67
|
+
assert(user != address(0) && user != address(this));
|
|
68
|
+
|
|
66
69
|
uint256 prevIndex = userInterest[user].index;
|
|
67
70
|
|
|
68
71
|
if (prevIndex == currentIndex) return;
|
|
@@ -4,11 +4,11 @@ pragma solidity 0.8.15;
|
|
|
4
4
|
import "../../interfaces/IPPrincipalToken.sol";
|
|
5
5
|
import "../../interfaces/IPYieldToken.sol";
|
|
6
6
|
|
|
7
|
-
import "../
|
|
7
|
+
import "../PendleERC20Permit.sol";
|
|
8
8
|
import "../../libraries/helpers/MiniHelpers.sol";
|
|
9
9
|
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
|
10
10
|
|
|
11
|
-
contract PendlePrincipalToken is
|
|
11
|
+
contract PendlePrincipalToken is PendleERC20Permit, Initializable, IPPrincipalToken {
|
|
12
12
|
address public immutable SCY;
|
|
13
13
|
address public immutable factory;
|
|
14
14
|
uint256 public immutable expiry;
|
|
@@ -30,7 +30,7 @@ contract PendlePrincipalToken is PendleERC20, Initializable, IPPrincipalToken {
|
|
|
30
30
|
string memory _symbol,
|
|
31
31
|
uint8 __decimals,
|
|
32
32
|
uint256 _expiry
|
|
33
|
-
)
|
|
33
|
+
) PendleERC20Permit(_name, _symbol, __decimals) {
|
|
34
34
|
SCY = _SCY;
|
|
35
35
|
expiry = _expiry;
|
|
36
36
|
factory = msg.sender;
|