Withdraw
Withdraw

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. Set the amount to max 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

morpho
plug
boolean
13actions
  1. 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. 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. 3·Take

    The caller supplies minimum_apr_delta at execution time, declared here as a named parameter for the refinancing check to reference.

  4. 4·Take

    Declared next is minimum_health_factor, its value provided by the caller when the plug runs.

  5. 5·Take

    Also taken from the caller is liquidity_multiplier, a named parameter for later use.

  6. 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. 7·Predicate

    This predicate requires that the boolean in slot 5.0 equals true, gating everything that follows on the refinancing check passing.

  8. 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. 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. 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. 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. 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. 13·End block

    The open block is closed here, ending the gated refinancing sequence.

Get market parameters of
Get market parameters of
Take
Take
Take
Use where
current_marketis
target_marketis
minimum_apr_deltais
minimum_health_factoris
liquidity_multiplieris
Flash loan
Repay to
Withdraw from
Supply to
Borrow from
End block
  • Morpho: Refinance to Cheaper Borrow Market

    morpho
    plug
    boolean

On other protocols · 5