
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



1·Take
Take token as a named parameter supplied by the caller at execution time, identifying which token this run concerns.
2·Take
Declare today as a caller supplied parameter, the reference point in time for this run.
3·Take
Bring in days_back as a parameter the caller provides, a count of days used later.
4·Take
Accept price_running_total as a caller supplied parameter, the value to be extended in this run.
5·Get duration
Convert [the days_back value] into seconds by treating it as a count of days and multiplying by 0x015180.
6·Calculate
Subtract [that seconds duration] from [the today value], producing an earlier point in time.
7·Read nested map value
Read a value from the two level map named sma in socket storage, keyed first by [the token] and then by [the computed earlier time].
8·Calculate
Add [the value read from sma] to [the price_running_total], extending the total.
9·Bubble
Surface [the resulting sum] as the output of this plug.