Skip to content

Commit

Permalink
fix: removed unused, moved types to DecoderCustomTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
CarsonCase committed Oct 22, 2024
1 parent eab666f commit 26b213e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
36 changes: 36 additions & 0 deletions src/interfaces/DecoderCustomTypes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 26b213e

Please sign in to comment.