# Noxy in Practice: A DeFi Yield Rebalancer Agent

*A practical walkthrough of building an AI agent that watches lending rates 24/7, spots better yield, and hands the final call to you — not to the bot*

By [Noxy](https://paragraph.com/@noxy) · 2026-04-17

defi, ai, agent, yield, farming, web3, crypto, defai, aiagents, yieldfarming, humanintheloop, ethereum, base, aave, compound, fluid, morpho, noxy, noxy.network

---

**The problem**
---------------

DeFi lending rates move constantly. The spread between Aave and Fluid Lending, or Aave and Compound, can swing by 2–3 percentage points overnight. On a $10,000 position that’s real money — hundreds of dollars a year left sitting on the table just because you weren’t paying attention at the right moment.

The obvious fix is automation. Build a bot that checks rates and moves funds when a better opportunity appears. Problem solved, right?

Not quite. Here’s what actually happens when you give a bot unconditional access to your wallet and your on-chain positions:

*   Rates fluctuate. What looks like a +2 pp edge at 2am might reverse by the time the transaction confirms.
    
*   Gas spikes. An aggressive rebalancer executing on a fee spike can eat the entire yield advantage in one round trip.
    
*   Protocols have risks. Smaller TVL pools, newer deployments, bridge exposure — a bot doesn’t know what you’re comfortable with today.
    
*   You wake up and have no idea what ran overnight.
    

Full automation of fund movements feels good as a concept. In practice, at 1am, with real money, it’s terrifying.

Pure alerting — “hey, Fluid is now paying 5.3% vs Aave’s 2.7%” — is the opposite extreme. You see the notification. You think “I’ll look at that later.” You don’t. Or you look, you’re not sure the edge justifies the gas, you’re not sure about the protocol, and you close Telegram without doing anything.

**The gap is the decision layer.** The agent should do all the thinking. The human should make the final call. That’s exactly what I built with Noxy.

**What I built**
----------------

The **Yield Rebalancer Agent** is a Node.js/TypeScript daemon that runs continuously, polling lending rates across Aave V3, Fluid Lending, Compound V3, Morpho on Base. When it detects a meaningful yield edge — above a configurable threshold, after accounting for gas — it doesn’t execute. It pauses, builds a complete proposal, and routes it to me via Noxy.

I see the full picture on my phone. I tap Approve or Reject. Only if I approve does the transaction go on-chain.

The agent watches. Claude thinks. Noxy asks. I decide.

**The stack**
-------------

*   **Aave V3, Fluid Lending, Compound V3, Morpho** — DeFi pools, reads yields and TVL
    
*   **Alchemy** — RPC provider + ETH/USD price feed
    
*   **CoinGecko / Binance** — fallback price sources for gas cost estimation
    
*   **Anthropic Claude Haiku** — generates the rebalancing proposal (full position analysis, risk factors, net edge calculation)
    
*   **Noxy** — delivers the decision request to iOS and Telegram simultaneously, waits for response, returns it to the agent
    
*   **Node.js + TypeScript** — agent runtime
    

**How it works, step by step**
------------------------------

**Step 1 — The agent spots an opportunity**
-------------------------------------------

Every few minutes, the agent fetches current APY from both protocols and computes the net edge:

    edge = (target_gross_apy - source_gross_apy) - estimated_gas_cost_in_yield_terms

If `edge > threshold` (I set mine at 1.0 pp), it moves to the next step. Below that, it keeps watching silently.

**Step 2 — Claude builds the proposal**
---------------------------------------

This is where the agent stops being a simple rate comparator and starts being useful. The agent calls Claude with the full position context:

*   Current position size and pool
    
*   Source and target APYs (gross)
    
*   TVL of the target pool
    
*   Live ETH/USD gas estimate
    
*   Known risks (TVL concentration, bridge exposure, protocol age)
    

Claude returns a structured proposal: exactly how much USDC to move, why the edge is real after friction, and a plain-English risk summary. This takes about 500ms and costs fractions of a cent per check.

**Step 3 — Noxy delivers the decision request**
-----------------------------------------------

Here’s where Noxy comes in. The agent doesn’t execute anything. It calls the Noxy SDK with the proposal text and waits.

Noxy fires the decision request **simultaneously** to:

*   My iOS app (native push notification with Approve / Reject on the lock screen)
    
*   My Telegram bot
    

Both arrive within the same second. If I’m asleep, Noxy stores the request and delivers it the moment my device reconnects. The agent is designed to wait — it won’t retry or act until it gets a response.

**What it looks like in practice**
----------------------------------

Here’s an actual decision request that arrived on a Sunday morning. The agent had been watching overnight and caught a +1.41 pp net edge between Aave V3 and Fluid Lending USDC pools.

**In the Noxy iOS app — lock screen notification and decision view:**

![](https://storage.googleapis.com/papyrus_images/62d6b7f552b4fe81b3f33c15f5e9d747e1f39df5463dc3df7a90e90d5fbfc3c2.png)

The lock screen notification shows the full proposal summary. Tapping it opens the Noxy app with the complete decision — position size, source pool APY, target pool APY, TVL, net edge, gas cost — and two buttons: **Approve** or **Reject**.

**In Telegram — the same request, same second:**

![](https://storage.googleapis.com/papyrus_images/2a4130cd7b343dcb733b0fa8a90b92b96c6cce0a312e11b90528da23c8645ed6.jpg)

The Telegram version shows the full proposal that Claude generated: not just the numbers but the reasoning — why the spread justifies the move, what the risks are, and what conditions should be monitored post-execution. The agent explains itself.

In this case, I approved. The agent withdrew from Aave V3 and supplied to Fluid Lending. Total gas: $0.01. Net yield improvement: +1.41 pp on a ~$200 position.

**The Noxy integration — what it looks like in code**
-----------------------------------------------------

The integration is straightforward. After Claude generates the proposal, the agent sends it to Noxy and waits:

    import { NoxySdk } from '@noxy/sdk';
    const noxy = new NoxySdk({ token: process.env.NOXY_APP_TOKEN });
    const decision = await noxy.sendDecisionRequest({
      walletAddress: userWallet,
      title: `Rebalance yield: +${edge.toFixed(2)} pp net (est.) - ${targetPool}`,
      body: claudeProposal,
      timeoutSeconds: 300,       // 5 min window, then re-check rates before retry
      onTimeout: 'reject',       // if no response, back off - don't execute
    });
    if (decision.approved) {
      await executeRebalance(sourcePool, targetPool, amount);
    } else {
      console.log('User rejected. Will re-alert only if edge improves.');
    }

Three things worth noting:

**Timeout behavior.** If I don’t respond within 5 minutes, the agent rejects by default — it doesn’t execute without my answer. This is configurable. You could set it to auto-approve for small amounts and require manual approval above a threshold.

**Re-alert logic.** If I reject, the agent backs off and only sends a new request if the edge improves further. No spam.

**Both channels fire.** Noxy handles the delivery — iOS and Telegram in parallel. I don’t need to configure both separately. The agent calls one endpoint.

**What Noxy adds at each stage**
--------------------------------

Agent stageWithout NoxyWith NoxyOpportunity detectedBot executes or sends a dumb alertAgent builds full proposal, routes to humanDeliveryEmail / single channel / easily missedSimultaneous iOS + Telegram, store-and-forward if offlineDecisionNone (auto-execute) or manual (open app, calculate, transact)Approve or Reject in one tap, in contextExecutionAlways, on bot’s termsOnly if you said yesFallbackBot retries indefinitelyConfigurable timeout + back-off logic

The agent is smarter. The human is still in control. That combination didn’t exist before.

**Why this matters beyond yield**
---------------------------------

The rebalancer is one use case. The pattern — **agent proposes, Noxy routes, human decides, agent executes** — applies anywhere an autonomous DeFi agent reaches a decision that has real financial consequences:

*   Liquidation prevention (collateral top-up proposals on Aave)
    
*   Leveraged position management (open/close above risk threshold)
    
*   Treasury reallocation (DAO fund movements)
    
*   Protocol parameter changes (governance agent proposals)
    

In every case, the gap between “agent detects an opportunity” and “agent moves funds” needs a human checkpoint. Noxy is that checkpoint — delivered fast enough that the window doesn’t close, with enough context that the decision is actually informed.

**Try it yourself**
-------------------

The full source is open:

👉 [**github.com/vstostap/yield-rebalancer-agent**](https://github.com/vstostap/yield-rebalancer-agent)

You’ll need:

*   An **Alchemy** RPC URL (or any Base-compatible RPC)
    
*   An **Anthropic** API key (Claude Haiku — cheap, fast)
    
*   A **Noxy** app token → [noxy.network](http://noxy.network)
    

Clone the repo, fill in `.env`, run `pnpm start`. The README covers every config option including threshold tuning, timeout behavior, and pool selection.

The agent watches constantly. You only get pinged when it actually matters. And you’re always the one who says go.

* * *

_Built with Noxy:_

[

Noxy Network - Decision Layer for AI Agents
-------------------------------------------

Noxy orchestrates encrypted decision requests from AI agents to end users across push, Telegram, and more-so humans can approve or reject in the loop. Post-quantum secure, wallet-native relay.

https://noxy.network

![Noxy Network - Decision Layer for AI Agents](https://storage.googleapis.com/papyrus_images/e0bff5592e0fedd4febcc6b35daebd0561477523e14aab91c414d8013109360b.png)

](https://noxy.network)

_Source:_

[

GitHub - vstostap/yield-rebalancer-agent: Cross-protocol lending yield scanner with Anthropic + Noxy human-in-the-loop
----------------------------------------------------------------------------------------------------------------------

Cross-protocol lending yield scanner with Anthropic + Noxy human-in-the-loop - vstostap/yield-rebalancer-agent

https://github.com

![GitHub - vstostap/yield-rebalancer-agent: Cross-protocol lending yield scanner with Anthropic + Noxy human-in-the-loop](https://storage.googleapis.com/papyrus_images/48dd46b9cf18c0fd04728f9646b185a25683d6ccf93783be634490a4dfdb24eb.png)

](https://github.com/vstostap/yield-rebalancer-agent)

---

*Originally published on [Noxy](https://paragraph.com/@noxy/noxy-in-practice-a-defi-yield-rebalancer-agent)*
