Sorry if this question is a little too basic but what determines repo rates? Not like "they are OTC transactions so they are determined directly between counterparties" but like what is the way you would approach calculations?
Take a bond priced $100$ at time $t=0$. Basic examples would say that party A lends party B the bond in exchange for $100$ now and repurchase the bond at $98$ later, for a repo margin of $2$. But how did $2$ arise; how did part B decide the appropriate return for this transaction was $2$? For example, is it because the risk-free is at $2\%$ so that's the return you would earn from investing the $100$, and therefore you're NPV zero in this transaction? How does the bond coupon tie into the calculation, since as a bond lender I assume you're receiving coupons?
Add on the scenario of an environment of rising yields like recently. Repo rates were observed to go down (at least for my region). Why did it go down? I tried to explain it with this made up theory: party B is going to be buying back a bond for $98$ that may only be worth $96$ after the selloff. Therefore he doesn't want to pay such a large haircut of $2$.
Can someone demonstrate with an example plz.