Skip to content

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.

Owner walletholds the USDGGuardchecks, holds nothingRecipientallowlistedtransferFrom(owner → recipient)
The approval caps what the guard may pull; nothing is deposited.

#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.

Illustration · sample values
BitNameShown asMeaning
0UNKNOWN_MANDATEUnknown mandateThere is no mandate with this number.
1REVOKEDRevokedThe owner revoked this mandate. Nothing can run under it again.
2PAUSEDPausedThe mandate is paused by the owner (or by the agent itself).
3NOT_STARTEDNot startedThe mandate's start time has not been reached.
4EXPIREDExpiredThe mandate's end time has passed.
5NOT_AGENTNot the agentOnly the agent address named in the mandate can act under it.
6ZERO_AMOUNTZero amountThe amount is zero.
7TOKEN_NOT_ALLOWEDToken not allowedThe mandate does not list this token for spending.
8RECIPIENT_NOT_ALLOWEDRecipient not allowedThe recipient is not on the mandate's allowlist.
9OVER_PER_TXOver per-tx capThe amount is above the per-transaction cap for this token.
10OVER_DAILYOver daily capToday's spend plus this amount would pass the daily cap (UTC day).
11DAILY_COUNTDaily action limitThe mandate's number of actions per UTC day is used up.
12ROUTER_NOT_ALLOWEDRouter not allowedThe swap router is not on the mandate's allowlist.
13TOKEN_OUT_NOT_ALLOWEDOutput token not allowedThe token the swap would buy is not listed in the mandate.
14LOW_ALLOWANCEAllowance too lowThe owner's ERC-20 allowance to the guard is below the amount.
15LOW_BALANCEBalance too lowThe owner's wallet holds less than the amount.
16NO_MIN_OUTNo minimum outputA swap needs a minimum output above zero.
17SAME_TOKENSame tokenThe swap sells and buys the same token.
18TOKEN_UNREADABLEToken unreadableThe token did not answer balanceOf / allowance like an ERC-20.

The contract reference shows how the bits are computed.