Swap is not repay: two ways a CDP took my coins
Ten months apart, two collateralised debt positions took my coins without a hack. On Sui, a redemption halved my position and raised my collateral ratio; on IOTA, I was liquidated within minutes while trying to leave. The arithmetic of both, and the order of operations I now follow.
Earlier this month I was liquidated. I wasn’t adding risk; I was taking it off, unwinding a position on IOTA one step at a time, and the position was gone within minutes of the step I took. Last December a different protocol, on Sui, took half of another position from me without my doing anything at all. Neither was a hack, a scam or a bug. In both cases the protocol did exactly what its documentation says it does, to someone who hadn’t worked through what that meant. Tonight I’m working through it.
One ratio
Both protocols are collateralised debt positions, CDPs. You lock a volatile coin as collateral and borrow a stablecoin against it. Everything about the position comes down to one number, the collateral ratio: the value of what you locked divided by what you owe. With n coins at price P and a debt of D stablecoins,
Each protocol sets a minimum, MCR; on both of the protocols in this post it is 110% [1] [2]. Below it, the position can be liquidated. People use these positions to borrow against coins they don’t want to sell, or, as I did, to loop: borrow the stablecoin, put it to work for a yield, and keep the coin’s upside.
Redemption: the peg’s backstop, paid for with your coins
In October last year I opened my first CDP, on Bucket, a stablecoin protocol on Sui. I locked SUI, borrowed its dollar coin, BUCK, at a collateral ratio of about 150%, well above the minimum, and staked the BUCK for a yield of 15 to 20% and points towards the protocol’s coming token. In late November I borrowed more, which took me to about 170%.
At the start of December, SUI had barely moved, but my position had shrunk. My debt had been cut roughly in half, a large part of my SUI had gone with it, and my collateral ratio had gone up. That was the clue. I had been redeemed.
Bucket’s design follows Liquity, a stablecoin protocol on Ethereum. Anyone holding BUCK can hand it to the protocol and receive one dollar’s worth of SUI per BUCK, at the oracle price, and the SUI is taken from borrowers’ positions “in ascending order of their collateralization ratio” [3]. The redeemer pays a fee of at least 0.5%, which rises when many people redeem at once [3] [4]. This is what holds the stablecoin’s price up: whenever BUCK trades below a dollar, buying it and redeeming it is a profit, and the buying pushes the price back. The cost of that floor is paid by whichever borrowers happen to be at the front of the queue.
The documentation is honest about what this does to the borrower: “you won’t incur a net loss but lose some SUI exposure. Your bottle’s collateral ratio will improve” [3]. Both halves are true, and the arithmetic shows why.
Redemption takes R dollars of debt and R dollars’ worth of collateral, at the oracle price P, from the same position:
In dollars, nothing was lost: I owed R less and held R less. The protocol even considers me safer. But I had not opened the position to hold dollars. I had opened it to hold SUI, and redemption is a forced sale of my SUI at the price on the day someone else chose. To get back to where I was, I had to buy the coins back, at whatever the price was when I did:
I rebuilt the position that afternoon, re-collateralised it twice more over the following months, and finally converted the last of my BUCK back into SUI in March. Every one of those conversions happened at whatever SUI cost that day, not at the price at which I had been redeemed. SUI was about $3.50 when I noticed; five weeks later it reached an all-time high of about $5.35 [5]. I didn’t add it up until this May, when I reconciled every transaction on a block explorer and found that nearly a fifth of my SUI had gone. There was no single moment of loss to notice. It leaked out through the round trips.
Liquidation: the exit is a trade too
The second lesson came on IOTA. In July, after IOTA’s new mainnet, a CDP called Virtue and a DEX called Pools launched together, and I built a loop: stake IOTA into stIOTA, lock stIOTA on Virtue, borrow its dollar coin VUSD, and provide stIOTA and VUSD as liquidity on Pools for the farming rewards. The parameters were familiar: a 110% minimum, and below it, a stability pool of VUSD repays the debt and takes the collateral [2].
I had thought about the risks. In August I worked out both of the loop’s failure bands: if IOTA ran above about $0.25, impermanent loss in the pool would eat the rewards; if it fell below about $0.14, the CDP would be in the same trouble as my Bucket position. What I hadn’t modelled was my own exit.
When I left the pool, I received stIOTA and VUSD. I swapped the VUSD into IOTA, because I wanted IOTA. That felt like closing the position. It wasn’t: the VUSD I owed Virtue was still owed. A swap is not a repayment. I had turned my loop into a plain leveraged long on IOTA, without meaning to, and left it there.
In the middle of this month I went to unwind what I thought was a small leftover. The first step I took was to withdraw collateral, and the app let me withdraw as much as the rules allowed, which is exactly the amount that leaves the position at the minimum:
The screenshot at the top of this post is my position just after that withdrawal: a collateral ratio of 110.10% against a minimum of 110.00%, with the liquidation price a hair below the market price. A position at exactly its minimum ratio survives only as long as the price doesn’t move against it at all. IOTA had been sliding since the crash of 10 and 11 October, when more than $19 billion of leveraged positions were liquidated across the market in a day, the largest such event on record [6], and it kept falling, below $0.13 at one point [7]. I had stepped away for a few minutes, waiting to take the next step. When I looked again, the position had been liquidated, and a third of my IOTA had gone with it.
Order of operations
The fix is simple to state, and I now write it down before every exit.
First, repay before you withdraw. Paying down the debt raises the collateral ratio; withdrawing lowers it. Doing them in the wrong order walks the position down to the edge, however briefly.
Second, a swap is not a repayment. If you borrowed a stablecoin, the debt is in that stablecoin, and it stays open until you return it to the protocol, whatever you do with the coins in between.
Third, check the ratio after every step, not just at the end. An exit is a sequence of transactions, and the riskiest moment of a position is often halfway out of it.
Fourth, anything with a loan in it needs watching. A redemption can come any day the stablecoin dips below its peg while your position is near the front of the queue, and the only defence is noticing in time. I was busy with exams and the lab, and in both cases I noticed late.
The real lesson is about the denomination. Both protocols measure everything in dollars, and in dollars, the redemption was fair and the liquidation followed the rules. I measure my holdings in coins, and in coins I lost a fifth of one position and a third of another. A CDP is a tool for people who think in dollars and borrow against coins. I have used it twice as someone who thinks in coins, and I won’t borrow again.
References
- Bucket Protocol. Borrowing. Documentation, archived 16 October 2024. web.archive.org.
- Virtue. Stability pool and liquidations. Documentation. docs.virtue.money.
- Bucket Protocol. Redemptions. Documentation, archived 3 December 2024. web.archive.org.
- Liquity. LUSD redemptions. Liquity v1 documentation. docs.liquity.org.
- CoinGecko. Sui historical data. coingecko.com.
- CoinDesk Research. Market spotlight: the $19 billion liquidation that shook crypto. 17 October 2025. coindesk.com.
- CoinGecko. IOTA historical data. coingecko.com.