morpho-rs-api 0.1.1

Rust API library for querying Morpho V1 (MetaMorpho) and V2 vaults via GraphQL
Documentation

Morpho Vaults Rust API Library

This crate provides a Rust client for querying Morpho V1 (MetaMorpho) and V2 vaults via their GraphQL API, and executing on-chain transactions.

Example

use morpho_rs_api::{MorphoClient, MorphoClientConfig, Chain};
use alloy::primitives::{Address, U256};

#[tokio::main]
async fn main() -> Result<(), morpho_rs_api::ApiError> {
    // API-only client (no transactions)
    let client = MorphoClient::new();
    let vaults = client.get_vaults_by_chain(Chain::EthMainnet).await?;

    // Full client with transaction support
    let config = MorphoClientConfig::new()
        .with_rpc_url("https://eth.llamarpc.com")
        .with_private_key("0x...");
    let client = MorphoClient::with_config(config)?;

    // V1 vault operations using bound signer address
    let vault: Address = "0x...".parse().unwrap();
    let balance = client.vault_v1()?.balance(vault).await?;

    // Approve and deposit
    let amount = U256::from(1000000);
    client.vault_v1()?.approve(vault, amount).await?;
    client.vault_v1()?.deposit(vault, amount).await?;

    Ok(())
}