DEV Community

kazunft
kazunft

Posted on

I built a trading agent on a testnet and let it trade

Paper trading never felt real to me, because nothing is at stake and the numbers are easy to ignore. For the HSK Chain Horizon hackathon I built Horizon Trader, an AI agent that trades on a testnet, where the tokens are free and the mechanics are real.

The contracts are written in Foundry: a constant-product AMM, a TWAP oracle, and a vault that holds the funds and enforces the risk limits on-chain. The agent runs in Node.js, scores the market with a multi-factor model, and gates every trade through a risk module that mirrors the vault's limits. The AI in the name is a statistical model, not an LLM.

I deployed the whole thing to the HSK testnet. The faucet gave me 0.1 HSK, which was enough to deploy the contracts, seed the pool with 1000 mHSK and 2000 mUSDC, prime the oracle, and fund the vault. The forge tests pass 13 out of 13, and the agent unit tests pass 11 out of 11.

The code is public at github.com/slowwwkiss/horizon-trader. The tokens are free, and the plumbing is the same as mainnet. That is the part worth getting right before anything real is on the line.

Top comments (1)

Collapse
 
sergei_b profile image
Sergei B •

You write that the tokens are free but the mechanics are real. I'm curious what the agent does when a swap is submitted but hasn't been confirmed yet. Did you test a delayed or reverted swap, and can the agent tell those apart from a completed trade?