Inside the contribute function, contribution.amount is not updated after a contributor sends SOL to the chosen fund.
Inside the contribute function, a contributor sends SOL to the fund he has chosen to contribute to. The SOL transferred to the fund is correctly tracked in the fund and the fund's amount_raised is increased by amount:
However, the user contribution is not tracked in the contribution account of the user for the fund and contribution.amount remains the same, although the user contribution has increased.
Not updating contribution.amount inside the contribute function after a SOL contribution has been done, means that the contibutor would not be able to take the contributed SOL back (if he decides to do so) by calling the refund function - this is because contribution.amount is not updated in the contribute function. Thus, inside the refund function, the refund amount a contributor is eligible to take back will always be 0:
let amount = ctx.accounts.contribution.amount; //@audit -> amount will always be 0 here
As a result, the refund function is unusable, which makes part of protocol's functionality completely unusable.
Manual Review
Track the amount a user has contributed to a fund by updating contribution.amount of that user for the fund inside the contribute function. Fixed contribute function would 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.