From a4a03624da483f135453e523ef98394b7f80230e Mon Sep 17 00:00:00 2001 From: Subarna Singh Date: Thu, 26 Oct 2023 21:44:44 +0530 Subject: [PATCH] Feature/df 18875 cryptocompare inverse eth usd (#3049) * CryptoCompare inverse behaviour * changeset * e2e test modified * test renamed * undo test changes * undo test changes --- .changeset/nasty-students-perform.md | 5 +++++ .../sources/cryptocompare/src/config/includes.json | 13 +++++++++++++ .../sources/cryptocompare/src/endpoint/crypto.ts | 6 ++++++ packages/sources/cryptocompare/src/index.ts | 2 ++ 4 files changed, 26 insertions(+) create mode 100644 .changeset/nasty-students-perform.md create mode 100644 packages/sources/cryptocompare/src/config/includes.json diff --git a/.changeset/nasty-students-perform.md b/.changeset/nasty-students-perform.md new file mode 100644 index 0000000000..39dcf2121a --- /dev/null +++ b/.changeset/nasty-students-perform.md @@ -0,0 +1,5 @@ +--- +'@chainlink/cryptocompare-adapter': minor +--- + +inverse behaviour to support BTC/ETH pair diff --git a/packages/sources/cryptocompare/src/config/includes.json b/packages/sources/cryptocompare/src/config/includes.json new file mode 100644 index 0000000000..81d1f2b9ba --- /dev/null +++ b/packages/sources/cryptocompare/src/config/includes.json @@ -0,0 +1,13 @@ +[ + { + "from": "BTC", + "to": "ETH", + "includes": [ + { + "from": "ETH", + "to": "BTC", + "inverse": true + } + ] + } +] diff --git a/packages/sources/cryptocompare/src/endpoint/crypto.ts b/packages/sources/cryptocompare/src/endpoint/crypto.ts index 903155abb3..ab39e9cb26 100644 --- a/packages/sources/cryptocompare/src/endpoint/crypto.ts +++ b/packages/sources/cryptocompare/src/endpoint/crypto.ts @@ -14,6 +14,12 @@ export const endpoint = new CryptoPriceEndpoint({ customRouter: (_req, adapterConfig) => { return adapterConfig.WS_ENABLED ? 'ws' : 'rest' }, + requestTransforms: [ + (req) => { + req.requestContext.data.base = req.requestContext.data.base.toUpperCase() + req.requestContext.data.quote = req.requestContext.data.quote?.toUpperCase() + }, + ], inputParameters: cryptoInputParams, overrides: overrides.cryptocompare, }) diff --git a/packages/sources/cryptocompare/src/index.ts b/packages/sources/cryptocompare/src/index.ts index d0d64ce507..ea85b53c9b 100644 --- a/packages/sources/cryptocompare/src/index.ts +++ b/packages/sources/cryptocompare/src/index.ts @@ -2,12 +2,14 @@ import { expose, ServerInstance } from '@chainlink/external-adapter-framework' import { PriceAdapter } from '@chainlink/external-adapter-framework/adapter' import { crypto, vwap, volume, marketcap } from './endpoint' import { config } from './config' +import includes from './config/includes.json' export const adapter = new PriceAdapter({ name: 'CRYPTOCOMPARE', defaultEndpoint: 'crypto', config, endpoints: [crypto, vwap, volume, marketcap], + includes, rateLimiting: { tiers: { free: {