If anyone sent token to the implementation(Distributor) by mistake can contact the owner of the contracts ProxyFactory to rescue the funds.
The owner with the distributeByOwner
rescue the stuck funds but this charge fees(0.05%) that are sent to the STADIUM_ADDRESS
pragma solidity 0.8.18;
import {Test} from "forge-std/Test.sol";
import {ProxyFactory} from "../../src/ProxyFactory.sol";
import {MockERC20} from "../mock/MockERC20.sol";
import {Distributor} from "../../src/Distributor.sol";
contract PoC is Test {
bytes32 idAlice = keccak256("Alice");
address alice = address(uint160(uint256(idAlice)));
address feeReceive = address(123);
MockERC20 token = new MockERC20("", "");
ProxyFactory proxyFactory;
Distributor distributor;
address calculatedProxyAddress;
function setUp() public {
MockERC20(token).mint(alice, 110 ether);
address[] memory tokensToWhitelist = new address[](1);
tokensToWhitelist[0] = address(token);
proxyFactory = new ProxyFactory(tokensToWhitelist);
distributor = new Distributor(address(proxyFactory), feeReceive);
proxyFactory.setContest(alice, idAlice, block.timestamp, address(distributor));
bytes32 salt = keccak256(abi.encode(alice, idAlice, address(distributor)));
calculatedProxyAddress = proxyFactory.getProxyAddress(salt, address(distributor));
vm.prank(alice);
MockERC20(token).transfer(calculatedProxyAddress, 10 ether);
address[] memory winners = new address[](1);
winners[0] = address(666);
uint256[] memory percentages = new uint256[](1);
percentages[0] = 9500;
bytes memory data = abi.encodeWithSelector(Distributor.distribute.selector, address(token), winners, percentages, "");
vm.prank(alice);
proxyFactory.deployProxyAndDistribute(idAlice, address(distributor), data);
}
function test() public {
vm.prank(alice);
MockERC20(token).transfer(calculatedProxyAddress, 100 ether);
vm.warp(proxyFactory.EXPIRATION_TIME() + 1);
address[] memory winners = new address[](1);
winners[0] = address(alice);
uint256[] memory percentages = new uint256[](1);
percentages[0] = 9500;
bytes memory data = abi.encodeWithSelector(Distributor.distribute.selector, address(token), winners, percentages, "");
proxyFactory.distributeByOwner(calculatedProxyAddress, alice, idAlice, address(distributor), data);
assertEq(token.balanceOf(alice), 100 ether, "The balance of alice has to be the one she sent by mistake");
}
}