Pavel.

Writing

Notes & essays

Thinking out loud about engineering, design, and the craft of building things that last.

The coefficient that wouldn't stay small: socializing bad debt across many tokens

1 July 2026

A companion to the Marginly math. Spreading one borrower's bad debt across a whole pool collapses, in the single-token case, into a tidy 2×2 coefficient you apply globally — the same scaled-balance trick. With many tokens at different prices it looks like it balloons into an ever-growing tensor. It doesn't have to: with the right state it stays a finite matrix — just no longer a tidy one.

12 min read/math, defi, equilibrium, marginly

From a socket to a SNARK: proving the bailsmen payout instead of redoing it

25 June 2026

The second post in my zero-knowledge series. I take the problem that sent me looking — Equilibrium's bailsmen payout, which meant looping over every user on-chain — and hand it to a real proof system: a Groth16 SNARK in Rust. It works, a cheating prover gets caught, and the off-chain dream half-comes-true in an instructive way.

11 min read/zk, cryptography, rust, equilibrium

Zero-knowledge from scratch: commitments, and two programs arguing over a socket

20 June 2026

How I started learning zero-knowledge proofs at the end of 2022 — building Pedersen commitments and interactive Sigma protocols by hand in Rust, as a prover and a verifier shouting numbers across a TCP socket. The first in a series that ends at modern proof systems; including the cryptographic flaw my younger self happily shipped.

11 min read/zk, cryptography, rust

Deleverage coefficients: the math behind Marginly

15 June 2026

Deriving Marginly's deleverage coefficients with linear algebra — an extra coefficient on top of the scaled-balance trick Aave already uses, and why the whole thing collapses into a few numbers you can update in O(1).

10 min read/math, defi, marginly

From heuristics to MILP: rebuilding the Levva liquidity balancer

11 June 2026

Reworking Levva's vault liquidity balancer from an earlier C# heuristic into a Rust solver that works out — globally, in one pass — exactly how much to move along each route. Modeled as flows on a graph and solved as a MILP; the moves come out cheapest as a bonus.

13 min read/algorithm, rust, defi, levva