Get borrow rate
Get borrow rate

Morpho · Reads onchain state

Reads a Morpho Blue market's current borrow rate as a per-second rate and an APY. The interest rate model's borrowRateView is evaluated on the market's live state at 18 decimals, and the action compounds it over a year into borrowApy. Reach for it to compare markets before borrowing, to gate a borrow on a maximum rate, or to weigh the cost against what borrowed funds will earn elsewhere.

Morpho: Find Borrow Rate Delta

plug
morpho
evm
13actions
  1. 1·Take

    First, the plug declares a parameter named current_market, whose value the caller supplies when running it.

  2. 2·Take

    Next, a second parameter named target_market is declared, again filled in by the caller at execution.

  3. 3·Get borrow rate

    Reading the current_market value from slot 0.0, this step fetches that Morpho Blue market's borrow rate as a per-second rate and an APY.

  4. 4·Use

    A nested plug, Morpho: Get Borrow APR, is composed here to convert the current market's borrow rate into an APR.

  5. 5·Set

    The APR produced by that composed plug, drawn from slot 3.0, is stored in the variable current_apr for later comparison.

  6. 6·Get borrow rate

    Turning to the target_market value in slot 1.0, this step reads that market's borrow rate the same way, per-second and APY.

  7. 7·Use

    The Get Borrow APR plug runs again, this time turning the target market's borrow rate into an APR.

  8. 8·Set

    That result from slot 6.0 is assigned to target_apr, giving the second value to compare.

  9. 9·Use

    With both APRs in hand, the Find Value Delta plug is composed to measure the difference between current_apr and target_apr.

  10. 10·Set

    From slot 8.0, the delta plug's judgment of whether the current APR is higher is saved into current_apr_is_higher.

  11. 11·Set

    Slot 8.1 carries the size of the difference, which is stored in apr_delta.

  12. 12·Bubble

    The current_apr_is_higher flag, wired from slot 9.0, is surfaced as an output of the plug.

  13. 13·Bubble

    Finally, apr_delta from slot 10.0 is bubbled up as the plug's second output.

Take
Take
Get borrow rate of
Use where
borrow_rate_per_secondis
Set to
Get borrow rate of
Use where
borrow_rate_per_secondis
Set to
Use where
value_1is
value_2is
Set to
Set to
Bubble
Bubble
  • Morpho: Find Borrow Rate Delta

    plug
    morpho
    evm

On other protocols · 3