TomoLabs converts Uniswap v4 swap fees into an autonomous on-chain debt repayment engine using a permissioned hook and a non-custodial expense ledger.
✅ Live on Ethereum Mainnet
✅ Contracts Verified on Etherscan
✅ End-to-End Fee → Debt → Repayment Flow Operational
✅ Production-Grade Uniswap v4 Hook
This hook is live and deployed on Ethereum mainnet with fully verified contracts.
TomoLabs introduces a first-of-its-kind on-chain system where real-world group debt is repaid passively through DEX trading activity using programmable Uniswap v4 Hooks. Instead of relying on deadlines, reminders, or manual transfers, financial settlement is embedded directly into live market liquidity. This creates a new DeFi primitive: Debt as a Function of Trading Volume — where every swap becomes a settlement event.
✨ Live Hook on Ethereum • ⚙️ Powered by Uniswap v4 Hooks
🎥 Demo & Technical Walkthrough:
https://youtu.be/kkD-mo4hR3s?si=eru3pAn1B_A_1Q2S
All Uniswap v4 Hook logic, automated fee-to-debt repayment flow, permissioned hook system, and Foundry test suite were created during the Hookathon period. The system extends basic expense ledger concepts with entirely new Hook-based automation, written specifically for this cohort.
1.) Trustless Debt Settlement: All group expenses, member balances, and repayments are enforced entirely by smart contracts, eliminating reliance on off-chain trust, manual accounting, or centralized intermediaries.
2.) Automated Fee-to-Debt Conversion: Swap fees captured via Uniswap v4 Hooks are automatically routed into the Splitwise contract, converting passive trading activity into real-time debt repayments without user intervention.
3.) Composable DeFi Integration: The system is natively composable with Uniswap v4 permissionless liquidity and other DeFi protocols via standard ERC-20 flows.
4.) Non-Custodial & Permissioned Control: Users retain full control of their funds at all times, while sensitive repayment automation is strictly permissioned to the registered hook, preventing unauthorized fund movement.
5.) Transparent, On-Chain Accountability: Every expense, repayment, and auto-settlement action is emitted as on-chain events, enabling block explorers, DAOs, and analytics tools to verify all financial flows in real time.
-
Trustless Group Expense Management:
Creates on-chain expense groups with multiple members. Records shared expenses with:
-
Group ID
-
Token address
-
Total amount
-
Designated payer
Automatically calculates proportional debt per member.
-
-
Uniswap v4 Fee Capture via Hooks:
Integrates natively with Uniswap v4 Hooks to:
-
Intercept swaps via afterSwap
-
Capture protocol swap fees directly from the Pool Manager
-
Support both token0 and token1 fee flows
This enables DEX trades to become a repayment engine.
-
-
Automated Fee-to-Debt Repayment Engine:
Captured swap fees are:
-
Automatically routed into the Splitwise contract
-
Converted into real-time repayments for outstanding debts
-
Executed without any user transaction or approval
This creates a passive, always-on repayment system.
-
-
Permissioned Auto-Repayment Security:
Only the authorized SplitwiseHook can trigger autoRepay().
-
Protection includes:
-
On-chain hook verification
-
Revert protection for unauthorized callers
This ensures zero-exploit surface for forced repayments.
-
-
Manual Repayment Support:
Users can also repay debts manually via:
- repay(creditor, token, amount)
Supports:
-
Partial repayments
-
ERC-20 token-based repayments
-
Real-time debt reduction updates
-
Multi-Token Debt Tracking
Tracks debts:
-
Per user
-
Per creditor
-
Per token
Enables:
-
Multi-asset group expenses (USDC, ETH, LSTs, etc.)
-
Segmented settlement per asset class
-
-
Event-Driven On-Chain Transparency:
Emits verifiable events for:
-
GroupCreated
-
ExpenseAdded
-
ManualRepayment
-
AutoRepayment
-
HookSet
Enables:
-
Subgraph indexing
-
DAO dashboards
-
Real-time analytics
-
-
Non-Custodial Fund Flow:
Users never relinquish wallet control:
-
Hook only routes protocol fees
-
Users control all personal repayments
-
No pooled custody risk
Fully aligned with DeFi self-sovereignty principles.
-
-
Gas-Efficient Settlement Design:
Optimized for:
-
Batch group creation
-
Single-call fee harvesting
-
Minimal storage writes
Built for high-frequency swap environments.
-
-
Create an On-Chain Expense Group:
Initialize a new group by providing member addresses. The Splitwise contract assigns a groupId and stores all participants for future expense-sharing.
-
Add Shared Expenses:
Record expenses directly on-chain by calling addExpense() with:
-
Group ID
-
Token used for payment
-
Total expense amount
-
The payer’s address
The contract automatically splits the amount among all members and updates internal debt balances.
-
-
Deploy & Link the Splitwise Hook
Deploy the SplitwiseHook with:
-
PoolManager address
-
Splitwise contract address
-
Default bill payer
Then call setHook() on Splitwise to authorize the hook.
This enables the system to accept automated repayments.
-
-
Start Trading on the Uniswap v4 Pool
Users interact with the Uniswap v4 pool as usual.
Whenever a swap occurs:
-
The hook intercepts afterSwap
-
Extracts the swap fee generated by the trade
-
Sends the fee to Splitwise as repayment on the payer’s behalf
This converts every trade into a passive debt-reduction event.
-
-
Automatic Fee-Based Repayments
The SplitwiseHook calls autoRepay() with:
-
Token address
-
Amount of fee captured
-
Designated payer
Splitwise verifies hook permissions and updates the debt ledger entirely on-chain.
-
-
Manual Repayment
If users want to clear debt faster, they can manually repay using:
- repay(creditor, token, amount)
The contract recalculates remaining debt balances in real time.
-
View Debt Balances
Anyone can query:
-
Who owes whom
-
How much
-
In which token
using getOwed() and getGroupMembers().
This makes expense history fully transparent and audit-friendly.
-
-
Real-Time Automated Settlement
As more swaps occur in the Uniswap pool:
-
Fee revenue continues flowing into Splitwise
-
Debts shrink automatically
-
Groups settle expenses without requiring members to take any manual action
Your DeFi activity becomes a continuous settlement engine.
-
This project uses Foundry for testing.
Install Foundry:
curl -L https://foundry.paradigm.xyz | bash
foundryup
forge test -vvvv
┌──────────── User Swap on Uniswap ─────────────┐
│
┌─────────▼─────────┐
│ Uniswap v4 Pool │
│ (Liquidity AMM) │
└─────────┬─────────┘
│ afterSwap()
┌─────────▼─────────┐
│ SplitwiseHook │ ◄── Hook Authorization
│ (Automation) │
└─────────┬─────────┘
│ PoolManager.take()
┌─────────▼─────────┐
│ Fee Extraction │ ◄── Token0 / Token1 Logic
└─────────┬─────────┘
│ autoRepay()
┌────────────────▼────────────────┐
│ Splitwise Contract │ ◄── On-chain Debt Ledger
│ - Groups & Members │
│ - Expense Tracking │
│ - Per-User Debt Balances │
│ - Manual + Auto Repayment │
└───────────────┬───────────────────┘
│
┌─────────────▼─────────────┐
│ Bill Payer Settlement │ ◄── Trading fees reduce debt
└─────────────┬─────────────┘
│
┌─────────────▼─────────────┐
│ Event & Indexing Layer │ ◄── The Graph / Dashboards
└───────────────────────────┘
- The Splitwise contract only accepts autoRepay() calls from the authorized SplitwiseHook.
- The hook is set once via setHook() and cannot be spoofed.
- All debt updates are fully on-chain and verifiable.
- No user funds are ever held in custody by the system.
- All swap fees are pulled directly from the Uniswap v4 PoolManager.
- Hook logic tested with Foundry
- Fee capture and repayment flow validated through deployment on Ethereum mainnet and local testnet simulations.
- All state transitions are fully on-chain and verifiable via events
- Uniswap v4 Hooks – afterSwap-based protocol-level fee capture and fee routing
Splitwise Core Contract (Debt Engine):
0x9e9ee1221867413486b8c4a21c185b09b5b28c2f
🔍 Verified on Etherscan:
https://etherscan.io/address/0x9e9ee1221867413486b8c4a21c185b09b5b28c2f
Splitwise Uniswap v4 Hook (Auto Fee Repayment):
0x910880539c2cdba3f538dbb753b698555d108040
🔍 Verified on Etherscan:
https://etherscan.io/address/0x910880539c2cdba3f538dbb753b698555d108040