A State's police agencies are not paid for enforcing federal law. Federal police, FBI and CBP officers are. In either case there must be probable cause for the arrest (a crime), not just that the person in question is undocumented. If an undocumented person is arrested, and federal agents want custody of the person. There should be a short amount of time for agents to take custody and the jail should be paid for with federal money to cover the cost of holding the person until the transfer occurs.