
Morpho · Acts onchain
Withdraws lent loan asset and accrued interest from a Morpho Blue market. Morpho returns the exact asset amount to the socket, reporting assets and shares withdrawn, as long as the market has the liquidity. Pick Withdraw all to withdraw by shares, clearing the full supply exactly. Reach for it to exit a lending position or to pull the loan asset a following swap or deposit needs, coiling the amount forward.
Morpho: Refinance to Cheaper Borrow Market



1·Get market parameters
Reading the immutable parameters of Morpho Blue market 0x3a85...ee49 at 86% LLTV pulls in its loan token, collateral token, oracle, and fixed fields as the source market.
2·Get market parameters
Reading the parameters of Morpho Blue market 0x09dc...631c at 86% LLTV pulls in the same fields as the destination market the refinance moves into.
3·Take
The caller supplies minimum_apr_delta, the rate gap the refinance must clear before it fires.
4·Take
Taken next is minimum_health_factor, the floor the moved position's health must hold.
5·Take
Rounding out the inputs, liquidity_multiplier is taken from the caller to scale the destination market's required liquidity.
6·Use
Composing the Morpho Check Refinancing Constraints plug runs the rate, health, and liquidity tests using both markets and the three supplied parameters, returning a pass flag and the debt and supply figures.
7·Predicate
Requiring the pass flag at slot 5.0 equal true gates the whole flow, so it proceeds only when every refinancing constraint holds.
8·Flash loan
Taking a flash loan of the borrow amount at slot 5.1 in the source market's loan token from slot 0.0.0, fee-free and repaid within this transaction.
9·Repay
Repaying that borrow amount of loan-token debt to the source market from the socket balance clears the existing debt.
10·Withdraw
Withdrawing the supply amount at slot 5.3 from the source market recovers the lent loan asset back to the socket.
11·Supply
Supplying that same amount to the destination market lends the loan asset there to reestablish the position.
12·Borrow
Borrowing the flash-loan amount of loan token from the destination market against the supplied position funds repayment of the flash loan.
13·End block
Closing the innermost open block completes the composed refinance transaction.
On other protocols · 4