references/vyper.md
Vyper Entry Point Detection
Entry Point Identification (State-Changing Only)
Include: State-Changing Functions
@external # State-changing entry point
def function_name():
pass
@external
@payable # State-changing, receives ETH
def payable_function():
pass
@external
@nonreentrant("lock") # State-changing with reentrancy protection
def protected():
pass
Exclude: Read-Only Functions
@external
@view # EXCLUDE - cannot modify state
def read_only():
pass
@external
@pure # EXCLUDE - no state access
def pure_function():
pass
Decorator Matrix
| Decorators | Include? | Notes |
|------------|----------|-------|
| @external | Yes | State-changing entry point |
| @external @payable | Yes | State-changing, receives ETH |
| @external @nonreentrant | Yes | State-changing with protection |
| @external @view | No | Read-only, exclude |
| @external @pure | No | No state access, exclude |
| @internal | No | Not externally callable |
| @deploy | No | Constructor (Vyper 0.4+) |
Special Entry Points
@external
@payable
def __default__(): # Fallback function (receives ETH + unmatched calls)
pass
Access Control Patterns
Owner Pattern
owner: public(address)
@external
def restricted_function():
assert msg.sender == self.owner, "Not owner"
# ...
Role-Based Patterns
# Common patterns
admin: public(address)
governance: public(address)
guardian: public(address)
operator: public(address)
# Mapping-based roles
authorized: public(HashMap[address, bool])
minters: public(HashMap[address, bool])
@external
def mint(to: address, amount: uint256):
assert self.minters[msg.sender], "Not minter"
# ...
Access Control Classification
| Pattern | Classification |
|---------|----------------|
| assert msg.sender == self.owner | Admin/Owner |
| assert msg.sender == self.admin | Admin |
| assert msg.sender == self.governance | Governance |
| assert msg.sender == self.guardian | Guardian |
| assert self.authorized[msg.sender] | Review Required |
| assert self.whitelist[msg.sender] | Review Required |
Contract-Only Detection
Callback Functions
A callback name does not restrict callers. Classify the body's actual assertions; an unguarded state-changing callback is Public (Unrestricted).
@external
def onERC721Received(...) -> bytes4:
return method_id("onERC721Received(address,address,uint256,bytes)")
@external
def uniswapV3SwapCallback(amount0: int256, amount1: int256, data: Bytes[...]):
# Must verify caller is the pool
pass
Contract-Caller Checks
assert msg.sender == self.pool, "Only pool"
assert msg.sender != tx.origin, "No direct call" # Call-path condition, not protocol authentication
Extraction Strategy
- Parse all
.vyfiles - For each function:
- Check for
@externaldecorator - Skip functions with
@viewor@puredecorators - Record function name and parameters
- Record line number
- Check for access control assertions in function body
- Check for
- Classify:
- No access assertions → Public (Unrestricted)
msg.sender == self.X→ Check what X isself.mapping[msg.sender]→ Review Required- Caller pinned to an established integration contract → Contract-Only
- Caller checked against an unresolved configured address → Review Required
- Callback name without caller checks → Public (Unrestricted)
Vyper-Specific Considerations
- No Modifiers: Vyper doesn't have modifiers—access control is inline
assertstatements - No Inheritance: Each contract is standalone (interfaces only)
- Explicit is Better: All visibility must be declared explicitly
- Default Internal: Functions without decorators are internal
Common Gotchas
- Initializer Pattern: Look for
initialized: boolflag with one-time setup - Raw Calls:
raw_call()can delegate to other contracts - Create Functions:
create_minimal_proxy_to(),create_copy_of()are factory patterns - Reentrancy:
@nonreentrantprotects against reentrancy but function is still entry point