Repository Structure
Foundry Commands
All commands run from the contracts/ directory.
Writing Tests
Tests live in contracts/test/. Each contract has its own test file using Foundry’s testing framework.
Test File Structure
Useful Test Patterns
vm.prank / vm.startPrank — impersonate any address:
vm.warp — move time forward:
vm.expectRevert — assert a revert:
vm.expectEmit — assert an event:
deal — fund an address with native tokens:
The USDT 6-Decimal Rule
This is the single most common source of bugs. All USDT amounts in Prophet contracts use 6 decimal places.
In TypeScript (agents/frontend):
In Foundry tests:
Security Patterns
These patterns are enforced throughout the codebase and must be maintained in all new code:
Checks-Effects-Interactions
State changes happen before external calls:
SafeERC20
Never use raw transfer() or transferFrom():
ReentrancyGuard
All state-changing external functions use nonReentrant:
Never allow zero-amount operations:
Deploy Script Walkthrough
contracts/script/Deploy.s.sol implements the full deployment sequence:
OpenZeppelin Contracts Used
Adding a New Market Category
Market categories are string labels stored in metadata, not an enum on-chain. To add a new category:
- Add the category name to the category selector in
frontendV2/src/app/(dashboard)/markets/page.tsx
- Add the filter case to the market listing component
- No contract changes required — categories are stored in 0G Storage metadata blobs
Contract Size Limits
EVM contracts must be under 24KB. Check sizes after any significant additions:
If a contract approaches 24KB:
- Extract logic into libraries (
contracts/src/libraries/)
- Use
internal functions instead of duplicating logic
- Consider the proxy pattern for future upgrades (not currently used in Prophet MVP)