From 89a91934dad3228cce5bbbc6298e46e0667cb985 Mon Sep 17 00:00:00 2001 From: Carson Date: Tue, 22 Oct 2024 23:07:28 -0400 Subject: [PATCH] feat: revised pendle --- .../PendleRouterDecoderAndSanitizer.sol | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/base/DecodersAndSanitizers/Protocols/PendleRouterDecoderAndSanitizer.sol b/src/base/DecodersAndSanitizers/Protocols/PendleRouterDecoderAndSanitizer.sol index 6d30678..1e5f86a 100644 --- a/src/base/DecodersAndSanitizers/Protocols/PendleRouterDecoderAndSanitizer.sol +++ b/src/base/DecodersAndSanitizers/Protocols/PendleRouterDecoderAndSanitizer.sol @@ -7,6 +7,7 @@ abstract contract PendleRouterDecoderAndSanitizer is BaseDecoderAndSanitizer { //============================== ERRORS =============================== error PendleRouterDecoderAndSanitizer__AggregatorSwapsNotPermitted(); + error PendleRouterDecoderAndSanitizer__LimitOrderSwapsNotPermitted(); //============================== PENDLEROUTER =============================== @@ -177,7 +178,12 @@ abstract contract PendleRouterDecoderAndSanitizer is BaseDecoderAndSanitizer { virtual returns (bytes memory addressesFound) { - addressesFound = abi.encodePacked(receiver, market, input.tokenIn, input.tokenMintSy); + if ( + input.swapData.swapType != DecoderCustomTypes.SwapType.NONE || input.swapData.extRouter != address(0) + || input.pendleSwap != address(0) || input.tokenIn != input.tokenMintSy + ) revert PendleRouterDecoderAndSanitizer__AggregatorSwapsNotPermitted(); + + addressesFound = abi.encodePacked(receiver, market, input.tokenIn); } function addLiquiditySingleToken( @@ -192,7 +198,16 @@ abstract contract PendleRouterDecoderAndSanitizer is BaseDecoderAndSanitizer { pure returns (bytes memory addressesFound) { - addressesFound = abi.encodePacked(receiver, market, input.tokenIn, input.tokenMintSy); + if ( + input.swapData.swapType != DecoderCustomTypes.SwapType.NONE || input.swapData.extRouter != address(0) + || input.pendleSwap != address(0) || input.tokenIn != input.tokenMintSy + ) revert PendleRouterDecoderAndSanitizer__AggregatorSwapsNotPermitted(); + + if (limit.limitRouter != address(0)) { + revert PendleRouterDecoderAndSanitizer__LimitOrderSwapsNotPermitted(); + } + + addressesFound = abi.encodePacked(receiver, market); } function removeLiquiditySingleToken( @@ -207,6 +222,15 @@ abstract contract PendleRouterDecoderAndSanitizer is BaseDecoderAndSanitizer { virtual returns (bytes memory addressFound) { - addressFound = abi.encodePacked(receiver, market, output.tokenOut, output.tokenRedeemSy); + if ( + output.swapData.swapType != DecoderCustomTypes.SwapType.NONE || output.swapData.extRouter != address(0) + || output.pendleSwap != address(0) || output.tokenOut != output.tokenRedeemSy + ) revert PendleRouterDecoderAndSanitizer__AggregatorSwapsNotPermitted(); + + if (limit.limitRouter != address(0)) { + revert PendleRouterDecoderAndSanitizer__LimitOrderSwapsNotPermitted(); + } + + addressFound = abi.encodePacked(receiver, market); } }