Detecting Positive Arbitrage Using Pool Imbalance

In previous parts, we built a Telegram bot that monitors user wallets, liquidity positions, and rewards using Allbridge Core APIs.

In this part, we change the perspective.

Instead of tracking users, the bot tracks the state of liquidity pools and detects moments when the protocol itself signals that a transfer in a certain direction is economically favorable.

This is done without quotes, swaps, or transaction simulation.

Detecting Positive Arbitrage Using Pool Imbalance

What problem we are solving

Allbridge Core uses liquidity pools.

Each pool maintains:

  • real token balance . 
  • virtual USD balance (used by stable-swap math)

When users bridge assets, pools drift out of balance.

The protocol calculates this drift and exposes it as imbalance.

Our goal is simple:

Periodically read pool imbalance and notify users when the imbalance difference between pools becomes large enough to justify attention.

This is a signal, not a trade execution.

What imbalance represents

Each liquidity pool in Allbridge Core exposes a precomputed field called imbalance.

Imbalance is a normalized protocol-level metric that reflects the difference between:

  • the real token balance currently held by the pool
  • the virtual USD balance defined by the pool’s stable-swap invariant

In simple terms, it answers one question:

Does this pool currently hold more or fewer tokens than it should, according to the protocol’s internal equilibrium model?

Interpretation:

  • Positive imbalance means the pool holds excess liquidity(users are mostly bridging from this pool)
  • Negative imbalance means the pool has a liquidity deficit(users are mostly bridging into this pool)

Important properties:

  • Imbalance is already adjusted by the protocol’s math(including virtual balances and amplification parameters)
  • It is comparable across pools, even on different chains
  • It is directional, not an execution quote(it indicates pressure, not guaranteed profit)

Because this value is computed inside the protocol, the bot does not attempt to reconstruct pool invariants or simulate swaps.

It simply reads the signal that Allbridge Core already exposes.

Data sources

The bot uses only two endpoints.

  1. Get a list of all tokens
    GET /tokens
  2. Get each pool state
    GET /pool/info/server?tokenAddress=...

Only imbalance is required for the signal.

Signal model

We do not calculate expected output.

Instead, we compare the relative imbalance between pools of the same or different tokens.

For pools A and B:
delta = imbalance_B - imbalance_A

Interpretation:

  • large positive delta → moving liquidity from A to B helps rebalance
  • small or negative delta → ignore

This works even when both pools are positive or both negative.

Fixed test sizes

We evaluate signals using two fixed reference amounts:

  • 100
  • 1000

These are not transactions, only scaling factors.

They help distinguish:

  • retail-level signals
  • large-flow signals

No precision is required.

Notification rules

The bot:

  • runs on cron
  • stores previous signal state
  • sends notification only on threshold crossing

Example:

  • signal > $5 → notify
  • signal stays > $5 → silence
  • signal drops below → silence
  • signal exceeds again → notify

This prevents spam.

$THRESHOLD_USD = 5;
$TEST_AMOUNTS = [100, 1000];

foreach ($tokens as $token) {
    $pools = fetchPoolsForToken($token);

    foreach ($pools as $from) {
        foreach ($pools as $to) {
            if ($from['chain'] === $to['chain']) {
                continue;
            }

            $delta = (float)$to['imbalance'] - (float)$from['imbalance'];

            foreach ($TEST_AMOUNTS as $amount) {
                
                $signalUsd = abs($delta) * $amount / 1000;

                if ($signalUsd >= $THRESHOLD_USD) {
                    notifyIfNew(
                        $token['symbol'],
                        $from['chain'],
                        $to['chain'],
                        $amount,
                        $signalUsd
                    );
                }
            }
        }
    }
}

Telegram notification example

Potential arbitrage signal detected

Token: USDC
Direction: Algorand → Celo
Reference amount: 1000
Signal strength: ~$6.8

Why this approach is intentional

  • imbalance is already normalized by the protocol
  • exact output depends on timing and fees
  • the bot’s job is early detection, not execution

This keeps the system:

  • fast
  • cheap
  • stable
  • understandable

Summary

What we built:

  • a cron-driven pool state watcher
  • imbalance-based signal detection
  • threshold-based Telegram alerts
  • zero dependency on quotes or swaps

This turns the bot from a wallet tracker into a protocol state monitor.

Oleksii Opanasiuk Oleksii Opanasiuk

Oleksii Opanasiuk is a Lead Software Engineer and DevOps Specialist with 10+ years of experience in blockchain, cloud infrastructure, and full-stack development. He architects scalable systems, builds CI/CD pipelines, and helps teams deliver high-quality projects on time.

Leave a comment
Recent Comments (0)
No comments yet