The contract set
Two more source units have no deployment of their own:
IAnafiDelegationAdapteris the interface that each adapter implements. It has one function,anafiRegistry(), which returns the registry that the adapter reads.AdapterGasSettlementis an internal library. Both adapters use it to compute the redeem digest and the gas charge. Redeem gives its formulas.
IAvatar:
false for a failed inner call and does not revert. The adapter always sends operation = 0, a plain call. It never sends a delegatecall.
How the contracts relate
The registry is the root. Each other upgradeable contract stores the registry address once, at initialization, and reads three things from it:engineSigKey(): the address that must sign each redeem and each attested commit.isDelegationAdapter(address): an adapter checks its own entry first on each redeem.owner(): the only address that can call the admin functions and upgrade the contract.
engineSigKey() from the registry that each Safe names in its own policy.
Who can call what
The contracts know four parties. The engine never needs to send a transaction itself: a signature of the engine key is the authorization, and any address can submit it.Admin powers and upgrades
The registry uses OpenZeppelinOwnable2Step. Ownership moves only in two steps: the owner calls transferOwnership(newOwner), and then newOwner calls acceptOwnership(). renounceOwnership() always reverts with OwnershipNotRenounceable(). So the set always has an admin.
The DSL registry and both adapters have no owner of their own. Each one returns AnafiRegistry.owner() from its own owner() and reads it at the time of each call. A handover at the registry moves the admin of all four contracts in the same transaction.
The registry owner can do these things:
The admin functions above do not include these things:
- An upgrade of
AnafiSwapExecutororAnafiOffRampFallbackHandler. Neither has a proxy or an owner. A fix is a new contract. - A change of the swap executor after
initializeSwaps, other than through an upgrade of the ERC20Allow adapter. - A call to a Safe, or a change of the allowance that an owner gave to a token.
- A renounce of the admin role.
The Safe adapter executes each leg as a plain call from the Safe, with the target, the value and the call data of the leg. The ERC20Allow adapter pulls tokens only through the allowances that the account gave it. Redeem lists the checks of each adapter.
Upgraded(address indexed implementation) on an upgrade. The registry emits EngineIdentitySet on each key change, and DelegationAdapterAdded and DelegationAdapterRemoved on each list change. Verification shows how to watch these events.
The exit of each account kind
The owner can stop Anafi without the Anafi engine, the Anafi API or the registry owner. The exit is one owner transaction for a Safe, and one transaction for each approved token for an ERC20Allow account. It takes effect in the block where it lands.
Use these facts when you build an exit:
prevModuleis the module before the adapter in the linked module list of the Safe. Read it withgetModulesPaginatedon the Safe. Do not guess it.- An exit does not cancel a redeem that the engine signed before. The adapter keeps no record of the grant. If the owner grants the permission again, an unexpired signed redeem can land. Only its
validUntilbounds it. - For an ERC20Allow account,
setBlocked(true)stops all pulls in one transaction. The block switch is state of the adapter. The allowance is state of the token, and only the account can set it. - When the registry owner delists an adapter, its redeems stop, but no grant changes. The owner exit is still the only call that removes the grant.
- An exit does not clear a gas credit. The account claims a credit with
claimGasCredit(token, to)at any time, with no grant. - A Safe that installed the off-ramp handler stops off-ramp orders with
setOffRampPolicyand a zeroauthority, or with a new fallback handler. See Off-ramp handler.
Read more
Redeem
How one payment is authorized and executed on chain.
Verification
What the chain publishes about the engine, and how to check it.
Deployments
The addresses on each network.
Security
The trust model in plain words.