Commit c5a63c1
committed
liquidity: integrate scriptable autoloop mode
Add scriptable autoloop as a new mode alongside easy autoloop and
threshold rules. This allows users to provide custom Starlark scripts
that have full control over swap decisions.
Key changes:
- scriptable.go: ScriptableManager that evaluates user scripts on
each tick, builds context from current channel/peer state, and
converts script decisions to swap suggestions
- parameters.go: Add ScriptableAutoloop, ScriptableScript, and
ScriptableTickInterval parameters with validation to ensure
scriptable mode is mutually exclusive with easy autoloop and rules
- liquidity.go: Wire up scriptable manager to the autoloop system
- script_equivalence_test.go: Tests verifying Starlark scripts can
replicate easy-autoloop behavior plus advanced scenarios
The scriptable mode gives operators fine-grained control with
readable Python-like syntax:
def autoloop():
eligible = [c for c in channels if c.active]
eligible = sorted(eligible, key=lambda c: -c.local_balance)
if eligible and total_local > 100000:
return [loop_out(50000, [eligible[0].channel_id])]
return []
decisions = autoloop()1 parent 317bea4 commit c5a63c1
4 files changed
Lines changed: 1025 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
293 | 293 | | |
294 | 294 | | |
295 | 295 | | |
296 | | - | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
297 | 305 | | |
298 | 306 | | |
299 | 307 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
131 | 143 | | |
132 | 144 | | |
133 | 145 | | |
| |||
195 | 207 | | |
196 | 208 | | |
197 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
198 | 231 | | |
199 | 232 | | |
200 | 233 | | |
| |||
475 | 508 | | |
476 | 509 | | |
477 | 510 | | |
478 | | - | |
479 | | - | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
480 | 516 | | |
481 | 517 | | |
482 | 518 | | |
| |||
617 | 653 | | |
618 | 654 | | |
619 | 655 | | |
620 | | - | |
621 | | - | |
622 | | - | |
623 | | - | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
624 | 663 | | |
625 | 664 | | |
626 | 665 | | |
| |||
0 commit comments