Interest rates are "floating," which mean that they are dynamic and updated instantly depending on demand. This also means that rates are never "locked-in" at the time of opening a position and may change over the course of it being open.
There are separate rates for borrowing and lending per asset. The rates move based on utilization, which is the ratio of "amount borrowed" to "amount lent." As utilization increases, the interest rate will increase to incentivize more lenders. As utilization decreases, the interest rate decreases.
How Often is Interest Paid?
Interest is paid continuously, so that you can close a position or withdraw funds at any time without worrying about a lock-up period. This also means that interest is continuously-compounding and all rates are in APR (with a higher percentage in APY).
How is Interest Rate Calculated?
Interest Rate for Borrowers
Interest rates are floating and are calculated based on the current utilization of the market. The utilization is the amount borrowed vs the amount lent for that particular market.
If the utilization is X, then the borrow interest is calculated as:
(0.10 * X) + (0.05 * X^4) + (0.15 * X^16) + (0.20 * X^32)
For example if the utilization is 50%, then the interest is:
(0.10 * 50%) + (0.05 * 50%^4) + (0.15 * 50%^16) + (0.20 * 50%^32) = 5.31% APR
Therefore, the borrow interest rate scales non-linearly from 0% to 50% APR.
Interest Rate for Lenders
Mathematically, the interest rate for lenders must be less-than-or-equal-to the interest rate for borrowers; interest payments cannot accrue from thin-air. 5% percent of all interest accrued on the platform goes towards an insurance fund that helps to insure the protocol in times of extreme volatility. In addition, since the interest rate from borrowers is prorated across all funds lent, if the borrow interest rate is B, then the lender interest is calculated as:
95% * (B * X)
Interest Rate for Traders
Since all collateral in dYdX earns interest continuously, it is possible that your collateral is earning more interest than your borrow is paying. This will show up as a negative interest rate paid when opening a new isolated margin-position.
Your interest rate shown is the current interest rate that you expect to pay relative to your borrowed amount. Since your collateral earns interest (and there may be different collateral amounts depending on your leverage), changing the leverage of your position (before opening it) may change the interest rate shown.