> ## Documentation Index
> Fetch the complete documentation index at: https://docs.0xmonaco.com/llms.txt
> Use this file to discover all available pages before exploring further.

# V0.4.1

# Monaco Protocol SDK v0.4.1

## Indexer Improvements & Bug Fixes

This patch release focuses on backend infrastructure improvements, primarily migrating the indexer from the deprecated ethers.rs library to alloy, along with critical bug fixes for withdrawal event handling.

### What's New

**SDK Improvements**

* **TypeScript 5.9+**: Full type safety and IntelliSense support with latest TypeScript
* **viem 2.31+**: Updated to latest viem for improved blockchain interactions
* **Better Type Inference**: Improved TypeScript configuration for optimal developer experience

**Indexer Modernization**

* **Alloy Migration**: Replaced deprecated ethers.rs with modern alloy library for blockchain interactions
* **WebSocket Event Listening**: Native WebSocket support for vault event monitoring (no longer requires special RPC provider filters)
* **Broader RPC Compatibility**: Works with any standard EVM provider, including free tiers like Rhino
* **Repository Pattern**: Cleaner data access layer with dedicated repositories for applications, blockchain events, and processed blocks
* **Enhanced Gap Detection**: Improved logic for detecting and backfilling missed blockchain events

**Bug Fixes**

* **Withdrawal Events**: Fixed withdrawal event signature causing withdrawal events not to be indexed correctly
* **Whitelist App**: Resolved critical bug in the whitelist application
* **Configuration**: Improved environment variable naming consistency across indexer services

### Technical Details

**SDK Dependencies**

This release updates core SDK dependencies for better performance and type safety:

* **TypeScript 5.9+**: Full type safety and IntelliSense support
* **viem 2.31+**: Modern Ethereum library for blockchain interactions

### TypeScript Configuration

For optimal type inference and IntelliSense support, use the following TypeScript configuration:

```json theme={null}
{
  "compilerOptions": {
    "target": "ES2020",
    "module": "nodenext",
    "moduleResolution": "nodenext",
    "strict": true,
    "esModuleInterop": true,
    "resolveJsonModule": true
  }
}
```

**New Indexer Architecture**

The indexer has been refactored to follow best practices with repository pattern implementation:

```rust theme={null}
// New repositories for cleaner data access
ApplicationRepository
BlockchainEventsRepository  
ProcessedBlocksRepository
TradingPairsRepository
```

**WebSocket-Based Event Monitoring**

Previous versions required RPC providers with special filtering capabilities. v0.4.1 uses native WebSocket connections:

```
Before: HTTP polling with filters (limited provider support)
After:  WebSocket subscriptions (works with any EVM provider)
```

**Configuration Updates**

Environment variable naming has been standardized. Indexer operators should update their configuration:

```env theme={null}
# Updated variable names for consistency
INDEXER_RPC_URL=https://your-rpc-provider.com
INDEXER_POLLING_INTERVAL_MS=12000
DATABASE_URL=postgresql://...
```

**Improved Backfilling**

Enhanced gap detection and automatic backfilling ensures no events are missed:

* Detects gaps in processed blocks
* Automatically backfills missing events
* Better logging for monitoring indexer health
* Improved error handling and retry logic

### Migration Guide

**For Indexer Operators**

If you're running your own indexer, update your environment configuration:

1. Review the updated `.env.example` file in the `indexer/` directory
2. Update environment variable names to match new conventions
3. Restart the indexer service
4. Monitor logs for successful WebSocket connection

```bash theme={null}
# Restart indexer after configuration updates
cargo run -p indexer
```

**For SDK Users**

Update your dependencies to benefit from the latest improvements:

```bash theme={null}
npm install @0xmonaco/core@0.4.1 viem@^2.31.0
```

**Recommended TypeScript Configuration:**

If you haven't already, update your `tsconfig.json` for better type inference:

```json theme={null}
{
  "compilerOptions": {
    "target": "ES2020",
    "module": "nodenext",
    "moduleResolution": "nodenext",
    "strict": true,
    "esModuleInterop": true,
    "resolveJsonModule": true
  }
}
```

**What's Improved:**

* Better type safety with TypeScript 5.9+
* Enhanced blockchain interactions with viem 2.31+
* Improved IntelliSense and autocomplete
* No breaking changes to existing code

### Packages Updated

This release primarily affects backend services:

* **Indexer Service**: v0.4.1 with alloy migration
* **Data Layer**: Enhanced with new repositories
* **Infrastructure**: Updated Docker and configuration files

SDK packages remain at v0.4.1:

* `@0xmonaco/core@0.4.1`
* `@0xmonaco/types@0.4.1`
* `@0xmonaco/contracts@0.4.1`
* `@0xmonaco/react@0.4.1`

### Installation

```bash theme={null}
npm install @0xmonaco/core@0.4.1
npm install @0xmonaco/react@0.4.1  # For React applications
```

Or install the latest version without specifying:

```bash theme={null}
npm install @0xmonaco/core
npm install @0xmonaco/react  # For React applications
```

### Benefits

**For SDK Users**

* Enhanced type safety with TypeScript 5.9+ (better IntelliSense and autocomplete)
* Improved blockchain interactions with viem 2.31+
* Better developer experience with optimized TypeScript configuration

**For Backend Developers**

* More reliable event indexing
* Broader RPC provider compatibility
* Better error messages and logging
* Cleaner codebase following repository pattern

**For Infrastructure Operators**

* Reduced RPC provider requirements (no special filters needed)
* More cost-effective infrastructure (free tier providers work)
* Improved monitoring with better gap detection
* Enhanced reliability with automatic backfilling

### Related Changes

This release includes infrastructure improvements merged from multiple PRs:

* Indexer refactored to use alloy with repository pattern
* Enhanced vault event handling with WebSocket support
* Docker and environment configuration updates
* Comprehensive test coverage additions

### Testing & Coverage

Enhanced test suite with new integration and unit tests:

* Vault listener integration tests
* Repository unit tests
* Event handling edge cases
* Gap detection and backfilling tests

***

## Commit References

* `3a0d893d` - Refactor indexer to use alloy
* `d352c7d5` - Fix Withdrawal Event Signature
* `7ac2afd4` - Fixed critical bug in whitelist app
* `764d87ed` - Move alloy to workspace, cleanup dependencies

***

*Note: This is a patch release focused on backend infrastructure. No breaking changes for SDK users. Indexer operators should review and update their environment configuration.*


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.