Read nested map value
Read nested map value

Database · Acts onchain

Reads a value from a two-level keyed map in the socket's persistent storage. The outer and inner keys are both bytes32, so any values can serve, such as user then token. Scope chooses socket storage, shared by every plug the socket runs, or plug storage, private to this plug bundle. The read returns the committed value. Reach for it for two-dimensional records like per-user-per-token balances or per-market-per-interval history, then branch on the result with a predicate.

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