Skip to content

core: implement yield snapshot background job #72

Description

@EmeditWeb

Problem

There is no yield snapshot background job. The product vision requires periodic yield/APY calculations, but no such job exists. The liquidity service computes APY as a weighted average from off-chain loan data rather than from actual contract yield.

User impact: The displayed APY is an estimate, not the actual yield earned by the pool. Sponsors may make decisions based on inaccurate yield data.

Before Starting

Read: context/architecture-context.md

Root Cause

The yield snapshot job was never implemented.

What To Build

  1. Create src/jobs/yield-snapshot.processor.ts
  2. Read pool share price from contract at regular intervals
  3. Calculate APY from share price changes over time
  4. Store yield snapshots in a yield_history table
  5. Schedule: every 6 hours
  6. Add GET /liquidity/yield-history endpoint to serve snapshots

Files To Touch

  • src/jobs/yield-snapshot.processor.ts — new file
  • src/jobs/jobs.module.ts — register processor
  • src/modules/liquidity/liquidity.controller.ts — add yield-history endpoint

Acceptance Criteria

  • Job runs every 6 hours
  • Reads share price from contract
  • Computes APY from share price change
  • Stores in yield_history table
  • GET /liquidity/yield-history returns snapshot data
  • Build passes

Mandatory Checks

  • context/ files read
  • npm run build passes
  • PR references this issue

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions