@pendle/core-v2 0.13.1-testnet → 0.14.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/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/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/PendleGaugeControllerBaseUpg.sol/PendleGaugeControllerBaseUpg.json +89 -0
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.json +91 -2
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.json +91 -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/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 +26 -26
- 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/StandardizedYield/PYIndex.sol/PYIndexLib.dbg.json +4 -0
- package/build/artifacts/contracts/core/{SuperComposableYield → StandardizedYield}/PYIndex.sol/PYIndexLib.json +3 -3
- package/build/artifacts/contracts/core/StandardizedYield/SYBase.sol/SYBase.dbg.json +4 -0
- package/build/artifacts/contracts/core/{SuperComposableYield/SCYBase.sol/SCYBase.json → StandardizedYield/SYBase.sol/SYBase.json} +11 -11
- package/build/artifacts/contracts/core/StandardizedYield/SYBaseWithRewards.sol/SYBaseWithRewards.dbg.json +4 -0
- package/build/artifacts/contracts/core/{SuperComposableYield/SCYBaseWithRewards.sol/SCYBaseWithRewards.json → StandardizedYield/SYBaseWithRewards.sol/SYBaseWithRewards.json} +11 -11
- package/build/artifacts/contracts/core/StandardizedYield/SYUtils.sol/SYUtils.dbg.json +4 -0
- package/build/artifacts/contracts/core/{SuperComposableYield/SCYUtils.sol/SCYUtils.json → StandardizedYield/SYUtils.sol/SYUtils.json} +4 -4
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.dbg.json +4 -0
- package/build/artifacts/contracts/core/{SuperComposableYield → StandardizedYield}/implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.json +3 -3
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol/PendleQiTokenSY.dbg.json +4 -0
- package/build/artifacts/contracts/core/{SuperComposableYield/implementations/BenQi/PendleQiTokenSCY.sol/PendleQiTokenSCY.json → StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol/PendleQiTokenSY.json} +17 -17
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/ConvexCurveLP/Pendle3CrvAndTokenSY.sol/Pendle3CrvAndTokenSY.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/ConvexCurveLP/Pendle3CrvAndTokenSY.sol/Pendle3CrvAndTokenSY.json +1028 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/ConvexCurveLP/PendleConvexLPSY.sol/PendleConvexLPSY.dbg.json +4 -0
- package/build/artifacts/contracts/core/{SuperComposableYield/implementations/Convex/ConvexCurveLP/PendleConvexCurveLPSCY.sol/PendleConvexCurveLPSCY.json → StandardizedYield/implementations/Convex/ConvexCurveLP/PendleConvexLPSY.sol/PendleConvexLPSY.json} +47 -47
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/Pendle3CrvHelper.sol/Pendle3CrvHelper.dbg.json +4 -0
- package/build/artifacts/contracts/core/{SuperComposableYield → StandardizedYield}/implementations/Convex/Pendle3CrvHelper.sol/Pendle3CrvHelper.json +5 -5
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol/PendleWstEthSY.dbg.json +4 -0
- package/build/artifacts/contracts/core/{SuperComposableYield/implementations/PendleWstEthSCY.sol/PendleWstEthSCY.json → StandardizedYield/implementations/PendleWstEthSY.sol/PendleWstEthSY.json} +13 -13
- 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 +4 -4
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.json +4 -4
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.json +24 -24
- package/build/artifacts/contracts/core/libraries/Errors.sol/Errors.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/Errors.sol/Errors.json +28 -28
- package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.json +30 -30
- package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.json +34 -34
- package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.json +20 -20
- package/build/artifacts/contracts/interfaces/IPActionSwapPTYT.sol/IPActionSwapPTYT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapPTYT.sol/IPActionSwapPTYT.json +2 -2
- package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.json +20 -20
- package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.json +106 -106
- package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.json +18 -18
- package/build/artifacts/contracts/interfaces/IPMarketSwapCallback.sol/IPMarketSwapCallback.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMarketSwapCallback.sol/IPMarketSwapCallback.json +1 -1
- package/build/artifacts/contracts/interfaces/IPPrincipalToken.sol/IPPrincipalToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPPrincipalToken.sol/IPPrincipalToken.json +1 -1
- package/build/artifacts/contracts/interfaces/IPVotingController.sol/IPVotingController.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPVotingEscrowMainchain.sol/IPVotingEscrowMainchain.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPYieldContractFactory.sol/IPYieldContractFactory.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPYieldContractFactory.sol/IPYieldContractFactory.json +3 -3
- package/build/artifacts/contracts/interfaces/IPYieldToken.sol/IPYieldToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPYieldToken.sol/IPYieldToken.json +6 -6
- package/build/artifacts/contracts/interfaces/IStandardizedYield.sol/IStandardizedYield.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/{ISuperComposableYield.sol/ISuperComposableYield.json → IStandardizedYield.sol/IStandardizedYield.json} +5 -5
- package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.json +7 -7
- package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.json +116 -116
- package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.json +35 -35
- package/build/artifacts/contracts/router/ActionCallback.sol/ActionCallback.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionCallback.sol/ActionCallback.json +12 -12
- package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.json +41 -41
- 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 +28 -28
- package/build/artifacts/contracts/router/ActionSwapPTYT.sol/ActionSwapPTYT.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionSwapPTYT.sol/ActionSwapPTYT.json +4 -4
- package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.json +22 -22
- 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/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/kyberswap/KyberSwapHelper.sol/KyberSwapHelper.dbg.json +1 -1
- package/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol +96 -27
- package/contracts/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol +40 -12
- package/contracts/LiquidityMining/CrossChainMsg/PendleMsgSenderAppUpg.sol +24 -5
- package/contracts/LiquidityMining/CrossChainMsg/libraries/ExcessivelySafeCall.sol +133 -0
- package/contracts/LiquidityMining/CrossChainMsg/libraries/LayerZeroHelper.sol +33 -0
- package/contracts/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol +8 -1
- package/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol +3 -3
- package/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol +2 -7
- package/contracts/core/Market/MarketMathCore.sol +50 -53
- package/contracts/core/Market/PendleGauge.sol +8 -8
- package/contracts/core/Market/PendleMarket.sol +49 -49
- package/contracts/core/Market/PendleMarketFactory.sol +1 -1
- package/contracts/core/RewardManager/RewardManager.sol +1 -1
- package/contracts/core/{SuperComposableYield → StandardizedYield}/PYIndex.sol +16 -16
- package/contracts/core/{SuperComposableYield/SCYBase.sol → StandardizedYield/SYBase.sol} +17 -17
- package/contracts/core/{SuperComposableYield/SCYBaseWithRewards.sol → StandardizedYield/SYBaseWithRewards.sol} +9 -9
- package/contracts/core/StandardizedYield/SYUtils.sol +26 -0
- package/contracts/core/{SuperComposableYield → StandardizedYield}/implementations/BenQi/PendleQiTokenHelper.sol +1 -1
- package/contracts/core/{SuperComposableYield/implementations/BenQi/PendleQiTokenSCY.sol → StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol} +10 -10
- package/contracts/core/StandardizedYield/implementations/Convex/ConvexCurveLP/Pendle3CrvAndTokenSY.sol +167 -0
- package/contracts/core/{SuperComposableYield/implementations/Convex/ConvexCurveLP/PendleConvexCurveLPSCY.sol → StandardizedYield/implementations/Convex/ConvexCurveLP/PendleConvexLPSY.sol} +51 -70
- package/contracts/core/{SuperComposableYield → StandardizedYield}/implementations/Convex/Pendle3CrvHelper.sol +7 -7
- package/contracts/core/{SuperComposableYield/implementations/PendleWstEthSCY.sol → StandardizedYield/implementations/PendleWstEthSY.sol} +5 -5
- package/contracts/core/YieldContracts/InterestManagerYT.sol +7 -7
- package/contracts/core/YieldContracts/PendlePrincipalToken.sol +3 -3
- package/contracts/core/YieldContracts/PendleYieldContractFactory.sol +15 -15
- package/contracts/core/YieldContracts/PendleYieldToken.sol +71 -71
- package/contracts/core/libraries/Errors.sol +23 -21
- package/contracts/core/libraries/TokenHelper.sol +0 -33
- package/contracts/interfaces/Curve/ICrvPool.sol +2 -0
- package/contracts/interfaces/ILayerZeroEndpoint.sol +39 -0
- package/contracts/interfaces/ILayerZeroReceiver.sol +12 -0
- package/contracts/interfaces/IPActionAddRemoveLiq.sol +27 -27
- package/contracts/interfaces/IPActionMintRedeem.sol +30 -30
- package/contracts/interfaces/IPActionSwapPT.sol +16 -16
- package/contracts/interfaces/IPActionSwapPTYT.sol +2 -2
- package/contracts/interfaces/IPActionSwapYT.sol +16 -16
- package/contracts/interfaces/IPMarket.sol +14 -19
- package/contracts/interfaces/IPMarketSwapCallback.sol +1 -1
- package/contracts/interfaces/IPMsgSendEndpoint.sol +4 -2
- package/contracts/interfaces/IPPrincipalToken.sol +1 -1
- package/contracts/interfaces/IPYieldContractFactory.sol +3 -3
- package/contracts/interfaces/IPYieldToken.sol +7 -9
- package/contracts/interfaces/{ISuperComposableYield.sol → IStandardizedYield.sol} +6 -6
- package/contracts/offchain-helpers/MarketMathStatic.sol +116 -131
- package/contracts/offchain-helpers/RouterStatic.sol +80 -93
- package/contracts/router/ActionAddRemoveLiq.sol +99 -111
- package/contracts/router/ActionCallback.sol +46 -46
- package/contracts/router/ActionMintRedeem.sol +58 -58
- package/contracts/router/ActionSwapPT.sol +61 -69
- package/contracts/router/ActionSwapPTYT.sol +7 -7
- package/contracts/router/ActionSwapYT.sol +72 -79
- package/contracts/router/PendleRouter.sol +16 -16
- package/contracts/router/base/ActionBaseMintRedeem.sol +43 -43
- package/contracts/router/base/CallbackHelper.sol +20 -20
- package/contracts/router/base/MarketApproxLib.sol +166 -143
- package/contracts/router/kyberswap/KyberSwapHelper.sol +2 -2
- package/deployments/43113-core.json +16 -0
- package/{contracts/deployments → deployments}/43113-helper.json +0 -0
- package/deployments/43113-markets/benqi-market-QI-USDC-FEB-2ND.json +8 -0
- package/deployments/43113-markets/benqi-market-QI-WETH-DEC-1ST.json +8 -0
- package/{contracts/deployments → deployments}/43113-testenv.json +0 -0
- package/deployments/80001-core.json +15 -0
- package/{contracts/deployments → deployments}/80001-testenv.json +0 -0
- package/package.json +2 -2
- package/typechain-types/ActionAddRemoveLiq.ts +127 -129
- package/typechain-types/ActionCallback.ts +5 -5
- package/typechain-types/ActionMintRedeem.ts +139 -141
- package/typechain-types/ActionSwapPT.ts +73 -73
- package/typechain-types/ActionSwapPTYT.ts +2 -2
- package/typechain-types/ActionSwapYT.ts +73 -73
- package/typechain-types/IPActionAddRemoveLiq.ts +127 -129
- package/typechain-types/IPActionMintRedeem.ts +139 -141
- package/typechain-types/IPActionSwapPT.ts +73 -73
- package/typechain-types/IPActionSwapPTYT.ts +2 -2
- package/typechain-types/IPActionSwapYT.ts +73 -73
- package/typechain-types/IPAllAction.ts +402 -406
- package/typechain-types/IPMarket.ts +51 -54
- package/typechain-types/IPMarketSwapCallback.ts +5 -5
- package/typechain-types/IPPrincipalToken.ts +8 -8
- package/typechain-types/IPYieldContractFactory.ts +13 -13
- package/typechain-types/IPYieldToken.ts +17 -17
- package/typechain-types/IStandardizedYield.ts +895 -0
- package/typechain-types/MarketMathStatic.ts +27 -27
- package/typechain-types/Pendle3CrvAndTokenSY.ts +1243 -0
- package/typechain-types/Pendle3CrvHelper.ts +13 -13
- package/typechain-types/PendleConvexLPSY.ts +1189 -0
- package/typechain-types/PendleGaugeControllerBaseUpg.ts +125 -0
- package/typechain-types/PendleGaugeControllerMainchainUpg.ts +125 -0
- package/typechain-types/PendleGaugeControllerSidechainUpg.ts +124 -0
- package/typechain-types/PendleMarket.ts +54 -57
- package/typechain-types/PendlePrincipalToken.ts +8 -8
- package/typechain-types/PendleQiTokenSY.ts +1166 -0
- package/typechain-types/PendleWstEthSY.ts +1040 -0
- package/typechain-types/PendleYieldContractFactory.ts +8 -8
- package/typechain-types/PendleYieldToken.ts +41 -44
- package/typechain-types/RouterStatic.ts +196 -196
- package/typechain-types/SYBase.ts +1001 -0
- package/typechain-types/SYBaseWithRewards.ts +1094 -0
- package/typechain-types/factories/ActionAddRemoveLiq__factory.ts +34 -34
- package/typechain-types/factories/ActionCallback__factory.ts +11 -11
- package/typechain-types/factories/ActionMintRedeem__factory.ts +38 -38
- package/typechain-types/factories/ActionMisc__factory.ts +1 -1
- package/typechain-types/factories/ActionSwapPTYT__factory.ts +3 -3
- package/typechain-types/factories/ActionSwapPT__factory.ts +27 -27
- package/typechain-types/factories/ActionSwapYT__factory.ts +21 -21
- package/typechain-types/factories/Errors__factory.ts +27 -27
- package/typechain-types/factories/IPActionAddRemoveLiq__factory.ts +30 -30
- package/typechain-types/factories/IPActionMintRedeem__factory.ts +34 -34
- package/typechain-types/factories/IPActionSwapPTYT__factory.ts +2 -2
- package/typechain-types/factories/IPActionSwapPT__factory.ts +20 -20
- package/typechain-types/factories/IPActionSwapYT__factory.ts +20 -20
- package/typechain-types/factories/IPAllAction__factory.ts +106 -106
- package/typechain-types/factories/IPMarketSwapCallback__factory.ts +1 -1
- package/typechain-types/factories/IPMarket__factory.ts +18 -18
- package/typechain-types/factories/IPPrincipalToken__factory.ts +1 -1
- package/typechain-types/factories/IPYieldContractFactory__factory.ts +3 -3
- package/typechain-types/factories/IPYieldToken__factory.ts +6 -6
- package/typechain-types/factories/IStandardizedYield__factory.ts +658 -0
- package/typechain-types/factories/MarketMathStatic__factory.ts +6 -6
- package/typechain-types/factories/OracleLib__factory.ts +1 -1
- package/typechain-types/factories/Pendle3CrvAndTokenSY__factory.ts +1124 -0
- package/typechain-types/factories/Pendle3CrvHelper__factory.ts +3 -3
- package/typechain-types/factories/PendleConvexLPSY__factory.ts +963 -0
- package/typechain-types/factories/PendleFeeDistributorFactory__factory.ts +1 -1
- package/typechain-types/factories/PendleFeeDistributor__factory.ts +1 -1
- package/typechain-types/factories/PendleGaugeControllerBaseUpg__factory.ts +89 -0
- package/typechain-types/factories/PendleGaugeControllerMainchainUpg__factory.ts +90 -1
- package/typechain-types/factories/PendleGaugeControllerSidechainUpg__factory.ts +90 -1
- package/typechain-types/factories/PendleMarketFactory__factory.ts +1 -1
- package/typechain-types/factories/PendleMarket__factory.ts +21 -21
- 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 +7 -7
- package/typechain-types/factories/PendleQiTokenHelper__factory.ts +1 -1
- package/typechain-types/factories/PendleQiTokenSY__factory.ts +1095 -0
- 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 +924 -0
- package/typechain-types/factories/PendleYieldContractFactory__factory.ts +3 -3
- package/typechain-types/factories/PendleYieldToken__factory.ts +27 -27
- package/typechain-types/factories/RouterStatic__factory.ts +57 -57
- package/typechain-types/factories/SYBaseWithRewards__factory.ts +867 -0
- package/typechain-types/factories/SYBase__factory.ts +795 -0
- package/typechain-types/factories/VotingEscrowPendleMainchain__factory.ts +1 -1
- package/typechain-types/factories/VotingEscrowPendleSidechain__factory.ts +1 -1
- package/typechain-types/hardhat.d.ts +33 -51
- package/typechain-types/index.ts +14 -18
- package/build/artifacts/contracts/core/SuperComposableYield/PYIndex.sol/PYIndexLib.dbg.json +0 -4
- package/build/artifacts/contracts/core/SuperComposableYield/SCYBase.sol/SCYBase.dbg.json +0 -4
- package/build/artifacts/contracts/core/SuperComposableYield/SCYBaseWithRewards.sol/SCYBaseWithRewards.dbg.json +0 -4
- package/build/artifacts/contracts/core/SuperComposableYield/SCYUtils.sol/SCYUtils.dbg.json +0 -4
- package/build/artifacts/contracts/core/SuperComposableYield/implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.dbg.json +0 -4
- package/build/artifacts/contracts/core/SuperComposableYield/implementations/BenQi/PendleQiTokenSCY.sol/PendleQiTokenSCY.dbg.json +0 -4
- package/build/artifacts/contracts/core/SuperComposableYield/implementations/Convex/ConvexCurveLP/Pendle3CrvAndTokenSCY.sol/Pendle3CrvAndTokenSCY.dbg.json +0 -4
- package/build/artifacts/contracts/core/SuperComposableYield/implementations/Convex/ConvexCurveLP/Pendle3CrvAndTokenSCY.sol/Pendle3CrvAndTokenSCY.json +0 -1030
- package/build/artifacts/contracts/core/SuperComposableYield/implementations/Convex/ConvexCurveLP/PendleConvexCurveLP2PoolSCY.sol/PendleConvexCurveLP2PoolSCY.dbg.json +0 -4
- package/build/artifacts/contracts/core/SuperComposableYield/implementations/Convex/ConvexCurveLP/PendleConvexCurveLP2PoolSCY.sol/PendleConvexCurveLP2PoolSCY.json +0 -1025
- package/build/artifacts/contracts/core/SuperComposableYield/implementations/Convex/ConvexCurveLP/PendleConvexCurveLPSCY.sol/PendleConvexCurveLPSCY.dbg.json +0 -4
- package/build/artifacts/contracts/core/SuperComposableYield/implementations/Convex/Pendle3CrvHelper.sol/Pendle3CrvHelper.dbg.json +0 -4
- package/build/artifacts/contracts/core/SuperComposableYield/implementations/PendleWstEthSCY.sol/PendleWstEthSCY.dbg.json +0 -4
- package/build/artifacts/contracts/interfaces/ISuperComposableYield.sol/ISuperComposableYield.dbg.json +0 -4
- package/build/artifacts/contracts/offchain-helpers/ImplicitSwapfeeContract.sol/ImplicitSwapfeeContract.dbg.json +0 -4
- package/build/artifacts/contracts/offchain-helpers/ImplicitSwapfeeContract.sol/ImplicitSwapfeeContract.json +0 -190
- package/contracts/core/SuperComposableYield/SCYUtils.sol +0 -34
- package/contracts/core/SuperComposableYield/implementations/Convex/ConvexCurveLP/Pendle3CrvAndTokenSCY.sol +0 -135
- package/contracts/core/SuperComposableYield/implementations/Convex/ConvexCurveLP/PendleConvexCurveLP2PoolSCY.sol +0 -96
- package/contracts/deployments/43113-core.json +0 -16
- package/contracts/deployments/43113-markets/benqi-market-QI-USDC-FEB-2ND.json +0 -8
- package/contracts/deployments/43113-markets/benqi-market-QI-WETH-DEC-1ST.json +0 -8
- package/contracts/deployments/80001-core.json +0 -15
- package/contracts/deployments/80001-markets/benqi-market-QI-USDC-FEB-2ND.json +0 -8
- package/contracts/deployments/80001-markets/benqi-market-QI-WETH-DEC-1ST.json +0 -8
- package/contracts/interfaces/ICelerMessageBus.sol +0 -28
- package/contracts/interfaces/ICelerMessageReceiverApp.sol +0 -25
- package/contracts/offchain-helpers/ImplicitSwapfeeContract.sol +0 -26
|
@@ -12,15 +12,15 @@ struct ApproxParams {
|
|
|
12
12
|
uint256 eps; // the max eps between the returned result & the correct result, base 1e18. Normally this number will be set
|
|
13
13
|
// to 1e15 (1e18/1000 = 0.1%)
|
|
14
14
|
|
|
15
|
-
/// Further explanation of the eps. Take
|
|
16
|
-
/// it's necessary to run an approximation algorithm, because by default there only exists the Pt to
|
|
15
|
+
/// Further explanation of the eps. Take swapExactSyForPt for example. To calc the corresponding amount of Pt to swap out,
|
|
16
|
+
/// it's necessary to run an approximation algorithm, because by default there only exists the Pt to Sy formula
|
|
17
17
|
/// To approx, the 5 values above will have to be provided, and the approx process will run as follows:
|
|
18
18
|
/// mid = (guessMin + guessMax) / 2 // mid here is the current guess of the amount of Pt out
|
|
19
|
-
///
|
|
20
|
-
/// if (
|
|
19
|
+
/// netSyNeed = calcSwapSyForExactPt(mid)
|
|
20
|
+
/// if (netSyNeed > exactSyIn) guessMax = mid - 1 // since the maximum Sy in can't exceed the exactSyIn
|
|
21
21
|
/// else guessMin = mid (1)
|
|
22
|
-
/// For the (1), since
|
|
23
|
-
///
|
|
22
|
+
/// For the (1), since netSyNeed <= exactSyIn, the result might be usable. If the netSyNeed is within eps of
|
|
23
|
+
/// exactSyIn (ex eps=0.1% => we have used 99.9% the amount of Sy specified), mid will be chosen as the final guess result
|
|
24
24
|
|
|
25
25
|
/// for guessOffchain, this is to provide a shortcut to guessing. The offchain SDK can precalculate the exact result
|
|
26
26
|
/// before the tx is sent. When the tx reaches the contract, the guessOffchain will be checked first, and if it satisfies the
|
|
@@ -47,14 +47,21 @@ library MarketApproxPtInLib {
|
|
|
47
47
|
struct Args1 {
|
|
48
48
|
MarketState market;
|
|
49
49
|
PYIndex index;
|
|
50
|
-
uint256
|
|
50
|
+
uint256 minSyOut;
|
|
51
51
|
uint256 blockTime;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
/**
|
|
55
|
+
* @dev algorithm:
|
|
56
|
+
- Bin search the amount of PT to swap in
|
|
57
|
+
- Try swapping & get netSyOut
|
|
58
|
+
- Stop when netSyOut greater & approx minSyOut
|
|
59
|
+
- guess & approx is for netPtIn
|
|
60
|
+
*/
|
|
61
|
+
function approxSwapPtForExactSy(
|
|
55
62
|
MarketState memory _market,
|
|
56
63
|
PYIndex _index,
|
|
57
|
-
uint256
|
|
64
|
+
uint256 _minSyOut,
|
|
58
65
|
uint256 _blockTime,
|
|
59
66
|
ApproxParams memory _approx
|
|
60
67
|
)
|
|
@@ -62,17 +69,11 @@ library MarketApproxPtInLib {
|
|
|
62
69
|
pure
|
|
63
70
|
returns (
|
|
64
71
|
uint256, /*netPtIn*/
|
|
65
|
-
uint256, /*
|
|
66
|
-
uint256 /*
|
|
72
|
+
uint256, /*netSyOut*/
|
|
73
|
+
uint256 /*netSyFee*/
|
|
67
74
|
)
|
|
68
75
|
{
|
|
69
|
-
|
|
70
|
-
the algorithm is essentially to:
|
|
71
|
-
1. binary search netPtIn
|
|
72
|
-
2. if netScyOut is greater & approx minScyOut => answer found
|
|
73
|
-
*/
|
|
74
|
-
|
|
75
|
-
Args1 memory a = Args1(_market, _index, _minScyOut, _blockTime);
|
|
76
|
+
Args1 memory a = Args1(_market, _index, _minSyOut, _blockTime);
|
|
76
77
|
MarketPreCompute memory comp = a.market.getMarketPreCompute(a.index, a.blockTime);
|
|
77
78
|
ApproxParamsPtIn memory p = newApproxParamsPtIn(_approx, 0, calcMaxPtIn(comp.totalAsset));
|
|
78
79
|
|
|
@@ -83,13 +84,13 @@ library MarketApproxPtInLib {
|
|
|
83
84
|
continue;
|
|
84
85
|
}
|
|
85
86
|
|
|
86
|
-
(uint256
|
|
87
|
+
(uint256 netSyOut, uint256 netSyFee) = calcSyOut(a.market, comp, a.index, guess);
|
|
87
88
|
|
|
88
|
-
if (
|
|
89
|
+
if (netSyOut >= a.minSyOut) {
|
|
89
90
|
p.guessMax = guess;
|
|
90
|
-
bool isAnswerAccepted = Math.isAGreaterApproxB(
|
|
91
|
+
bool isAnswerAccepted = Math.isAGreaterApproxB(netSyOut, a.minSyOut, p.eps);
|
|
91
92
|
if (isAnswerAccepted) {
|
|
92
|
-
return (guess,
|
|
93
|
+
return (guess, netSyOut, netSyFee);
|
|
93
94
|
}
|
|
94
95
|
} else {
|
|
95
96
|
p.guessMin = guess;
|
|
@@ -101,14 +102,23 @@ library MarketApproxPtInLib {
|
|
|
101
102
|
struct Args2 {
|
|
102
103
|
MarketState market;
|
|
103
104
|
PYIndex index;
|
|
104
|
-
uint256
|
|
105
|
+
uint256 exactSyIn;
|
|
105
106
|
uint256 blockTime;
|
|
106
107
|
}
|
|
107
108
|
|
|
108
|
-
|
|
109
|
+
/**
|
|
110
|
+
* @dev algorithm:
|
|
111
|
+
- Bin search the amount of PT to swap in
|
|
112
|
+
- Flashswap the corresponding amount of SY out
|
|
113
|
+
- Pair those amount with exactSyIn SY to tokenize into PT & YT
|
|
114
|
+
- PT to repay the flashswap, YT transferred to user
|
|
115
|
+
- Stop when PT to repay the flashswap greater approx the amount of PT owed
|
|
116
|
+
- guess & approx is for netYtOut (also netPtIn)
|
|
117
|
+
*/
|
|
118
|
+
function approxSwapExactSyForYt(
|
|
109
119
|
MarketState memory _market,
|
|
110
120
|
PYIndex _index,
|
|
111
|
-
uint256
|
|
121
|
+
uint256 _exactSyIn,
|
|
112
122
|
uint256 _blockTime,
|
|
113
123
|
ApproxParams memory _approx
|
|
114
124
|
)
|
|
@@ -116,35 +126,34 @@ library MarketApproxPtInLib {
|
|
|
116
126
|
pure
|
|
117
127
|
returns (
|
|
118
128
|
uint256, /*netYtOut*/
|
|
119
|
-
uint256 /*
|
|
129
|
+
uint256 /*netSyFee*/
|
|
120
130
|
)
|
|
121
131
|
{
|
|
122
|
-
Args2 memory a = Args2(_market, _index,
|
|
132
|
+
Args2 memory a = Args2(_market, _index, _exactSyIn, _blockTime);
|
|
123
133
|
MarketPreCompute memory comp = a.market.getMarketPreCompute(a.index, a.blockTime);
|
|
124
134
|
|
|
125
|
-
// at minimum we will flashswap
|
|
135
|
+
// at minimum we will flashswap exactSyIn since we have enough SY to payback the PT loan
|
|
126
136
|
ApproxParamsPtIn memory p = newApproxParamsPtIn(
|
|
127
137
|
_approx,
|
|
128
|
-
a.index.
|
|
138
|
+
a.index.syToAsset(a.exactSyIn),
|
|
129
139
|
calcMaxPtIn(comp.totalAsset)
|
|
130
140
|
);
|
|
131
141
|
|
|
132
142
|
for (uint256 iter = 0; iter < p.maxIteration; ++iter) {
|
|
133
|
-
// ytOutGuess = ptInGuess
|
|
134
143
|
(bool isGoodSlope, uint256 guess) = nextGuess(p, comp, a.market.totalPt, iter);
|
|
135
144
|
if (!isGoodSlope) {
|
|
136
145
|
p.guessMax = guess;
|
|
137
146
|
continue;
|
|
138
147
|
}
|
|
139
148
|
|
|
140
|
-
(uint256
|
|
149
|
+
(uint256 netSyOut, uint256 netSyFee) = calcSyOut(a.market, comp, a.index, guess);
|
|
141
150
|
|
|
142
|
-
uint256 maxPtPayable = a.index.
|
|
151
|
+
uint256 maxPtPayable = a.index.syToAsset(netSyOut + a.exactSyIn);
|
|
143
152
|
|
|
144
153
|
if (guess <= maxPtPayable) {
|
|
145
154
|
p.guessMin = guess;
|
|
146
155
|
bool isAnswerAccepted = Math.isASmallerApproxB(guess, maxPtPayable, p.eps);
|
|
147
|
-
if (isAnswerAccepted) return (guess,
|
|
156
|
+
if (isAnswerAccepted) return (guess, netSyFee);
|
|
148
157
|
} else {
|
|
149
158
|
p.guessMax = guess;
|
|
150
159
|
}
|
|
@@ -159,6 +168,14 @@ library MarketApproxPtInLib {
|
|
|
159
168
|
uint256 blockTime;
|
|
160
169
|
}
|
|
161
170
|
|
|
171
|
+
/**
|
|
172
|
+
* @dev algorithm:
|
|
173
|
+
- Bin search the amount of PT to swap to SY
|
|
174
|
+
- Swap PT to SY
|
|
175
|
+
- Pair the remaining PT with the SY to add liquidity
|
|
176
|
+
- Stop when the ratio of PT / totalPt & SY / totalSy is approx
|
|
177
|
+
- guess & approx is for netPtSwap
|
|
178
|
+
*/
|
|
162
179
|
function approxSwapPtToAddLiquidity(
|
|
163
180
|
MarketState memory _market,
|
|
164
181
|
PYIndex _index,
|
|
@@ -170,21 +187,10 @@ library MarketApproxPtInLib {
|
|
|
170
187
|
pure
|
|
171
188
|
returns (
|
|
172
189
|
uint256, /*netPtSwap*/
|
|
173
|
-
uint256, /*
|
|
174
|
-
uint256 /*
|
|
190
|
+
uint256, /*netSyFromSwap*/
|
|
191
|
+
uint256 /*netSyFee*/
|
|
175
192
|
)
|
|
176
193
|
{
|
|
177
|
-
/*
|
|
178
|
-
The algorithm is essentially to:
|
|
179
|
-
1. Binary search netPtIn (therefore netScyOut)
|
|
180
|
-
2. Swap netPtIn for netScyOut
|
|
181
|
-
3. Use (totalPtIn - netPtIn) and netScyOut to mint LP
|
|
182
|
-
4. If (totalPtIn - netPtIn) / netScyOut ratio is close enough to the market's PT/SCY ratio
|
|
183
|
-
=> answer found
|
|
184
|
-
|
|
185
|
-
Note that market maintains PT/SCY ratio, but here PT/asset is used instead
|
|
186
|
-
*/
|
|
187
|
-
|
|
188
194
|
Args6 memory a = Args6(_market, _index, _totalPtIn, _blockTime);
|
|
189
195
|
require(a.market.totalLp != 0, "no existing lp");
|
|
190
196
|
|
|
@@ -205,33 +211,33 @@ library MarketApproxPtInLib {
|
|
|
205
211
|
continue;
|
|
206
212
|
}
|
|
207
213
|
|
|
208
|
-
(uint256
|
|
214
|
+
(uint256 netSyOut, uint256 netSyFee) = calcSyOut(a.market, comp, a.index, guess);
|
|
209
215
|
|
|
210
|
-
uint256
|
|
216
|
+
uint256 syNumerator;
|
|
211
217
|
uint256 ptNumerator;
|
|
212
218
|
{
|
|
213
219
|
uint256 newTotalPt = a.market.totalPt.Uint() + guess;
|
|
214
220
|
uint256 netPtRemaining = a.totalPtIn - guess;
|
|
215
|
-
uint256
|
|
221
|
+
uint256 newTotalSy = (a.market.totalSy.Uint() - netSyOut - netSyFee);
|
|
216
222
|
|
|
217
223
|
// it is desired that
|
|
218
|
-
//
|
|
224
|
+
// netSyOut / newTotalSy = netPtRemaining / newTotalPt
|
|
219
225
|
// which is equivalent to
|
|
220
|
-
//
|
|
226
|
+
// netSyOut * newTotalPt = netPtRemaining * newTotalSy
|
|
221
227
|
|
|
222
|
-
|
|
223
|
-
ptNumerator = netPtRemaining *
|
|
228
|
+
syNumerator = netSyOut * newTotalPt;
|
|
229
|
+
ptNumerator = netPtRemaining * newTotalSy;
|
|
224
230
|
}
|
|
225
231
|
|
|
226
|
-
if (Math.isAApproxB(
|
|
227
|
-
return (guess,
|
|
232
|
+
if (Math.isAApproxB(syNumerator, ptNumerator, p.eps)) {
|
|
233
|
+
return (guess, netSyOut, netSyFee);
|
|
228
234
|
}
|
|
229
235
|
|
|
230
|
-
if (
|
|
231
|
-
// needs more
|
|
236
|
+
if (syNumerator <= ptNumerator) {
|
|
237
|
+
// needs more SY --> swap more PT
|
|
232
238
|
p.guessMin = guess + 1;
|
|
233
239
|
} else {
|
|
234
|
-
// needs less
|
|
240
|
+
// needs less SY --> swap less PT
|
|
235
241
|
p.guessMax = guess - 1;
|
|
236
242
|
}
|
|
237
243
|
}
|
|
@@ -245,19 +251,28 @@ library MarketApproxPtInLib {
|
|
|
245
251
|
uint256 blockTime;
|
|
246
252
|
}
|
|
247
253
|
|
|
254
|
+
/**
|
|
255
|
+
* @dev algorithm:
|
|
256
|
+
- Bin search the amount of PT to swap to SY
|
|
257
|
+
- Flashswap the corresponding amount of SY out
|
|
258
|
+
- Tokenize all the SY into PT + YT
|
|
259
|
+
- PT to repay the flashswap, YT transferred to user
|
|
260
|
+
- Stop when the amount of PT owed is smaller approx the amount of PT to repay the flashswap
|
|
261
|
+
- guess & approx is for totalPtToSwap
|
|
262
|
+
*/
|
|
248
263
|
function approxSwapExactPtForYt(
|
|
249
264
|
MarketState memory _market,
|
|
250
265
|
PYIndex _index,
|
|
251
266
|
uint256 _exactPtIn,
|
|
252
267
|
uint256 _blockTime,
|
|
253
|
-
ApproxParams memory _approx
|
|
268
|
+
ApproxParams memory _approx
|
|
254
269
|
)
|
|
255
270
|
internal
|
|
256
271
|
pure
|
|
257
272
|
returns (
|
|
258
273
|
uint256, /*netYtOut*/
|
|
259
274
|
uint256, /*totalPtToSwap*/
|
|
260
|
-
uint256 /*
|
|
275
|
+
uint256 /*netSyFee*/
|
|
261
276
|
)
|
|
262
277
|
{
|
|
263
278
|
Args7 memory a = Args7(_market, _index, _exactPtIn, _blockTime);
|
|
@@ -277,15 +292,15 @@ library MarketApproxPtInLib {
|
|
|
277
292
|
continue;
|
|
278
293
|
}
|
|
279
294
|
|
|
280
|
-
(uint256
|
|
295
|
+
(uint256 netSyOut, uint256 netSyFee) = calcSyOut(a.market, comp, a.index, guess);
|
|
281
296
|
|
|
282
|
-
uint256 netAssetOut = a.index.
|
|
297
|
+
uint256 netAssetOut = a.index.syToAsset(netSyOut);
|
|
283
298
|
|
|
284
299
|
uint256 maxPtPayable = netAssetOut + a.exactPtIn;
|
|
285
300
|
if (guess <= maxPtPayable) {
|
|
286
301
|
p.guessMin = guess;
|
|
287
302
|
if (Math.isASmallerApproxB(guess, maxPtPayable, p.eps)) {
|
|
288
|
-
return (netAssetOut, guess,
|
|
303
|
+
return (netAssetOut, guess, netSyFee);
|
|
289
304
|
}
|
|
290
305
|
} else {
|
|
291
306
|
p.guessMax = guess - 1;
|
|
@@ -296,15 +311,15 @@ library MarketApproxPtInLib {
|
|
|
296
311
|
|
|
297
312
|
////////////////////////////////////////////////////////////////////////////////
|
|
298
313
|
|
|
299
|
-
function
|
|
314
|
+
function calcSyOut(
|
|
300
315
|
MarketState memory market,
|
|
301
316
|
MarketPreCompute memory comp,
|
|
302
317
|
PYIndex index,
|
|
303
318
|
uint256 netPtIn
|
|
304
|
-
) internal pure returns (uint256
|
|
305
|
-
(int256
|
|
306
|
-
|
|
307
|
-
|
|
319
|
+
) internal pure returns (uint256 netSyOut, uint256 netSyFee) {
|
|
320
|
+
(int256 _netSyOut, int256 _netSyFee) = market.calcTrade(comp, index, netPtIn.neg());
|
|
321
|
+
netSyOut = _netSyOut.Uint();
|
|
322
|
+
netSyFee = _netSyFee.Uint();
|
|
308
323
|
}
|
|
309
324
|
|
|
310
325
|
function newApproxParamsPtIn(
|
|
@@ -396,14 +411,21 @@ library MarketApproxPtOutLib {
|
|
|
396
411
|
struct Args4 {
|
|
397
412
|
MarketState market;
|
|
398
413
|
PYIndex index;
|
|
399
|
-
uint256
|
|
414
|
+
uint256 exactSyIn;
|
|
400
415
|
uint256 blockTime;
|
|
401
416
|
}
|
|
402
417
|
|
|
403
|
-
|
|
418
|
+
/**
|
|
419
|
+
* @dev algorithm:
|
|
420
|
+
- Bin search the amount of PT to swapExactOut
|
|
421
|
+
- Calculate the amount of SY needed
|
|
422
|
+
- Stop when the netSyIn is smaller approx exactSyIn
|
|
423
|
+
- guess & approx is for netSyIn
|
|
424
|
+
*/
|
|
425
|
+
function approxSwapExactSyForPt(
|
|
404
426
|
MarketState memory _market,
|
|
405
427
|
PYIndex _index,
|
|
406
|
-
uint256
|
|
428
|
+
uint256 _exactSyIn,
|
|
407
429
|
uint256 _blockTime,
|
|
408
430
|
ApproxParams memory _approx
|
|
409
431
|
)
|
|
@@ -411,16 +433,10 @@ library MarketApproxPtOutLib {
|
|
|
411
433
|
pure
|
|
412
434
|
returns (
|
|
413
435
|
uint256, /*netPtOut*/
|
|
414
|
-
uint256 /*
|
|
436
|
+
uint256 /*netSyFee*/
|
|
415
437
|
)
|
|
416
438
|
{
|
|
417
|
-
|
|
418
|
-
1. Binary search netPtOut
|
|
419
|
-
2. Calc netScyIn to swap to receive netPtOut
|
|
420
|
-
2. If netScyIn < exactScyIn && netScyIn ~ exactScyIn => answer found
|
|
421
|
-
*/
|
|
422
|
-
|
|
423
|
-
Args4 memory a = Args4(_market, _index, _exactScyIn, _blockTime);
|
|
439
|
+
Args4 memory a = Args4(_market, _index, _exactSyIn, _blockTime);
|
|
424
440
|
MarketPreCompute memory comp = a.market.getMarketPreCompute(a.index, a.blockTime);
|
|
425
441
|
ApproxParamsPtOut memory p = newApproxParamsPtOut(
|
|
426
442
|
_approx,
|
|
@@ -431,12 +447,12 @@ library MarketApproxPtOutLib {
|
|
|
431
447
|
for (uint256 iter = 0; iter < p.maxIteration; ++iter) {
|
|
432
448
|
uint256 guess = nextGuess(p, iter);
|
|
433
449
|
|
|
434
|
-
(uint256
|
|
450
|
+
(uint256 netSyIn, uint256 netSyFee) = calcSyIn(a.market, comp, a.index, guess);
|
|
435
451
|
|
|
436
|
-
if (
|
|
452
|
+
if (netSyIn <= a.exactSyIn) {
|
|
437
453
|
p.guessMin = guess;
|
|
438
|
-
bool isAnswerAccepted = Math.isASmallerApproxB(
|
|
439
|
-
if (isAnswerAccepted) return (guess,
|
|
454
|
+
bool isAnswerAccepted = Math.isASmallerApproxB(netSyIn, a.exactSyIn, p.eps);
|
|
455
|
+
if (isAnswerAccepted) return (guess, netSyFee);
|
|
440
456
|
} else {
|
|
441
457
|
p.guessMax = guess - 1;
|
|
442
458
|
}
|
|
@@ -448,14 +464,22 @@ library MarketApproxPtOutLib {
|
|
|
448
464
|
struct Args5 {
|
|
449
465
|
MarketState market;
|
|
450
466
|
PYIndex index;
|
|
451
|
-
uint256
|
|
467
|
+
uint256 minSyOut;
|
|
452
468
|
uint256 blockTime;
|
|
453
469
|
}
|
|
454
470
|
|
|
455
|
-
|
|
471
|
+
/**
|
|
472
|
+
* @dev algorithm:
|
|
473
|
+
- Bin search the amount of PT to swapExactOut
|
|
474
|
+
- Flashswap that amount of PT & pair with YT to redeem SY
|
|
475
|
+
- Use the SY to repay the flashswap debt and the remaining is transferred to user
|
|
476
|
+
- Stop when the netSyOut is greater approx the minSyOut
|
|
477
|
+
- guess & approx is for netSyOut
|
|
478
|
+
*/
|
|
479
|
+
function approxSwapYtForExactSy(
|
|
456
480
|
MarketState memory _market,
|
|
457
481
|
PYIndex _index,
|
|
458
|
-
uint256
|
|
482
|
+
uint256 _minSyOut,
|
|
459
483
|
uint256 _blockTime,
|
|
460
484
|
ApproxParams memory _approx
|
|
461
485
|
)
|
|
@@ -463,19 +487,11 @@ library MarketApproxPtOutLib {
|
|
|
463
487
|
pure
|
|
464
488
|
returns (
|
|
465
489
|
uint256, /*netYtIn*/
|
|
466
|
-
uint256, /*
|
|
467
|
-
uint256 /*
|
|
490
|
+
uint256, /*netSyOut*/
|
|
491
|
+
uint256 /*netSyFee*/
|
|
468
492
|
)
|
|
469
493
|
{
|
|
470
|
-
|
|
471
|
-
1. Binary search netPtOut (therefore netScyIn)
|
|
472
|
-
2. Flashswap netPtOut (now we owe netScyIn)
|
|
473
|
-
3. Pair netPtOut with netYtIn Yt => get SCY (netPtOut == netYtIn)
|
|
474
|
-
4. Pay back SCY & the exceed amount of SCY (netScyOut) is transferred out to user
|
|
475
|
-
5. If netScyOut > minScyOut && netScyOut ~ minScyOut => answer found
|
|
476
|
-
*/
|
|
477
|
-
|
|
478
|
-
Args5 memory a = Args5(_market, _index, _minScyOut, _blockTime);
|
|
494
|
+
Args5 memory a = Args5(_market, _index, _minSyOut, _blockTime);
|
|
479
495
|
MarketPreCompute memory comp = a.market.getMarketPreCompute(a.index, a.blockTime);
|
|
480
496
|
ApproxParamsPtOut memory p = newApproxParamsPtOut(
|
|
481
497
|
_approx,
|
|
@@ -486,15 +502,15 @@ library MarketApproxPtOutLib {
|
|
|
486
502
|
for (uint256 iter = 0; iter < p.maxIteration; ++iter) {
|
|
487
503
|
uint256 guess = nextGuess(p, iter);
|
|
488
504
|
|
|
489
|
-
(uint256
|
|
505
|
+
(uint256 netSyOwed, uint256 netSyFee) = calcSyIn(a.market, comp, a.index, guess);
|
|
490
506
|
|
|
491
|
-
uint256 netAssetToRepay = a.index.
|
|
492
|
-
uint256
|
|
507
|
+
uint256 netAssetToRepay = a.index.syToAssetUp(netSyOwed);
|
|
508
|
+
uint256 netSyOut = a.index.assetToSy(guess - netAssetToRepay);
|
|
493
509
|
|
|
494
|
-
if (
|
|
510
|
+
if (netSyOut >= a.minSyOut) {
|
|
495
511
|
p.guessMax = guess;
|
|
496
|
-
if (Math.isAGreaterApproxB(
|
|
497
|
-
return (guess,
|
|
512
|
+
if (Math.isAGreaterApproxB(netSyOut, a.minSyOut, p.eps)) {
|
|
513
|
+
return (guess, netSyOut, netSyFee);
|
|
498
514
|
}
|
|
499
515
|
} else {
|
|
500
516
|
p.guessMin = guess + 1;
|
|
@@ -506,14 +522,22 @@ library MarketApproxPtOutLib {
|
|
|
506
522
|
struct Args6 {
|
|
507
523
|
MarketState market;
|
|
508
524
|
PYIndex index;
|
|
509
|
-
uint256
|
|
525
|
+
uint256 totalSyIn;
|
|
510
526
|
uint256 blockTime;
|
|
511
527
|
}
|
|
512
528
|
|
|
513
|
-
|
|
529
|
+
/**
|
|
530
|
+
* @dev algorithm:
|
|
531
|
+
- Bin search the amount of PT to swapExactOut
|
|
532
|
+
- Swap that amount of PT out
|
|
533
|
+
- Pair the remaining PT with the SY to add liquidity
|
|
534
|
+
- Stop when the ratio of PT / totalPt & SY / totalSy is approx
|
|
535
|
+
- guess & approx is for netPtFromSwap
|
|
536
|
+
*/
|
|
537
|
+
function approxSwapSyToAddLiquidity(
|
|
514
538
|
MarketState memory _market,
|
|
515
539
|
PYIndex _index,
|
|
516
|
-
uint256
|
|
540
|
+
uint256 _totalSyIn,
|
|
517
541
|
uint256 _blockTime,
|
|
518
542
|
ApproxParams memory _approx
|
|
519
543
|
)
|
|
@@ -521,21 +545,11 @@ library MarketApproxPtOutLib {
|
|
|
521
545
|
pure
|
|
522
546
|
returns (
|
|
523
547
|
uint256, /*netPtFromSwap*/
|
|
524
|
-
uint256, /*
|
|
525
|
-
uint256 /*
|
|
548
|
+
uint256, /*netSySwap*/
|
|
549
|
+
uint256 /*netSyFee*/
|
|
526
550
|
)
|
|
527
551
|
{
|
|
528
|
-
|
|
529
|
-
1. Binary search netPtOut (therefore netScyIn)
|
|
530
|
-
2. Swap netScyIn for netPtOut
|
|
531
|
-
3. Use netPtOut and (totalScyIn - netScyIn) to mint LP
|
|
532
|
-
4. If netPtOut / (totalScyIn - netScyIn) ratio is close enough to the market's PT/SCY ratio
|
|
533
|
-
=> answer found
|
|
534
|
-
|
|
535
|
-
Note that market maintains PT/SCY ratio, but here PT/asset is used instead
|
|
536
|
-
*/
|
|
537
|
-
|
|
538
|
-
Args6 memory a = Args6(_market, _index, _totalScyIn, _blockTime);
|
|
552
|
+
Args6 memory a = Args6(_market, _index, _totalSyIn, _blockTime);
|
|
539
553
|
require(a.market.totalLp != 0, "no existing lp");
|
|
540
554
|
|
|
541
555
|
MarketPreCompute memory comp = a.market.getMarketPreCompute(a.index, a.blockTime);
|
|
@@ -548,35 +562,35 @@ library MarketApproxPtOutLib {
|
|
|
548
562
|
for (uint256 iter = 0; iter < p.maxIteration; ++iter) {
|
|
549
563
|
uint256 guess = nextGuess(p, iter);
|
|
550
564
|
|
|
551
|
-
(uint256
|
|
565
|
+
(uint256 netSyIn, uint256 netSyFee) = calcSyIn(a.market, comp, a.index, guess);
|
|
552
566
|
|
|
553
|
-
if (
|
|
567
|
+
if (netSyIn > a.totalSyIn) {
|
|
554
568
|
p.guessMax = guess - 1;
|
|
555
569
|
continue;
|
|
556
570
|
}
|
|
557
571
|
|
|
558
|
-
uint256
|
|
572
|
+
uint256 syNumerator;
|
|
559
573
|
uint256 ptNumerator;
|
|
560
574
|
|
|
561
575
|
{
|
|
562
|
-
uint256
|
|
576
|
+
uint256 netSyRemaining = a.totalSyIn - netSyIn;
|
|
563
577
|
uint256 newTotalPt = a.market.totalPt.Uint() - guess;
|
|
564
|
-
uint256
|
|
578
|
+
uint256 netTotalSy = comp.totalAsset.Uint() + netSyIn - netSyFee;
|
|
565
579
|
|
|
566
580
|
// it is desired that
|
|
567
|
-
//
|
|
581
|
+
// netPtFromSwap / newTotalPt = netSyRemaining / netTotalSy
|
|
568
582
|
// which is equivalent to
|
|
569
|
-
//
|
|
583
|
+
// netPtFromSwap * netTotalSy = netSyRemaining * newTotalPt
|
|
570
584
|
|
|
571
|
-
ptNumerator = guess *
|
|
572
|
-
|
|
585
|
+
ptNumerator = guess * netTotalSy;
|
|
586
|
+
syNumerator = netSyRemaining * newTotalPt;
|
|
573
587
|
}
|
|
574
588
|
|
|
575
|
-
if (Math.isAApproxB(ptNumerator,
|
|
576
|
-
return (guess,
|
|
589
|
+
if (Math.isAApproxB(ptNumerator, syNumerator, p.eps)) {
|
|
590
|
+
return (guess, netSyIn, netSyFee);
|
|
577
591
|
}
|
|
578
592
|
|
|
579
|
-
if (ptNumerator <=
|
|
593
|
+
if (ptNumerator <= syNumerator) {
|
|
580
594
|
// needs more PT
|
|
581
595
|
p.guessMin = guess + 1;
|
|
582
596
|
} else {
|
|
@@ -592,9 +606,18 @@ library MarketApproxPtOutLib {
|
|
|
592
606
|
PYIndex index;
|
|
593
607
|
uint256 exactYtIn;
|
|
594
608
|
uint256 blockTime;
|
|
595
|
-
uint256
|
|
609
|
+
uint256 maxSyPayable;
|
|
596
610
|
}
|
|
597
611
|
|
|
612
|
+
/**
|
|
613
|
+
* @dev algorithm:
|
|
614
|
+
- Bin search the amount of PT to swapExactOut
|
|
615
|
+
- Flashswap that amount of PT out
|
|
616
|
+
- Pair all the PT with the YT to redeem SY
|
|
617
|
+
- Use the SY to repay the flashswap debt
|
|
618
|
+
- Stop when the amount of SY owed is smaller approx the amount of SY to repay the flashswap
|
|
619
|
+
- guess & approx is for netPtFromSwap
|
|
620
|
+
*/
|
|
598
621
|
function approxSwapExactYtForPt(
|
|
599
622
|
MarketState memory _market,
|
|
600
623
|
PYIndex _index,
|
|
@@ -607,7 +630,7 @@ library MarketApproxPtOutLib {
|
|
|
607
630
|
returns (
|
|
608
631
|
uint256, /*netPtOut*/
|
|
609
632
|
uint256, /*totalPtSwapped*/
|
|
610
|
-
uint256 /*
|
|
633
|
+
uint256 /*netSyFee*/
|
|
611
634
|
)
|
|
612
635
|
{
|
|
613
636
|
Args8 memory a = Args8(
|
|
@@ -615,7 +638,7 @@ library MarketApproxPtOutLib {
|
|
|
615
638
|
_index,
|
|
616
639
|
_exactYtIn,
|
|
617
640
|
_blockTime,
|
|
618
|
-
_index.
|
|
641
|
+
_index.assetToSy(_exactYtIn)
|
|
619
642
|
);
|
|
620
643
|
MarketPreCompute memory comp = a.market.getMarketPreCompute(a.index, a.blockTime);
|
|
621
644
|
ApproxParamsPtOut memory p = newApproxParamsPtOut(
|
|
@@ -627,12 +650,12 @@ library MarketApproxPtOutLib {
|
|
|
627
650
|
for (uint256 iter = 0; iter < p.maxIteration; ++iter) {
|
|
628
651
|
uint256 guess = nextGuess(p, iter);
|
|
629
652
|
|
|
630
|
-
(uint256
|
|
653
|
+
(uint256 netSyOwed, uint256 netSyFee) = calcSyIn(a.market, comp, a.index, guess);
|
|
631
654
|
|
|
632
|
-
if (
|
|
655
|
+
if (netSyOwed <= a.maxSyPayable) {
|
|
633
656
|
p.guessMin = guess;
|
|
634
|
-
if (Math.isASmallerApproxB(
|
|
635
|
-
return (guess - a.exactYtIn, guess,
|
|
657
|
+
if (Math.isASmallerApproxB(netSyOwed, a.maxSyPayable, p.eps)) {
|
|
658
|
+
return (guess - a.exactYtIn, guess, netSyFee);
|
|
636
659
|
}
|
|
637
660
|
} else {
|
|
638
661
|
p.guessMax = guess - 1;
|
|
@@ -643,16 +666,16 @@ library MarketApproxPtOutLib {
|
|
|
643
666
|
|
|
644
667
|
////////////////////////////////////////////////////////////////////////////////
|
|
645
668
|
|
|
646
|
-
function
|
|
669
|
+
function calcSyIn(
|
|
647
670
|
MarketState memory market,
|
|
648
671
|
MarketPreCompute memory comp,
|
|
649
672
|
PYIndex index,
|
|
650
673
|
uint256 netPtOut
|
|
651
|
-
) internal pure returns (uint256
|
|
652
|
-
(int256
|
|
674
|
+
) internal pure returns (uint256 netSyIn, uint256 netSyFee) {
|
|
675
|
+
(int256 _netSyIn, int256 _netSyFee) = market.calcTrade(comp, index, netPtOut.Int());
|
|
653
676
|
|
|
654
|
-
|
|
655
|
-
|
|
677
|
+
netSyIn = _netSyIn.abs();
|
|
678
|
+
netSyFee = _netSyFee.Uint();
|
|
656
679
|
}
|
|
657
680
|
|
|
658
681
|
function newApproxParamsPtOut(
|
|
@@ -30,14 +30,14 @@ import "./AggregationRouterHelper.sol";
|
|
|
30
30
|
struct TokenInput {
|
|
31
31
|
address tokenIn;
|
|
32
32
|
uint256 netTokenIn;
|
|
33
|
-
address
|
|
33
|
+
address tokenMintSy;
|
|
34
34
|
bytes kybercall;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
struct TokenOutput {
|
|
38
38
|
address tokenOut;
|
|
39
39
|
uint256 minTokenOut;
|
|
40
|
-
address
|
|
40
|
+
address tokenRedeemSy;
|
|
41
41
|
bytes kybercall;
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"deployer": "0x1FcCC097db89A86Bfc474A1028F93958295b1Fb7",
|
|
3
|
+
"network": 43113,
|
|
4
|
+
"splitter": "0x93217b443F75aDCc96cF888d934E42421896b261",
|
|
5
|
+
"lzEndpoint": "0x93f54D755A063cE7bB9e6Ac47Eccc8e33411d706",
|
|
6
|
+
"treasury": "0xa123528ad71ef5c5bc36D4A78083b2452Ec1F233",
|
|
7
|
+
"PENDLE": "0xf1857a9F1df68159F710aA9198B6e2A373d28151",
|
|
8
|
+
"yieldContractFactory": "0xAe8bc036451af7c8F96Fd90642e163392d21D33b",
|
|
9
|
+
"marketFactory": "0x540Ec7BEd6aCE1726234DC0B8DBE7D44f6b37843",
|
|
10
|
+
"router": "0x7097112fbEc6BB001352fC98A3470d1951464F5B",
|
|
11
|
+
"routerStatic": "0xf3E9DeDdd01aa9bD0E18087c4729e82Bc66f366d",
|
|
12
|
+
"vePendle": "0x138C04c3602e58E1176168a58BE2c10eFd8c1b7e",
|
|
13
|
+
"senderEndpoint": "0x1B7Ec861Ad05843F0Fb34716B4fc94409655e1A3",
|
|
14
|
+
"votingController": "0xA2a12e2e0F31C4e92aEf08803fBA4e0DcD2bD726",
|
|
15
|
+
"gaugeController": "0xecBe97316Ee3F77E511D815cA432Ca2914fBa347"
|
|
16
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"symbol": "SY-qiUSDC",
|
|
3
|
+
"SY": "0xf1ce104816e7578EaBcc9c148C58B1b287ccd387",
|
|
4
|
+
"expiry": 1675382400,
|
|
5
|
+
"PT": "0xAaBbDd4E38E4669d37810B4B1A4747f94beeF73A",
|
|
6
|
+
"YT": "0x37613Fb19988c395E6a2e7C062fDa7823ce4bE1a",
|
|
7
|
+
"market": "0xEf74AfeB451F3662Bc8600d4468FB7eF13b36a97"
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"symbol": "SY-qiWETH",
|
|
3
|
+
"SY": "0x4C63A4B1F031D2aF9dcd4E070b30566D563c87fc",
|
|
4
|
+
"expiry": 1669852800,
|
|
5
|
+
"PT": "0x208B0a9F18346A532a60cdAf364b18775bA9c087",
|
|
6
|
+
"YT": "0x1814Baf30a36247f7005a07914cd269bEe0A4a85",
|
|
7
|
+
"market": "0x4d26b9742722e1D0F81dF3b2ee053995f83d4831"
|
|
8
|
+
}
|