@pendle/core-v2 0.11.2-testnet → 0.11.3-testnet
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/AaveV3/PendleAaveV3SCY.sol/PendleAaveV3SCY.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/AaveV3/PendleAaveV3SCY.sol/PendleAaveV3SCY.json +2 -2
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/AaveV3/WadRayMath.sol/WadRayMath.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiSAvaxSCY.sol/PendleQiSAvaxSCY.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiSAvaxSCY.sol/PendleQiSAvaxSCY.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/PendleQiTokenSCY.sol/PendleQiTokenSCY.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenSCY.sol/PendleQiTokenSCY.json +2 -2
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleSAvaxSCY.sol/PendleSAvaxSCY.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleSAvaxSCY.sol/PendleSAvaxSCY.json +2 -2
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/Euler/PendleEulerSCY.sol/PendleEulerSCY.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/Euler/PendleEulerSCY.sol/PendleEulerSCY.json +2 -2
- 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 +2 -2
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleStargateSCY.sol/PendleStargateSCY.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleStargateSCY.sol/PendleStargateSCY.json +2 -2
- 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 +2 -2
- 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 +2 -2
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/TraderJoe/PendleSJoeSCY.sol/PendleSJoeSCY.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/TraderJoe/PendleSJoeSCY.sol/PendleSJoeSCY.json +2 -2
- package/build/artifacts/contracts/SuperComposableYield/base-implementations/SCYBase.sol/SCYBase.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/base-implementations/SCYBaseWithRewards.sol/SCYBaseWithRewards.dbg.json +1 -1
- 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/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.json +2 -2
- package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.json +2 -2
- package/build/artifacts/contracts/core/LiquidityMining/PendleGauge.sol/PendleGauge.dbg.json +1 -1
- 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 +14 -62
- package/build/artifacts/contracts/core/LiquidityMining/VotingController/VotingControllerStorageUpg.sol/VotingControllerStorageUpg.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/VotingController/VotingControllerStorageUpg.sol/VotingControllerStorageUpg.json +12 -192
- 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 +8 -51
- 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 +2 -2
- 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/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/PendleYieldContractFactory.sol/PendleYieldContractFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.json +2 -2
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.json +2 -2
- package/build/artifacts/contracts/core/actions/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.json +2 -2
- 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/ActionMintRedeem.sol/ActionMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/ActionMintRedeem.sol/ActionMintRedeem.json +173 -2
- package/build/artifacts/contracts/core/actions/ActionMisc.sol/ActionMisc.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/ActionMisc.sol/ActionMisc.json +2 -2
- package/build/artifacts/contracts/core/actions/ActionSwapPT.sol/ActionSwapPT.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/ActionSwapPT.sol/ActionSwapPT.json +2 -2
- package/build/artifacts/contracts/core/actions/ActionSwapYT.sol/ActionSwapYT.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/ActionSwapYT.sol/ActionSwapYT.json +2 -2
- package/build/artifacts/contracts/core/actions/base/ActionBaseMintRedeem.sol/ActionBaseMintRedeem.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/IEulerEToken.sol/IEulerEToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IEulerMarkets.sol/IEulerMarkets.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.json +171 -0
- package/build/artifacts/contracts/interfaces/IPActionMisc.sol/IPActionMisc.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.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 +171 -0
- package/build/artifacts/contracts/interfaces/IPGauge.sol/IPGauge.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPGauge.sol/IPGauge.json +19 -0
- 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/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 +19 -0
- 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/IPPrincipalToken.sol/IPPrincipalToken.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/IPVotingController.sol/IPVotingController.json +0 -124
- package/build/artifacts/contracts/interfaces/IPVotingEscrow.sol/IPVotingEscrow.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPVotingEscrow.sol/IPVotingEscrow.json +0 -86
- package/build/artifacts/contracts/interfaces/IPYieldContractFactory.sol/IPYieldContractFactory.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPYieldToken.sol/IPYieldToken.dbg.json +1 -1
- 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/IRewardManager.sol/IRewardManager.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ISAvax.sol/ISAvax.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ISJoe.sol/ISJoe.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IStETH.sol/IStETH.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IStargateLPStaking.sol/IStargateLPStaking.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IStargatePool.sol/IStargatePool.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IStargateRouter.sol/IStargateRouter.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ISuperComposableYield.sol/ISuperComposableYield.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IWAvax.sol/IWAvax.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IWETH.sol/IWETH.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/OracleLib.sol/OracleLib.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/SCYUtils.sol/SCYUtils.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/VeBalanceLib.sol/VeBalanceLib.dbg.json +1 -1
- 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/ExpiryUtilsLib.sol/ExpiryUtils.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/helpers/MiniHelpers.sol/MiniHelpers.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/helpers/PYIndex.sol/PYIndexLib.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/helpers/SSTORE2Deployer.sol/SSTORE2Deployer.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/helpers/TokenHelper.sol/TokenHelper.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/kyberswap/KyberSwapHelper.sol/KyberSwapHelper.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/math/LogExpMath.sol/LogExpMath.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/math/MarketApproxLib.sol/MarketApproxPtInLib.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/math/MarketApproxLib.sol/MarketApproxPtOutLib.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/math/MarketMathCore.sol/MarketMathCore.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/math/Math.sol/Math.dbg.json +1 -1
- 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/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.json +2 -2
- 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/BoringOwnableUpgradeable.sol/BoringOwnableUpgradeable.dbg.json +1 -1
- package/build/artifacts/contracts/periphery/BoringOwnableUpgradeable.sol/BoringOwnableUpgradeableData.dbg.json +1 -1
- package/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol +1 -1
- package/contracts/core/LiquidityMining/PendleGauge.sol +1 -1
- package/contracts/core/LiquidityMining/VotingController/PendleVotingControllerUpg.sol +1 -2
- package/contracts/core/Market/PendleMarketFactory.sol +11 -16
- package/contracts/core/PendleRouter.sol +1 -3
- package/contracts/core/YieldContracts/PendlePrincipalToken.sol +1 -1
- package/contracts/core/YieldContracts/PendleYieldContractFactory.sol +5 -5
- package/contracts/core/actions/ActionMintRedeem.sol +141 -0
- package/contracts/core/actions/base/ActionBaseMintRedeem.sol +0 -1
- package/contracts/interfaces/IPActionMintRedeem.sol +43 -0
- package/contracts/interfaces/IPGaugeController.sol +1 -1
- package/contracts/interfaces/IPMarketFactory.sol +1 -1
- package/contracts/interfaces/ISJoe.sol +3 -6
- package/contracts/libraries/helpers/PYIndex.sol +9 -0
- package/contracts/libraries/helpers/TokenHelper.sol +33 -24
- package/contracts/libraries/kyberswap/AggregationRouterHelper.sol +308 -0
- package/contracts/libraries/kyberswap/IMultihopRouter.sol +139 -0
- package/contracts/libraries/kyberswap/KyberSwapHelper.sol +7 -1
- package/contracts/libraries/math/MarketMathCore.sol +3 -1
- package/contracts/offchain-helpers/RouterStatic.sol +5 -5
- package/contracts/offchain-helpers/SSTORE2DeployerContract.sol +21 -0
- package/contracts/periphery/BoringOwnableUpgradeable.sol +2 -2
- package/deployments/43113-core.json +1 -1
- package/package.json +4 -5
- package/typechain-types/ActionMintRedeem.ts +172 -0
- package/typechain-types/AggregationRouterHelper.ts +108 -0
- package/typechain-types/ERC1967Upgrade.ts +97 -0
- package/typechain-types/EpochResultManager.ts +261 -0
- package/typechain-types/FeeDistributorVePendle.ts +3 -224
- package/typechain-types/IBeacon.ts +87 -0
- package/typechain-types/IBoringOwnableUpgradeable.ts +114 -0
- package/typechain-types/IERC1822Proxiable.ts +87 -0
- package/typechain-types/IMultihopRouter.ts +209 -0
- package/typechain-types/IPActionMintRedeem.ts +172 -0
- package/typechain-types/IPAllAction.ts +172 -0
- package/typechain-types/IPFeeDistributor.ts +24 -81
- package/typechain-types/IPFeeDistributorFactory.ts +187 -0
- package/typechain-types/IPGauge.ts +25 -0
- package/typechain-types/IPMarket.ts +25 -0
- package/typechain-types/IPVotingController.ts +7 -205
- package/typechain-types/IPVotingEscrow.ts +0 -117
- package/typechain-types/PendleFeeDistributor.ts +483 -0
- package/typechain-types/PendleFeeDistributorFactory.ts +466 -0
- package/typechain-types/PendleVotingControllerUpg.ts +24 -73
- package/typechain-types/SSTORE2DeployerContract.ts +242 -0
- package/typechain-types/VotingControllerStorageUpg.ts +27 -207
- package/typechain-types/VotingEscrowPendleMainchain.ts +13 -57
- package/typechain-types/factories/ActionAddRemoveLiq__factory.ts +1 -1
- package/typechain-types/factories/ActionCallback__factory.ts +1 -1
- package/typechain-types/factories/ActionMintRedeem__factory.ts +172 -1
- package/typechain-types/factories/ActionMisc__factory.ts +1 -1
- package/typechain-types/factories/ActionSwapPT__factory.ts +1 -1
- package/typechain-types/factories/ActionSwapYT__factory.ts +1 -1
- package/typechain-types/factories/AggregationRouterHelper__factory.ts +92 -0
- package/typechain-types/factories/ERC1967Upgrade__factory.ts +71 -0
- package/typechain-types/factories/EpochResultManager__factory.ts +146 -0
- package/typechain-types/factories/FeeDistributorVePendle__factory.ts +1 -154
- package/typechain-types/factories/IBeacon__factory.ts +36 -0
- package/typechain-types/factories/IBoringOwnableUpgradeable__factory.ts +53 -0
- package/typechain-types/factories/IERC1822Proxiable__factory.ts +39 -0
- package/typechain-types/factories/IMultihopRouter__factory.ts +151 -0
- package/typechain-types/factories/IPActionMintRedeem__factory.ts +171 -0
- package/typechain-types/factories/IPAllAction__factory.ts +171 -0
- package/typechain-types/factories/IPFeeDistributorFactory__factory.ts +95 -0
- package/typechain-types/factories/IPFeeDistributor__factory.ts +8 -42
- package/typechain-types/factories/IPGauge__factory.ts +19 -0
- package/typechain-types/factories/IPMarket__factory.ts +19 -0
- package/typechain-types/factories/IPVotingController__factory.ts +0 -124
- package/typechain-types/factories/IPVotingEscrow__factory.ts +0 -86
- package/typechain-types/factories/MarketMathStatic__factory.ts +1 -1
- package/typechain-types/factories/PendleAaveV3SCY__factory.ts +1 -1
- package/typechain-types/factories/PendleERC4626SCY__factory.ts +1 -1
- package/typechain-types/factories/PendleEulerSCY__factory.ts +1 -1
- package/typechain-types/factories/PendleFeeDistributorFactory__factory.ts +355 -0
- package/typechain-types/factories/PendleFeeDistributor__factory.ts +390 -0
- package/typechain-types/factories/PendleGaugeControllerMainchainUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleGaugeControllerSidechainUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleMarketFactory__factory.ts +1 -1
- package/typechain-types/factories/PendleMarket__factory.ts +1 -1
- package/typechain-types/factories/PendleQiSAvaxSCY__factory.ts +1 -1
- package/typechain-types/factories/PendleQiTokenSCY__factory.ts +1 -1
- package/typechain-types/factories/PendleRouter__factory.ts +1 -1
- package/typechain-types/factories/PendleSAvaxSCY__factory.ts +1 -1
- package/typechain-types/factories/PendleSJoeSCY__factory.ts +1 -1
- package/typechain-types/factories/PendleStargateSCY__factory.ts +1 -1
- package/typechain-types/factories/PendleVotingControllerUpg__factory.ts +13 -61
- package/typechain-types/factories/PendleWstEthSCY__factory.ts +1 -1
- package/typechain-types/factories/PendleYearnVaultSCY__factory.ts +1 -1
- package/typechain-types/factories/PendleYieldContractFactory__factory.ts +1 -1
- package/typechain-types/factories/PendleYieldToken__factory.ts +1 -1
- package/typechain-types/factories/RouterStatic__factory.ts +1 -1
- package/typechain-types/factories/SSTORE2DeployerContract__factory.ts +191 -0
- package/typechain-types/factories/VotingControllerStorageUpg__factory.ts +12 -192
- package/typechain-types/factories/VotingEscrowPendleMainchain__factory.ts +7 -50
- package/typechain-types/factories/VotingEscrowPendleSidechain__factory.ts +1 -1
- package/typechain-types/hardhat.d.ts +36 -54
- package/typechain-types/index.ts +6 -12
- package/build/artifacts/contracts/core/LiquidityMining/FeeDistributor/FeeDistributorVePendle.sol/FeeDistributorVePendle.dbg.json +0 -4
- package/build/artifacts/contracts/core/LiquidityMining/FeeDistributor/FeeDistributorVePendle.sol/FeeDistributorVePendle.json +0 -188
- package/build/artifacts/contracts/core/LiquidityMining/FeeDistributor/PendleFeeDistributorAbstract.sol/PendleFeeDistributorAbstract.dbg.json +0 -4
- package/build/artifacts/contracts/core/LiquidityMining/FeeDistributor/PendleFeeDistributorAbstract.sol/PendleFeeDistributorAbstract.json +0 -164
- package/build/artifacts/contracts/core/LiquidityMining/FeeDistributor/PendleFeeDistributorVoting.sol/PendleFeeDistributorVoting.dbg.json +0 -4
- package/build/artifacts/contracts/core/LiquidityMining/FeeDistributor/PendleFeeDistributorVoting.sol/PendleFeeDistributorVoting.json +0 -206
- package/build/artifacts/contracts/core/LiquidityMining/FeeDistributor/PendleFeeDistributorVotingFactory.sol/PendleFeeDistributorVotingFactory.dbg.json +0 -4
- package/build/artifacts/contracts/core/LiquidityMining/FeeDistributor/PendleFeeDistributorVotingFactory.sol/PendleFeeDistributorVotingFactory.json +0 -149
- package/build/artifacts/contracts/interfaces/IPFeeDistributor.sol/IPFeeDistributor.dbg.json +0 -4
- package/build/artifacts/contracts/interfaces/IPFeeDistributor.sol/IPFeeDistributor.json +0 -151
- package/contracts/periphery/PendleGovernanceManager.sol +0 -38
- package/contracts/periphery/PermissionsV2Upg.sol +0 -29
|
@@ -120,5 +120,146 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
120
120
|
for (uint256 i = 0; i < markets.length; ++i) {
|
|
121
121
|
marketRewards[i] = IPMarket(markets[i]).redeemRewards(user);
|
|
122
122
|
}
|
|
123
|
+
emit RedeemDueInterestAndRewards(
|
|
124
|
+
user,
|
|
125
|
+
scys,
|
|
126
|
+
yts,
|
|
127
|
+
markets,
|
|
128
|
+
scyRewards,
|
|
129
|
+
ytInterests,
|
|
130
|
+
ytRewards,
|
|
131
|
+
marketRewards
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
struct RouterTokenAmounts {
|
|
136
|
+
address[] tokens;
|
|
137
|
+
uint256[] amounts;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function redeemDueInterestAndRewardsThenSwapAll(
|
|
141
|
+
address[] calldata scys,
|
|
142
|
+
RouterYtRedeemStruct calldata dataYT,
|
|
143
|
+
address[] calldata markets,
|
|
144
|
+
RouterSwapAllStruct calldata dataSwap
|
|
145
|
+
) external returns (uint256 netTokenOut, uint256[] memory amountsSwapped) {
|
|
146
|
+
require(dataSwap.tokens.length == dataSwap.kybercalls.length, "invalid dataSwap");
|
|
147
|
+
require(dataYT.tokenRedeemScys.length == dataYT.scyAddrs.length, "invalid dataYT");
|
|
148
|
+
|
|
149
|
+
RouterTokenAmounts memory tokensOut = _newRouterTokenAmounts(dataSwap.tokens);
|
|
150
|
+
RouterTokenAmounts memory scysOut = _newRouterTokenAmounts(dataYT.scyAddrs);
|
|
151
|
+
|
|
152
|
+
// redeem SCY
|
|
153
|
+
for (uint256 i = 0; i < scys.length; ++i) {
|
|
154
|
+
ISuperComposableYield SCY = ISuperComposableYield(scys[i]);
|
|
155
|
+
|
|
156
|
+
address[] memory rewardTokens = SCY.getRewardTokens();
|
|
157
|
+
uint256[] memory rewardAmounts = SCY.claimRewards(msg.sender);
|
|
158
|
+
_addTokenAmounts(tokensOut, rewardTokens, rewardAmounts);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// redeem YT
|
|
162
|
+
for (uint256 i = 0; i < dataYT.yts.length; ++i) {
|
|
163
|
+
IPYieldToken YT = IPYieldToken(dataYT.yts[i]);
|
|
164
|
+
|
|
165
|
+
(uint256 interestAmount, uint256[] memory rewardAmounts) = YT
|
|
166
|
+
.redeemDueInterestAndRewards(msg.sender, true, true);
|
|
167
|
+
|
|
168
|
+
address scyAddr = YT.SCY();
|
|
169
|
+
address[] memory rewardTokens = YT.getRewardTokens();
|
|
170
|
+
|
|
171
|
+
_addTokenAmount(scysOut, scyAddr, interestAmount);
|
|
172
|
+
_addTokenAmounts(tokensOut, rewardTokens, rewardAmounts);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// redeem market
|
|
176
|
+
for (uint256 i = 0; i < markets.length; ++i) {
|
|
177
|
+
IPMarket market = IPMarket(markets[i]);
|
|
178
|
+
|
|
179
|
+
address[] memory rewardTokens = market.getRewardTokens();
|
|
180
|
+
uint256[] memory rewardAmounts = market.redeemRewards(msg.sender);
|
|
181
|
+
_addTokenAmounts(tokensOut, rewardTokens, rewardAmounts);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// guaranteed no ETH, all rewards are ERC20
|
|
185
|
+
_transferFrom(tokensOut.tokens, msg.sender, address(this), tokensOut.amounts);
|
|
186
|
+
_redeemAllScys(scysOut, dataYT.tokenRedeemScys, tokensOut);
|
|
187
|
+
|
|
188
|
+
// now swap all to outputToken
|
|
189
|
+
netTokenOut = _swapAllToOutputToken(tokensOut, dataSwap);
|
|
190
|
+
amountsSwapped = tokensOut.amounts;
|
|
191
|
+
|
|
192
|
+
emit RedeemDueInterestAndRewardsThenSwapAll(
|
|
193
|
+
msg.sender,
|
|
194
|
+
scys,
|
|
195
|
+
dataYT.yts,
|
|
196
|
+
markets,
|
|
197
|
+
dataSwap.outputToken,
|
|
198
|
+
netTokenOut
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function _newRouterTokenAmounts(address[] memory tokens)
|
|
203
|
+
internal
|
|
204
|
+
pure
|
|
205
|
+
returns (RouterTokenAmounts memory)
|
|
206
|
+
{
|
|
207
|
+
return RouterTokenAmounts(tokens, new uint256[](tokens.length));
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/// @dev pull SCYs from users & redeem them, then add to tokensOut
|
|
211
|
+
function _redeemAllScys(
|
|
212
|
+
RouterTokenAmounts memory scys,
|
|
213
|
+
address[] calldata tokenRedeemScys,
|
|
214
|
+
RouterTokenAmounts memory tokensOut
|
|
215
|
+
) internal {
|
|
216
|
+
for (uint256 i = 0; i < scys.tokens.length; ++i) {
|
|
217
|
+
if (scys.amounts[i] == 0) continue;
|
|
218
|
+
|
|
219
|
+
_transferFrom(scys.tokens[i], msg.sender, scys.tokens[i], scys.amounts[i]);
|
|
220
|
+
uint256 amountOut = ISuperComposableYield(scys.tokens[i]).redeemAfterTransfer(
|
|
221
|
+
address(this),
|
|
222
|
+
tokenRedeemScys[i],
|
|
223
|
+
1
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
_addTokenAmount(tokensOut, tokenRedeemScys[i], amountOut);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function _swapAllToOutputToken(
|
|
231
|
+
RouterTokenAmounts memory tokens,
|
|
232
|
+
RouterSwapAllStruct memory dataSwap
|
|
233
|
+
) internal returns (uint256 netTokenOut) {
|
|
234
|
+
for (uint256 i = 0; i < tokens.tokens.length; ++i) {
|
|
235
|
+
if (tokens.amounts[i] == 0) continue;
|
|
236
|
+
_kyberswap(tokens.tokens[i], tokens.amounts[i], dataSwap.kybercalls[i]);
|
|
237
|
+
}
|
|
238
|
+
netTokenOut = _selfBalance(dataSwap.outputToken);
|
|
239
|
+
_transferOut(dataSwap.outputToken, msg.sender, netTokenOut);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function _addTokenAmount(
|
|
243
|
+
RouterTokenAmounts memory data,
|
|
244
|
+
address token,
|
|
245
|
+
uint256 amount
|
|
246
|
+
) internal pure {
|
|
247
|
+
for (uint256 j = 0; j < data.tokens.length; j++) {
|
|
248
|
+
if (data.tokens[j] == token) {
|
|
249
|
+
data.amounts[j] += amount;
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
revert("token not found");
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function _addTokenAmounts(
|
|
257
|
+
RouterTokenAmounts memory data,
|
|
258
|
+
address[] memory tokens,
|
|
259
|
+
uint256[] memory amounts
|
|
260
|
+
) internal pure {
|
|
261
|
+
for (uint256 i = 0; i < tokens.length; i++) {
|
|
262
|
+
_addTokenAmount(data, tokens[i], amounts[i]);
|
|
263
|
+
}
|
|
123
264
|
}
|
|
124
265
|
}
|
|
@@ -68,7 +68,6 @@ abstract contract ActionBaseMintRedeem is TokenHelper, KyberSwapHelper {
|
|
|
68
68
|
output.tokenRedeemScy,
|
|
69
69
|
1
|
|
70
70
|
);
|
|
71
|
-
_safeApproveInf(output.tokenRedeemScy, SCY);
|
|
72
71
|
_kyberswap(output.tokenRedeemScy, netTokenRedeemed, output.kybercall);
|
|
73
72
|
|
|
74
73
|
netTokenOut = _selfBalance(output.tokenOut);
|
|
@@ -57,6 +57,26 @@ interface IPActionMintRedeem {
|
|
|
57
57
|
uint256 netTokenOut
|
|
58
58
|
);
|
|
59
59
|
|
|
60
|
+
event RedeemDueInterestAndRewards(
|
|
61
|
+
address indexed user,
|
|
62
|
+
address[] scys,
|
|
63
|
+
address[] yts,
|
|
64
|
+
address[] markets,
|
|
65
|
+
uint256[][] scyRewards,
|
|
66
|
+
uint256[] ytInterests,
|
|
67
|
+
uint256[][] ytRewards,
|
|
68
|
+
uint256[][] marketRewards
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
event RedeemDueInterestAndRewardsThenSwapAll(
|
|
72
|
+
address indexed user,
|
|
73
|
+
address[] scys,
|
|
74
|
+
address[] yts,
|
|
75
|
+
address[] markets,
|
|
76
|
+
address indexed tokenOut,
|
|
77
|
+
uint256 netTokenOut
|
|
78
|
+
);
|
|
79
|
+
|
|
60
80
|
function mintScyFromToken(
|
|
61
81
|
address receiver,
|
|
62
82
|
address SCY,
|
|
@@ -112,4 +132,27 @@ interface IPActionMintRedeem {
|
|
|
112
132
|
uint256[][] memory ytRewards,
|
|
113
133
|
uint256[][] memory marketRewards
|
|
114
134
|
);
|
|
135
|
+
|
|
136
|
+
struct RouterYtRedeemStruct {
|
|
137
|
+
address[] yts;
|
|
138
|
+
// key-value pair
|
|
139
|
+
address[] scyAddrs;
|
|
140
|
+
address[] tokenRedeemScys;
|
|
141
|
+
//
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
struct RouterSwapAllStruct {
|
|
145
|
+
// key-value pair
|
|
146
|
+
address[] tokens;
|
|
147
|
+
bytes[] kybercalls;
|
|
148
|
+
//
|
|
149
|
+
address outputToken;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function redeemDueInterestAndRewardsThenSwapAll(
|
|
153
|
+
address[] calldata scys,
|
|
154
|
+
RouterYtRedeemStruct calldata dataYT,
|
|
155
|
+
address[] calldata markets,
|
|
156
|
+
RouterSwapAllStruct calldata dataSwap
|
|
157
|
+
) external returns (uint256 netTokenOut, uint256[] memory amountsSwapped);
|
|
115
158
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
2
|
pragma solidity 0.8.15;
|
|
3
3
|
|
|
4
|
-
import "@openzeppelin/contracts
|
|
4
|
+
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
5
5
|
|
|
6
6
|
interface ISJoe {
|
|
7
7
|
function joe() external view returns (address);
|
|
@@ -23,7 +23,7 @@ interface ISJoe {
|
|
|
23
23
|
* @return The amount of JOE user has deposited
|
|
24
24
|
* @return The reward debt for the chosen token
|
|
25
25
|
*/
|
|
26
|
-
function getUserInfo(address _user,
|
|
26
|
+
function getUserInfo(address _user, IERC20 _rewardToken)
|
|
27
27
|
external
|
|
28
28
|
view
|
|
29
29
|
returns (uint256, uint256);
|
|
@@ -42,10 +42,7 @@ interface ISJoe {
|
|
|
42
42
|
* @param _token The address of the token
|
|
43
43
|
* @return `_user`'s pending reward token
|
|
44
44
|
*/
|
|
45
|
-
function pendingReward(address _user,
|
|
46
|
-
external
|
|
47
|
-
view
|
|
48
|
-
returns (uint256);
|
|
45
|
+
function pendingReward(address _user, IERC20 _token) external view returns (uint256);
|
|
49
46
|
|
|
50
47
|
/**
|
|
51
48
|
* @notice Withdraw JOE and harvest the rewards
|
|
@@ -66,4 +66,13 @@ library PYIndexLib {
|
|
|
66
66
|
return sign * (SCYUtils.assetToScy(PYIndex.unwrap(index), assetAmount.abs())).Int();
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
function assetToScyUp(PYIndex index, int256 assetAmount)
|
|
70
|
+
internal
|
|
71
|
+
pure
|
|
72
|
+
returns (int256)
|
|
73
|
+
{
|
|
74
|
+
int256 sign = assetAmount < 0 ? int256(-1) : int256(1);
|
|
75
|
+
return sign * (SCYUtils.assetToScyUp(PYIndex.unwrap(index), assetAmount.abs())).Int();
|
|
76
|
+
}
|
|
77
|
+
|
|
69
78
|
}
|
|
@@ -8,6 +8,39 @@ abstract contract TokenHelper {
|
|
|
8
8
|
address internal constant NATIVE = address(0);
|
|
9
9
|
uint256 internal constant LOWER_BOUND_APPROVAL = type(uint96).max / 2; // some tokens use 96 bits for approval
|
|
10
10
|
|
|
11
|
+
function _transferFrom(
|
|
12
|
+
address token,
|
|
13
|
+
address from,
|
|
14
|
+
address to,
|
|
15
|
+
uint256 amount
|
|
16
|
+
) internal {
|
|
17
|
+
if (token == NATIVE) require(msg.value == amount, "eth mismatch");
|
|
18
|
+
else if (amount != 0) IERC20(token).safeTransferFrom(from, to, amount);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function _transferFrom(
|
|
22
|
+
address[] memory tokens,
|
|
23
|
+
address from,
|
|
24
|
+
address to,
|
|
25
|
+
uint256[] memory amounts
|
|
26
|
+
) internal {
|
|
27
|
+
uint256 length = tokens.length;
|
|
28
|
+
require(length == amounts.length, "length mismatch");
|
|
29
|
+
|
|
30
|
+
for (uint256 i = 0; i < length; ) {
|
|
31
|
+
if (amounts[i] > 0) {
|
|
32
|
+
if (tokens[i] == NATIVE) {
|
|
33
|
+
require(msg.value == amounts[i], "native mismatch");
|
|
34
|
+
} else {
|
|
35
|
+
IERC20(tokens[i]).safeTransferFrom(from, to, amounts[i]);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
unchecked {
|
|
39
|
+
i++;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
11
44
|
function _transferIn(
|
|
12
45
|
address token,
|
|
13
46
|
address from,
|
|
@@ -46,30 +79,6 @@ abstract contract TokenHelper {
|
|
|
46
79
|
}
|
|
47
80
|
}
|
|
48
81
|
|
|
49
|
-
function _transferOutMaxMulti(
|
|
50
|
-
address token,
|
|
51
|
-
uint256 totalAmount,
|
|
52
|
-
address[] memory tos,
|
|
53
|
-
uint256[] memory maxAmounts
|
|
54
|
-
) internal returns (uint256 leftover) {
|
|
55
|
-
uint256 numTos = tos.length;
|
|
56
|
-
require(numTos == maxAmounts.length, "invalid length");
|
|
57
|
-
|
|
58
|
-
leftover = totalAmount;
|
|
59
|
-
for (uint256 i = 0; i < numTos; ) {
|
|
60
|
-
uint256 maxAmount = maxAmounts[i];
|
|
61
|
-
if (maxAmount > leftover) {
|
|
62
|
-
maxAmount = leftover;
|
|
63
|
-
}
|
|
64
|
-
_transferOut(token, tos[i], maxAmount);
|
|
65
|
-
unchecked {
|
|
66
|
-
leftover -= maxAmount;
|
|
67
|
-
if (leftover == 0) break;
|
|
68
|
-
i++;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
82
|
function _selfBalance(address token) internal view returns (uint256) {
|
|
74
83
|
return (token == NATIVE) ? address(this).balance : IERC20(token).balanceOf(address(this));
|
|
75
84
|
}
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity 0.8.15;
|
|
4
|
+
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
5
|
+
import "./IMultihopRouter.sol";
|
|
6
|
+
|
|
7
|
+
library AggregationRouterHelper {
|
|
8
|
+
uint256 private constant _PARTIAL_FILL = 0x01;
|
|
9
|
+
uint256 private constant _REQUIRES_EXTRA_ETH = 0x02;
|
|
10
|
+
uint256 private constant _SHOULD_CLAIM = 0x04;
|
|
11
|
+
uint256 private constant _BURN_FROM_MSG_SENDER = 0x08;
|
|
12
|
+
uint256 private constant _BURN_FROM_TX_ORIGIN = 0x10;
|
|
13
|
+
uint256 private constant _SIMPLE_SWAP = 0x20;
|
|
14
|
+
|
|
15
|
+
uint256 private constant SLIPPAGE_RANGE = 10; // over 100
|
|
16
|
+
|
|
17
|
+
enum DexType {
|
|
18
|
+
UNI,
|
|
19
|
+
STABLESWAP,
|
|
20
|
+
CURVE,
|
|
21
|
+
KYBERDMM,
|
|
22
|
+
SADDLE,
|
|
23
|
+
UNIV3PROMM,
|
|
24
|
+
BALANCERV2,
|
|
25
|
+
KYBERRFQ,
|
|
26
|
+
DODO,
|
|
27
|
+
VELODROME,
|
|
28
|
+
PLATYPUS
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
struct SwapDescription {
|
|
32
|
+
IERC20 srcToken;
|
|
33
|
+
IERC20 dstToken;
|
|
34
|
+
address[] srcReceivers;
|
|
35
|
+
uint256[] srcAmounts;
|
|
36
|
+
address dstReceiver;
|
|
37
|
+
uint256 amount;
|
|
38
|
+
uint256 minReturnAmount;
|
|
39
|
+
uint256 flags;
|
|
40
|
+
bytes permit;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
struct SimpleSwapData {
|
|
44
|
+
address[] firstPools;
|
|
45
|
+
uint256[] firstSwapAmounts;
|
|
46
|
+
bytes[] swapDatas;
|
|
47
|
+
uint256 deadline;
|
|
48
|
+
bytes destTokenFeeData;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
struct SwapExecutorDescription {
|
|
52
|
+
IMultihopRouter.Swap[][] swapSequences;
|
|
53
|
+
address tokenIn;
|
|
54
|
+
address tokenOut;
|
|
55
|
+
uint256 minTotalAmountOut;
|
|
56
|
+
address to;
|
|
57
|
+
uint256 deadline;
|
|
58
|
+
bytes destTokenFeeData;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function getScaledInputData(bytes calldata kybercall, uint256 newAmount)
|
|
62
|
+
external
|
|
63
|
+
pure
|
|
64
|
+
returns (bytes memory)
|
|
65
|
+
{
|
|
66
|
+
bytes4 selector = bytes4(kybercall[:4]);
|
|
67
|
+
(
|
|
68
|
+
address caller,
|
|
69
|
+
SwapDescription memory desc,
|
|
70
|
+
bytes memory executorData,
|
|
71
|
+
bytes memory clientData
|
|
72
|
+
) = abi.decode(kybercall[4:], (address, SwapDescription, bytes, bytes));
|
|
73
|
+
|
|
74
|
+
(desc, executorData) = _getScaledInputData(desc, executorData, newAmount);
|
|
75
|
+
return abi.encodeWithSelector(selector, caller, desc, executorData, clientData);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function _getScaledInputData(
|
|
79
|
+
SwapDescription memory desc,
|
|
80
|
+
bytes memory executorData,
|
|
81
|
+
uint256 newAmount
|
|
82
|
+
) internal pure returns (SwapDescription memory, bytes memory) {
|
|
83
|
+
uint256 flags = desc.flags;
|
|
84
|
+
uint256 oldAmount = desc.amount;
|
|
85
|
+
if (oldAmount == newAmount) {
|
|
86
|
+
return (desc, executorData);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
//if the difference of newAmount and oldAmount > 5%, revert
|
|
90
|
+
require(
|
|
91
|
+
(oldAmount * (100 - SLIPPAGE_RANGE)) / 100 <= newAmount &&
|
|
92
|
+
newAmount <= (oldAmount * (100 + SLIPPAGE_RANGE)) / 100,
|
|
93
|
+
"kyber: difference too large"
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
// simple mode swap
|
|
97
|
+
if (flags & _SIMPLE_SWAP != 0) {
|
|
98
|
+
require(desc.srcReceivers.length == 0, "kyber: can't scale if take fee");
|
|
99
|
+
return (
|
|
100
|
+
_getNewDescription(desc, oldAmount, newAmount),
|
|
101
|
+
_getNewSimpleSwapData(executorData, oldAmount, newAmount)
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
//normal mode swap
|
|
106
|
+
bytes memory newExecutorData = _getNewExecutorData(executorData, oldAmount, newAmount);
|
|
107
|
+
return (_getNewDescription(desc, oldAmount, newAmount), newExecutorData);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function _getNewDescription(
|
|
111
|
+
SwapDescription memory desc,
|
|
112
|
+
uint256 oldAmount,
|
|
113
|
+
uint256 newAmount
|
|
114
|
+
) internal pure returns (SwapDescription memory) {
|
|
115
|
+
uint256 oldMinReturnAmount = desc.minReturnAmount;
|
|
116
|
+
desc.minReturnAmount = (desc.minReturnAmount * newAmount) / oldAmount;
|
|
117
|
+
//newMinReturnAmount should no be 0 if oldMinReturnAmount > 0
|
|
118
|
+
if (oldMinReturnAmount > 0 && desc.minReturnAmount == 0) desc.minReturnAmount = 1;
|
|
119
|
+
desc.amount = newAmount;
|
|
120
|
+
if (desc.srcReceivers.length == 0) {
|
|
121
|
+
return desc;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
uint256 newTotal;
|
|
125
|
+
for (uint256 i = 0; i < desc.srcReceivers.length; i++) {
|
|
126
|
+
if (i == desc.srcReceivers.length - 1) {
|
|
127
|
+
desc.srcAmounts[i] = newAmount - newTotal;
|
|
128
|
+
} else {
|
|
129
|
+
desc.srcAmounts[i] = (desc.srcAmounts[i] * newAmount) / oldAmount;
|
|
130
|
+
}
|
|
131
|
+
newTotal += desc.srcAmounts[i];
|
|
132
|
+
}
|
|
133
|
+
return desc;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function _getNewSimpleSwapData(
|
|
137
|
+
bytes memory data,
|
|
138
|
+
uint256 oldAmount,
|
|
139
|
+
uint256 newAmount
|
|
140
|
+
) internal pure returns (bytes memory) {
|
|
141
|
+
SimpleSwapData memory swapData = abi.decode(data, (SimpleSwapData));
|
|
142
|
+
uint256 numberSeq = swapData.firstPools.length;
|
|
143
|
+
uint256 newTotalSwapAmount;
|
|
144
|
+
for (uint256 i = 0; i < numberSeq; i++) {
|
|
145
|
+
if (i == numberSeq - 1) {
|
|
146
|
+
swapData.firstSwapAmounts[i] = newAmount - newTotalSwapAmount;
|
|
147
|
+
} else {
|
|
148
|
+
swapData.firstSwapAmounts[i] =
|
|
149
|
+
(swapData.firstSwapAmounts[i] * newAmount) /
|
|
150
|
+
oldAmount;
|
|
151
|
+
}
|
|
152
|
+
newTotalSwapAmount += swapData.firstSwapAmounts[i];
|
|
153
|
+
}
|
|
154
|
+
return abi.encode(swapData);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function _getNewExecutorData(
|
|
158
|
+
bytes memory data,
|
|
159
|
+
uint256 oldAmount,
|
|
160
|
+
uint256 newAmount
|
|
161
|
+
) internal pure returns (bytes memory) {
|
|
162
|
+
SwapExecutorDescription memory swapExecutorDescription = abi.decode(
|
|
163
|
+
data,
|
|
164
|
+
(SwapExecutorDescription)
|
|
165
|
+
);
|
|
166
|
+
swapExecutorDescription.minTotalAmountOut =
|
|
167
|
+
(swapExecutorDescription.minTotalAmountOut * newAmount) /
|
|
168
|
+
oldAmount;
|
|
169
|
+
|
|
170
|
+
uint256 newTotalSwapAmount;
|
|
171
|
+
for (uint256 i = 0; i < swapExecutorDescription.swapSequences.length; i++) {
|
|
172
|
+
IMultihopRouter.Swap memory swap = swapExecutorDescription.swapSequences[i][0];
|
|
173
|
+
uint8 dexType = uint8(swap.dexOption >> 8);
|
|
174
|
+
uint256 value;
|
|
175
|
+
if (i == swapExecutorDescription.swapSequences.length - 1)
|
|
176
|
+
value = newAmount - newTotalSwapAmount;
|
|
177
|
+
|
|
178
|
+
if (dexType == uint8(DexType.UNI)) {
|
|
179
|
+
(swap.data, value) = _newUniSwap(swap.data, value, oldAmount, newAmount);
|
|
180
|
+
} else if (dexType == uint8(DexType.STABLESWAP) || dexType == uint8(DexType.SADDLE)) {
|
|
181
|
+
(swap.data, value) = _newStableSwap(swap.data, value, oldAmount, newAmount);
|
|
182
|
+
} else if (dexType == uint8(DexType.CURVE)) {
|
|
183
|
+
(swap.data, value) = _newCurveSwap(swap.data, value, oldAmount, newAmount);
|
|
184
|
+
} else if (dexType == uint8(DexType.KYBERDMM)) {
|
|
185
|
+
(swap.data, value) = _newKyberDMMSwap(swap.data, value, oldAmount, newAmount);
|
|
186
|
+
} else if (dexType == uint8(DexType.UNIV3PROMM)) {
|
|
187
|
+
(swap.data, value) = _newUniV3ProMMSwap(swap.data, value, oldAmount, newAmount);
|
|
188
|
+
} else if (dexType == uint8(DexType.BALANCERV2)) {
|
|
189
|
+
(swap.data, value) = _newBalancerV2Swap(swap.data, value, oldAmount, newAmount);
|
|
190
|
+
} else if (dexType == uint8(DexType.KYBERRFQ)) {
|
|
191
|
+
revert("kyber: can't scale kyberrfq");
|
|
192
|
+
} else if (dexType == uint8(DexType.DODO)) {
|
|
193
|
+
(swap.data, value) = _newDODOSwap(swap.data, value, oldAmount, newAmount);
|
|
194
|
+
} else if (dexType == uint8(DexType.VELODROME)) {
|
|
195
|
+
(swap.data, value) = _newVelodromeSwap(swap.data, value, oldAmount, newAmount);
|
|
196
|
+
} else {
|
|
197
|
+
revert("AggregationExecutor: Dex type not supported");
|
|
198
|
+
}
|
|
199
|
+
newTotalSwapAmount += value;
|
|
200
|
+
}
|
|
201
|
+
return abi.encode(swapExecutorDescription);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function _newUniSwap(
|
|
205
|
+
bytes memory data,
|
|
206
|
+
uint256 value,
|
|
207
|
+
uint256 oldAmount,
|
|
208
|
+
uint256 newAmount
|
|
209
|
+
) internal pure returns (bytes memory, uint256) {
|
|
210
|
+
IMultihopRouter.UniSwap memory uniSwap = abi.decode(data, (IMultihopRouter.UniSwap));
|
|
211
|
+
if (value > 0) uniSwap.collectAmount = value;
|
|
212
|
+
else uniSwap.collectAmount = (uniSwap.collectAmount * newAmount) / oldAmount;
|
|
213
|
+
return (abi.encode(uniSwap), uniSwap.collectAmount);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function _newStableSwap(
|
|
217
|
+
bytes memory data,
|
|
218
|
+
uint256 value,
|
|
219
|
+
uint256 oldAmount,
|
|
220
|
+
uint256 newAmount
|
|
221
|
+
) internal pure returns (bytes memory, uint256) {
|
|
222
|
+
IMultihopRouter.StableSwap memory stableSwap = abi.decode(
|
|
223
|
+
data,
|
|
224
|
+
(IMultihopRouter.StableSwap)
|
|
225
|
+
);
|
|
226
|
+
if (value > 0) stableSwap.dx = value;
|
|
227
|
+
else stableSwap.dx = (stableSwap.dx * newAmount) / oldAmount;
|
|
228
|
+
return (abi.encode(stableSwap), stableSwap.dx);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function _newCurveSwap(
|
|
232
|
+
bytes memory data,
|
|
233
|
+
uint256 value,
|
|
234
|
+
uint256 oldAmount,
|
|
235
|
+
uint256 newAmount
|
|
236
|
+
) internal pure returns (bytes memory, uint256) {
|
|
237
|
+
IMultihopRouter.CurveSwap memory curveSwap = abi.decode(data, (IMultihopRouter.CurveSwap));
|
|
238
|
+
if (value > 0) curveSwap.dx = value;
|
|
239
|
+
else curveSwap.dx = (curveSwap.dx * newAmount) / oldAmount;
|
|
240
|
+
return (abi.encode(curveSwap), curveSwap.dx);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function _newKyberDMMSwap(
|
|
244
|
+
bytes memory data,
|
|
245
|
+
uint256 value,
|
|
246
|
+
uint256 oldAmount,
|
|
247
|
+
uint256 newAmount
|
|
248
|
+
) internal pure returns (bytes memory, uint256) {
|
|
249
|
+
IMultihopRouter.UniSwap memory kyberDMMSwap = abi.decode(data, (IMultihopRouter.UniSwap));
|
|
250
|
+
if (value > 0) kyberDMMSwap.collectAmount = value;
|
|
251
|
+
else kyberDMMSwap.collectAmount = (kyberDMMSwap.collectAmount * newAmount) / oldAmount;
|
|
252
|
+
return (abi.encode(kyberDMMSwap), kyberDMMSwap.collectAmount);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function _newUniV3ProMMSwap(
|
|
256
|
+
bytes memory data,
|
|
257
|
+
uint256 value,
|
|
258
|
+
uint256 oldAmount,
|
|
259
|
+
uint256 newAmount
|
|
260
|
+
) internal pure returns (bytes memory, uint256) {
|
|
261
|
+
IMultihopRouter.UniSwapV3ProMM memory uniSwapV3ProMM = abi.decode(
|
|
262
|
+
data,
|
|
263
|
+
(IMultihopRouter.UniSwapV3ProMM)
|
|
264
|
+
);
|
|
265
|
+
if (value > 0) uniSwapV3ProMM.swapAmount = value;
|
|
266
|
+
else uniSwapV3ProMM.swapAmount = (uniSwapV3ProMM.swapAmount * newAmount) / oldAmount;
|
|
267
|
+
return (abi.encode(uniSwapV3ProMM), uniSwapV3ProMM.swapAmount);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function _newBalancerV2Swap(
|
|
271
|
+
bytes memory data,
|
|
272
|
+
uint256 value,
|
|
273
|
+
uint256 oldAmount,
|
|
274
|
+
uint256 newAmount
|
|
275
|
+
) internal pure returns (bytes memory, uint256) {
|
|
276
|
+
IMultihopRouter.BalancerV2 memory balancerV2 = abi.decode(
|
|
277
|
+
data,
|
|
278
|
+
(IMultihopRouter.BalancerV2)
|
|
279
|
+
);
|
|
280
|
+
if (value > 0) balancerV2.amount = value;
|
|
281
|
+
else balancerV2.amount = (balancerV2.amount * newAmount) / oldAmount;
|
|
282
|
+
return (abi.encode(balancerV2, balancerV2.amount), balancerV2.amount);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function _newDODOSwap(
|
|
286
|
+
bytes memory data,
|
|
287
|
+
uint256 value,
|
|
288
|
+
uint256 oldAmount,
|
|
289
|
+
uint256 newAmount
|
|
290
|
+
) internal pure returns (bytes memory, uint256) {
|
|
291
|
+
IMultihopRouter.DODO memory dodo = abi.decode(data, (IMultihopRouter.DODO));
|
|
292
|
+
if (value > 0) dodo.amount = value;
|
|
293
|
+
else dodo.amount = (dodo.amount * newAmount) / oldAmount;
|
|
294
|
+
return (abi.encode(dodo), dodo.amount);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function _newVelodromeSwap(
|
|
298
|
+
bytes memory data,
|
|
299
|
+
uint256 value,
|
|
300
|
+
uint256 oldAmount,
|
|
301
|
+
uint256 newAmount
|
|
302
|
+
) internal pure returns (bytes memory, uint256) {
|
|
303
|
+
IMultihopRouter.UniSwap memory velodrome = abi.decode(data, (IMultihopRouter.UniSwap));
|
|
304
|
+
if (value > 0) velodrome.collectAmount = value;
|
|
305
|
+
else velodrome.collectAmount = (velodrome.collectAmount * newAmount) / oldAmount;
|
|
306
|
+
return (abi.encode(velodrome), velodrome.collectAmount);
|
|
307
|
+
}
|
|
308
|
+
}
|