From 26b213e786b5ee4379576bf13e5f9e75a82af495 Mon Sep 17 00:00:00 2001 From: Carson Date: Tue, 22 Oct 2024 15:09:53 -0400 Subject: [PATCH] fix: removed unused, moved types to DecoderCustomTypes --- .../PendleRouterDecoderAndSanitizer.sol | 93 ++----------------- .../UniswapV3DecoderAndSanitizer.sol | 8 -- src/interfaces/DecoderCustomTypes.sol | 36 +++++++ 3 files changed, 42 insertions(+), 95 deletions(-) diff --git a/src/base/DecodersAndSanitizers/Protocols/PendleRouterDecoderAndSanitizer.sol b/src/base/DecodersAndSanitizers/Protocols/PendleRouterDecoderAndSanitizer.sol index 8d93cdd..6d30678 100644 --- a/src/base/DecodersAndSanitizers/Protocols/PendleRouterDecoderAndSanitizer.sol +++ b/src/base/DecodersAndSanitizers/Protocols/PendleRouterDecoderAndSanitizer.sol @@ -165,47 +165,12 @@ abstract contract PendleRouterDecoderAndSanitizer is BaseDecoderAndSanitizer { } } - struct SwapData { - SwapType swapType; - address extRouter; - bytes extCalldata; - bool needScale; - } - - enum SwapType { - NONE, - KYBERSWAP, - ONE_INCH, - // ETH_WETH not used in Aggregator - ETH_WETH - } - - struct TokenInput { - // TOKEN DATA - address tokenIn; - uint256 netTokenIn; - address tokenMintSy; - // AGGREGATOR DATA - address pendleSwap; - SwapData swapData; - } - - struct ApproxParams { - uint256 guessMin; - uint256 guessMax; - uint256 guessOffchain; // pass 0 in to skip this variable - uint256 maxIteration; // every iteration, the diff between guessMin and guessMax will be divided by 2 - uint256 eps; // the max eps between the returned result & the correct result, base 1e18. Normally this number - // will be set - // to 1e15 (1e18/1000 = 0.1%) - } - function addLiquiditySingleTokenKeepYt( address receiver, address market, uint256 minLpOut, uint256 minYtOut, - TokenInput calldata input + DecoderCustomTypes.TokenInput calldata input ) external pure @@ -219,9 +184,9 @@ abstract contract PendleRouterDecoderAndSanitizer is BaseDecoderAndSanitizer { address receiver, address market, uint256 minLpOut, - ApproxParams calldata guessPtReceivedFromSy, - TokenInput calldata input, - LimitOrderData calldata limit + DecoderCustomTypes.ApproxParams calldata guessPtReceivedFromSy, + DecoderCustomTypes.TokenInput calldata input, + DecoderCustomTypes.LimitOrderData calldata limit ) external pure @@ -230,58 +195,12 @@ abstract contract PendleRouterDecoderAndSanitizer is BaseDecoderAndSanitizer { addressesFound = abi.encodePacked(receiver, market, input.tokenIn, input.tokenMintSy); } - enum OrderType { - SY_FOR_PT, - PT_FOR_SY, - SY_FOR_YT, - YT_FOR_SY - } - - struct Order { - uint256 salt; - uint256 expiry; - uint256 nonce; - OrderType orderType; - address token; - address YT; - address maker; - address receiver; - uint256 makingAmount; - uint256 lnImpliedRate; - uint256 failSafeRate; - bytes permit; - } - - struct FillOrderParams { - Order order; - bytes signature; - uint256 makingAmount; - } - - struct TokenOutput { - // TOKEN DATA - address tokenOut; - uint256 minTokenOut; - address tokenRedeemSy; - // AGGREGATOR DATA - address pendleSwap; - SwapData swapData; - } - - struct LimitOrderData { - address limitRouter; - uint256 epsSkipMarket; // only used for swap operations, will be ignored otherwise - FillOrderParams[] normalFills; - FillOrderParams[] flashFills; - bytes optData; - } - function removeLiquiditySingleToken( address receiver, address market, uint256 netLpToRemove, - TokenOutput calldata output, - LimitOrderData calldata limit + DecoderCustomTypes.TokenOutput calldata output, + DecoderCustomTypes.LimitOrderData calldata limit ) external pure diff --git a/src/base/DecodersAndSanitizers/Protocols/UniswapV3DecoderAndSanitizer.sol b/src/base/DecodersAndSanitizers/Protocols/UniswapV3DecoderAndSanitizer.sol index 03a429c..dac7bc8 100644 --- a/src/base/DecodersAndSanitizers/Protocols/UniswapV3DecoderAndSanitizer.sol +++ b/src/base/DecodersAndSanitizers/Protocols/UniswapV3DecoderAndSanitizer.sol @@ -117,12 +117,4 @@ abstract contract UniswapV3DecoderAndSanitizer is BaseDecoderAndSanitizer { { addressesFound = abi.encodePacked(to); } - - function transferFrom(address, address to, uint256) external pure virtual returns (bytes memory addressesFound) { - addressesFound = abi.encodePacked(to); - } - - function setApprovalForAll(address operator, bool) external pure virtual returns (bytes memory addressesFound) { - addressesFound = abi.encodePacked(operator); - } } diff --git a/src/interfaces/DecoderCustomTypes.sol b/src/interfaces/DecoderCustomTypes.sol index 9a5c783..ceb9c14 100644 --- a/src/interfaces/DecoderCustomTypes.sol +++ b/src/interfaces/DecoderCustomTypes.sol @@ -146,6 +146,42 @@ contract DecoderCustomTypes { bool needScale; } + enum OrderType { + SY_FOR_PT, + PT_FOR_SY, + SY_FOR_YT, + YT_FOR_SY + } + + struct Order { + uint256 salt; + uint256 expiry; + uint256 nonce; + OrderType orderType; + address token; + address YT; + address maker; + address receiver; + uint256 makingAmount; + uint256 lnImpliedRate; + uint256 failSafeRate; + bytes permit; + } + + struct FillOrderParams { + Order order; + bytes signature; + uint256 makingAmount; + } + + struct LimitOrderData { + address limitRouter; + uint256 epsSkipMarket; // only used for swap operations, will be ignored otherwise + FillOrderParams[] normalFills; + FillOrderParams[] flashFills; + bytes optData; + } + enum SwapType { NONE, KYBERSWAP,