ยง 3004. Where restoration of benefits before judgment unnecessary. A party who has received benefits by reason of a transaction that is void or voidable because of fraud, misrepresentation, mistake, duress, infancy or incompetency, and who, in an action or by way of defense or counterclaim, seeks rescission, restitution, a declaration or judgment that such transaction is void, or other relief, whether formerly denominated legal or equitable, dependent upon a determination that such transaction was void or voidable, shall not be denied relief because of a failure to tender before judgment restoration of such benefits; but the court may make a tender of restoration a condition of its judgment, and may otherwise in its judgment so adjust the equities between the parties that unjust enrichment is avoided.