Skip to content

feat(sdk): mock spoke cf, thf, lb#1253

Merged
gbarkhatov merged 3 commits intomainfrom
feat/partial-liquidation-02-sdk-spoke-read
Mar 17, 2026
Merged

feat(sdk): mock spoke cf, thf, lb#1253
gbarkhatov merged 3 commits intomainfrom
feat/partial-liquidation-02-sdk-spoke-read

Conversation

@gbarkhatov
Copy link
Contributor

@gbarkhatov gbarkhatov commented Mar 17, 2026

  • adds mock data for core spoke - cf - collateral factor, thf - target health factor, lb - liquidation bonus

closes #1227

Greptile Summary

This PR introduces mock implementations for three Core Spoke governance parameters — Collateral Factor (CF), Target Health Factor (THF), and Liquidation Bonus (LB) — as placeholder reads until the real Core Spoke ABI is available. The changes follow the existing pattern of async contract-read functions in spoke.ts, export the mocks via the public aave module, and include an eslint rule update to allow _-prefixed unused parameters.

Key changes:

  • Adds MOCK_TARGET_HEALTH_FACTOR_WAD (1.10), MOCK_COLLATERAL_FACTOR_BPS (75%), and MOCK_LIQUIDATION_BONUS_WAD (1.05) to constants.ts
  • Adds getTargetHealthFactor, getCollateralFactor, and getLiquidationBonus to spoke.ts, each returning the corresponding mock constant
  • Re-exports all three constants and functions from the public aave/index.ts
  • Adds @typescript-eslint/no-unused-vars ESLint rule with argsIgnorePattern: "^_" to suppress lint errors for the stub parameters
  • Note: getCollateralFactor returns a BPS-scaled value (7500n), while getTargetHealthFactor and getLiquidationBonus return WAD-scaled values. This is inconsistent with the existing avgCollateralFactor field in getUserAccountData, which is WAD-scaled, and may cause calculation errors if callers assume a uniform scale across all three functions.

Confidence Score: 3/5

  • Safe to merge as a temporary mock, but the BPS/WAD scale mismatch in the public API should be resolved before dependent code is written against it.
  • The mock implementations are straightforward and well-documented with TODO notes. The primary concern is that getCollateralFactor returns BPS while the other two functions return WAD — an inconsistency that also conflicts with the existing avgCollateralFactor (WAD) in getUserAccountData. Since these mocks are exported as part of the public SDK API, consumers may already start building against the current scale conventions, making a later correction a breaking change.
  • packages/babylon-ts-sdk/src/tbv/integrations/aave/clients/spoke.ts — the mixed BPS/WAD return units across the three new getter functions warrants attention before downstream code is built on top of it.

Important Files Changed

Filename Overview
packages/babylon-ts-sdk/src/tbv/integrations/aave/clients/spoke.ts Adds three mock getter functions (getTargetHealthFactor, getCollateralFactor, getLiquidationBonus). Main concern: getCollateralFactor returns BPS while the other two return WAD, which is inconsistent with each other and with the existing avgCollateralFactor (WAD) in getUserAccountData.
packages/babylon-ts-sdk/src/tbv/integrations/aave/constants.ts Adds three well-documented MOCK_* constants with correct numeric values and clear TODO notes. Values are correctly computed (WAD and BPS scaled as documented).
packages/babylon-ts-sdk/src/tbv/integrations/aave/clients/tests/spoke.test.ts Tests verify all three mock return values; correct use of BPS_SCALE and WAD_DECIMALS. Minor concern: converting large bigints to Number for arithmetic, though the specific constants happen to be exactly representable in float64.
packages/babylon-ts-sdk/src/tbv/integrations/aave/index.ts Correctly re-exports both the new MOCK_* constants and the three new getter functions from the public API.
packages/babylon-ts-sdk/src/tbv/integrations/aave/clients/index.ts Cleanly exports the three new functions alongside existing exports; no issues.
packages/babylon-ts-sdk/eslint.config.mjs Adds no-unused-vars rule with _-prefix ignore pattern (needed for the new mock function parameters). Plugin re-declaration may be redundant if the shared typescriptConfig already registers it, but is harmless in ESLint flat config.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Caller] -->|getTargetHealthFactor| B[spoke.ts]
    A -->|getCollateralFactor| B
    A -->|getLiquidationBonus| B

    B -->|returns MOCK_TARGET_HEALTH_FACTOR_WAD| C["WAD scale\n1_100_000_000_000_000_000n\n÷ 1e18 = 1.10"]
    B -->|returns MOCK_COLLATERAL_FACTOR_BPS| D["BPS scale ⚠️\n7500n\n÷ 10000 = 0.75"]
    B -->|returns MOCK_LIQUIDATION_BONUS_WAD| E["WAD scale\n1_050_000_000_000_000_000n\n÷ 1e18 = 1.05"]

    C --> F[constants.ts]
    D --> F
    E --> F

    style D fill:#fff3cd,stroke:#ffc107,color:#000
Loading

Last reviewed commit: 3300f4f

Greptile also left 2 inline comments on this PR.

@cursor
Copy link

cursor bot commented Mar 17, 2026

You have used all of your free Bugbot PR reviews.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@github-actions
Copy link

github-actions bot commented Mar 17, 2026

🔐 Commit Signature Verification

All 3 commit(s) passed verification

Commit Author Signature Key Type Key Check
7fd13a4a1910 Govard Barkhatov sk-ssh-ed25519
98ca861beda6 Govard Barkhatov sk-ssh-ed25519
3300f4fed19a Govard Barkhatov sk-ssh-ed25519

Summary

  • Commits verified: 3
  • Signature check: ✅ All passed
  • Key type enforcement: ✅ All sk-ssh-ed25519

Required key type: sk-ssh-ed25519 (FIDO2 hardware key)

Last verified: 2026-03-17 10:02 UTC

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3300f4fed1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Collaborator

@jrwbabylonlab jrwbabylonlab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, ok. i assume u have relevant ticket tracking the todo?

@gbarkhatov
Copy link
Contributor Author

@jrwbabylonlab #1254

@gbarkhatov gbarkhatov merged commit 2b066e2 into main Mar 17, 2026
6 checks passed
@gbarkhatov gbarkhatov deleted the feat/partial-liquidation-02-sdk-spoke-read branch March 17, 2026 10:14
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.

[Partial Liquidation] - 02 - ts-sdk - Contract read functions for Core Spoke parameters

2 participants