Skip to content

Commit d5644ba

Browse files
Merge pull request #52 from aavegotchi/codex/devex-add-agents-md
DevEx: Add AGENTS.md
2 parents 51416af + 5bcc12e commit d5644ba

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

AGENTS.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Agent Notes (Aavegotchi Contracts)
2+
3+
This repo contains Aavegotchi smart contracts built around the EIP-2535 Diamond pattern (diamond + facets + shared storage).
4+
5+
These notes are for automated agents and contributors working in this repo.
6+
7+
## Safety Defaults (Read First)
8+
9+
- Do not broadcast transactions by default.
10+
- Prefer local forks/simulations (`hardhat` network) over live networks.
11+
- Never print or commit secrets (for example `.env`, private keys, API keys).
12+
- If a task requires a funded key, hardware wallet, multisig, Defender relayer, or mainnet/testnet interaction: stop and ask for explicit confirmation + parameters.
13+
14+
## Quick Local Validation
15+
16+
```bash
17+
git submodule update --init --recursive
18+
npm ci
19+
20+
forge build --sizes
21+
npx hardhat compile
22+
```
23+
24+
## Repo Map (Where Things Live)
25+
26+
- Main diamond:
27+
- `contracts/Aavegotchi/Diamond.sol`
28+
- `contracts/Aavegotchi/InitDiamond.sol`
29+
- Facets: `contracts/Aavegotchi/facets/`
30+
- Libraries: `contracts/Aavegotchi/libraries/`
31+
- Diamond kernel + shared libs/interfaces:
32+
- `contracts/shared/`
33+
- Addresses/constants by chain:
34+
- `helpers/constants.ts`
35+
- Aggregated ABI for the Aavegotchi diamond:
36+
- `diamondABI/diamond.json` (generated)
37+
- Generate: `npx hardhat diamondABI` (after `npx hardhat compile`)
38+
- Ops/tasks:
39+
- Hardhat tasks: `tasks/`
40+
- Scripts: `scripts/`
41+
42+
## Diamond Gotchas (Important)
43+
44+
### Shared Storage (AppStorage)
45+
46+
The diamond uses a single `AppStorage` struct stored at slot 0:
47+
- `contracts/Aavegotchi/libraries/LibAppStorage.sol`
48+
49+
Rules:
50+
- Treat it like a database schema.
51+
- Append-only: do not reorder/remove existing fields or change field types.
52+
- Add new fields at the end and consider any required initialization/migrations.
53+
54+
### Meta-Transactions
55+
56+
Some auth paths use `LibMeta.msgSender()` (meta-tx aware) rather than `msg.sender`:
57+
- `contracts/shared/libraries/LibMeta.sol`
58+
- `contracts/Aavegotchi/facets/MetaTransactionsFacet.sol`
59+
60+
When adding new permissioned functions in facets, be deliberate about which sender pattern is correct.
61+
62+
### Calling Facets
63+
64+
Externally, users typically call the diamond address with facet ABIs. Selector routing is implemented via `LibDiamond`:
65+
- `contracts/shared/libraries/LibDiamond.sol`
66+
67+
## PR Workflow Expectations
68+
69+
- Use a branch name with `codex/` prefix.
70+
- Keep changes scoped to one concern per PR when possible.
71+
- Include a short test section in the PR description (what you ran locally).
72+

0 commit comments

Comments
 (0)