-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
TypeScript compilation fails with @1inch/aqua-sdk v0.1.0 due to viem version incompatibility
Description
The @1inch/aqua-sdk v0.1.0 fails TypeScript compilation with "Type instantiation is excessively deep" errors from viem's type definitions, making the SDK unusable in TypeScript projects.
Environment
- SDK Version:
@1inch/[email protected] - TypeScript:
5.7.2 - viem:
2.40.0(resolved from^2.21.0dependency) - Node: v23.3.0
Minimal Reproduction
- Install the SDK:
npm install @1inch/aqua-sdk typescript- Create
test.ts:
import { AquaProtocolContract } from '@1inch/aqua-sdk';
const aqua = new AquaProtocolContract(1);
console.log(aqua);- Compile:
npx tsc --noEmit test.tsError Output
node_modules/viem/_types/types/multicall.d.ts(12,18): error TS2589: Type instantiation is excessively deep and possibly infinite.
node_modules/viem/_types/utils/abi/parseEventLogs.d.ts(22,308): error TS2344: Type 'eventName extends ContractEventName<abi>[] ? eventName[number] : eventName' does not satisfy the constraint 'ContractEventName<abi>'.
Root Cause
The SDK's package.json specifies viem@^2.21.0, which allows npm to install [email protected]. However, viem versions after 2.21.x contain breaking TypeScript changes that cause compilation errors.
Verification:
$ npm list viem
└─┬ @1inch/[email protected]
└── [email protected]Proposed Fix
Option 1 (Quick Fix): Pin to viem 2.21.x
"dependencies": {
"viem": "~2.21.0"
}Option 2 (Better): Update SDK to work with latest viem
"dependencies": {
"viem": "^2.40.0"
}Workaround
Users can bypass the SDK and use viem directly:
import { encodeFunctionData, encodeAbiParameters, keccak256 } from 'viem';
const AQUA_ADDRESS = '0x499943e74fb0ce105688beee8ef2abec5d936d31';
// Encode strategy
const strategyBytes = encodeAbiParameters(
[{ type: 'address' }, { type: 'address' }, { type: 'uint24' }, { type: 'bytes4' }],
[token0, token1, feeTier, salt]
);
// Calculate hash
const strategyHash = keccak256(strategyBytes);Impact
- Severity: Critical
- Affected: All TypeScript users
- Workaround: Available (use viem directly)
Note: The underlying Aqua protocol is excellent and well-designed. This is purely a dependency version management issue in the SDK wrapper.
Metadata
Metadata
Assignees
Labels
No labels