How Rayyan Works
The full lifecycle of capital through the protocol, with real numbers.
The two sides of the pool
- Liquidity providers supply USDC under a mudarabah (profit-sharing) arrangement. Their balance grows continuously as murabaha markup streams from active positions.
- Borrowers deposit collateral (WETH, WBTC) and receive USDC at a fixed contract price. This is a murabaha: the pool provides capital at a disclosed cost-plus-markup.
One pool, one contract type, and no interest anywhere in the system.
Step by step
1. A borrower opens a position
Amir deposits 5 WETH and requests 10,000 USDC. At that moment the protocol reads the current rate from the utilization curve, say 4.2%, and locks it for his position forever. The full markup for the maximum 360-day term is computed up front:
Full markup = 10,000 × 4.2% = 420 USDC
Contract price = 10,000 + 420 = 10,420 USDC ← the most Amir can ever owe
Settlement date = today + 360 daysAmir receives exactly 10,000 USDC. The contract price (10,420) is recorded as his debt, which means Compound V3's unmodified health-factor machinery protects the pool against his maximum obligation from day one. His health factor is constant over time and moves only with collateral price.
2. Markup accrues linearly and streams to LPs
Amir's cost grows in a straight line: 420 USDC ÷ 360 days ≈ $1.17/day, every day the same, never compounding.
| Day | Amir owes | Of which markup |
|---|---|---|
| 0 | 10,000.00 | 0 |
| 90 | 10,105.00 | 105 (exactly 90/360 of 420) |
| 180 | 10,210.00 | 210 |
| 360 | 10,420.00 | 420 (the cap, which it can never exceed) |
As it accrues, the markup streams to the pool's suppliers block-by-block through the same supply-index mechanism Aave and Compound use: 85% to LPs (the mudarabah profit-sharing ratio, flat from day one), the remainder to the protocol treasury. LPs watch their balance tick up every block. Each position's stream stops exactly at its settlement date, enforced by an on-chain expiration queue rather than an off-chain process.
3. Three ways to exit
a) Repay early → ibra' (automatic rebate). At day 90 Amir owes 10,105, and the unearned 315 of markup is forgiven rather than negotiated. The smart contract cannot charge him more than time held. This is the second leg of the embedded collar: if market rates dropped, Amir closes for the accrued amount and re-borrows at the new lower rate, free.
b) Unified close, paying with any mix of USDC and collateral. Amir owes 10,105 but only has 8,000 USDC in his wallet? One click: the RayyanCloser contract atomically borrows the shortfall from the Uniswap V3 WETH/USDC pool (a flash swap), repays his murabaha in full (ibra' applied), sells exactly 0.60 ETH of his released collateral to repay the pool, and returns the remaining 4.40 ETH to his wallet. One transaction; if any step fails, everything reverts and his position is untouched.
c) Do nothing → protocol settlement at day 360. Every murabaha has a maturity. When Amir opened the position he appointed Rayyan as his agent for this case, so if he never closes, the protocol's keeper sells enough collateral at market price to settle, charges an agency fee of 0.25% of the amount settled (26.05 USDC on 10,420), and returns the remainder to his wallet. The fee goes to the operator, never to depositors.
4. If collateral crashes
Health factor below 1.0 triggers Compound V3's native absorb() liquidation, with one Rayyan change: the collateral is credited against what the borrower owes after ibra', so the unearned markup is forgiven here too. The borrower is credited the collateral's value less the discount paid to whoever buys it (4.2% for WETH and WBTC), the protocol keeps none of that discount, and everything above the amount owed stays with the borrower.
(The live Sepolia deployment still runs the earlier terms, a 1.5% settlement fee on collateral value and liquidation at 93% against the full contract price, until the next deployment.)
5. LPs withdraw whenever they want
An 80% utilization cap guarantees at least 20% of the pool is always liquid, the on-chain equivalent of an Islamic bank's statutory liquidity reserve. The universal 360-day maturity guarantees every dollar of capital turns over at least once a year.
Where the yield comes from (and why it's backed)
LP yield is a claim against borrower debt secured by overcollateralized positions, exactly as on Aave/Compound, except that the total claim is known at borrow time (the contract price) rather than discovered through floating rates. Accounting identity, maintained by the contract and verified under fuzzing:
pool USDC + outstanding debt + protocol-owned collateral ≥ all LP claimsWhen Amir repays 10,105 at day 90: the pool sent out 10,000, got back 10,105, and exactly 105 was ever credited to LP + treasury claims. The forgiven 315 was never promised to anyone. Ibra' is solvency-neutral by construction.
What makes this murabaha, not a loan
- The total price is fixed at the moment of contract and can never increase, either for late payment or for market changes.
- The obligation has a settlement date, since every murabaha has a maturity.
- Nothing is ever added to the debt for late payment. Enforcement is via the pledge, and maturity settlement is an agency the borrower grants at signing.
- Early repayment triggers ibra', the rebate of unearned profit, enforced by code.
- LP returns are mudarabah: variable profit-sharing, never guaranteed.
Next: Rayyan vs. Aave →