Skip to content

Commit 3cc84af

Browse files
Opdata 2671 wintermute ea (#4139)
* Add tsconfig file * Wintermute * add changeset * Updated yarn.lock file * update packages * FIX: unit test linter errors * FIX: linter issues; replace index with symbol * FIX: failing tests * FIX: README and test-payload --------- Co-authored-by: app-token-issuer-data-feeds[bot] <134377064+app-token-issuer-data-feeds[bot]@users.noreply.github.com>
1 parent aebc473 commit 3cc84af

File tree

20 files changed

+512
-0
lines changed

20 files changed

+512
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@chainlink/wintermute-adapter': major
3+
---
4+
5+
Wintermute v1.0

.pnp.cjs

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/sources/wintermute/CHANGELOG.md

Whitespace-only changes.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# WINTERMUTE
2+
3+
![0.0.0](https://img.shields.io/github/package-json/v/smartcontractkit/external-adapters-js?filename=packages/sources/gmci/package.json) ![v3](https://img.shields.io/badge/framework%20version-v3-blueviolet)
4+
5+
This document was generated automatically. Please see [README Generator](../../scripts#readme-generator) for more info.
6+
7+
## Environment Variables
8+
9+
| Required? | Name | Description | Type | Options | Default |
10+
| :-------: | :-------------: | :--------------------------------: | :----: | :-----: | :-------------------------: |
11+
|| API_KEY | An API key for Data Provider | string | | |
12+
| | WS_API_ENDPOINT | WS endpoint for GMCI Data Provider | string | | `wss://api.gmci.co/private` |
13+
14+
---
15+
16+
## Data Provider Rate Limits
17+
18+
There are no rate limits for this adapter.
19+
20+
---
21+
22+
## Input Parameters
23+
24+
| Required? | Name | Description | Type | Options | Default |
25+
| :-------: | :------: | :-----------------: | :----: | :----------------------: | :-----: |
26+
| | endpoint | The endpoint to use | string | [price](#price-endpoint) | `price` |
27+
28+
## Price Endpoint
29+
30+
`price` is the only supported name for this endpoint.
31+
32+
### Input Params
33+
34+
| Required? | Name | Aliases | Description | Type | Options | Default | Depends On | Not Valid With |
35+
| :-------: | :---: | :-----: | :---------: | :----: | :-----: | :-----: | :--------: | :------------: |
36+
|| index | | Index name | string | | | | |
37+
38+
### Example
39+
40+
Request:
41+
42+
```json
43+
{
44+
"data": {
45+
"endpoint": "price",
46+
"symbol": "GMCI30"
47+
}
48+
}
49+
```
50+
51+
---
52+
53+
MIT License
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "@chainlink/wintermute-adapter",
3+
"version": "1.0.3",
4+
"description": "Chainlink wintermute adapter.",
5+
"keywords": [
6+
"Chainlink",
7+
"LINK",
8+
"blockchain",
9+
"oracle",
10+
"wintermute"
11+
],
12+
"main": "dist/index.js",
13+
"types": "dist/index.d.ts",
14+
"files": [
15+
"dist"
16+
],
17+
"repository": {
18+
"url": "https://github.com/smartcontractkit/external-adapters-js",
19+
"type": "git"
20+
},
21+
"license": "MIT",
22+
"scripts": {
23+
"clean": "rm -rf dist && rm -f tsconfig.tsbuildinfo",
24+
"prepack": "yarn build",
25+
"build": "tsc -b",
26+
"server": "node -e 'require(\"./index.js\").server()'",
27+
"server:dist": "node -e 'require(\"./dist/index.js\").server()'",
28+
"start": "yarn server:dist"
29+
},
30+
"devDependencies": {
31+
"@sinonjs/fake-timers": "9.1.2",
32+
"@types/jest": "^29.5.14",
33+
"@types/node": "22.14.1",
34+
"@types/sinonjs__fake-timers": "8.1.5",
35+
"nock": "13.5.6",
36+
"typescript": "5.8.3"
37+
},
38+
"dependencies": {
39+
"@chainlink/external-adapter-framework": "2.8.0",
40+
"tslib": "2.4.1"
41+
}
42+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { AdapterConfig } from '@chainlink/external-adapter-framework/config'
2+
3+
export const config = new AdapterConfig({
4+
API_KEY: {
5+
description: 'An API key for Wintermute Data Provider',
6+
type: 'string',
7+
required: true,
8+
sensitive: true,
9+
},
10+
WS_API_ENDPOINT: {
11+
description: 'WS endpoint for Wintermute Data Provider',
12+
type: 'string',
13+
required: true,
14+
},
15+
})
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { endpoint as price } from './price'
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { AdapterEndpoint } from '@chainlink/external-adapter-framework/adapter'
2+
import { InputParameters } from '@chainlink/external-adapter-framework/validation'
3+
import { config } from '../config'
4+
import { transport } from '../transport/price'
5+
6+
export const inputParameters = new InputParameters(
7+
{
8+
symbol: {
9+
required: true,
10+
type: 'string',
11+
description: 'Index name',
12+
},
13+
},
14+
[
15+
{
16+
symbol: 'GMCI30',
17+
},
18+
],
19+
)
20+
21+
export type WintermuteResultResponse = {
22+
Result: number
23+
Data: {
24+
symbol: string
25+
result: number
26+
}
27+
}
28+
29+
export type BaseEndpointTypes = {
30+
Parameters: typeof inputParameters.definition
31+
Response: WintermuteResultResponse
32+
Settings: typeof config.settings
33+
}
34+
35+
export const endpoint = new AdapterEndpoint({
36+
name: 'price',
37+
aliases: [],
38+
transport: transport,
39+
inputParameters,
40+
})
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { expose, ServerInstance } from '@chainlink/external-adapter-framework'
2+
import { Adapter } from '@chainlink/external-adapter-framework/adapter'
3+
import { config } from './config'
4+
import { price } from './endpoint'
5+
6+
export const adapter = new Adapter({
7+
defaultEndpoint: price.name,
8+
name: 'WINTERMUTE',
9+
config,
10+
endpoints: [price],
11+
})
12+
13+
export const server = (): Promise<ServerInstance | undefined> => expose(adapter)
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import { EndpointContext } from '@chainlink/external-adapter-framework/adapter'
2+
import {
3+
WebSocketTransport,
4+
WebSocketTransportConfig,
5+
} from '@chainlink/external-adapter-framework/transports'
6+
import { BaseEndpointTypes } from '../endpoint/price'
7+
8+
export interface PriceMessage {
9+
last_updated: string
10+
price: number
11+
symbol: string
12+
}
13+
14+
export interface WSResponse {
15+
success: boolean
16+
data: Array<PriceMessage>
17+
topic: string
18+
}
19+
20+
export type WsTransportTypes = BaseEndpointTypes & {
21+
Provider: {
22+
WsMessage: WSResponse
23+
}
24+
}
25+
26+
export const options: WebSocketTransportConfig<WsTransportTypes> = {
27+
url: (context: EndpointContext<WsTransportTypes>) => context.adapterSettings.WS_API_ENDPOINT,
28+
options: async (context: EndpointContext<WsTransportTypes>) => ({
29+
headers: {
30+
'X-GMCI-API-KEY': context.adapterSettings.API_KEY,
31+
},
32+
}),
33+
34+
handlers: {
35+
message(message) {
36+
if (message.success === false) {
37+
return
38+
}
39+
40+
const results = []
41+
42+
if (message.topic === 'price') {
43+
for (const item of message.data) {
44+
results.push({
45+
params: { symbol: item.symbol },
46+
response: {
47+
result: item.price,
48+
data: {
49+
result: item.price,
50+
symbol: item.symbol,
51+
},
52+
timestamps: {
53+
providerIndicatedTimeUnixMs: Date.parse(item.last_updated),
54+
},
55+
},
56+
})
57+
}
58+
}
59+
return results
60+
},
61+
},
62+
63+
builders: {
64+
subscribeMessage: (params) => {
65+
return {
66+
op: 'subscribe',
67+
args: [`price.${params.symbol}`.toLowerCase()],
68+
}
69+
},
70+
71+
unsubscribeMessage: (params) => {
72+
return {
73+
op: 'unsubscribe',
74+
args: [`price.${params.symbol}`.toLowerCase()],
75+
}
76+
},
77+
},
78+
}
79+
80+
export const transport = new WebSocketTransport(options)

0 commit comments

Comments
 (0)