Lending Transactions: Legal Structures and Risk Allocation