File 1 of 2: DistributeWrapper.sol
pragma solidity ^0.8.17;
import {ISplitMain} from "./interfaces/ISplitMain.sol";
contract DistributeWrapper {
error AmountNotPresent();
ISplitMain public immutable SPLIT_MAIN;
constructor(address _splitMain) {
SPLIT_MAIN = ISplitMain(_splitMain);
}
function distributeETH(
address _split,
address[] calldata _accounts,
uint32[] calldata _percentAllocations,
uint32 _distributorFee,
address _distributorAddress,
uint256 _amount
) external {
if (SPLIT_MAIN.getETHBalance(_split) < _amount) revert AmountNotPresent();
SPLIT_MAIN.distributeETH(_split, _accounts, _percentAllocations, _distributorFee, _distributorAddress);
}
function distributeERC20(
address _split,
address _token,
address[] calldata _accounts,
uint32[] calldata _percentAllocations,
uint32 _distributorFee,
address _distributorAddress,
uint256 _amount
) external {
if (SPLIT_MAIN.getERC20Balance(_split, _token) < _amount) revert AmountNotPresent();
SPLIT_MAIN.distributeERC20(_split, _token, _accounts, _percentAllocations, _distributorFee, _distributorAddress);
}
}
File 2 of 2: ISplitMain.sol
pragma solidity ^0.8.17;
interface ISplitMain {
event CreateSplit(
address indexed split,
address[] accounts,
uint32[] percentAllocations,
uint32 distributorFee,
address controller
);
event UpdateSplit(address indexed split, address[] accounts, uint32[] percentAllocations, uint32 distributorFee);
event InitiateControlTransfer(address indexed split, address indexed newPotentialController);
event CancelControlTransfer(address indexed split);
event ControlTransfer(address indexed split, address indexed previousController, address indexed newController);
event DistributeETH(address indexed split, uint256 amount, address indexed distributorAddress);
event DistributeERC20(
address indexed split, address indexed token, uint256 amount, address indexed distributorAddress
);
event Withdrawal(address indexed account, uint256 ethAmount, address[] tokens, uint256[] tokenAmounts);
function walletImplementation() external returns (address);
function createSplit(
address[] calldata accounts,
uint32[] calldata percentAllocations,
uint32 distributorFee,
address controller
) external returns (address);
function predictImmutableSplitAddress(
address[] calldata accounts,
uint32[] calldata percentAllocations,
uint32 distributorFee
) external view returns (address);
function updateSplit(
address split,
address[] calldata accounts,
uint32[] calldata percentAllocations,
uint32 distributorFee
) external;
function transferControl(address split, address newController) external;
function cancelControlTransfer(address split) external;
function acceptControl(address split) external;
function makeSplitImmutable(address split) external;
function distributeETH(
address split,
address[] calldata accounts,
uint32[] calldata percentAllocations,
uint32 distributorFee,
address distributorAddress
) external;
function updateAndDistributeETH(
address split,
address[] calldata accounts,
uint32[] calldata percentAllocations,
uint32 distributorFee,
address distributorAddress
) external;
function distributeERC20(
address split,
address token,
address[] calldata accounts,
uint32[] calldata percentAllocations,
uint32 distributorFee,
address distributorAddress
) external;
function updateAndDistributeERC20(
address split,
address token,
address[] calldata accounts,
uint32[] calldata percentAllocations,
uint32 distributorFee,
address distributorAddress
) external;
function withdraw(address account, uint256 withdrawETH, address[] calldata tokens) external;
function getHash(address split) external view returns (bytes32);
function getController(address split) external view returns (address);
function getERC20Balance(address account, address token) external view returns (uint256);
function getETHBalance(address account) external view returns (uint256);
}
{
"compilationTarget": {
"src/DistributeWrapper.sol": "DistributeWrapper"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": [
":ds-test/=lib/forge-std/lib/ds-test/src/",
":forge-std/=lib/forge-std/src/",
":solady/=lib/solady/src/",
":solmate/=lib/solmate/src/"
]
}