Skip to content

Commit

Permalink
feat: earnBTC decoder draft
Browse files Browse the repository at this point in the history
  • Loading branch information
CarsonCase committed Oct 30, 2024
1 parent f6f0d56 commit 105248e
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,29 @@ abstract contract PendleRouterDecoderAndSanitizer is BaseDecoderAndSanitizer {

addressFound = abi.encodePacked(receiver, market);
}

function swapExactTokenForPt(
address receiver,
address market,
uint256 minPtOut,
DecoderCustomTypes.ApproxParams calldata guessPtOut,
DecoderCustomTypes.TokenInput calldata input,
DecoderCustomTypes.LimitOrderData calldata limit
)
external
pure
virtual
returns (bytes memory addressFound)
{
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();
}

addressFound = abi.encodePacked(receiver, market);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;

import { BaseDecoderAndSanitizer } from "src/base/DecodersAndSanitizers/BaseDecoderAndSanitizer.sol";

abstract contract PumpBTCDecoderAndSanitizer is BaseDecoderAndSanitizer {
//============================== PumpBTC ===============================

function stake(uint256 amount) external pure virtual returns (bytes memory addressesFound) {
// nothing to sanitize
}

function unstakeInstant(uint256 amount) external pure virtual returns (bytes memory addressFound) {
// nothing to sanitize
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;

import { BaseDecoderAndSanitizer } from "src/base/DecodersAndSanitizers/BaseDecoderAndSanitizer.sol";

abstract contract swBTCDecoderAndSanitizer is BaseDecoderAndSanitizer {
//============================== swBTCDecoderAndSanitizer ===============================

error swBTCDecoderAndSanitizer_ThirdPartyNotSupported();

function deposit(uint256, address receiver) external pure virtual returns (bytes memory addressesFound) {
addressesFound = abi.encodePacked(receiver);
}

function requestWithdraw(
address asset,
uint96 shares,
uint16 maxLoss,
bool allowThirdPartyToComplete
)
external
pure
virtual
returns (bytes memory addressesFound)
{
if (allowThirdPartyToComplete) {
revert swBTCDecoderAndSanitizer_ThirdPartyNotSupported();
}
addressesFound = abi.encodePacked(asset);
}
}
55 changes: 55 additions & 0 deletions src/base/DecodersAndSanitizers/earnBTCDecoderAndSanitizer.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// SPDX-License-Identifier: MIT

pragma solidity 0.8.21;

import {
PendleRouterDecoderAndSanitizer,
BaseDecoderAndSanitizer
} from "src/base/DecodersAndSanitizers/Protocols/PendleRouterDecoderAndSanitizer.sol";
import { PumpBTCDecoderAndSanitizer } from "src/base/DecodersAndSanitizers/Protocols/PumpBTCDecoderAndSanitizer.sol";
import { swBTCDecoderAndSanitizer } from "src/base/DecodersAndSanitizers/Protocols/swBTCDecoderAndSanitizer.sol";
import { UniswapV3DecoderAndSanitizer } from "src/base/DecodersAndSanitizers/Protocols/UniswapV3DecoderAndSanitizer.sol";
import { OneInchDecoderAndSanitizer } from "src/base/DecodersAndSanitizers/Protocols/OneInchDecoderAndSanitizer.sol";
import { BalancerV2DecoderAndSanitizer } from
"src/base/DecodersAndSanitizers/Protocols/BalancerV2DecoderAndSanitizer.sol";
import { CurveDecoderAndSanitizer } from "src/base/DecodersAndSanitizers/Protocols/CurveDecoderAndSanitizer.sol";

contract earnBTCDecoderAndSanitizer is
PendleRouterDecoderAndSanitizer,
PumpBTCDecoderAndSanitizer,
swBTCDecoderAndSanitizer,
UniswapV3DecoderAndSanitizer,
OneInchDecoderAndSanitizer,
BalancerV2DecoderAndSanitizer,
CurveDecoderAndSanitizer
{
constructor(
address _boringVault,
address _uniswapV3NonFungiblePositionManager
)
UniswapV3DecoderAndSanitizer(_uniswapV3NonFungiblePositionManager)
BaseDecoderAndSanitizer(_boringVault)
{ }

function deposit(
uint256,
address receiver
)
external
pure
override(BalancerV2DecoderAndSanitizer, swBTCDecoderAndSanitizer, CurveDecoderAndSanitizer)
returns (bytes memory addressesFound)
{
addressesFound = abi.encodePacked(receiver);
}

function withdraw(uint256)
external
pure
override(BalancerV2DecoderAndSanitizer, CurveDecoderAndSanitizer)
returns (bytes memory addressesFound)
{
// Nothing to sanitize or return
return addressesFound;
}
}

0 comments on commit 105248e

Please sign in to comment.