You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CLAUDE.md
+15-35Lines changed: 15 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,55 +34,35 @@ Deployment scripts are in `script/` directory. Required environment variables:
34
34
35
35
### Core Components
36
36
37
-
This is a Solidity project implementing **Sapient Signer modules** for Sequence v3 wallets, focusing on cross-chain payment and bridging functionality through LiFi and relay protocols.
37
+
This is a Solidity project implementing cross-chain payment and bridging functionality through TrailsRouter and TrailsIntentEntrypoint for Sequence v3 wallets.
38
38
39
39
#### Primary Contracts
40
-
-**TrailsLiFiSapientSigner** (`src/TrailsLiFiSapientSigner.sol`) - Validates LiFi protocol operations (swaps/bridges) via off-chain attestations. Targets a specific immutable `TARGET_LIFI_DIAMOND` address for security.
41
-
-**TrailsRelaySapientSigner** (`src/TrailsRelaySapientSigner.sol`) - Validates relay operations through similar attestation mechanism.
42
-
-**TrailsTokenSweeper** (`src/TrailsTokenSweeper.sol`) - Utility contract for token recovery operations.
40
+
-**TrailsRouter** (`src/TrailsRouter.sol`) - Consolidated router contract combining multicall routing, balance injection, and token sweeping functionality. Executes via delegatecall from Sequence v3 wallets.
41
+
-**TrailsRouterShim** (`src/TrailsRouterShim.sol`) - Lightweight shim that wraps router calls and records execution success using storage sentinels.
42
+
-**TrailsIntentEntrypoint** (`src/TrailsIntentEntrypoint.sol`) - EIP-712 signature-based entrypoint for depositing tokens to intent addresses with user authorization.
43
43
44
44
#### Library Architecture
45
45
The project uses a modular library approach under `src/libraries/`:
46
46
47
-
**Execution Info Management:**
48
-
-`TrailsExecutionInfoInterpreter.sol` - Standardizes cross-chain execution data
49
-
-`TrailsExecutionInfoParams.sol` - Parameter handling for execution info
47
+
**Sentinel Management:**
48
+
-`TrailsSentinelLib.sol` - Manages storage sentinels for conditional execution tracking using tstore/sstore
50
49
51
-
**LiFi Integration:**
52
-
-`TrailsLiFiFlagDecoder.sol` - Decodes LiFi call data using flag-based strategies
53
-
-`TrailsLiFiInterpreter.sol` - Interprets and validates LiFi operations
54
-
-`TrailsLiFiValidator.sol` - Validation logic for LiFi transactions
55
-
56
-
**Relay Integration:**
57
-
-`TrailsRelayDecoder.sol` - Decodes relay call data
-`TrailsRelayValidator.sol` - Validation logic for relay transactions
60
-
-`TrailsRelayParams.sol` - Parameter handling for relay operations
50
+
### Key Architecture Patterns
61
51
62
-
#### Interface Definitions
63
-
-`TrailsExecutionInfo.sol` - Core execution info structure
64
-
-`TrailsLiFi.sol` - LiFi-specific interfaces and decoding strategies
65
-
-`TrailsRelay.sol` - Relay-specific interfaces
52
+
**Delegatecall-Only Execution:** TrailsRouter and TrailsRouterShim are designed to execute only via delegatecall from Sequence v3 wallets. Direct calls are blocked via `onlyDelegatecall` modifier.
66
53
67
-
### Key Architecture Patterns
54
+
**Success Sentinel Pattern:** Operations track success/failure via storage sentinels keyed by `opHash`. This enables conditional fee collection and fallback refund logic.
68
55
69
-
**Sapient Signer Integration:**Both main contracts implement `ISapient` interface and integrate with Sequence wallet configuration trees as "Sapient Signer Leaves". They validate off-chain attestations to authorize operations without requiring direct wallet pre-approval.
56
+
**Balance Injection:**Runtime balance injection allows protocols to receive exact token amounts when bridge amounts are unknown beforehand (due to slippage and fees).
70
57
71
-
**Validation Flow:**
72
-
1. Contract receives payload and encoded signature (attestation)
73
-
2. Validates target addresses match immutable contract addresses
74
-
3. Recovers attestation signer from signature
75
-
4. Decodes and interprets operation data using libraries
76
-
5. Computes intent hash from operations + signer
77
-
6. Returns hash for comparison against wallet's configured `imageHash`
58
+
**EIP-712 Intent Authorization:** TrailsIntentEntrypoint uses EIP-712 signatures to authorize deposits to intent addresses, preventing replay attacks via nonce tracking.
78
59
79
-
**Security Model:** Each contract is deployed with immutable target addresses to prevent authorization of calls to arbitrary contracts. All validation is stateless and deterministic.
80
60
81
61
### External Dependencies
82
-
-**Sequence Wallet v3**- Core wallet infrastructure and payload handling
-**Tstorish**(`tstorish`) - Storage library for tstore/sstore operations
65
+
-**ERC2470**(`erc2470-libs`) - Singleton deployment pattern for deterministic addresses
86
66
87
67
### Testing Structure
88
68
Tests mirror the source structure with unit tests for libraries and integration tests for main contracts. Mock contracts in `test/mocks/` simulate external protocol interactions.
Copy file name to clipboardExpand all lines: CODE4ARENA.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Trails Contracts — Code4rena Audit Prep
2
2
3
-
These contracts are used with **Trails** (https://docs.trails.build/) and Sequence v3 **sapient signer**wallets. The closed‑source **Intent Machine** is **out of scope** for this audit, but auditors can exercise public API interfaces that drive the on‑chain flows.
3
+
These contracts are used with **Trails** (https://docs.trails.build/) and Sequence v3 wallets. The closed‑source **Intent Machine** is **out of scope** for this audit, but auditors can exercise public API interfaces that drive the on‑chain flows.
The latest innovation in the Trails ecosystem: a single entrypoint contract that enables true 1-click crypto transactions by accepting intents through ETH/ERC20 transfers with calldata suffixes.
13
13
14
14
**Key Features:**
15
15
- Single entrypoint for all intent-based operations
16
-
-Transfer suffix pattern eliminates approve step
17
-
-Commit-prove pattern with signature validation
16
+
-EIP-712 signature verification for secure intent authorization
17
+
-ERC-2612 permit support for gasless approvals
18
18
- Generic multicall execution for bridges, swaps, and DeFi operations
19
19
- Comprehensive safety mechanisms and emergency functions
0 commit comments