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

    Declares token, a named parameter the caller supplies at execution time.

  2. 2·Take

    Declares today, a caller-supplied parameter, at execution time.

  3. 3·Take

    Adds days_back as a named parameter the caller provides when running.

  4. 4·Take

    Declares price_running_total, the final caller-supplied parameter.

  5. 5·Get duration

    Converts days_back into seconds using the fixed multiplier 0x015180, producing that span in seconds.

  6. 6·Calculate

    Subtracts the day-span-in-seconds from today, yielding an earlier timestamp.

  7. 7·Read nested map value

    Reads the nested map value keyed by token and the earlier timestamp from sma in socket storage.

  8. 8·Calculate

    Adds the stored sma value to price_running_total, accumulating the running total.

  9. 9·Bubble

    Surfaces the accumulated running total as this plug's output.

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

    plug
    values
    math