
Morpho · Acts onchain
Repays loan-asset debt to a Morpho Blue market from the socket's balance. The socket approves Morpho and repays the exact asset amount; the call returns the assets and shares repaid. Set the amount to max to repay by shares, clearing the full debt exactly with interest, with the approval reset afterward. Reach for it to clear debt before withdrawing collateral, to restore health when the position read shows it slipping, or to settle the borrow leg after a swap has produced the loan asset.
Morpho: Refinance to Cheaper Borrow Market



1·Get market parameters
Reading the Morpho Blue market at 0x3a85...ee49 pulls in its immutable parameters, the source market carrying an 86 percent liquidation threshold.
2·Get market parameters
Reading the second Morpho Blue market at 0x09dc...31c1 pulls in its immutable parameters, the destination market also carrying an 86 percent liquidation threshold.
3·Take
The caller supplies minimum_apr_delta at execution time, declared here as a named parameter for the refinancing check to reference.
4·Take
Declared next is minimum_health_factor, its value provided by the caller when the plug runs.
5·Take
Also taken from the caller is liquidity_multiplier, a named parameter for later use.
6·Use
Composing the Morpho Check Refinancing Constraints plug pulls its logic into this one, evaluating the two markets against the supplied thresholds and returning the values consumed below.
7·Predicate
This predicate requires that the boolean in slot 5.0 equals true, gating everything that follows on the refinancing check passing.
8·Flash loan
A flash loan draws the amount in slot 5.1 in the loan asset from slot 0.0.0, borrowed fee free and repaid within this transaction.
9·Repay
The flash loaned amount is repaid as debt in the loan asset from slot 0.0.0 to the source market, clearing the position there.
10·Withdraw
Withdrawing the amount in slot 5.3 in the loan asset from slot 0.0.1 pulls lent principal and accrued interest out of the source market.
11·Supply
The withdrawn amount is supplied in the loan asset from slot 1.0.1 to the destination market, moving the lent position across.
12·Borrow
Borrowing the amount in slot 5.1 in the loan asset from slot 1.0.0 against the supplied position in the destination market funds the flash loan repayment.
13·End block
The open block is closed here, ending the gated refinancing sequence.
On other protocols · 4