Skip to content

Commit

Permalink
Glv adapter refactor (#3671)
Browse files Browse the repository at this point in the history
* refactor price into a base transport

add separate timeout for GLV info APIs

tighten up vars + code

fixing up tests

* Adjust test data to use proper minimized/maximized glvTokenPrice result
  • Loading branch information
akuzni2 authored Feb 6, 2025
1 parent 805468b commit 5bb85b8
Show file tree
Hide file tree
Showing 8 changed files with 432 additions and 373 deletions.
5 changes: 5 additions & 0 deletions .changeset/sour-glasses-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/glv-token-adapter': minor
---

Refactor price into a base transport
29 changes: 15 additions & 14 deletions packages/composites/glv-token/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@ This document was generated automatically. Please see [README Generator](../../s

## Environment Variables

| Required? | Name | Description | Type | Options | Default |
| :-------: | :--------------------------: | :---------------------------------------------------------------------------------------: | :----: | :-----: | :------------------------------------------: |
|| ARBITRUM_RPC_URL | RPC url of Arbitrum node | string | | |
|| ARBITRUM_CHAIN_ID | The chain id to connect to | number | | `42161` |
|| DATASTORE_CONTRACT_ADDRESS | Address of Data Store contract | string | | `0xFD70de6b91282D8017aA4E741e9Ae325CAb992d8` |
|| GLV_READER_CONTRACT_ADDRESS | Address of Glv Reader Contract | string | | `0x6a9505D0B44cFA863d9281EA5B0b34cB36243b45` |
|| TIINGO_ADAPTER_URL | URL of Tiingo EA | string | | |
|| NCFX_ADAPTER_URL | URL of NCFX EA | string | | |
|| COINMETRICS_ADAPTER_URL | URL of Coinmetrics EA | string | | |
|| MIN_REQUIRED_SOURCE_SUCCESS | Minimum number of source EAs that need to successfully return a value. | number | | `2` |
|| MARKET_INFO_API | URL market meta data supported by Glv | string | | `https://arbitrum-api.gmxinfra.io/markets` |
|| TOKEN_INFO_API | URL to token meta data supported by Glv | string | | `https://arbitrum-api.gmxinfra.io/tokens` |
| | METADATA_REFRESH_INTERVAL_MS | The amount of time the metadata should be refreshed | number | | `10800000` |
| | BACKGROUND_EXECUTE_MS | The amount of time the background execute should sleep before performing the next request | number | | `10000` |
| Required? | Name | Description | Type | Options | Default |
| :-------: | :--------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :----: | :-----: | :------------------------------------------: |
|| ARBITRUM_RPC_URL | RPC url of Arbitrum node | string | | |
|| ARBITRUM_CHAIN_ID | The chain id to connect to | number | | `42161` |
|| DATASTORE_CONTRACT_ADDRESS | Address of Data Store contract | string | | `0xFD70de6b91282D8017aA4E741e9Ae325CAb992d8` |
|| GLV_READER_CONTRACT_ADDRESS | Address of Glv Reader Contract | string | | `0x6a9505D0B44cFA863d9281EA5B0b34cB36243b45` |
|| TIINGO_ADAPTER_URL | URL of Tiingo EA | string | | |
|| NCFX_ADAPTER_URL | URL of NCFX EA | string | | |
|| COINMETRICS_ADAPTER_URL | URL of Coinmetrics EA | string | | |
|| MIN_REQUIRED_SOURCE_SUCCESS | Minimum number of source EAs that need to successfully return a value. | number | | `2` |
|| MARKET_INFO_API | URL market meta data supported by Glv | string | | `https://arbitrum-api.gmxinfra.io/markets` |
|| TOKEN_INFO_API | URL to token meta data supported by Glv | string | | `https://arbitrum-api.gmxinfra.io/tokens` |
| | METADATA_REFRESH_INTERVAL_MS | The amount of time the metadata should be refreshed | number | | `10800000` |
| | BACKGROUND_EXECUTE_MS | The amount of time the background execute should sleep before performing the next request | number | | `10000` |
| | GLV_INFO_API_TIMEOUT_MS | The amount of time the request to the GLV info APIs should wait before timing out. Distinct from timeout used to make requests to the EAs which can be set with API_TIMEOUT | number | | `10000` |

---

Expand Down
7 changes: 7 additions & 0 deletions packages/composites/glv-token/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ export const config = new AdapterConfig(
required: true,
default: 'https://arbitrum-api.gmxinfra.io/tokens',
},
GLV_INFO_API_TIMEOUT_MS: {
description:
'The amount of time the request to the GLV info APIs should wait before timing out. ' +
'Distinct from timeout used to make requests to the EAs which can be set with API_TIMEOUT',
type: 'number',
default: 10_000,
},
METADATA_REFRESH_INTERVAL_MS: {
description: 'The amount of time the metadata should be refreshed',
type: 'number',
Expand Down
4 changes: 2 additions & 2 deletions packages/composites/glv-token/src/endpoint/price.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AdapterEndpoint } from '@chainlink/external-adapter-framework/adapter'
import { InputParameters } from '@chainlink/external-adapter-framework/validation'
import { SingleNumberResultResponse } from '@chainlink/external-adapter-framework/util'
import { config } from '../config'
import { glvTokenTransport } from '../transport/price'
import { glvPriceTransport } from '../transport/price'

export const inputParameters = new InputParameters(
{
Expand Down Expand Up @@ -31,6 +31,6 @@ export type BaseEndpointTypes = {

export const endpoint = new AdapterEndpoint({
name: 'price',
transport: glvTokenTransport,
transport: glvPriceTransport,
inputParameters,
})
Loading

0 comments on commit 5bb85b8

Please sign in to comment.