Developer Docs
Smart Contracts
Reinvest Library
Reinvest Modules
Forward Funds

Forward Reinvest Modual

Allows users to instantly forward on the swaped in token to another address.

Functions

_execute

 function _execute(
        uint256 amount_,
        bytes memory data_
    ) internal returns (uint256 amount, bool success)

Executes the the Aave V3 reinvest logic

Parameters

NameTypeDescription
amount_uint256Amount to input to the Reinvest
data_bytesEncoded Reinvest data

Returns

NameTypeDescription
amountuint256Amount of liquidety token retunred
successboolIf the reinvest was successfull
     function _execute(
        uint256 amount_,
        bytes memory data_
    ) internal returns (uint256, bool success) {
        ReinvestDataStruct memory investData = _decodeData(data_);
        if (investData.token == address(0))
            (success, ) = payable(address(investData.receiver)).call{
                value: amount_
            }("");
        else
            success = IERC20(investData.token).transfer(
                investData.receiver,
                amount_
            );
 
        return (amount_, success);
    }

_unwind

 function _unwind(
        uint256 amount_,
        bytes memory data_
    ) internal returns (uint256 amount, bool success)

Executes the the Aave V3 unwind logic

Parameters

NameTypeDescription
amount_uint256Amount of the liqidety token to unwind
data_bytesEncoded Reinvest data

Returns

NameTypeDescription
amountuint256Amount of token returned
successboolIf the unwind was successfull
    function _unwind(
        uint256 amount_,
        bytes memory data_
    ) internal pure returns (uint256 amount, bool success) {
        //  There isn't any investments to unwind in the forward
        return (0, true);
    }

_decodeData

  function _decodeData(
        bytes memory data_
    ) private pure returns (ReinvestDataStruct memory)

Decode the reinvest data

Parameters

NameTypeDescription
data_bytesEncoded Reinvest data

Returns

NameTypeDescription
_0ReinvestDataStructThe Reinvest data
    function _decodeData(
        bytes memory data_
    ) private pure returns (ReinvestDataStruct memory) {
        return abi.decode(data_, (ReinvestDataStruct));
    }
}