Morpho: Borrow Shares to Borrow Assets
0x484428507A212cA56D71baa27Ca6089a6dB63a88

What this does

This plug converts a Morpho borrow share balance into a loan-asset amount using the protocol's virtual-offset rounding. 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 total assets and 1000000 to total shares before multiplying borrow_shares by virtual assets, dividing by virtual shares, and rounding up. Computing this by hand or against stale market totals 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