import { buildCuratedPoolRegistry } from './pool-registry-report';

describe('buildCuratedPoolRegistry', () => {
  it('returns DODO PMM pools with dodo_dvm lp type from deployment-status', () => {
    const report = buildCuratedPoolRegistry(138);
    expect(report.count).toBeGreaterThan(0);
    expect(report.chain138StackAIntegration).toBe('0x86ADA6Ef91A3B450F89f2b751e93B1b7A3218895');

    const dodoPools = report.pools.filter((pool) => pool.venue === 'dodo_pmm');
    expect(dodoPools.length).toBeGreaterThan(0);
    for (const pool of dodoPools) {
      expect(pool.lpTokenType).toBe('dodo_dvm');
      expect(pool.lpTokenAddress).toBe(pool.poolAddress);
      expect(pool.chainId).toBe(138);
      expect(pool.baseAddress).toMatch(/^0x[a-f0-9]{40}$/);
      expect(pool.quoteAddress).toMatch(/^0x[a-f0-9]{40}$/);
    }
  });

  it('filters pools by chainId when requested', () => {
    const all = buildCuratedPoolRegistry();
    const chain138 = buildCuratedPoolRegistry(138);
    expect(chain138.pools.every((pool) => pool.chainId === 138)).toBe(true);
    expect(chain138.count).toBeLessThanOrEqual(all.count);
  });

  it('includes univ2_pair entries when live catalog is present', () => {
    const report = buildCuratedPoolRegistry();
    const univ2 = report.pools.filter((pool) => pool.venue === 'uniswap_v2');
    if (univ2.length === 0) return;
    for (const pool of univ2) {
      expect(pool.lpTokenType).toBe('univ2_pair');
      expect(pool.lpTokenAddress).toBe(pool.poolAddress);
    }
  });
});
