@pendle/core-v2 0.17.7-testnet → 0.18.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/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/VotingController/VotingControllerStorageUpg.sol/VotingControllerStorageUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol/VotingEscrowTokenBase.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/libraries/VeBalanceLib.sol/VeBalanceLib.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/libraries/VeBalanceLib.sol/VeBalanceLib.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/CheckpointHelper.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/CheckpointHelper.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/Checkpoints.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/Checkpoints.json +2 -2
- package/build/artifacts/contracts/core/BulkSeller/BulkSeller.sol/BulkSeller.dbg.json +1 -1
- package/build/artifacts/contracts/core/BulkSeller/BulkSeller.sol/BulkSeller.json +2 -2
- package/build/artifacts/contracts/core/BulkSeller/BulkSellerFactory.sol/BulkSellerFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/BulkSeller/BulkSellerFactory.sol/BulkSellerFactory.json +2 -2
- package/build/artifacts/contracts/core/BulkSeller/BulkSellerMathCore.sol/BulkSellerMathCore.dbg.json +1 -1
- package/build/artifacts/contracts/core/BulkSeller/BulkSellerMathCore.sol/BulkSellerMathCore.json +2 -2
- package/build/artifacts/contracts/core/Market/MarketMathCore.sol/MarketMathCore.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/MarketMathCore.sol/MarketMathCore.json +2 -2
- package/build/artifacts/contracts/core/Market/OracleLib.sol/OracleLib.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/OracleLib.sol/OracleLib.json +2 -2
- package/build/artifacts/contracts/core/Market/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/StandardizedYield/SYBase.sol/SYBase.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/SYBase.sol/SYBase.json +0 -141
- package/build/artifacts/contracts/core/StandardizedYield/SYBaseWithRewards.sol/SYBaseWithRewards.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/SYBaseWithRewards.sol/SYBaseWithRewards.json +0 -141
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Ape/sAPE.sol/sAPE.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Ape/sAPE.sol/sAPE.json +934 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.json +2 -2
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol/PendleQiTokenSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol/PendleQiTokenSY.json +2 -143
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol/PendleCurveFraxUsdcSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol/PendleCurveFraxUsdcSY.json +2 -143
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol/PendleCurveUsdd3CrvSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol/PendleCurveUsdd3CrvSY.json +2 -143
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/PendleConvexLPSY.sol/PendleConvexLPSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/PendleConvexLPSY.sol/PendleConvexLPSY.json +0 -141
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleLooksStakingSY.sol/PendleLooksStakingSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleLooksStakingSY.sol/PendleLooksStakingSY.json +2 -143
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol/PendleWstEthSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol/PendleWstEthSY.json +2 -143
- package/build/artifacts/contracts/core/YieldContracts/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/libraries/Errors.sol/Errors.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/Errors.sol/Errors.json +13 -2
- package/build/artifacts/contracts/interfaces/IApeStaking.sol/IApeStaking.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/IApeStaking.sol/IApeStaking.json +149 -0
- package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapPTYT.sol/IPActionSwapPTYT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPBulkSeller.sol/IPBulkSeller.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPFeeDistributor.sol/IPFeeDistributor.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPFeeDistributorFactory.sol/IPFeeDistributorFactory.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.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/offchain-helpers/BulkSellerOffchain.sol/BulkSellerOffchain.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/BulkSellerOffchain.sol/BulkSellerOffchain.json +2 -2
- package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.json +42 -2
- package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.json +73 -100
- package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.json +2 -2
- package/build/artifacts/contracts/router/ActionCallback.sol/ActionCallback.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionCallback.sol/ActionCallback.json +2 -2
- package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.json +2 -2
- package/build/artifacts/contracts/router/ActionMisc.sol/ActionMisc.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionMisc.sol/ActionMisc.json +2 -2
- package/build/artifacts/contracts/router/ActionSwapPT.sol/ActionSwapPT.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionSwapPT.sol/ActionSwapPT.json +2 -2
- package/build/artifacts/contracts/router/ActionSwapPTYT.sol/ActionSwapPTYT.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionSwapPTYT.sol/ActionSwapPTYT.json +2 -2
- package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.json +2 -2
- package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.dbg.json +1 -1
- package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.json +2 -2
- package/build/artifacts/contracts/router/base/ActionBaseMintRedeem.sol/ActionBaseMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtInLib.dbg.json +1 -1
- package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtInLib.json +2 -2
- package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtOutLib.dbg.json +1 -1
- package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtOutLib.json +2 -2
- package/build/artifacts/contracts/router/kyberswap/AggregationRouterHelper.sol/AggregationRouterHelper.dbg.json +1 -1
- package/build/artifacts/contracts/router/kyberswap/AggregationRouterHelper.sol/AggregationRouterHelper.json +2 -2
- package/build/artifacts/contracts/router/kyberswap/IMultihopRouterEthereum.sol/IMultihopRouterEthereum.dbg.json +4 -0
- package/build/artifacts/contracts/router/kyberswap/{IMultihopRouter.sol/IMultihopRouter.json → IMultihopRouterEthereum.sol/IMultihopRouterEthereum.json} +3 -3
- package/build/artifacts/contracts/router/kyberswap/KyberSwapHelper.sol/KyberSwapHelper.dbg.json +1 -1
- package/contracts/core/BulkSeller/BulkSeller.sol +1 -1
- package/contracts/core/StandardizedYield/implementations/Ape/{PendleApeStakingSY.sol → sAPE.sol} +43 -30
- package/contracts/interfaces/IApeStaking.sol +3 -0
- package/contracts/offchain-helpers/MarketMathStatic.sol +30 -55
- package/contracts/offchain-helpers/RouterStatic.sol +30 -52
- package/contracts/router/kyberswap/AggregationRouterHelper.sol +37 -23
- package/contracts/router/kyberswap/{IMultihopRouter.sol → IMultihopRouterEthereum.sol} +11 -9
- package/deployments/1-markets/APE-JUNE-29.json +8 -0
- package/deployments/80001-core.json +28 -0
- package/deployments/80001-markets/USDC-FEB-4TH.json +10 -0
- package/deployments/80001-markets/WETH-FEB-4TH.json +11 -0
- package/deployments/80001-testenv.json +22 -0
- package/package.json +1 -1
- package/typechain-types/BribeDistributor.ts +363 -0
- package/typechain-types/DistributorBase.ts +363 -0
- package/typechain-types/FeeDistributor.ts +416 -0
- package/typechain-types/IApeStaking.ts +31 -0
- package/typechain-types/IMultihopRouterEthereum.ts +209 -0
- package/typechain-types/MarketMathStatic.ts +49 -0
- package/typechain-types/PendleApeStakingSY.ts +88 -204
- package/typechain-types/PendleConvexLPSY.ts +0 -204
- package/typechain-types/PendleCurveFraxUsdcSY.ts +0 -204
- package/typechain-types/PendleCurveUsdd3CrvSY.ts +0 -204
- package/typechain-types/PendleLooksStakingSY.ts +0 -204
- package/typechain-types/PendleQiTokenSY.ts +0 -204
- package/typechain-types/PendleWstEthSY.ts +0 -204
- package/typechain-types/RouterStatic.ts +0 -49
- package/typechain-types/SAPE.ts +1191 -0
- package/typechain-types/SYBase.ts +0 -204
- package/typechain-types/SYBaseWithRewards.ts +0 -204
- package/typechain-types/factories/ActionAddRemoveLiq__factory.ts +1 -1
- package/typechain-types/factories/ActionCallback__factory.ts +1 -1
- package/typechain-types/factories/ActionMintRedeem__factory.ts +1 -1
- package/typechain-types/factories/ActionMisc__factory.ts +1 -1
- package/typechain-types/factories/ActionSwapPTYT__factory.ts +1 -1
- package/typechain-types/factories/ActionSwapPT__factory.ts +1 -1
- package/typechain-types/factories/ActionSwapYT__factory.ts +1 -1
- package/typechain-types/factories/AggregationRouterHelper__factory.ts +1 -1
- package/typechain-types/factories/BribeDistributor__factory.ts +303 -0
- 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/DistributorBase__factory.ts +249 -0
- package/typechain-types/factories/Errors__factory.ts +12 -1
- package/typechain-types/factories/FeeDistributor__factory.ts +339 -0
- package/typechain-types/factories/IApeStaking__factory.ts +34 -0
- package/typechain-types/factories/IMultihopRouterEthereum__factory.ts +155 -0
- package/typechain-types/factories/MarketMathStatic__factory.ts +41 -1
- package/typechain-types/factories/OracleLib__factory.ts +1 -1
- package/typechain-types/factories/PendleApeStakingSY__factory.ts +57 -141
- package/typechain-types/factories/PendleConvexLPSY__factory.ts +0 -141
- package/typechain-types/factories/PendleCurveFraxUsdcSY__factory.ts +1 -142
- package/typechain-types/factories/PendleCurveUsdd3CrvSY__factory.ts +1 -142
- package/typechain-types/factories/PendleFeeDistributorFactory__factory.ts +1 -1
- package/typechain-types/factories/PendleFeeDistributor__factory.ts +1 -1
- package/typechain-types/factories/PendleGaugeControllerMainchainUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleGaugeControllerSidechainUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleLooksStakingSY__factory.ts +1 -142
- package/typechain-types/factories/PendleMarketFactory__factory.ts +1 -1
- package/typechain-types/factories/PendleMarket__factory.ts +1 -1
- package/typechain-types/factories/PendleMsgReceiveEndpointUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleMsgSendEndpointUpg__factory.ts +1 -1
- package/typechain-types/factories/PendlePrincipalToken__factory.ts +1 -1
- package/typechain-types/factories/PendleQiTokenHelper__factory.ts +1 -1
- package/typechain-types/factories/PendleQiTokenSY__factory.ts +1 -142
- package/typechain-types/factories/PendleRouter__factory.ts +1 -1
- package/typechain-types/factories/PendleVotingControllerUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleWstEthSY__factory.ts +1 -142
- package/typechain-types/factories/PendleYieldContractFactory__factory.ts +1 -1
- package/typechain-types/factories/PendleYieldToken__factory.ts +1 -1
- package/typechain-types/factories/RouterStatic__factory.ts +18 -41
- package/typechain-types/factories/SAPE__factory.ts +1001 -0
- package/typechain-types/factories/SYBaseWithRewards__factory.ts +0 -141
- package/typechain-types/factories/SYBase__factory.ts +0 -141
- package/typechain-types/factories/VotingEscrowPendleMainchain__factory.ts +1 -1
- package/typechain-types/factories/VotingEscrowPendleSidechain__factory.ts +1 -1
- package/typechain-types/hardhat.d.ts +72 -0
- package/typechain-types/index.ts +12 -0
- package/build/artifacts/contracts/router/kyberswap/IMultihopRouter.sol/IMultihopRouter.dbg.json +0 -4
|
@@ -14,6 +14,17 @@ library MarketMathStatic {
|
|
|
14
14
|
using PYIndexLib for PYIndex;
|
|
15
15
|
using PYIndexLib for IPYieldToken;
|
|
16
16
|
|
|
17
|
+
function getDefaultApproxParams() public pure returns (ApproxParams memory) {
|
|
18
|
+
return
|
|
19
|
+
ApproxParams({
|
|
20
|
+
guessMin: 0,
|
|
21
|
+
guessMax: type(uint256).max,
|
|
22
|
+
guessOffchain: 0,
|
|
23
|
+
maxIteration: 256,
|
|
24
|
+
eps: 1e14
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
17
28
|
function addLiquidityDualSyAndPtStatic(
|
|
18
29
|
address market,
|
|
19
30
|
uint256 netSyDesired,
|
|
@@ -36,11 +47,7 @@ library MarketMathStatic {
|
|
|
36
47
|
}
|
|
37
48
|
|
|
38
49
|
/// @dev netPtToSwap is the parameter to approx
|
|
39
|
-
function addLiquiditySinglePtStatic(
|
|
40
|
-
address market,
|
|
41
|
-
uint256 netPtIn,
|
|
42
|
-
ApproxParams memory approxParams
|
|
43
|
-
)
|
|
50
|
+
function addLiquiditySinglePtStatic(address market, uint256 netPtIn)
|
|
44
51
|
external
|
|
45
52
|
returns (
|
|
46
53
|
uint256 netLpOut,
|
|
@@ -56,7 +63,7 @@ library MarketMathStatic {
|
|
|
56
63
|
pyIndex(market),
|
|
57
64
|
netPtIn,
|
|
58
65
|
block.timestamp,
|
|
59
|
-
|
|
66
|
+
getDefaultApproxParams()
|
|
60
67
|
);
|
|
61
68
|
|
|
62
69
|
state = IPMarket(market).readState(address(this)); // re-read
|
|
@@ -78,11 +85,7 @@ library MarketMathStatic {
|
|
|
78
85
|
}
|
|
79
86
|
|
|
80
87
|
/// @dev netPtFromSwap is the parameter to approx
|
|
81
|
-
function addLiquiditySingleSyStatic(
|
|
82
|
-
address market,
|
|
83
|
-
uint256 netSyIn,
|
|
84
|
-
ApproxParams memory approxParams
|
|
85
|
-
)
|
|
88
|
+
function addLiquiditySingleSyStatic(address market, uint256 netSyIn)
|
|
86
89
|
public
|
|
87
90
|
returns (
|
|
88
91
|
uint256 netLpOut,
|
|
@@ -98,7 +101,7 @@ library MarketMathStatic {
|
|
|
98
101
|
pyIndex(market),
|
|
99
102
|
netSyIn,
|
|
100
103
|
block.timestamp,
|
|
101
|
-
|
|
104
|
+
getDefaultApproxParams()
|
|
102
105
|
);
|
|
103
106
|
|
|
104
107
|
state = IPMarket(market).readState(address(this)); // re-read
|
|
@@ -125,11 +128,7 @@ library MarketMathStatic {
|
|
|
125
128
|
}
|
|
126
129
|
|
|
127
130
|
/// @dev netPtFromSwap is the parameter to approx
|
|
128
|
-
function removeLiquiditySinglePtStatic(
|
|
129
|
-
address market,
|
|
130
|
-
uint256 netLpToRemove,
|
|
131
|
-
ApproxParams memory approxParams
|
|
132
|
-
)
|
|
131
|
+
function removeLiquiditySinglePtStatic(address market, uint256 netLpToRemove)
|
|
133
132
|
external
|
|
134
133
|
returns (
|
|
135
134
|
uint256 netPtOut,
|
|
@@ -146,7 +145,7 @@ library MarketMathStatic {
|
|
|
146
145
|
pyIndex(market),
|
|
147
146
|
syFromBurn,
|
|
148
147
|
block.timestamp,
|
|
149
|
-
|
|
148
|
+
getDefaultApproxParams()
|
|
150
149
|
);
|
|
151
150
|
|
|
152
151
|
netPtOut = ptFromBurn + netPtFromSwap;
|
|
@@ -225,11 +224,7 @@ library MarketMathStatic {
|
|
|
225
224
|
}
|
|
226
225
|
|
|
227
226
|
/// @dev netPtOut is the parameter to approx
|
|
228
|
-
function swapExactSyForPtStatic(
|
|
229
|
-
address market,
|
|
230
|
-
uint256 exactSyIn,
|
|
231
|
-
ApproxParams memory approxParams
|
|
232
|
-
)
|
|
227
|
+
function swapExactSyForPtStatic(address market, uint256 exactSyIn)
|
|
233
228
|
public
|
|
234
229
|
returns (
|
|
235
230
|
uint256 netPtOut,
|
|
@@ -243,7 +238,7 @@ library MarketMathStatic {
|
|
|
243
238
|
pyIndex(market),
|
|
244
239
|
exactSyIn,
|
|
245
240
|
block.timestamp,
|
|
246
|
-
|
|
241
|
+
getDefaultApproxParams()
|
|
247
242
|
);
|
|
248
243
|
priceImpact = calcPriceImpactPt(market, netPtOut.Int());
|
|
249
244
|
|
|
@@ -253,11 +248,7 @@ library MarketMathStatic {
|
|
|
253
248
|
}
|
|
254
249
|
|
|
255
250
|
/// @dev netPtIn is the parameter to approx
|
|
256
|
-
function swapPtForExactSyStatic(
|
|
257
|
-
address market,
|
|
258
|
-
uint256 exactSyOut,
|
|
259
|
-
ApproxParams memory approxParams
|
|
260
|
-
)
|
|
251
|
+
function swapPtForExactSyStatic(address market, uint256 exactSyOut)
|
|
261
252
|
public
|
|
262
253
|
returns (
|
|
263
254
|
uint256 netPtIn,
|
|
@@ -272,7 +263,7 @@ library MarketMathStatic {
|
|
|
272
263
|
pyIndex(market),
|
|
273
264
|
exactSyOut,
|
|
274
265
|
block.timestamp,
|
|
275
|
-
|
|
266
|
+
getDefaultApproxParams()
|
|
276
267
|
);
|
|
277
268
|
priceImpact = calcPriceImpactPt(market, netPtIn.neg());
|
|
278
269
|
|
|
@@ -309,11 +300,7 @@ library MarketMathStatic {
|
|
|
309
300
|
}
|
|
310
301
|
|
|
311
302
|
/// @dev netYtOut is the parameter to approx
|
|
312
|
-
function swapExactSyForYtStatic(
|
|
313
|
-
address market,
|
|
314
|
-
uint256 exactSyIn,
|
|
315
|
-
ApproxParams memory approxParams
|
|
316
|
-
)
|
|
303
|
+
function swapExactSyForYtStatic(address market, uint256 exactSyIn)
|
|
317
304
|
public
|
|
318
305
|
returns (
|
|
319
306
|
uint256 netYtOut,
|
|
@@ -329,13 +316,13 @@ library MarketMathStatic {
|
|
|
329
316
|
index,
|
|
330
317
|
exactSyIn,
|
|
331
318
|
block.timestamp,
|
|
332
|
-
|
|
319
|
+
getDefaultApproxParams()
|
|
333
320
|
);
|
|
334
321
|
|
|
335
322
|
priceImpact = calcPriceImpactYt(market, netYtOut.neg());
|
|
336
323
|
|
|
337
324
|
// Execute swap to calculate exchangeRateAfter
|
|
338
|
-
state.
|
|
325
|
+
state.swapExactPtForSy(index, netYtOut, block.timestamp);
|
|
339
326
|
exchangeRateAfter = _getTradeExchangeRateExcludeFee(market, state);
|
|
340
327
|
}
|
|
341
328
|
|
|
@@ -365,11 +352,7 @@ library MarketMathStatic {
|
|
|
365
352
|
}
|
|
366
353
|
|
|
367
354
|
/// @dev netYtIn is the parameter to approx
|
|
368
|
-
function swapYtForExactSyStatic(
|
|
369
|
-
address market,
|
|
370
|
-
uint256 exactSyOut,
|
|
371
|
-
ApproxParams memory approxParams
|
|
372
|
-
)
|
|
355
|
+
function swapYtForExactSyStatic(address market, uint256 exactSyOut)
|
|
373
356
|
external
|
|
374
357
|
returns (
|
|
375
358
|
uint256 netYtIn,
|
|
@@ -386,7 +369,7 @@ library MarketMathStatic {
|
|
|
386
369
|
index,
|
|
387
370
|
exactSyOut,
|
|
388
371
|
block.timestamp,
|
|
389
|
-
|
|
372
|
+
getDefaultApproxParams()
|
|
390
373
|
);
|
|
391
374
|
priceImpact = calcPriceImpactYt(market, netYtIn.Int());
|
|
392
375
|
|
|
@@ -396,11 +379,7 @@ library MarketMathStatic {
|
|
|
396
379
|
}
|
|
397
380
|
|
|
398
381
|
// totalPtToSwap is the param to approx
|
|
399
|
-
function swapExactPtForYt(
|
|
400
|
-
address market,
|
|
401
|
-
uint256 exactPtIn,
|
|
402
|
-
ApproxParams memory approxParams
|
|
403
|
-
)
|
|
382
|
+
function swapExactPtForYt(address market, uint256 exactPtIn)
|
|
404
383
|
external
|
|
405
384
|
returns (
|
|
406
385
|
uint256 netYtOut,
|
|
@@ -417,7 +396,7 @@ library MarketMathStatic {
|
|
|
417
396
|
index,
|
|
418
397
|
exactPtIn,
|
|
419
398
|
block.timestamp,
|
|
420
|
-
|
|
399
|
+
getDefaultApproxParams()
|
|
421
400
|
);
|
|
422
401
|
priceImpact = calcPriceImpactPY(market, totalPtToSwap.neg());
|
|
423
402
|
|
|
@@ -427,11 +406,7 @@ library MarketMathStatic {
|
|
|
427
406
|
}
|
|
428
407
|
|
|
429
408
|
// totalPtSwapped is the param to approx
|
|
430
|
-
function swapExactYtForPt(
|
|
431
|
-
address market,
|
|
432
|
-
uint256 exactYtIn,
|
|
433
|
-
ApproxParams memory approxParams
|
|
434
|
-
)
|
|
409
|
+
function swapExactYtForPt(address market, uint256 exactYtIn)
|
|
435
410
|
external
|
|
436
411
|
returns (
|
|
437
412
|
uint256 netPtOut,
|
|
@@ -448,7 +423,7 @@ library MarketMathStatic {
|
|
|
448
423
|
index,
|
|
449
424
|
exactYtIn,
|
|
450
425
|
block.timestamp,
|
|
451
|
-
|
|
426
|
+
getDefaultApproxParams()
|
|
452
427
|
);
|
|
453
428
|
|
|
454
429
|
priceImpact = calcPriceImpactPY(market, totalPtSwapped.Int());
|
|
@@ -14,9 +14,10 @@ import "../LiquidityMining/libraries/VeBalanceLib.sol";
|
|
|
14
14
|
|
|
15
15
|
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
|
16
16
|
import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
|
|
17
|
+
import "@openzeppelin/contracts/proxy/Proxy.sol";
|
|
17
18
|
|
|
18
19
|
/// EXCLUDED FROM ALL AUDITS, TO BE CALLED ONLY BY PENDLE's SDK
|
|
19
|
-
contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeable {
|
|
20
|
+
contract RouterStatic is Initializable, Proxy, BoringOwnableUpgradeable, UUPSUpgradeable {
|
|
20
21
|
using Math for uint256;
|
|
21
22
|
using VeBalanceLib for VeBalance;
|
|
22
23
|
using VeBalanceLib for LockedPosition;
|
|
@@ -62,32 +63,29 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
62
63
|
IPMarketFactory internal immutable marketFactory;
|
|
63
64
|
IPVotingEscrowMainchain internal immutable vePENDLE;
|
|
64
65
|
IPBulkSellerFactory internal immutable bulkFactory;
|
|
66
|
+
address internal immutable marketMathStaticLib;
|
|
65
67
|
|
|
66
68
|
constructor(
|
|
67
69
|
IPYieldContractFactory _yieldContractFactory,
|
|
68
70
|
IPMarketFactory _marketFactory,
|
|
69
71
|
IPVotingEscrowMainchain _vePENDLE,
|
|
70
|
-
IPBulkSellerFactory _bulkFactory
|
|
72
|
+
IPBulkSellerFactory _bulkFactory,
|
|
73
|
+
address _marketMathStaticLib
|
|
71
74
|
) initializer {
|
|
72
75
|
yieldContractFactory = _yieldContractFactory;
|
|
73
76
|
marketFactory = _marketFactory;
|
|
74
77
|
vePENDLE = _vePENDLE;
|
|
75
78
|
bulkFactory = _bulkFactory;
|
|
79
|
+
marketMathStaticLib = _marketMathStaticLib;
|
|
76
80
|
}
|
|
77
81
|
|
|
78
|
-
|
|
79
|
-
|
|
82
|
+
// all Market-related functions will go to MarketMathStaticLib
|
|
83
|
+
function _implementation() internal view override returns (address) {
|
|
84
|
+
return marketMathStaticLib;
|
|
80
85
|
}
|
|
81
86
|
|
|
82
|
-
function
|
|
83
|
-
|
|
84
|
-
ApproxParams({
|
|
85
|
-
guessMin: 0,
|
|
86
|
-
guessMax: type(uint256).max,
|
|
87
|
-
guessOffchain: 0,
|
|
88
|
-
maxIteration: 256,
|
|
89
|
-
eps: 1e14
|
|
90
|
-
});
|
|
87
|
+
function initialize() external initializer {
|
|
88
|
+
__BoringOwnable_init();
|
|
91
89
|
}
|
|
92
90
|
|
|
93
91
|
function _authorizeUpgrade(address newImplementation) internal override onlyOwner {}
|
|
@@ -329,8 +327,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
329
327
|
uint256 exchangeRateAfter
|
|
330
328
|
)
|
|
331
329
|
{
|
|
332
|
-
return
|
|
333
|
-
MarketMathStatic.addLiquiditySinglePtStatic(market, netPtIn, getDefaultApproxParams());
|
|
330
|
+
return MarketMathStatic.addLiquiditySinglePtStatic(market, netPtIn);
|
|
334
331
|
}
|
|
335
332
|
|
|
336
333
|
function addLiquiditySingleSyStatic(address market, uint256 netSyIn)
|
|
@@ -343,8 +340,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
343
340
|
uint256 exchangeRateAfter
|
|
344
341
|
)
|
|
345
342
|
{
|
|
346
|
-
return
|
|
347
|
-
MarketMathStatic.addLiquiditySingleSyStatic(market, netSyIn, getDefaultApproxParams());
|
|
343
|
+
return MarketMathStatic.addLiquiditySingleSyStatic(market, netSyIn);
|
|
348
344
|
}
|
|
349
345
|
|
|
350
346
|
function addLiquiditySingleBaseTokenStatic(
|
|
@@ -369,8 +365,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
369
365
|
bulk
|
|
370
366
|
);
|
|
371
367
|
|
|
372
|
-
return
|
|
373
|
-
MarketMathStatic.addLiquiditySingleSyStatic(market, netSyIn, getDefaultApproxParams());
|
|
368
|
+
return MarketMathStatic.addLiquiditySingleSyStatic(market, netSyIn);
|
|
374
369
|
}
|
|
375
370
|
|
|
376
371
|
function removeLiquidityDualSyAndPtStatic(address market, uint256 netLpToRemove)
|
|
@@ -407,12 +402,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
407
402
|
uint256 exchangeRateAfter
|
|
408
403
|
)
|
|
409
404
|
{
|
|
410
|
-
return
|
|
411
|
-
MarketMathStatic.removeLiquiditySinglePtStatic(
|
|
412
|
-
market,
|
|
413
|
-
netLpToRemove,
|
|
414
|
-
getDefaultApproxParams()
|
|
415
|
-
);
|
|
405
|
+
return MarketMathStatic.removeLiquiditySinglePtStatic(market, netLpToRemove);
|
|
416
406
|
}
|
|
417
407
|
|
|
418
408
|
function removeLiquiditySingleSyStatic(address market, uint256 netLpToRemove)
|
|
@@ -443,10 +433,8 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
443
433
|
{
|
|
444
434
|
uint256 netSyOut;
|
|
445
435
|
|
|
446
|
-
(netSyOut, netSyFee, priceImpact, exchangeRateAfter) = MarketMathStatic
|
|
447
|
-
market,
|
|
448
|
-
netLpToRemove
|
|
449
|
-
);
|
|
436
|
+
(netSyOut, netSyFee, priceImpact, exchangeRateAfter) = MarketMathStatic
|
|
437
|
+
.removeLiquiditySingleSyStatic(market, netLpToRemove);
|
|
450
438
|
|
|
451
439
|
netBaseTokenOut = previewRedeemStatic(getSyMarket(market), baseToken, netSyOut, bulk);
|
|
452
440
|
}
|
|
@@ -484,8 +472,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
484
472
|
uint256 exchangeRateAfter
|
|
485
473
|
)
|
|
486
474
|
{
|
|
487
|
-
return
|
|
488
|
-
MarketMathStatic.swapExactSyForPtStatic(market, exactSyIn, getDefaultApproxParams());
|
|
475
|
+
return MarketMathStatic.swapExactSyForPtStatic(market, exactSyIn);
|
|
489
476
|
}
|
|
490
477
|
|
|
491
478
|
function swapPtForExactSyStatic(address market, uint256 exactSyOut)
|
|
@@ -497,8 +484,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
497
484
|
uint256 exchangeRateAfter
|
|
498
485
|
)
|
|
499
486
|
{
|
|
500
|
-
return
|
|
501
|
-
MarketMathStatic.swapPtForExactSyStatic(market, exactSyOut, getDefaultApproxParams());
|
|
487
|
+
return MarketMathStatic.swapPtForExactSyStatic(market, exactSyOut);
|
|
502
488
|
}
|
|
503
489
|
|
|
504
490
|
function swapExactBaseTokenForPtStatic(
|
|
@@ -521,7 +507,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
521
507
|
amountBaseToken,
|
|
522
508
|
bulk
|
|
523
509
|
);
|
|
524
|
-
return MarketMathStatic.swapExactSyForPtStatic(market, netSyIn
|
|
510
|
+
return MarketMathStatic.swapExactSyForPtStatic(market, netSyIn);
|
|
525
511
|
}
|
|
526
512
|
|
|
527
513
|
function swapExactPtForBaseTokenStatic(
|
|
@@ -539,10 +525,8 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
539
525
|
)
|
|
540
526
|
{
|
|
541
527
|
uint256 netSyOut;
|
|
542
|
-
(netSyOut, netSyFee, priceImpact, exchangeRateAfter) = MarketMathStatic
|
|
543
|
-
market,
|
|
544
|
-
exactPtIn
|
|
545
|
-
);
|
|
528
|
+
(netSyOut, netSyFee, priceImpact, exchangeRateAfter) = MarketMathStatic
|
|
529
|
+
.swapExactPtForSyStatic(market, exactPtIn);
|
|
546
530
|
|
|
547
531
|
netBaseTokenOut = previewRedeemStatic(getSyMarket(market), baseToken, netSyOut, bulk);
|
|
548
532
|
}
|
|
@@ -566,11 +550,9 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
566
550
|
uint256 netSyFee,
|
|
567
551
|
uint256 priceImpact,
|
|
568
552
|
uint256 exchangeRateAfter
|
|
569
|
-
|
|
570
553
|
)
|
|
571
554
|
{
|
|
572
|
-
return
|
|
573
|
-
MarketMathStatic.swapExactSyForYtStatic(market, exactSyIn, getDefaultApproxParams());
|
|
555
|
+
return MarketMathStatic.swapExactSyForYtStatic(market, exactSyIn);
|
|
574
556
|
}
|
|
575
557
|
|
|
576
558
|
function swapExactYtForSyStatic(address market, uint256 exactYtIn)
|
|
@@ -580,7 +562,6 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
580
562
|
uint256 netSyFee,
|
|
581
563
|
uint256 priceImpact,
|
|
582
564
|
uint256 exchangeRateAfter
|
|
583
|
-
|
|
584
565
|
)
|
|
585
566
|
{
|
|
586
567
|
return MarketMathStatic.swapExactYtForSyStatic(market, exactYtIn);
|
|
@@ -595,8 +576,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
595
576
|
uint256 exchangeRateAfter
|
|
596
577
|
)
|
|
597
578
|
{
|
|
598
|
-
return
|
|
599
|
-
MarketMathStatic.swapYtForExactSyStatic(market, exactSyOut, getDefaultApproxParams());
|
|
579
|
+
return MarketMathStatic.swapYtForExactSyStatic(market, exactSyOut);
|
|
600
580
|
}
|
|
601
581
|
|
|
602
582
|
function swapExactYtForBaseTokenStatic(
|
|
@@ -614,10 +594,8 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
614
594
|
)
|
|
615
595
|
{
|
|
616
596
|
uint256 netSyOut;
|
|
617
|
-
(netSyOut, netSyFee, priceImpact, exchangeRateAfter) = MarketMathStatic
|
|
618
|
-
market,
|
|
619
|
-
exactYtIn
|
|
620
|
-
);
|
|
597
|
+
(netSyOut, netSyFee, priceImpact, exchangeRateAfter) = MarketMathStatic
|
|
598
|
+
.swapExactYtForSyStatic(market, exactYtIn);
|
|
621
599
|
|
|
622
600
|
netBaseTokenOut = previewRedeemStatic(getSyMarket(market), baseToken, netSyOut, bulk);
|
|
623
601
|
}
|
|
@@ -643,7 +621,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
643
621
|
bulk
|
|
644
622
|
);
|
|
645
623
|
|
|
646
|
-
return MarketMathStatic.swapExactSyForYtStatic(market, netSyIn
|
|
624
|
+
return MarketMathStatic.swapExactSyForYtStatic(market, netSyIn);
|
|
647
625
|
}
|
|
648
626
|
|
|
649
627
|
function swapExactPtForYtStatic(address market, uint256 exactPtIn)
|
|
@@ -656,7 +634,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
656
634
|
uint256 exchangeRateAfter
|
|
657
635
|
)
|
|
658
636
|
{
|
|
659
|
-
return MarketMathStatic.swapExactPtForYt(market, exactPtIn
|
|
637
|
+
return MarketMathStatic.swapExactPtForYt(market, exactPtIn);
|
|
660
638
|
}
|
|
661
639
|
|
|
662
640
|
function swapExactYtForPtStatic(address market, uint256 exactYtIn)
|
|
@@ -669,7 +647,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
669
647
|
uint256 exchangeRateAfter
|
|
670
648
|
)
|
|
671
649
|
{
|
|
672
|
-
return MarketMathStatic.swapExactYtForPt(market, exactYtIn
|
|
650
|
+
return MarketMathStatic.swapExactYtForPt(market, exactYtIn);
|
|
673
651
|
}
|
|
674
652
|
|
|
675
653
|
// ============= vePENDLE =============
|
|
@@ -825,7 +803,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
|
|
|
825
803
|
address bulk,
|
|
826
804
|
uint256 netSyOut
|
|
827
805
|
) public view returns (uint256 netTokenIn) {
|
|
828
|
-
uint256 pivotAmount = 10
|
|
806
|
+
uint256 pivotAmount = 10**IERC20Metadata(tokenIn).decimals();
|
|
829
807
|
|
|
830
808
|
uint256 low = pivotAmount;
|
|
831
809
|
{
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
// SPDX-License-Identifier:
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
2
|
|
|
3
3
|
pragma solidity 0.8.17;
|
|
4
4
|
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
5
|
-
import "./
|
|
5
|
+
import "./IMultihopRouterEthereum.sol";
|
|
6
6
|
import "./IAggregatorRouterHelper.sol";
|
|
7
7
|
import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
|
|
8
8
|
import "../../core/libraries/BoringOwnableUpgradeable.sol";
|
|
@@ -40,8 +40,7 @@ contract AggregationRouterHelper is
|
|
|
40
40
|
BALANCERV2,
|
|
41
41
|
KYBERRFQ,
|
|
42
42
|
DODO,
|
|
43
|
-
|
|
44
|
-
PLATYPUS
|
|
43
|
+
WSTETH
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
struct SwapDescription {
|
|
@@ -65,7 +64,7 @@ contract AggregationRouterHelper is
|
|
|
65
64
|
}
|
|
66
65
|
|
|
67
66
|
struct SwapExecutorDescription {
|
|
68
|
-
|
|
67
|
+
IMultihopRouterEthereum.Swap[][] swapSequences;
|
|
69
68
|
address tokenIn;
|
|
70
69
|
address tokenOut;
|
|
71
70
|
uint256 minTotalAmountOut;
|
|
@@ -178,7 +177,7 @@ contract AggregationRouterHelper is
|
|
|
178
177
|
|
|
179
178
|
uint256 newTotalSwapAmount;
|
|
180
179
|
for (uint256 i = 0; i < swapExecutorDescription.swapSequences.length; i++) {
|
|
181
|
-
|
|
180
|
+
IMultihopRouterEthereum.Swap memory swap = swapExecutorDescription.swapSequences[i][0];
|
|
182
181
|
uint8 dexType = uint8(swap.dexOption >> 8);
|
|
183
182
|
uint256 value;
|
|
184
183
|
if (i == swapExecutorDescription.swapSequences.length - 1)
|
|
@@ -200,8 +199,8 @@ contract AggregationRouterHelper is
|
|
|
200
199
|
revert("kyber: can't scale kyberrfq");
|
|
201
200
|
} else if (dexType == uint8(DexType.DODO)) {
|
|
202
201
|
(swap.data, value) = _newDODOSwap(swap.data, value, oldAmount, newAmount);
|
|
203
|
-
} else if (dexType == uint8(DexType.
|
|
204
|
-
(swap.data, value) =
|
|
202
|
+
} else if (dexType == uint8(DexType.WSTETH)) {
|
|
203
|
+
(swap.data, value) = _newWrappedstETHSwap(swap.data, value, oldAmount, newAmount);
|
|
205
204
|
} else {
|
|
206
205
|
revert("AggregationExecutor: Dex type not supported");
|
|
207
206
|
}
|
|
@@ -216,7 +215,10 @@ contract AggregationRouterHelper is
|
|
|
216
215
|
uint256 oldAmount,
|
|
217
216
|
uint256 newAmount
|
|
218
217
|
) internal pure returns (bytes memory, uint256) {
|
|
219
|
-
|
|
218
|
+
IMultihopRouterEthereum.UniSwap memory uniSwap = abi.decode(
|
|
219
|
+
data,
|
|
220
|
+
(IMultihopRouterEthereum.UniSwap)
|
|
221
|
+
);
|
|
220
222
|
if (value > 0) uniSwap.collectAmount = value;
|
|
221
223
|
else uniSwap.collectAmount = (uniSwap.collectAmount * newAmount) / oldAmount;
|
|
222
224
|
return (abi.encode(uniSwap), uniSwap.collectAmount);
|
|
@@ -228,9 +230,9 @@ contract AggregationRouterHelper is
|
|
|
228
230
|
uint256 oldAmount,
|
|
229
231
|
uint256 newAmount
|
|
230
232
|
) internal pure returns (bytes memory, uint256) {
|
|
231
|
-
|
|
233
|
+
IMultihopRouterEthereum.StableSwap memory stableSwap = abi.decode(
|
|
232
234
|
data,
|
|
233
|
-
(
|
|
235
|
+
(IMultihopRouterEthereum.StableSwap)
|
|
234
236
|
);
|
|
235
237
|
if (value > 0) stableSwap.dx = value;
|
|
236
238
|
else stableSwap.dx = (stableSwap.dx * newAmount) / oldAmount;
|
|
@@ -243,7 +245,10 @@ contract AggregationRouterHelper is
|
|
|
243
245
|
uint256 oldAmount,
|
|
244
246
|
uint256 newAmount
|
|
245
247
|
) internal pure returns (bytes memory, uint256) {
|
|
246
|
-
|
|
248
|
+
IMultihopRouterEthereum.CurveSwap memory curveSwap = abi.decode(
|
|
249
|
+
data,
|
|
250
|
+
(IMultihopRouterEthereum.CurveSwap)
|
|
251
|
+
);
|
|
247
252
|
if (value > 0) curveSwap.dx = value;
|
|
248
253
|
else curveSwap.dx = (curveSwap.dx * newAmount) / oldAmount;
|
|
249
254
|
return (abi.encode(curveSwap), curveSwap.dx);
|
|
@@ -255,7 +260,10 @@ contract AggregationRouterHelper is
|
|
|
255
260
|
uint256 oldAmount,
|
|
256
261
|
uint256 newAmount
|
|
257
262
|
) internal pure returns (bytes memory, uint256) {
|
|
258
|
-
|
|
263
|
+
IMultihopRouterEthereum.UniSwap memory kyberDMMSwap = abi.decode(
|
|
264
|
+
data,
|
|
265
|
+
(IMultihopRouterEthereum.UniSwap)
|
|
266
|
+
);
|
|
259
267
|
if (value > 0) kyberDMMSwap.collectAmount = value;
|
|
260
268
|
else kyberDMMSwap.collectAmount = (kyberDMMSwap.collectAmount * newAmount) / oldAmount;
|
|
261
269
|
return (abi.encode(kyberDMMSwap), kyberDMMSwap.collectAmount);
|
|
@@ -267,9 +275,9 @@ contract AggregationRouterHelper is
|
|
|
267
275
|
uint256 oldAmount,
|
|
268
276
|
uint256 newAmount
|
|
269
277
|
) internal pure returns (bytes memory, uint256) {
|
|
270
|
-
|
|
278
|
+
IMultihopRouterEthereum.UniSwapV3ProMM memory uniSwapV3ProMM = abi.decode(
|
|
271
279
|
data,
|
|
272
|
-
(
|
|
280
|
+
(IMultihopRouterEthereum.UniSwapV3ProMM)
|
|
273
281
|
);
|
|
274
282
|
if (value > 0) uniSwapV3ProMM.swapAmount = value;
|
|
275
283
|
else uniSwapV3ProMM.swapAmount = (uniSwapV3ProMM.swapAmount * newAmount) / oldAmount;
|
|
@@ -282,9 +290,9 @@ contract AggregationRouterHelper is
|
|
|
282
290
|
uint256 oldAmount,
|
|
283
291
|
uint256 newAmount
|
|
284
292
|
) internal pure returns (bytes memory, uint256) {
|
|
285
|
-
|
|
293
|
+
IMultihopRouterEthereum.BalancerV2 memory balancerV2 = abi.decode(
|
|
286
294
|
data,
|
|
287
|
-
(
|
|
295
|
+
(IMultihopRouterEthereum.BalancerV2)
|
|
288
296
|
);
|
|
289
297
|
if (value > 0) balancerV2.amount = value;
|
|
290
298
|
else balancerV2.amount = (balancerV2.amount * newAmount) / oldAmount;
|
|
@@ -297,21 +305,27 @@ contract AggregationRouterHelper is
|
|
|
297
305
|
uint256 oldAmount,
|
|
298
306
|
uint256 newAmount
|
|
299
307
|
) internal pure returns (bytes memory, uint256) {
|
|
300
|
-
|
|
308
|
+
IMultihopRouterEthereum.DODO memory dodo = abi.decode(
|
|
309
|
+
data,
|
|
310
|
+
(IMultihopRouterEthereum.DODO)
|
|
311
|
+
);
|
|
301
312
|
if (value > 0) dodo.amount = value;
|
|
302
313
|
else dodo.amount = (dodo.amount * newAmount) / oldAmount;
|
|
303
314
|
return (abi.encode(dodo), dodo.amount);
|
|
304
315
|
}
|
|
305
316
|
|
|
306
|
-
function
|
|
317
|
+
function _newWrappedstETHSwap(
|
|
307
318
|
bytes memory data,
|
|
308
319
|
uint256 value,
|
|
309
320
|
uint256 oldAmount,
|
|
310
321
|
uint256 newAmount
|
|
311
322
|
) internal pure returns (bytes memory, uint256) {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
323
|
+
IMultihopRouterEthereum.WSTETH memory wstEthData = abi.decode(
|
|
324
|
+
data,
|
|
325
|
+
(IMultihopRouterEthereum.WSTETH)
|
|
326
|
+
);
|
|
327
|
+
if (value > 0) wstEthData.amount = value;
|
|
328
|
+
else wstEthData.amount = (wstEthData.amount * newAmount) / oldAmount;
|
|
329
|
+
return (abi.encode(wstEthData), wstEthData.amount);
|
|
316
330
|
}
|
|
317
331
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
// SPDX-License-Identifier:
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
2
|
|
|
3
|
-
pragma solidity
|
|
3
|
+
pragma solidity 0.8.17;
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
interface IMultihopRouter {
|
|
5
|
+
interface IMultihopRouterEthereum {
|
|
8
6
|
enum DexType {
|
|
9
7
|
UNI,
|
|
10
8
|
STABLESWAP,
|
|
@@ -15,8 +13,7 @@ interface IMultihopRouter {
|
|
|
15
13
|
BALANCERV2,
|
|
16
14
|
KYBERRFQ,
|
|
17
15
|
DODO,
|
|
18
|
-
|
|
19
|
-
PLATYPUS
|
|
16
|
+
WSTETH
|
|
20
17
|
}
|
|
21
18
|
|
|
22
19
|
event Exchange(address pair, uint256 amountOut, address output);
|
|
@@ -32,13 +29,18 @@ interface IMultihopRouter {
|
|
|
32
29
|
// 6: balancerv2
|
|
33
30
|
// 7: kyber RFQ
|
|
34
31
|
// 8: dodo
|
|
35
|
-
// 9:
|
|
36
|
-
// 10: platypus
|
|
32
|
+
// 9: wstETH: Lido wrapped stETH
|
|
37
33
|
//dexId:
|
|
38
34
|
// 0: firebird
|
|
39
35
|
uint16 dexOption; //dexType(8bit) + dexId(8bit)
|
|
40
36
|
}
|
|
41
37
|
|
|
38
|
+
struct WSTETH {
|
|
39
|
+
address pool;
|
|
40
|
+
uint256 amount;
|
|
41
|
+
bool isWrapping;
|
|
42
|
+
}
|
|
43
|
+
|
|
42
44
|
struct UniSwap {
|
|
43
45
|
address pool;
|
|
44
46
|
address tokenIn;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sAPE",
|
|
3
|
+
"SY": "0x47BA20283Be4d72D4AFB1862994F4203551539C5",
|
|
4
|
+
"YT": "0x9523F7e527f8AE884DFb0a38F611AA7417Fd2845",
|
|
5
|
+
"PT": "0x2CF5Eb8dB83C9752125D5d961C4C9DfaA9178d1A",
|
|
6
|
+
"market": "0x9A76925dD91A7561b58D8353f0bcE4DF1e517aBb",
|
|
7
|
+
"expiry": 1687996800
|
|
8
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"deployer": "0x1FcCC097db89A86Bfc474A1028F93958295b1Fb7",
|
|
3
|
+
"network": {
|
|
4
|
+
"chainId": 80001,
|
|
5
|
+
"treasury": "0x7D301Cc4F91A9eDd8EDE1801344bd6516b5FA3d2",
|
|
6
|
+
"governance": "0x1FcCC097db89A86Bfc474A1028F93958295b1Fb7",
|
|
7
|
+
"pendle": "0xa6dc67fF3b241DEdeC6aF907Ff24bB5cFC3EEeAf",
|
|
8
|
+
"lzEndpoint": "0xf69186dfBa60DdB133E91E9A4B5673624293d8F8",
|
|
9
|
+
"wrappedNative": "0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889",
|
|
10
|
+
"initialRewardFee": "30000000000000000",
|
|
11
|
+
"initialInterestFee": "30000000000000000",
|
|
12
|
+
"initialFeeRateRoot": "999500333083533",
|
|
13
|
+
"initialReserveFeePercent": "80",
|
|
14
|
+
"initialPendlePerSec": "826719576719576719",
|
|
15
|
+
"safeWaitTime": 15000
|
|
16
|
+
},
|
|
17
|
+
"baseCodeSplitter": "0xc5E332F1c3123E66C0b1bf0dFb9Cb4BA86a175C9",
|
|
18
|
+
"PENDLE": "0xa6dc67fF3b241DEdeC6aF907Ff24bB5cFC3EEeAf",
|
|
19
|
+
"yieldContractFactory": "0x8091897bE27CC11d80De8F48049168C9C7A5B1aC",
|
|
20
|
+
"marketFactory": "0xeB2AEd0aE414c76e4f9D4d43cD01064Fec010dfB",
|
|
21
|
+
"bulkSellerFactory": "0x4707f0CC2Ad4211172EdBAFc453E60DBd1C9D854",
|
|
22
|
+
"bulkSellerOffchain": "0x7Fb3626D95449d69f991a37e304b8C9A0a5D0e0c",
|
|
23
|
+
"router": "0x5141Ad90AafB0D45e9F19Bd9F861362d56f2CF79",
|
|
24
|
+
"routerStatic": "0xc7F8F9F1DdE1104664b6fC8F33E49b169C12F41E",
|
|
25
|
+
"receiverEndpoint": "0x256752c851EDB92c97377C93232A9034c835F376",
|
|
26
|
+
"vePendle": "0xC0BC61112D9fD7bA5809047a86EC245593BA0e1E",
|
|
27
|
+
"gaugeController": "0x9aBcB6a79dD8de67FB41108493787533775d98d3"
|
|
28
|
+
}
|