To change what stands behind it you have to repay it — and the money to repay it is exactly what you do not have, because you borrowed it. Kedge borrows the repayment for the length of one transaction: your old collateral comes out, is sold, the new one is bought and pledged, and the same dollars are borrowed straight back against it. The debt that comes out is the debt that went in.
That is not a flaw in Morpho; it is what makes the loan safe. But it means every ordinary way of changing your mind needs money you do not have — and the two ways round it both cost you something real.
Repay the loan out of your own pocket, swap the collateral, pledge it again and borrow again. It works, and it needs the whole debt in dollars, sitting idle, for as long as the four transactions take.
Sell part of the collateral to repay, then buy the new one with what is left. You end up with a smaller position than you started with, and you have paid the spread on the part you sold twice over.
Morpho will lend anyone the dollars for the length of one call, as long as they come back before it ends. That is the whole trick: the repayment is borrowed, used, and handed back inside a single transaction.
This is the whole bundle. It is sent to Bundler3 — Morpho's own batching contract — and every call in it is to a contract that was already live on this chain before Kedge existed. Kedge deploys nothing.
morphoFlashLoan takes the debt, plus a small
cushion for the interest that accrues while the transaction waits, out of Morpho's own
idle dollars. Everything below happens inside that call.
The permission is temporary. Steps 3 and 5 act on your position, so Morpho wants
an authorisation. Rather than leaving one standing, the bundle carries two signatures
over consecutive nonces: it grants the permission in its first call and revokes it in
its last. After the transaction, isAuthorized is false again — the fork
suite asserts exactly that after every move it makes.
One of them is money that is gone. The other is an opinion held by two price feeds. Kedge shows them separately, because adding them together would flatter every move on this chain.
Two pool fees and the price your own size moves, measured against the same two pools at their mid price. Kedge prices it by simulating the pools exactly — the same arithmetic the pool runs, in the page, over the tick data it has actually read — so the number is not an estimate from a formula. It is never negative, and it is the money you do not get back.
Morpho values collateral from an oracle, not from a pool, and on this chain the two do not always agree. Arriving in a market whose oracle sits above its pool gives the position more borrowing power than you paid for. That is worth knowing and it is not profit, so it is reported on its own line.
The worked example above, against every market with enough left to lend and a pool to trade through. Cheapest first.
| Move into | To trade | At the oracles | Rate you would pay | Liquidation |
|---|---|---|---|---|
| reading the chain… | ||||
Every Morpho market here prices borrowing off how full it is. These markets are small, so a loan arriving in one is not a rounding error — it is the thing that sets the rate.
Kedge answers that with a line-by-line port of Morpho's Adaptive Curve IRM, taken from the verified source of the contract deployed on this chain. Because the port takes the market state as an argument, it can be asked about a state that has not happened yet: what will this market charge once my loan is in it? The scan checks the port against the deployed model on every market it lists, and the answers have to agree to the unit.
The market you leave is reported too. A loan going out of a small market lowers the rate for everyone still borrowing there, and that is part of an honest picture of a move.
Markets lend at different thresholds — 62.5% against some stocks here, 38.5% against others. The same debt against the same value of collateral can be comfortable in one and close to the edge in another. Kedge shows the liquidation price on both sides and refuses any move that would land above 90% of the destination's threshold.
The whole move goes through them twice. Kedge prices every pool a stock trades in, at your size, and refuses a hop it cannot price from the tick data it has read rather than guessing at the depth beyond it. The transaction carries one floor, on the collateral that comes out the far end.
Your debt is borrowed again on arrival, so a market with less left to lend than you owe cannot take you, however good it looks. Every row on the board is checked against that first, and the ones that fail say so instead of disappearing.
Every market's oracle is checked against a Uniswap pool for the same stock, and one that disagrees by more than 25% is marked suspect and never offered as a destination. A market's own oracle cannot corroborate itself.
Kedge does not decide what you should be long of. It prices the change you are considering and sends it as one transaction instead of four.
No contract of ours is deployed, no balance of yours passes through anything we own, and no permission is left standing afterwards. If this site went dark tomorrow your position would be exactly where you left it, in Morpho.
The same record, as the suites wrote it: /js/proof.json — built from the results files and nothing typed in.