morpho-rs-api
GraphQL API client for querying Morpho vaults with unified transaction support.
Installation
Features
- VaultV1Client / VaultV2Client - Dedicated clients for V1 and V2 vault queries
- MorphoApiClient - Combined API client for both vault versions
- MorphoClient - Unified client combining API queries and on-chain transactions
- 25 supported chains - Ethereum, Base, Arbitrum, Optimism, and more
- User position queries - Track positions, PnL, and ROE across chains
- Flexible filtering - Query vaults by chain, curator, APY, and more
- alloy-chains integration - Uses
NamedChainfrom alloy-chains for chain types
Usage
Query-Only Client
use ;
async
Full Client with Transaction Support
use ;
use ;
async
Querying Vaults with Filters
use ;
let client = new;
// Build filters
let filters = new
.chain
.listed
.min_apy; // 5% minimum APY
let vaults = client.api.v1.get_vaults.await?;
Depositing and Withdrawing
use ;
use ;
let config = new
.with_rpc_url
.with_private_key;
let client = with_config?;
let vault: Address = "0x...".parse?;
let amount = U256from;
// Deposit to V1 vault
client.vault_v1?.deposit.await?;
// Withdraw from V2 vault
client.vault_v2?.withdraw.await?;
Querying User Positions
use ;
use Address;
let client = new;
let user: Address = "0x...".parse?;
// Query positions on all chains
let positions = client.api.get_user_vault_positions.await?;
println!;
println!;
// Query positions on specific chain
let positions = client.api.get_user_vault_positions.await?;
// Get complete account overview
let overview = client.api.get_user_account_overview.await?;
println!;
Supported Chains
| Chain | ID | Aliases |
|---|---|---|
| Ethereum | 1 | ethereum, eth, mainnet |
| Base | 8453 | base |
| Arbitrum | 42161 | arbitrum, arb |
| Optimism | 10 | optimism, op |
| Polygon | 137 | polygon, matic |
| Linea | 59144 | linea |
| Scroll | 534352 | scroll |
| Mode | 34443 | mode |
| Sonic | 146 | sonic |
| World Chain | 480 | worldchain |
| Fraxtal | 252 | fraxtal |
| Ink | 57073 | ink |
| Unichain | 130 | unichain |
| Corn | 21000000 | corn |
| Katana | 747474 | katana |
| Etherlink | 42793 | etherlink |
| Lisk | 1135 | lisk |
| Hyperliquid | 999 | hyperliquid |
| Sei | 1329 | sei |
| Monad | 143 | monad |
| Stable | 988 | stable |
| Cronos | 25 | cronos |
| Celo | 42220 | celo |
| Abstract | 2741 | abstract |
| Sepolia | 11155111 | sepolia (testnet) |
Public API
Client Types
MorphoClient- Unified client with API + optional transaction supportMorphoClientConfig- Configuration builder for MorphoClientMorphoApiClient- Combined V1 + V2 API clientVaultV1Client- V1 vault query clientVaultV2Client- V2 vault query clientVaultV1Operations/VaultV2Operations- Transaction wrappers
Data Types
Vault- Unified vault type (V1 or V2)VaultV1/VaultV2- Version-specific vault typesVaultStateV1/VaultStateV2- Vault state with APY, fees, allocationsNamedChain- Supported blockchain networks (from alloy-chains)Asset- Token informationUserVaultPositions- User's vault positionsUserAccountOverview- Complete user account state
Filter Types
VaultFiltersV1- Filter builder for V1 vault queriesVaultFiltersV2- Filter builder for V2 vault queries
Error Handling
License
MIT