A decentralized application (dApp) for peer-to-peer trading of Financial NFTs with real-time net value calculations and atomic swaps.
This platform is designed for experienced DeFi users to trade complex financial instruments represented as NFTs (like Uniswap V3 LP positions, Aave yield tokens, etc.) in a specialized, data-rich environment.
- Portfolio Dashboard: Scans wallet for Financial NFTs with live net value calculations
- Atomic Swaps: Non-custodial trading via smart contracts
- Real-time Valuations: Client-side calculation of underlying asset values
- Tool-first Design: Built for power users who need detailed financial data
ethproj1/
├── contracts/ # Smart contracts (Hardhat)
├── frontend/ # Next.js web application
└── subgraph/ # TheGraph indexing (planned)
The core contract facilitates atomic swaps between:
- NFT ↔ NFT trades
- NFT ↔ ERC20 token trades
Key Functions:
createTrade()- List an NFT for tradeexecuteTrade()- Accept and execute a tradecancelTrade()- Cancel your own trade listing
Security Features:
- Non-custodial (never holds user assets)
- Approval-based transfers only
- Comprehensive validation checks
- Reentrancy protection
✅ 25 passing tests covering:
- Trade creation and validation
- Atomic swap execution
- Cancellation logic
- Security edge cases
- View functions
- Framework: Next.js 14 with App Router
- Wallet Integration: RainbowKit + Wagmi
- Styling: TailwindCSS
- Blockchain: Ethers.js / Viem
- Type Safety: TypeScript
- Portfolio Dashboard - Main user interface showing owned Financial NFTs
- NFT Cards - Display individual NFTs with live valuations
- Trade Creation Modal - Interface for creating new trade listings
- Marketplace View - Browse available trades (planned)
The frontend will calculate real-time USD values by:
- Reading NFT composition from protocol contracts (e.g., Uniswap NonfungiblePositionManager)
- Fetching token prices from Chainlink Data Feeds
- Computing spot prices from DEX liquidity pools
- Displaying verifiable calculations to users
- Node.js 18+
- npm or yarn
- Git
-
Clone the repository
git clone <repository-url> cd ethproj1
-
Install dependencies
npm install cd contracts && npm install cd ../frontend && npm install
-
Set up environment files
# Copy environment templates cp contracts/env.example contracts/.env cp frontend/env.example frontend/.env.local # Edit the files with your API keys
-
Compile and test smart contracts
cd contracts npm run compile npm run test
-
Start the frontend development server
cd frontend npm run dev -
Visit the application Open http://localhost:3000 in your browser
SEPOLIA_URL=https://sepolia.infura.io/v3/YOUR_INFURA_API_KEY
PRIVATE_KEY=your_private_key_here
ETHERSCAN_API_KEY=your_etherscan_api_key_hereNEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=your_walletconnect_project_id
NEXT_PUBLIC_ALCHEMY_ID=your_alchemy_api_key-
Deploy contracts
cd contracts npm run deploy:sepolia -
Update frontend configuration
# Copy contract addresses from contracts/deployments/sepolia.json # to frontend/.env.local
-
Build and deploy frontend
cd frontend npm run build
- BarterExchange contract
- Mock contracts for testing
- Comprehensive test suite
- Deployment scripts
- Next.js setup with RainbowKit
- Portfolio dashboard
- Trade creation modal
- Basic wallet integration
- Live net value calculation
- Contract integration
- TheGraph subgraph development
- Event indexing for trade listings
- GraphQL API integration
- Marketplace view
- Trade history
- Advanced filtering/sorting
- Price alerts
- Portfolio analytics
cd contracts
npm run testcd frontend
npm run lint
npm run build- Non-custodial Design: Contract never holds user assets
- Approval-based: Uses ERC721/ERC20 approval patterns
- Validation: Extensive ownership and approval checks
- Testing: Comprehensive test coverage including edge cases
- Static Analysis: Planned Slither integration
This is currently a personal project. For suggestions or issues, please open an issue in the repository.
MIT License - see LICENSE file for details.
"Adi, the DeFi Strategist": An experienced DeFi user who:
- Manages diverse portfolios of yield-bearing assets
- Values data accuracy and verifiability
- Needs tools for precise portfolio rebalancing
- Comfortable with complex protocols
- Task-oriented and efficiency-focused
- Tool First, Marketplace Second: Personal dashboard is the primary entry point
- Data Density: Rich financial information prominently displayed
- Desktop First: Optimized for serious trading workflows
- Verifiable Calculations: All valuations show underlying data
- Power User Focus: No hand-holding, built for experts