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

    A caller parameter named count is declared here, its value supplied at execution time to bound both loops below.

  2. 2·Set

    Seeding the accumulator, total is set to 0 before any weight is summed.

  3. 3·Set

    Setting index to 0 establishes the counter for the first pass over the weight slots.

  4. 4·Predicate

    A loop opens that runs while index stays less than count, iterating once per weight slot.

  5. 5·Read map value

    Inside the loop, the weights map in socket storage is read at the current index, returning the raw weight stored at that position.

  6. 6·Calculate

    Arithmetic adds that read weight to the running total.

  7. 7·Set

    Reassigning total to that sum folds this slot's weight into the accumulator.

  8. 8·Calculate

    Advancing the counter, index is added to 1.

  9. 9·Set

    The incremented result is written back into index for the next pass.

  10. 10·End block

    Closing the loop block returns control to the condition until index reaches count.

  11. 11·Set

    Resetting index to 0 restarts the counter for the second pass.

  12. 12·Predicate

    A loop opens again while index stays less than count, iterating once per slot to rewrite each weight.

  13. 13·Read map value

    Inside this pass, the weights map is read at the current index, returning that slot's raw weight.

  14. 14·Multiply then divide

    Multiplying the raw weight by 100 then dividing by total, rounding down, converts it into a percentage of the summed total.

  15. 15·Set map value

    Writing that percentage back into the weights map at index in socket storage overwrites the raw weight with its percent share.

  16. 16·Calculate

    Bumping the counter, index is added to 1.

  17. 17·Set

    That incremented result is written back into index for the next pass.

  18. 18·End block

    Closing the loop block completes the second pass over the weight set.

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
  • Morpho Pendle Expiry Deleveraging

    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
  • Trailing Stop Loss (WETH/USDC Loop)

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

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

    aave
    boolean
    evm
  • Loop WETH/USDC at Target HF

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

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

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

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

    boolean
    aave
    evm

On other protocols · 1