Skip to content

Conversation

@cl-mayowa
Copy link
Collaborator

@cl-mayowa cl-mayowa commented Oct 20, 2025

Closes OPDATA-4680

Description

This EA fetches Streamex’s GLDY PoR status, verifies gold reserves and ripcord state, and outputs a result for Chainlink PoR feeds.
......

Changes

  • Added reserve endpoint and transport for streamex endpoint
  • Checked for ripcord failure
  • Added authentication via API key
  • Added tests to verify implementation

Steps to Test

  1. Unit tests added
  2. Test endpoints e2e locally

export STREAMEX_API_KEY=<STREAMEX_API_KEY>

reserve endpoint test

curl --location 'http://localhost:8080' \
--header 'Content-Type: application/json' \
--data '{
    "data": {
        "endpoint": "reserve"
    }
}'
{
    "result": 23923,
    "data": {
        "result": 23923,
        "ripcord": false,
        "ripcordAsInt": 0,
        "totalReserve": 23923
    },
    "timestamps": {
        "providerDataRequestedUnixMs": 1760989922089,
        "providerDataReceivedUnixMs": 1760989922679,
        "providerIndicatedTimeUnixMs": 1760989922608
    },
    "statusCode": 200,
    "meta": {
        "adapterName": "STREAMEX",
        "metrics": {
            "feedId": "N/A"
        }
    }
}

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 or update the soak testing blacklist.
  • 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.

@changeset-bot
Copy link

changeset-bot bot commented Oct 20, 2025

🦋 Changeset detected

Latest commit: 16136ba

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

This PR includes changesets to release 1 package
Name Type
@chainlink/streamex-adapter Major

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

@mmcallister-cll mmcallister-cll self-requested a review October 22, 2025 23:33
import { AdapterConfig } from '@chainlink/external-adapter-framework/config'

export const config = new AdapterConfig({
STREAMEX_API_KEY: {
Copy link
Contributor

Choose a reason for hiding this comment

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

Usually prefixing the env var would be reserved for changes where you would select your api key per asset for example, but even then you'd probably want something more like GLDY_API_KEY, OTHERASSET_API_KEY, etc.

Based on the default API below seeming pretty special for us though, I'm assuming we'll be safe with just API_KEY

export type BaseEndpointTypes = {
Parameters: typeof inputParameters.definition
Response: PoRProviderResponse & {
ripcordAsInt?: number
Copy link
Contributor

@mmcallister-cll mmcallister-cll Oct 22, 2025

Choose a reason for hiding this comment

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

holding on additional usage info in ticket for whether we need this field or not

Copy link
Contributor

Choose a reason for hiding this comment

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

seems we can remove

tiers: {
default: {
rateLimit1m: 10, // 10 requests per minute
rateLimit1s: 2, // 20 per 10s = ~2 per second
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you're trying to define some sort of burst limiter, correct?
While usefulness is debatable, I don't think this will work the way you expect it to. Here's the usage in the framework: https://github.com/smartcontractkit/ea-framework-js/blob/main/src/rate-limiting/index.ts#L139-L141

IMO just stick with the 10req/min and you can remove the rateLimit1s line.

params: [param],
request: {
baseURL: config.API_ENDPOINT,
url: '/gldy-status',
Copy link
Contributor

Choose a reason for hiding this comment

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

qq: do you want to stick this in the default API_ENDPOINT or is it possible we'll reuse this data provider with another path?

response: {
errorMessage: message,
ripcord,
ripcordAsInt,
Copy link
Contributor

Choose a reason for hiding this comment

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

again, may not need this (awaiting further details), if we do, this is not the correct implementation. See https://github.com/smartcontractkit/external-adapters-js/blob/main/packages/sources/the-network-firm/src/endpoint/reserve.ts#L17-L23 for more context


// If ripcord is true, return 502 error
if (ripcord) {
const ripcordDetails = response.data.ripcordDetails.join(', ')
Copy link
Contributor

Choose a reason for hiding this comment

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

do we have an example of the ripcord details?

Copy link
Contributor

Choose a reason for hiding this comment

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

can remove

@mmcallister-cll
Copy link
Contributor

mmcallister-cll commented Oct 23, 2025

Please also try adding transport unit tests 🙏

A good example written by @dskloetc is solactive EA: https://github.com/smartcontractkit/external-adapters-js/blob/main/packages/sources/solactive/test/unit/nav.test.ts

Take a lot of inspiration from this test file. Adding the unit tests will likely require a small refactor of the transport in order to make it more testable. See https://github.com/smartcontractkit/external-adapters-js/blob/main/packages/sources/solactive/src/transport/nav.ts for inspiration there.

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.

2 participants