Skip to content

Commit

Permalink
feat: revised pendle
Browse files Browse the repository at this point in the history
  • Loading branch information
CarsonCase committed Oct 23, 2024
1 parent 26b213e commit 89a9193
Showing 1 changed file with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ abstract contract PendleRouterDecoderAndSanitizer is BaseDecoderAndSanitizer {
//============================== ERRORS ===============================

error PendleRouterDecoderAndSanitizer__AggregatorSwapsNotPermitted();
error PendleRouterDecoderAndSanitizer__LimitOrderSwapsNotPermitted();

//============================== PENDLEROUTER ===============================

Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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);
}
}

0 comments on commit 89a9193

Please sign in to comment.