
Time · Reads onchain state
Returns the current block timestamp as Unix seconds. This is the time the plug executes at, as the chain sees it. Reach for it to stamp a stored record of when a step ran, to compute intervals against earlier timestamps, or to set a deadline offset for a later step.
Takes nothing — it reads the caller's own position.
Get Simple Moving Average



1·Take
The caller supplies a token as a named parameter, declared here so later steps can reference it.
2·Take
A window parameter is declared next, its value provided by the caller at execution time.
3·Get current timestamp
The current block timestamp is read as Unix seconds.
4·Get interval start
This computes the start of the 1 day interval containing the window value from slot 2.0, snapping that timestamp to a day boundary.
5·Get price
A Chainlink read fetches the latest price of the token in USD, normalized to 18 decimals.
6·Set nested map value
The fetched price from slot 4.7 is written into the sma nested map in socket storage, keyed by the token and the day start from slot 3.0.
7·Set
A variable named day_index is initialized to 0 to serve as a loop counter.
8·Set
Another variable, total, is set to 0 to accumulate a running sum.
9·Predicate
A loop predicate runs while day_index is less than the window value, controlling how many iterations execute.
10·Use
Inside the loop, the Get Price Running Total plug is composed to produce a value.
11·Set
The total variable is assigned the result returned by that composed plug from slot 9.0.
12·Calculate
Arithmetic adds 1 to day_index.
13·Set
The incremented result is written back into day_index, advancing the loop.
14·End block
The loop block is closed here.
15·Calculate
Once the loop ends, total is divided by the window value to compute the average.
16·Bubble
The averaged result from slot 14.0 is surfaced as an output.
17·Bubble
The stored price from slot 4.7 is also surfaced as an output.