Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/beige-timers-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/coinpaprika-state-adapter': major
---

Add coinpaprika-state adapter for real-time state price streaming
20 changes: 20 additions & 0 deletions .pnp.cjs

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

Empty file.
82 changes: 82 additions & 0 deletions packages/sources/coinpaprika-state/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# COINPAPRIKA_STATE

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

This document was generated automatically. Please see [Input Parameters](#Input-Parameters) for a list of environments variables and [Schemas](#Schemas) for additional examples.

## Environment Variables

| Required? | Name | Description | Type | Options | Default |
| :-------: | :---------------------: | :---------------------------------------------------------------------------------------: | :----: | :-----: | :-------------------------------------------------: |
| ✅ | `API_KEY` | An API key for Coinpaprika | string | | |
| | `API_ENDPOINT` | An API endpoint for Coinpaprika | string | | `https://chainlink-streaming.dexpaprika.com/stream` |
| | `BACKGROUND_EXECUTE_MS` | The amount of time the background execute should sleep before performing the next request | number | | `3000` |
| | `REQUEST_TIMEOUT_MS` | Timeout for HTTP requests to the provider in milliseconds | number | | `60000` |
| | `RECONNECT_DELAY_MS` | Base delay for reconnection attempts in milliseconds | number | | `5000` |

---

## Input Parameters

Every EA supports base input parameters from [this list](https://github.com/smartcontractkit/ea-framework-js/blob/main/src/config/index.ts)

| Required? | Name | Description | Type | Options | Default |
| :-------: | :------: | :-----------------: | :----: | :-----: | :-----: |
| | endpoint | The endpoint to use | string | | |

## Coinpaprika-state Endpoint

`coinpaprika-state` is the only supported name for this endpoint.

### Input Params

| Required? | Name | Aliases | Description | Type | Options | Default | Depends On | Not Valid With |
| :-------: | :-----: | :------------: | :--------------------------------------: | :----: | :-----: | :-----: | :--------: | :------------: |
| ✅ | `base` | `coin`, `from` | The symbol of the currency to query | string | | | | |
| ✅ | `quote` | `market`, `to` | The symbol of the currency to convert to | string | | | | |

### Example

Request:

```json
{
"id": "1",
"data": {
"base": "LUSD",
"quote": "USD"
},
"debug": {
"cacheKey": "YlEjKJJLVmjXzFKQjFjVtKmQWlM="
}
}
```

Response:

```json
{
"jobRunID": "1",
"data": {
"result": 1.000979,
"timestamp": 1758888503
},
"result": 1.000979,
"statusCode": 200,
"timestamps": {
"providerDataRequestedUnixMs": 1758888508939,
"providerDataReceivedUnixMs": 1758888508939,
"providerIndicatedTimeUnixMs": 1758888503000
}
}
```

---

## Known Issues

See [known-issues.md](./known-issues.md) for detailed information about streaming data, connection management, and error handling.

---

MIT License
40 changes: 40 additions & 0 deletions packages/sources/coinpaprika-state/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "@chainlink/coinpaprika-state-adapter",
"version": "0.0.0",
"description": "Chainlink coinpaprika-state adapter.",
"keywords": [
"Chainlink",
"LINK",
"blockchain",
"oracle",
"coinpaprika-state"
],
"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": "^29.5.14",
"@types/node": "22.14.1",
"nock": "13.5.6",
"typescript": "5.8.3"
},
"dependencies": {
"@chainlink/external-adapter-framework": "2.7.2",
"tslib": "2.4.1"
}
}
31 changes: 31 additions & 0 deletions packages/sources/coinpaprika-state/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { AdapterConfig } from '@chainlink/external-adapter-framework/config'

export const config = new AdapterConfig({
API_KEY: {
description: 'An API key for Coinpaprika',
type: 'string',
required: true,
sensitive: true,
},
API_ENDPOINT: {
description: 'An API endpoint for Coinpaprika',
type: 'string',
default: 'https://chainlink-streaming.dexpaprika.com/stream',
},
BACKGROUND_EXECUTE_MS: {
description:
'The amount of time the background execute should sleep before performing the next request',
type: 'number',
default: 3_000,
},
REQUEST_TIMEOUT_MS: {
description: 'Timeout for HTTP requests to the provider in milliseconds',
type: 'number',
default: 60_000,
},
RECONNECT_DELAY_MS: {
description: 'Base delay for reconnection attempts in milliseconds',
type: 'number',
default: 5_000,
},
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {
PriceEndpoint,
priceEndpointInputParametersDefinition,
} from '@chainlink/external-adapter-framework/adapter'
import { SingleNumberResultResponse } from '@chainlink/external-adapter-framework/util'
import { InputParameters } from '@chainlink/external-adapter-framework/validation'
import { config } from '../config'
import { coinpaprikaSubscriptionTransport } from '../transport/coinpaprika-state'

export const inputParameters = new InputParameters(priceEndpointInputParametersDefinition, [
{
base: 'LUSD',
quote: 'USD',
},
])

export type BaseEndpointTypes = {
Parameters: typeof inputParameters.definition
Response: SingleNumberResultResponse
Settings: typeof config.settings
}

export const endpoint = new PriceEndpoint({
name: 'price',
aliases: ['coinpaprika-state', 'state'],
transport: coinpaprikaSubscriptionTransport,
inputParameters,
requestTransforms: [
(req) => {
req.requestContext.data.base = req.requestContext.data.base.toUpperCase()
req.requestContext.data.quote = req.requestContext.data.quote.toUpperCase()
return req
},
],
})
1 change: 1 addition & 0 deletions packages/sources/coinpaprika-state/src/endpoint/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { endpoint as coinpaprikaState } from './coinpaprika-state'
13 changes: 13 additions & 0 deletions packages/sources/coinpaprika-state/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { expose, ServerInstance } from '@chainlink/external-adapter-framework'
import { PriceAdapter } from '@chainlink/external-adapter-framework/adapter'
import { config } from './config'
import { coinpaprikaState } from './endpoint'

export const adapter = new PriceAdapter({
defaultEndpoint: coinpaprikaState.name,
name: 'COINPAPRIKA_STATE',
config,
endpoints: [coinpaprikaState],
})

export const server = (): Promise<ServerInstance | undefined> => expose(adapter)
Loading
Loading