Architecture Overview

Overview
This document provides a structured explanation of the API flow for interacting with the Deframe service. The flow consists of several stages, each responsible for specific actions across loans, swaps, and yield products.
Common Flow Patterns
1. Protocol Data
Description
Retrieve quotes and protocol information using the API.
Endpoints
GET /strategies/:id
GET /strategies
Purpose
Fetch available protocols and their current rates
Get quotes for loans, swaps, or yield positions
Compare rates across different protocols
2. Transaction Data
Description
Request transaction data (bytecode) needed for execution.
Endpoint
GET /strategies/:id/bytecode
Purpose
Provides the bytecode for executing transactions
Supports multiple transaction types:
Loans (borrow/repay)
Swaps
Yield positions (deposit/withdraw)
3. Sign & Propagate Bytecode
Description
Transaction signature and propagation are handled entirely on your side
Deframe does not hold, manage, or pass any funds through its smart contracts
Responsibilities
Users sign transactions themselves
Transaction propagation is handled by the user
Full custody remains with the user
4. Position Monitoring
Description
After transaction execution, Deframe monitors positions and provides updates.
Endpoints
GET /wallets/:address # General position info
GET /wallets/:address/yield # Yield positions
Purpose
Track wallet activity and positions
Monitor health factors for loans
Track yield earnings
View swap history
5. Alerts & Notifications
Description
Configure alerts for position monitoring.
Features
Webhook notifications
Push notifications
Email alerts
Liquidation warnings for loans
APY change notifications for yield positions
6. Integration Features
Description
Additional features to enhance user protection and experience.
Available Features
Integration with DeFiSaver for loan protection
Optional liquidation protection
Auto-compounding for yield positions
Best-rate routing for swaps
Rate Limiting
100 requests per minute per IP address
1000 requests per hour per API key
Error Handling
The API uses standard HTTP response codes:
200: Success
400: Bad Request
401: Unauthorized
429: Too Many Requests
500: Internal Server Error
Summary
This architecture ensures:
Trustless operations with no fund custody
Comprehensive position monitoring
Real-time alerts and notifications
Integration with protection mechanisms
Support for multiple DeFi products (loans, swaps, yield)
For detailed implementation guides, see:
Swap Tutorials
Last updated