import { bytesToUint256LittleEndian } from './subgraph.js'; export function toBigIntId(id: string | Uint8Array | number | bigint): bigint { if (typeof id === 'bigint') return id; if (typeof id === 'number') return BigInt(id); if (typeof id === 'string') { const trimmed = id.startsWith('0x') ? id : `0x${id}`; return BigInt(trimmed); } if (id instanceof Uint8Array) { return bytesToUint256LittleEndian(id); } throw new Error('Unsupported position id type'); } export function decodePositionId(id: string | Uint8Array | number | bigint): bigint { return toBigIntId(id); }