@pendle/core-v2 0.15.3-mainnet → 0.16.0-testnet
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol/PendleMsgReceiveEndpointUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol/PendleMsgReceiveEndpointUpg.json +48 -110
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiverAppUpg.sol/PendleMsgReceiverAppUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol/PendleMsgSendEndpointUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol/PendleMsgSendEndpointUpg.json +21 -75
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSenderAppUpg.sol/PendleMsgSenderAppUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSenderAppUpg.sol/PendleMsgSenderAppUpg.json +0 -39
- package/build/artifacts/contracts/LiquidityMining/FeeDistributor/EpochResultManager.sol/EpochResultManager.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.json +2 -15
- package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributorFactory.sol/PendleFeeDistributorFactory.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributorFactory.sol/PendleFeeDistributorFactory.json +2 -15
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol/PendleGaugeControllerBaseUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol/PendleGaugeControllerBaseUpg.json +0 -13
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.json +2 -15
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.json +2 -15
- package/build/artifacts/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.json +2 -46
- package/build/artifacts/contracts/LiquidityMining/VotingController/VotingControllerStorageUpg.sol/VotingControllerStorageUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.json +8 -52
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.json +2 -15
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol/VotingEscrowTokenBase.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/libraries/VeBalanceLib.sol/VeBalanceLib.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/libraries/VeBalanceLib.sol/VeBalanceLib.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/CheckpointHelper.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/CheckpointHelper.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/Checkpoints.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/Checkpoints.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/libraries/WeekMath.sol/WeekMath.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/MarketMathCore.sol/MarketMathCore.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/MarketMathCore.sol/MarketMathCore.json +2 -2
- package/build/artifacts/contracts/core/Market/OracleLib.sol/OracleLib.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/OracleLib.sol/OracleLib.json +2 -2
- package/build/artifacts/contracts/core/Market/PendleGauge.sol/PendleGauge.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/PendleMarket.sol/PendleMarket.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/PendleMarket.sol/PendleMarket.json +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 +17 -77
- package/build/artifacts/contracts/core/RewardManager/RewardManager.sol/RewardManager.dbg.json +1 -1
- package/build/artifacts/contracts/core/RewardManager/RewardManagerAbstract.sol/RewardManagerAbstract.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/PYIndex.sol/PYIndexLib.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/PYIndex.sol/PYIndexLib.json +2 -2
- package/build/artifacts/contracts/core/StandardizedYield/SYBase.sol/SYBase.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/SYBaseWithRewards.sol/SYBaseWithRewards.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.json +2 -2
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol/PendleQiTokenSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol/PendleQiTokenSY.json +2 -2
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/ConvexCurveLP/Pendle3CrvAndTokenSY.sol/Pendle3CrvAndTokenSY.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/ConvexCurveLP/Pendle3CrvAndTokenSY.sol/Pendle3CrvAndTokenSY.json +1018 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/ConvexCurveLP/PendleConvexLPSY.sol/PendleConvexLPSY.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/{base → ConvexCurveLP}/PendleConvexLPSY.sol/PendleConvexLPSY.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/Pendle3CrvHelper.sol/Pendle3CrvHelper.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/Pendle3CrvHelper.sol/Pendle3CrvHelper.json +76 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleLooksStaking.sol/PendleLooksStaking.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/{PendleLooksStakingSY.sol/PendleLooksStakingSY.json → PendleLooksStaking.sol/PendleLooksStaking.json} +4 -4
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol/PendleWstEthSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol/PendleWstEthSY.json +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 +2 -15
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.json +4 -85
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.json +4 -17
- package/build/artifacts/contracts/core/erc20/PendleERC20.sol/PendleERC20.dbg.json +1 -1
- package/build/artifacts/contracts/core/erc20/PendleERC20.sol/PendleERC20.json +2 -2
- package/build/artifacts/contracts/core/erc20/PendleERC20Permit.sol/PendleERC20Permit.dbg.json +1 -1
- package/build/artifacts/contracts/core/erc20/PendleERC20Permit.sol/PendleERC20Permit.json +2 -2
- package/build/artifacts/contracts/core/libraries/BaseSplitCodeFactory.sol/BaseSplitCodeFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/BaseSplitCodeFactory.sol/BaseSplitCodeFactory.json +38 -3
- package/build/artifacts/contracts/core/libraries/BaseSplitCodeFactory.sol/CodeDeployer.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/BaseSplitCodeFactory.sol/CodeDeployer.json +2 -2
- package/build/artifacts/contracts/core/libraries/BoringOwnableUpgradeable.sol/BoringOwnableUpgradeable.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/BoringOwnableUpgradeable.sol/BoringOwnableUpgradeable.json +0 -13
- package/build/artifacts/contracts/core/libraries/BoringOwnableUpgradeable.sol/BoringOwnableUpgradeableData.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/BoringOwnableUpgradeable.sol/BoringOwnableUpgradeableData.json +2 -2
- package/build/artifacts/contracts/core/libraries/Errors.sol/Errors.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/Errors.sol/Errors.json +35 -319
- package/build/artifacts/contracts/core/libraries/TokenHelper.sol/TokenHelper.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ConvexCurve/IBooster.sol/IBooster.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ConvexCurve/IBooster.sol/IBooster.json +1 -1
- package/build/artifacts/contracts/interfaces/Curve/ICrvPool.sol/ICrvPool.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Curve/ICrvPool.sol/ICrvPool.json +85 -39
- package/build/artifacts/contracts/interfaces/IAToken.sol/IAToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ICelerMessageBus.sol/ICelerMessageBus.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/ICelerMessageBus.sol/ICelerMessageBus.json +53 -0
- package/build/artifacts/contracts/interfaces/ICelerMessageReceiverApp.sol/ICelerMessageReceiverApp.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/ICelerMessageReceiverApp.sol/ICelerMessageReceiverApp.json +45 -0
- package/build/artifacts/contracts/interfaces/IERC4626.sol/IERC4626.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ILooksFeeSharing.sol/ILooksFeeSharing.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ILooksStaking.sol/ILooksStaking.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ILooksStaking.sol/ILooksStaking.json +0 -7
- package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.json +17 -91
- package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.json +0 -50
- package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.json +0 -20
- package/build/artifacts/contracts/interfaces/IPActionSwapPTYT.sol/IPActionSwapPTYT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.json +0 -20
- package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.json +17 -181
- package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMarketFactory.sol/IPMarketFactory.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMarketFactory.sol/IPMarketFactory.json +2 -2
- package/build/artifacts/contracts/interfaces/IPMsgSendEndpoint.sol/IPMsgSendEndpoint.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMsgSendEndpoint.sol/IPMsgSendEndpoint.json +2 -12
- package/build/artifacts/contracts/interfaces/IPPrincipalToken.sol/IPPrincipalToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPVotingController.sol/IPVotingController.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPVotingEscrowMainchain.sol/IPVotingEscrowMainchain.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPYieldContractFactory.sol/IPYieldContractFactory.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPYieldContractFactory.sol/IPYieldContractFactory.json +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/ISJoe.sol/ISJoe.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IStETH.sol/IStETH.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IStETH.sol/IStETH.json +0 -45
- package/build/artifacts/contracts/interfaces/IStandardizedYield.sol/IStandardizedYield.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/offchain-helpers/BaseSplitCodeFactoryContract.sol/BaseSplitCodeFactoryContract.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/BaseSplitCodeFactoryContract.sol/BaseSplitCodeFactoryContract.json +2 -15
- package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.json +80 -2
- package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.json +60 -299
- package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.json +41 -118
- package/build/artifacts/contracts/router/ActionCallback.sol/ActionCallback.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionCallback.sol/ActionCallback.json +2 -2
- package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.json +24 -61
- package/build/artifacts/contracts/router/ActionMisc.sol/ActionMisc.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionMisc.sol/ActionMisc.json +2 -2
- package/build/artifacts/contracts/router/ActionSwapPT.sol/ActionSwapPT.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionSwapPT.sol/ActionSwapPT.json +24 -31
- package/build/artifacts/contracts/router/ActionSwapPTYT.sol/ActionSwapPTYT.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionSwapPTYT.sol/ActionSwapPTYT.json +2 -2
- package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.json +24 -31
- package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.dbg.json +1 -1
- package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.json +2 -15
- package/build/artifacts/contracts/router/base/ActionBaseMintRedeem.sol/ActionBaseMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/router/base/ActionBaseMintRedeem.sol/ActionBaseMintRedeem.json +1 -1
- package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtInLib.dbg.json +1 -1
- package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtInLib.json +2 -2
- package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtOutLib.dbg.json +1 -1
- package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtOutLib.json +2 -2
- package/build/artifacts/contracts/router/kyberswap/AggregationRouterHelper.sol/AggregationRouterHelper.dbg.json +1 -1
- package/build/artifacts/contracts/router/kyberswap/AggregationRouterHelper.sol/AggregationRouterHelper.json +2 -191
- package/build/artifacts/contracts/router/kyberswap/KyberSwapHelper.sol/KyberSwapHelper.dbg.json +1 -1
- package/build/artifacts/contracts/router/kyberswap/KyberSwapHelper.sol/KyberSwapHelper.json +1 -1
- package/contracts/LiquidityMining/CrossChainMsg/PendleMsgSenderAppUpg.sol +1 -1
- package/contracts/core/Market/PendleMarket.sol +7 -18
- package/contracts/core/Market/PendleMarketFactory.sol +5 -15
- package/contracts/core/StandardizedYield/implementations/Convex/ConvexCurveLP/Pendle3CrvAndTokenSY.sol +167 -0
- package/contracts/core/StandardizedYield/implementations/Convex/{base → ConvexCurveLP}/PendleConvexLPSY.sol +4 -2
- package/contracts/core/StandardizedYield/implementations/Convex/Pendle3CrvHelper.sol +83 -0
- package/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol +4 -19
- package/contracts/core/YieldContracts/PendlePrincipalToken.sol +3 -3
- package/contracts/core/YieldContracts/PendleYieldContractFactory.sol +7 -21
- package/contracts/core/YieldContracts/PendleYieldToken.sol +21 -54
- package/contracts/core/erc20/PendleERC20.sol +7 -4
- package/contracts/core/libraries/BaseSplitCodeFactory.sol +1 -1
- package/contracts/core/libraries/BoringOwnableUpgradeable.sol +1 -1
- package/contracts/core/libraries/Errors.sol +2 -28
- package/contracts/core/libraries/TokenHelper.sol +0 -9
- package/contracts/interfaces/ConvexCurve/IBooster.sol +1 -1
- package/contracts/interfaces/Curve/ICrvPool.sol +31 -12
- package/contracts/interfaces/IPActionAddRemoveLiq.sol +5 -3
- package/contracts/interfaces/IPActionMintRedeem.sol +0 -2
- package/contracts/interfaces/IPMarketFactory.sol +1 -1
- package/contracts/interfaces/IPYieldContractFactory.sol +1 -1
- package/contracts/interfaces/IStETH.sol +0 -6
- package/contracts/interfaces/IStandardizedYield.sol +10 -15
- package/contracts/offchain-helpers/ImplicitSwapfeeContract.sol +30 -0
- package/contracts/offchain-helpers/MarketMathStatic.sol +173 -0
- package/contracts/offchain-helpers/RouterStatic.sol +50 -189
- package/contracts/router/ActionAddRemoveLiq.sol +52 -71
- package/contracts/router/ActionCallback.sol +8 -4
- package/contracts/router/ActionMintRedeem.sol +18 -27
- package/contracts/router/ActionSwapPT.sol +9 -8
- package/contracts/router/ActionSwapPTYT.sol +7 -3
- package/contracts/router/ActionSwapYT.sol +10 -15
- package/contracts/router/PendleRouter.sol +0 -3
- package/contracts/router/base/ActionBaseMintRedeem.sol +83 -78
- package/contracts/router/base/MarketApproxLib.sol +1 -1
- package/contracts/router/kyberswap/AggregationRouterHelper.sol +1 -17
- package/contracts/router/kyberswap/KyberSwapHelper.sol +8 -21
- package/deployments/43113-core.json +16 -0
- package/deployments/43113-helper.json +3 -0
- package/deployments/43113-markets/benqi-market-QI-USDC-FEB-2ND.json +8 -0
- package/deployments/43113-markets/benqi-market-QI-WETH-DEC-1ST.json +8 -0
- package/deployments/43113-testenv.json +22 -0
- package/deployments/80001-core.json +15 -0
- package/deployments/80001-markets/benqi-market-QI-USDC-FEB-2ND.json +8 -0
- package/deployments/80001-markets/benqi-market-QI-WETH-DEC-1ST.json +8 -0
- package/deployments/80001-testenv.json +22 -0
- package/package.json +2 -3
- package/typechain-types/ActionAddRemoveLiq.ts +52 -64
- package/typechain-types/ActionBaseMintRedeem.ts +8 -8
- package/typechain-types/ActionMintRedeem.ts +16 -48
- package/typechain-types/ActionSwapPT.ts +12 -34
- package/typechain-types/ActionSwapYT.ts +12 -34
- package/typechain-types/AggregationRouterHelper.ts +3 -287
- package/typechain-types/BaseSplitCodeFactoryContract.ts +0 -9
- package/typechain-types/BoringOwnableUpgradeable.ts +0 -9
- package/typechain-types/IBooster.ts +3 -9
- package/typechain-types/ICrvPool.ts +172 -69
- package/typechain-types/ILooksStaking.ts +0 -27
- package/typechain-types/IPActionAddRemoveLiq.ts +44 -56
- package/typechain-types/IPActionMintRedeem.ts +8 -40
- package/typechain-types/IPActionSwapPT.ts +4 -26
- package/typechain-types/IPActionSwapYT.ts +4 -26
- package/typechain-types/IPAllAction.ts +54 -76
- package/typechain-types/IPMarketFactory.ts +2 -2
- package/typechain-types/IPMsgSendEndpoint.ts +14 -24
- package/typechain-types/IPYieldContractFactory.ts +3 -3
- package/typechain-types/IStETH.ts +0 -56
- package/typechain-types/ImplicitSwapfeeContract.ts +17 -9
- package/typechain-types/KyberSwapHelper.ts +8 -8
- package/typechain-types/MarketMathStatic.ts +117 -0
- package/typechain-types/PendleFeeDistributor.ts +0 -9
- package/typechain-types/PendleFeeDistributorFactory.ts +0 -9
- package/typechain-types/PendleGaugeControllerBaseUpg.ts +0 -9
- package/typechain-types/PendleGaugeControllerMainchainUpg.ts +0 -9
- package/typechain-types/PendleGaugeControllerSidechainUpg.ts +0 -9
- package/typechain-types/PendleMarketFactory.ts +2 -51
- package/typechain-types/PendleMsgReceiveEndpointUpg.ts +68 -135
- package/typechain-types/PendleMsgSendEndpointUpg.ts +39 -108
- package/typechain-types/PendleMsgSenderAppUpg.ts +0 -64
- package/typechain-types/PendlePrincipalToken.ts +0 -9
- package/typechain-types/PendleRouter.ts +0 -9
- package/typechain-types/PendleVotingControllerUpg.ts +0 -64
- package/typechain-types/PendleYieldContractFactory.ts +8 -57
- package/typechain-types/PendleYieldToken.ts +0 -21
- package/typechain-types/RouterStatic.ts +20 -302
- package/typechain-types/VotingEscrowPendleMainchain.ts +6 -70
- package/typechain-types/VotingEscrowPendleSidechain.ts +0 -9
- package/typechain-types/factories/ActionAddRemoveLiq__factory.ts +59 -122
- package/typechain-types/factories/ActionBaseMintRedeem__factory.ts +1 -1
- package/typechain-types/factories/ActionCallback__factory.ts +1 -1
- package/typechain-types/factories/ActionMintRedeem__factory.ts +42 -65
- package/typechain-types/factories/ActionMisc__factory.ts +1 -1
- package/typechain-types/factories/ActionSwapPTYT__factory.ts +1 -1
- package/typechain-types/factories/ActionSwapPT__factory.ts +42 -35
- package/typechain-types/factories/ActionSwapYT__factory.ts +42 -35
- package/typechain-types/factories/AggregationRouterHelper__factory.ts +1 -190
- package/typechain-types/factories/BaseSplitCodeFactoryContract__factory.ts +1 -14
- package/typechain-types/factories/BaseSplitCodeFactory__factory.ts +1 -1
- package/typechain-types/factories/BoringOwnableUpgradeableData__factory.ts +1 -1
- package/typechain-types/factories/BoringOwnableUpgradeable__factory.ts +0 -13
- package/typechain-types/factories/ERC20__factory.ts +1 -1
- package/typechain-types/factories/Errors__factory.ts +34 -318
- package/typechain-types/factories/IBooster__factory.ts +1 -1
- package/typechain-types/factories/ICrvPool__factory.ts +85 -39
- package/typechain-types/factories/ILooksStaking__factory.ts +0 -7
- package/typechain-types/factories/IPActionAddRemoveLiq__factory.ts +17 -91
- package/typechain-types/factories/IPActionMintRedeem__factory.ts +0 -50
- package/typechain-types/factories/IPActionSwapPT__factory.ts +0 -20
- package/typechain-types/factories/IPActionSwapYT__factory.ts +0 -20
- package/typechain-types/factories/IPAllAction__factory.ts +17 -181
- package/typechain-types/factories/IPMarketFactory__factory.ts +2 -2
- package/typechain-types/factories/IPMsgSendEndpoint__factory.ts +2 -12
- package/typechain-types/factories/IPYieldContractFactory__factory.ts +1 -1
- package/typechain-types/factories/IStETH__factory.ts +0 -45
- package/typechain-types/factories/ImplicitSwapfeeContract__factory.ts +12 -4
- package/typechain-types/factories/KyberSwapHelper__factory.ts +1 -1
- package/typechain-types/factories/MarketMathStatic__factory.ts +79 -1
- package/typechain-types/factories/OracleLib__factory.ts +1 -1
- package/typechain-types/factories/Pendle3CrvAndTokenSY__factory.ts +1 -1
- package/typechain-types/factories/PendleERC20Permit__factory.ts +1 -1
- package/typechain-types/factories/PendleERC20__factory.ts +1 -1
- package/typechain-types/factories/PendleFeeDistributorFactory__factory.ts +1 -14
- package/typechain-types/factories/PendleFeeDistributor__factory.ts +1 -14
- package/typechain-types/factories/PendleGaugeControllerBaseUpg__factory.ts +0 -13
- package/typechain-types/factories/PendleGaugeControllerMainchainUpg__factory.ts +1 -14
- package/typechain-types/factories/PendleGaugeControllerSidechainUpg__factory.ts +1 -14
- package/typechain-types/factories/PendleMarketFactory__factory.ts +16 -76
- package/typechain-types/factories/PendleMarket__factory.ts +1 -1
- package/typechain-types/factories/PendleMsgReceiveEndpointUpg__factory.ts +51 -113
- package/typechain-types/factories/PendleMsgSendEndpointUpg__factory.ts +23 -84
- package/typechain-types/factories/PendleMsgSenderAppUpg__factory.ts +0 -39
- package/typechain-types/factories/PendlePrincipalToken__factory.ts +1 -14
- package/typechain-types/factories/PendleQiTokenHelper__factory.ts +1 -1
- package/typechain-types/factories/PendleQiTokenSY__factory.ts +1 -1
- package/typechain-types/factories/PendleRouter__factory.ts +1 -14
- package/typechain-types/factories/PendleVotingControllerUpg__factory.ts +2 -57
- package/typechain-types/factories/PendleWstEthSY__factory.ts +1 -1
- package/typechain-types/factories/PendleYieldContractFactory__factory.ts +3 -84
- package/typechain-types/factories/PendleYieldToken__factory.ts +3 -16
- package/typechain-types/factories/RouterStatic__factory.ts +1 -244
- package/typechain-types/factories/VotingEscrowPendleMainchain__factory.ts +8 -63
- package/typechain-types/factories/VotingEscrowPendleSidechain__factory.ts +1 -14
- package/typechain-types/hardhat.d.ts +39 -219
- package/typechain-types/index.ts +12 -48
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/libraries/ExcessivelySafeCall.sol/ExcessivelySafeCall.dbg.json +0 -4
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/libraries/ExcessivelySafeCall.sol/ExcessivelySafeCall.json +0 -10
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/libraries/LayerZeroHelper.sol/LayerZeroHelper.dbg.json +0 -4
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/libraries/LayerZeroHelper.sol/LayerZeroHelper.json +0 -10
- package/build/artifacts/contracts/core/BulkSeller/BulkSeller.sol/BulkSeller.dbg.json +0 -4
- package/build/artifacts/contracts/core/BulkSeller/BulkSeller.sol/BulkSeller.json +0 -699
- package/build/artifacts/contracts/core/BulkSeller/BulkSellerFactory.sol/BulkSellerFactory.dbg.json +0 -4
- package/build/artifacts/contracts/core/BulkSeller/BulkSellerFactory.sol/BulkSellerFactory.json +0 -515
- package/build/artifacts/contracts/core/BulkSeller/BulkSellerMathCore.sol/BulkSellerMathCore.dbg.json +0 -4
- package/build/artifacts/contracts/core/BulkSeller/BulkSellerMathCore.sol/BulkSellerMathCore.json +0 -10
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol/PendleCurveFraxUsdcSY.dbg.json +0 -4
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol/PendleCurveFraxUsdcSY.json +0 -1003
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol/PendleCurveUsdd3CrvSY.dbg.json +0 -4
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol/PendleCurveUsdd3CrvSY.json +0 -1068
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/Curve3CrvPoolHelper.sol/Curve3CrvPoolHelper.dbg.json +0 -4
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/Curve3CrvPoolHelper.sol/Curve3CrvPoolHelper.json +0 -10
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/CurveFraxUsdcPoolHelper.sol/CurveFraxUsdcPoolHelper.dbg.json +0 -4
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/CurveFraxUsdcPoolHelper.sol/CurveFraxUsdcPoolHelper.json +0 -10
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/CurveUsdd3CrvPoolHelper.sol/CurveUsdd3CrvPoolHelper.dbg.json +0 -4
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/CurveUsdd3CrvPoolHelper.sol/CurveUsdd3CrvPoolHelper.json +0 -10
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/PendleConvexLPSY.sol/PendleConvexLPSY.dbg.json +0 -4
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleLooksStakingSY.sol/PendleLooksStakingSY.dbg.json +0 -4
- package/build/artifacts/contracts/interfaces/Curve/ITriCrvPool.sol/ITriCrvPool.dbg.json +0 -4
- package/build/artifacts/contracts/interfaces/Curve/ITriCrvPool.sol/ITriCrvPool.json +0 -213
- package/build/artifacts/contracts/interfaces/ILayerZeroEndpoint.sol/ILayerZeroEndpoint.dbg.json +0 -4
- package/build/artifacts/contracts/interfaces/ILayerZeroEndpoint.sol/ILayerZeroEndpoint.json +0 -119
- package/build/artifacts/contracts/interfaces/ILayerZeroReceiver.sol/ILayerZeroReceiver.dbg.json +0 -4
- package/build/artifacts/contracts/interfaces/ILayerZeroReceiver.sol/ILayerZeroReceiver.json +0 -39
- package/build/artifacts/contracts/interfaces/IPBulkSeller.sol/IPBulkSeller.dbg.json +0 -4
- package/build/artifacts/contracts/interfaces/IPBulkSeller.sol/IPBulkSeller.json +0 -173
- package/build/artifacts/contracts/interfaces/IPBulkSellerFactory.sol/IPBulkSellerFactory.dbg.json +0 -4
- package/build/artifacts/contracts/interfaces/IPBulkSellerFactory.sol/IPBulkSellerFactory.json +0 -86
- package/build/artifacts/contracts/interfaces/IPBulkSellerSYCallback.sol/IPBulkSellerCallback.dbg.json +0 -4
- package/build/artifacts/contracts/interfaces/IPBulkSellerSYCallback.sol/IPBulkSellerCallback.json +0 -34
- package/build/artifacts/contracts/offchain-helpers/BulkSellerOffchain.sol/BulkSellerOffchain.dbg.json +0 -4
- package/build/artifacts/contracts/offchain-helpers/BulkSellerOffchain.sol/BulkSellerOffchain.json +0 -35
- package/build/artifacts/contracts/router/kyberswap/IAggregatorRouterHelper.sol/IAggregationRouterHelper.dbg.json +0 -4
- package/build/artifacts/contracts/router/kyberswap/IAggregatorRouterHelper.sol/IAggregationRouterHelper.json +0 -35
- package/contracts/core/BulkSeller/BulkSeller.sol +0 -259
- package/contracts/core/BulkSeller/BulkSellerFactory.sol +0 -88
- package/contracts/core/BulkSeller/BulkSellerMathCore.sol +0 -143
- package/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol +0 -102
- package/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol +0 -160
- package/contracts/core/StandardizedYield/implementations/Convex/README.md +0 -29
- package/contracts/core/StandardizedYield/implementations/Convex/base/Curve3CrvPoolHelper.sol +0 -215
- package/contracts/core/StandardizedYield/implementations/Convex/base/CurveFraxUsdcPoolHelper.sol +0 -127
- package/contracts/core/StandardizedYield/implementations/Convex/base/CurveUsdd3CrvPoolHelper.sol +0 -152
- package/contracts/core/StandardizedYield/implementations/PendleLooksStakingSY.sol +0 -122
- package/contracts/interfaces/Curve/ITriCrvPool.sol +0 -41
- package/contracts/interfaces/ILooksFeeSharing.sol +0 -5
- package/contracts/interfaces/ILooksStaking.sol +0 -13
- package/contracts/interfaces/IPBulkSeller.sol +0 -28
- package/contracts/interfaces/IPBulkSellerFactory.sol +0 -12
- package/contracts/interfaces/IPBulkSellerSYCallback.sol +0 -10
- package/contracts/offchain-helpers/BulkSellerOffchain.sol +0 -43
- package/contracts/router/kyberswap/IAggregatorRouterHelper.sol +0 -10
- package/deployments/1-core.json +0 -17
- package/deployments/1-markets/FRAX_30_MAR_23.json +0 -9
- package/deployments/1-markets/LOOKS_30_MAR_23.json +0 -8
- package/deployments/1-markets/STETH_MARCH_30.json +0 -8
- package/deployments/1-markets/USDD_MARCH_30.json +0 -9
- package/deployments/1-offchain-helper.json +0 -3
- package/typechain-types/AccessControl.ts +0 -360
- package/typechain-types/AccessControlUpgradeable.ts +0 -369
- package/typechain-types/BeaconProxy.ts +0 -97
- package/typechain-types/BulkSeller.ts +0 -777
- package/typechain-types/BulkSellerFactory.ts +0 -707
- package/typechain-types/BulkSellerOffchain.ts +0 -117
- package/typechain-types/ContextUpgradeable.ts +0 -68
- package/typechain-types/Curve3CrvPoolHelper.ts +0 -236
- package/typechain-types/CurveFraxUsdcPoolHelper.ts +0 -158
- package/typechain-types/CurveUsdd3CrvPoolHelper.ts +0 -184
- package/typechain-types/ERC165.ts +0 -102
- package/typechain-types/ERC165Upgradeable.ts +0 -113
- package/typechain-types/IAccessControl.ts +0 -305
- package/typechain-types/IAccessControlUpgradeable.ts +0 -305
- package/typechain-types/IAggregationRouterHelper.ts +0 -108
- package/typechain-types/IERC165.ts +0 -102
- package/typechain-types/IERC165Upgradeable.ts +0 -102
- package/typechain-types/IPBulkSeller.ts +0 -290
- package/typechain-types/IPBulkSellerCallback.ts +0 -115
- package/typechain-types/IPBulkSellerFactory.ts +0 -147
- package/typechain-types/ITriCrvPool.ts +0 -345
- package/typechain-types/Initializable.ts +0 -68
- package/typechain-types/PendleConvex2TokensSY.ts +0 -1215
- package/typechain-types/PendleCurveFraxUsdcSY.ts +0 -1228
- package/typechain-types/PendleCurveUsdd3CrvSY.ts +0 -1299
- package/typechain-types/PendleLooksStakingSY.ts +0 -1052
- package/typechain-types/ReentrancyGuardUpgradeable.ts +0 -68
- package/typechain-types/factories/AccessControlUpgradeable__factory.ts +0 -247
- package/typechain-types/factories/AccessControl__factory.ts +0 -227
- package/typechain-types/factories/BeaconProxy__factory.ts +0 -141
- package/typechain-types/factories/BulkSellerFactory__factory.ts +0 -568
- package/typechain-types/factories/BulkSellerOffchain__factory.ts +0 -88
- package/typechain-types/factories/BulkSeller__factory.ts +0 -749
- package/typechain-types/factories/ContextUpgradeable__factory.ts +0 -39
- package/typechain-types/factories/Curve3CrvPoolHelper__factory.ts +0 -220
- package/typechain-types/factories/CurveFraxUsdcPoolHelper__factory.ts +0 -146
- package/typechain-types/factories/CurveUsdd3CrvPoolHelper__factory.ts +0 -172
- package/typechain-types/factories/ERC165Upgradeable__factory.ts +0 -58
- package/typechain-types/factories/ERC165__factory.ts +0 -39
- package/typechain-types/factories/IAccessControlUpgradeable__factory.ts +0 -202
- package/typechain-types/factories/IAccessControl__factory.ts +0 -198
- package/typechain-types/factories/IAggregationRouterHelper__factory.ts +0 -54
- package/typechain-types/factories/IERC165Upgradeable__factory.ts +0 -45
- package/typechain-types/factories/IERC165__factory.ts +0 -42
- package/typechain-types/factories/IPBulkSellerCallback__factory.ts +0 -53
- package/typechain-types/factories/IPBulkSellerFactory__factory.ts +0 -101
- package/typechain-types/factories/IPBulkSeller__factory.ts +0 -185
- package/typechain-types/factories/ITriCrvPool__factory.ts +0 -225
- package/typechain-types/factories/Initializable__factory.ts +0 -36
- package/typechain-types/factories/PendleConvex2TokensSY__factory.ts +0 -1093
- package/typechain-types/factories/PendleCurveFraxUsdcSY__factory.ts +0 -1068
- package/typechain-types/factories/PendleCurveUsdd3CrvSY__factory.ts +0 -1133
- package/typechain-types/factories/PendleLooksStakingSY__factory.ts +0 -937
- package/typechain-types/factories/ReentrancyGuardUpgradeable__factory.ts +0 -43
|
@@ -12,12 +12,12 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
12
12
|
using MarketMathCore for MarketState;
|
|
13
13
|
using MarketApproxPtInLib for MarketState;
|
|
14
14
|
using MarketApproxPtOutLib for MarketState;
|
|
15
|
+
using SafeERC20 for IERC20;
|
|
15
16
|
using PYIndexLib for IPYieldToken;
|
|
16
|
-
using BulkSellerMathCore for BulkSellerState;
|
|
17
17
|
|
|
18
18
|
/// @dev since this contract will be proxied, it must not contains non-immutable variables
|
|
19
|
-
constructor(address
|
|
20
|
-
ActionBaseMintRedeem(
|
|
19
|
+
constructor(address _kyberSwapRouter)
|
|
20
|
+
ActionBaseMintRedeem(_kyberSwapRouter) //solhint-disable-next-line no-empty-blocks
|
|
21
21
|
{}
|
|
22
22
|
|
|
23
23
|
function addLiquidityDualSyAndPt(
|
|
@@ -36,7 +36,6 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
36
36
|
{
|
|
37
37
|
(IStandardizedYield SY, IPPrincipalToken PT, ) = IPMarket(market).readTokens();
|
|
38
38
|
|
|
39
|
-
// calculate the amount of SY and PT to be used
|
|
40
39
|
MarketState memory state = IPMarket(market).readState();
|
|
41
40
|
(, netLpOut, netSyUsed, netPtUsed) = state.addLiquidity(
|
|
42
41
|
netSyDesired,
|
|
@@ -47,9 +46,8 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
47
46
|
// early-check
|
|
48
47
|
if (netLpOut < minLpOut) revert Errors.RouterInsufficientLpOut(netLpOut, minLpOut);
|
|
49
48
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
_transferFrom(IERC20(PT), msg.sender, market, netPtUsed);
|
|
49
|
+
IERC20(SY).safeTransferFrom(msg.sender, market, netSyUsed);
|
|
50
|
+
IERC20(PT).safeTransferFrom(msg.sender, market, netPtUsed);
|
|
53
51
|
|
|
54
52
|
(netLpOut, , ) = IPMarket(market).mint(receiver, netSyUsed, netPtUsed);
|
|
55
53
|
|
|
@@ -59,13 +57,11 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
59
57
|
emit AddLiquidityDualSyAndPt(msg.sender, market, receiver, netSyUsed, netPtUsed, netLpOut);
|
|
60
58
|
}
|
|
61
59
|
|
|
62
|
-
/**
|
|
63
|
-
* @dev this function assumes that netTokenDesired = netTokenUsed, and fails if this does not hold
|
|
64
|
-
*/
|
|
65
60
|
function addLiquidityDualTokenAndPt(
|
|
66
61
|
address receiver,
|
|
67
62
|
address market,
|
|
68
|
-
|
|
63
|
+
address tokenIn,
|
|
64
|
+
uint256 netTokenDesired,
|
|
69
65
|
uint256 netPtDesired,
|
|
70
66
|
uint256 minLpOut
|
|
71
67
|
)
|
|
@@ -79,38 +75,45 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
79
75
|
{
|
|
80
76
|
(IStandardizedYield SY, IPPrincipalToken PT, ) = IPMarket(market).readTokens();
|
|
81
77
|
|
|
82
|
-
uint256 netSyDesired =
|
|
78
|
+
uint256 netSyDesired = SY.previewDeposit(tokenIn, netTokenDesired);
|
|
83
79
|
uint256 netSyUsed;
|
|
84
80
|
|
|
85
81
|
{
|
|
86
|
-
// calc the amount of SY and PT to be used
|
|
87
82
|
MarketState memory state = IPMarket(market).readState();
|
|
88
83
|
(, netLpOut, netSyUsed, netPtUsed) = state.addLiquidity(
|
|
89
84
|
netSyDesired,
|
|
90
85
|
netPtDesired,
|
|
91
86
|
block.timestamp
|
|
92
87
|
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (netLpOut < minLpOut) revert Errors.RouterInsufficientLpOut(netLpOut, minLpOut);
|
|
91
|
+
|
|
92
|
+
IERC20(PT).safeTransferFrom(msg.sender, market, netPtUsed);
|
|
93
93
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if (netLpOut < minLpOut) revert Errors.RouterInsufficientLpOut(netLpOut, minLpOut);
|
|
94
|
+
// convert tokenIn to SY to deposit
|
|
95
|
+
netTokenUsed = (netTokenDesired * netSyUsed).rawDivUp(netSyDesired);
|
|
97
96
|
|
|
98
|
-
|
|
97
|
+
if (tokenIn == NATIVE) {
|
|
98
|
+
_transferIn(tokenIn, msg.sender, netTokenDesired);
|
|
99
|
+
SY.deposit{ value: netTokenUsed }(market, tokenIn, netTokenUsed, netSyUsed);
|
|
100
|
+
_transferOut(tokenIn, msg.sender, netTokenDesired - netTokenUsed);
|
|
101
|
+
} else {
|
|
102
|
+
_transferIn(tokenIn, msg.sender, netTokenUsed);
|
|
103
|
+
_safeApproveInf(tokenIn, address(SY));
|
|
104
|
+
SY.deposit(market, tokenIn, netTokenUsed, netSyUsed);
|
|
99
105
|
}
|
|
100
106
|
|
|
101
|
-
// SY has been minted and transferred to the market
|
|
102
|
-
_transferFrom(IERC20(PT), msg.sender, market, netPtUsed);
|
|
103
107
|
(netLpOut, , ) = IPMarket(market).mint(receiver, netSyUsed, netPtUsed);
|
|
104
108
|
|
|
105
|
-
// fail-safe
|
|
106
109
|
if (netLpOut < minLpOut) assert(false);
|
|
107
110
|
|
|
108
111
|
emit AddLiquidityDualTokenAndPt(
|
|
109
112
|
msg.sender,
|
|
110
113
|
market,
|
|
111
114
|
receiver,
|
|
112
|
-
|
|
113
|
-
|
|
115
|
+
tokenIn,
|
|
116
|
+
netTokenDesired,
|
|
114
117
|
netPtUsed,
|
|
115
118
|
netLpOut
|
|
116
119
|
);
|
|
@@ -125,7 +128,6 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
125
128
|
) external returns (uint256 netLpOut, uint256 netSyFee) {
|
|
126
129
|
(, IPPrincipalToken PT, IPYieldToken YT) = IPMarket(market).readTokens();
|
|
127
130
|
|
|
128
|
-
// calculate the amount of PT to swap
|
|
129
131
|
MarketState memory state = IPMarket(market).readState();
|
|
130
132
|
|
|
131
133
|
(uint256 netPtSwap, , ) = state.approxSwapPtToAddLiquidity(
|
|
@@ -135,17 +137,15 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
135
137
|
guessPtSwapToSy
|
|
136
138
|
);
|
|
137
139
|
|
|
138
|
-
|
|
139
|
-
_transferFrom(IERC20(PT), msg.sender, market, netPtIn);
|
|
140
|
+
IERC20(PT).safeTransferFrom(msg.sender, market, netPtIn);
|
|
140
141
|
|
|
141
142
|
uint256 netSyReceived;
|
|
142
143
|
(netSyReceived, netSyFee) = IPMarket(market).swapExactPtForSy(
|
|
143
144
|
market,
|
|
144
145
|
netPtSwap,
|
|
145
146
|
EMPTY_BYTES
|
|
146
|
-
);
|
|
147
|
+
); // ignore return, receiver = market
|
|
147
148
|
|
|
148
|
-
// execute the addLiquidity
|
|
149
149
|
(netLpOut, , ) = IPMarket(market).mint(receiver, netSyReceived, netPtIn - netPtSwap);
|
|
150
150
|
|
|
151
151
|
if (netLpOut < minLpOut) revert Errors.RouterInsufficientLpOut(netLpOut, minLpOut);
|
|
@@ -161,11 +161,8 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
161
161
|
ApproxParams calldata guessPtReceivedFromSy
|
|
162
162
|
) external returns (uint256 netLpOut, uint256 netSyFee) {
|
|
163
163
|
(IStandardizedYield SY, , IPYieldToken YT) = IPMarket(market).readTokens();
|
|
164
|
+
IERC20(SY).safeTransferFrom(msg.sender, market, netSyIn);
|
|
164
165
|
|
|
165
|
-
// transfer SY to market
|
|
166
|
-
_transferFrom(IERC20(SY), msg.sender, market, netSyIn);
|
|
167
|
-
|
|
168
|
-
// mint LP
|
|
169
166
|
(netLpOut, netSyFee) = _addLiquiditySingleSy(
|
|
170
167
|
receiver,
|
|
171
168
|
market,
|
|
@@ -187,10 +184,9 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
187
184
|
) external payable returns (uint256 netLpOut, uint256 netSyFee) {
|
|
188
185
|
(IStandardizedYield SY, , IPYieldToken YT) = IPMarket(market).readTokens();
|
|
189
186
|
|
|
190
|
-
//
|
|
191
|
-
uint256 netSyUsed = _mintSyFromToken(market, address(SY), 1, input);
|
|
187
|
+
// all output SY is transferred directly to the market
|
|
188
|
+
uint256 netSyUsed = _mintSyFromToken(address(market), address(SY), 1, input);
|
|
192
189
|
|
|
193
|
-
// mint LP
|
|
194
190
|
(netLpOut, netSyFee) = _addLiquiditySingleSy(
|
|
195
191
|
receiver,
|
|
196
192
|
market,
|
|
@@ -217,7 +213,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
217
213
|
uint256 minSyOut,
|
|
218
214
|
uint256 minPtOut
|
|
219
215
|
) external returns (uint256 netSyOut, uint256 netPtOut) {
|
|
220
|
-
|
|
216
|
+
IERC20(market).safeTransferFrom(msg.sender, market, netLpToRemove);
|
|
221
217
|
|
|
222
218
|
(netSyOut, netPtOut) = IPMarket(market).burn(receiver, receiver, netLpToRemove);
|
|
223
219
|
|
|
@@ -238,25 +234,20 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
238
234
|
address receiver,
|
|
239
235
|
address market,
|
|
240
236
|
uint256 netLpToRemove,
|
|
241
|
-
|
|
237
|
+
address tokenOut,
|
|
238
|
+
uint256 minTokenOut,
|
|
242
239
|
uint256 minPtOut
|
|
243
240
|
) external returns (uint256 netTokenOut, uint256 netPtOut) {
|
|
244
241
|
(IStandardizedYield SY, , ) = IPMarket(market).readTokens();
|
|
245
242
|
|
|
246
|
-
|
|
247
|
-
_transferFrom(IERC20(market), msg.sender, market, netLpToRemove);
|
|
243
|
+
IERC20(market).safeTransferFrom(msg.sender, market, netLpToRemove);
|
|
248
244
|
|
|
249
245
|
uint256 netSyOut;
|
|
250
|
-
(netSyOut, netPtOut) = IPMarket(market).burn(
|
|
251
|
-
_syOrBulk(address(SY), output),
|
|
252
|
-
receiver,
|
|
253
|
-
netLpToRemove
|
|
254
|
-
);
|
|
246
|
+
(netSyOut, netPtOut) = IPMarket(market).burn(address(SY), receiver, netLpToRemove);
|
|
255
247
|
|
|
256
|
-
|
|
248
|
+
netTokenOut = SY.redeem(receiver, netSyOut, tokenOut, minTokenOut, true);
|
|
257
249
|
|
|
258
|
-
|
|
259
|
-
netTokenOut = _redeemSyToToken(receiver, address(SY), netSyOut, output, false);
|
|
250
|
+
if (netPtOut < minPtOut) revert Errors.RouterInsufficientPtOut(netPtOut, minPtOut);
|
|
260
251
|
|
|
261
252
|
emit RemoveLiquidityDualTokenAndPt(
|
|
262
253
|
msg.sender,
|
|
@@ -264,7 +255,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
264
255
|
receiver,
|
|
265
256
|
netLpToRemove,
|
|
266
257
|
netPtOut,
|
|
267
|
-
|
|
258
|
+
tokenOut,
|
|
268
259
|
netTokenOut
|
|
269
260
|
);
|
|
270
261
|
}
|
|
@@ -278,7 +269,8 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
278
269
|
) external returns (uint256 netPtOut, uint256 netSyFee) {
|
|
279
270
|
(, , IPYieldToken YT) = IPMarket(market).readTokens();
|
|
280
271
|
|
|
281
|
-
|
|
272
|
+
IERC20(market).safeTransferFrom(msg.sender, market, netLpToRemove);
|
|
273
|
+
|
|
282
274
|
MarketState memory state = IPMarket(market).readState();
|
|
283
275
|
(uint256 syFromBurn, uint256 ptFromBurn) = state.removeLiquidity(netLpToRemove);
|
|
284
276
|
(uint256 ptFromSwap, ) = state.approxSwapExactSyForPt(
|
|
@@ -291,16 +283,13 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
291
283
|
if (ptFromBurn + ptFromSwap < minPtOut)
|
|
292
284
|
revert Errors.RouterInsufficientPtOut(ptFromBurn + ptFromSwap, minPtOut);
|
|
293
285
|
|
|
294
|
-
// execute the burn & the swap
|
|
295
|
-
_transferFrom(IERC20(market), msg.sender, market, netLpToRemove);
|
|
296
|
-
|
|
297
286
|
(, ptFromBurn) = IPMarket(market).burn(market, receiver, netLpToRemove);
|
|
298
287
|
(, netSyFee) = IPMarket(market).swapSyForExactPt(receiver, ptFromSwap, EMPTY_BYTES);
|
|
299
288
|
|
|
300
|
-
netPtOut = ptFromBurn + ptFromSwap;
|
|
301
|
-
|
|
302
289
|
// fail-safe
|
|
303
|
-
if (
|
|
290
|
+
if (ptFromBurn + ptFromSwap < minPtOut) assert(false);
|
|
291
|
+
|
|
292
|
+
netPtOut = ptFromBurn + ptFromSwap;
|
|
304
293
|
|
|
305
294
|
emit RemoveLiquiditySinglePt(msg.sender, market, receiver, netLpToRemove, netPtOut);
|
|
306
295
|
}
|
|
@@ -311,12 +300,8 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
311
300
|
uint256 netLpToRemove,
|
|
312
301
|
uint256 minSyOut
|
|
313
302
|
) external returns (uint256 netSyOut, uint256 netSyFee) {
|
|
314
|
-
|
|
315
|
-
_transferFrom(IERC20(market), msg.sender, market, netLpToRemove);
|
|
316
|
-
|
|
317
|
-
// burn LP, SY sent to receiver
|
|
303
|
+
IERC20(market).safeTransferFrom(msg.sender, market, netLpToRemove);
|
|
318
304
|
(netSyOut, netSyFee) = _removeLiquiditySingleSy(receiver, market, netLpToRemove, minSyOut);
|
|
319
|
-
|
|
320
305
|
emit RemoveLiquiditySingleSy(msg.sender, market, receiver, netLpToRemove, netSyOut);
|
|
321
306
|
}
|
|
322
307
|
|
|
@@ -328,19 +313,19 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
328
313
|
) external returns (uint256 netTokenOut, uint256 netSyFee) {
|
|
329
314
|
(IStandardizedYield SY, , ) = IPMarket(market).readTokens();
|
|
330
315
|
|
|
331
|
-
|
|
332
|
-
_transferFrom(IERC20(market), msg.sender, market, netLpToRemove);
|
|
316
|
+
IERC20(market).safeTransferFrom(msg.sender, market, netLpToRemove);
|
|
333
317
|
|
|
318
|
+
// all output SY is directly transferred to the SY contract
|
|
334
319
|
uint256 netSyReceived;
|
|
335
320
|
|
|
336
321
|
(netSyReceived, netSyFee) = _removeLiquiditySingleSy(
|
|
337
|
-
|
|
322
|
+
address(SY),
|
|
338
323
|
market,
|
|
339
324
|
netLpToRemove,
|
|
340
325
|
1
|
|
341
326
|
);
|
|
342
327
|
|
|
343
|
-
//
|
|
328
|
+
// since all SY is already at the SY contract, doPull = false
|
|
344
329
|
netTokenOut = _redeemSyToToken(receiver, address(SY), netSyReceived, output, false);
|
|
345
330
|
|
|
346
331
|
emit RemoveLiquiditySingleToken(
|
|
@@ -363,23 +348,20 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
363
348
|
) internal returns (uint256 netLpOut, uint256 netSyFee) {
|
|
364
349
|
MarketState memory state = IPMarket(market).readState();
|
|
365
350
|
|
|
366
|
-
|
|
367
|
-
(uint256 netPtFromSwap, , ) = state.approxSwapSyToAddLiquidity(
|
|
351
|
+
(uint256 netPtReceived, , ) = state.approxSwapSyToAddLiquidity(
|
|
368
352
|
YT.newIndex(),
|
|
369
353
|
netSyIn,
|
|
370
354
|
block.timestamp,
|
|
371
355
|
guessPtReceivedFromSy
|
|
372
356
|
);
|
|
373
357
|
|
|
374
|
-
// execute the swap & the addLiquidity
|
|
375
358
|
uint256 netSySwapped;
|
|
376
359
|
(netSySwapped, netSyFee) = IPMarket(market).swapSyForExactPt(
|
|
377
360
|
market,
|
|
378
|
-
|
|
361
|
+
netPtReceived,
|
|
379
362
|
EMPTY_BYTES
|
|
380
|
-
);
|
|
381
|
-
|
|
382
|
-
(netLpOut, , ) = IPMarket(market).mint(receiver, netSyIn - netSySwapped, netPtFromSwap);
|
|
363
|
+
); // ignore return, receiver = market
|
|
364
|
+
(netLpOut, , ) = IPMarket(market).mint(receiver, netSyIn - netSySwapped, netPtReceived);
|
|
383
365
|
|
|
384
366
|
if (netLpOut < minLpOut) revert Errors.RouterInsufficientLpOut(netLpOut, minLpOut);
|
|
385
367
|
}
|
|
@@ -426,7 +408,6 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
|
|
|
426
408
|
ptFromBurn,
|
|
427
409
|
EMPTY_BYTES
|
|
428
410
|
);
|
|
429
|
-
|
|
430
411
|
netSyOut = syFromBurn + syFromSwap;
|
|
431
412
|
}
|
|
432
413
|
}
|
|
@@ -12,9 +12,13 @@ import "./base/CallbackHelper.sol";
|
|
|
12
12
|
|
|
13
13
|
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
|
14
14
|
|
|
15
|
-
contract ActionCallback is IPMarketSwapCallback, CallbackHelper
|
|
15
|
+
contract ActionCallback is IPMarketSwapCallback, CallbackHelper {
|
|
16
16
|
using Math for int256;
|
|
17
17
|
using Math for uint256;
|
|
18
|
+
using SafeERC20 for IStandardizedYield;
|
|
19
|
+
using SafeERC20 for IPYieldToken;
|
|
20
|
+
using SafeERC20 for IPPrincipalToken;
|
|
21
|
+
using SafeERC20 for IERC20;
|
|
18
22
|
using PYIndexLib for PYIndex;
|
|
19
23
|
using PYIndexLib for IPYieldToken;
|
|
20
24
|
|
|
@@ -110,7 +114,7 @@ contract ActionCallback is IPMarketSwapCallback, CallbackHelper, TokenHelper {
|
|
|
110
114
|
/// mint & transfer
|
|
111
115
|
/// ------------------------------------------------------------
|
|
112
116
|
if (netSyToPull > 0) {
|
|
113
|
-
|
|
117
|
+
SY.safeTransferFrom(vars.payer, address(YT), netSyToPull);
|
|
114
118
|
}
|
|
115
119
|
|
|
116
120
|
uint256 netPyOut = YT.mintPY(market, vars.receiver);
|
|
@@ -171,7 +175,7 @@ contract ActionCallback is IPMarketSwapCallback, CallbackHelper, TokenHelper {
|
|
|
171
175
|
|
|
172
176
|
uint256 netSyOwed = syToAccount.abs();
|
|
173
177
|
|
|
174
|
-
|
|
178
|
+
PT.safeTransfer(address(YT), exactYtIn);
|
|
175
179
|
uint256 netSyToMarket = YT.redeemPY(market);
|
|
176
180
|
|
|
177
181
|
if (netSyToMarket < netSyOwed)
|
|
@@ -180,6 +184,6 @@ contract ActionCallback is IPMarketSwapCallback, CallbackHelper, TokenHelper {
|
|
|
180
184
|
uint256 netPtOut = ptToAccount.Uint() - exactYtIn;
|
|
181
185
|
if (netPtOut < minPtOut) revert Errors.RouterInsufficientPtOut(netPtOut, minPtOut);
|
|
182
186
|
|
|
183
|
-
|
|
187
|
+
PT.safeTransfer(receiver, netPtOut);
|
|
184
188
|
}
|
|
185
189
|
}
|
|
@@ -10,12 +10,14 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
10
10
|
using MarketMathCore for MarketState;
|
|
11
11
|
using Math for uint256;
|
|
12
12
|
using Math for int256;
|
|
13
|
+
using SafeERC20 for IERC20;
|
|
13
14
|
|
|
14
15
|
/// @dev since this contract will be proxied, it must not contains non-immutable variables
|
|
15
|
-
constructor(address
|
|
16
|
-
ActionBaseMintRedeem(
|
|
16
|
+
constructor(address _kyberSwapRouter)
|
|
17
|
+
ActionBaseMintRedeem(_kyberSwapRouter) //solhint-disable-next-line no-empty-blocks
|
|
17
18
|
{}
|
|
18
19
|
|
|
20
|
+
/// @dev refer to the internal function
|
|
19
21
|
function mintSyFromToken(
|
|
20
22
|
address receiver,
|
|
21
23
|
address SY,
|
|
@@ -23,9 +25,11 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
23
25
|
TokenInput calldata input
|
|
24
26
|
) external payable returns (uint256 netSyOut) {
|
|
25
27
|
netSyOut = _mintSyFromToken(receiver, SY, minSyOut, input);
|
|
28
|
+
|
|
26
29
|
emit MintSyFromToken(msg.sender, receiver, SY, input.tokenIn, input.netTokenIn, netSyOut);
|
|
27
30
|
}
|
|
28
31
|
|
|
32
|
+
/// @dev refer to the internal function
|
|
29
33
|
function redeemSyToToken(
|
|
30
34
|
address receiver,
|
|
31
35
|
address SY,
|
|
@@ -36,31 +40,25 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
36
40
|
emit RedeemSyToToken(msg.sender, receiver, SY, netSyIn, output.tokenOut, netTokenOut);
|
|
37
41
|
}
|
|
38
42
|
|
|
43
|
+
/// @dev refer to the internal function
|
|
39
44
|
function mintPyFromToken(
|
|
40
45
|
address receiver,
|
|
41
46
|
address YT,
|
|
42
47
|
uint256 minPyOut,
|
|
43
48
|
TokenInput calldata input
|
|
44
49
|
) external payable returns (uint256 netPyOut) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
uint256 netSyToMint = _mintSyFromToken(YT, SY, 0, input);
|
|
48
|
-
netPyOut = _mintPyFromSy(receiver, YT, netSyToMint, minPyOut, false);
|
|
49
|
-
|
|
50
|
+
netPyOut = _mintPyFromToken(receiver, YT, minPyOut, input);
|
|
50
51
|
emit MintPyFromToken(msg.sender, receiver, YT, input.tokenIn, input.netTokenIn, netPyOut);
|
|
51
52
|
}
|
|
52
53
|
|
|
54
|
+
/// @dev refer to the internal function
|
|
53
55
|
function redeemPyToToken(
|
|
54
56
|
address receiver,
|
|
55
57
|
address YT,
|
|
56
58
|
uint256 netPyIn,
|
|
57
59
|
TokenOutput calldata output
|
|
58
60
|
) external returns (uint256 netTokenOut) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
uint256 netSyToRedeem = _redeemPyToSy(_syOrBulk(SY, output), YT, netPyIn, 1);
|
|
62
|
-
netTokenOut = _redeemSyToToken(receiver, SY, netSyToRedeem, output, false);
|
|
63
|
-
|
|
61
|
+
netTokenOut = _redeemPyToToken(receiver, YT, netPyIn, output, true);
|
|
64
62
|
emit RedeemPyToToken(msg.sender, receiver, YT, netPyIn, output.tokenOut, netTokenOut);
|
|
65
63
|
}
|
|
66
64
|
|
|
@@ -80,7 +78,7 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
80
78
|
uint256 netPyIn,
|
|
81
79
|
uint256 minSyOut
|
|
82
80
|
) external returns (uint256 netSyOut) {
|
|
83
|
-
netSyOut = _redeemPyToSy(receiver, YT, netPyIn, minSyOut);
|
|
81
|
+
netSyOut = _redeemPyToSy(receiver, YT, netPyIn, minSyOut, true);
|
|
84
82
|
emit RedeemPyToSy(msg.sender, receiver, YT, netPyIn, netSyOut);
|
|
85
83
|
}
|
|
86
84
|
|
|
@@ -183,14 +181,13 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
183
181
|
|
|
184
182
|
// guaranteed no ETH, all rewards are ERC20
|
|
185
183
|
for (uint256 i = 0; i < tokensOut.tokens.length; ++i) {
|
|
186
|
-
|
|
187
|
-
IERC20(tokensOut.tokens[i]),
|
|
184
|
+
IERC20(tokensOut.tokens[i]).safeTransferFrom(
|
|
188
185
|
msg.sender,
|
|
189
186
|
address(this),
|
|
190
187
|
tokensOut.amounts[i]
|
|
191
188
|
);
|
|
192
189
|
}
|
|
193
|
-
_redeemAllSys(sysOut, dataYT.
|
|
190
|
+
_redeemAllSys(sysOut, dataYT.tokenRedeemSys, tokensOut);
|
|
194
191
|
|
|
195
192
|
// now swap all to outputToken
|
|
196
193
|
netTokenOut = _swapAllToOutputToken(tokensOut, dataSwap);
|
|
@@ -221,19 +218,18 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
221
218
|
/// @dev pull SYs from users & redeem them, then add to tokensOut
|
|
222
219
|
function _redeemAllSys(
|
|
223
220
|
RouterTokenAmounts memory sys,
|
|
224
|
-
address[] calldata bulks,
|
|
225
221
|
address[] calldata tokenRedeemSys,
|
|
226
222
|
RouterTokenAmounts memory tokensOut
|
|
227
223
|
) internal {
|
|
228
224
|
for (uint256 i = 0; i < sys.tokens.length; ++i) {
|
|
229
225
|
if (sys.amounts[i] == 0) continue;
|
|
230
226
|
|
|
231
|
-
|
|
232
|
-
uint256 amountOut =
|
|
227
|
+
IERC20(sys.tokens[i]).safeTransferFrom(msg.sender, sys.tokens[i], sys.amounts[i]);
|
|
228
|
+
uint256 amountOut = IStandardizedYield(sys.tokens[i]).redeem(
|
|
233
229
|
address(this),
|
|
234
|
-
sys.tokens[i],
|
|
235
230
|
sys.amounts[i],
|
|
236
|
-
|
|
231
|
+
tokenRedeemSys[i],
|
|
232
|
+
1,
|
|
237
233
|
true
|
|
238
234
|
);
|
|
239
235
|
|
|
@@ -247,12 +243,7 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
|
|
|
247
243
|
) internal returns (uint256 netTokenOut) {
|
|
248
244
|
for (uint256 i = 0; i < tokens.tokens.length; ++i) {
|
|
249
245
|
if (tokens.amounts[i] == 0) continue;
|
|
250
|
-
_kyberswap(
|
|
251
|
-
tokens.tokens[i],
|
|
252
|
-
tokens.amounts[i],
|
|
253
|
-
dataSwap.kyberRouter,
|
|
254
|
-
dataSwap.kybercalls[i]
|
|
255
|
-
);
|
|
246
|
+
_kyberswap(tokens.tokens[i], tokens.amounts[i], dataSwap.kybercalls[i]);
|
|
256
247
|
}
|
|
257
248
|
netTokenOut = _selfBalance(dataSwap.outputToken);
|
|
258
249
|
_transferOut(dataSwap.outputToken, msg.sender, netTokenOut);
|
|
@@ -12,11 +12,12 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
|
|
|
12
12
|
using MarketApproxPtOutLib for MarketState;
|
|
13
13
|
using Math for uint256;
|
|
14
14
|
using Math for int256;
|
|
15
|
+
using SafeERC20 for IERC20;
|
|
15
16
|
using PYIndexLib for IPYieldToken;
|
|
16
17
|
|
|
17
18
|
/// @dev since this contract will be proxied, it must not contains non-immutable variables
|
|
18
|
-
constructor(address
|
|
19
|
-
ActionBaseMintRedeem(
|
|
19
|
+
constructor(address _kyberSwapRouter)
|
|
20
|
+
ActionBaseMintRedeem(_kyberSwapRouter) //solhint-disable-next-line no-empty-blocks
|
|
20
21
|
{}
|
|
21
22
|
|
|
22
23
|
function swapExactPtForSy(
|
|
@@ -26,7 +27,7 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
|
|
|
26
27
|
uint256 minSyOut
|
|
27
28
|
) external returns (uint256 netSyOut, uint256 netSyFee) {
|
|
28
29
|
(, IPPrincipalToken PT, ) = IPMarket(market).readTokens();
|
|
29
|
-
|
|
30
|
+
IERC20(address(PT)).safeTransferFrom(msg.sender, market, exactPtIn);
|
|
30
31
|
|
|
31
32
|
(netSyOut, netSyFee) = IPMarket(market).swapExactPtForSy(receiver, exactPtIn, EMPTY_BYTES);
|
|
32
33
|
|
|
@@ -58,7 +59,7 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
|
|
|
58
59
|
|
|
59
60
|
if (netPtIn > maxPtIn) revert Errors.RouterExceededLimitPtIn(netPtIn, maxPtIn);
|
|
60
61
|
|
|
61
|
-
|
|
62
|
+
IERC20(PT).safeTransferFrom(msg.sender, market, netPtIn);
|
|
62
63
|
|
|
63
64
|
uint256 netSyOut;
|
|
64
65
|
(netSyOut, netSyFee) = IPMarket(market).swapExactPtForSy(receiver, netPtIn, EMPTY_BYTES);
|
|
@@ -82,7 +83,7 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
|
|
|
82
83
|
|
|
83
84
|
if (netSyIn > maxSyIn) revert Errors.RouterExceededLimitSyIn(netSyIn, maxSyIn);
|
|
84
85
|
|
|
85
|
-
|
|
86
|
+
IERC20(SY).safeTransferFrom(msg.sender, market, netSyIn);
|
|
86
87
|
|
|
87
88
|
(, netSyFee) = IPMarket(market).swapSyForExactPt(receiver, exactPtOut, EMPTY_BYTES); // ignore return
|
|
88
89
|
|
|
@@ -99,7 +100,7 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
|
|
|
99
100
|
) external returns (uint256 netPtOut, uint256 netSyFee) {
|
|
100
101
|
(IStandardizedYield SY, , IPYieldToken YT) = IPMarket(market).readTokens();
|
|
101
102
|
|
|
102
|
-
|
|
103
|
+
IERC20(SY).safeTransferFrom(msg.sender, market, exactSyIn);
|
|
103
104
|
|
|
104
105
|
(netPtOut, netSyFee) = _swapExactSyForPt(
|
|
105
106
|
receiver,
|
|
@@ -162,12 +163,12 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
|
|
|
162
163
|
) external returns (uint256 netTokenOut, uint256 netSyFee) {
|
|
163
164
|
(IStandardizedYield SY, IPPrincipalToken PT, ) = IPMarket(market).readTokens();
|
|
164
165
|
|
|
165
|
-
|
|
166
|
+
IERC20(address(PT)).safeTransferFrom(msg.sender, market, exactPtIn);
|
|
166
167
|
|
|
167
168
|
// all output SY is directly transferred to the SY contract
|
|
168
169
|
uint256 netSyReceived;
|
|
169
170
|
(netSyReceived, netSyFee) = IPMarket(market).swapExactPtForSy(
|
|
170
|
-
|
|
171
|
+
address(SY),
|
|
171
172
|
exactPtIn,
|
|
172
173
|
EMPTY_BYTES
|
|
173
174
|
);
|
|
@@ -5,13 +5,17 @@ import "../interfaces/IPActionSwapPTYT.sol";
|
|
|
5
5
|
import "../interfaces/IPMarket.sol";
|
|
6
6
|
import "./base/CallbackHelper.sol";
|
|
7
7
|
|
|
8
|
-
contract ActionSwapPTYT is IPActionSwapPTYT, CallbackHelper
|
|
8
|
+
contract ActionSwapPTYT is IPActionSwapPTYT, CallbackHelper {
|
|
9
9
|
using MarketMathCore for MarketState;
|
|
10
10
|
using MarketApproxPtInLib for MarketState;
|
|
11
11
|
using MarketApproxPtOutLib for MarketState;
|
|
12
12
|
using Math for uint256;
|
|
13
13
|
using Math for int256;
|
|
14
|
+
using SafeERC20 for IERC20;
|
|
14
15
|
using PYIndexLib for IPYieldToken;
|
|
16
|
+
using SafeERC20 for IStandardizedYield;
|
|
17
|
+
using SafeERC20 for IPYieldToken;
|
|
18
|
+
using SafeERC20 for IPPrincipalToken;
|
|
15
19
|
|
|
16
20
|
/// @dev since this contract will be proxied, it must not contains non-immutable variables
|
|
17
21
|
constructor() //solhint-disable-next-line no-empty-blocks
|
|
@@ -29,7 +33,7 @@ contract ActionSwapPTYT is IPActionSwapPTYT, CallbackHelper, TokenHelper {
|
|
|
29
33
|
(, IPPrincipalToken PT, IPYieldToken YT) = IPMarket(market).readTokens();
|
|
30
34
|
MarketState memory state = IPMarket(market).readState();
|
|
31
35
|
|
|
32
|
-
|
|
36
|
+
PT.safeTransferFrom(msg.sender, market, exactPtIn);
|
|
33
37
|
|
|
34
38
|
uint256 totalPtToSwap;
|
|
35
39
|
(netYtOut, totalPtToSwap, netSyFee) = state.approxSwapExactPtForYt(
|
|
@@ -60,7 +64,7 @@ contract ActionSwapPTYT is IPActionSwapPTYT, CallbackHelper, TokenHelper {
|
|
|
60
64
|
(, , IPYieldToken YT) = IPMarket(market).readTokens();
|
|
61
65
|
MarketState memory state = IPMarket(market).readState();
|
|
62
66
|
|
|
63
|
-
|
|
67
|
+
YT.safeTransferFrom(msg.sender, address(YT), exactYtIn);
|
|
64
68
|
|
|
65
69
|
uint256 totalPtSwapped;
|
|
66
70
|
(netPtOut, totalPtSwapped, netSyFee) = state.approxSwapExactYtForPt(
|
|
@@ -13,11 +13,13 @@ contract ActionSwapYT is IPActionSwapYT, ActionBaseMintRedeem, CallbackHelper {
|
|
|
13
13
|
using MarketMathCore for MarketState;
|
|
14
14
|
using MarketApproxPtInLib for MarketState;
|
|
15
15
|
using MarketApproxPtOutLib for MarketState;
|
|
16
|
+
using SafeERC20 for IStandardizedYield;
|
|
17
|
+
using SafeERC20 for IPYieldToken;
|
|
16
18
|
using PYIndexLib for IPYieldToken;
|
|
17
19
|
|
|
18
20
|
/// @dev since this contract will be proxied, it must not contains non-immutable variables
|
|
19
|
-
constructor(address
|
|
20
|
-
ActionBaseMintRedeem(
|
|
21
|
+
constructor(address _kyberSwapRouter)
|
|
22
|
+
ActionBaseMintRedeem(_kyberSwapRouter) //solhint-disable-next-line no-empty-blocks
|
|
21
23
|
{}
|
|
22
24
|
|
|
23
25
|
/**
|
|
@@ -39,7 +41,7 @@ contract ActionSwapYT is IPActionSwapYT, ActionBaseMintRedeem, CallbackHelper {
|
|
|
39
41
|
) external returns (uint256 netYtOut, uint256 netSyFee) {
|
|
40
42
|
(IStandardizedYield SY, , IPYieldToken YT) = IPMarket(market).readTokens();
|
|
41
43
|
|
|
42
|
-
|
|
44
|
+
SY.safeTransferFrom(msg.sender, address(YT), exactSyIn);
|
|
43
45
|
|
|
44
46
|
(netYtOut, netSyFee) = _swapExactSyForYt(
|
|
45
47
|
receiver,
|
|
@@ -71,7 +73,7 @@ contract ActionSwapYT is IPActionSwapYT, ActionBaseMintRedeem, CallbackHelper {
|
|
|
71
73
|
) external returns (uint256 netSyOut, uint256 netSyFee) {
|
|
72
74
|
(IStandardizedYield SY, , IPYieldToken YT) = IPMarket(market).readTokens();
|
|
73
75
|
|
|
74
|
-
|
|
76
|
+
YT.safeTransferFrom(msg.sender, address(YT), exactYtIn);
|
|
75
77
|
|
|
76
78
|
(netSyOut, netSyFee) = _swapExactYtForSy(receiver, market, SY, YT, exactYtIn, minSyOut);
|
|
77
79
|
|
|
@@ -137,7 +139,7 @@ contract ActionSwapYT is IPActionSwapYT, ActionBaseMintRedeem, CallbackHelper {
|
|
|
137
139
|
|
|
138
140
|
if (netYtIn > maxYtIn) revert Errors.RouterExceededLimitYtIn(netYtIn, maxYtIn);
|
|
139
141
|
|
|
140
|
-
|
|
142
|
+
YT.safeTransferFrom(msg.sender, address(YT), netYtIn);
|
|
141
143
|
|
|
142
144
|
(, netSyFee) = IPMarket(market).swapSyForExactPt(
|
|
143
145
|
address(YT),
|
|
@@ -186,18 +188,11 @@ contract ActionSwapYT is IPActionSwapYT, ActionBaseMintRedeem, CallbackHelper {
|
|
|
186
188
|
) external returns (uint256 netTokenOut, uint256 netSyFee) {
|
|
187
189
|
(IStandardizedYield SY, , IPYieldToken YT) = IPMarket(market).readTokens();
|
|
188
190
|
|
|
189
|
-
|
|
191
|
+
YT.safeTransferFrom(msg.sender, address(YT), netYtIn);
|
|
190
192
|
|
|
191
193
|
uint256 netSyOut;
|
|
192
194
|
|
|
193
|
-
(netSyOut, netSyFee) = _swapExactYtForSy(
|
|
194
|
-
_syOrBulk(address(SY), output),
|
|
195
|
-
market,
|
|
196
|
-
SY,
|
|
197
|
-
YT,
|
|
198
|
-
netYtIn,
|
|
199
|
-
1
|
|
200
|
-
);
|
|
195
|
+
(netSyOut, netSyFee) = _swapExactYtForSy(address(SY), market, SY, YT, netYtIn, 1);
|
|
201
196
|
|
|
202
197
|
netTokenOut = _redeemSyToToken(receiver, address(SY), netSyOut, output, false);
|
|
203
198
|
|
|
@@ -252,7 +247,7 @@ contract ActionSwapYT is IPActionSwapYT, ActionBaseMintRedeem, CallbackHelper {
|
|
|
252
247
|
address(YT),
|
|
253
248
|
exactYtIn, // exactPtOut = exactYtIn
|
|
254
249
|
_encodeSwapYtForSy(receiver, minSyOut)
|
|
255
|
-
);
|
|
250
|
+
); // ignore return
|
|
256
251
|
|
|
257
252
|
netSyOut = SY.balanceOf(receiver) - preSyBalance;
|
|
258
253
|
}
|