Skip to content

Commit

Permalink
Merge pull request #28 from Ion-Protocol/jun/seiyanETH-decoder
Browse files Browse the repository at this point in the history
seiyanETH Decoder
  • Loading branch information
CarsonCase authored Oct 2, 2024
2 parents 5721dcc + 9234795 commit 030dd4c
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 62 deletions.
2 changes: 2 additions & 0 deletions src/base/DecodersAndSanitizers/BaseDecoderAndSanitizer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ pragma solidity 0.8.21;
import { DecoderCustomTypes } from "src/interfaces/DecoderCustomTypes.sol";

contract BaseDecoderAndSanitizer {
error NotVault();

//============================== IMMUTABLES ===============================

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ import { BaseDecoderAndSanitizer } from "src/base/DecodersAndSanitizers/BaseDeco
import { SendParam } from "@layerzerolabs/oft-evm/contracts/interfaces/IOFT.sol";
import { MessagingFee } from "@layerzerolabs/oapp-evm/contracts/oapp/OApp.sol";

contract LayerZeroOFTDecoderAndSanitizer is BaseDecoderAndSanitizer {
abstract contract LayerZeroOFTDecoderAndSanitizer is BaseDecoderAndSanitizer {
error LayerZeroOFTDecoderAndSanitizer_ComposedMsgNotSupported();
error LayerZeroOFTDecoderAndSanitizer_NotVault();

constructor(address _boringVault) BaseDecoderAndSanitizer(_boringVault) { }

/**
* @dev _sendParam:
Expand All @@ -19,7 +16,8 @@ contract LayerZeroOFTDecoderAndSanitizer is BaseDecoderAndSanitizer {
* uint256 minAmountLD; // Minimum amount to send in local decimals.
* bytes extraOptions; // Additional options supplied by the caller to be used in the LayerZero message.
* bytes composeMsg; // The composed message for the send() operation. [NONE]
* bytes oftCmd; // The OFT command to be executed, unused in default OFT implementations. [NONE]
* bytes oftCmd; // The OFT command to be executed, unused in default OFT implementations. 0 for Taxi (faster,
* expensive) 1 for Bus (slower, cheaper)
* @dev _fee:
* uint256 nativeFee;
* uint256 lzTokenFee;
Expand All @@ -33,8 +31,8 @@ contract LayerZeroOFTDecoderAndSanitizer is BaseDecoderAndSanitizer {
view
returns (bytes memory)
{
if (bytes32ToAddress(_sendParam.to) != boringVault) {
revert LayerZeroOFTDecoderAndSanitizer_NotVault();
if (bytes32ToAddress(_sendParam.to) != boringVault || refundReceiver != boringVault) {
revert NotVault();
}
if (_sendParam.composeMsg.length > 0) {
revert LayerZeroOFTDecoderAndSanitizer_ComposedMsgNotSupported();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ abstract contract CurveDecoderAndSanitizer is BaseDecoderAndSanitizer {
return addressesFound;
}

function deposit(uint256, address receiver) external pure virtual returns (bytes memory addressesFound) {
function deposit(uint256, address receiver) external view virtual returns (bytes memory addressesFound) {
if (receiver != boringVault) {
revert NotVault();
}
addressesFound = abi.encodePacked(receiver);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ import { BaseDecoderAndSanitizer } from "src/base/DecodersAndSanitizers/BaseDeco
abstract contract ERC4626DecoderAndSanitizer is BaseDecoderAndSanitizer {
//============================== ERC4626 ===============================

function deposit(uint256, address receiver) external pure virtual returns (bytes memory addressesFound) {
function deposit(uint256, address receiver) external view virtual returns (bytes memory addressesFound) {
if (receiver != boringVault) {
revert NotVault();
}
addressesFound = abi.encodePacked(receiver);
}

function mint(uint256, address receiver) external pure virtual returns (bytes memory addressesFound) {
function mint(uint256, address receiver) external view virtual returns (bytes memory addressesFound) {
if (receiver != boringVault) {
revert NotVault();
}
addressesFound = abi.encodePacked(receiver);
}

Expand All @@ -20,10 +26,13 @@ abstract contract ERC4626DecoderAndSanitizer is BaseDecoderAndSanitizer {
address owner
)
external
pure
view
virtual
returns (bytes memory addressesFound)
{
if (receiver != boringVault) {
revert NotVault();
}
addressesFound = abi.encodePacked(receiver, owner);
}

Expand All @@ -33,10 +42,13 @@ abstract contract ERC4626DecoderAndSanitizer is BaseDecoderAndSanitizer {
address owner
)
external
pure
view
virtual
returns (bytes memory addressesFound)
{
if (receiver != boringVault) {
revert NotVault();
}
addressesFound = abi.encodePacked(receiver, owner);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity 0.8.21;
import { BaseDecoderAndSanitizer } from "src/base/DecodersAndSanitizers/BaseDecoderAndSanitizer.sol";

abstract contract NativeWrapperDecoderAndSanitizer is BaseDecoderAndSanitizer {
//============================== ETHERFI ===============================
//============================== WETH/ETHERFI ===============================

function deposit() external pure virtual returns (bytes memory addressesFound) {
// Nothing to sanitize or return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { BaseDecoderAndSanitizer } from "src/base/DecodersAndSanitizers/BaseDeco

abstract contract PirexEthDecoderAndSanitizer is BaseDecoderAndSanitizer {
function deposit(address receiver, bool) external returns (bytes memory) {
if (receiver != boringVault) {
revert NotVault();
}
return abi.encodePacked(receiver);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,49 @@
pragma solidity 0.8.21;

import { BaseDecoderAndSanitizer } from "src/base/DecodersAndSanitizers/BaseDecoderAndSanitizer.sol";
import { ERC4626DecoderAndSanitizer } from "src/base/DecodersAndSanitizers/Protocols/ERC4626DecoderAndSanitizer.sol";
import { PirexEthDecoderAndSanitizer } from "src/base/DecodersAndSanitizers/Protocols/PirexEthDecoderAndSanitizer.sol";
import { LayerZeroOFTDecoderAndSanitizer } from "src/base/DecodersAndSanitizers/LayerZeroOFTDecoderAndSanitizer.sol";
import { NativeWrapperDecoderAndSanitizer } from
"src/base/DecodersAndSanitizers/Protocols/NativeWrapperDecoderAndSanitizer.sol";
import { ERC4626DecoderAndSanitizer } from "src/base/DecodersAndSanitizers/Protocols/ERC4626DecoderAndSanitizer.sol";
import { CurveDecoderAndSanitizer } from "src/base/DecodersAndSanitizers/Protocols/CurveDecoderAndSanitizer.sol";

contract SeiyanEthRebalanceDecoderAndSanitizer is
BaseDecoderAndSanitizer,
ERC4626DecoderAndSanitizer,
PirexEthDecoderAndSanitizer,
NativeWrapperDecoderAndSanitizer
LayerZeroOFTDecoderAndSanitizer,
NativeWrapperDecoderAndSanitizer,
ERC4626DecoderAndSanitizer,
CurveDecoderAndSanitizer
{
constructor(address _boringVault) BaseDecoderAndSanitizer(_boringVault) { }

function deposit(
uint256,
address receiver
)
external
view
override(CurveDecoderAndSanitizer, ERC4626DecoderAndSanitizer)
returns (bytes memory addressesFound)
{
if (receiver != boringVault) {
revert NotVault();
}
addressesFound = abi.encodePacked(receiver);
}

/**
* @notice Curve and WETH both specifies a `withdraw(uint256)`, but all
* cases are handled the same way.
*/
function withdraw(uint256)
external
pure
override(CurveDecoderAndSanitizer, NativeWrapperDecoderAndSanitizer)
returns (bytes memory addressesFound)
{
// Nothing to sanitize or return
return addressesFound;
}
}
46 changes: 0 additions & 46 deletions src/base/DecodersAndSanitizers/StargateV2DecoderAndSanitizer.sol

This file was deleted.

0 comments on commit 030dd4c

Please sign in to comment.