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
| Name | Type | Description |
|---|---|---|
| amount_ | uint256 | Amount to input to the Reinvest |
| data_ | bytes | Encoded Reinvest data |
Returns
| Name | Type | Description |
|---|---|---|
| amount | uint256 | Amount of liquidety token retunred |
| success | bool | If 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
| Name | Type | Description |
|---|---|---|
| amount_ | uint256 | Amount of the liqidety token to unwind |
| data_ | bytes | Encoded Reinvest data |
Returns
| Name | Type | Description |
|---|---|---|
| amount | uint256 | Amount of token returned |
| success | bool | If 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
| Name | Type | Description |
|---|---|---|
| data_ | bytes | Encoded Reinvest data |
Returns
| Name | Type | Description |
|---|---|---|
| _0 | ReinvestDataStruct | The Reinvest data |
function _decodeData(
bytes memory data_
) private pure returns (ReinvestDataStruct memory) {
return abi.decode(data_, (ReinvestDataStruct));
}
}