The automaton
Two moves, five constants, no clock.
Constants
State machine
Live counters
Last twenty ticks
How the entry works
The program keeps one counter and one reference price. On every tick it compares the new price to the last one. Strictly higher increments the counter and leaves the reference alone. Strictly lower resets the counter to zero and sets the reference to the new price. Equal does nothing. The reference is always the price at the bottom of the current run.
When the counter reaches five and the current price is at least twelve percent above the reference, the program spends forty percent of the allowance balance on a market buy and moves to the exposed state. It does not wait for a better price. It does not scale in. It buys the exact moment the condition is true, which is by construction after the move has already happened.
Forty percent rather than everything means tom can be wrong more than once per allowance. A second entry only happens after a full exit, because the entry rule is only evaluated while the position is zero.
How the exit works
While exposed, the program recomputes tom's basis from his own fills: total SOL spent divided by total tokens held. On every tick it marks the position at the new price. The first tick where the mark is fifteen percent or more under the basis, it sells the whole position at market. There is no partial exit, no trailing stop, no waiting for a bounce.
The sell instruction does not return SOL to the allowance. It delivers the SOL to the pool as single sided liquidity and burns the receipt. The program cannot be told to do otherwise. After the sell lands, the next chain read shows the position at zero and the state returns to observing with a fresh counter.
Why there is no clock
Nothing in the program reads the slot or the block time. There are no epochs, no cooldowns, no scheduled runs and no snapshots. The only inputs are price ticks and tom's own fills. If the price does not move, tom does not move. If the market goes quiet for a day, the counter just holds. That is on purpose: a clock would let tom be right by accident, and the point is that he is wrong by design.