" Lend and borrow peer-to-peer. No pools, no keepers, no CEX just SUI "
Rain is a fully on-chain, non-custodial peer-to-peer lending marketplace on Sui. It addresses “fake P2P” by removing reliance on centralized exchanges for rates and off-chain keeper bots for liquidations. Borrowers lock collateral in a Custody contract (user-owned vaults, no pooled liquidity). Interest rates and loan matching are discovered via DeepBook orderbooks on mainnet. Risk and liquidation eligibility use Pyth oracle prices only—not orderbook or other external price sources. Liquidations are executed on-chain: the LiquidationEngine gets authorization from an Adjudicator (evidence-based), then Custody releases collateral to the liquidator, who sells it on DeepBook. No protocol or admin key can unilaterally move user funds—only rule satisfaction or Adjudicator authorization. The system supports partial fills (borrow/lend orders filled in multiple matches; each match creates a LoanPosition; vault debt is the sum of positions). An Escrow flow lets lenders lock funds first so borrowers can complete the fill later without off-chain coordination. A browser-based frontend (Next.js + Sui dApp Kit) lets users create vaults, deposit collateral, submit and fill borrow/lend orders, repay, withdraw (via repayment auth + Custody release), use escrow fills, and liquidate unhealthy vaults. Contracts are deployed on Sui Testnet; DeepBook integration is designed for mainnet pool IDs; the current deployment on Sui Testnet uses testnet DeepBook pools. https://suiscan.xyz/testnet/object/0x40303a5f8f5e84d5769523dad6c5ca8334974112026eb3374572d8e25d8af01b/tx-blocks https://suiscan.xyz/testnet/object/0x46866743cab6b7174895be4848c598db76101dddef61962223971b853a3f0701/tx-blocks
We built Rain around a few core ideas. Partial fills are first-class: every order tracks how much is already filled, so one borrow can be filled by many lenders and one lend can match many borrowers in chunks; each chunk becomes its own loan position and the order stays on the book until it’s fully filled. Security is split by design: one module holds the collateral, another decides when it’s safe to release it (e.g. after repayment or for liquidation). No single component can move funds on its own—you need proof plus authorization. Async fills let lenders commit capital up front: they lock funds in an escrow with an expiry; the borrower can complete the fill later (same partial-fill logic), and if they don’t, the lender can cancel and get their funds back. The frontend is a modern React app that composes these flows—create then submit orders, request auth then withdraw, liquidate then sell collateral—and stays compatible with contract upgrades by using the original package for types and the latest for transactions. The partial fills, custody vs adjudicator separation, and lender-first escrow, all wired through a clean frontend.
Smart contracts: Ten Move modules in contracts/rain/sources/: UserVault (per-user state and accounting), LendingMarketplace (orderbook, partial fills, LoanPosition creation), DeepBookAdapter (thin wrapper over MystenLabs DeepBook v3 for swaps and order placement), RiskEngine (LTV and liquidation checks), OracleAdapter (Pyth price feeds via get_price_no_older_than), Custody (holds collateral; releases only on rules or Adjudicator authorization), Adjudicator (authorizes releases from evidence; no custody), LiquidationEngine (evidence → Adjudicator → Custody release → sell on DeepBook), Escrow (lender_commit_fill / borrower_complete_fill / lender_cancel_fill with expiry). Dependencies: DeepBook (git, rev deepbook3.1), Pyth (pyth-crosschain, Sui contracts, testnet rev) with Wormhole pinned to match Pyth’s resolution and avoid version conflicts. Frontend: Next.js 16, React 19, TypeScript. @mysten/dapp-kit and @mysten/sui for wallet connection and Transaction building; @pythnetwork/pyth-sui-js for Pyth price object IDs and feed bytes passed into fill/liquidation Move calls; TanStack React Query for caching and invalidation of vaults, orders, positions, fill requests. Config in lib/rain.ts: original vs latest package IDs (Sui upgrades keep struct types on original, entry points on latest), marketplace ID, Pyth SUI/USD object, DeepBook SUI/USDC pool and coin types. Custom hooks in useRainTransactions.ts construct single or multi-step Move calls (e.g. create order → submit order; request repayment auth → release to owner; liquidate → sell_collateral_and_settle). Notable: Custody + Adjudicator separation so no single key can move funds; escrow flow for async lender-first fills; frontend explicitly uses both package IDs for type queries vs transaction targets.

