Get duration
Get duration

Values · Reads onchain state

Converts a count of time units into seconds. Units are seconds, minutes, hours, days, weeks, months, and years; months are 30 days and years are 365. Reach for it to build a deadline offset from the current timestamp, to compare an elapsed delta against a required interval, or to size a cooldown for a stored timestamp check.

Get Price Running Total

plug
values
math
9actions
  1. 1·Take

    The plug opens by taking token, a parameter the caller supplies at execution time.

  2. 2·Take

    Next it declares today, another caller-supplied parameter naming the current reference point.

  3. 3·Take

    A third parameter, days_back, is taken from the caller to set how far the window reaches into the past.

  4. 4·Take

    It also takes price_running_total, a caller-supplied value to be extended by this run.

  5. 5·Get duration

    Step five converts the days_back count into seconds using the duration mechanism, producing a span in seconds.

  6. 6·Calculate

    Subtracting that span from today yields the start point of the lookback window.

  7. 7·Read nested map value

    Reading the socket's nested sma map, this step fetches the stored value keyed by token and by the computed window start.

  8. 8·Calculate

    Adding that fetched sma value to price_running_total accumulates the two into a new total.

  9. 9·Bubble

    Finally, the running total is surfaced as the output of this plug.

Take
Take
Take
Take
Get as seconds
Calculate
Read nested map value of in in
Calculate
Bubble
  • Get Price Running Total

    plug
    values
    math
  • Morpho: Get Borrow APR

    plug
    values
    math