TEEFi is a comprehensive platform for secure and verifiable financial transactions leveraging Trusted Execution Environment (TEE) technology, specifically Intel SGX. It integrates AI-powered financial agents with blockchain DeFi protocols to provide investment advice, yield optimization, and secure transaction execution. The platform consists of multiple components working together to ensure autonomy, security, and efficiency in decentralized finance operations.
Note: Reference implementation, not production-ready.
TEEFi combines cutting-edge technologies to create a secure DeFi ecosystem:
A Python-based service that provides AI-powered investment advice and yield optimization recommendations. It analyzes Aave protocol market data through Model Context Protocol (MCP) integration and uses large language models to deliver personalized financial insights.
Key Features:
- Personalized investment recommendations
- Yield optimization analysis
- Direct Aave protocol integration
- LLM-powered market analysis
A Go-based backend service responsible for executing financial transactions in a secure manner using Intel SGX TEE. It handles deposits, withdrawals, and yield generation while ensuring all operations are TEE-verified.
Key Features:
- REST API for financial operations
- TEE/SGX integration for secure transaction signing
- On-chain operations (deposit, withdraw, claim)
- Block scanning and event processing
Smart contracts deployed on Ethereum-compatible networks that enable secure financial transactions. The contracts integrate with lending protocols like Aave and manage user wallets through TEE-verified transactions.
Key Features:
- Modular, upgradeable contract architecture
- TEE attestation verification
- Integration with lending protocols
- Trust-managed wallet proxies
TEEFi follows a layered architecture designed for security, modularity, and scalability:
┌───────────────────┐
│ Financial Agent │ ← AI Analysis & Recommendations
│ (Python/FastAPI) │
└───────────────────┘
│
▼
┌───────────────────┐
│ Financial Backend │ ← Transaction Creation
│ (Go/Gin + TEE) │
└───────────────────┘
│
▼
┌───────────────────┐
│ EVM Contracts │ ← On-Chain Execution
│ (Solidity) │
└───────────────────┘
- User Request: Financial Agent analyzes market data and provides investment advice
- Transaction Preparation: Backend validates requests and prepares TEE-signed transactions
- On-Chain Execution: Smart contracts verify TEE attestations and execute operations
- Yield Generation: Funds are deployed to lending protocols for yield optimization
- TEE Integration: All sensitive operations occur within Intel SGX enclaves
- Attestation Verification: Smart contracts verify TEE hardware attestation before execution
- AccessControl: Smart contracts provide high-level access rights verification
TEEFi/
├── financial-agent/ # AI-powered financial advice service
│ ├── src/financial_agent/ # Python application code
│ ├── tests/ # Unit and integration tests
│ ├── Dockerfile # Containerization
│ ├── docker-compose.yml # Production deployment
│ ├── pyproject.toml # Python dependencies
│ └── README.md # Component documentation
│
├── financial-agent-backend/ # Go backend with TEE integration
│ ├── cmd/ # Application entry point
│ ├── core/ # Business logic
│ ├── config/ # Configuration management
│ ├── tests/ # Integration tests
│ ├── graminize_scripts/ # SGX deployment scripts
│ ├── Dockerfile # Containerization
│ ├── go.mod # Go dependencies
│ └── README.md # Component documentation
│
└── teefi-evm-contracts/ # Smart contracts
├── contracts/ # Solidity source code
├── test/ # Contract tests
├── ignition/ # Deployment scripts
├── hardhat.config.js # Hardhat configuration
├── package.json # Node dependencies
└── README.md # Component documentation
- Operating System: Linux/Windows/macOS
- Docker: For containerized deployment
- Intel SGX: For TEE features (optional for development)
- Python 3.12+
- UV package manager
- LLM API access (Google/Together AI)
- Aave MCP server access
- Go 1.23+
- Ethereum RPC endpoint access
- Intel SGX (for production TEE features)
- Node.js 18+
- npm or yarn
- Hardhat
- Ethereum RPC endpoint access
- Install Docker and Docker Compose
- Set up Ethereum RPC endpoint (e.g., Infura, Alchemy)
- Obtain necessary API keys (LLM providers, RPC access)
-
Clone the repository:
git clone <https://github.com/Xyber-Labs/TEEFi> cd TEEFi git submodule update --init --recursive
-
Set up each component:
Financial Agent:
cd financial-agent uv sync cp env.example .env # Configure .env with API keys and MCP server URL
Financial Agent Backend:
cd ../financial-agent-backend go mod download cp config.yaml.example config.yaml # Configure config.yaml with RPC URL and contract addresses
TEEFi EVM Contracts:
cd ../teefi-evm-contracts npm install cp .env.example .env # Configure .env with RPC URL and deployment keys
-
Deploy contracts:
cd teefi-evm-contracts npx hardhat compile npx hardhat ignition deploy ignition/modules/TeeFiModule.js --parameters <params> --network <network>
-
Start services:
# Start backend cd ../financial-agent-backend go run cmd/main.go # Start financial agent cd ../financial-agent uvicorn financial_agent.__main__:app --reload --host 0.0.0.0 --port 8000
For production deployment with Docker:
# Build and start all services
docker-compose -f financial-agent/docker-compose.yml up --build
docker-compose -f financial-agent-backend/docker-compose.yml up --buildFor TEE-enabled deployment:
cd financial-agent-backend/graminize_scripts
./0_generate_gram_key.sh
./1_build_base_docker_image.sh
./2_build_prod_docker_image.sh
./3_graminize_image.sh
./5_deploy_gram_image.shcd financial-agent
uv run pytest tests/cd financial-agent-backend
go test ./...
make coverage # For coverage reportcd teefi-evm-contracts
npx hardhat test
npx hardhat coverage # For coverage report# Run all component tests
cd financial-agent-backend/tests
go test -tags=integration ./...This project is licensed under the MIT License - see the LICENSE file for details
Copyright (c) 2026 Xyber.inc
We welcome contributions to TEEFi! Please follow these steps:
- Fork the individual sub component
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow existing code style and conventions
- Add tests for new features
- Update documentation as needed
- Ensure all tests pass before submitting PR
For questions, issues, or contributions:
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: See individual component READMEs for detailed guides