Raw Weights to Percents
0x484428507A212cA56D71baa27Ca6089a6dB63a88

What this does

This plug converts raw stored weights into percent shares across a set of token slots. It asks the caller for count, the number of weight slots to process. It runs whenever invoked, first summing every slot's weight from socket storage, then rewriting each slot as its weight times 100 divided by that total, rounded down. Done by hand or on a stale total, the written percents drift from the true proportions and misstate each slot's share.

Actions · 17

  • Set
    Set to
    Assigns a value to a named variable that later steps reference.
  • Set
    Set to
    Assigns a value to a named variable that later steps reference.
  • Predicate
    Steers control flow by comparing two values: branch, loop, or require the condition holds.
  • Read map value
    Read map value of in in
    Reads a value from a keyed map in the socket's persistent storage.
  • Calculate
    Calculate
    Applies a binary arithmetic operation to two values and returns the result.
  • Set
    Set to
    Assigns a value to a named variable that later steps reference.
  • Calculate
    Calculate
    Applies a binary arithmetic operation to two values and returns the result.
  • Set
    Set to
    Assigns a value to a named variable that later steps reference.
  • End block
    End block
    Closes the innermost open block, whether a conditional branch or a loop.
  • Set
    Set to
    Assigns a value to a named variable that later steps reference.
  • Predicate
    Steers control flow by comparing two values: branch, loop, or require the condition holds.
  • Read map value
    Read map value of in in
    Reads a value from a keyed map in the socket's persistent storage.
  • Multiply then divide
    Calculate times divided by rounded
    Multiplies two values and divides by a third in one step, rounding up or down.
  • Set map value
    Set map value of in in to
    Writes a value into a keyed map in the socket's persistent storage.
  • Calculate
    Calculate
    Applies a binary arithmetic operation to two values and returns the result.
  • Set
    Set to
    Assigns a value to a named variable that later steps reference.
  • End block
    End block
    Closes the innermost open block, whether a conditional branch or a loop.

Related plugs · 8