This plug reads the latest Chainlink USD price of a token, stores it keyed by the current day in socket storage, then sums the stored daily prices across a window and divides to return a simple moving average. It asks the caller for a token address and a window count of days. It runs each time it is called, recording one day's price and recomputing the average. Computing this by hand means reading each daily Chainlink price and dividing manually, and a stale stored price skews the average.
Actions · 15
Getcurrenttimestamp
Returns the current block timestamp as Unix seconds.
Getstartofcontaining
Returns the start timestamp of the hour, day, week, or larger interval containing a timestamp.
Getpriceofin
Reads the latest Chainlink price of a base asset in a quote asset, normalized to 18 decimals.
Setnestedmapvalueofininto
Writes a value into a two-level keyed map in the socket's persistent storage.
Setto
Assigns a value to a named variable that later steps reference.
Setto
Assigns a value to a named variable that later steps reference.
Steers control flow by comparing two values: branch, loop, or require the condition holds.
Usewhere
tokenis
todayis
days_backis
price_running_totalis
Composes another plug inside this one.
Setto
Assigns a value to a named variable that later steps reference.
Calculate
Applies a binary arithmetic operation to two values and returns the result.
Setto
Assigns a value to a named variable that later steps reference.
Endblock
Closes the innermost open block, whether a conditional branch or a loop.
Calculate
Applies a binary arithmetic operation to two values and returns the result.
Bubble
Surfaces a value as an output of this plug.
Bubble
Surfaces a value as an output of this plug.
Related plugs · 8
Not ready to run as it stands: it waits on values or a position of your own.