Morpho: Borrow Shares to Borrow Assets
0x484428507A212cA56D71baa27Ca6089a6dB63a88

What this does

This plug converts a Morpho Blue borrow-share balance into a loan-asset amount by applying the market's virtual-asset and virtual-share offsets. It asks the caller for borrow_shares, total_borrow_assets, and total_borrow_shares at execution time. It runs whenever those three figures are supplied, adding 1 to the asset total and 1000000 to the share total before multiplying borrow_shares by virtual_assets, dividing by virtual_shares, and rounding up. Computing this by hand or on a stale total_borrow_assets or total_borrow_shares yields a borrow-asset figure that misstates the debt owed.

Actions · 7

  • Calculate
    Calculate
    Applies a binary arithmetic operation to two values and returns the result.
  • Set
    Set to
    Assigns a value to a named variable that later steps reference.
  • Calculate
    Calculate
    Applies a binary arithmetic operation to two values and returns the result.
  • Set
    Set to
    Assigns a value to a named variable that later steps reference.
  • Multiply then divide
    Calculate times divided by rounded
    Multiplies two values and divides by a third in one step, rounding up or down.
  • Set
    Set to
    Assigns a value to a named variable that later steps reference.
  • Bubble
    Bubble
    Surfaces a value as an output of this plug.

Related plugs · 8