Phoenix price points are keyed on the wall clock, so a replay is stored twice

Abierto Apto para principiantes
#633 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 3 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
postgresql, typescript

Línea de trabajo

Lee src/ingest/venues/phoenix.ts alrededor de las líneas 426–470, compara el patrón de identidad en src/ingest/venues/soroswap.ts alrededor de la línea 392 y revisa upsertPricePoints en src/db.ts. Añade o actualiza pruebas en src/__tests__/phoenixIngester.test.ts y src/__tests__/pricePointIdentity.test.ts para verificar que los mismos datos de un pool produzcan IDs estables, que las reservas modificadas produzcan IDs diferentes y que volver a procesar un lote no añada una fila. Ejecuta las pruebas de Vitest pertinentes; la tarea se considera terminada cuando pasen todos los casos indicados de identidad y repetición, sin valores de reloj ni aleatorios en el ID.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

area:ingest difficulty:easy help wanted points:100 Stellar Wave
Background

Issue #237 set a rule for rows that have no trade id: the row's identity must
come from the state that was read, never from the clock. The Soroswap adapter
states it in a comment: "Must never be Date.now()/random." The Horizon AMM
keys its snapshot on (pool, last_modified_ledger).

derivePhoenixPricePoints in src/ingest/venues/phoenix.ts (line 467) breaks
the rule:

eventId: `phoenix-${raw.poolAddress}-${Date.now()}`,

Every call makes a new id. A retried batch, or a second instance reading the
same pool, inserts the same observation again. The function is also documented
as "Pure", and it is not.

What to build
  • Derive the id from the pool state: the pool address and the two reserves,
    as Soroswap does (soroswap-${pool}-${reserveA}-${reserveB}).
  • Make sure the id does not depend on which way round the pool stores the
    pair. The function swaps a and b for a reversed pool; build the id from
    the raw reserves before the swap, or from a fixed order.
  • Check what this does to an unchanged pool: identical reserves now produce
    the same id, so the second write is skipped as a duplicate. Say in the PR
    whether that is the wanted behaviour and what it means for freshness.
Where to look
  • src/ingest/venues/phoenix.ts lines 426–470
  • src/ingest/venues/soroswap.ts line 392 for the pattern
  • src/db.ts upsertPricePoints for how eventId becomes the row id
  • src/__tests__/phoenixIngester.test.ts, src/__tests__/pricePointIdentity.test.ts
Done when
  • Two calls with the same pool read return the same eventId
  • Two calls with different reserves return different ids
  • No Date.now() or random value is used to build the id
  • A test proves a replayed batch does not create a second row

Drips Wave · Complexity: Easy · 100 points


Repo: Divinity-Labs/Lens. Install with npm ci, typecheck with
npx tsc --noEmit, test with npm test. Tests are vitest, not jest
(running jest reports zero tests and proves nothing).

You cannot reach the production deployment. Everything must be proven with
local tests and fixtures. Do not write a test that needs the live network.

No floating point in new price or amount maths. Prices are stored as
Decimal(36, 18) and amounts as Decimal(36, 7). Do sums in SQL numeric, in
bigint, or on decimal strings. If you must touch existing float code, do not
add more of it.

The price convention is fixed: a stored price means units of assetB per
one unit of assetA, in the order the pair is configured. Every adapter must
follow it.

Generated files are checked byte for byte by CI (the OpenAPI spec, the
README sections, the GraphQL schema file, the TypeScript client schema, and the
Prisma migration baseline). If you change a route, the GraphQL schema or
prisma/schema.prisma, regenerate the generated files and commit them. The
commands are in the scripts section of package.json (openapi:gen,
readme:gen, graphql:schema:gen, client:gen) and in CONTRIBUTING.md. A
schema change also needs a migration and a regenerated baseline: see
docs/database-migrations.md. The database is migrated with
prisma migrate deploy, never db push.

Never shorten or invent a contract id or issuer address. Copy it in full
from the repo. If a venue's id is not in the repo, read it from the venue's
official docs and cite the source in the PR.

No personal data and no secrets in code, fixtures, logs or the PR. A
fixture recorded from a public API must not contain an API key.

Do not weaken a test to make it pass. If an existing test encodes the bug
you are fixing, change the test and say so in the PR.



Required: Before submitting, join the contributor Telegram so your work can be tracked and counted toward the Stellar Wave: https://t.me/+fxHXq8f1SwlkZDBk

Lenguaje dominante
TypeScript
Estrellas
4
Forks
71
Merge medio
2 d 6 h
PR fusionados (30 d)
24

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Divinity-Labs/Lens

Todos los issues de Divinity-Labs/Lens

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.