@pendle/core-v2 1.2.0-mainnet → 1.2.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 +2 -2
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiverAppUpg.sol/PendleMsgReceiverAppUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiverAppUpg.sol/PendleMsgReceiverAppUpg.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/CrossChainMsg/libraries/LayerZeroHelper.sol/LayerZeroHelper.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 +3 -3
- package/build/artifacts/contracts/LiquidityMining/VeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.json +34 -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 +3 -3
- 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/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/PYIndex.sol/PYIndexLib.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 +141 -0
- package/build/artifacts/contracts/core/StandardizedYield/SYBaseWithRewards.sol/SYBaseWithRewards.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/SYBaseWithRewards.sol/SYBaseWithRewards.json +141 -0
- package/build/artifacts/contracts/core/StandardizedYield/SYUtils.sol/SYUtils.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/StEthHelper.sol/StEthHelper.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/StEthHelper.sol/StEthHelper.json +10 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Ape/sAPE.sol/sAPE.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Ape/sAPE.sol/sAPE.json +143 -2
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethRethSY.sol/PendleAuraWethRethSY.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethRethSY.sol/PendleAuraWethRethSY.json +1218 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethWstethSY.sol/PendleAuraWethWstethSY.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethWstethSY.sol/PendleAuraWethWstethSY.json +1192 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/FixedPoint.sol/FixedPoint.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/FixedPoint.sol/FixedPoint.json +10 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/MetaStable/MetaStableMath.sol/MetaStableMath.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/MetaStable/MetaStableMath.sol/MetaStableMath.json +40 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/MetaStable/MetaStablePreview.sol/MetaStablePreview.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/MetaStable/MetaStablePreview.sol/MetaStablePreview.json +322 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/PendleAuraBalancerStableLPSY.sol/PendleAuraBalancerStableLPSY.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/PendleAuraBalancerStableLPSY.sol/PendleAuraBalancerStableLPSY.json +1171 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/StablePoolUserData.sol/StablePoolUserData.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/StablePoolUserData.sol/StablePoolUserData.json +10 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/StablePreviewBase.sol/StablePreviewBase.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/StablePreviewBase.sol/StablePreviewBase.json +133 -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 +143 -2
- 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 +143 -2
- 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 +143 -2
- 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 +141 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/GLP/GLPPreviewHelper.sol/GLPPreviewHelper.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/GLP/GLPPreviewHelper.sol/GLPPreviewHelper.json +50 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/GLP/PendleGlpSY.sol/PendleGlpSY.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/GLP/PendleGlpSY.sol/PendleGlpSY.json +1163 -0
- 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 +143 -2
- 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 +143 -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 -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/YieldContractsV2/InterestManagerYTV2.sol/InterestManagerYTV2.dbg.json +4 -0
- package/build/artifacts/contracts/core/YieldContractsV2/InterestManagerYTV2.sol/InterestManagerYTV2.json +66 -0
- package/build/artifacts/contracts/core/YieldContractsV2/PendlePrincipalTokenV2.sol/PendlePrincipalTokenV2.dbg.json +4 -0
- package/build/artifacts/contracts/core/YieldContractsV2/PendlePrincipalTokenV2.sol/PendlePrincipalTokenV2.json +476 -0
- package/build/artifacts/contracts/core/YieldContractsV2/PendleYieldContractFactoryV2.sol/PendleYieldContractFactoryV2.dbg.json +4 -0
- package/build/artifacts/contracts/core/YieldContractsV2/PendleYieldContractFactoryV2.sol/PendleYieldContractFactoryV2.json +590 -0
- package/build/artifacts/contracts/core/YieldContractsV2/PendleYieldTokenV2.sol/PendleYieldTokenV2.dbg.json +4 -0
- package/build/artifacts/contracts/core/YieldContractsV2/PendleYieldTokenV2.sol/PendleYieldTokenV2.json +1017 -0
- 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/ArrayLib.sol/ArrayLib.json +2 -2
- package/build/artifacts/contracts/core/libraries/BaseSplitCodeFactory.sol/BaseSplitCodeFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/BaseSplitCodeFactory.sol/CodeDeployer.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 +87 -2
- package/build/artifacts/contracts/core/libraries/ExpiryUtilsLib.sol/ExpiryUtils.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/MiniHelpers.sol/MiniHelpers.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/StringLib.sol/StringLib.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/TokenHelper.sol/TokenHelper.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/math/LogExpMath.sol/LogExpMath.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/math/Math.sol/Math.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Balancer/IAsset.sol/IAsset.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/Balancer/IAsset.sol/IAsset.json +10 -0
- package/build/artifacts/contracts/interfaces/Balancer/IBalancerFees.sol/IBalancerFees.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/Balancer/IBalancerFees.sol/IBalancerFees.json +24 -0
- package/build/artifacts/contracts/interfaces/Balancer/IBalancerStablePreview.sol/IBalancerStablePreview.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/Balancer/IBalancerStablePreview.sol/IBalancerStablePreview.json +133 -0
- package/build/artifacts/contracts/interfaces/Balancer/IBasePool.sol/IBasePool.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/Balancer/IBasePool.sol/IBasePool.json +328 -0
- package/build/artifacts/contracts/interfaces/Balancer/IComposableStable.sol/IComposableStable.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/Balancer/IComposableStable.sol/IComposableStable.json +467 -0
- package/build/artifacts/contracts/interfaces/Balancer/IGauge.sol/IGauge.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/Balancer/IGauge.sol/IGauge.json +61 -0
- package/build/artifacts/contracts/interfaces/Balancer/ILiquidityGaugeFactory.sol/ILiquidityGaugeFactory.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/Balancer/ILiquidityGaugeFactory.sol/ILiquidityGaugeFactory.json +30 -0
- package/build/artifacts/contracts/interfaces/Balancer/IMetaStablePool.sol/IMetaStablePool.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/Balancer/IMetaStablePool.sol/IMetaStablePool.json +398 -0
- package/build/artifacts/contracts/interfaces/Balancer/IRateProvider.sol/IRateProvider.dbg.json +4 -0
- package/build/artifacts/contracts/{router/kyberswap/KyberSwapHelper.sol/KyberSwapHelper.json → interfaces/Balancer/IRateProvider.sol/IRateProvider.json} +5 -5
- package/build/artifacts/contracts/interfaces/Balancer/IVault.sol/IVault.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/Balancer/IVault.sol/IVault.json +278 -0
- package/build/artifacts/contracts/interfaces/ConvexCurve/IBooster.sol/IBooster.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ConvexCurve/ICrvDepositor.sol/ICrvDepositor.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ConvexCurve/ICvxCrv.sol/ICvxCrv.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ConvexCurve/IRewards.sol/IRewards.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ConvexCurve/IRewards.sol/IRewards.json +18 -0
- 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/GMX/IGMXVault.sol/IGMXVault.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/GMX/IGMXVault.sol/IGMXVault.json +308 -0
- package/build/artifacts/contracts/interfaces/GMX/IGlpManager.sol/IGlpManager.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/GMX/IGlpManager.sol/IGlpManager.json +43 -0
- package/build/artifacts/contracts/interfaces/GMX/IRewardRouterV2.sol/IRewardRouterV2.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/GMX/IRewardRouterV2.sol/IRewardRouterV2.json +201 -0
- package/build/artifacts/contracts/interfaces/GMX/IVaultPriceFeed.sol/IVaultPriceFeed.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/GMX/IVaultPriceFeed.sol/IVaultPriceFeed.json +45 -0
- package/build/artifacts/contracts/interfaces/IAToken.sol/IAToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IAavePool.sol/IAavePool.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IAaveRewardsController.sol/IAaveRewardsController.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IAddressProvider.sol/IAddressProvider.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/IAddressProvider.sol/IAddressProvider.json +48 -0
- package/build/artifacts/contracts/interfaces/IApeStaking.sol/IApeStaking.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IBenQiComptroller.sol/IBenQiComptroller.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IBenQiInterestRateModel.sol/IBenQiInterestRateModel.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IBoringOwnableUpgradeable.sol/IBoringOwnableUpgradeable.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IDiamondCut.sol/IDiamondCut.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/IDiamondCut.sol/IDiamondCut.json +93 -0
- package/build/artifacts/contracts/interfaces/IDiamondLoupe.sol/IDiamondLoupe.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/IDiamondLoupe.sol/IDiamondLoupe.json +87 -0
- package/build/artifacts/contracts/interfaces/IERC4626.sol/IERC4626.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IEulerEToken.sol/IEulerEToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IEulerMarkets.sol/IEulerMarkets.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ILayerZeroEndpoint.sol/ILayerZeroEndpoint.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ILayerZeroReceiver.sol/ILayerZeroReceiver.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/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.json +338 -16
- package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.json +105 -224
- package/build/artifacts/contracts/interfaces/IPActionMisc.sol/IPActionMisc.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionMisc.sol/IPActionMisc.json +56 -12
- package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.json +52 -8
- package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.json +231 -8
- package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.json +675 -241
- 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/IPBulkSellerSYCallback.sol/IPBulkSellerCallback.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPFeeDistributor.sol/IPFeeDistributor.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPFeeDistributor.sol/IPFeeDistributor.json +19 -0
- package/build/artifacts/contracts/interfaces/IPGauge.sol/IPGauge.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPGaugeController.sol/IPGaugeController.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPGaugeControllerMainchain.sol/IPGaugeControllerMainchain.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPGovernanceManager.sol/IPGovernanceManager.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPInterestManagerYT.sol/IPInterestManagerYT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPInterestManagerYTV2.sol/IPInterestManagerYTV2.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/IPInterestManagerYTV2.sol/IPInterestManagerYTV2.json +40 -0
- 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/IPMarketSwapCallback.sol/IPMarketSwapCallback.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMsgReceiverApp.sol/IPMsgReceiverApp.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMsgReceiverApp.sol/IPMsgReceiverApp.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMsgSendEndpoint.sol/IPMsgSendEndpoint.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPPermissionsV2Upg.sol/IPermissionsV2Upg.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPPrincipalToken.sol/IPPrincipalToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/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/IPYieldContractFactory.sol/IPYieldContractFactory.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPYieldToken.sol/IPYieldToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPYieldTokenV2.sol/IPYieldTokenV2.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/IPYieldTokenV2.sol/IPYieldTokenV2.json +679 -0
- package/build/artifacts/contracts/interfaces/IQiAvax.sol/IQiAvax.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IQiErc20.sol/IQiErc20.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IQiToken.sol/IQiToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IREDACTEDStaking.sol/IREDACTEDStaking.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IRewardManager.sol/IRewardManager.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ISAvax.sol/ISAvax.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ISJoe.sol/ISJoe.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IStETH.sol/IStETH.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IStandardizedYield.sol/IStandardizedYield.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/IWAvax.sol/IWAvax.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IWETH.sol/IWETH.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IWXBTRFLY.sol/IWXBTRFLY.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IWstETH.sol/IWstETH.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IYearnVault.sol/IYearnVault.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/AddressProvider.sol/AddressProvider.dbg.json +4 -0
- package/build/artifacts/contracts/offchain-helpers/AddressProvider.sol/AddressProvider.json +143 -0
- 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 +2 -28
- package/build/artifacts/contracts/offchain-helpers/Multicall2.sol/Multicall2.dbg.json +4 -0
- package/build/artifacts/contracts/offchain-helpers/Multicall2.sol/Multicall2.json +322 -0
- package/build/artifacts/contracts/offchain-helpers/PendleMulticall.sol/PendleMulticall.dbg.json +4 -0
- package/build/artifacts/contracts/offchain-helpers/PendleMulticall.sol/PendleMulticall.json +47 -0
- package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.json +144 -60
- package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.json +345 -62
- package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.json +107 -260
- package/build/artifacts/contracts/router/ActionMisc.sol/ActionMisc.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionMisc.sol/ActionMisc.json +57 -18
- package/build/artifacts/contracts/router/ActionSwapPT.sol/ActionSwapPT.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionSwapPT.sol/ActionSwapPT.json +54 -65
- package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.json +342 -44
- package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.dbg.json +1 -1
- package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.json +76 -67
- package/build/artifacts/contracts/router/base/ActionBaseCallback.sol/ActionBaseCallback.dbg.json +4 -0
- package/build/artifacts/contracts/router/base/ActionBaseCallback.sol/ActionBaseCallback.json +141 -0
- package/build/artifacts/contracts/router/base/ActionBaseMintRedeem.sol/ActionBaseMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/router/base/ActionBaseMintRedeem.sol/ActionBaseMintRedeem.json +1 -15
- package/build/artifacts/contracts/router/base/CallbackHelper.sol/CallbackHelper.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/swap-aggregator/1inch/I1inchAggregationRouterV5.sol/I1inchAggregationRouterV5.dbg.json +4 -0
- package/build/artifacts/contracts/router/swap-aggregator/1inch/I1inchAggregationRouterV5.sol/I1inchAggregationRouterV5.json +160 -0
- package/build/artifacts/contracts/router/swap-aggregator/1inch/OneInchAggregationRouterHelper.sol/OneInchAggregationRouterHelper.dbg.json +4 -0
- package/build/artifacts/contracts/router/swap-aggregator/1inch/OneInchAggregationRouterHelper.sol/OneInchAggregationRouterHelper.json +10 -0
- package/build/artifacts/contracts/router/swap-aggregator/IPSwapAggregator.sol/IPSwapAggregator.dbg.json +4 -0
- package/build/artifacts/contracts/router/swap-aggregator/IPSwapAggregator.sol/IPSwapAggregator.json +56 -0
- package/build/artifacts/contracts/router/swap-aggregator/PendleSwapAggregator.sol/PendleSwapAggregator.dbg.json +4 -0
- package/build/artifacts/contracts/router/swap-aggregator/PendleSwapAggregator.sol/PendleSwapAggregator.json +72 -0
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/KyberAggregationRouterHelper.sol/KyberAggregationRouterHelper.dbg.json +4 -0
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/KyberAggregationRouterHelper.sol/KyberAggregationRouterHelper.json +10 -0
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/ScaleDataHelperEthereum1.sol/ScaleDataHelperEthereum1.dbg.json +4 -0
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/ScaleDataHelperEthereum1.sol/ScaleDataHelperEthereum1.json +10 -0
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/interfaces/IAggregationExecutor.sol/IAggregationExecutor.dbg.json +4 -0
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/interfaces/IAggregationExecutor.sol/IAggregationExecutor.json +65 -0
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/interfaces/IExecutorHelperEthereum1.sol/IExecutorHelperEthereum1.dbg.json +4 -0
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/interfaces/IExecutorHelperEthereum1.sol/IExecutorHelperEthereum1.json +388 -0
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/interfaces/IHashflow.sol/IHashflow.dbg.json +4 -0
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/interfaces/IHashflow.sol/IHashflow.json +101 -0
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/interfaces/IMetaAggregationRouterV2.sol/IMetaAggregationRouterV2.dbg.json +4 -0
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/interfaces/IMetaAggregationRouterV2.sol/IMetaAggregationRouterV2.json +215 -0
- package/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiverAppUpg.sol +0 -1
- package/contracts/LiquidityMining/CrossChainMsg/libraries/LayerZeroHelper.sol +9 -9
- package/contracts/core/RewardManager/RewardManager.sol +1 -1
- package/contracts/core/StandardizedYield/SYBase.sol +23 -5
- package/contracts/core/StandardizedYield/StEthHelper.sol +71 -0
- package/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethRethSY.sol +134 -0
- package/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethWstethSY.sol +154 -0
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/FixedPoint.sol +68 -0
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/MetaStable/MetaStableMath.sol +322 -0
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/MetaStable/MetaStablePreview.sol +390 -0
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/PendleAuraBalancerStableLPSY.sol +329 -0
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/StablePoolUserData.sol +30 -0
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/StablePreviewBase.sol +189 -0
- package/contracts/core/StandardizedYield/implementations/GLP/GLPPreviewHelper.sol +142 -0
- package/contracts/core/StandardizedYield/implementations/GLP/PendleGlpSY.sol +224 -0
- package/contracts/core/StandardizedYield/implementations/GLP/README.md +61 -0
- package/contracts/core/StandardizedYield/implementations/PendleGdaiSY.sol +138 -0
- package/contracts/core/YieldContracts/PendleYieldContractFactory.sol +10 -0
- package/contracts/core/YieldContractsV2/InterestManagerYTV2.sol +114 -0
- package/contracts/core/YieldContractsV2/PendlePrincipalTokenV2.sol +63 -0
- package/contracts/core/YieldContractsV2/PendleYieldContractFactoryV2.sol +200 -0
- package/contracts/core/YieldContractsV2/PendleYieldTokenV2.sol +485 -0
- package/contracts/core/libraries/ArrayLib.sol +27 -12
- package/contracts/core/libraries/Errors.sol +8 -2
- package/contracts/core/libraries/TokenHelper.sol +10 -0
- package/contracts/interfaces/Balancer/IAsset.sol +4 -0
- package/contracts/interfaces/Balancer/IBalancerFees.sol +6 -0
- package/contracts/interfaces/Balancer/IBalancerStablePreview.sol +22 -0
- package/contracts/interfaces/Balancer/IBasePool.sol +30 -0
- package/contracts/interfaces/Balancer/IComposableStable.sol +39 -0
- package/contracts/interfaces/Balancer/IGauge.sol +10 -0
- package/contracts/interfaces/Balancer/ILiquidityGaugeFactory.sol +6 -0
- package/contracts/interfaces/Balancer/IMetaStablePool.sol +31 -0
- package/contracts/interfaces/Balancer/IRateProvider.sol +6 -0
- package/contracts/interfaces/Balancer/IVault.sol +78 -0
- package/contracts/interfaces/ConvexCurve/IRewards.sol +5 -0
- package/contracts/interfaces/GMX/IGMXVault.sol +47 -0
- package/contracts/interfaces/GMX/IGlpManager.sol +12 -0
- package/contracts/interfaces/GMX/IRewardRouterV2.sol +43 -0
- package/contracts/interfaces/GMX/IVaultPriceFeed.sol +11 -0
- package/contracts/interfaces/IAddressProvider.sol +7 -0
- package/contracts/interfaces/IDiamondCut.sol +36 -0
- package/contracts/interfaces/IDiamondLoupe.sol +38 -0
- package/contracts/interfaces/IERC4626.sol +2 -0
- package/contracts/interfaces/IPActionAddRemoveLiq.sol +36 -1
- package/contracts/interfaces/IPActionInfoStatic.sol +43 -0
- package/contracts/interfaces/IPActionMarketAuxStatic.sol +30 -0
- package/contracts/interfaces/IPActionMarketCoreStatic.sol +317 -0
- package/contracts/interfaces/IPActionMintRedeem.sol +2 -55
- package/contracts/interfaces/IPActionMintRedeemStatic.sol +60 -0
- package/contracts/interfaces/IPActionMisc.sol +18 -4
- package/contracts/interfaces/IPActionStorageStatic.sol +25 -0
- package/contracts/interfaces/IPActionSwapPT.sol +1 -1
- package/contracts/interfaces/IPActionSwapYT.sol +28 -4
- package/contracts/interfaces/IPActionVePendleStatic.sol +9 -0
- package/contracts/interfaces/IPAllAction.sol +5 -3
- package/contracts/interfaces/IPInterestManagerYTV2.sol +13 -0
- package/contracts/interfaces/IPMiniDiamond.sol +12 -0
- package/contracts/interfaces/IPMsgReceiverApp.sol +1 -1
- package/contracts/interfaces/IPRouterStatic.sol +19 -0
- package/contracts/interfaces/IPVotingController.sol +6 -0
- package/contracts/interfaces/IPYieldTokenV2.sol +66 -0
- package/contracts/interfaces/IStandardizedYield.sol +1 -1
- package/contracts/offchain-helpers/AddressProvider.sol +16 -0
- package/contracts/offchain-helpers/Broadcaster.sol +48 -0
- package/contracts/offchain-helpers/PendleMulticall.sol +26 -0
- package/contracts/offchain-helpers/{MarketMathStatic.sol → legacy/MarketMathStatic.sol} +2 -2
- package/contracts/offchain-helpers/{RouterStatic.sol → legacy/RouterStatic.sol} +7 -7
- package/contracts/offchain-helpers/router-static/PendleRouterStatic.sol +19 -0
- package/contracts/offchain-helpers/router-static/StorageLayout.sol +21 -0
- package/contracts/offchain-helpers/router-static/base/ActionInfoStatic.sol +125 -0
- package/contracts/offchain-helpers/router-static/base/ActionMarketAuxStatic.sol +166 -0
- package/contracts/offchain-helpers/router-static/base/ActionMarketCoreStatic.sol +769 -0
- package/contracts/offchain-helpers/router-static/base/ActionMintRedeemStatic.sol +166 -0
- package/contracts/offchain-helpers/router-static/base/ActionStorageStatic.sol +75 -0
- package/contracts/offchain-helpers/router-static/base/ActionVePendleStatic.sol +55 -0
- package/contracts/router/ActionAddRemoveLiq.sol +116 -6
- package/contracts/router/ActionMintRedeem.sol +12 -202
- package/contracts/router/ActionMisc.sol +45 -19
- package/contracts/router/ActionSwapPT.sol +0 -5
- package/contracts/router/ActionSwapYT.sol +103 -13
- package/contracts/router/PendleRouter.sol +211 -72
- package/contracts/router/{ActionCallback.sol → base/ActionBaseCallback.sol} +47 -47
- package/contracts/router/base/ActionBaseMintRedeem.sol +105 -60
- package/contracts/router/base/CallbackHelper.sol +137 -44
- package/contracts/router/base/MarketApproxLib.sol +227 -350
- package/contracts/router/swap-aggregator/1inch/I1inchAggregationRouterV5.sol +45 -0
- package/contracts/router/swap-aggregator/1inch/OneInchAggregationRouterHelper.sol +69 -0
- package/contracts/router/swap-aggregator/IPSwapAggregator.sol +25 -0
- package/contracts/router/swap-aggregator/PendleSwapAggregator.sol +46 -0
- package/contracts/router/swap-aggregator/kyberswap/KyberAggregationRouterHelper.sol +214 -0
- package/contracts/router/swap-aggregator/kyberswap/ScaleDataHelperEthereum1.sol +147 -0
- package/contracts/router/swap-aggregator/kyberswap/interfaces/IAggregationExecutor.sol +17 -0
- package/contracts/router/swap-aggregator/kyberswap/interfaces/IExecutorHelperEthereum1.sol +191 -0
- package/contracts/router/swap-aggregator/kyberswap/interfaces/IHashflow.sol +30 -0
- package/contracts/router/swap-aggregator/kyberswap/interfaces/IMetaAggregationRouterV2.sol +42 -0
- package/deployments/43113-core.json +30 -0
- package/deployments/43113-markets/APE-30-MARCH.json +10 -0
- package/deployments/43113-markets/USDC-FEB-2ND-2024.json +10 -0
- package/deployments/43113-markets/USDC-FEB-2ND.json +10 -0
- package/deployments/43113-markets/USDC-FEB-4TH.json +10 -0
- package/deployments/43113-markets/WETH-FEB-2ND.json +11 -0
- package/deployments/43113-markets/WETH-FEB-4TH.json +11 -0
- package/deployments/43113-offchain-helper.json +4 -0
- package/deployments/43113-testenv.json +22 -0
- package/deployments/80001-core.json +29 -0
- package/deployments/80001-markets/GLP-DEC-8TH.json +10 -0
- package/deployments/80001-markets/USDC-DEC-8TH.json +10 -0
- package/deployments/80001-markets/USDC-FEB-4TH.json +10 -0
- package/deployments/80001-markets/WETH-FEB-4TH.json +11 -0
- package/deployments/80001-offchain-helper.json +4 -0
- package/deployments/80001-testenv.json +22 -0
- package/package.json +9 -10
- package/typechain-types/ActionAddRemoveLiq.ts +203 -23
- package/typechain-types/ActionBaseCallback.ts +115 -0
- package/typechain-types/ActionMintRedeem.ts +29 -230
- package/typechain-types/ActionMisc.ts +77 -27
- package/typechain-types/ActionSwapPT.ts +26 -31
- package/typechain-types/ActionSwapYT.ts +202 -21
- package/typechain-types/AddressProvider.ts +280 -0
- package/typechain-types/ComposableStablePreview.ts +217 -0
- package/typechain-types/GLPPreviewHelper.ts +121 -0
- package/typechain-types/GMXPreviewHelper.ts +121 -0
- package/typechain-types/I1inchAggregationRouterV5.ts +257 -0
- package/typechain-types/IAddressProvider.ts +123 -0
- package/typechain-types/IAggregationExecutor.ts +182 -0
- package/typechain-types/IBalancerFees.ts +89 -0
- package/typechain-types/IBalancerStablePreview.ts +217 -0
- package/typechain-types/IBasePool.ts +482 -0
- package/typechain-types/IComposableStable.ts +730 -0
- package/typechain-types/IDiamondCut.ts +152 -0
- package/typechain-types/IDiamondLoupe.ts +190 -0
- package/typechain-types/IExecutorHelperEthereum1.ts +643 -0
- package/typechain-types/IGMXVault.ts +494 -0
- package/typechain-types/IGauge.ts +160 -0
- package/typechain-types/IGlpManager.ts +115 -0
- package/typechain-types/IHashflow.ts +159 -0
- package/typechain-types/IKyberSwapAggregationRouterHelper.ts +109 -0
- package/typechain-types/ILiquidityGaugeFactory.ts +99 -0
- package/typechain-types/IMetaAggregationRouter.ts +213 -0
- package/typechain-types/IMetaAggregationRouterV2.ts +221 -0
- package/typechain-types/IMetaStablePool.ts +619 -0
- package/typechain-types/IPActionAddRemoveLiq.ts +213 -14
- package/typechain-types/IPActionMintRedeem.ts +29 -211
- package/typechain-types/IPActionMisc.ts +77 -27
- package/typechain-types/IPActionSwapPT.ts +26 -12
- package/typechain-types/IPActionSwapYT.ts +168 -12
- package/typechain-types/IPAllAction.ts +445 -227
- package/typechain-types/IPFeeDistributor.ts +18 -0
- package/typechain-types/IPInterestManagerYTV2.ts +117 -0
- package/typechain-types/IPMsgReceiverApp.ts +5 -5
- package/typechain-types/IPSwapAggregator.ts +126 -0
- package/typechain-types/IPYieldTokenV2.ts +901 -0
- package/typechain-types/IRateProvider.ts +81 -0
- package/typechain-types/IRewardRouterV2.ts +346 -0
- package/typechain-types/IRewards.ts +35 -5
- package/typechain-types/ISwapAggregator.ts +124 -0
- package/typechain-types/IVault.ts +410 -0
- package/typechain-types/IVaultPriceFeed.ts +114 -0
- package/typechain-types/InterestManagerYTV2.ts +157 -0
- package/typechain-types/MetaStableMath.ts +113 -0
- package/typechain-types/MetaStablePreview.ts +501 -0
- package/typechain-types/Multicall2.ts +437 -0
- package/typechain-types/PendleAura3EthSY.ts +1600 -0
- package/typechain-types/PendleAuraBalancerStableLPSY.ts +1523 -0
- package/typechain-types/PendleAuraCbethWstethSY.ts +1587 -0
- package/typechain-types/PendleAuraWethRethSY.ts +1549 -0
- package/typechain-types/PendleAuraWethWstethSY.ts +1523 -0
- package/typechain-types/PendleConvexLPSY.ts +204 -0
- package/typechain-types/PendleCurveFraxUsdcSY.ts +204 -0
- package/typechain-types/PendleCurveUsdd3CrvSY.ts +204 -0
- package/typechain-types/PendleFeeDistributor.ts +37 -0
- package/typechain-types/PendleGaugeControllerSidechainUpg.ts +4 -4
- package/typechain-types/PendleGlpSY.ts +1463 -0
- package/typechain-types/PendleLooksStakingSY.ts +204 -0
- package/typechain-types/PendleMsgReceiverAppUpg.ts +5 -5
- package/typechain-types/PendleMulticall.ts +110 -0
- package/typechain-types/PendlePrincipalTokenV2.ts +614 -0
- package/typechain-types/PendleQiTokenSY.ts +204 -0
- package/typechain-types/PendleRouter.ts +109 -131
- package/typechain-types/PendleSwapAggregator.ts +126 -0
- package/typechain-types/PendleWstEthSY.ts +204 -0
- package/typechain-types/PendleYieldContractFactoryV2.ts +801 -0
- package/typechain-types/PendleYieldTokenV2.ts +1298 -0
- package/typechain-types/RouterStatic.ts +92 -0
- package/typechain-types/SAPE.ts +204 -0
- package/typechain-types/SYBase.ts +204 -0
- package/typechain-types/SYBaseWithRewards.ts +204 -0
- package/typechain-types/StEthHelper.ts +107 -0
- package/typechain-types/StablePreviewBase.ts +217 -0
- package/typechain-types/SwapAggregator.ts +406 -0
- package/typechain-types/VotingEscrowPendleSidechain.ts +4 -5
- package/typechain-types/factories/ActionAddRemoveLiq__factory.ts +346 -68
- package/typechain-types/factories/ActionBaseCallback__factory.ts +156 -0
- package/typechain-types/factories/ActionCallback__factory.ts +1 -1
- package/typechain-types/factories/ActionMintRedeem__factory.ts +108 -266
- package/typechain-types/factories/ActionMisc__factory.ts +56 -17
- package/typechain-types/factories/ActionSwapPTYT__factory.ts +1 -1
- package/typechain-types/factories/ActionSwapPT__factory.ts +55 -71
- package/typechain-types/factories/ActionSwapYT__factory.ts +356 -48
- package/typechain-types/factories/AddressProvider__factory.ts +196 -0
- package/typechain-types/factories/AggregationRouterHelper__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/ComposableStablePreview__factory.ts +190 -0
- package/typechain-types/factories/Errors__factory.ts +86 -1
- package/typechain-types/factories/GLPPreviewHelper__factory.ts +65 -0
- package/typechain-types/factories/GMXPreviewHelper__factory.ts +65 -0
- package/typechain-types/factories/I1inchAggregationRouterV5__factory.ts +179 -0
- package/typechain-types/factories/IAddressProvider__factory.ts +63 -0
- package/typechain-types/factories/IAggregationExecutor__factory.ts +84 -0
- package/typechain-types/factories/IBalancerFees__factory.ts +36 -0
- package/typechain-types/factories/IBalancerStablePreview__factory.ts +152 -0
- package/typechain-types/factories/IBasePool__factory.ts +340 -0
- package/typechain-types/factories/IComposableStable__factory.ts +482 -0
- package/typechain-types/factories/IDiamondCut__factory.ts +105 -0
- package/typechain-types/factories/IDiamondLoupe__factory.ts +99 -0
- package/typechain-types/factories/IExecutorHelperEthereum1__factory.ts +407 -0
- package/typechain-types/factories/IGMXVault__factory.ts +320 -0
- package/typechain-types/factories/IGauge__factory.ts +70 -0
- package/typechain-types/factories/IGlpManager__factory.ts +55 -0
- package/typechain-types/factories/IHashflow__factory.ts +113 -0
- package/typechain-types/factories/IKyberSwapAggregationRouterHelper__factory.ts +56 -0
- package/typechain-types/factories/ILiquidityGaugeFactory__factory.ts +49 -0
- package/typechain-types/factories/IMetaAggregationRouterV2__factory.ts +234 -0
- package/typechain-types/factories/IMetaAggregationRouter__factory.ts +202 -0
- package/typechain-types/factories/IMetaStablePool__factory.ts +413 -0
- package/typechain-types/factories/IPActionAddRemoveLiq__factory.ts +338 -16
- package/typechain-types/factories/IPActionMintRedeem__factory.ts +105 -224
- package/typechain-types/factories/IPActionMisc__factory.ts +55 -11
- package/typechain-types/factories/IPActionSwapPT__factory.ts +52 -8
- package/typechain-types/factories/IPActionSwapYT__factory.ts +231 -8
- package/typechain-types/factories/IPAllAction__factory.ts +675 -241
- package/typechain-types/factories/IPFeeDistributor__factory.ts +19 -0
- package/typechain-types/factories/IPInterestManagerYTV2__factory.ts +59 -0
- package/typechain-types/factories/IPMsgReceiverApp__factory.ts +1 -1
- package/typechain-types/factories/IPSwapAggregator__factory.ts +71 -0
- package/typechain-types/factories/IPYieldTokenV2__factory.ts +694 -0
- package/typechain-types/factories/IRateProvider__factory.ts +36 -0
- package/typechain-types/factories/IRewardRouterV2__factory.ts +216 -0
- package/typechain-types/factories/IRewards__factory.ts +18 -0
- package/typechain-types/factories/ISwapAggregator__factory.ts +66 -0
- package/typechain-types/factories/IVaultPriceFeed__factory.ts +60 -0
- package/typechain-types/factories/IVault__factory.ts +287 -0
- package/typechain-types/factories/InterestManagerYTV2__factory.ts +81 -0
- package/typechain-types/factories/MarketMathStatic__factory.ts +1 -27
- package/typechain-types/factories/MetaStableMath__factory.ts +93 -0
- package/typechain-types/factories/MetaStablePreview__factory.ts +375 -0
- package/typechain-types/factories/Multicall2__factory.ts +372 -0
- package/typechain-types/factories/OracleLib__factory.ts +1 -1
- package/typechain-types/factories/PendleAura3EthSY__factory.ts +1326 -0
- package/typechain-types/factories/PendleAuraBalancerStableLPSY__factory.ts +1190 -0
- package/typechain-types/factories/PendleAuraCbethWstethSY__factory.ts +1317 -0
- package/typechain-types/factories/PendleAuraWethRethSY__factory.ts +1291 -0
- package/typechain-types/factories/PendleAuraWethWstethSY__factory.ts +1265 -0
- package/typechain-types/factories/PendleConvexLPSY__factory.ts +141 -0
- package/typechain-types/factories/PendleCurveFraxUsdcSY__factory.ts +142 -1
- package/typechain-types/factories/PendleCurveUsdd3CrvSY__factory.ts +142 -1
- package/typechain-types/factories/PendleFeeDistributor__factory.ts +33 -1
- package/typechain-types/factories/PendleGaugeControllerMainchainUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleGaugeControllerSidechainUpg__factory.ts +2 -2
- package/typechain-types/factories/PendleGlpSY__factory.ts +1249 -0
- package/typechain-types/factories/PendleLooksStakingSY__factory.ts +142 -1
- 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/PendleMsgReceiverAppUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleMsgSendEndpointUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleMulticall__factory.ts +100 -0
- package/typechain-types/factories/PendlePrincipalTokenV2__factory.ts +564 -0
- 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 +142 -1
- package/typechain-types/factories/PendleRouter__factory.ts +75 -74
- package/typechain-types/factories/PendleSwapAggregator__factory.ts +129 -0
- package/typechain-types/factories/PendleVotingControllerUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleWstEthSY__factory.ts +142 -1
- package/typechain-types/factories/PendleYieldContractFactoryV2__factory.ts +674 -0
- package/typechain-types/factories/PendleYieldContractFactory__factory.ts +1 -1
- package/typechain-types/factories/PendleYieldTokenV2__factory.ts +1109 -0
- package/typechain-types/factories/PendleYieldToken__factory.ts +1 -1
- package/typechain-types/factories/RouterStatic__factory.ts +69 -1
- package/typechain-types/factories/SAPE__factory.ts +142 -1
- package/typechain-types/factories/SYBaseWithRewards__factory.ts +141 -0
- package/typechain-types/factories/SYBase__factory.ts +141 -0
- package/typechain-types/factories/StEthHelper__factory.ts +62 -0
- package/typechain-types/factories/StablePreviewBase__factory.ts +148 -0
- package/typechain-types/factories/SwapAggregator__factory.ts +309 -0
- package/typechain-types/factories/VotingEscrowPendleMainchain__factory.ts +1 -1
- package/typechain-types/factories/VotingEscrowPendleSidechain__factory.ts +2 -2
- package/typechain-types/hardhat.d.ts +369 -54
- package/typechain-types/index.ts +88 -18
- package/build/artifacts/contracts/interfaces/IPActionSwapPTYT.sol/IPActionSwapPTYT.dbg.json +0 -4
- package/build/artifacts/contracts/interfaces/IPActionSwapPTYT.sol/IPActionSwapPTYT.json +0 -190
- package/build/artifacts/contracts/router/ActionCallback.sol/ActionCallback.dbg.json +0 -4
- package/build/artifacts/contracts/router/ActionCallback.sol/ActionCallback.json +0 -165
- package/build/artifacts/contracts/router/ActionSwapPTYT.sol/ActionSwapPTYT.dbg.json +0 -4
- package/build/artifacts/contracts/router/ActionSwapPTYT.sol/ActionSwapPTYT.json +0 -343
- package/build/artifacts/contracts/router/kyberswap/AggregationRouterHelper.sol/AggregationRouterHelper.dbg.json +0 -4
- package/build/artifacts/contracts/router/kyberswap/AggregationRouterHelper.sol/AggregationRouterHelper.json +0 -224
- 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/build/artifacts/contracts/router/kyberswap/IMultihopRouterEthereum.sol/IMultihopRouterEthereum.dbg.json +0 -4
- package/build/artifacts/contracts/router/kyberswap/IMultihopRouterEthereum.sol/IMultihopRouterEthereum.json +0 -136
- package/build/artifacts/contracts/router/kyberswap/KyberSwapHelper.sol/KyberSwapHelper.dbg.json +0 -4
- package/contracts/interfaces/IBoringOwnableUpgradeable.sol +0 -10
- package/contracts/interfaces/IPActionSwapPTYT.sol +0 -31
- package/contracts/router/ActionSwapPTYT.sol +0 -108
- package/contracts/router/kyberswap/AggregationRouterHelper.sol +0 -331
- package/contracts/router/kyberswap/IAggregatorRouterHelper.sol +0 -10
- package/contracts/router/kyberswap/IMultihopRouterEthereum.sol +0 -141
- package/contracts/router/kyberswap/KyberSwapHelper.sol +0 -79
- package/deployments/1-core.json +0 -30
- package/deployments/1-markets/APE-JUNE-29.json +0 -8
- package/deployments/1-markets/FRAXUSDC-CURVELP-MARCH30.json +0 -11
- package/deployments/1-markets/LOOKS-STAKING-MARCH30.json +0 -10
- package/deployments/1-markets/STETH-JUNE29.json +0 -10
- package/deployments/1-markets/STETH-MARCH30.json +0 -10
|
@@ -35,23 +35,6 @@ library MarketApproxPtInLib {
|
|
|
35
35
|
using Math for int256;
|
|
36
36
|
using LogExpMath for int256;
|
|
37
37
|
|
|
38
|
-
struct ApproxParamsPtIn {
|
|
39
|
-
uint256 guessMin;
|
|
40
|
-
uint256 guessMax;
|
|
41
|
-
uint256 guessOffchain;
|
|
42
|
-
uint256 maxIteration;
|
|
43
|
-
uint256 eps;
|
|
44
|
-
//
|
|
45
|
-
uint256 biggestGoodGuess;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
struct Args1 {
|
|
49
|
-
MarketState market;
|
|
50
|
-
PYIndex index;
|
|
51
|
-
uint256 minSyOut;
|
|
52
|
-
uint256 blockTime;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
38
|
/**
|
|
56
39
|
* @dev algorithm:
|
|
57
40
|
- Bin search the amount of PT to swap in
|
|
@@ -60,11 +43,11 @@ library MarketApproxPtInLib {
|
|
|
60
43
|
- guess & approx is for netPtIn
|
|
61
44
|
*/
|
|
62
45
|
function approxSwapPtForExactSy(
|
|
63
|
-
MarketState memory
|
|
64
|
-
PYIndex
|
|
65
|
-
uint256
|
|
66
|
-
uint256
|
|
67
|
-
ApproxParams memory
|
|
46
|
+
MarketState memory market,
|
|
47
|
+
PYIndex index,
|
|
48
|
+
uint256 minSyOut,
|
|
49
|
+
uint256 blockTime,
|
|
50
|
+
ApproxParams memory approx
|
|
68
51
|
)
|
|
69
52
|
internal
|
|
70
53
|
pure
|
|
@@ -74,39 +57,28 @@ library MarketApproxPtInLib {
|
|
|
74
57
|
uint256 /*netSyFee*/
|
|
75
58
|
)
|
|
76
59
|
{
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (!isGoodSlope) {
|
|
84
|
-
p.guessMax = guess;
|
|
85
|
-
continue;
|
|
86
|
-
}
|
|
60
|
+
MarketPreCompute memory comp = market.getMarketPreCompute(index, blockTime);
|
|
61
|
+
if (approx.guessOffchain == 0) {
|
|
62
|
+
// no limit on min
|
|
63
|
+
approx.guessMax = Math.min(approx.guessMax, calcMaxPtIn(market, comp));
|
|
64
|
+
validateApprox(approx);
|
|
65
|
+
}
|
|
87
66
|
|
|
88
|
-
|
|
67
|
+
for (uint256 iter = 0; iter < approx.maxIteration; ++iter) {
|
|
68
|
+
uint256 guess = nextGuess(approx, iter);
|
|
69
|
+
(uint256 netSyOut, uint256 netSyFee, ) = calcSyOut(market, comp, index, guess);
|
|
89
70
|
|
|
90
|
-
if (netSyOut >=
|
|
91
|
-
|
|
92
|
-
bool isAnswerAccepted = Math.isAGreaterApproxB(netSyOut, a.minSyOut, p.eps);
|
|
93
|
-
if (isAnswerAccepted) {
|
|
71
|
+
if (netSyOut >= minSyOut) {
|
|
72
|
+
if (Math.isAGreaterApproxB(netSyOut, minSyOut, approx.eps))
|
|
94
73
|
return (guess, netSyOut, netSyFee);
|
|
95
|
-
|
|
74
|
+
approx.guessMax = guess;
|
|
96
75
|
} else {
|
|
97
|
-
|
|
76
|
+
approx.guessMin = guess;
|
|
98
77
|
}
|
|
99
78
|
}
|
|
100
79
|
revert Errors.ApproxFail();
|
|
101
80
|
}
|
|
102
81
|
|
|
103
|
-
struct Args2 {
|
|
104
|
-
MarketState market;
|
|
105
|
-
PYIndex index;
|
|
106
|
-
uint256 exactSyIn;
|
|
107
|
-
uint256 blockTime;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
82
|
/**
|
|
111
83
|
* @dev algorithm:
|
|
112
84
|
- Bin search the amount of PT to swap in
|
|
@@ -117,11 +89,11 @@ library MarketApproxPtInLib {
|
|
|
117
89
|
- guess & approx is for netYtOut (also netPtIn)
|
|
118
90
|
*/
|
|
119
91
|
function approxSwapExactSyForYt(
|
|
120
|
-
MarketState memory
|
|
121
|
-
PYIndex
|
|
122
|
-
uint256
|
|
123
|
-
uint256
|
|
124
|
-
ApproxParams memory
|
|
92
|
+
MarketState memory market,
|
|
93
|
+
PYIndex index,
|
|
94
|
+
uint256 exactSyIn,
|
|
95
|
+
uint256 blockTime,
|
|
96
|
+
ApproxParams memory approx
|
|
125
97
|
)
|
|
126
98
|
internal
|
|
127
99
|
pure
|
|
@@ -130,48 +102,36 @@ library MarketApproxPtInLib {
|
|
|
130
102
|
uint256 /*netSyFee*/
|
|
131
103
|
)
|
|
132
104
|
{
|
|
133
|
-
|
|
134
|
-
|
|
105
|
+
MarketPreCompute memory comp = market.getMarketPreCompute(index, blockTime);
|
|
106
|
+
if (approx.guessOffchain == 0) {
|
|
107
|
+
approx.guessMin = Math.max(approx.guessMin, index.syToAsset(exactSyIn));
|
|
108
|
+
approx.guessMax = Math.min(approx.guessMax, calcMaxPtIn(market, comp));
|
|
109
|
+
validateApprox(approx);
|
|
110
|
+
}
|
|
135
111
|
|
|
136
112
|
// at minimum we will flashswap exactSyIn since we have enough SY to payback the PT loan
|
|
137
|
-
ApproxParamsPtIn memory p = newApproxParamsPtIn(
|
|
138
|
-
_approx,
|
|
139
|
-
a.index.syToAsset(a.exactSyIn),
|
|
140
|
-
calcMaxPtIn(comp.totalAsset)
|
|
141
|
-
);
|
|
142
113
|
|
|
143
|
-
for (uint256 iter = 0; iter <
|
|
144
|
-
|
|
145
|
-
if (!isGoodSlope) {
|
|
146
|
-
p.guessMax = guess;
|
|
147
|
-
continue;
|
|
148
|
-
}
|
|
114
|
+
for (uint256 iter = 0; iter < approx.maxIteration; ++iter) {
|
|
115
|
+
uint256 guess = nextGuess(approx, iter);
|
|
149
116
|
|
|
150
|
-
(uint256 netSyOut, uint256 netSyFee, ) = calcSyOut(
|
|
117
|
+
(uint256 netSyOut, uint256 netSyFee, ) = calcSyOut(market, comp, index, guess);
|
|
151
118
|
|
|
152
|
-
uint256 netSyToTokenizePt =
|
|
119
|
+
uint256 netSyToTokenizePt = index.assetToSyUp(guess);
|
|
153
120
|
|
|
154
121
|
// for sure netSyToTokenizePt >= netSyOut since we are swapping PT to SY
|
|
155
122
|
uint256 netSyToPull = netSyToTokenizePt - netSyOut;
|
|
156
123
|
|
|
157
|
-
if (netSyToPull <=
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
124
|
+
if (netSyToPull <= exactSyIn) {
|
|
125
|
+
if (Math.isASmallerApproxB(netSyToPull, exactSyIn, approx.eps))
|
|
126
|
+
return (guess, netSyFee);
|
|
127
|
+
approx.guessMin = guess;
|
|
161
128
|
} else {
|
|
162
|
-
|
|
129
|
+
approx.guessMax = guess - 1;
|
|
163
130
|
}
|
|
164
131
|
}
|
|
165
132
|
revert Errors.ApproxFail();
|
|
166
133
|
}
|
|
167
134
|
|
|
168
|
-
struct Args6 {
|
|
169
|
-
MarketState market;
|
|
170
|
-
PYIndex index;
|
|
171
|
-
uint256 totalPtIn;
|
|
172
|
-
uint256 blockTime;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
135
|
/**
|
|
176
136
|
* @dev algorithm:
|
|
177
137
|
- Bin search the amount of PT to swap to SY
|
|
@@ -181,11 +141,11 @@ library MarketApproxPtInLib {
|
|
|
181
141
|
- guess & approx is for netPtSwap
|
|
182
142
|
*/
|
|
183
143
|
function approxSwapPtToAddLiquidity(
|
|
184
|
-
MarketState memory
|
|
185
|
-
PYIndex
|
|
186
|
-
uint256
|
|
187
|
-
uint256
|
|
188
|
-
ApproxParams memory
|
|
144
|
+
MarketState memory market,
|
|
145
|
+
PYIndex index,
|
|
146
|
+
uint256 totalPtIn,
|
|
147
|
+
uint256 blockTime,
|
|
148
|
+
ApproxParams memory approx
|
|
189
149
|
)
|
|
190
150
|
internal
|
|
191
151
|
pure
|
|
@@ -195,63 +155,71 @@ library MarketApproxPtInLib {
|
|
|
195
155
|
uint256 /*netSyFee*/
|
|
196
156
|
)
|
|
197
157
|
{
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
0,
|
|
205
|
-
|
|
206
|
-
);
|
|
207
|
-
|
|
208
|
-
p.guessMax = Math.min(p.guessMax, a.totalPtIn);
|
|
209
|
-
|
|
210
|
-
for (uint256 iter = 0; iter < p.maxIteration; ++iter) {
|
|
211
|
-
(bool isGoodSlope, uint256 guess) = nextGuess(p, comp, a.market.totalPt, iter);
|
|
212
|
-
|
|
213
|
-
if (!isGoodSlope) {
|
|
214
|
-
p.guessMax = guess;
|
|
215
|
-
continue;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
(uint256 netSyOut, uint256 netSyFee, uint256 netSyToReserve) = calcSyOut(
|
|
219
|
-
a.market,
|
|
220
|
-
comp,
|
|
221
|
-
a.index,
|
|
222
|
-
guess
|
|
223
|
-
);
|
|
158
|
+
MarketPreCompute memory comp = market.getMarketPreCompute(index, blockTime);
|
|
159
|
+
if (approx.guessOffchain == 0) {
|
|
160
|
+
// no limit on min
|
|
161
|
+
approx.guessMax = Math.min(approx.guessMax, calcMaxPtIn(market, comp));
|
|
162
|
+
approx.guessMax = Math.min(approx.guessMax, totalPtIn);
|
|
163
|
+
validateApprox(approx);
|
|
164
|
+
require(market.totalLp != 0, "no existing lp");
|
|
165
|
+
}
|
|
224
166
|
|
|
225
|
-
|
|
226
|
-
uint256
|
|
227
|
-
{
|
|
228
|
-
uint256 newTotalPt = a.market.totalPt.Uint() + guess;
|
|
229
|
-
uint256 newTotalSy = (a.market.totalSy.Uint() - netSyOut - netSyToReserve);
|
|
167
|
+
for (uint256 iter = 0; iter < approx.maxIteration; ++iter) {
|
|
168
|
+
uint256 guess = nextGuess(approx, iter);
|
|
230
169
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
170
|
+
(
|
|
171
|
+
uint256 syNumerator,
|
|
172
|
+
uint256 ptNumerator,
|
|
173
|
+
uint256 netSyOut,
|
|
174
|
+
uint256 netSyFee,
|
|
235
175
|
|
|
236
|
-
|
|
237
|
-
ptNumerator = (a.totalPtIn - guess) * newTotalSy;
|
|
238
|
-
}
|
|
176
|
+
) = calcNumerators(market, index, totalPtIn, comp, guess);
|
|
239
177
|
|
|
240
|
-
if (Math.isAApproxB(syNumerator, ptNumerator,
|
|
178
|
+
if (Math.isAApproxB(syNumerator, ptNumerator, approx.eps))
|
|
241
179
|
return (guess, netSyOut, netSyFee);
|
|
242
|
-
}
|
|
243
180
|
|
|
244
181
|
if (syNumerator <= ptNumerator) {
|
|
245
182
|
// needs more SY --> swap more PT
|
|
246
|
-
|
|
183
|
+
approx.guessMin = guess + 1;
|
|
247
184
|
} else {
|
|
248
185
|
// needs less SY --> swap less PT
|
|
249
|
-
|
|
186
|
+
approx.guessMax = guess - 1;
|
|
250
187
|
}
|
|
251
188
|
}
|
|
252
189
|
revert Errors.ApproxFail();
|
|
253
190
|
}
|
|
254
191
|
|
|
192
|
+
function calcNumerators(
|
|
193
|
+
MarketState memory market,
|
|
194
|
+
PYIndex index,
|
|
195
|
+
uint256 totalPtIn,
|
|
196
|
+
MarketPreCompute memory comp,
|
|
197
|
+
uint256 guess
|
|
198
|
+
)
|
|
199
|
+
internal
|
|
200
|
+
pure
|
|
201
|
+
returns (
|
|
202
|
+
uint256 syNumerator,
|
|
203
|
+
uint256 ptNumerator,
|
|
204
|
+
uint256 netSyOut,
|
|
205
|
+
uint256 netSyFee,
|
|
206
|
+
uint256 netSyToReserve
|
|
207
|
+
)
|
|
208
|
+
{
|
|
209
|
+
(netSyOut, netSyFee, netSyToReserve) = calcSyOut(market, comp, index, guess);
|
|
210
|
+
|
|
211
|
+
uint256 newTotalPt = uint256(market.totalPt) + guess;
|
|
212
|
+
uint256 newTotalSy = (uint256(market.totalSy) - netSyOut - netSyToReserve);
|
|
213
|
+
|
|
214
|
+
// it is desired that
|
|
215
|
+
// netSyOut / newTotalSy = netPtRemaining / newTotalPt
|
|
216
|
+
// which is equivalent to
|
|
217
|
+
// netSyOut * newTotalPt = netPtRemaining * newTotalSy
|
|
218
|
+
|
|
219
|
+
syNumerator = netSyOut * newTotalPt;
|
|
220
|
+
ptNumerator = (totalPtIn - guess) * newTotalSy;
|
|
221
|
+
}
|
|
222
|
+
|
|
255
223
|
struct Args7 {
|
|
256
224
|
MarketState market;
|
|
257
225
|
PYIndex index;
|
|
@@ -269,11 +237,11 @@ library MarketApproxPtInLib {
|
|
|
269
237
|
- guess & approx is for totalPtToSwap
|
|
270
238
|
*/
|
|
271
239
|
function approxSwapExactPtForYt(
|
|
272
|
-
MarketState memory
|
|
273
|
-
PYIndex
|
|
274
|
-
uint256
|
|
275
|
-
uint256
|
|
276
|
-
ApproxParams memory
|
|
240
|
+
MarketState memory market,
|
|
241
|
+
PYIndex index,
|
|
242
|
+
uint256 exactPtIn,
|
|
243
|
+
uint256 blockTime,
|
|
244
|
+
ApproxParams memory approx
|
|
277
245
|
)
|
|
278
246
|
internal
|
|
279
247
|
pure
|
|
@@ -283,37 +251,29 @@ library MarketApproxPtInLib {
|
|
|
283
251
|
uint256 /*netSyFee*/
|
|
284
252
|
)
|
|
285
253
|
{
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
calcMaxPtIn(comp.totalAsset)
|
|
293
|
-
);
|
|
294
|
-
|
|
295
|
-
for (uint256 iter = 0; iter < p.maxIteration; ++iter) {
|
|
296
|
-
(bool isGoodSlope, uint256 guess) = nextGuess(p, comp, a.market.totalPt, iter);
|
|
254
|
+
MarketPreCompute memory comp = market.getMarketPreCompute(index, blockTime);
|
|
255
|
+
if (approx.guessOffchain == 0) {
|
|
256
|
+
approx.guessMin = Math.max(approx.guessMin, exactPtIn);
|
|
257
|
+
approx.guessMax = Math.min(approx.guessMax, calcMaxPtIn(market, comp));
|
|
258
|
+
validateApprox(approx);
|
|
259
|
+
}
|
|
297
260
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
continue;
|
|
301
|
-
}
|
|
261
|
+
for (uint256 iter = 0; iter < approx.maxIteration; ++iter) {
|
|
262
|
+
uint256 guess = nextGuess(approx, iter);
|
|
302
263
|
|
|
303
|
-
(uint256 netSyOut, uint256 netSyFee, ) = calcSyOut(
|
|
264
|
+
(uint256 netSyOut, uint256 netSyFee, ) = calcSyOut(market, comp, index, guess);
|
|
304
265
|
|
|
305
|
-
uint256 netAssetOut =
|
|
266
|
+
uint256 netAssetOut = index.syToAsset(netSyOut);
|
|
306
267
|
|
|
307
268
|
// guess >= netAssetOut since we are swapping PT to SY
|
|
308
269
|
uint256 netPtToPull = guess - netAssetOut;
|
|
309
270
|
|
|
310
|
-
if (netPtToPull <=
|
|
311
|
-
|
|
312
|
-
if (Math.isASmallerApproxB(netPtToPull, a.exactPtIn, p.eps)) {
|
|
271
|
+
if (netPtToPull <= exactPtIn) {
|
|
272
|
+
if (Math.isASmallerApproxB(netPtToPull, exactPtIn, approx.eps))
|
|
313
273
|
return (netAssetOut, guess, netSyFee);
|
|
314
|
-
|
|
274
|
+
approx.guessMin = guess;
|
|
315
275
|
} else {
|
|
316
|
-
|
|
276
|
+
approx.guessMax = guess - 1;
|
|
317
277
|
}
|
|
318
278
|
}
|
|
319
279
|
revert Errors.ApproxFail();
|
|
@@ -338,70 +298,49 @@ library MarketApproxPtInLib {
|
|
|
338
298
|
(int256 _netSyOut, int256 _netSyFee, int256 _netSyToReserve) = market.calcTrade(
|
|
339
299
|
comp,
|
|
340
300
|
index,
|
|
341
|
-
netPtIn
|
|
301
|
+
-int256(netPtIn)
|
|
342
302
|
);
|
|
343
|
-
netSyOut = _netSyOut
|
|
344
|
-
netSyFee = _netSyFee
|
|
345
|
-
netSyToReserve = _netSyToReserve
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
function newApproxParamsPtIn(
|
|
349
|
-
ApproxParams memory _approx,
|
|
350
|
-
uint256 minGuessMin,
|
|
351
|
-
uint256 maxGuessMax
|
|
352
|
-
) internal pure returns (ApproxParamsPtIn memory res) {
|
|
353
|
-
res.guessMin = Math.max(_approx.guessMin, minGuessMin);
|
|
354
|
-
res.guessMax = Math.min(_approx.guessMax, maxGuessMax);
|
|
355
|
-
|
|
356
|
-
if (res.guessMin > res.guessMax || _approx.eps > Math.ONE)
|
|
357
|
-
revert Errors.ApproxParamsInvalid(_approx.guessMin, _approx.guessMax, _approx.eps);
|
|
358
|
-
|
|
359
|
-
res.guessOffchain = _approx.guessOffchain;
|
|
360
|
-
res.maxIteration = _approx.maxIteration;
|
|
361
|
-
res.eps = _approx.eps;
|
|
303
|
+
netSyOut = uint256(_netSyOut);
|
|
304
|
+
netSyFee = uint256(_netSyFee);
|
|
305
|
+
netSyToReserve = uint256(_netSyToReserve);
|
|
362
306
|
}
|
|
363
307
|
|
|
364
|
-
function
|
|
365
|
-
|
|
308
|
+
function nextGuess(ApproxParams memory approx, uint256 iter) internal pure returns (uint256) {
|
|
309
|
+
if (iter == 0 && approx.guessOffchain != 0) return approx.guessOffchain;
|
|
310
|
+
if (approx.guessMin <= approx.guessMax) return (approx.guessMin + approx.guessMax) / 2;
|
|
311
|
+
revert Errors.ApproxFail();
|
|
366
312
|
}
|
|
367
313
|
|
|
368
|
-
|
|
369
|
-
ApproxParamsPtIn memory p,
|
|
370
|
-
MarketPreCompute memory comp,
|
|
371
|
-
int256 totalPt,
|
|
372
|
-
uint256 iter
|
|
373
|
-
) internal pure returns (bool, uint256) {
|
|
374
|
-
uint256 guess = _nextGuessPrivate(p, iter);
|
|
375
|
-
if (guess <= p.biggestGoodGuess) return (true, guess);
|
|
376
|
-
|
|
377
|
-
int256 slope = calcSlope(comp, totalPt, guess.Int());
|
|
378
|
-
if (slope < 0) return (false, guess);
|
|
314
|
+
/// INTENDED TO BE CALLED BY WHEN GUESS.OFFCHAIN == 0 ONLY ///
|
|
379
315
|
|
|
380
|
-
|
|
381
|
-
|
|
316
|
+
function validateApprox(ApproxParams memory approx) internal pure {
|
|
317
|
+
if (approx.guessMin > approx.guessMax || approx.eps > Math.ONE)
|
|
318
|
+
revert Errors.ApproxParamsInvalid(approx.guessMin, approx.guessMax, approx.eps);
|
|
382
319
|
}
|
|
383
320
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
* So once guessMin becomes larger, it should always be the case of ApproxFail
|
|
387
|
-
*/
|
|
388
|
-
function _nextGuessPrivate(ApproxParamsPtIn memory p, uint256 iter)
|
|
389
|
-
private
|
|
321
|
+
function calcMaxPtIn(MarketState memory market, MarketPreCompute memory comp)
|
|
322
|
+
internal
|
|
390
323
|
pure
|
|
391
324
|
returns (uint256)
|
|
392
325
|
{
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
326
|
+
uint256 low = 0;
|
|
327
|
+
uint256 hi = uint256(comp.totalAsset) - 1;
|
|
328
|
+
|
|
329
|
+
while (low != hi) {
|
|
330
|
+
uint256 mid = (low + hi + 1) / 2;
|
|
331
|
+
if (calcSlope(comp, market.totalPt, int256(mid)) < 0) hi = mid - 1;
|
|
332
|
+
else low = mid;
|
|
333
|
+
}
|
|
334
|
+
return low;
|
|
396
335
|
}
|
|
397
336
|
|
|
398
337
|
function calcSlope(
|
|
399
338
|
MarketPreCompute memory comp,
|
|
400
339
|
int256 totalPt,
|
|
401
|
-
int256 ptToMarket
|
|
340
|
+
int256 ptToMarket
|
|
402
341
|
) internal pure returns (int256) {
|
|
403
342
|
int256 diffAssetPtToMarket = comp.totalAsset - ptToMarket;
|
|
404
|
-
int256 sumPt = ptToMarket + totalPt;
|
|
343
|
+
int256 sumPt = ptToMarket + totalPt;
|
|
405
344
|
|
|
406
345
|
require(diffAssetPtToMarket > 0 && sumPt > 0, "invalid ptToMarket");
|
|
407
346
|
|
|
@@ -423,21 +362,6 @@ library MarketApproxPtOutLib {
|
|
|
423
362
|
using Math for int256;
|
|
424
363
|
using LogExpMath for int256;
|
|
425
364
|
|
|
426
|
-
struct ApproxParamsPtOut {
|
|
427
|
-
uint256 guessMin;
|
|
428
|
-
uint256 guessMax;
|
|
429
|
-
uint256 guessOffchain;
|
|
430
|
-
uint256 maxIteration;
|
|
431
|
-
uint256 eps;
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
struct Args4 {
|
|
435
|
-
MarketState market;
|
|
436
|
-
PYIndex index;
|
|
437
|
-
uint256 exactSyIn;
|
|
438
|
-
uint256 blockTime;
|
|
439
|
-
}
|
|
440
|
-
|
|
441
365
|
/**
|
|
442
366
|
* @dev algorithm:
|
|
443
367
|
- Bin search the amount of PT to swapExactOut
|
|
@@ -446,11 +370,11 @@ library MarketApproxPtOutLib {
|
|
|
446
370
|
- guess & approx is for netSyIn
|
|
447
371
|
*/
|
|
448
372
|
function approxSwapExactSyForPt(
|
|
449
|
-
MarketState memory
|
|
450
|
-
PYIndex
|
|
451
|
-
uint256
|
|
452
|
-
uint256
|
|
453
|
-
ApproxParams memory
|
|
373
|
+
MarketState memory market,
|
|
374
|
+
PYIndex index,
|
|
375
|
+
uint256 exactSyIn,
|
|
376
|
+
uint256 blockTime,
|
|
377
|
+
ApproxParams memory approx
|
|
454
378
|
)
|
|
455
379
|
internal
|
|
456
380
|
pure
|
|
@@ -459,38 +383,30 @@ library MarketApproxPtOutLib {
|
|
|
459
383
|
uint256 /*netSyFee*/
|
|
460
384
|
)
|
|
461
385
|
{
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
);
|
|
386
|
+
MarketPreCompute memory comp = market.getMarketPreCompute(index, blockTime);
|
|
387
|
+
if (approx.guessOffchain == 0) {
|
|
388
|
+
// no limit on min
|
|
389
|
+
approx.guessMax = Math.min(approx.guessMax, calcMaxPtOut(comp, market.totalPt));
|
|
390
|
+
validateApprox(approx);
|
|
391
|
+
}
|
|
469
392
|
|
|
470
|
-
for (uint256 iter = 0; iter <
|
|
471
|
-
uint256 guess = nextGuess(
|
|
393
|
+
for (uint256 iter = 0; iter < approx.maxIteration; ++iter) {
|
|
394
|
+
uint256 guess = nextGuess(approx, iter);
|
|
472
395
|
|
|
473
|
-
(uint256 netSyIn, uint256 netSyFee, ) = calcSyIn(
|
|
396
|
+
(uint256 netSyIn, uint256 netSyFee, ) = calcSyIn(market, comp, index, guess);
|
|
474
397
|
|
|
475
|
-
if (netSyIn <=
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
398
|
+
if (netSyIn <= exactSyIn) {
|
|
399
|
+
if (Math.isASmallerApproxB(netSyIn, exactSyIn, approx.eps))
|
|
400
|
+
return (guess, netSyFee);
|
|
401
|
+
approx.guessMin = guess;
|
|
479
402
|
} else {
|
|
480
|
-
|
|
403
|
+
approx.guessMax = guess - 1;
|
|
481
404
|
}
|
|
482
405
|
}
|
|
483
406
|
|
|
484
407
|
revert Errors.ApproxFail();
|
|
485
408
|
}
|
|
486
409
|
|
|
487
|
-
struct Args5 {
|
|
488
|
-
MarketState market;
|
|
489
|
-
PYIndex index;
|
|
490
|
-
uint256 minSyOut;
|
|
491
|
-
uint256 blockTime;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
410
|
/**
|
|
495
411
|
* @dev algorithm:
|
|
496
412
|
- Bin search the amount of PT to swapExactOut
|
|
@@ -500,11 +416,11 @@ library MarketApproxPtOutLib {
|
|
|
500
416
|
- guess & approx is for netSyOut
|
|
501
417
|
*/
|
|
502
418
|
function approxSwapYtForExactSy(
|
|
503
|
-
MarketState memory
|
|
504
|
-
PYIndex
|
|
505
|
-
uint256
|
|
506
|
-
uint256
|
|
507
|
-
ApproxParams memory
|
|
419
|
+
MarketState memory market,
|
|
420
|
+
PYIndex index,
|
|
421
|
+
uint256 minSyOut,
|
|
422
|
+
uint256 blockTime,
|
|
423
|
+
ApproxParams memory approx
|
|
508
424
|
)
|
|
509
425
|
internal
|
|
510
426
|
pure
|
|
@@ -514,29 +430,27 @@ library MarketApproxPtOutLib {
|
|
|
514
430
|
uint256 /*netSyFee*/
|
|
515
431
|
)
|
|
516
432
|
{
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
);
|
|
433
|
+
MarketPreCompute memory comp = market.getMarketPreCompute(index, blockTime);
|
|
434
|
+
if (approx.guessOffchain == 0) {
|
|
435
|
+
// no limit on min
|
|
436
|
+
approx.guessMax = Math.min(approx.guessMax, calcMaxPtOut(comp, market.totalPt));
|
|
437
|
+
validateApprox(approx);
|
|
438
|
+
}
|
|
524
439
|
|
|
525
|
-
for (uint256 iter = 0; iter <
|
|
526
|
-
uint256 guess = nextGuess(
|
|
440
|
+
for (uint256 iter = 0; iter < approx.maxIteration; ++iter) {
|
|
441
|
+
uint256 guess = nextGuess(approx, iter);
|
|
527
442
|
|
|
528
|
-
(uint256 netSyOwed, uint256 netSyFee, ) = calcSyIn(
|
|
443
|
+
(uint256 netSyOwed, uint256 netSyFee, ) = calcSyIn(market, comp, index, guess);
|
|
529
444
|
|
|
530
|
-
uint256 netAssetToRepay =
|
|
531
|
-
uint256 netSyOut =
|
|
445
|
+
uint256 netAssetToRepay = index.syToAssetUp(netSyOwed);
|
|
446
|
+
uint256 netSyOut = index.assetToSy(guess - netAssetToRepay);
|
|
532
447
|
|
|
533
|
-
if (netSyOut >=
|
|
534
|
-
|
|
535
|
-
if (Math.isAGreaterApproxB(netSyOut, a.minSyOut, p.eps)) {
|
|
448
|
+
if (netSyOut >= minSyOut) {
|
|
449
|
+
if (Math.isAGreaterApproxB(netSyOut, minSyOut, approx.eps))
|
|
536
450
|
return (guess, netSyOut, netSyFee);
|
|
537
|
-
|
|
451
|
+
approx.guessMax = guess;
|
|
538
452
|
} else {
|
|
539
|
-
|
|
453
|
+
approx.guessMin = guess + 1;
|
|
540
454
|
}
|
|
541
455
|
}
|
|
542
456
|
revert Errors.ApproxFail();
|
|
@@ -547,6 +461,7 @@ library MarketApproxPtOutLib {
|
|
|
547
461
|
PYIndex index;
|
|
548
462
|
uint256 totalSyIn;
|
|
549
463
|
uint256 blockTime;
|
|
464
|
+
ApproxParams approx;
|
|
550
465
|
}
|
|
551
466
|
|
|
552
467
|
/**
|
|
@@ -572,18 +487,18 @@ library MarketApproxPtOutLib {
|
|
|
572
487
|
uint256 /*netSyFee*/
|
|
573
488
|
)
|
|
574
489
|
{
|
|
575
|
-
Args6 memory a = Args6(_market, _index, _totalSyIn, _blockTime);
|
|
576
|
-
require(a.market.totalLp != 0, "no existing lp");
|
|
490
|
+
Args6 memory a = Args6(_market, _index, _totalSyIn, _blockTime, _approx);
|
|
577
491
|
|
|
578
492
|
MarketPreCompute memory comp = a.market.getMarketPreCompute(a.index, a.blockTime);
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
493
|
+
if (a.approx.guessOffchain == 0) {
|
|
494
|
+
// no limit on min
|
|
495
|
+
a.approx.guessMax = Math.min(a.approx.guessMax, calcMaxPtOut(comp, a.market.totalPt));
|
|
496
|
+
validateApprox(a.approx);
|
|
497
|
+
require(a.market.totalLp != 0, "no existing lp");
|
|
498
|
+
}
|
|
584
499
|
|
|
585
|
-
for (uint256 iter = 0; iter <
|
|
586
|
-
uint256 guess = nextGuess(
|
|
500
|
+
for (uint256 iter = 0; iter < a.approx.maxIteration; ++iter) {
|
|
501
|
+
uint256 guess = nextGuess(a.approx, iter);
|
|
587
502
|
|
|
588
503
|
(uint256 netSyIn, uint256 netSyFee, uint256 netSyToReserve) = calcSyIn(
|
|
589
504
|
a.market,
|
|
@@ -593,7 +508,7 @@ library MarketApproxPtOutLib {
|
|
|
593
508
|
);
|
|
594
509
|
|
|
595
510
|
if (netSyIn > a.totalSyIn) {
|
|
596
|
-
|
|
511
|
+
a.approx.guessMax = guess - 1;
|
|
597
512
|
continue;
|
|
598
513
|
}
|
|
599
514
|
|
|
@@ -601,8 +516,8 @@ library MarketApproxPtOutLib {
|
|
|
601
516
|
uint256 ptNumerator;
|
|
602
517
|
|
|
603
518
|
{
|
|
604
|
-
uint256 newTotalPt = a.market.totalPt
|
|
605
|
-
uint256 netTotalSy = a.market.totalSy
|
|
519
|
+
uint256 newTotalPt = uint256(a.market.totalPt) - guess;
|
|
520
|
+
uint256 netTotalSy = uint256(a.market.totalSy) + netSyIn - netSyToReserve;
|
|
606
521
|
|
|
607
522
|
// it is desired that
|
|
608
523
|
// netPtFromSwap / newTotalPt = netSyRemaining / netTotalSy
|
|
@@ -613,44 +528,35 @@ library MarketApproxPtOutLib {
|
|
|
613
528
|
syNumerator = (a.totalSyIn - netSyIn) * newTotalPt;
|
|
614
529
|
}
|
|
615
530
|
|
|
616
|
-
if (Math.isAApproxB(ptNumerator, syNumerator,
|
|
531
|
+
if (Math.isAApproxB(ptNumerator, syNumerator, a.approx.eps))
|
|
617
532
|
return (guess, netSyIn, netSyFee);
|
|
618
|
-
}
|
|
619
533
|
|
|
620
534
|
if (ptNumerator <= syNumerator) {
|
|
621
535
|
// needs more PT
|
|
622
|
-
|
|
536
|
+
a.approx.guessMin = guess + 1;
|
|
623
537
|
} else {
|
|
624
538
|
// needs less PT
|
|
625
|
-
|
|
539
|
+
a.approx.guessMax = guess - 1;
|
|
626
540
|
}
|
|
627
541
|
}
|
|
628
542
|
revert Errors.ApproxFail();
|
|
629
543
|
}
|
|
630
544
|
|
|
631
|
-
struct Args8 {
|
|
632
|
-
MarketState market;
|
|
633
|
-
PYIndex index;
|
|
634
|
-
uint256 exactYtIn;
|
|
635
|
-
uint256 blockTime;
|
|
636
|
-
uint256 maxSyPayable;
|
|
637
|
-
}
|
|
638
|
-
|
|
639
545
|
/**
|
|
640
546
|
* @dev algorithm:
|
|
641
547
|
- Bin search the amount of PT to swapExactOut
|
|
642
548
|
- Flashswap that amount of PT out
|
|
643
549
|
- Pair all the PT with the YT to redeem SY
|
|
644
550
|
- Use the SY to repay the flashswap debt
|
|
645
|
-
- Stop when the amount of
|
|
551
|
+
- Stop when the amount of YT required to pair with PT is approx exactYtIn
|
|
646
552
|
- guess & approx is for netPtFromSwap
|
|
647
553
|
*/
|
|
648
554
|
function approxSwapExactYtForPt(
|
|
649
|
-
MarketState memory
|
|
650
|
-
PYIndex
|
|
651
|
-
uint256
|
|
652
|
-
uint256
|
|
653
|
-
ApproxParams memory
|
|
555
|
+
MarketState memory market,
|
|
556
|
+
PYIndex index,
|
|
557
|
+
uint256 exactYtIn,
|
|
558
|
+
uint256 blockTime,
|
|
559
|
+
ApproxParams memory approx
|
|
654
560
|
)
|
|
655
561
|
internal
|
|
656
562
|
pure
|
|
@@ -660,33 +566,26 @@ library MarketApproxPtOutLib {
|
|
|
660
566
|
uint256 /*netSyFee*/
|
|
661
567
|
)
|
|
662
568
|
{
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
);
|
|
670
|
-
MarketPreCompute memory comp = a.market.getMarketPreCompute(a.index, a.blockTime);
|
|
671
|
-
ApproxParamsPtOut memory p = newApproxParamsPtOut(
|
|
672
|
-
_approx,
|
|
673
|
-
a.exactYtIn,
|
|
674
|
-
calcMaxPtOut(comp, a.market.totalPt)
|
|
675
|
-
);
|
|
569
|
+
MarketPreCompute memory comp = market.getMarketPreCompute(index, blockTime);
|
|
570
|
+
if (approx.guessOffchain == 0) {
|
|
571
|
+
approx.guessMin = Math.max(approx.guessMin, exactYtIn);
|
|
572
|
+
approx.guessMax = Math.min(approx.guessMax, calcMaxPtOut(comp, market.totalPt));
|
|
573
|
+
validateApprox(approx);
|
|
574
|
+
}
|
|
676
575
|
|
|
677
|
-
for (uint256 iter = 0; iter <
|
|
678
|
-
uint256 guess = nextGuess(
|
|
576
|
+
for (uint256 iter = 0; iter < approx.maxIteration; ++iter) {
|
|
577
|
+
uint256 guess = nextGuess(approx, iter);
|
|
679
578
|
|
|
680
|
-
(uint256 netSyOwed, uint256 netSyFee, ) = calcSyIn(
|
|
579
|
+
(uint256 netSyOwed, uint256 netSyFee, ) = calcSyIn(market, comp, index, guess);
|
|
681
580
|
|
|
682
|
-
|
|
683
|
-
p.guessMin = guess;
|
|
581
|
+
uint256 netYtToPull = index.syToAssetUp(netSyOwed);
|
|
684
582
|
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
583
|
+
if (netYtToPull <= exactYtIn) {
|
|
584
|
+
if (Math.isASmallerApproxB(netYtToPull, exactYtIn, approx.eps))
|
|
585
|
+
return (guess - netYtToPull, guess, netSyFee);
|
|
586
|
+
approx.guessMin = guess;
|
|
688
587
|
} else {
|
|
689
|
-
|
|
588
|
+
approx.guessMax = guess - 1;
|
|
690
589
|
}
|
|
691
590
|
}
|
|
692
591
|
revert Errors.ApproxFail();
|
|
@@ -711,36 +610,13 @@ library MarketApproxPtOutLib {
|
|
|
711
610
|
(int256 _netSyIn, int256 _netSyFee, int256 _netSyToReserve) = market.calcTrade(
|
|
712
611
|
comp,
|
|
713
612
|
index,
|
|
714
|
-
netPtOut
|
|
613
|
+
int256(netPtOut)
|
|
715
614
|
);
|
|
716
615
|
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
function newApproxParamsPtOut(
|
|
723
|
-
ApproxParams memory _approx,
|
|
724
|
-
uint256 minGuessMin,
|
|
725
|
-
uint256 maxGuessMax
|
|
726
|
-
) internal pure returns (ApproxParamsPtOut memory res) {
|
|
727
|
-
if (_approx.guessMin > _approx.guessMax || _approx.eps > Math.ONE)
|
|
728
|
-
revert Errors.ApproxParamsInvalid(_approx.guessMin, _approx.guessMax, _approx.eps);
|
|
729
|
-
|
|
730
|
-
res.guessMin = Math.max(_approx.guessMin, minGuessMin);
|
|
731
|
-
res.guessMax = Math.min(_approx.guessMax, maxGuessMax);
|
|
732
|
-
|
|
733
|
-
if (res.guessMin > res.guessMax)
|
|
734
|
-
revert Errors.ApproxBinarySearchInputInvalid(
|
|
735
|
-
_approx.guessMin,
|
|
736
|
-
_approx.guessMax,
|
|
737
|
-
minGuessMin,
|
|
738
|
-
maxGuessMax
|
|
739
|
-
);
|
|
740
|
-
|
|
741
|
-
res.guessOffchain = _approx.guessOffchain;
|
|
742
|
-
res.maxIteration = _approx.maxIteration;
|
|
743
|
-
res.eps = _approx.eps;
|
|
616
|
+
// all safe since totalPt and totalSy is int128
|
|
617
|
+
netSyIn = uint256(-_netSyIn);
|
|
618
|
+
netSyFee = uint256(_netSyFee);
|
|
619
|
+
netSyToReserve = uint256(_netSyToReserve);
|
|
744
620
|
}
|
|
745
621
|
|
|
746
622
|
function calcMaxPtOut(MarketPreCompute memory comp, int256 totalPt)
|
|
@@ -753,16 +629,17 @@ library MarketApproxPtOutLib {
|
|
|
753
629
|
int256 numerator = proportion.mulDown(totalPt + comp.totalAsset);
|
|
754
630
|
int256 maxPtOut = totalPt - numerator;
|
|
755
631
|
// only get 99.9% of the theoretical max to accommodate some precision issues
|
|
756
|
-
return (maxPtOut
|
|
632
|
+
return (uint256(maxPtOut) * 999) / 1000;
|
|
757
633
|
}
|
|
758
634
|
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
*/
|
|
763
|
-
function nextGuess(ApproxParamsPtOut memory p, uint256 iter) private pure returns (uint256) {
|
|
764
|
-
if (iter == 0 && p.guessOffchain != 0) return p.guessOffchain;
|
|
765
|
-
if (p.guessMin <= p.guessMax) return (p.guessMin + p.guessMax) / 2;
|
|
635
|
+
function nextGuess(ApproxParams memory approx, uint256 iter) internal pure returns (uint256) {
|
|
636
|
+
if (iter == 0 && approx.guessOffchain != 0) return approx.guessOffchain;
|
|
637
|
+
if (approx.guessMin <= approx.guessMax) return (approx.guessMin + approx.guessMax) / 2;
|
|
766
638
|
revert Errors.ApproxFail();
|
|
767
639
|
}
|
|
640
|
+
|
|
641
|
+
function validateApprox(ApproxParams memory approx) internal pure {
|
|
642
|
+
if (approx.guessMin > approx.guessMax || approx.eps > Math.ONE)
|
|
643
|
+
revert Errors.ApproxParamsInvalid(approx.guessMin, approx.guessMax, approx.eps);
|
|
644
|
+
}
|
|
768
645
|
}
|