Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Peregrine Data External Adapter Submission #3590

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

droconnel22
Copy link

Closes #ISSUE_NUMBER_GOES_HERE

Description

......

Changes

  • High level
  • changes that
  • you made

Steps to Test

  1. Steps
  2. to
  3. test

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.

Copy link

changeset-bot bot commented Nov 27, 2024

🦋 Changeset detected

Latest commit: 481efb8

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

This PR includes changesets to release 1 package
Name Type
@chainlink/peregrine-fund-admin-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

@droconnel22 droconnel22 changed the title nav and reserve build out Peregrine Data External Adapter Submission Nov 27, 2024
Copy link
Contributor

@mxiao-cll mxiao-cll left a comment

Choose a reason for hiding this comment

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

Need to run yarn as well as yarn test peregrine-fund-admin/test

packages/sources/peregrine-fund-admin/src/endpoint/nav.ts Outdated Show resolved Hide resolved
packages/sources/peregrine-fund-admin/src/endpoint/nav.ts Outdated Show resolved Hide resolved
@mmcallister-cll
Copy link
Contributor

once changes are made, please run yarn changeset and select major from root external-adapters-js dir.

// `request` contains any valid axios request configuration
request: {
baseURL: config.DEFAULT_BASE_URL,
url: config.DEFAULT_RESERVE_URL,
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't this supposed to include the assetId as a path param the end?

Copy link
Author

Choose a reason for hiding this comment

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

There are now API search query params, I just need to include the assetId as path a variable on the end. This is true for both end points.

i.e. https://www.myfoo.com/api/v1/nav/100, https://www.myfoo.com/api/v1/reserves/100
https://www.myfoo.com/api/v1/reserves/{assetId}

Copy link
Author

Choose a reason for hiding this comment

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

I think i see the suggestion now will update with param injected into the endpoint string for the prepareRequest

@droconnel22
Copy link
Author

once changes are made, please run yarn changeset and select major from root external-adapters-js dir.

this has now been run and commited in latest for this PR.

@droconnel22
Copy link
Author

once changes are made, please run yarn changeset and select major from root external-adapters-js dir.

this has been run.

@droconnel22
Copy link
Author

what is the correct way to run test in my directory? I tried yarn test, etc.

@mxiao-cll
Copy link
Contributor

what is the correct way to run test in my directory? I tried yarn test, etc.

yarn test peregrine-fund-admin/test

in root

@droconnel22
Copy link
Author

Need to run yarn as well as yarn test peregrine-fund-admin/test

Thank you I have now pushed the latest commit with 2 passing integration tests, at least locally passing. Please see if test pass as well.

@mxiao-cll
Copy link
Contributor

Looks like you need to run yarn again

@mxiao-cll
Copy link
Contributor

I also didn't see you latest commit

@droconnel22
Copy link
Author

`

PASS packages/sources/peregrine-fund-admin/test/integration/adapter.test.ts

Test Suites: 1 passed, 1 total
Tests: 2 passed, 2 total
Snapshots: 2 passed, 2 total
Time: 2.561 s, estimated 3 s`

Please confirm running the integration tests pass as expected.

},
API_RESERVE_ENDPOINT: {
description: 'API Endpoint to get the latest Proof of Reserves for a given asset',
type: 'string',
Copy link
Contributor

Choose a reason for hiding this comment

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

The values seems to be lost?

Copy link
Contributor

Choose a reason for hiding this comment

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

Just need 1 changeset for the PR, please mark it major instead of patch

required: true,
sensitive: true,
},
API_BASE_URL: {
Copy link
Contributor

Choose a reason for hiding this comment

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

might be what @mxiao-cll is mentioning below, but should there be default URLs here as there were in the original commit?

}

export const endpoint = new AdapterEndpoint({
// Endpoint name
Copy link
Contributor

Choose a reason for hiding this comment

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

you can get rid of the comments in this object

}

export const endpoint = new AdapterEndpoint({
// Endpoint name
Copy link
Contributor

Choose a reason for hiding this comment

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

here too please

import { nav, reserve } from './endpoint'

export const adapter = new Adapter({
//Requests will direct to this endpoint if the `endpoint` input parameter is not specified.
Copy link
Contributor

Choose a reason for hiding this comment

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

and here

// `request` contains any valid axios request configuration
request: {
baseURL: config.API_BASE_URL,
url: config.API_NAV_ENDPOINT,
Copy link
Contributor

Choose a reason for hiding this comment

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

this is still missing the assetId, isn't it?

return {
params: param,
response: {
result: Number(response.data.equityNav),
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't follow the earlier discussion very closely but I think what you might be looking for here is something like the following:

add to nav inputParameters

    trancheSelector: {
      required: true,
      type: 'string',
      options: ['equityNav', 'seniorNAV', 'juniorNav'],
      description: 'The tranche to use as result',
    },

then here

result: Number(response.data[param.trancheSelector])

plus necessary validation/verification where appropriate

@mmcallister-cll
Copy link
Contributor

mmcallister-cll commented Dec 4, 2024

Please run end to end manual tests as well on the package.
You'll need to set the necessary env vars (API_KEY, any endpoint overrides)
Then from external-adapters-js/packages/sources/peregrine-fund-admin run

> yarn build; yarn start

and request against your local EA with a curl like this (plus any additional params you add)

curl --location 'localhost:8080' \
--header 'Content-Type: application/json' \
--data '{
  "data": {
    "endpoint": "globalmarketcap",
    "assetId": "100"
  }
}'

hope this will help with the e2e debugging 🙏

export interface ResponseSchema {
Id: string | null
assetId: string
seniorNAV: string
Copy link
Contributor

@mmcallister-cll mmcallister-cll Dec 4, 2024

Choose a reason for hiding this comment

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

also I'm curious why this senior NAV is capitalized while junior and equity use Nav?

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