M

I rebuilt my arbitrage bot with Grok Bot and now it makes $12k per week (full guide + code)

17 min readView source ↗

Cover image

My arb bot used to be one giant tangled script.

Now it's a team of AI agents, each doing one job, and it's at $66k PnL.

I rebuilt the whole thing with Grok Build, and it made the bot easier to run, easier to fix, and far more reliable than the monolith ever was.

Article image

Public wallet: [https://polymarket.com/@l5zn1bwom8etsk?via=surfer]

This is the full build, updated, and it's the advanced version, not the beginner overview.

Same battle-tested bones i always preach, but restructured around specialized agents instead of one brain trying to do everything at once.

I built 500+ bots to learn this. 99% of them failed.

This is the architecture behind the 1% that prints, and i'm going to show you every piece, including the parts that quietly kill people.

Let me walk you through it, step by step.

1. WHY A TEAM OF AGENTS BEATS ONE SCRIPT

First, the core idea behind the whole rebuild, because it changes everything downstream.

My old arb bot was a monolith.

One script that found the arb, checked the risk, ran the fee math, placed the orders, and managed the exits.

One brain doing five jobs, and every job made the other four harder to reason about.

When it broke, i couldn't tell WHICH part broke.

Was it the scanner flagging a fake gap? The risk check letting a bad leg through? The fee math being wrong? You couldn't isolate it, so every bug was a nightmare.

Grok Build changed the shape of the whole thing.

It spins up parallel sub-agents, so instead of one tangled brain, you build a team of small specialists that each own one job and hand off cleanly to the next.

My example:

> hunter agent finds the arb.

> risk agent verifies both legs can actually complete.

> fee agent decides if the gap survives costs.

> execution layer places, tracks, and manages the pair.

Each one has a single, testable job it never messes up.

Article image

And the real win is debuggability.

When something goes wrong now, i know exactly which agent to look at, because each one has a narrow, defined responsibility.

This is the same lesson i preach about bots themselves.

A specialist destroys a generalist at its one task, every time.

A chip built for one operation beats a chip that does everything.

I just applied that same principle to the AI running my bot, and the whole system got sharper, faster to fix, and more reliable.

The monolith was one point of failure.

The team is five small points of failure you can each check in isolation, which in practice means far fewer failures at all.

2. WHAT THE ARB ACTUALLY IS (AND THE TWO KINDS)

Before any code, the mechanic, because the agents are useless if you don't deeply understand what they're hunting.

On a binary Polymarket market, the two sides should add up to exactly $1.

Up plus Down equals a dollar.

That's the rule the entire strategy stands on, and it comes from the fact that one side WILL pay out $1 at resolution and the other WILL pay $0.

But sometimes the market breaks that rule:

> Up trades at 0.55

> Down trades at 0.42

> Together that's 0.97, not 1.00

That 3-cent gap is free money if you grab both sides.

You lock the pair for 97c, and it's guaranteed to be worth exactly $1 at resolution, no matter which way the market resolves.

Article image

No prediction. No directional risk. Just a pricing error you collected.

Now here's the part beginners miss, there are actually two kinds of this.

Simple arb, both sides on the SAME market

Up and Down on one BTC window that sum to less than a dollar. Cleanest, most obvious, and the most competed-for, so these gaps are tiny and close in milliseconds.

Combinatorial arb, LINKED markets

Two separate markets that are logically connected. "Team A wins" and "Team A wins by 2+" can't contradict each other, so their prices must obey a rule, and when they drift you get a locked position across both. Fewer people hunt these because the search space is huge, so the gaps are fatter and last longer.

The hunter agent can be pointed at either.

Most people only ever build the first kind and fight everyone for scraps.

The real money over time is teaching your hunter to spot the second.

Everything below works for both, the difference is only in what the hunter scans for.

3. PREREQUISITES (ADVANCED VERSION)

Same foundations as every serious bot, and Grok Build does NOT replace them.

Python and NumPy, and understanding what gets generated

You still need to handle websockets, order-book reconstruction, and fast vectorized decisions. Grok Build writes most of it now, but if you can't read and reason about what it produced, you'll ship bugs you can't find. The tool raises your ceiling, it doesn't remove the need to understand your own bot.

Low-latency infrastructure, placed correctly

A VPS or server physically close to Polymarket's infra. This matters more for arb than almost any other strategy, because arb requires completing BOTH legs, and every millisecond between them is a millisecond one side can move and break the pair. Pick a cloud region with the lowest ping to their servers. A far-away host doesn't just slow you down, it actively creates half-filled arbs.

Polymarket API access and a real wallet

Get your keys, set up the funder wallet, and start dry runs at zero balance so real errors, insufficient funds, allowance issues, rejections, surface early and become data you feed back into your backtest.

Article image

Clean data feeds, from multiple sources

Polymarket CLOB and Gamma websockets, plus external references like Binance and Coinbase for sanity-checking resolution prices. Dirty data means fake arbs, you'll see a gap that isn't real because one side's quote is stale.

Here's the shift with Grok Build:

You no longer hand-write all this plumbing across days of work.

You describe each piece to an agent in plain language and it builds the worker, tests it, and iterates.

But you own the architecture decisions, the region choice, the data sources, the wallet setup, and you must read and trust what each agent produces before it touches real money.

The tool compresses weeks of building into days.

It does not compress the judgment.

4. HUNTER AGENT (CODE)

The first agent's entire job is scanning for the gap, relentlessly.

You cannot do this by hand. The gaps are small, they appear across dozens of markets at once, and they close in seconds or faster.

So this agent runs nonstop, checking every active pair's two sides against the dollar, on every book update.

The core check it runs looks like this:

def find_arb(book_up, book_down, min_edge=0.02, fee=0.0):
    # you must BUY at the ask, not the bid - this trips up beginners
    up_ask = book_up.best_ask
    down_ask = book_down.best_ask
    # depth matters: a gap you can't fill in size is not a gap
    up_size = book_up.ask_size
    down_size = book_down.ask_size
    fillable = min(up_size, down_size)
    pair_cost = up_ask + down_ask + fee
    edge = 1.0 - pair_cost # guaranteed $1 payout minus what you paid
    if edge >= min_edge and fillable > 0:
        return {
            "up_price": up_ask,
            "down_price": down_ask,
            "edge": round(edge, 4),
            "max_size": fillable,
        }
    return None

Notice two things most people get wrong.

First, you buy at the ASK, not the bid. The gap has to exist at the price you'd actually pay, not the mid or the bid.

Second, the agent checks DEPTH, not just price. A 5-cent gap with only $3 of size behind it is worth almost nothing after fees and effort. The real prize is edge times available size, so the hunter reports how much it can actually fill.

The agent flags a qualifying setup and hands it straight to the risk agent, along with the max fillable size.

It never sleeps, never blinks, never misses a gap because it got distracted or tired.

That is exactly what an AI agent is genuinely good for, tireless, focused scanning.

Not making the bet, hunting the setup.

Grok Build let me spin this worker up, test it against recorded book data, and iterate on the edge threshold in a fraction of the time it took to write the first version by hand.

5. RISK AGENT - WHY "RISK-FREE" ISN'T (CODE)

Finding the gap is the easy 20%.

Not getting wrecked by it is the hard 80%, and it's the entire reason the risk agent exists as its own dedicated worker.

Here's the trap that turns "risk-free" arb into real losses.

An arb is only risk-free if you get BOTH legs.

Fill one side and miss the other, and you are no longer arbing.

You are now a directional trader holding one naked side, fully exposed to the exact price move you were trying to neutralize.

That naked leg can move against you instantly, and the "safe" trade becomes your worst loss of the day.

This is the single most common way arb bots blow up, and it almost never shows up in a naive backtest because the backtest assumes both legs always fill.

So the risk agent runs a series of hard checks before anything fires:

def approve_trade(setup, book_up, book_down, inventory, max_imbalance=50):
    # 1. can BOTH legs actually fill at the flagged size?
    size = setup["max_size"]
    if book_up.ask_size < size or book_down.ask_size < size:
        return False, "insufficient depth on one leg"

    # 2. would this leave me dangerously lopsided?
    projected = inventory.net_exposure + 0 # arb should stay ~neutral
    if abs(projected) > max_imbalance:
        return False, "inventory too imbalanced"

    # 3. is one leg suspiciously cheap? (stale quote / adverse selection)
    if setup["up_price"] < 0.02 or setup["down_price"] < 0.02:
        return False, "leg price looks stale, likely fake gap"

    return True, "approved"

Walk through what it's actually protecting against.

Depth on both sides

If either leg can't fill the full size, the pair can't complete, so it kills the trade.

Inventory balance

Arb should keep you market-neutral. If a fill would leave you lopsided, that's directional risk creeping in, and it stops.

Suspiciously cheap legs

A price that's too good is usually a stale quote or a sign you're about to be adversely selected, filled on the losing side because someone knows something. The agent treats an unrealistic gap as a red flag, not a gift.

Because a half-filled arb is worse than no arb.

No trade costs you nothing.

A naked leg costs you the entire thing you were protecting against, plus the fees you already paid on the leg that did fill.

Article image

This is the discipline solo builders skip because it's boring and invisible when it's working.

It's exactly the kind of narrow, critical, unglamorous job that's perfect to hand to its own dedicated agent that runs the same checks every single time without ever getting lazy or excited about a fat-looking gap.

6. THE FEE AGENT AND WHY GTC BEATS FAK (CODE)

The third agent answers one question that decides everything, does this gap survive the costs?

Because a 3-cent gap has zero room to give away.

If fees eat the gap, you did all that work to make nothing, or to actually lose after slippage.

And here's the lever that controls your fees, your order TYPE.

> FAK, fill-and-kill, is an aggressive taker order. It grabs available liquidity immediately, but you PAY a taker fee for the privilege, on both legs.

> GTC, good-till-cancelled, rests on the book as a maker order. You wait to be filled, but you often EARN a maker rebate instead of paying a fee.

On thin arb margins, that difference isn't a detail, it's the whole trade.

The fee agent runs the real net math before it greenlights anything:

def net_after_fees(setup, size, maker_rebate=0.0, taker_fee=0.0, use_gtc=True):
    gross = (1.0 - (setup["up_price"] + setup["down_price"])) * size
    if use_gtc:
        # resting maker orders: rebate is income, not cost
        costs = -(maker_rebate * size * 2)
    else:
        # aggressive taker on both legs
        costs = taker_fee * size * 2
    net = gross - costs
    return net > 0, round(net, 4)

Run the same 3-cent gap through both paths and you get two completely different businesses.

Take both legs aggressively with FAK and the taker fees can swallow the entire gap, leaving you flat or negative.

Rest both legs as GTC, earn the rebate, and the same gap clears with real profit, sometimes the rebate alone adds meaningfully to the edge.

So the fee agent pushes hard toward resting GTC orders, and only permits aggressive FAK when the gap is fat enough to eat the taker fee and still profit, which is rare.

But here's the tradeoff it has to weigh.

GTC means you WAIT to fill, and while you wait, the gap can close or one leg can fill without the other.

Article image

That's exactly why the risk agent and the fee agent have to work together, the fee agent wants patient resting orders, the risk agent makes sure those resting legs actually complete as a pair.

Every agent constrains the next.

That interlock is what a monolith could never do cleanly, and it's the core reason the multi-agent rebuild outperforms the old script.

7. EXECUTION, THE MERGE LOOP, AND CAPITAL VELOCITY (CODE)

Now the part almost nobody talks about, the hidden half of the strategy that actually determines your monthly PnL.

Once both legs fill, you hold a complete pair, one Up share and one Down share, bought together for 97c.

The beginner move is to wait for the market to resolve to collect your dollar.

That works, but it FREEZES your capital for the entire life of the market, sometimes hours.

And frozen capital is dead capital, it can't be catching the next gap.

Here's the advanced move.

A complete pair, one Up plus one Down, can be MERGED straight back into $1 of collateral, instantly, without waiting for resolution.

def recycle_pair(market, size):
    # you hold `size` Up and `size` Down after the arb filled
    # merge them back into USDC immediately - no waiting for resolution
    tx = merge_positions(market.condition_id, size)
    if confirm_on_chain(tx):
        return size # capital is liquid again, right now
    return 0

So the full loop is: hunter finds the gap, risk approves it, fee agent confirms it nets positive, executor fills both legs for 97c, then you merge the pair back to $1 immediately, pocket the 3c, and the capital is free in seconds to hit the next one.

This is where the real money is, and it's pure math.

Article image

Your monthly return is that tiny per-trade edge times how many times you recycle the same capital per day.

A 3c edge captured once a day on $1,000 is trivial.

The same 3c edge recycled 40 times a day on the same $1,000 is a real income.

Velocity IS the strategy. The gap is just the per-cycle yield.

This is also precisely why copying my wallet is useless.

On chain, someone sees the buys and the merges and a PnL number climbing.

What they can't see is the timing between legs, the order routing that captured the rebate, the merge cadence that freed the capital, or the risk logic that killed the setups where one leg wouldn't complete.

By the time a trade appears on chain, the gap it captured is long gone.

The edge lives in the bot's logic and timing, never in the visible wallet.

8. BACKTESTING, RISK CONTROLS AND DEPLOYMENT

The agents do not get you out of proving the bot works. If anything, arb demands a harsher gauntlet, because the naive backtest lies the most here.

Backtest on real book data, never price lines

Arb depends entirely on the actual bid, ask, and depth at each moment. A backtest against closing prices will show you gaps that were never fillable. You need your own recorded order-book snapshots, both sides, with depth.

Re-run it assuming both legs DON'T always fill

This is the gate that kills most arb strategies, and it should. Model missed legs, model one side filling and the other moving away, model latency between the two fills. A real arb backtest assumes you sometimes get stuck with a naked leg and prices it in. If it still profits under those conditions, you might have something.

Article image

Model the fees explicitly, per order type

Backtest the GTC-rebate path and the FAK-fee path separately. The same strategy can be profitable as a maker and a loser as a taker.

Dry-run live at zero balance

Let it try to fire, fail on no funds, and log exactly what it would have done. Every rejection is a real-world signal your backtest was missing.

Only deploy when live matches backtest within a few percent

If they diverge, assume execution is the problem, latency, fills, leg timing, until proven otherwise.

And here's a Grok Build trick that genuinely raised my confidence.

Use a SEPARATE agent as an adversarial reviewer of your backtest.

One agent builds the backtest, a second agent's only job is to attack it, hunt for look-ahead bias, check whether it assumed impossible fills, question whether both legs could really have completed at those prices.

The backtest you trust is the one another agent tried its hardest to destroy and couldn't.

Then the safety rails, and for arb these are non-negotiable because a stuck naked leg overnight can erase weeks:

A kill switch that halts all trading if daily loss crosses a hard limit.

Constant state dumps to disk, so a crash and restart never double-fills a leg or forgets an open pair.

A pre-flight check on startup, funder address, USDC allowance, gas balance, live data feeds, that refuses to start if anything is off.

A dedicated "naked leg" monitor that screams if you're ever holding one side unhedged, so you can act before it moves against you.

PUTTING IT ALL TOGETHER

Step back and look at what the rebuild actually accomplished.

The strategy itself did not change.

It's still the same arb, catch a pair that sums to less than a dollar, verify it's real and fillable, lock both legs cheaply, merge back to $1, and recycle the capital as fast as possible.

What changed is the ARCHITECTURE, and the architecture is what makes it survivable at scale.

One tangled, undebuggable script became a team of focused agents.

The hunter finds and sizes the gap.

The risk agent guarantees both legs can complete and keeps you neutral.

The fee agent enforces that the gap survives costs and pushes toward maker rebates.

The executor fills, merges, and recycles the capital.

An adversarial agent tries to break the backtest before your money does.

Each piece is isolated, testable, and easy to fix, which in practice means the whole system breaks far less.

Grok Build made building that entire team fast, turning what used to be weeks of monolith wrestling into days of describing focused jobs to focused agents.

But be crystal clear about the split, because this is the part the hype merchants lie about.

The agents handle the plumbing, the scanning, the checks, the math, the execution.

The EDGE, the strategy design, the inventory discipline, the infra placement, the judgment about which gaps are real, is still mine, and it's still the only part that actually matters.

Grok Build removed the barrier to BUILDING.

It did not hand me the edge, and it will not hand you one either.

What it will do is let you build a proper, professional, multi-agent system in a fraction of the time, so you can spend your energy on the part that actually prints, the edge.

Build the team.

Keep the edge as yours.

If you wanna go deeper on the exact agent workflow and prompts i used, i break the whole thing down in my channel.

Join here: [https://t.me/+jCBHygDAJa9hMTJk]

Article image

Everything here is free, and it stays free.

Good luck.

Related articles