@pendle/core-v2 1.0.0-mainnet → 1.0.2-mainnet
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/README.md +28 -0
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol/PendleMsgReceiveEndpointUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol/PendleMsgReceiveEndpointUpg.json +2 -2
- 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 +2 -2
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSenderAppUpg.sol/PendleMsgSenderAppUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/libraries/ExcessivelySafeCall.sol/ExcessivelySafeCall.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/libraries/LayerZeroHelper.sol/LayerZeroHelper.dbg.json +1 -1
- 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 -2
- package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributorFactory.sol/PendleFeeDistributorFactory.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributorFactory.sol/PendleFeeDistributorFactory.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol/PendleGaugeControllerBaseUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.json +2 -2
- 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 +2 -2
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.json +2 -2
- 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/core/BulkSeller/BulkSeller.sol/BulkSeller.dbg.json +1 -1
- package/build/artifacts/contracts/core/BulkSeller/BulkSeller.sol/BulkSeller.json +2 -2
- package/build/artifacts/contracts/core/BulkSeller/BulkSellerFactory.sol/BulkSellerFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/BulkSeller/BulkSellerFactory.sol/BulkSellerFactory.json +2 -2
- package/build/artifacts/contracts/core/BulkSeller/BulkSellerMathCore.sol/BulkSellerMathCore.dbg.json +1 -1
- package/build/artifacts/contracts/core/BulkSeller/BulkSellerMathCore.sol/BulkSellerMathCore.json +2 -2
- 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 +2 -2
- 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/SYBase.sol/SYBase.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/SYBase.sol/SYBase.json +0 -141
- package/build/artifacts/contracts/core/StandardizedYield/SYBaseWithRewards.sol/SYBaseWithRewards.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/SYBaseWithRewards.sol/SYBaseWithRewards.json +0 -141
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Ape/sAPE.sol/sAPE.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Ape/sAPE.sol/sAPE.json +934 -0
- 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 -143
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol/PendleCurveFraxUsdcSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol/PendleCurveFraxUsdcSY.json +2 -143
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol/PendleCurveUsdd3CrvSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol/PendleCurveUsdd3CrvSY.json +2 -143
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/Curve3CrvPoolHelper.sol/Curve3CrvPoolHelper.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/CurveFraxUsdcPoolHelper.sol/CurveFraxUsdcPoolHelper.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/CurveUsdd3CrvPoolHelper.sol/CurveUsdd3CrvPoolHelper.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/PendleConvexLPSY.sol/PendleConvexLPSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/PendleConvexLPSY.sol/PendleConvexLPSY.json +0 -141
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleLooksStakingSY.sol/PendleLooksStakingSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleLooksStakingSY.sol/PendleLooksStakingSY.json +2 -143
- 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 -143
- 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 -2
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.json +2 -2
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.json +2 -2
- package/build/artifacts/contracts/core/erc20/PendleERC20.sol/PendleERC20.dbg.json +1 -1
- package/build/artifacts/contracts/core/erc20/PendleERC20Permit.sol/PendleERC20Permit.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/ArrayLib.sol/ArrayLib.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/BoringOwnableUpgradeable.sol/BoringOwnableUpgradeable.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/BoringOwnableUpgradeable.sol/BoringOwnableUpgradeableData.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/Errors.sol/Errors.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/Errors.sol/Errors.json +13 -2
- package/build/artifacts/contracts/core/libraries/MiniHelpers.sol/MiniHelpers.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/TokenHelper.sol/TokenHelper.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Curve/ICrvPool.sol/ICrvPool.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Curve/ITriCrvPool.sol/ITriCrvPool.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IApeStaking.sol/IApeStaking.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/IApeStaking.sol/IApeStaking.json +149 -0
- package/build/artifacts/contracts/interfaces/IBoringOwnableUpgradeable.sol/IBoringOwnableUpgradeable.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ILayerZeroEndpoint.sol/ILayerZeroEndpoint.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ILayerZeroReceiver.sol/ILayerZeroReceiver.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.dbg.json +1 -1
- 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/IPAllAction.sol/IPAllAction.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPBulkSeller.sol/IPBulkSeller.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPBulkSellerFactory.sol/IPBulkSellerFactory.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMsgReceiverApp.sol/IPMsgReceiverApp.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMsgSendEndpoint.sol/IPMsgSendEndpoint.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPVeToken.sol/IPVeToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPVotingController.sol/IPVotingController.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPVotingEscrowMainchain.sol/IPVotingEscrowMainchain.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IREDACTEDStaking.sol/IREDACTEDStaking.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IStETH.sol/IStETH.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IStargateLPStaking.sol/IStargateLPStaking.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IStargatePool.sol/IStargatePool.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IStargateRouter.sol/IStargateRouter.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IWXBTRFLY.sol/IWXBTRFLY.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/BaseSplitCodeFactoryContract.sol/BaseSplitCodeFactoryContract.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/BulkSellerOffchain.sol/BulkSellerOffchain.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/BulkSellerOffchain.sol/BulkSellerOffchain.json +2 -2
- package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.json +42 -2
- package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.json +171 -98
- package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.json +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.dbg.json +1 -1
- package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.json +2 -2
- package/build/artifacts/contracts/router/base/ActionBaseMintRedeem.sol/ActionBaseMintRedeem.dbg.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/IAggregatorRouterHelper.sol/IAggregationRouterHelper.dbg.json +1 -1
- package/build/artifacts/contracts/router/kyberswap/IMultihopRouter.sol/IMultihopRouter.dbg.json +1 -1
- package/build/artifacts/contracts/router/kyberswap/KyberSwapHelper.sol/KyberSwapHelper.dbg.json +1 -1
- package/contracts/core/StandardizedYield/SYBase.sol +5 -23
- package/contracts/core/StandardizedYield/SYBaseWithRewards.sol +1 -3
- package/contracts/core/StandardizedYield/implementations/Ape/sAPE.sol +197 -0
- package/contracts/core/libraries/Errors.sol +2 -0
- package/contracts/interfaces/IApeStaking.sol +30 -0
- package/contracts/offchain-helpers/MarketMathStatic.sol +181 -88
- package/contracts/offchain-helpers/RouterStatic.sol +72 -72
- package/deployments/1-core.json +1 -1
- package/deployments/1-markets/APE-JUNE-29.json +7 -0
- package/package.json +1 -1
- package/typechain-types/IApeStaking.ts +305 -0
- package/typechain-types/MarketMathStatic.ts +49 -0
- package/typechain-types/PendleApeStakingSY.ts +1135 -0
- package/typechain-types/PendleConvexLPSY.ts +0 -204
- package/typechain-types/PendleCurveFraxUsdcSY.ts +0 -204
- package/typechain-types/PendleCurveUsdd3CrvSY.ts +0 -204
- package/typechain-types/PendleLooksStakingSY.ts +0 -204
- package/typechain-types/PendleQiTokenSY.ts +0 -204
- package/typechain-types/PendleWstEthSY.ts +0 -204
- package/typechain-types/RouterStatic.ts +40 -69
- package/typechain-types/SAPE.ts +1191 -0
- package/typechain-types/SYBase.ts +0 -204
- package/typechain-types/SYBaseAutoCompound.ts +1203 -0
- package/typechain-types/SYBaseWithRewards.ts +0 -204
- package/typechain-types/factories/ActionAddRemoveLiq__factory.ts +1 -1
- package/typechain-types/factories/ActionCallback__factory.ts +1 -1
- package/typechain-types/factories/ActionMintRedeem__factory.ts +1 -1
- 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 +1 -1
- package/typechain-types/factories/ActionSwapYT__factory.ts +1 -1
- package/typechain-types/factories/BulkSellerFactory__factory.ts +1 -1
- package/typechain-types/factories/BulkSellerOffchain__factory.ts +1 -1
- package/typechain-types/factories/BulkSeller__factory.ts +1 -1
- package/typechain-types/factories/Errors__factory.ts +12 -1
- package/typechain-types/factories/IApeStaking__factory.ts +161 -0
- package/typechain-types/factories/MarketMathStatic__factory.ts +41 -1
- package/typechain-types/factories/OracleLib__factory.ts +1 -1
- package/typechain-types/factories/PendleApeStakingSY__factory.ts +981 -0
- package/typechain-types/factories/PendleConvexLPSY__factory.ts +0 -141
- package/typechain-types/factories/PendleCurveFraxUsdcSY__factory.ts +1 -142
- package/typechain-types/factories/PendleCurveUsdd3CrvSY__factory.ts +1 -142
- package/typechain-types/factories/PendleFeeDistributorFactory__factory.ts +1 -1
- package/typechain-types/factories/PendleFeeDistributor__factory.ts +1 -1
- package/typechain-types/factories/PendleGaugeControllerMainchainUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleGaugeControllerSidechainUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleLooksStakingSY__factory.ts +1 -142
- package/typechain-types/factories/PendleMarketFactory__factory.ts +1 -1
- package/typechain-types/factories/PendleMarket__factory.ts +1 -1
- package/typechain-types/factories/PendleMsgReceiveEndpointUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleMsgSendEndpointUpg__factory.ts +1 -1
- package/typechain-types/factories/PendlePrincipalToken__factory.ts +1 -1
- package/typechain-types/factories/PendleQiTokenHelper__factory.ts +1 -1
- package/typechain-types/factories/PendleQiTokenSY__factory.ts +1 -142
- package/typechain-types/factories/PendleRouter__factory.ts +1 -1
- package/typechain-types/factories/PendleVotingControllerUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleWstEthSY__factory.ts +1 -142
- package/typechain-types/factories/PendleYieldContractFactory__factory.ts +1 -1
- package/typechain-types/factories/PendleYieldToken__factory.ts +1 -1
- package/typechain-types/factories/RouterStatic__factory.ts +118 -41
- package/typechain-types/factories/SAPE__factory.ts +1001 -0
- package/typechain-types/factories/SYBaseAutoCompound__factory.ts +942 -0
- package/typechain-types/factories/SYBaseWithRewards__factory.ts +0 -141
- package/typechain-types/factories/SYBase__factory.ts +0 -141
- package/typechain-types/factories/VotingEscrowPendleMainchain__factory.ts +1 -1
- package/typechain-types/factories/VotingEscrowPendleSidechain__factory.ts +1 -1
- package/typechain-types/hardhat.d.ts +18 -0
- package/typechain-types/index.ts +4 -0
|
@@ -14,6 +14,17 @@ library MarketMathStatic {
|
|
|
14
14
|
using PYIndexLib for PYIndex;
|
|
15
15
|
using PYIndexLib for IPYieldToken;
|
|
16
16
|
|
|
17
|
+
function getDefaultApproxParams() public pure returns (ApproxParams memory) {
|
|
18
|
+
return
|
|
19
|
+
ApproxParams({
|
|
20
|
+
guessMin: 0,
|
|
21
|
+
guessMax: type(uint256).max,
|
|
22
|
+
guessOffchain: 0,
|
|
23
|
+
maxIteration: 256,
|
|
24
|
+
eps: 1e14
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
17
28
|
function addLiquidityDualSyAndPtStatic(
|
|
18
29
|
address market,
|
|
19
30
|
uint256 netSyDesired,
|
|
@@ -36,17 +47,14 @@ library MarketMathStatic {
|
|
|
36
47
|
}
|
|
37
48
|
|
|
38
49
|
/// @dev netPtToSwap is the parameter to approx
|
|
39
|
-
function addLiquiditySinglePtStatic(
|
|
40
|
-
address market,
|
|
41
|
-
uint256 netPtIn,
|
|
42
|
-
ApproxParams memory approxParams
|
|
43
|
-
)
|
|
50
|
+
function addLiquiditySinglePtStatic(address market, uint256 netPtIn)
|
|
44
51
|
external
|
|
45
52
|
returns (
|
|
46
53
|
uint256 netLpOut,
|
|
47
54
|
uint256 netPtToSwap,
|
|
48
55
|
uint256 netSyFee,
|
|
49
|
-
uint256 priceImpact
|
|
56
|
+
uint256 priceImpact,
|
|
57
|
+
uint256 exchangeRateAfter
|
|
50
58
|
)
|
|
51
59
|
{
|
|
52
60
|
MarketState memory state = IPMarket(market).readState(address(this));
|
|
@@ -55,7 +63,7 @@ library MarketMathStatic {
|
|
|
55
63
|
pyIndex(market),
|
|
56
64
|
netPtIn,
|
|
57
65
|
block.timestamp,
|
|
58
|
-
|
|
66
|
+
getDefaultApproxParams()
|
|
59
67
|
);
|
|
60
68
|
|
|
61
69
|
state = IPMarket(market).readState(address(this)); // re-read
|
|
@@ -72,21 +80,19 @@ library MarketMathStatic {
|
|
|
72
80
|
block.timestamp
|
|
73
81
|
);
|
|
74
82
|
|
|
75
|
-
priceImpact =
|
|
83
|
+
priceImpact = calcPriceImpactPt(market, netPtToSwap.neg());
|
|
84
|
+
exchangeRateAfter = _getTradeExchangeRateExcludeFee(market, state);
|
|
76
85
|
}
|
|
77
86
|
|
|
78
87
|
/// @dev netPtFromSwap is the parameter to approx
|
|
79
|
-
function addLiquiditySingleSyStatic(
|
|
80
|
-
address market,
|
|
81
|
-
uint256 netSyIn,
|
|
82
|
-
ApproxParams memory approxParams
|
|
83
|
-
)
|
|
88
|
+
function addLiquiditySingleSyStatic(address market, uint256 netSyIn)
|
|
84
89
|
public
|
|
85
90
|
returns (
|
|
86
91
|
uint256 netLpOut,
|
|
87
92
|
uint256 netPtFromSwap,
|
|
88
93
|
uint256 netSyFee,
|
|
89
|
-
uint256 priceImpact
|
|
94
|
+
uint256 priceImpact,
|
|
95
|
+
uint256 exchangeRateAfter
|
|
90
96
|
)
|
|
91
97
|
{
|
|
92
98
|
MarketState memory state = IPMarket(market).readState(address(this));
|
|
@@ -95,7 +101,7 @@ library MarketMathStatic {
|
|
|
95
101
|
pyIndex(market),
|
|
96
102
|
netSyIn,
|
|
97
103
|
block.timestamp,
|
|
98
|
-
|
|
104
|
+
getDefaultApproxParams()
|
|
99
105
|
);
|
|
100
106
|
|
|
101
107
|
state = IPMarket(market).readState(address(this)); // re-read
|
|
@@ -108,7 +114,8 @@ library MarketMathStatic {
|
|
|
108
114
|
);
|
|
109
115
|
(, netLpOut, , ) = state.addLiquidity(netSyIn - netSySwap, netPtFromSwap, block.timestamp);
|
|
110
116
|
|
|
111
|
-
priceImpact =
|
|
117
|
+
priceImpact = calcPriceImpactPt(market, netPtFromSwap.Int());
|
|
118
|
+
exchangeRateAfter = _getTradeExchangeRateExcludeFee(market, state);
|
|
112
119
|
}
|
|
113
120
|
|
|
114
121
|
function removeLiquidityDualSyAndPtStatic(address market, uint256 netLpToRemove)
|
|
@@ -121,17 +128,14 @@ library MarketMathStatic {
|
|
|
121
128
|
}
|
|
122
129
|
|
|
123
130
|
/// @dev netPtFromSwap is the parameter to approx
|
|
124
|
-
function removeLiquiditySinglePtStatic(
|
|
125
|
-
address market,
|
|
126
|
-
uint256 netLpToRemove,
|
|
127
|
-
ApproxParams memory approxParams
|
|
128
|
-
)
|
|
131
|
+
function removeLiquiditySinglePtStatic(address market, uint256 netLpToRemove)
|
|
129
132
|
external
|
|
130
133
|
returns (
|
|
131
134
|
uint256 netPtOut,
|
|
132
135
|
uint256 netPtFromSwap,
|
|
133
136
|
uint256 netSyFee,
|
|
134
|
-
uint256 priceImpact
|
|
137
|
+
uint256 priceImpact,
|
|
138
|
+
uint256 exchangeRateAfter
|
|
135
139
|
)
|
|
136
140
|
{
|
|
137
141
|
MarketState memory state = IPMarket(market).readState(address(this));
|
|
@@ -141,11 +145,15 @@ library MarketMathStatic {
|
|
|
141
145
|
pyIndex(market),
|
|
142
146
|
syFromBurn,
|
|
143
147
|
block.timestamp,
|
|
144
|
-
|
|
148
|
+
getDefaultApproxParams()
|
|
145
149
|
);
|
|
146
150
|
|
|
147
151
|
netPtOut = ptFromBurn + netPtFromSwap;
|
|
148
|
-
priceImpact =
|
|
152
|
+
priceImpact = calcPriceImpactPt(market, netPtFromSwap.Int());
|
|
153
|
+
|
|
154
|
+
// Execute swap to calculate exchangeRateAfter
|
|
155
|
+
state.swapSyForExactPt(pyIndex(market), netPtFromSwap, block.timestamp);
|
|
156
|
+
exchangeRateAfter = _getTradeExchangeRateExcludeFee(market, state);
|
|
149
157
|
}
|
|
150
158
|
|
|
151
159
|
function removeLiquiditySingleSyStatic(address market, uint256 netLpToRemove)
|
|
@@ -153,7 +161,8 @@ library MarketMathStatic {
|
|
|
153
161
|
returns (
|
|
154
162
|
uint256 netSyOut,
|
|
155
163
|
uint256 netSyFee,
|
|
156
|
-
uint256 priceImpact
|
|
164
|
+
uint256 priceImpact,
|
|
165
|
+
uint256 exchangeRateAfter
|
|
157
166
|
)
|
|
158
167
|
{
|
|
159
168
|
MarketState memory state = IPMarket(market).readState(address(this));
|
|
@@ -171,7 +180,8 @@ library MarketMathStatic {
|
|
|
171
180
|
);
|
|
172
181
|
|
|
173
182
|
netSyOut = syFromBurn + syFromSwap;
|
|
174
|
-
priceImpact =
|
|
183
|
+
priceImpact = calcPriceImpactPt(market, ptFromBurn.neg());
|
|
184
|
+
exchangeRateAfter = _getTradeExchangeRateExcludeFee(market, state);
|
|
175
185
|
}
|
|
176
186
|
}
|
|
177
187
|
|
|
@@ -180,7 +190,8 @@ library MarketMathStatic {
|
|
|
180
190
|
returns (
|
|
181
191
|
uint256 netSyOut,
|
|
182
192
|
uint256 netSyFee,
|
|
183
|
-
uint256 priceImpact
|
|
193
|
+
uint256 priceImpact,
|
|
194
|
+
uint256 exchangeRateAfter
|
|
184
195
|
)
|
|
185
196
|
{
|
|
186
197
|
MarketState memory state = IPMarket(market).readState(address(this));
|
|
@@ -189,7 +200,8 @@ library MarketMathStatic {
|
|
|
189
200
|
exactPtIn,
|
|
190
201
|
block.timestamp
|
|
191
202
|
);
|
|
192
|
-
priceImpact =
|
|
203
|
+
priceImpact = calcPriceImpactPt(market, exactPtIn.neg());
|
|
204
|
+
exchangeRateAfter = _getTradeExchangeRateExcludeFee(market, state);
|
|
193
205
|
}
|
|
194
206
|
|
|
195
207
|
function swapSyForExactPtStatic(address market, uint256 exactPtOut)
|
|
@@ -197,7 +209,8 @@ library MarketMathStatic {
|
|
|
197
209
|
returns (
|
|
198
210
|
uint256 netSyIn,
|
|
199
211
|
uint256 netSyFee,
|
|
200
|
-
uint256 priceImpact
|
|
212
|
+
uint256 priceImpact,
|
|
213
|
+
uint256 exchangeRateAfter
|
|
201
214
|
)
|
|
202
215
|
{
|
|
203
216
|
MarketState memory state = IPMarket(market).readState(address(this));
|
|
@@ -206,20 +219,18 @@ library MarketMathStatic {
|
|
|
206
219
|
exactPtOut,
|
|
207
220
|
block.timestamp
|
|
208
221
|
);
|
|
209
|
-
priceImpact =
|
|
222
|
+
priceImpact = calcPriceImpactPt(market, exactPtOut.Int());
|
|
223
|
+
exchangeRateAfter = _getTradeExchangeRateExcludeFee(market, state);
|
|
210
224
|
}
|
|
211
225
|
|
|
212
226
|
/// @dev netPtOut is the parameter to approx
|
|
213
|
-
function swapExactSyForPtStatic(
|
|
214
|
-
address market,
|
|
215
|
-
uint256 exactSyIn,
|
|
216
|
-
ApproxParams memory approxParams
|
|
217
|
-
)
|
|
227
|
+
function swapExactSyForPtStatic(address market, uint256 exactSyIn)
|
|
218
228
|
public
|
|
219
229
|
returns (
|
|
220
230
|
uint256 netPtOut,
|
|
221
231
|
uint256 netSyFee,
|
|
222
|
-
uint256 priceImpact
|
|
232
|
+
uint256 priceImpact,
|
|
233
|
+
uint256 exchangeRateAfter
|
|
223
234
|
)
|
|
224
235
|
{
|
|
225
236
|
MarketState memory state = IPMarket(market).readState(address(this));
|
|
@@ -227,22 +238,23 @@ library MarketMathStatic {
|
|
|
227
238
|
pyIndex(market),
|
|
228
239
|
exactSyIn,
|
|
229
240
|
block.timestamp,
|
|
230
|
-
|
|
241
|
+
getDefaultApproxParams()
|
|
231
242
|
);
|
|
232
|
-
priceImpact =
|
|
243
|
+
priceImpact = calcPriceImpactPt(market, netPtOut.Int());
|
|
244
|
+
|
|
245
|
+
// Execute swap to calculate exchangeRateAfter
|
|
246
|
+
state.swapSyForExactPt(pyIndex(market), netPtOut, block.timestamp);
|
|
247
|
+
exchangeRateAfter = _getTradeExchangeRateExcludeFee(market, state);
|
|
233
248
|
}
|
|
234
249
|
|
|
235
250
|
/// @dev netPtIn is the parameter to approx
|
|
236
|
-
function swapPtForExactSyStatic(
|
|
237
|
-
address market,
|
|
238
|
-
uint256 exactSyOut,
|
|
239
|
-
ApproxParams memory approxParams
|
|
240
|
-
)
|
|
251
|
+
function swapPtForExactSyStatic(address market, uint256 exactSyOut)
|
|
241
252
|
public
|
|
242
253
|
returns (
|
|
243
254
|
uint256 netPtIn,
|
|
244
255
|
uint256 netSyFee,
|
|
245
|
-
uint256 priceImpact
|
|
256
|
+
uint256 priceImpact,
|
|
257
|
+
uint256 exchangeRateAfter
|
|
246
258
|
)
|
|
247
259
|
{
|
|
248
260
|
MarketState memory state = IPMarket(market).readState(address(this));
|
|
@@ -251,9 +263,13 @@ library MarketMathStatic {
|
|
|
251
263
|
pyIndex(market),
|
|
252
264
|
exactSyOut,
|
|
253
265
|
block.timestamp,
|
|
254
|
-
|
|
266
|
+
getDefaultApproxParams()
|
|
255
267
|
);
|
|
256
|
-
priceImpact =
|
|
268
|
+
priceImpact = calcPriceImpactPt(market, netPtIn.neg());
|
|
269
|
+
|
|
270
|
+
// Execute swap to calculate exchangeRateAfter
|
|
271
|
+
state.swapExactPtForSy(pyIndex(market), netPtIn, block.timestamp);
|
|
272
|
+
exchangeRateAfter = _getTradeExchangeRateExcludeFee(market, state);
|
|
257
273
|
}
|
|
258
274
|
|
|
259
275
|
function swapSyForExactYtStatic(address market, uint256 exactYtOut)
|
|
@@ -261,11 +277,13 @@ library MarketMathStatic {
|
|
|
261
277
|
returns (
|
|
262
278
|
uint256 netSyIn,
|
|
263
279
|
uint256 netSyFee,
|
|
264
|
-
uint256 priceImpact
|
|
280
|
+
uint256 priceImpact,
|
|
281
|
+
uint256 exchangeRateAfter
|
|
265
282
|
)
|
|
266
283
|
{
|
|
267
|
-
|
|
284
|
+
priceImpact = calcPriceImpactYt(market, exactYtOut.neg());
|
|
268
285
|
|
|
286
|
+
MarketState memory state = IPMarket(market).readState(address(this));
|
|
269
287
|
PYIndex index = pyIndex(market);
|
|
270
288
|
|
|
271
289
|
uint256 syReceived;
|
|
@@ -278,20 +296,17 @@ library MarketMathStatic {
|
|
|
278
296
|
uint256 totalSyNeed = index.assetToSyUp(exactYtOut);
|
|
279
297
|
netSyIn = totalSyNeed.subMax0(syReceived);
|
|
280
298
|
|
|
281
|
-
|
|
299
|
+
exchangeRateAfter = _getTradeExchangeRateExcludeFee(market, state);
|
|
282
300
|
}
|
|
283
301
|
|
|
284
302
|
/// @dev netYtOut is the parameter to approx
|
|
285
|
-
function swapExactSyForYtStatic(
|
|
286
|
-
address market,
|
|
287
|
-
uint256 exactSyIn,
|
|
288
|
-
ApproxParams memory approxParams
|
|
289
|
-
)
|
|
303
|
+
function swapExactSyForYtStatic(address market, uint256 exactSyIn)
|
|
290
304
|
public
|
|
291
305
|
returns (
|
|
292
306
|
uint256 netYtOut,
|
|
293
307
|
uint256 netSyFee,
|
|
294
|
-
uint256 priceImpact
|
|
308
|
+
uint256 priceImpact,
|
|
309
|
+
uint256 exchangeRateAfter
|
|
295
310
|
)
|
|
296
311
|
{
|
|
297
312
|
MarketState memory state = IPMarket(market).readState(address(this));
|
|
@@ -301,10 +316,14 @@ library MarketMathStatic {
|
|
|
301
316
|
index,
|
|
302
317
|
exactSyIn,
|
|
303
318
|
block.timestamp,
|
|
304
|
-
|
|
319
|
+
getDefaultApproxParams()
|
|
305
320
|
);
|
|
306
321
|
|
|
307
|
-
priceImpact =
|
|
322
|
+
priceImpact = calcPriceImpactYt(market, netYtOut.neg());
|
|
323
|
+
|
|
324
|
+
// Execute swap to calculate exchangeRateAfter
|
|
325
|
+
state.swapSyForExactPt(index, netYtOut, block.timestamp);
|
|
326
|
+
exchangeRateAfter = _getTradeExchangeRateExcludeFee(market, state);
|
|
308
327
|
}
|
|
309
328
|
|
|
310
329
|
function swapExactYtForSyStatic(address market, uint256 exactYtIn)
|
|
@@ -312,9 +331,12 @@ library MarketMathStatic {
|
|
|
312
331
|
returns (
|
|
313
332
|
uint256 netSyOut,
|
|
314
333
|
uint256 netSyFee,
|
|
315
|
-
uint256 priceImpact
|
|
334
|
+
uint256 priceImpact,
|
|
335
|
+
uint256 exchangeRateAfter
|
|
316
336
|
)
|
|
317
337
|
{
|
|
338
|
+
priceImpact = calcPriceImpactYt(market, exactYtIn.Int());
|
|
339
|
+
|
|
318
340
|
MarketState memory state = IPMarket(market).readState(address(this));
|
|
319
341
|
|
|
320
342
|
PYIndex index = pyIndex(market);
|
|
@@ -326,20 +348,17 @@ library MarketMathStatic {
|
|
|
326
348
|
uint256 amountPYToRedeemSyOut = exactYtIn - amountPYToRepaySyOwed;
|
|
327
349
|
|
|
328
350
|
netSyOut = index.assetToSy(amountPYToRedeemSyOut);
|
|
329
|
-
|
|
351
|
+
exchangeRateAfter = _getTradeExchangeRateExcludeFee(market, state);
|
|
330
352
|
}
|
|
331
353
|
|
|
332
354
|
/// @dev netYtIn is the parameter to approx
|
|
333
|
-
function swapYtForExactSyStatic(
|
|
334
|
-
address market,
|
|
335
|
-
uint256 exactSyOut,
|
|
336
|
-
ApproxParams memory approxParams
|
|
337
|
-
)
|
|
355
|
+
function swapYtForExactSyStatic(address market, uint256 exactSyOut)
|
|
338
356
|
external
|
|
339
357
|
returns (
|
|
340
358
|
uint256 netYtIn,
|
|
341
359
|
uint256 netSyFee,
|
|
342
|
-
uint256 priceImpact
|
|
360
|
+
uint256 priceImpact,
|
|
361
|
+
uint256 exchangeRateAfter
|
|
343
362
|
)
|
|
344
363
|
{
|
|
345
364
|
MarketState memory state = IPMarket(market).readState(address(this));
|
|
@@ -350,23 +369,24 @@ library MarketMathStatic {
|
|
|
350
369
|
index,
|
|
351
370
|
exactSyOut,
|
|
352
371
|
block.timestamp,
|
|
353
|
-
|
|
372
|
+
getDefaultApproxParams()
|
|
354
373
|
);
|
|
355
|
-
priceImpact =
|
|
374
|
+
priceImpact = calcPriceImpactYt(market, netYtIn.Int());
|
|
375
|
+
|
|
376
|
+
// Execute swap to calculate exchangeRateAfter
|
|
377
|
+
state.swapSyForExactPt(index, netYtIn, block.timestamp);
|
|
378
|
+
exchangeRateAfter = _getTradeExchangeRateExcludeFee(market, state);
|
|
356
379
|
}
|
|
357
380
|
|
|
358
381
|
// totalPtToSwap is the param to approx
|
|
359
|
-
function swapExactPtForYt(
|
|
360
|
-
address market,
|
|
361
|
-
uint256 exactPtIn,
|
|
362
|
-
ApproxParams memory approxParams
|
|
363
|
-
)
|
|
382
|
+
function swapExactPtForYt(address market, uint256 exactPtIn)
|
|
364
383
|
external
|
|
365
384
|
returns (
|
|
366
385
|
uint256 netYtOut,
|
|
367
386
|
uint256 totalPtToSwap,
|
|
368
387
|
uint256 netSyFee,
|
|
369
|
-
uint256 priceImpact
|
|
388
|
+
uint256 priceImpact,
|
|
389
|
+
uint256 exchangeRateAfter
|
|
370
390
|
)
|
|
371
391
|
{
|
|
372
392
|
MarketState memory state = IPMarket(market).readState(address(this));
|
|
@@ -376,23 +396,24 @@ library MarketMathStatic {
|
|
|
376
396
|
index,
|
|
377
397
|
exactPtIn,
|
|
378
398
|
block.timestamp,
|
|
379
|
-
|
|
399
|
+
getDefaultApproxParams()
|
|
380
400
|
);
|
|
381
|
-
priceImpact =
|
|
401
|
+
priceImpact = calcPriceImpactPY(market, totalPtToSwap.neg());
|
|
402
|
+
|
|
403
|
+
// Execute swap to calculate exchangeRateAfter
|
|
404
|
+
state.swapExactPtForSy(index, totalPtToSwap, block.timestamp);
|
|
405
|
+
exchangeRateAfter = _getTradeExchangeRateExcludeFee(market, state);
|
|
382
406
|
}
|
|
383
407
|
|
|
384
408
|
// totalPtSwapped is the param to approx
|
|
385
|
-
function swapExactYtForPt(
|
|
386
|
-
address market,
|
|
387
|
-
uint256 exactYtIn,
|
|
388
|
-
ApproxParams memory approxParams
|
|
389
|
-
)
|
|
409
|
+
function swapExactYtForPt(address market, uint256 exactYtIn)
|
|
390
410
|
external
|
|
391
411
|
returns (
|
|
392
412
|
uint256 netPtOut,
|
|
393
413
|
uint256 totalPtSwapped,
|
|
394
414
|
uint256 netSyFee,
|
|
395
|
-
uint256 priceImpact
|
|
415
|
+
uint256 priceImpact,
|
|
416
|
+
uint256 exchangeRateAfter
|
|
396
417
|
)
|
|
397
418
|
{
|
|
398
419
|
MarketState memory state = IPMarket(market).readState(address(this));
|
|
@@ -402,10 +423,14 @@ library MarketMathStatic {
|
|
|
402
423
|
index,
|
|
403
424
|
exactYtIn,
|
|
404
425
|
block.timestamp,
|
|
405
|
-
|
|
426
|
+
getDefaultApproxParams()
|
|
406
427
|
);
|
|
407
428
|
|
|
408
|
-
priceImpact =
|
|
429
|
+
priceImpact = calcPriceImpactPY(market, totalPtSwapped.Int());
|
|
430
|
+
|
|
431
|
+
// Execute swap to calculate exchangeRateAfter
|
|
432
|
+
state.swapSyForExactPt(index, totalPtSwapped, block.timestamp);
|
|
433
|
+
exchangeRateAfter = _getTradeExchangeRateExcludeFee(market, state);
|
|
409
434
|
}
|
|
410
435
|
|
|
411
436
|
function pyIndex(address market) public returns (PYIndex index) {
|
|
@@ -414,8 +439,25 @@ library MarketMathStatic {
|
|
|
414
439
|
return YT.newIndex();
|
|
415
440
|
}
|
|
416
441
|
|
|
417
|
-
function
|
|
418
|
-
|
|
442
|
+
function getTradeExchangeRateExcludeFee(address market) public returns (uint256) {
|
|
443
|
+
if (IPMarket(market).isExpired()) return Math.ONE;
|
|
444
|
+
MarketState memory state = IPMarket(market).readState(address(this));
|
|
445
|
+
return _getTradeExchangeRateExcludeFee(market, state);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
function _getTradeExchangeRateExcludeFee(address market, MarketState memory state)
|
|
449
|
+
public
|
|
450
|
+
returns (uint256)
|
|
451
|
+
{
|
|
452
|
+
MarketPreCompute memory comp = state.getMarketPreCompute(pyIndex(market), block.timestamp);
|
|
453
|
+
int256 preFeeExchangeRate = MarketMathCore._getExchangeRate(
|
|
454
|
+
state.totalPt,
|
|
455
|
+
comp.totalAsset,
|
|
456
|
+
comp.rateScalar,
|
|
457
|
+
comp.rateAnchor,
|
|
458
|
+
0
|
|
459
|
+
);
|
|
460
|
+
return preFeeExchangeRate.Uint();
|
|
419
461
|
}
|
|
420
462
|
|
|
421
463
|
function getTradeExchangeRateIncludeFee(address market, int256 netPtOut)
|
|
@@ -445,14 +487,40 @@ library MarketMathStatic {
|
|
|
445
487
|
}
|
|
446
488
|
}
|
|
447
489
|
|
|
448
|
-
function
|
|
490
|
+
function calcPriceImpactPt(address market, int256 netPtOut)
|
|
449
491
|
public
|
|
450
492
|
returns (uint256 priceImpact)
|
|
451
493
|
{
|
|
452
|
-
uint256 preTradeRate =
|
|
494
|
+
uint256 preTradeRate = getTradeExchangeRateIncludeFee(market, _getSign(netPtOut));
|
|
453
495
|
uint256 tradedRate = getTradeExchangeRateIncludeFee(market, netPtOut);
|
|
496
|
+
priceImpact = _calculateImpact(preTradeRate, tradedRate);
|
|
497
|
+
}
|
|
454
498
|
|
|
455
|
-
|
|
499
|
+
function calcPriceImpactYt(address market, int256 netPtOut)
|
|
500
|
+
public
|
|
501
|
+
returns (uint256 priceImpact)
|
|
502
|
+
{
|
|
503
|
+
uint256 ytPreTradeRate = _calcVirtualYTPrice(
|
|
504
|
+
getTradeExchangeRateIncludeFee(market, _getSign(netPtOut))
|
|
505
|
+
);
|
|
506
|
+
uint256 ytTradedRate = _calcVirtualYTPrice(
|
|
507
|
+
getTradeExchangeRateIncludeFee(market, netPtOut)
|
|
508
|
+
);
|
|
509
|
+
priceImpact = _calculateImpact(ytPreTradeRate, ytTradedRate);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
function calcPriceImpactPY(address market, int256 netPtOut)
|
|
513
|
+
public
|
|
514
|
+
returns (uint256 priceImpact)
|
|
515
|
+
{
|
|
516
|
+
uint256 ptPreTradeRate = getTradeExchangeRateIncludeFee(market, _getSign(netPtOut));
|
|
517
|
+
uint256 ytPreTradeRate = _calcVirtualYTPrice(ptPreTradeRate);
|
|
518
|
+
uint256 ptTradeRate = getTradeExchangeRateIncludeFee(market, netPtOut);
|
|
519
|
+
uint256 ytTradeRate = _calcVirtualYTPrice(ptTradeRate);
|
|
520
|
+
|
|
521
|
+
uint256 pyPreTradeRate = ytPreTradeRate.divDown(ptPreTradeRate);
|
|
522
|
+
uint256 pyTradeRate = ytTradeRate.divDown(ptTradeRate);
|
|
523
|
+
priceImpact = _calculateImpact(pyPreTradeRate, pyTradeRate);
|
|
456
524
|
}
|
|
457
525
|
|
|
458
526
|
function getPtImpliedYield(address market) public view returns (int256) {
|
|
@@ -461,4 +529,29 @@ library MarketMathStatic {
|
|
|
461
529
|
int256 lnImpliedRate = (state.lastLnImpliedRate).Int();
|
|
462
530
|
return lnImpliedRate.exp();
|
|
463
531
|
}
|
|
532
|
+
|
|
533
|
+
function _calcVirtualYTPrice(uint256 ptAssetExchangeRate)
|
|
534
|
+
private
|
|
535
|
+
pure
|
|
536
|
+
returns (uint256 ytAssetExchangeRate)
|
|
537
|
+
{
|
|
538
|
+
// 1 asset = EX pt
|
|
539
|
+
// 1 pt = 1/EX Asset
|
|
540
|
+
// 1 yt + 1/EX Asset = 1 Asset
|
|
541
|
+
// 1 yt = 1 Asset - 1/EX Asset
|
|
542
|
+
// 1 yt = (EX - 1) / EX Asset
|
|
543
|
+
return (ptAssetExchangeRate - Math.ONE).divDown(ptAssetExchangeRate);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
function _getSign(int256 netPtOut) private pure returns (int256) {
|
|
547
|
+
return netPtOut > 0 ? int256(1) : int256(-1);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
function _calculateImpact(uint256 rateBefore, uint256 rateTraded)
|
|
551
|
+
private
|
|
552
|
+
pure
|
|
553
|
+
returns (uint256 impact)
|
|
554
|
+
{
|
|
555
|
+
impact = (rateBefore.Int() - rateTraded.Int()).abs().divDown(rateBefore);
|
|
556
|
+
}
|
|
464
557
|
}
|