Auto-forward and auto-swap crypto deposits: wallet rules with limits

Forward each confirmed crypto deposit to a treasury address or swap it into USDT automatically, with a minimum, a kept amount, a daily limit and a 2FA code.

Published 6 min read

A deposit arrives, and somebody has to do something with it: move it to the treasury, send it to an exchange, turn it into a stablecoin before the price moves. Done by hand it waits for a person. Done by a script it needs a key that can send, a queue, retries, and a guard against sending twice after a restart. A kryptr.io wallet does it by itself with a wallet rule: you say once what happens to a coin's deposits, and the wallet acts on each one as soon as it is confirmed.

What a rule is

One rule belongs to one wallet and one asset. It has:

Field Meaning
asset_id the asset whose confirmed deposits fire the rule, for example USDT.tron
action send to an address, or swap into another asset of the same wallet
scope deposit: move the deposit's amount; balance: move everything the address holds above keep_amount
min_amount a deposit, or a remainder, below it is left alone, so dust never costs a fee
keep_amount what always stays on the address; required for a network's own coin (TRX, ETH, BNB…), because it pays the fee
daily_limit optional: the most the rule moves in any 24 hours, in the asset's units

Three common setups:

  • Forward to the treasury. USDT on TRON, send, scope: deposit, your cold address, min_amount 10. Every confirmed deposit of 10 USDT or more goes on; smaller ones stay.
  • Convert on arrival. A coin you do not want to hold, swap into the one you do, with a keep_amount that covers the fees. Each deposit becomes the target coin on the same wallet. The preview shows whether a provider quotes that pair and amount.
  • Keep a float, send the excess. ETH, send, scope: balance, keep_amount 0.5, min_amount 0.1. Whenever a deposit lifts the balance 0.1 ETH or more above 0.5 ETH, everything above 0.5 ETH goes to your address.

Who can make one

Funds move with no person present, so the switch is guarded:

  • A rule is made and switched on only in the dashboard, with a 2FA code. Switching off and deleting need no code: they only stop the wallet.
  • An API key cannot make, change or switch a rule. It reads them and their log (GET /api/v1/wallets/{id}/rules and /rule-runs, scope wallets:read). A key under a daily limit therefore cannot give itself a rule that sends around that limit.
  • A rule is fixed once made, except on and off. To change it, delete it and make another, so the log always shows what a run acted under.
  • Before you confirm, Check the rule tries it on a deposit: the amount it would move, whether a send's network fee can be paid (when the address already holds the amount), and for a swap the providers' quotes at that moment.

What happens to a deposit

  1. The deposit reaches the network's confirmation count (19 on TRON, 12 on Ethereum, 2 on Bitcoin).
  2. The wallet records a run for it: one run per rule and deposit, written before anything moves.
  3. The run reads the address's balance, decides the amount, and makes an ordinary transfer or swap with the run's own idempotency key. A restart in the middle returns the same transfer instead of sending again.
  4. The run ends as done (the transfer or swap was started; its own status says how it ended), skipped (nothing to move, with the reason) or failed (it could not start, with the reason).

Only deposits confirmed after the rule was switched on fire it. What arrived while it was off stays where it is.

We ran this on kryptr.io on 1 December 2026. A rule on one wallet sent each TRX deposit of 1 TRX or more to another wallet's address, keeping what the wallet held before. The transfer that brought the 2 TRX deposit read as confirmed at 20:29:10 UTC; the deposit's run was recorded at 20:29:19 and queued its transfer within the same second, and the 2 TRX was confirmed at the other address by 20:30:31. In an earlier run that day two dust deposits of 0.000001 TRX from strangers reached the wallet; both were logged as skipped, below the minimum.

A token send pays its fee in the network's coin: a rule that forwards USDT on TRON needs TRX on the same address. Without it the run fails at once with the amount of TRX needed, and no fee is burned on a transfer that cannot complete.

The guards

  • Sanctions, both ways. A send rule's recipient is compared with the OFAC SDN list when the rule is made, when it is switched on and at each transfer. A deposit from a listed sender fires no run, and later runs leave its amount on the address until you switch the rule off and on again, which is your decision about what the address holds.
  • Daily limit. A run that would pass daily_limit is skipped and the deposit stays.
  • No loops. A wallet's swap rules may not form a cycle (409 rule_loop), and a chain of rules that feed one another across wallets stops after three runs.
  • A failed swap stops the rule. A refund arrives as a deposit of the same asset, so a swap rule switches itself off when its swap is refunded or fails, and tells you why.
  • Retries with an end. An unreadable network or a provider with no quote is tried 6 times, with waits doubling from one minute (about half an hour in all); then the run fails and the funds stay on the wallet.
  • One at a time. A run waits until the wallet's earlier transfer of that asset is final, because the chain's balance still counts those coins.

Webhooks

Event When data
rule.executed a run started its transfer or swap the run, with transfer_id or swap_id
rule.failed a run could not start it the run, with reason
rule.paused a rule switched itself off the rule, with paused_reason

rule.executed means the transfer was queued, not that it is on chain: follow the transfer by transfer.sent, transfer.confirmed or transfer.failed, and a swap by swap.completed, swap.refunded or swap.failed. A skipped run sends nothing; it is in the log with its reason.

{
  "id": "6f1d…",
  "type": "rule.executed",
  "created_at": "2026-12-01T18:40:11Z",
  "data": {
    "id": "0b6f…",
    "rule_id": "b89e…",
    "wallet_id": "dac3…",
    "deposit_id": "5e1c…",
    "status": "done",
    "amount": "250",
    "transfer_id": "9a41…",
    "swap_id": null,
    "reason": "",
    "attempts": 0,
    "created_at": "2026-12-01T18:40:02Z",
    "finished_at": "2026-12-01T18:40:11Z"
  }
}

Rules or your own code

Write the forwarding yourself when the decision needs something the wallet does not know: an order's state, a customer's tier, a price from your own book. Your server then listens for deposit.confirmed and calls the transfer endpoint with an idempotency key.

Use a rule when the decision is the same every time. It needs no key that can send on your server, it survives your server being down, and its limits are enforced where the funds are.

Checklist

  • Start with scope: deposit and a daily_limit; move to scope: balance when the amounts are known.
  • Set min_amount above the network fee of one transfer, or dust will be forwarded at a loss.
  • For a token rule, keep enough of the network's coin on the address for fees.
  • Check the recipient address and its network in the preview: a sent transfer cannot be reversed.
  • Subscribe to rule.failed and rule.paused; they are the two events that need a person.
  • Read the log (/rule-runs) when a deposit did not move: every deposit a rule looked at is there with the reason.

More guides