DOCS

How a deal works

A borrower locks tokens and names a buyback price and a term. A lender pays the loan in SOL. At the deadline the borrower pays the buyback price and takes the collateral back, or does nothing and the lender takes it. Everything below is generated from the program at 7c657b1.

THE FIVE STATES

OPEN
Collateral is in the vault. Terms are set, nobody has funded it, the borrower can cancel.
FUNDED
A lender has paid the loan. The deadline is now fixed and cannot move.
REPAID
The borrower paid the buyback price in time and took the collateral back. The account closed.
CLAIMED
The deadline passed with nobody coming back, and the lender took the collateral. The account closed.
CANCELLED
A deal was withdrawn before it was funded. The collateral went straight back. The account closed.

EVERY PARAMETER, AND ITS RANGE

TERMlib.rs:82
1D .. 90D
PROTOCOL FEElib.rs:27
0.50% OF THE LOAN
BUYBACK PRICElib.rs:80
MUST EXCEED THE LOAN
DEADLINElib.rs:181
FUNDED_AT + TERM, FIXED AT FUNDING
COLLATERALlib.rs:343
SPL OR TOKEN-2022

Refused Token-2022 extensions: TransferHook, ConfidentialTransferMint, ConfidentialTransferFeeConfig, ConfidentialMintBurn, PermanentDelegate.

THE ONLY TWO FORMULAS

WHAT THE BORROWER RECEIVES
loan_lamports - loan_lamports * 50 / 10000
lib.rs:149
WHAT THE BORROWER PAYS, UNTIL THE DEADLINE
buyback_lamports
lib.rs:202

Integer division floors, always in the borrower's favour on the fee. The fee is a constant in the program and cannot be changed.

WHAT THE ADMIN CAN DO

2 instructions: set_treasury and set_paused. Neither can touch locked collateral, a funded deal's SOL, or a deadline. There is no path from the admin to any deal that exists.

THE EXHAUSTIVE LIST, WITH LINE NUMBERS →

Put your own numbers through the same arithmetic in the simulator, see the settlement rule against real price history in the backtest, read what can still go wrong, and every open deal.