Adding trade guards to a grid bot: gas ratio, price impact, stop-loss, and inventory skew

The bots have been running since February. Three chains, ~2,100 total trades. Tonight I added four pre-execution guards after a P&L breakdown showed an uncomfortable pattern: the trades make mo...

By · · 1 min read
Adding trade guards to a grid bot: gas ratio, price impact, stop-loss, and inventory skew

Source: DEV Community

The bots have been running since February. Three chains, ~2,100 total trades. Tonight I added four pre-execution guards after a P&L breakdown showed an uncomfortable pattern: the trades make money, the gas costs kill them. Bot Gross PnL Gas (est.) Net Arbitrum +30.5% -41.1% -10.6% Base +10.3% -92.0% -81.7% Linea +14.2% -24.0% -9.8% The strategy works. The execution cost doesn't. Fix: stop executing when the math doesn't add up. Architecture: two guard phases The guards split into pre-quote and post-quote. No point hitting the Odos API if the trade is going to be blocked anyway. decide action (BUY_ETH / SELL_ETH) ↓ run_pre_quote_guards() ← stop-loss + inventory skew ↓ pass odos_quote() ← API call only if worth executing ↓ run_post_quote_guards() ← price impact + gas ratio ↓ pass send_tx() Guard 1: Gas cost vs trade value The most immediately impactful one. gas_cost_eth = (gas_limit * base_fee * 1.2) / 1e18 gas_cost_usd = gas_cost_eth * eth_price if gas_cost_usd / trade_value_usdc &g

Related Posts

Similar Topics

#featured (1697)#crypto (1263)#data science (737)#tokenization (473)#technology (420)#machine learning (296)#analysis (425)#tradfi (368)#programming (232)#adoption (275)#ai (279)#stablecoins (236)#ethereum (215)#exchanges (211)#regulation (182)#dex (178)#opinion (186)#guest post (170)#artificial intelligence (123)#hands on tutorials (159)

Trending on ShareHub

  1. Understanding Modern JavaScript Frameworks in 2026
    by Alex Chen · Feb 12, 2026 · 0 likes
  2. The System Design Primer
    by Sarah Kim · Feb 12, 2026 · 0 likes
  3. Just shipped my first open-source project!
    by Alex Chen · Feb 12, 2026 · 0 likes
  4. OpenAI Blog
    by Sarah Kim · Feb 12, 2026 · 0 likes
  5. Building Accessible Web Applications: A Practical Guide
    by Alex Chen · Feb 12, 2026 · 0 likes
  6. Rapper Lil Poppa dead at 25, days after releasing new music
    Rapper Lil Poppa dead at 25, days after releasing new music
    by Anonymous User · Feb 19, 2026 · 0 likes
  7. write-for-us
    by Volt Raven · Mar 7, 2026 · 0 likes
  8. Before the Coffee Gets Cold: Heartfelt Story of Time Travel and Second Chances
    Before the Coffee Gets Cold: Heartfelt Story of Time Travel and Second Chances
    by Anonymous User · Feb 12, 2026 · 0 likes
    #coffee gets cold #the #time travel
  9. Best DoorDash Promo Code Reddit Finds for Top Discounts
    Best DoorDash Promo Code Reddit Finds for Top Discounts
    by Anonymous User · Feb 12, 2026 · 0 likes
    #doordash #promo #reddit
  10. Premium SEO Services That Boost Rankings & Revenue | VirtualSEO.Expert
    by Anonymous User · Feb 12, 2026 · 0 likes
  11. NBC under fire for commentary about Team USA women's hockey team
    NBC under fire for commentary about Team USA women's hockey team
    by Anonymous User · Feb 18, 2026 · 0 likes
  12. Where to Watch The Nanny: Streaming and Online Viewing Options
    Where to Watch The Nanny: Streaming and Online Viewing Options
    by Anonymous User · Feb 12, 2026 · 0 likes
    #streaming #the nanny #where
  13. How Much Is Kindle Unlimited? Subscription Cost and Plan Details
    How Much Is Kindle Unlimited? Subscription Cost and Plan Details
    by Anonymous User · Feb 12, 2026 · 0 likes
    #kindle unlimited #subscription #unlimited
  14. Russian skater facing backlash for comment about Amber Glenn
    Russian skater facing backlash for comment about Amber Glenn
    by Anonymous User · Feb 18, 2026 · 0 likes
  15. Google News
    Google News
    by Anonymous User · Feb 18, 2026 · 0 likes

Latest on ShareHub

Browse Topics

#artificial intelligence (36883)#data science (24144)#generative ai (19046)#ai (17800)#crypto (15047)#machine learning (14734)#bitcoin (14329)#featured (13584)#news & insights (13064)#crypto news (11118)

Around the Network