How to write a financial contract