Blockchain / Global / Address
Contract
0xD1c2956a56BBEcfdC0fC2fbA23A4d7dbA9B15e8D
- Balance
- 0 SOMI
- Transactions sent
- 1
- Type
- Contract · 925 bytes of code
TransferHook Verified
- Compiler
- solc 0.8.30+commit.73712a01
- Language
- Solidity
- Optimization
- Yes, 200 runs
- EVM version
- prague
- License
- —
- Verified
- 2026-10-12
src/hook/TransferHook.sol
and 3 more files
Solidity
// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
import {IWithdrawable} from "./IHook.sol";
import {AbstractHook} from "./AbstractHook.sol";
contract TransferHook is AbstractHook {
error TransferFailed();
error InsufficientAllocation();
constructor() {}
function execute(address, address _recipient, bytes32, bytes32, uint256 _allocatedamount, bytes memory _extra)
external
returns (uint256 _consumed)
{
uint256 _amount = abi.decode(_extra, (uint256));
bool _isWrappedToken = _distributor().isWrappedToken();
if (_amount > _allocatedamount) revert InsufficientAllocation();
if (_isWrappedToken) {
address _token = _distributor().token();
_distributor().hookTransfer(address(this), _amount);
IWithdrawable(_token).withdraw(_amount);
(bool success,) = payable(_recipient).call{value: _amount}("");
if (!success) revert TransferFailed();
} else {
_distributor().hookTransfer(_recipient, _amount);
}
return _amount;
}
receive() external payable {}
}
Other files
src/hook/AbstractHook.sol
// SPDX-License-Identifier: MIT pragma solidity 0.8.30; import {IHook} from "./IHook.sol"; import {IDistributor} from "../sub/IDistributor.sol"; abstract contract AbstractHook is IHook { function _distributor() internal view returns (IDistributor) { return IDistributor(msg.sender); } }src/hook/IHook.sol
// SPDX-License-Identifier: MIT pragma solidity 0.8.30; interface IWithdrawable { function withdraw(uint256 _wad) external; } interface IHook { function execute( address _vault, address _recipient, bytes32 _root, bytes32 _configurationId, uint256 _allocatedamount, bytes memory _extra ) external returns (uint256 _consumed); }src/sub/IDistributor.sol
// SPDX-License-Identifier: MIT pragma solidity 0.8.30; interface IDistributor { function hookTransfer(address _recipient, uint256 _amount) external; function token() external view returns (address); function isWrappedToken() external view returns (bool); function configurationIdCount(bytes32 _root) external view returns (uint256); function configurationIdAt(bytes32 _root, uint256 _index) external view returns (bytes32); function hasConfigurationId(bytes32 _root, bytes32 _configurationId) external view returns (bool); function getConfigurationIds(bytes32 _root) external view returns (bytes32[] memory); }
ABI · 5 entries
json
[
{
"type": "constructor",
"inputs": [],
"stateMutability": "nonpayable"
},
{
"name": "InsufficientAllocation",
"type": "error",
"inputs": []
},
{
"name": "TransferFailed",
"type": "error",
"inputs": []
},
{
"name": "execute",
"type": "function",
"inputs": [
{
"name": "",
"type": "address",
"internalType": "address"
},
{
"name": "_recipient",
"type": "address",
"internalType": "address"
},
{
"name": "",
"type": "bytes32",
"internalType": "bytes32"
},
{
"name": "",
"type": "bytes32",
"internalType": "bytes32"
},
{
"name": "_allocatedamount",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "_extra",
"type": "bytes",
"internalType": "bytes"
}
],
"outputs": [
{
"name": "_consumed",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "nonpayable"
},
{
"type": "receive",
"stateMutability": "payable"
}
]