Skip to content

Add pool share price endpoint#973

Open
Lucas-FManager wants to merge 2 commits into
LabsCrypt:mainfrom
Lucas-FManager:code/remitlend-pool-share-price-946
Open

Add pool share price endpoint#973
Lucas-FManager wants to merge 2 commits into
LabsCrypt:mainfrom
Lucas-FManager:code/remitlend-pool-share-price-946

Conversation

@Lucas-FManager
Copy link
Copy Markdown

Summary

Refs #946.

This adds a lender-only GET /api/pool/:token/share-price endpoint that reads the LendingPool get_share_price(token) value, returns the raw 1e6-scaled share price, a human-readable ratio, aggregate utilization, and the short cache TTL.

Approach

  • Added sorobanService.getPoolSharePrice(token) as a read-only Soroban simulation.
  • Added a small token-scoped cache so dashboard/API consumers do not repeatedly hit RPC for the same value.
  • Kept the route behind the existing lender JWT + read:pool checks.
  • Refactored aggregate pool stats into a shared helper so /pool/stats and this endpoint use the same utilization calculation.
  • Restored the missing transactionRoutes import so backend typecheck can run cleanly.

Security

  • Read-only endpoint: no deposit, withdrawal, signing, or transaction submission path is touched.
  • Token input is validated before calling Soroban address parsing.
  • Cache keys include the token address to avoid cross-token data mixing.
  • Authorization matches the existing pool read surface: authenticated lender role plus read:pool scope.

Verification

  • npm test -- --runTestsByPath src/__tests__/poolSharePrice.test.ts
  • npm test -- --runTestsByPath src/__tests__/poolController.asyncHandler.test.ts src/__tests__/swaggerDocs.test.ts
  • npm run typecheck
  • git diff --check

@Lucas-FManager
Copy link
Copy Markdown
Author

CI note after re-checking the failing workflow:

  • CodeQL and supply-chain checks are passing.
  • I re-ran formatting/lint on the backend files changed by this PR locally:
    • npx prettier --check src/app.ts src/config/swaggerSchemas.ts src/controllers/poolController.ts src/routes/poolRoutes.ts src/schemas/poolSchemas.ts src/services/sorobanService.ts src/__tests__/poolSharePrice.test.ts -> passed
    • npx eslint src/app.ts src/config/swaggerSchemas.ts src/controllers/poolController.ts src/routes/poolRoutes.ts src/schemas/poolSchemas.ts src/services/sorobanService.ts src/__tests__/poolSharePrice.test.ts -> passed with warnings only
  • The red CI is coming from the shared full-repo lint/format pass, including files outside this PR scope. I am leaving the branch unchanged unless you want the PR to also normalize broader repository formatting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant