agentleFS
gokite-aigokite-ai/passport-skills/defi-auto-repay/SKILL.md

defi-auto-repay

Skill2 starsChanged 4 months agoMITView on GitHub

Arm a one-shot Aave v3 auto-repay on Base: when the health factor of an Aave position (in any wallet) drops below a threshold the user picks, Kite repays its USDC debt once from the user's Passport wallet. Reads a position's health factor and debt, creates a trigger (armed with a passkey in the browser), and lists, checks or cancels triggers. Invoke when the user wants to keep an Aave loan healthy, avoid or reduce liquidation risk, set a health-factor alert that repays automatically, or asks about their Aave position's health.

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 2 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Prerequisite: Before using any Passport skill, check if kpass is installed by running command -v kpass.

    line 20
  2. Distinctive:

    Never invent the inputs: Ask the user for the position address, the trigger health factor, the amount (a USDC number, or "max" for the full …

    line 48
  3. Very specific:

    Show the position first: Run defi position and show the Position card before asking for the trigger, so the user picks a threshold below …

    line 49
  4. Distinctive:

    Say it fires once: After it repays, the trigger is done.

    line 51
  5. Very specific:

    If trigger_status is cancelled, expired or failed (exit 3), tell the user it will not fire and offer to create a new one.

    line 129
  6. Very specific:

    After it fires: check the repay in history with activity.

    line 172

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

DeFi Auto-Repay (Aave v3 on Base)

Prerequisite: Before using any Passport skill, check if kpass is installed by running command -v kpass. If it returns nothing, invoke the passport-setup skill first to install the CLI.

Arm a one-shot repay trigger on an Aave v3 position: when its health factor drops below the user's threshold, Kite repays its USDC debt once from the user's Passport wallet. The position can live in any wallet (MetaMask, a Safe, anything): Kite repays on its behalf, and never needs that wallet's keys. This reduces liquidation risk; never say it "protects" against or "guarantees" anything.

Reference files (read when you need exact detail):

  • @references/commands.md: every flag, validation rule, JSON shape and error code.
  • @references/examples.md: end-to-end worked examples.

When to Use This Skill

  • The user wants to keep an Aave loan from being liquidated, or "repay automatically if my health factor gets low".
  • The user asks for their Aave position's health factor or debt.
  • The user wants to see, check or cancel their repay triggers.

When NOT to Use This Skill

  • To send tokens to an address, use wallet-send.
  • To pay for an API, use kite-discovery then x402-execute (the account allowance pays; request-session only if it can't).
  • For positions on other protocols (Morpho, Spark, Compound) or other chains: not supported yet. Say so.

Prerequisites

The user must be logged in. If a command exits 3 with "Not logged in", use authenticate-user first, then retry.

Availability: on in production, staging and dev. Production and staging run on Base mainnet with Circle USDC — a repay spends real funds. Dev runs on Base Sepolia with Aave's own test USDC, not Circle's. An environment with the feature switched off answers error_code: "aave_repay_disabled" (exit 4).

Rules (Do Not Skip)

  1. Never invent the inputs. Ask the user for the position address, the trigger health factor, the amount (a USDC number, or "max" for the full debt) and the expiry. Do not pick values for them.
  2. Show the position first. Run defi position and show the Position card before asking for the trigger, so the user picks a threshold below their current health factor.
  3. Show the wrong-address warning verbatim on the Approval Required card. Kite repays whatever address is entered; if it isn't the user's, their funds repay someone else's loan and cannot be recovered.
  4. Say it fires once. After it repays, the trigger is done; to keep auto-repay on, the user creates a new one.
  5. Always use --output json.

Commands at a Glance

CommandPurpose
kpass defi position --address <addr> --output jsonPosition health, debt, eligibility; your Passport wallet's USDC/ETH
kpass defi repay-trigger create --address <addr> --hf <n> --amount <usdc|max> --expires <7d|24h|RFC3339> --output jsonCreate a pending trigger (needs passkey approval)
kpass defi repay-trigger get --id <id> --wait --output jsonPoll until armed
kpass defi repay-trigger list --output jsonYour triggers, newest first
kpass defi repay-trigger cancel --id <id> --output jsonCancel a pending or armed trigger (an armed trigger may need passkey approval)

Display Cards — MANDATORY

You MUST show these cards at each step, in this exact horizontal-rule format. Never skip or replace them with plain text.

Step 1: defi position

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🏦 Aave v3 Position — {chain}

📍 Address:        {position_address}
❤️  Health factor:  {health_factor}
💵 Debt:           ${total_debt_usd} (USDC debt {usdc_debt})
🧱 Collateral:     ${total_collateral_usd}
✅ Eligible:       {supported}

👛 Your Passport wallet {wallet.address}: {wallet.usdc} USDC, {wallet.eth} ETH
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

If has_debt is false, show "Health factor: no debt" and stop: there is nothing to repay. If supported is false, explain that auto-repay needs USDC to be the position's only debt. If the wallet holds little USDC, note that it must hold enough when the trigger fires.

Step 2: repay-trigger create → approval required

The response is status: "human_action_required" (exit 0, not an error) with approval_url, warning, trigger, optional notices, and next_command.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🛡️ Aave Auto-Repay — Approval Required

⚠️ {warning}

📍 Loan address:  {trigger.position_address}
🎯 Repays when:   health factor < {trigger.trigger_hf}
💵 Repays:        {trigger.amount} USDC  ("max" = the full debt at that moment)
👛 Pays from:     {trigger.wallet_address}
🔁 Fires:         once
⏳ Expires:       {trigger.expires_at}

🌐 {approval_url}

👆 Open the link and arm it with your passkey.
⏳ I'll wait automatically...
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Show every notices entry under the card (e.g. the wallet holds less USDC than the repay may need). Optionally open the URL (open/xdg-open), then immediately run next_command.

Step 3: repay-trigger get --wait → armed

In JSON the envelope's status is success/pending; the trigger's own state is trigger_status and the trigger is under trigger. Judge by trigger_status, never by status.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ Aave Auto-Repay Armed

Kite will repay {trigger.amount} USDC once if the health factor of
{trigger.position_address} drops below {trigger.trigger_hf},
until {trigger.expires_at}.

This reduces liquidation risk. Cancel any time:
kpass defi repay-trigger cancel --id {trigger_id}
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

If trigger_status is cancelled, expired or failed (exit 3), tell the user it will not fire and offer to create a new one.

Cancelling an armed trigger → may need a passkey

repay-trigger cancel usually returns trigger_status: "cancelled" right away. But an armed trigger has set USDC aside, so releasing it can need the user's passkey: the response comes back as status: "human_action_required" (exit 0, not an error) with action: "approve_aave_repay_cancel", an approval_url, approval_expires_at, and next_command. The trigger stays armed until the user approves. Handle it exactly like the create approval.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🛡️ Aave Auto-Repay — Confirm Cancel

Cancelling releases the USDC this armed trigger set aside,
so it needs your passkey. It stays armed until you approve.

🌐 {approval_url}

👆 Open the link and approve the cancel with your passkey.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Optionally open the URL (open/xdg-open). After the user approves, run next_command (repay-trigger get --id <id>) to confirm trigger_status: "cancelled". That command is a one-shot read (no --wait): if it still shows armed, the user hasn't finished approving — wait and check again. A pending_approval trigger — and an armed trigger wherever the environment doesn't require the passkey — cancels immediately with no approval step.

Error Handling

Exiterror_codeMeaningRecovery
0Success, pending, or human_action_requiredContinue the flow
2invalid_request, aave_position_no_debt, aave_position_unsupported_debt, aave_trigger_not_below_hf, aave_trigger_already_active, aave_trigger_not_cancellableBad input, or the position doesn't qualifyShow the reason; re-check with defi position; for an active trigger, list then cancel it first
3Not logged in; trigger cancelled/expired/failed; --wait timed outauthenticate-user, or create a new trigger
4aave_repay_disabled, aave_trigger_not_foundFeature off in this environment; unknown IDCheck --base-url; list to find IDs
1aave_chain_unavailableThe chain couldn't be readRetry in a moment

Commands That DO NOT Exist

  • kpass defi (no sub-command), kpass aave …, kpass defi repay / defi borrow / defi supply / defi withdraw: the CLI only reads positions and manages repay triggers.
  • kpass defi repay-trigger create --position / --trigger / --health-factor: the flags are --address and --hf.
  • kpass defi repay-trigger arm / approve: arming happens in the browser at the approval_url.
  • kpass defi repay-trigger update / edit: cancel and create a new one.
  • --json: the flag is --output json.

Cross-Skill References

  • Prerequisite: authenticate-user.
  • Funding the Passport wallet (it pays the repay): wallet-send for its address and balance.
  • After it fires: check the repay in history with activity.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.