A robust and secure REST API for interacting with Ionic and Morpho protocols across multiple chains. Built with TypeScript, NestJS, and Viem.
-
Multi-Chain Support: Seamlessly interact with Ionic Protocol on:
- ⚡ Mode Network
- 🔵 Base
- 🔴 Optimism
- 🟣 Bob
- 🟡 Fraxtal
- 🟢 Lisk
- 🔷 Ink
- 🟨 SuperSeed
- 🟦 WorldChain
- 🟩 Swell
- 🟪 Soneium
-
Core Operations:
- 📊 Get market information
- 💼 View user positions
- 💰 Supply assets
- 🏦 Withdraw funds
- 💸 Borrow assets
- 💳 Repay loans
-
Security First:
- ✅ Input validation with class-validator
- 🛡️ CORS protection
- 🔐 Environment variable protection
- 📝 Comprehensive request logging
-
Clone & Install
git clone <repository-url> cd ionic-api-v2 pnpm install
-
Environment Setup
cp .env.example .env # Add your credentials: # SUPABASE_URL=your_supabase_url # SUPABASE_KEY=your_supabase_key
-
Start Development Server
pnpm run start:dev
Access our interactive API documentation at /api-docs
to:
- Explore all available endpoints
- Test API calls directly from your browser
- View request/response schemas
- Download OpenAPI specification
Get Market Information
GET /beta/v0/ionic/market
Get detailed market information with optional filters:
chain
: Blockchain network (e.g., "optimism", "base", etc.)asset
: Asset symbol (e.g., "WETH")address
: Market addresspoolAddress
: Pool addressunderlyingAddress
: Underlying token addressunderlyingName
: Underlying token nameunderlyingSymbol
: Underlying token symbol
Get Market Information (Specific Chain)
GET /beta/v0/ionic/market/:chain
Get detailed market information for a specific chain with optional filters:
asset
: Asset symbol (e.g., "WETH")address
: Market addresspoolAddress
: Pool addressunderlyingAddress
: Underlying token addressunderlyingName
: Underlying token nameunderlyingSymbol
: Underlying token symbol
Get User Positions
GET /beta/v0/ionic/position/:chain/:address
Get user positions across all markets, including:
- Pool information
- Asset balances
- Supply/borrow amounts
- Health factors
- Reward information
Supply Assets
POST /beta/v0/ionic/supply/:chain
Supply assets to an Ionic pool. Request body:
{
"sender": "0x...",
"call_data": {
"asset": "WETH",
"amount": 1.5,
"on_behalf_of": "0x..."
}
}
Withdraw Assets
POST /beta/v0/ionic/withdraw/:chain
Withdraw your supplied assets. Request body:
{
"sender": "0x...",
"call_data": {
"asset": "WETH",
"amount": 1.0,
"on_behalf_of": "0x..."
}
}
Borrow Assets
POST /beta/v0/ionic/borrow/:chain
Borrow assets from a pool. Request body:
{
"sender": "0x...",
"call_data": {
"asset": "WETH",
"amount": 0.5,
"on_behalf_of": "0x..."
}
}
Repay Loan
POST /beta/v0/ionic/repay/:chain
Repay your borrowed assets. Request body:
{
"sender": "0x...",
"call_data": {
"asset": "WETH",
"amount": 0.5,
"on_behalf_of": "0x..."
}
}
Get Position Details
GET /beta/v0/morpho/position/:chain/:marketId/:sender
Get detailed position information for a specific market and user.
Get Market Details
GET /beta/v0/morpho/market/:chain
Get market details with optional filters:
marketId
: Market IDcollateralToken
: Collateral token addresscollateralTokenSymbol
: Collateral token symbolborrowToken
: Borrow token addressborrowTokenSymbol
: Borrow token symbol
- TypeScript - Type safety and better developer experience
- NestJS - Progressive Node.js framework
- Viem - Modern Ethereum library
- Supabase - Backend infrastructure
- Swagger - API documentation
- Jest - Testing framework
This API implements several security measures:
- Request validation with class-validator
- Comprehensive request logging
- Environment variable protection
- Proper error handling and logging
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- Built on NestJS for optimal performance
- Efficient error handling with global filters
- Fast response times with proper caching
- Minimal dependencies
Built with ❤️ for the DeFi community