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

    Declaring count as a named parameter, this leaves the number of weight entries for the caller to supply at execution time.

  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 loop counter that starts at the first entry.

  4. 4·Predicate

    A for loop opens, running while index stays less than count, iterating once per entry.

  5. 5·Read map value

    Inside the loop, the weights map in socket storage is read at the current index, returning that entry's stored weight.

  6. 6·Calculate

    Arithmetic adds the weight just read to the running total.

  7. 7·Set

    Reassigning total to that sum folds this entry'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 prepares the counter for the second pass.

  12. 12·Predicate

    A second for loop opens, running again while index stays less than count.

  13. 13·Read map value

    Reading the weights map in socket storage at the current index returns that entry's stored weight once more.

  14. 14·Multiply then divide

    Taking that weight times 100 divided by total, rounded down, computes the entry's percent share of the summed total.

  15. 15·Set map value

    Writing that percent back into the weights map at the current index overwrites the raw weight with its computed share.

  16. 16·Calculate

    Bumping the counter, index is added to 1.

  17. 17·Set

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

  18. 18·End block

    Closing the second loop block completes the composed transaction.

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
  • Take Profit (WETH/USDC Loop)

    boolean
    aave
    evm
  • Loop WETH/USDC at Target HF

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

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

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

    aave
    boolean
    evm
  • 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