Auto-claim without the scheduler, and no claim twice
A payout locks in profit and opens nothing, so stopping the trading no longer stops it: a claim watcher runs the same claims once a minute while the scheduler is off (its tick still claims while it runs), and the dashboard's Auto-claim payouts box turns them off. From two independent reviews of the claim path: - A claim holds every further claim on the account until Vest's transactions show its WITHDRAW. A sync already out when the claim lands (by sync generation, not the clock) no longer writes the pre-claim balance back, and a fresh sync follows the claim. - A withdraw that fails in transit (timeout, reset, 5xx) may have gone in: it is recorded as of unknown outcome and holds claims the same way, until the transactions show it, or an hour of them shows it didn't. - claimProfit checks Vest's own account: funded (or instant), and no more than the balance above its starting capital. - A claiming account is marked in flight; runClaims sends the amount it re-checked under the mutex. - The watcher starts before the rest of the init can fail; settings are validated before any is written. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
016444239e
commit
6f6660fdcc
+25
-1
@@ -743,6 +743,7 @@ export default function Home() {
|
||||
const [tickInterval, setTickInterval] = useState('60');
|
||||
const [tradeLoading, setTradeLoading] = useState(false);
|
||||
const [stopAfterAll, setStopAfterAll] = useState(false);
|
||||
const [autoClaim, setAutoClaim] = useState(true);
|
||||
|
||||
const handleSort = (col: SortKey) => {
|
||||
if (sortKey === col) {
|
||||
@@ -812,8 +813,9 @@ export default function Home() {
|
||||
|
||||
fetch('/api/settings')
|
||||
.then((r) => r.json())
|
||||
.then((s: { tick_interval_seconds?: string | null }) => {
|
||||
.then((s: { tick_interval_seconds?: string | null; auto_claim?: string | null }) => {
|
||||
if (s.tick_interval_seconds != null) setTickInterval(s.tick_interval_seconds);
|
||||
setAutoClaim(s.auto_claim !== 'off');
|
||||
})
|
||||
.catch(() => {});
|
||||
|
||||
@@ -1000,6 +1002,28 @@ export default function Home() {
|
||||
/>
|
||||
<span className="text-xs text-slate-400 whitespace-nowrap">Stop after all eligible</span>
|
||||
</label>
|
||||
{config.some((f) => f.platform === 'vest') && (
|
||||
<label
|
||||
className="flex items-center gap-1.5 ml-2 cursor-pointer select-none"
|
||||
title="Claim a funded account's profit as soon as it reaches its stage's target (Vest) — whether or not the scheduler is running"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={autoClaim}
|
||||
onChange={(e) => {
|
||||
const on = e.target.checked;
|
||||
setAutoClaim(on);
|
||||
fetch('/api/settings', {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ auto_claim: on ? 'on' : 'off' }),
|
||||
}).then((r) => { if (!r.ok) setAutoClaim(!on); }).catch(() => setAutoClaim(!on));
|
||||
}}
|
||||
className="rounded border-slate-300 text-emerald-500 focus:ring-emerald-500"
|
||||
/>
|
||||
<span className="text-xs text-slate-400 whitespace-nowrap">Auto-claim payouts</span>
|
||||
</label>
|
||||
)}
|
||||
<div className="ml-auto flex items-center gap-2">
|
||||
{hasAnyPosition && (
|
||||
<button
|
||||
|
||||
Reference in New Issue
Block a user