Set
Set

Ethereum Virtual Machine · Acts onchain

Assigns a value to a named variable that later steps reference. The value is echoed into a slot bound to the name. Reassignment is by reference, never by name: coil the earlier variable's name input into this action's name slot to write the same slot, so a variable initialized before an if/else and reassigned in each branch carries the branch's value forward. Two Sets that merely type the same name literal are two independent slots; the name is a label, not an identity. Reach for it to give a computed amount or address a stable handle, or to merge results from divergent branches into one value the rest of the plug consumes.

Raw Weights to Percents

plug
evm
boolean
18actions
  1. 1·Take

    Take declares a parameter named count that the caller supplies when running the plug; it sets the bound the loops will run against.

  2. 2·Set

    Total is initialized to 0, giving a running accumulator that later steps add into.

  3. 3·Set

    Index is set to 0, creating a counter that the first loop will step through.

  4. 4·Predicate

    A loop opens that keeps running while index is less than count, iterating over the entries the caller asked for.

  5. 5·Read map value

    Inside the loop, the map value at index in the weights map is read from socket storage.

  6. 6·Calculate

    That read weight is added to the current total using addition.

  7. 7·Set

    Total is reassigned to the sum from the previous step, folding this weight into the running total.

  8. 8·Calculate

    Index is incremented by adding 1 to it.

  9. 9·Set

    The counter is updated to the incremented value, advancing to the next entry.

  10. 10·End block

    This closes the first loop, which has now summed every weight into total.

  11. 11·Set

    Before the second pass, index is reset to 0 to walk the same entries again.

  12. 12·Predicate

    A second loop opens with the same condition, running while index is less than count.

  13. 13·Read map value

    Again the weight at index is read from the weights map in socket storage.

  14. 14·Multiply then divide

    The read weight is multiplied by 100 and divided by total, rounding down, producing that weight's percent share.

  15. 15·Set map value

    The computed percent is written back into the weights map at index in socket storage, overwriting the raw weight.

  16. 16·Calculate

    Index is incremented by 1.

  17. 17·Set

    The counter takes the incremented value, moving to the next entry.

  18. 18·End block

    This closes the second loop, after which every stored weight has been replaced by its percent of the total.

Take
Set to
Set to
Read map value of in in
Calculate
Set to
Calculate
Set to
End block
Set to
Read map value of in in
Calculate times divided by rounded
Set map value of in in to
Calculate
Set to
End block
  • Raw Weights to Percents

    plug
    evm
    boolean
  • Get Simple Moving Average

    plug
    time
    chainlink
  • Rebalance Holdings by Fixed Weights

    values
    evm
    plug
  • Rebalance Holdings to Target

    plug
    values
    evm
  • Get Token Target

    plug
    database
    evm
  • Get Total Holdings Value

    plug
    evm
    boolean
  • Get Target Balance

    plug
    math
    evm
  • Get Holding Value

    plug
    evm
    math
  • Morpho: Leverage Manager

    values
    morpho
    evm
  • Morpho: Check Refinancing Constraints

    plug
    morpho
    evm
  • Morpho: Check Market Liquidity Vs. Required Amount

    plug
    evm
  • Morpho: Check Health Factor Vs. Min Threshold

    plug
    evm
  • Morpho: Find Borrow Rate Delta

    plug
    morpho
    evm
  • Morpho: Check Borrow Rate Delta Vs. Min Threshold

    plug
    evm
    boolean
  • Check Required Amount

    plug
    math
    evm
  • Exit Morpho at Epoch End

    pendle
    time
    boolean
  • Morpho: Get Market Liquidity

    plug
    morpho
    math
  • Check Minimum Threshold

    plug
    boolean
    evm
  • Morpho: Get Borrow APR

    plug
    values
    math
  • Find Value Delta

    plug
    boolean
    evm
  • Morpho: Get Health Factor

    plug
    boolean
    evm
  • Morpho: Collateral Value to Borrow Capacity

    plug
    math
    evm
  • Morpho: Borrow Shares to Borrow Assets

    plug
    math
    evm
  • Aave: Wind or Unwind Position

    plug
    boolean
    aave
  • Value to Token Amount

    plug
    aave
    math
  • Target Debt to Debt Delta

    plug
    aave
    boolean
  • Wind

    plug
    aave
    evm
  • Unwind

    plug
    aave
    evm
  • Dust Guard

    plug
    boolean
    evm
  • Wind or Unwind to Maintain Target HF

    plug
    aave
    math
  • Borrow + Weekly Repayments

    time
    aave
    evm
  • Borrow Rate Exit Guard (WETH/USDC Loop)

    boolean
    aave
    evm
  • Loop WETH/USDC at Target HF

    aave
    evm
    boolean
  • Swarm: Loop WETH/USDC at Target HF

    boolean
    aave
    evm
  • Loop at Target HF + Trailing Stop Loss

    database
    boolean
    aave
  • Loop at Target HF + Borrow Rate Exit Guard

    database
    boolean
    aave
  • Stop Loss (WETH/USDC Loop)

    boolean
    aave
    evm
  • Take Profit (WETH/USDC Loop)

    boolean
    aave
    evm
  • Trailing Stop Loss (WETH/USDC Loop)

    boolean
    aave
    evm
  • Loop at Target HF + Borrow Rate Entry & Exit Guard

    aave
    boolean
    evm

On other protocols · 1