
Morpho · Acts onchain
Borrows any token the Morpho Blue singleton holds, fee-free, repaid inside this transaction. The action opens a block: the steps inside spend the borrowed funds, and before the block ends the socket must hold the principal, surfaced as the owed output, or the whole transaction reverts. Repayment approval is handled here. There is no premium and no market to choose, only the token. Reach for it to refinance debt across protocols with no capital, to unwind a leveraged position by repaying before withdrawing collateral, or to fund an arbitrage across venues.
Morpho: Auto Leverage Trigger



1·Take
The caller supplies account at execution time, declared here as a named parameter for later steps to reference.
2·Take
A market parameter is declared, its value provided by the caller when the plug runs.
3·Take
triggerLTV is taken as a caller supplied value, the LTV threshold at which this plug should act.
4·Take
targetLTV is declared as a caller supplied value, the LTV the position should be moved toward.
5·Take
maxSlippage enters as a named parameter set by the caller at execution time.
6·Take
numChunks is declared as a caller supplied parameter for later use.
7·Get market parameters
Reading the Morpho Blue market at the identifier in the market slot pulls in its immutable configuration.
8·Get account data
Your position in that market is read for the loan asset from slot 6.0.0, returning shares, collateral, debt, and health factor.
9·Get price
The oracle price of the collateral in slot 6.0.1 is read in the loan asset for that market.
10·Calculate
Slot 7.11.2 is multiplied by the position data from slot 8.5, producing a scaled quantity.
11·Calculate
Slot 7.19 is divided by the oracle price, converting a value into price adjusted terms.
12·Compare two values
A comparison checks whether the product from step 10 equals 0, returning a boolean.
13·Predicate
This predicate requires that the quotient from step 11 is not equal to 0, since the target is false, halting if it does equal 0.
14·Calculate
The triggerLTV is multiplied by the oracle price, scaling the threshold against the current price.
15·Compare two values
A comparison tests whether the product from step 10 is less than the value in the market slot 2.0.
16·Compare two values
Another comparison checks whether the triggerLTV scaled result from slot 13.0 is greater than slot 7.19.
17·Predicate
This predicate requires slot 14.0 and slot 15.0 to both hold, gating execution on both conditions being true.
18·Calculate
Slot 7.19 is subtracted from the triggerLTV scaled value in slot 13.0, giving a difference.
19·Calculate
Slot 3.0 is subtracted from 1, computing the complement of the triggerLTV.
20·Calculate
The difference from step 17 is divided by the difference from step 18, producing a ratio.
21·Calculate
maxSlippage is floored at 1, clamping it to a minimum of that raw base unit value.
22·Calculate
The complement from step 19 is divided by the ratio from step 20, yielding a sizing figure.
23·Flash loan
A flash loan of the amount from slot 21.0 is drawn in the loan asset from slot 6.0.0, borrowed fee free and repaid within this transaction.
24·Calculate
The flash loaned amount from slot 22.0 is divided by the position data in slot 8.5.
25·Calculate
The targetLTV is subtracted from 1, computing its complement.
26·Calculate
The flash loan sizing from slot 23.0 is multiplied by the targetLTV complement, producing a collateral amount.
27·Use
Composing the Swap at Floor plug pulls its swap logic into this transaction.
28·Supply Collateral
The swapped output from slot 26.0 is supplied as collateral in the collateral asset from slot 6.0.1 to the market.
29·Borrow
The amount from slot 22.0 is borrowed in the loan asset from slot 6.0.0 against the supplied collateral, funding the flash loan repayment.
30·End block
The open block is closed here, ending the gated sequence.
On other protocols · 2