Read map value
Read map value

Database · Acts onchain

Reads a value from a keyed map in the socket's persistent storage. The map and key are both bytes32, so any value can serve as the key: a token address, a user address, an interval bucket. 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 to keep per-token or per-user records across executions, such as the last price seen for each asset, and branch on them with a predicate in the same transaction.

Set SMA Weight

plug
database
5actions
  1. 1·Take

    First the plug declares a caller-supplied parameter named index, whose value arrives at execution time.

  2. 2·Take

    Next it declares a second caller-supplied parameter named sma_window, also filled in by the caller when the plug runs.

  3. 3·Read map value

    Reading from the socket's persistent storage, this step looks up the tokens map using the key held in slot 0.0, which is the index parameter, and returns the stored value for that key.

  4. 4·Use

    Then it composes the plug Get Weight Target inside this one, running its logic as part of this transaction.

  5. 5·Set map value

    Finally it writes into the weights map in socket storage, using the index parameter as the key and setting the entry to the value produced in slot 3.0 by the composed Get Weight Target plug.

Take
Take
Read map value of in in
Use where
tokenis
windowis
Set map value of in in to
  • Set SMA Weight

    plug
    database
  • Raw Weights to Percents

    plug
    evm
    boolean
  • Rebalance Holdings to Target

    plug
    values
    evm
  • Get Token Target

    plug
    database
    evm
  • Get Total Holdings Value

    plug
    evm
    boolean