Getting started
Concepts
Mandates, roles, caps, allowlists, expiry, pause and revoke, the allowance model and reason bits.
#Mandate
A mandate is a numbered record in DeleqMandateGuard: one owner, one agent, a list of token rules, allowlisted recipients and routers, a validity window, an optional number of actions per day, a label, a version that grows with every change, and two switches (paused, revoked). An owner can hold up to 64 mandates.
#Owner and agent
- Owner: the wallet that created the mandate. Only the owner changes it, pauses, unpauses or revokes it. The owner's tokens are what the agent spends.
- Agent: the one address that may execute under the mandate. It can never change a limit; it can only pause itself.
#Caps
- Per transaction: the most one action may move of a token.
- Per UTC day: the most all actions together may move of a token on one calendar day in UTC (timestamp / 86,400). It resets at 00:00 UTC, so up to twice a cap can move around one midnight.
- Actions per UTC day: how many payments and swaps the agent may make per day, across all tokens. 0 = no count limit.
#Allowlists
- Tokens (up to 16): a token without a rule cannot be spent. For a swap, the token bought must be listed too (caps 0 is fine for a token the agent only receives).
- Recipients (up to 32): the only addresses a payment may go to.
- Routers (up to 4): swap routers the agent may use. The output always goes to the owner, never to the agent.
#Validity window
Every mandate has a start (validFrom, default: now) and an expiry, at most 730 days apart. Outside the window every action is refused.
#Pause and revoke
The guard reads the mandate on every call, so a pause or revoke applies from the next transaction, in the same block if it comes later. A pause can be lifted by the owner; a revoke is final.
#Non-custodial allowance model
The owner approves the guard for an ERC-20 amount, the usual way. That approval is a ceiling; the mandate's caps apply on top. Nothing is deposited: a payment is transferFrom(owner → recipient), and a swap pulls the amount into the guard, swaps it with the output sent to the owner and checks that nothing is left, inside one transaction.
The allowance belongs to the owner and the guard, not to one mandate: two mandates of the same owner share it. Approve 0 to stop everything at the token level.
#Reason bitmask
checkTransfer and checkSwap return one bit per broken rule; 0 means the guard would let the action through. The execute functions run the same checks and revert with Rejected(reasons). The site uses the same positions (a test reads them from the Solidity library).
Answer from DeleqMandateGuard.check view
Inside the mandate
contract bits 0 · site engine bits 0 · match
Answer from DeleqMandateGuard.check view
Rejected · 1 reason
Over per-tx capThe amount is above the per-transaction cap for this token.
| Bit | Name | Shown as | Meaning |
|---|---|---|---|
| 0 | UNKNOWN_MANDATE | Unknown mandate | There is no mandate with this number. |
| 1 | REVOKED | Revoked | The owner revoked this mandate. Nothing can run under it again. |
| 2 | PAUSED | Paused | The mandate is paused by the owner (or by the agent itself). |
| 3 | NOT_STARTED | Not started | The mandate's start time has not been reached. |
| 4 | EXPIRED | Expired | The mandate's end time has passed. |
| 5 | NOT_AGENT | Not the agent | Only the agent address named in the mandate can act under it. |
| 6 | ZERO_AMOUNT | Zero amount | The amount is zero. |
| 7 | TOKEN_NOT_ALLOWED | Token not allowed | The mandate does not list this token for spending. |
| 8 | RECIPIENT_NOT_ALLOWED | Recipient not allowed | The recipient is not on the mandate's allowlist. |
| 9 | OVER_PER_TX | Over per-tx cap | The amount is above the per-transaction cap for this token. |
| 10 | OVER_DAILY | Over daily cap | Today's spend plus this amount would pass the daily cap (UTC day). |
| 11 | DAILY_COUNT | Daily action limit | The mandate's number of actions per UTC day is used up. |
| 12 | ROUTER_NOT_ALLOWED | Router not allowed | The swap router is not on the mandate's allowlist. |
| 13 | TOKEN_OUT_NOT_ALLOWED | Output token not allowed | The token the swap would buy is not listed in the mandate. |
| 14 | LOW_ALLOWANCE | Allowance too low | The owner's ERC-20 allowance to the guard is below the amount. |
| 15 | LOW_BALANCE | Balance too low | The owner's wallet holds less than the amount. |
| 16 | NO_MIN_OUT | No minimum output | A swap needs a minimum output above zero. |
| 17 | SAME_TOKEN | Same token | The swap sells and buys the same token. |
| 18 | TOKEN_UNREADABLE | Token unreadable | The token did not answer balanceOf / allowance like an ERC-20. |
The contract reference shows how the bits are computed.