Skip to content

Commit

Permalink
Added gm-token EA (#3123)
Browse files Browse the repository at this point in the history
* add gm-token EA

* add gm-token ea to soakTestBlacklist

* change response to include sources for prices

* regenerate readme

* change error message

* remove unused property from PriceData type
  • Loading branch information
karen-stepanyan authored Jan 2, 2024
1 parent d48d103 commit 1379810
Show file tree
Hide file tree
Showing 23 changed files with 4,956 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/neat-dryers-repair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/gm-token-adapter': major
---

Initial version of the EA
22 changes: 22 additions & 0 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
67 changes: 67 additions & 0 deletions packages/composites/gm-token/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# GM_TOKEN

![0.0.0](https://img.shields.io/github/package-json/v/smartcontractkit/external-adapters-js?filename=packages/composites/gm-token/package.json) ![v3](https://img.shields.io/badge/framework%20version-v3-blueviolet)

This document was generated automatically. Please see [README Generator](../../scripts#readme-generator) for more info.

## 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` |
|| READER_CONTRACT_ADDRESS | Address of Reader contract | string | | `0xf60becbba223EEA9495Da3f606753867eC10d139` |
|| PNL_FACTOR_TYPE | PnL factor type. See https://github.com/gmx-io/gmx-synthetics#market-token-price | string | | `MAX_PNL_FACTOR_FOR_TRADERS` |
|| 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` |
| | BACKGROUND_EXECUTE_MS | The amount of time the background execute should sleep before performing the next request | number | | `10000` |

---

## Data Provider Rate Limits

There are no rate limits for this adapter.

---

## Input Parameters

| Required? | Name | Description | Type | Options | Default |
| :-------: | :------: | :-----------------: | :----: | :----------------------: | :-----: |
| | endpoint | The endpoint to use | string | [price](#price-endpoint) | `price` |

## Price Endpoint

`price` is the only supported name for this endpoint.

### Input Params

| Required? | Name | Aliases | Description | Type | Options | Default | Depends On | Not Valid With |
| :-------: | :----: | :-----: | :----------------------------------------------------------------------------------: | :----: | :---------------------------------------------------------------------: | :-----: | :--------: | :------------: |
|| index | | Index token. Long and short tokens will be opened / closed based on this price feed. | string | `ARB`, `BTC`, `DOGE`, `ETH`, `LINK`, `LTC`, `SOL`, `UNI`, `WETH`, `XRP` | | | |
|| long | | Long token. This is the token that will back long positions. | string | `ARB`, `ETH`, `LINK`, `SOL`, `UNI`, `WBTC.b`, `WETH` | | | |
|| short | | Short token. This is the token that will back short positions. | string | `USDC` | | | |
|| market | | Market address of the market pool. | string | | | | |

### Example

Request:

```json
{
"data": {
"endpoint": "price",
"index": "LINK",
"long": "LINK",
"short": "USDC",
"market": "0x7f1fa204bb700853D36994DA19F830b6Ad18455C"
}
}
```

---

MIT License
42 changes: 42 additions & 0 deletions packages/composites/gm-token/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "@chainlink/gm-token-adapter",
"version": "0.0.0",
"description": "Chainlink gm-token adapter.",
"keywords": [
"Chainlink",
"LINK",
"blockchain",
"oracle",
"gm-token"
],
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"repository": {
"url": "https://github.com/smartcontractkit/external-adapters-js",
"type": "git"
},
"license": "MIT",
"scripts": {
"clean": "rm -rf dist && rm -f tsconfig.tsbuildinfo",
"prepack": "yarn build",
"build": "tsc -b",
"server": "node -e 'require(\"./index.js\").server()'",
"server:dist": "node -e 'require(\"./dist/index.js\").server()'",
"start": "yarn server:dist"
},
"devDependencies": {
"@types/jest": "27.5.2",
"@types/node": "16.11.51",
"nock": "13.2.9",
"typescript": "5.0.4"
},
"dependencies": {
"@chainlink/external-adapter-framework": "0.33.1",
"decimal.js": "^10.3.1",
"ethers": "^5.4.6",
"tslib": "2.4.1"
}
}
70 changes: 70 additions & 0 deletions packages/composites/gm-token/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { AdapterConfig } from '@chainlink/external-adapter-framework/config'
import { validator } from '@chainlink/external-adapter-framework/validation/utils'

export const config = new AdapterConfig(
{
ARBITRUM_RPC_URL: {
description: 'RPC url of Arbitrum node',
type: 'string',
required: true,
},
ARBITRUM_CHAIN_ID: {
description: 'The chain id to connect to',
type: 'number',
required: true,
default: 42161,
},
DATASTORE_CONTRACT_ADDRESS: {
description: 'Address of Data Store contract',
type: 'string',
required: true,
default: '0xFD70de6b91282D8017aA4E741e9Ae325CAb992d8',
},
READER_CONTRACT_ADDRESS: {
description: 'Address of Reader contract',
type: 'string',
required: true,
default: '0xf60becbba223EEA9495Da3f606753867eC10d139',
},
PNL_FACTOR_TYPE: {
description:
'PnL factor type. See https://github.com/gmx-io/gmx-synthetics#market-token-price',
type: 'string',
required: true,
default: 'MAX_PNL_FACTOR_FOR_TRADERS',
},
TIINGO_ADAPTER_URL: {
description: 'URL of Tiingo EA',
type: 'string',
required: true,
},
NCFX_ADAPTER_URL: {
description: 'URL of NCFX EA',
type: 'string',
required: true,
},
COINMETRICS_ADAPTER_URL: {
description: 'URL of Coinmetrics EA',
type: 'string',
required: true,
},
MIN_REQUIRED_SOURCE_SUCCESS: {
description: 'Minimum number of source EAs that need to successfully return a value.',
type: 'number',
required: true,
default: 2,
validate: validator.integer({ min: 1, max: 3 }),
},
BACKGROUND_EXECUTE_MS: {
description:
'The amount of time the background execute should sleep before performing the next request',
type: 'number',
default: 10_000,
},
},
{
envDefaultOverrides: {
RETRY: 3,
},
},
)
Loading

0 comments on commit 1379810

Please sign in to comment.