// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; /// @title Payroll disperser for $THUNDARC on Arc. /// Sends the chain's native asset (USDC on Arc) or any ERC20 to many recipients in one transaction. /// No owner, no admin, no storage. Anyone can use it. It never holds funds. interface IERC20 { function transferFrom(address from, address to, uint256 value) external returns (bool); } contract Payroll { event Paid(address indexed payer, uint256 recipients, uint256 total); /// Native USDC. msg.value must equal the sum of values. Leftover is refunded. function payNative(address[] calldata recipients, uint256[] calldata values) external payable { require(recipients.length == values.length, "length"); uint256 total; for (uint256 i = 0; i < recipients.length; i++) { (bool ok, ) = recipients[i].call{value: values[i]}(""); require(ok, "send failed"); total += values[i]; } require(total <= msg.value, "value"); if (msg.value > total) { (bool r, ) = msg.sender.call{value: msg.value - total}(""); require(r, "refund"); } emit Paid(msg.sender, recipients.length, total); } /// Any ERC20 (approve this contract first). function payToken(IERC20 token, address[] calldata recipients, uint256[] calldata values) external { require(recipients.length == values.length, "length"); uint256 total; for (uint256 i = 0; i < recipients.length; i++) { require(token.transferFrom(msg.sender, recipients[i], values[i]), "transfer failed"); total += values[i]; } emit Paid(msg.sender, recipients.length, total); } }