@pendle/core-v2 0.15.2-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 -16
- package/deployments/1-markets/FRAX_30_MAR_23.json +0 -8
- 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 -8
- 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
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
-
pragma solidity 0.8.17;
|
|
3
|
-
|
|
4
|
-
import "../libraries/TokenHelper.sol";
|
|
5
|
-
import "../libraries/math/Math.sol";
|
|
6
|
-
import "../libraries/Errors.sol";
|
|
7
|
-
|
|
8
|
-
struct BulkSellerState {
|
|
9
|
-
uint256 rateTokenToSy;
|
|
10
|
-
uint256 rateSyToToken;
|
|
11
|
-
uint256 totalToken;
|
|
12
|
-
uint256 totalSy;
|
|
13
|
-
uint256 feeRate;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
library BulkSellerMathCore {
|
|
17
|
-
using Math for uint256;
|
|
18
|
-
|
|
19
|
-
function swapExactTokenForSy(BulkSellerState memory state, uint256 netTokenIn)
|
|
20
|
-
internal
|
|
21
|
-
pure
|
|
22
|
-
returns (uint256 netSyOut)
|
|
23
|
-
{
|
|
24
|
-
netSyOut = calcSwapExactTokenForSy(state, netTokenIn);
|
|
25
|
-
state.totalToken += netTokenIn;
|
|
26
|
-
state.totalSy -= netSyOut;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function swapExactSyForToken(BulkSellerState memory state, uint256 netSyIn)
|
|
30
|
-
internal
|
|
31
|
-
pure
|
|
32
|
-
returns (uint256 netTokenOut)
|
|
33
|
-
{
|
|
34
|
-
netTokenOut = calcSwapExactSyForToken(state, netSyIn);
|
|
35
|
-
state.totalSy += netSyIn;
|
|
36
|
-
state.totalToken -= netTokenOut;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function calcSwapExactTokenForSy(BulkSellerState memory state, uint256 netTokenIn)
|
|
40
|
-
internal
|
|
41
|
-
pure
|
|
42
|
-
returns (uint256 netSyOut)
|
|
43
|
-
{
|
|
44
|
-
uint256 postFeeRate = state.rateTokenToSy.mulDown(Math.ONE - state.feeRate);
|
|
45
|
-
assert(postFeeRate != 0);
|
|
46
|
-
|
|
47
|
-
netSyOut = netTokenIn.mulDown(postFeeRate);
|
|
48
|
-
if (netSyOut > state.totalSy)
|
|
49
|
-
revert Errors.BulkInsufficientSyForTrade(state.totalSy, netSyOut);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function calcSwapExactSyForToken(BulkSellerState memory state, uint256 netSyIn)
|
|
53
|
-
internal
|
|
54
|
-
pure
|
|
55
|
-
returns (uint256 netTokenOut)
|
|
56
|
-
{
|
|
57
|
-
uint256 postFeeRate = state.rateSyToToken.mulDown(Math.ONE - state.feeRate);
|
|
58
|
-
assert(postFeeRate != 0);
|
|
59
|
-
|
|
60
|
-
netTokenOut = netSyIn.mulDown(postFeeRate);
|
|
61
|
-
if (netTokenOut > state.totalToken)
|
|
62
|
-
revert Errors.BulkInsufficientTokenForTrade(state.totalToken, netTokenOut);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function getTokenProp(BulkSellerState memory state) internal pure returns (uint256) {
|
|
66
|
-
uint256 totalToken = state.totalToken;
|
|
67
|
-
uint256 totalTokenFromSy = state.totalSy.mulDown(state.rateSyToToken);
|
|
68
|
-
return totalToken.divDown(totalToken + totalTokenFromSy);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function getReBalanceParams(BulkSellerState memory state, uint256 targetTokenProp)
|
|
72
|
-
internal
|
|
73
|
-
pure
|
|
74
|
-
returns (uint256 netTokenToDeposit, uint256 netSyToRedeem)
|
|
75
|
-
{
|
|
76
|
-
uint256 currentTokenProp = getTokenProp(state);
|
|
77
|
-
|
|
78
|
-
if (currentTokenProp > targetTokenProp) {
|
|
79
|
-
netTokenToDeposit = state.totalToken.mulDown(
|
|
80
|
-
(currentTokenProp - targetTokenProp).divDown(currentTokenProp)
|
|
81
|
-
);
|
|
82
|
-
} else {
|
|
83
|
-
uint256 currentSyProp = Math.ONE - currentTokenProp;
|
|
84
|
-
netSyToRedeem = state.totalSy.mulDown(
|
|
85
|
-
(targetTokenProp - currentTokenProp).divDown(currentSyProp)
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function reBalanceTokenToSy(
|
|
91
|
-
BulkSellerState memory state,
|
|
92
|
-
uint256 netTokenToDeposit,
|
|
93
|
-
uint256 netSyFromToken,
|
|
94
|
-
uint256 maxDiff
|
|
95
|
-
) internal pure {
|
|
96
|
-
uint256 rate = netSyFromToken.divDown(netTokenToDeposit);
|
|
97
|
-
|
|
98
|
-
if (!Math.isAApproxB(rate, state.rateTokenToSy, maxDiff))
|
|
99
|
-
revert Errors.BulkBadRateTokenToSy(rate, state.rateTokenToSy, maxDiff);
|
|
100
|
-
|
|
101
|
-
state.totalToken -= netTokenToDeposit;
|
|
102
|
-
state.totalSy += netSyFromToken;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function reBalanceSyToToken(
|
|
106
|
-
BulkSellerState memory state,
|
|
107
|
-
uint256 netSyToRedeem,
|
|
108
|
-
uint256 netTokenFromSy,
|
|
109
|
-
uint256 maxDiff
|
|
110
|
-
) internal pure {
|
|
111
|
-
uint256 rate = netTokenFromSy.divDown(netSyToRedeem);
|
|
112
|
-
|
|
113
|
-
if (!Math.isAApproxB(rate, state.rateSyToToken, maxDiff))
|
|
114
|
-
revert Errors.BulkBadRateSyToToken(rate, state.rateSyToToken, maxDiff);
|
|
115
|
-
|
|
116
|
-
state.totalToken += netTokenFromSy;
|
|
117
|
-
state.totalSy -= netSyToRedeem;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function setRate(
|
|
121
|
-
BulkSellerState memory state,
|
|
122
|
-
uint256 rateSyToToken,
|
|
123
|
-
uint256 rateTokenToSy,
|
|
124
|
-
uint256 maxDiff
|
|
125
|
-
) internal pure {
|
|
126
|
-
if (
|
|
127
|
-
state.rateTokenToSy != 0 &&
|
|
128
|
-
!Math.isAApproxB(rateTokenToSy, state.rateTokenToSy, maxDiff)
|
|
129
|
-
) {
|
|
130
|
-
revert Errors.BulkBadRateTokenToSy(rateTokenToSy, state.rateTokenToSy, maxDiff);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (
|
|
134
|
-
state.rateSyToToken != 0 &&
|
|
135
|
-
!Math.isAApproxB(rateSyToToken, state.rateSyToToken, maxDiff)
|
|
136
|
-
) {
|
|
137
|
-
revert Errors.BulkBadRateSyToToken(rateSyToToken, state.rateSyToToken, maxDiff);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
state.rateTokenToSy = rateTokenToSy;
|
|
141
|
-
state.rateSyToToken = rateSyToToken;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
-
pragma solidity 0.8.17;
|
|
3
|
-
|
|
4
|
-
import "./base/PendleConvexLPSY.sol";
|
|
5
|
-
import "./base/CurveFraxUsdcPoolHelper.sol";
|
|
6
|
-
import "../../../libraries/ArrayLib.sol";
|
|
7
|
-
|
|
8
|
-
contract PendleCurveFraxUsdcSY is PendleConvexLPSY {
|
|
9
|
-
using ArrayLib for address[];
|
|
10
|
-
|
|
11
|
-
uint256 public constant PID = 100;
|
|
12
|
-
|
|
13
|
-
address public constant FRAX = CurveFraxUsdcPoolHelper.FRAX;
|
|
14
|
-
address public constant USDC = CurveFraxUsdcPoolHelper.USDC;
|
|
15
|
-
|
|
16
|
-
constructor(string memory _name, string memory _symbol)
|
|
17
|
-
PendleConvexLPSY(
|
|
18
|
-
_name,
|
|
19
|
-
_symbol,
|
|
20
|
-
PID,
|
|
21
|
-
CurveFraxUsdcPoolHelper.LP,
|
|
22
|
-
CurveFraxUsdcPoolHelper.POOL
|
|
23
|
-
)
|
|
24
|
-
{
|
|
25
|
-
_safeApproveInf(FRAX, crvPool);
|
|
26
|
-
_safeApproveInf(USDC, crvPool);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function _depositToCurve(address tokenIn, uint256 amountTokenToDeposit)
|
|
30
|
-
internal
|
|
31
|
-
virtual
|
|
32
|
-
override
|
|
33
|
-
returns (uint256 amountLpOut)
|
|
34
|
-
{
|
|
35
|
-
uint256[2] memory amounts;
|
|
36
|
-
amounts[_getIndex(tokenIn)] = amountTokenToDeposit;
|
|
37
|
-
amountLpOut = ICrvPool(crvPool).add_liquidity(amounts, 0);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function _redeemFromCurve(address tokenOut, uint256 amountLpToRedeem)
|
|
41
|
-
internal
|
|
42
|
-
virtual
|
|
43
|
-
override
|
|
44
|
-
returns (uint256 amountTokenOut)
|
|
45
|
-
{
|
|
46
|
-
amountTokenOut = ICrvPool(crvPool).remove_liquidity_one_coin(
|
|
47
|
-
amountLpToRedeem,
|
|
48
|
-
Math.Int128(_getIndex(tokenOut)),
|
|
49
|
-
0
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function _previewDepositToCurve(address tokenIn, uint256 amountTokenToDeposit)
|
|
54
|
-
internal
|
|
55
|
-
view
|
|
56
|
-
virtual
|
|
57
|
-
override
|
|
58
|
-
returns (uint256)
|
|
59
|
-
{
|
|
60
|
-
return CurveFraxUsdcPoolHelper.previewAddLiquidity(tokenIn, amountTokenToDeposit);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function _previewRedeemFromCurve(address tokenOut, uint256 amountLpToRedeem)
|
|
64
|
-
internal
|
|
65
|
-
view
|
|
66
|
-
virtual
|
|
67
|
-
override
|
|
68
|
-
returns (uint256)
|
|
69
|
-
{
|
|
70
|
-
return
|
|
71
|
-
ICrvPool(crvPool).calc_withdraw_one_coin(
|
|
72
|
-
amountLpToRedeem,
|
|
73
|
-
Math.Int128(_getIndex(tokenOut))
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function _getIndex(address token) internal pure returns (uint256) {
|
|
78
|
-
return (token == FRAX ? 0 : 1);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function getTokensIn() public view virtual override returns (address[] memory res) {
|
|
82
|
-
res = new address[](3);
|
|
83
|
-
res[0] = crvLp;
|
|
84
|
-
res[1] = FRAX;
|
|
85
|
-
res[2] = USDC;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function getTokensOut() public view virtual override returns (address[] memory res) {
|
|
89
|
-
res = new address[](3);
|
|
90
|
-
res[0] = crvLp;
|
|
91
|
-
res[1] = FRAX;
|
|
92
|
-
res[2] = USDC;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function isValidTokenIn(address token) public view virtual override returns (bool res) {
|
|
96
|
-
res = (token == crvLp || token == FRAX || token == USDC);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function isValidTokenOut(address token) public view override returns (bool res) {
|
|
100
|
-
res = (token == crvLp || token == FRAX || token == USDC);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
-
pragma solidity 0.8.17;
|
|
3
|
-
|
|
4
|
-
import "./base/PendleConvexLPSY.sol";
|
|
5
|
-
import "./base/CurveUsdd3CrvPoolHelper.sol";
|
|
6
|
-
import "../../../libraries/ArrayLib.sol";
|
|
7
|
-
|
|
8
|
-
contract PendleCurveUsdd3CrvSY is PendleConvexLPSY {
|
|
9
|
-
using ArrayLib for address[];
|
|
10
|
-
|
|
11
|
-
uint256 public constant PID = 96;
|
|
12
|
-
address public constant USDD = CurveUsdd3CrvPoolHelper.USDD;
|
|
13
|
-
address public constant LP_3CRV = Curve3CrvPoolHelper.LP;
|
|
14
|
-
address public constant DAI = Curve3CrvPoolHelper.DAI;
|
|
15
|
-
address public constant USDC = Curve3CrvPoolHelper.USDC;
|
|
16
|
-
address public constant USDT = Curve3CrvPoolHelper.USDT;
|
|
17
|
-
address public constant POOL_3CRV = Curve3CrvPoolHelper.POOL;
|
|
18
|
-
uint256 public constant INDEX_OF_3CRV = 1;
|
|
19
|
-
|
|
20
|
-
constructor(string memory _name, string memory _symbol)
|
|
21
|
-
PendleConvexLPSY(
|
|
22
|
-
_name,
|
|
23
|
-
_symbol,
|
|
24
|
-
PID,
|
|
25
|
-
CurveUsdd3CrvPoolHelper.POOL,
|
|
26
|
-
CurveUsdd3CrvPoolHelper.POOL
|
|
27
|
-
)
|
|
28
|
-
{
|
|
29
|
-
_safeApproveInf(USDD, crvPool);
|
|
30
|
-
_safeApproveInf(LP_3CRV, crvPool);
|
|
31
|
-
_safeApproveInf(DAI, POOL_3CRV);
|
|
32
|
-
_safeApproveInf(USDC, POOL_3CRV);
|
|
33
|
-
_safeApproveInf(USDT, POOL_3CRV);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function _depositToCurve(address tokenIn, uint256 amountTokenToDeposit)
|
|
37
|
-
internal
|
|
38
|
-
virtual
|
|
39
|
-
override
|
|
40
|
-
returns (uint256 amountLpOut)
|
|
41
|
-
{
|
|
42
|
-
uint256 preBalanceLp = _selfBalance(crvLp);
|
|
43
|
-
|
|
44
|
-
uint256[2] memory amounts;
|
|
45
|
-
|
|
46
|
-
if (Curve3CrvPoolHelper.is3CrvToken(tokenIn)) {
|
|
47
|
-
uint256 amount3CrvLp = Curve3CrvPoolHelper.deposit3Crv(tokenIn, amountTokenToDeposit);
|
|
48
|
-
amounts[INDEX_OF_3CRV] = amount3CrvLp;
|
|
49
|
-
} else {
|
|
50
|
-
// one of the 2 LP
|
|
51
|
-
amounts[_getIndex(tokenIn)] = amountTokenToDeposit;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
ICrvPool(crvPool).add_liquidity(amounts, 0);
|
|
55
|
-
|
|
56
|
-
amountLpOut = _selfBalance(crvLp) - preBalanceLp;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function _redeemFromCurve(address tokenOut, uint256 amountLpToRedeem)
|
|
60
|
-
internal
|
|
61
|
-
virtual
|
|
62
|
-
override
|
|
63
|
-
returns (uint256 amountTokenOut)
|
|
64
|
-
{
|
|
65
|
-
address tokenToRemove = (tokenOut == USDD) ? USDD : LP_3CRV;
|
|
66
|
-
|
|
67
|
-
uint256 preBalanceToken = _selfBalance(tokenToRemove);
|
|
68
|
-
|
|
69
|
-
ICrvPool(crvPool).remove_liquidity_one_coin(
|
|
70
|
-
amountLpToRedeem,
|
|
71
|
-
Math.Int128(_getIndex(tokenToRemove)),
|
|
72
|
-
0
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
uint256 amountTokenRemoved = _selfBalance(tokenToRemove) - preBalanceToken;
|
|
76
|
-
|
|
77
|
-
if (Curve3CrvPoolHelper.is3CrvToken(tokenOut)) {
|
|
78
|
-
amountTokenOut = Curve3CrvPoolHelper.redeem3Crv(tokenOut, amountTokenRemoved);
|
|
79
|
-
} else {
|
|
80
|
-
// one of the 2 LP
|
|
81
|
-
amountTokenOut = amountTokenRemoved;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function _previewDepositToCurve(address tokenIn, uint256 amountTokenToDeposit)
|
|
86
|
-
internal
|
|
87
|
-
view
|
|
88
|
-
virtual
|
|
89
|
-
override
|
|
90
|
-
returns (uint256)
|
|
91
|
-
{
|
|
92
|
-
return CurveUsdd3CrvPoolHelper.previewAddLiquidity(tokenIn, amountTokenToDeposit);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function _previewRedeemFromCurve(address tokenOut, uint256 amountLpToRedeem)
|
|
96
|
-
internal
|
|
97
|
-
view
|
|
98
|
-
virtual
|
|
99
|
-
override
|
|
100
|
-
returns (uint256)
|
|
101
|
-
{
|
|
102
|
-
address tokenToRemove = tokenOut == USDD ? USDD : LP_3CRV;
|
|
103
|
-
uint256 amountTokenRemoved = ICrvPool(crvPool).calc_withdraw_one_coin(
|
|
104
|
-
amountLpToRedeem,
|
|
105
|
-
Math.Int128(_getIndex(tokenToRemove))
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
if (Curve3CrvPoolHelper.is3CrvToken(tokenOut)) {
|
|
109
|
-
return Curve3CrvPoolHelper.preview3CrvRedeem(tokenOut, amountTokenRemoved);
|
|
110
|
-
} else {
|
|
111
|
-
// one of the 2 LP
|
|
112
|
-
return amountTokenRemoved;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function _getIndex(address token) internal pure returns (uint256) {
|
|
117
|
-
return (token == USDD ? 0 : 1);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function getTokensIn() public view virtual override returns (address[] memory res) {
|
|
121
|
-
res = new address[](6);
|
|
122
|
-
res[0] = crvLp;
|
|
123
|
-
res[1] = USDD;
|
|
124
|
-
res[2] = LP_3CRV;
|
|
125
|
-
res[3] = DAI;
|
|
126
|
-
res[4] = USDC;
|
|
127
|
-
res[5] = USDT;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function getTokensOut() public view virtual override returns (address[] memory res) {
|
|
131
|
-
res = new address[](6);
|
|
132
|
-
res[0] = crvLp;
|
|
133
|
-
res[1] = USDD;
|
|
134
|
-
res[2] = LP_3CRV;
|
|
135
|
-
res[3] = DAI;
|
|
136
|
-
res[4] = USDC;
|
|
137
|
-
res[5] = USDT;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
function isValidTokenIn(address token) public view virtual override returns (bool res) {
|
|
141
|
-
res = (token == crvLp ||
|
|
142
|
-
token == USDD ||
|
|
143
|
-
token == LP_3CRV ||
|
|
144
|
-
Curve3CrvPoolHelper.is3CrvToken(token));
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
function isValidTokenOut(address token) public view override returns (bool res) {
|
|
148
|
-
res = (token == crvLp ||
|
|
149
|
-
token == USDD ||
|
|
150
|
-
token == LP_3CRV ||
|
|
151
|
-
Curve3CrvPoolHelper.is3CrvToken(token));
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function _getRewardTokens() internal pure override returns (address[] memory rewardTokens) {
|
|
155
|
-
rewardTokens = new address[](3);
|
|
156
|
-
rewardTokens[0] = USDD;
|
|
157
|
-
rewardTokens[1] = CRV;
|
|
158
|
-
rewardTokens[2] = CVX;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# PENDLE Curve/Convex SY
|
|
2
|
-
|
|
3
|
-
For the simplicity of the writeup, we will describe only the noticable properties of `PendleCurveUSDD3CrvSY`. `PendleCurveFraxUsdcSY` contract should contain only a subset of those properties compared to USDD one.
|
|
4
|
-
|
|
5
|
-
## Token in/out flow
|
|
6
|
-
|
|
7
|
-
We support USDD/USDC/DAI/USDT and the two LPs as in and out tokens. Tokens after being deposited to Curve to get back LP USDD/3Crv will be staked into Convex reward system to gain rewards of:
|
|
8
|
-
|
|
9
|
-
- USDD
|
|
10
|
-
- CRV
|
|
11
|
-
- CVX
|
|
12
|
-
|
|
13
|
-

|
|
14
|
-
|
|
15
|
-
## Exchange Rate
|
|
16
|
-
|
|
17
|
-
Asset type for this SY should be in type of Liquidity. For exchange rate, we use Curve's `pool.get_virtual_price()` as it shows the growth in price of LP token respecting to the swap fees earned by the pool.
|
|
18
|
-
|
|
19
|
-
## Preview functions
|
|
20
|
-
|
|
21
|
-
Before getting to this, we would like to note that preview functions will play an important role in Pendle's off-chain system. Hence, it is essential for preview function returns the actual outcome that user can get by calling `deposit/redeem`.
|
|
22
|
-
|
|
23
|
-
For preview redeem, Curve provides a view function of `calc_withdraw_one_coin` which accurately returns the amount of token can be redeem by user with a particular amount of LP.
|
|
24
|
-
|
|
25
|
-
For previde deposit, Curve's provided function `calc_token_amount` does not take into account the fee, thus, it does not return the actual amount of lp token user can get.
|
|
26
|
-
|
|
27
|
-
We implemented a workaround for previewDeposit in `CurveUsdd3CrvPoolHelper` and `Curve3CrvPoolHelper` to simulate the calculation happened in Curve's code base.
|
|
28
|
-
|
|
29
|
-
Another thing to note is that `CurveUsdd3CrvPoolHelper`'s preivew deposit result has a dependency on the `3crv.get_virtual_price`. So the simulation should also take into account the case when user deposits with DAI/USDC/USDT, the state of 3Crv pool changes, and thus the `get_virtual_price` of 3crv changes.
|
package/contracts/core/StandardizedYield/implementations/Convex/base/Curve3CrvPoolHelper.sol
DELETED
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
-
pragma solidity 0.8.17;
|
|
3
|
-
|
|
4
|
-
import "../../../../libraries/math/Math.sol";
|
|
5
|
-
import "../../../../../interfaces/Curve/ITriCrvPool.sol";
|
|
6
|
-
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
|
7
|
-
|
|
8
|
-
library Curve3CrvPoolHelper {
|
|
9
|
-
using Math for uint256;
|
|
10
|
-
|
|
11
|
-
uint256 internal constant N_COINS = 3;
|
|
12
|
-
uint256 internal constant PRECISION = 10**18;
|
|
13
|
-
uint256 internal constant RATE_0 = 1000000000000000000;
|
|
14
|
-
uint256 internal constant RATE_1 = 1000000000000000000000000000000;
|
|
15
|
-
uint256 internal constant RATE_2 = 1000000000000000000000000000000;
|
|
16
|
-
uint256 internal constant FEE_DENOMINATOR = 10**10;
|
|
17
|
-
|
|
18
|
-
address internal constant LP = 0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490;
|
|
19
|
-
address internal constant POOL = 0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7;
|
|
20
|
-
address internal constant DAI = 0x6B175474E89094C44Da98b954EedeAC495271d0F;
|
|
21
|
-
address internal constant USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
|
|
22
|
-
address internal constant USDT = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
|
|
23
|
-
|
|
24
|
-
// previewDeposit at the end of the file
|
|
25
|
-
|
|
26
|
-
function preview3CrvRedeem(address tokenOut, uint256 amountSharesToRedeem)
|
|
27
|
-
internal
|
|
28
|
-
view
|
|
29
|
-
returns (uint256)
|
|
30
|
-
{
|
|
31
|
-
return
|
|
32
|
-
ITriCrvPool(POOL).calc_withdraw_one_coin(
|
|
33
|
-
amountSharesToRedeem,
|
|
34
|
-
_get3CrvTokenIndex(tokenOut).Int128()
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function deposit3Crv(address tokenIn, uint256 amountTokenToDeposit)
|
|
39
|
-
internal
|
|
40
|
-
returns (uint256)
|
|
41
|
-
{
|
|
42
|
-
uint256 balBefore = IERC20(LP).balanceOf(address(this));
|
|
43
|
-
ITriCrvPool(POOL).add_liquidity(_getTokenAmounts(tokenIn, amountTokenToDeposit), 0);
|
|
44
|
-
uint256 balAfter = IERC20(LP).balanceOf(address(this));
|
|
45
|
-
return balAfter - balBefore;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function redeem3Crv(address tokenOut, uint256 amountSharesToRedeem)
|
|
49
|
-
internal
|
|
50
|
-
returns (uint256)
|
|
51
|
-
{
|
|
52
|
-
uint256 balBefore = IERC20(tokenOut).balanceOf(address(this));
|
|
53
|
-
ITriCrvPool(POOL).remove_liquidity_one_coin(
|
|
54
|
-
amountSharesToRedeem,
|
|
55
|
-
_get3CrvTokenIndex(tokenOut).Int128(),
|
|
56
|
-
0
|
|
57
|
-
);
|
|
58
|
-
uint256 balAfter = IERC20(tokenOut).balanceOf(address(this));
|
|
59
|
-
return balAfter - balBefore;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function _getTokenAmounts(address token, uint256 amount)
|
|
63
|
-
internal
|
|
64
|
-
pure
|
|
65
|
-
returns (uint256[N_COINS] memory res)
|
|
66
|
-
{
|
|
67
|
-
res[_get3CrvTokenIndex(token)] = amount;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function _get3CrvTokenIndex(address token) internal pure returns (uint256) {
|
|
71
|
-
if (token == DAI) return 0;
|
|
72
|
-
if (token == USDC) return 1;
|
|
73
|
-
if (token == USDT) return 2;
|
|
74
|
-
revert("Pendle3CrvHelper: not valid token");
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function is3CrvToken(address token) internal pure returns (bool) {
|
|
78
|
-
return (token == DAI || token == USDC || token == USDT);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function get_virtual_price() internal view returns (uint256) {
|
|
82
|
-
return ITriCrvPool(POOL).get_virtual_price();
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// ----------------- Forking StableSwap3Pool's calculation -----------------
|
|
86
|
-
|
|
87
|
-
// fork of StableSwap3Pool.vy
|
|
88
|
-
function preview3CrvDeposit(address token, uint256 amount)
|
|
89
|
-
internal
|
|
90
|
-
view
|
|
91
|
-
returns (uint256 netLpOut, uint256 new_virtual_price)
|
|
92
|
-
{
|
|
93
|
-
uint256[N_COINS] memory amounts = _getTokenAmounts(token, amount);
|
|
94
|
-
uint256[N_COINS] memory self_balances = _getBalances();
|
|
95
|
-
|
|
96
|
-
uint256[N_COINS] memory fees;
|
|
97
|
-
uint256 _fee = (ITriCrvPool(POOL).fee() * N_COINS) / (4 * (N_COINS - 1));
|
|
98
|
-
uint256 _admin_fee = ITriCrvPool(POOL).admin_fee();
|
|
99
|
-
uint256 amp = ITriCrvPool(POOL).A();
|
|
100
|
-
|
|
101
|
-
uint256 token_supply = IERC20(LP).totalSupply();
|
|
102
|
-
// Initial invariant
|
|
103
|
-
uint256 D0 = 0;
|
|
104
|
-
uint256[N_COINS] memory old_balances = arrayClone(self_balances);
|
|
105
|
-
D0 = get_D_mem(old_balances, amp);
|
|
106
|
-
|
|
107
|
-
uint256[N_COINS] memory new_balances = arrayClone(old_balances);
|
|
108
|
-
|
|
109
|
-
for (uint256 i = 0; i < N_COINS; ++i) {
|
|
110
|
-
new_balances[i] += amounts[i];
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
uint256 D1 = get_D_mem(new_balances, amp);
|
|
114
|
-
assert(D1 > D0);
|
|
115
|
-
|
|
116
|
-
// We need to recalculate the invariant accounting for fees
|
|
117
|
-
// to calculate fair user's share
|
|
118
|
-
uint256 D2 = D1;
|
|
119
|
-
for (uint256 i = 0; i < N_COINS; ++i) {
|
|
120
|
-
uint256 ideal_balance = (D1 * old_balances[i]) / D0;
|
|
121
|
-
uint256 difference = 0;
|
|
122
|
-
if (ideal_balance > new_balances[i]) {
|
|
123
|
-
difference = ideal_balance - new_balances[i];
|
|
124
|
-
} else {
|
|
125
|
-
difference = new_balances[i] - ideal_balance;
|
|
126
|
-
}
|
|
127
|
-
fees[i] = (_fee * difference) / FEE_DENOMINATOR;
|
|
128
|
-
self_balances[i] = new_balances[i] - ((fees[i] * _admin_fee) / FEE_DENOMINATOR);
|
|
129
|
-
new_balances[i] -= fees[i];
|
|
130
|
-
D2 = get_D_mem(new_balances, amp);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
netLpOut = (token_supply * (D2 - D0)) / D0;
|
|
134
|
-
new_virtual_price = _get_virtual_price_with_balances(
|
|
135
|
-
self_balances,
|
|
136
|
-
token_supply + netLpOut
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
function _get_virtual_price_with_balances(
|
|
141
|
-
uint256[N_COINS] memory balances,
|
|
142
|
-
uint256 token_supply
|
|
143
|
-
) internal view returns (uint256) {
|
|
144
|
-
uint256 amp = ITriCrvPool(POOL).A();
|
|
145
|
-
uint256 D = get_D_mem(balances, amp);
|
|
146
|
-
return (D * PRECISION) / token_supply;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
function get_D_mem(uint256[N_COINS] memory balances, uint256 amp)
|
|
150
|
-
internal
|
|
151
|
-
pure
|
|
152
|
-
returns (uint256)
|
|
153
|
-
{
|
|
154
|
-
return get_D(_xp_mem(balances), amp);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function _xp_mem(uint256[N_COINS] memory balances)
|
|
158
|
-
internal
|
|
159
|
-
pure
|
|
160
|
-
returns (uint256[N_COINS] memory)
|
|
161
|
-
{
|
|
162
|
-
uint256[N_COINS] memory result;
|
|
163
|
-
result[0] = (RATE_0 * balances[0]) / PRECISION;
|
|
164
|
-
result[1] = (RATE_1 * balances[1]) / PRECISION;
|
|
165
|
-
result[2] = (RATE_2 * balances[2]) / PRECISION;
|
|
166
|
-
|
|
167
|
-
return result;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function get_D(uint256[N_COINS] memory _xp, uint256 _amp) internal pure returns (uint256) {
|
|
171
|
-
uint256 S = 0;
|
|
172
|
-
for (uint256 k = 0; k < N_COINS; ++k) S += _xp[k];
|
|
173
|
-
if (S == 0) return 0;
|
|
174
|
-
|
|
175
|
-
uint256 Dprev = 0;
|
|
176
|
-
uint256 D = S;
|
|
177
|
-
uint256 Ann = _amp * N_COINS;
|
|
178
|
-
|
|
179
|
-
for (uint256 _i = 0; _i < 255; ++_i) {
|
|
180
|
-
uint256 D_P = D;
|
|
181
|
-
for (uint256 k = 0; k < N_COINS; ++k) {
|
|
182
|
-
D_P = (D_P * D) / (_xp[k] * N_COINS);
|
|
183
|
-
}
|
|
184
|
-
Dprev = D;
|
|
185
|
-
D = ((Ann * S + D_P * N_COINS) * D) / (((Ann - 1) * D) + (N_COINS + 1) * D_P);
|
|
186
|
-
|
|
187
|
-
if (D > Dprev) {
|
|
188
|
-
if (D - Dprev <= 1) {
|
|
189
|
-
break;
|
|
190
|
-
}
|
|
191
|
-
} else {
|
|
192
|
-
if (Dprev - D <= 1) {
|
|
193
|
-
break;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
return D;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
function _getBalances() internal view returns (uint256[N_COINS] memory balances) {
|
|
201
|
-
balances[0] = ITriCrvPool(POOL).balances(0);
|
|
202
|
-
balances[1] = ITriCrvPool(POOL).balances(1);
|
|
203
|
-
balances[2] = ITriCrvPool(POOL).balances(2);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
function arrayClone(uint256[N_COINS] memory a)
|
|
207
|
-
internal
|
|
208
|
-
pure
|
|
209
|
-
returns (uint256[N_COINS] memory res)
|
|
210
|
-
{
|
|
211
|
-
for (uint256 i = 0; i < N_COINS; ++i) {
|
|
212
|
-
res[i] = a[i];
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|