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

    This step declares current_market as a caller-supplied parameter, the market whose borrow rate you want measured first.

  2. 2·Take

    A second parameter, target_market, is declared here so the caller names the market to compare against.

  3. 3·Get borrow rate

    Reading the borrow rate uses [the value in slot "0.0"], meaning current_market, and returns its per-second rate and APY.

  4. 4·Use

    This composes the Morpho: Get Borrow APR plug to turn the raw rate figures into an APR for the current market.

  5. 5·Set

    The result of that composition, [the value in slot "3.0"], is stored as current_apr for later comparison.

  6. 6·Get borrow rate

    Borrow rate is read again, this time for [the value in slot "1.0"], which is target_market, giving its per-second rate and APY.

  7. 7·Use

    The same Get Borrow APR plug runs again to convert the target market's rate into an APR.

  8. 8·Set

    That output, [the value in slot "6.0"], is saved as target_apr.

  9. 9·Use

    Composing the Morpho: Find Value Delta plug compares the two stored APRs to compute their difference and direction.

  10. 10·Set

    From the delta result, [the value in slot "8.0"] is stored as current_apr_is_higher, a flag for which market's APR is greater.

  11. 11·Set

    The magnitude of the difference, [the value in slot "8.1"], is saved as apr_delta.

  12. 12·Bubble

    Bubbling <={9.0} surfaces current_apr_is_higher as an output of this plug.

  13. 13·Bubble

    Finally, <={10.0} surfaces apr_delta as an output so callers can read the size of the gap.

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 · 4