ctx.accounts.fund.amount_raised is not updated inside the refund function.
ctx.accounts.fund.amount_raised is not updated inside the refund function. Because a contributor takes his contributions back from the fund, fund.amount_raised decreases, but this is not implemented inside the refund function.
By not updating the ctx.accounts.fund.amount_raised when a contributor takes his contributions from the fund, ctx.accounts.fund.amount_raised no longer tracks correctly the amount of SOL kept inside the fund at any given moment. Because ctx.accounts.fund.amount_raised is never decreased, once ctx.accounts.fund.amount_raised is messed up (by calling the refund function), ctx.accounts.fund.amount_raised is always greater than the actual SOL held inside the fund. When fund's creator tries to withdraw the SOL from the fund, the call to withdraw will error as the creator tries to withdraw ctx.accounts.fund.amount_raised, which is more than the SOL holdings of the fund. As a result, all the SOL remains stuck inside the fund forever.
Manual Review
Inside the refund function, decrease ctx.accounts.fund.amount_raised by amount, so that ctx.accounts.fund.amount_raised tracks correctly fund's holdings. The updated function should look like so:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.