DEX
Open app

Running a crypto trading bot with a daily spending limit

A trading bot does not need unlimited access to a wallet. Most strategies touch a few tokens and a predictable amount per day. This guide shows how to run such a bot through Hopivia so that the limit is enforced by a smart contract rather than by the bot's own good behaviour.

Three strategies that fit a daily limit

Dollar-cost averaging. The bot buys a fixed amount of an asset every day or every hour. Allow the stablecoin it sells and the asset it buys, set the daily cap to the daily budget, and the bot physically cannot buy more.

Rebalancing. An assistant checks the portfolio once a week and moves a few percent between assets. Allow the assets involved and set the cap to the largest expected move.

Take-profit or stop orders. The bot sells an asset when the price reaches a level. Allow that asset and the stablecoin, and cap the daily amount at the position size you want to sell per day.

Sizing the limit

What the bot does on every run

  1. Asks the Hopivia API for a quote: GET /quote returns the best exchange, the route and the minimum output after slippage.
  2. Checks the remaining daily budget with the contract's limitOf view. If the budget is used up, it waits for the reset at 00:00 UTC.
  3. Calls the contract's swap function with its own wallet, passing the route from the quote and the minimum output. The contract pulls the input from your wallet, executes the trade and sends the output to you.

The same flow is available as tools in the Hopivia MCP server, so an assistant such as Claude or Cursor can run it without custom code.

Monitoring

The AI agents page shows every agent you allowed, each token's cap, how much was spent today and when the limit expires. Every swap emits an on-chain event with the agent, the tokens and the amounts, so you can also watch the contract in a block explorer or subscribe to events from your own scripts.

Stopping the bot

None of these require moving funds, changing wallets or contacting anyone.

FAQ

Does the bot need my funds in its own wallet?

No. The funds stay in your wallet until the moment of the swap. The bot's wallet only needs enough of the network coin to pay gas.

Can the bot trade on any exchange?

Only on the exchanges in the contract's fixed list. The quote from the Hopivia API tells the bot which routes are eligible.

What if the price moves against the bot?

The bot passes a minimum output with every swap. If the exchange cannot deliver at least that amount, the transaction reverts and nothing is spent.

Can I run the bot on several networks?

Each network has its own deployment of the contract and its own limits. Set them up separately on each network where the contract is live.

Updated: