# Track Specification: Ethers.js v5 to v6 Migration

## Overview

Migrate the entire codebase from ethers.js v5 to the latest ethers.js v6, handling breaking changes including BigNumber to BigInt conversions, provider API updates, and contract interaction layer changes.

## Background

Ethers.js v6 introduces significant breaking changes that require a comprehensive migration:

- `BigNumber` replaced with native JavaScript `BigInt`
- Provider API restructuring
- Event handling changes
- Contract interaction updates

## Functional Requirements

### Phase 1: Core Math & Utilities Migration

- [ ] Replace all `BigNumber` imports and usages with native `BigInt`
- [ ] Update mathematical operations to use BigInt arithmetic
- [ ] Migrate utility functions using ethers utilities (formatting, parsing, etc.)
- [ ] Update type definitions for BigInt compatibility

### Phase 2: Provider Layer Migration

- [ ] Migrate provider instantiation and configuration
- [ ] Update signer interfaces and wallet connections
- [ ] Refactor network detection and chain ID handling
- [ ] Update RPC method calls and response handling

### Phase 3: Contract Interaction Migration

- [ ] Update contract factory patterns
- [ ] Migrate ABI encoding/decoding logic
- [ ] Update contract method call patterns
- [ ] Refactor event listening and filtering

### Phase 4: Integration & Testing

- [ ] Ensure all existing tests pass with ethers v6
- [ ] Create migration comparison tests (v5 vs v6 outputs)
- [ ] Verify calculation accuracy is preserved
- [ ] Update documentation and examples

## Non-Functional Requirements

- **Calculation Accuracy**: All mathematical calculations must produce identical results pre/post migration
- **Test Coverage**: Maintain >80% code coverage throughout migration
- **Performance**: No regression in calculation performance
- **Type Safety**: All TypeScript types must remain valid and strict

## Acceptance Criteria

- [ ] All existing unit tests pass
- [ ] Migration comparison tests demonstrate calculation parity
- [ ] Code coverage remains >80%
- [ ] No TypeScript compilation errors
- [ ] Integration tests pass with live providers
- [ ] Documentation updated to reflect v6 APIs

## Out of Scope

- Adding new features beyond migration requirements
- Performance optimizations (to be addressed in future tracks)
- UI changes (this is an SDK migration only)
- Breaking changes to public API (where possible, maintain backward compatibility in our SDK's public interface)

## Dependencies

- ethers.js v6.x (latest)
- Updated @uniswap/\* packages compatible with ethers v6 (if available)
