(a) In all cases of mutual debts or mutual credits between the insurer and another person in connection with any action or proceeding under this article, the credits and debts shall be set off and the balance only shall be allowed or paid, except as provided in subsection (b), below.
(b) No setoff may be allowed in favor of any such person where:
(1) The obligation of the insurer to the person would not at the date of the entry of any liquidation order or otherwise, as provided in section twenty-five of this article, entitle him or her to share as a claimant in the assets of the insurer;
(2) The obligation of the insurer to the person was purchased by or transferred to the person with a view of its being used as a setoff;
(3) The obligation of the person is to pay an assessment levied against the members of a mutual insurer, or against the subscribers of a reciprocal insurer, or is to pay a balance upon the subscription to the capital stock of a stock insurer;
(4) The obligation of the insurer is owed to an affiliate of such person, or any other entity or association other than the person;
(5) The obligation of the person is owed to an affiliate of the insurer, or any other entity or association other than the insurer; or
(6) The obligations between the person and the insurer arise from transactions by which the person or the insurer assumed risk and obligations from the other party and ceded back substantially the same risks and obligations except the receiver may permit setoffs if in his or her discretion, a setoff is appropriate because of specific circumstances.
(c) Notwithstanding the provisions of subsection (b) of this section, a setoff of sums due on obligations in the nature of those set forth in subdivision (6), subsection (b) of this section shall be allowed for those sums accruing from business written where the contracts were entered into, renewed or extended with the approval of the commissioner of insurance of the state of domicile of the now insolvent insurer, when in the judgment of such commissioner it was necessary to provide reinsurance in order to prevent or mitigate a threatened impairment or insolvency of a domiciliary insurer in connection with the exercise of the commissioner's regulatory responsibilities.
(d) The provisions of this section shall supersede any agreements or contractual provisions which might be construed to enlarge the setoff rights of any person under any contract with the insurer.