Project: LimitCraft
Tracks:
- Extend Limit Order Protocol
- Build a full Application using 1inch APIs
Demo: Live Demo Video: LimitCraft Demo Video
-
PreInteraction + PostInteraction https://arbiscan.io/tx/0x3671c60f1aa96e61c8f984404cbf117c773ca8a257780e652593a9278ea393cc
-
TWAP Order(partial fill) + PreInteraction + PostInteraction https://arbiscan.io/tx/0x62e9e33f8502c4447b232b01bc65fe6df1b07ae68d436045a8cb7c37bce64de4
LimitCraft revolutionizes DeFi trading by providing an advanced limit order platform that seamlessly integrates with lending protocols. LimitCraft empowers traders to craft sophisticated trading strategies with unprecedented control and efficiency in the DeFi ecosystem.
Our breakthrough feature allows traders to earn lending yield on their tokens while waiting for limit orders to fill. This solves the opportunity cost problem that has plagued limit order systems since their inception.
Traditional limit order systems force traders to choose between:
- Setting limit orders and having capital sit idle
- Earning yield in lending protocols but missing trading opportunities
This creates significant opportunity cost and capital inefficiency in DeFi.
LimitCraft introduces Smart Limit Orders with integrated lending:
- Pre-Trade Yield: Automatically deposits order tokens into lending protocols (Aave, Compound)
- Seamless Execution: When orders fill, tokens are withdrawn from lending and traded
- Post-Trade Yield: Received tokens are automatically re-deposited to continue earning
- Zero Friction: All happens in a single transaction with no manual intervention
User has 10,000 USDC earning 5% APY on Aave
โ
Creates limit order: Buy ETH at $2,000
โ
USDC continues earning yield while waiting
โ
Order fills: USDC withdrawn โ ETH purchased โ ETH deposited to Aave
โ
User now earns yield on ETH position
- Frontend: React + TypeScript + Vite + TailwindCSS
- Wallet Integration: RainbowKit + Wagmi v2
- Backend: Bun + Elysia.js (Ultra-fast TypeScript runtime)
- Database: PostgreSQL + Drizzle ORM
- Blockchain: EVM-compatible blockchain support
- Order Protocol: 1inch Limit Order Protocol v4
- Smart Contracts: Solidity + Foundry + OpenZeppelin
- Order Resolution: Custom automated resolver service
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ React UI โโโโโถโ Elysia API โโโโโถโ PostgreSQL DB โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ โ โฒ
โ โ โ
โผ โผ โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ Wagmi Wallet โ โ Order Resolver โโโโโถโ Order Status โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ โ
โผ โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ On-Chain Infrastructure โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ โ
โ โ 1inch LOP โ โ LimitCraft Extensions โ โAAVE/Compoundโ โUniswap Permit2โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
- Real-time price feeds from 1inch API
- Advanced order types (limit, with pre-interaction lending position unwrapping, with post-interaction lending position deposit)
- Multi-protocol support:
- Aave
- Compound (coming soon)
- Off-chain order book for gas efficiency
- MEV-resistant order execution
- Fair ordering with timestamp priority
- Partial fill support
LimitCraft leverages multiple 1inch API endpoints to provide a seamless trading experience:
| API Service | Endpoint | Purpose | Implementation |
|---|---|---|---|
| Balance API | GET /balance/v1.2/{chainId}/balances/{address} |
Fetch user token balances | Real-time wallet balance display in UI dropdowns |
| Token API | GET /token/v1.4/{chainId}/custom/{tokenAddress} |
Resolve token metadata | Token symbols, names, decimals, logos for all assets |
| Price API | GET /price/v1.1/{chainId}/{tokenAddress} |
Live market prices | Market rate calculations and USD conversions |
| Price API (Bulk) | POST /price/v1.1/{chainId} |
Multiple token prices | Batch price fetching for trading pairs |
| Limit Order Protocol SDK | Smart Contract Integration | Order management | EIP-712 signatures, extensions, Permit2 |
Balance API (https://api.1inch.dev/balance/v1.2/{chainId}/balances/{address})
// Fetches all token balances for a wallet address
const balancesResponse = await fetch(balancesUrl, {
headers: {
Authorization: `Bearer ${oneInchApiKey}`,
accept: "application/json",
},
});- Filters tokens with non-zero balances
- Displays available amounts in order creation form
- Sorts tokens by balance value for better UX
Token Details API (https://api.1inch.dev/token/v1.4/{chainId}/custom/{tokenAddress})
// Fetches metadata for each token with balances
const detailsResponse = await fetch(detailsUrl, {
headers: {
Authorization: `Bearer ${oneInchApiKey}`,
accept: "application/json",
},
});- Resolves token symbols, names, decimals, and logos
- Validates token addresses for order creation
- Handles edge cases (e.g., USDC_1 โ USDC symbol fix)
Price API (https://api.1inch.dev/price/v1.1/{chainId}/{tokenAddress}?currency=USD)
// Single token price (GET)
const response = await fetch(
`https://api.1inch.dev/price/v1.1/${chainId}/${tokenAddress}?currency=USD`,
);
// Multiple token prices (POST)
const response = await fetch(`https://api.1inch.dev/price/v1.1/${chainId}`, {
method: "POST",
body: JSON.stringify({
tokens: tokenAddresses,
currency: "USD",
}),
});- Powers market rate spectrum slider in order creation
- Calculates USD values for portfolio display
- Implements fallback from GET to POST for reliability
Backend Proxy Architecture
- All 1inch API calls are proxied through our Elysia.js backend
- Secure API key management with
Bearerauthentication - Rate limiting and error handling for production reliability
- Fallback mechanisms (1inch โ Moralis for token data)
Our backend exposes these endpoints that utilize 1inch APIs:
| Endpoint | 1inch API Used | Description |
|---|---|---|
GET /api/v1/tokens/{address}?chainId={id} |
Balance + Token APIs | Combined token balances and metadata |
GET /api/v1/prices?token1={addr}&token2={addr} |
Price API | Trading pair price data |
POST /api/v1/orders |
LOP SDK | Order creation and storage |
This architecture ensures secure, efficient access to 1inch services while maintaining optimal performance for our users.
- Bun 1.0+
- PostgreSQL 15+
- wallet
- Maker token balances
# Clone the repository
git clone https://github.com/yourusername/limitcraft.git
cd limitcraft
# Install dependencies
bun install
# Initialize submodules (for smart contracts)
git submodule update --init --recursive
# Set up the database
bun run db:setup
# Start all services
bun run dev:allCreate .env files in each service directory:
# API (.env)
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/limitcraft-db
API_PORT=3001
# Resolver (.env)
PRIVATE_KEY=your_private_key_here
ONEINCH_API_KEY=your_1inch_api_key
RPC_URL=your_preferred_chain_rpc_url
# UI (.env)
VITE_API_URL=http://localhost:3001
VITE_WALLETCONNECT_PROJECT_ID=your_walletconnect_id- Non-custodial architecture - users retain full control
- Connect Wallet: Link your MetaMask to LimitCraft
- Select Trading Pair: Choose from 100+ token pairs
- Set Order Parameters:
- Order type (limit/)
- Price levels
- Amount to trade
- Enable lending integration
- Choose and configure TWAP
- Review & Sign: Check gas costs and sign transaction
- Monitor Orders: Track status in real-time dashboard
- Claim Rewards: Withdraw accumulated yield anytime
OrderManager.sol // Main order lifecycle management
LendingIntegration.sol // Aave/Compound protocol interactions
OrderResolver.sol // Automated execution logic
PriceOracle.sol // Chainlink price feed integration
EmergencyPause.sol // Circuit breaker mechanism- EIP-712 typed signatures for orders
- Permit2 integration for gasless approvals
- Comprehensive event logging for indexing
- โ First platform to integrate lending yields with limit orders
- โ Sub-second order matching algorithm
- โ Cross-protocol yield optimization engine
- โ One-click order creation with lending
- โ Real-time portfolio analytics
- โ Mobile-responsive design
- โ Intuitive order management interface
- โ Horizontal scaling architecture
- โ Production deployment almost ready
- Enhanced DeFi protocol integrations
- Advanced charting with TradingView
- Mobile application (iOS/Android)
- Limit order NFTs for composability
- DAO governance implementation
- Protocol revenue sharing mechanism
- Institutional API access
- Advanced order types (TWAPs, Icebergs)
- Perpetual futures integration
- Options trading support
- Social trading features
- AI-powered trade suggestions
- Lead Developer: Junta Okuda - Smart Contract Architect
- Lead Developer: Rashid Mak - Smart Contract Engineer
- 1inch Protocol team for the limit order framework
- The broader DeFi ecosystem
- Aave and Compound for lending integrations
- The DeFi community for invaluable feedback
This project is licensed under the MIT License - see LICENSE for details.
