Fully repaying a loan will result in debt payment being lost
When a `loan` is fully repaid the `loan` `storage` is deleted. Since `loan` is a `storage` reference to the `loan`, `loan.lender` will return `address(0)` after the `loan` has been deleted. This will result in the `debt` being transferred to `address(0)` instead of the lender. Some ERC20 tokens will revert when being sent to `address(0)` but a large number will simply be sent there and lost forever.\\n```\\nfunction repay (uint256 loanID, uint256 repaid) external {\\n    Loan storage loan = loans[loanID];\\n\\n    if (block.timestamp > loan.expiry) \\n        revert Default();\\n    \\n    uint256 decollateralized = loan.collateral * repaid / loan.amount;\\n\\n    if (repaid == loan.amount) delete loans[loanID];\\n    else {\\n        loan.amount -= repaid;\\n        loan.collateral -= decollateralized;\\n    }\\n\\n    debt.transferFrom(msg.sender, loan.lender, repaid);\\n    collateral.transfer(owner, decollateralized);\\n}\\n```\\n\\nIn `Cooler#repay` the `loan` storage associated with the loanID being repaid is deleted. `loan` is a storage reference so when `loans[loanID]` is deleted so is `loan`. The result is that `loan.lender` is now `address(0)` and the `loan` payment will be sent there instead.
Send collateral/debt then delete:\\n```\\n-   if (repaid == loan.amount) delete loans[loanID];\\n+   if (repaid == loan.amount) {\\n+       debt.transferFrom(msg.sender, loan.lender, loan.amount);\\n+       collateral.transfer(owner, loan.collateral);\\n+       delete loans[loanID];\\n+       return;\\n+   }\\n```\\n
Lender's funds are sent to `address(0)`
```\\nfunction repay (uint256 loanID, uint256 repaid) external {\\n    Loan storage loan = loans[loanID];\\n\\n    if (block.timestamp > loan.expiry) \\n        revert Default();\\n    \\n    uint256 decollateralized = loan.collateral * repaid / loan.amount;\\n\\n    if (repaid == loan.amount) delete loans[loanID];\\n    else {\\n        loan.amount -= repaid;\\n        loan.collateral -= decollateralized;\\n    }\\n\\n    debt.transferFrom(msg.sender, loan.lender, repaid);\\n    collateral.transfer(owner, decollateralized);\\n}\\n```\\n