Float-target refill model: sweep maintains $50 IPRoyal balance, alert at $10 danger level
This commit is contained in:
20
sweep.py
20
sweep.py
@@ -20,8 +20,8 @@ def main():
|
|||||||
args = ap.parse_args()
|
args = ap.parse_args()
|
||||||
|
|
||||||
cfg = iproyal.CFG.get("sweep", {})
|
cfg = iproyal.CFG.get("sweep", {})
|
||||||
threshold = iproyal.CFG.get("alerts", {}).get("low_balance_threshold", 10.0)
|
float_target = float(cfg.get("float_target", 50.0))
|
||||||
max_sats = args.cap_sats or int(cfg.get("max_sats", 100000))
|
max_sats = args.cap_sats or int(cfg.get("max_sats", 75000))
|
||||||
dest = cfg.get("iproyal_btc_address", "")
|
dest = cfg.get("iproyal_btc_address", "")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -30,22 +30,22 @@ def main():
|
|||||||
print(f"balance check failed: {e}")
|
print(f"balance check failed: {e}")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if bal >= threshold:
|
if bal >= float_target:
|
||||||
print(f"balance ${bal} >= threshold ${threshold} — no top-up needed")
|
print(f"balance ${bal} >= float target ${float_target} — no top-up needed")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
shortfall = float_target - bal
|
||||||
if not dest:
|
if not dest:
|
||||||
print("NO destination set (sweep.iproyal_btc_address). "
|
print(f"LOW: balance ${bal} is below float target ${float_target} (shortfall ${shortfall:.2f}). "
|
||||||
"Set it in config.json before going live.")
|
"Set sweep.iproyal_btc_address in config.json to enable auto-top-up.")
|
||||||
return
|
return
|
||||||
|
|
||||||
if args.live:
|
if args.live:
|
||||||
print(f"LIVE: balance ${bal} < ${threshold} — would send {max_sats} sats to {dest}")
|
print(f"LIVE: balance ${bal} < ${float_target} — would send {max_sats} sats (~${shortfall:.2f}) to {dest}")
|
||||||
# TODO: wire send() to source wallet (BTCPay hot wallet / Alby on-chain).
|
|
||||||
# Hard cap enforced here: never exceed max_sats.
|
|
||||||
print("WARNING: send() not yet wired — this is a no-op placeholder.")
|
print("WARNING: send() not yet wired — this is a no-op placeholder.")
|
||||||
else:
|
else:
|
||||||
print(f"DRY-RUN: balance ${bal} < ${threshold} — would top up {max_sats} sats to {dest}")
|
print(f"DRY-RUN: balance ${bal} < float target ${float_target} (shortfall ${shortfall:.2f}) — "
|
||||||
|
f"would top up {max_sats} sats to {dest}")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user