Skip to content

Feat/OPDATA-6509 support data engine v7 schema & returnAs: float#4770

Open
mmcallister-cll wants to merge 4 commits intomainfrom
feat/OPDATA-6509-support-data-engine-v7-float
Open

Feat/OPDATA-6509 support data engine v7 schema & returnAs: float#4770
mmcallister-cll wants to merge 4 commits intomainfrom
feat/OPDATA-6509-support-data-engine-v7-float

Conversation

@mmcallister-cll
Copy link
Copy Markdown
Contributor

@mmcallister-cll mmcallister-cll commented Mar 25, 2026

Closes #OPDATA-6509

Description

Adds support for data-engine v7 report schema
Adds functionality to decimal scaling via returnAs: 'float' input param. Previous behaviour was truncate-only. Truncate is preserved as default behaviour for backward compatibility.

Changes

  • Add exchangeRate-v7 (redemptionRate-v7) endpoint
  • Added returnAs common inputParam to allow for scaling selection (+ required downstream code changes)
  • Added tests
  • Mock date in tests to ensure new additions don't affect snapshots moving forward

Steps to Test

  1. yarn test data-engine
  2. with payload
{
    "data": {
        "endpoint": "redemptionRate-v7",
        "feedId": "0x0007621b6f5eb0b5bd5a8bb3d52902b3e19498ba45781e5ddf92ce7e03d7ecef",
        "resultPath": "exchangeRate",
        "decimals": 0,
        "returnAs": "float"
    }
}

Quality Assurance

  • If a new adapter was made, or an existing one was modified so that its environment variables have changed, update the relevant infra-k8s configuration file.
  • If a new adapter was made, or an existing one was modified so that its environment variables have changed, update the relevant adapter-secrets configuration file.
  • If a new adapter was made, or a new endpoint was added, update the test-payload.json file with relevant requests.
  • The branch naming follows git flow (feature/x, chore/x, release/x, hotfix/x, fix/x) or is created from Jira.
  • This is related to a maximum of one Jira story or GitHub issue.
  • Types are safe (avoid TypeScript/TSLint features like any and disable, instead use more specific types).
  • All code changes have 100% unit and integration test coverage. If testing is not applicable or too difficult to justify doing, the reasoning should be documented explicitly in the PR.

@mmcallister-cll mmcallister-cll requested a review from a team March 25, 2026 23:40
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 25, 2026

🦋 Changeset detected

Latest commit: ae9868b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@chainlink/data-engine-adapter Minor
@chainlink/glv-token-adapter Patch
@chainlink/gmx-tokens-adapter Patch
@chainlink/gold-adapter Patch
@chainlink/tokenized-equity-adapter Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

👋 mmcallister-cll, thanks for creating this pull request!

To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team.

Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks!

Copy link
Copy Markdown
Collaborator

@mohamed-mehany mohamed-mehany left a comment

Choose a reason for hiding this comment

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

Looks good, minor comments about edge cases

Comment on lines +25 to +28
if (returnAs === 'float') {
// scaled is the actual value, return as decimal string
return scaled.toString()
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

When fromDecimals === toDecimals, the function returns immediately, bypassing the 'float' logic entirely. If someone passes decimals: 18 (same as native) with returnAs: 'float', they'd get the raw integer "1156789000000000000" instead of "1.156789".

Copy link
Copy Markdown
Contributor Author

@mmcallister-cll mmcallister-cll Mar 26, 2026

Choose a reason for hiding this comment

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

That looks right to me 🤔. The intent is to perform the same scale-to num_decimals operation as already exists (scale to a certain # of decimals *10^X), but preserve the floating point precision rather than truncating. Am I missing something?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ah I see, I thought "returnAs" meant always return the value as float-point decimal, but I guess it means to return as float only when scaling is required, as an alternative to truncation? maybe worth adding a unit test or 2 to explicitly document the expected behavior.

type: 'number',
description: 'Number of decimals to scale the resultPath value to (from native 18)',
},
returnAs: {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why?

Copy link
Copy Markdown
Contributor Author

@mmcallister-cll mmcallister-cll Mar 26, 2026

Choose a reason for hiding this comment

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

float vs int

Use case is using in a multiply with implied-price. Prob most correct is to add multiply/divide by constant to implied-price, and then nest implied-price calling itself, but figured we already have scaling functionality here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, I think we should update implied-price to multiply two numbers with decimals instead

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.

3 participants