Skip to content

Commit 5bb85b8

Browse files
authored
Glv adapter refactor (#3671)
* 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
1 parent 805468b commit 5bb85b8

File tree

8 files changed

+432
-373
lines changed

8 files changed

+432
-373
lines changed

.changeset/sour-glasses-travel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@chainlink/glv-token-adapter': minor
3+
---
4+
5+
Refactor price into a base transport

packages/composites/glv-token/README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,21 @@ This document was generated automatically. Please see [README Generator](../../s
66

77
## Environment Variables
88

9-
| Required? | Name | Description | Type | Options | Default |
10-
| :-------: | :--------------------------: | :---------------------------------------------------------------------------------------: | :----: | :-----: | :------------------------------------------: |
11-
|| ARBITRUM_RPC_URL | RPC url of Arbitrum node | string | | |
12-
|| ARBITRUM_CHAIN_ID | The chain id to connect to | number | | `42161` |
13-
|| DATASTORE_CONTRACT_ADDRESS | Address of Data Store contract | string | | `0xFD70de6b91282D8017aA4E741e9Ae325CAb992d8` |
14-
|| GLV_READER_CONTRACT_ADDRESS | Address of Glv Reader Contract | string | | `0x6a9505D0B44cFA863d9281EA5B0b34cB36243b45` |
15-
|| TIINGO_ADAPTER_URL | URL of Tiingo EA | string | | |
16-
|| NCFX_ADAPTER_URL | URL of NCFX EA | string | | |
17-
|| COINMETRICS_ADAPTER_URL | URL of Coinmetrics EA | string | | |
18-
|| MIN_REQUIRED_SOURCE_SUCCESS | Minimum number of source EAs that need to successfully return a value. | number | | `2` |
19-
|| MARKET_INFO_API | URL market meta data supported by Glv | string | | `https://arbitrum-api.gmxinfra.io/markets` |
20-
|| TOKEN_INFO_API | URL to token meta data supported by Glv | string | | `https://arbitrum-api.gmxinfra.io/tokens` |
21-
| | METADATA_REFRESH_INTERVAL_MS | The amount of time the metadata should be refreshed | number | | `10800000` |
22-
| | BACKGROUND_EXECUTE_MS | The amount of time the background execute should sleep before performing the next request | number | | `10000` |
9+
| Required? | Name | Description | Type | Options | Default |
10+
| :-------: | :--------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :----: | :-----: | :------------------------------------------: |
11+
|| ARBITRUM_RPC_URL | RPC url of Arbitrum node | string | | |
12+
|| ARBITRUM_CHAIN_ID | The chain id to connect to | number | | `42161` |
13+
|| DATASTORE_CONTRACT_ADDRESS | Address of Data Store contract | string | | `0xFD70de6b91282D8017aA4E741e9Ae325CAb992d8` |
14+
|| GLV_READER_CONTRACT_ADDRESS | Address of Glv Reader Contract | string | | `0x6a9505D0B44cFA863d9281EA5B0b34cB36243b45` |
15+
|| TIINGO_ADAPTER_URL | URL of Tiingo EA | string | | |
16+
|| NCFX_ADAPTER_URL | URL of NCFX EA | string | | |
17+
|| COINMETRICS_ADAPTER_URL | URL of Coinmetrics EA | string | | |
18+
|| MIN_REQUIRED_SOURCE_SUCCESS | Minimum number of source EAs that need to successfully return a value. | number | | `2` |
19+
|| MARKET_INFO_API | URL market meta data supported by Glv | string | | `https://arbitrum-api.gmxinfra.io/markets` |
20+
|| TOKEN_INFO_API | URL to token meta data supported by Glv | string | | `https://arbitrum-api.gmxinfra.io/tokens` |
21+
| | METADATA_REFRESH_INTERVAL_MS | The amount of time the metadata should be refreshed | number | | `10800000` |
22+
| | BACKGROUND_EXECUTE_MS | The amount of time the background execute should sleep before performing the next request | number | | `10000` |
23+
| | 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` |
2324

2425
---
2526

packages/composites/glv-token/src/config/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ export const config = new AdapterConfig(
6060
required: true,
6161
default: 'https://arbitrum-api.gmxinfra.io/tokens',
6262
},
63+
GLV_INFO_API_TIMEOUT_MS: {
64+
description:
65+
'The amount of time the request to the GLV info APIs should wait before timing out. ' +
66+
'Distinct from timeout used to make requests to the EAs which can be set with API_TIMEOUT',
67+
type: 'number',
68+
default: 10_000,
69+
},
6370
METADATA_REFRESH_INTERVAL_MS: {
6471
description: 'The amount of time the metadata should be refreshed',
6572
type: 'number',

packages/composites/glv-token/src/endpoint/price.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { AdapterEndpoint } from '@chainlink/external-adapter-framework/adapter'
22
import { InputParameters } from '@chainlink/external-adapter-framework/validation'
33
import { SingleNumberResultResponse } from '@chainlink/external-adapter-framework/util'
44
import { config } from '../config'
5-
import { glvTokenTransport } from '../transport/price'
5+
import { glvPriceTransport } from '../transport/price'
66

77
export const inputParameters = new InputParameters(
88
{
@@ -31,6 +31,6 @@ export type BaseEndpointTypes = {
3131

3232
export const endpoint = new AdapterEndpoint({
3333
name: 'price',
34-
transport: glvTokenTransport,
34+
transport: glvPriceTransport,
3535
inputParameters,
3636
})

0 commit comments

Comments
 (0)