Skip to content

Commit 5e5f86a

Browse files
Add EA for Asseto Finance (#4046)
* add ea for asseto finance * fix vulnerable npm axios package * remove override file from config * Apply suggestion from @mmcallister-cll Co-authored-by: mmcallister-cll <139181225+mmcallister-cll@users.noreply.github.com> * Apply suggestion from @mmcallister-cll Co-authored-by: mmcallister-cll <139181225+mmcallister-cll@users.noreply.github.com> * remove unsued file and update test * refactor api endpoints in helpers * add helper tests * remove axios dependency * refactor transport and endppint functions * add more tests for edge cases * Update .changeset/rich-fishes-travel.md * refactor tests and comments * remove changes to contributing.md * escape ripcord detail strings in snapshot --------- Co-authored-by: mmcallister-cll <139181225+mmcallister-cll@users.noreply.github.com> Co-authored-by: Matthew McAllister <matthew.mcallister@smartcontract.com>
1 parent 18df82f commit 5e5f86a

31 files changed

+1437
-0
lines changed

.changeset/rich-fishes-travel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@chainlink/asseto-finance-adapter': major
3+
---
4+
5+
asseto-finance initial release

.pnp.cjs

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

packages/sources/asseto-finance/CHANGELOG.md

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Chainlink External Adapter for asseto-finance
2+
3+
This README will be generated automatically when code is merged to `main`. If you would like to generate a preview of the README, please run `yarn generate:readme asseto-finance`.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "@chainlink/asseto-finance-adapter",
3+
"version": "0.0.0",
4+
"description": "Chainlink asseto-finance adapter.",
5+
"keywords": [
6+
"Chainlink",
7+
"LINK",
8+
"blockchain",
9+
"oracle",
10+
"asseto-finance"
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+
"@types/jest": "^29.5.14",
32+
"@types/node": "22.14.1",
33+
"nock": "13.5.6",
34+
"typescript": "5.8.3"
35+
},
36+
"dependencies": {
37+
"@chainlink/external-adapter-framework": "2.7.0",
38+
"tslib": "2.4.1"
39+
}
40+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { AdapterConfig } from '@chainlink/external-adapter-framework/config'
2+
3+
export const config = new AdapterConfig({
4+
API_ENDPOINT: {
5+
description: 'An API endpoint for Data Provider',
6+
type: 'string',
7+
default: 'https://open.syncnav.com/api',
8+
},
9+
CLIENT_ID: {
10+
description: 'Data Provider client ID',
11+
type: 'string',
12+
default: 'chainlink',
13+
},
14+
CLIENT_SECRET: {
15+
description: 'Data Provider client secret',
16+
type: 'string',
17+
required: true,
18+
sensitive: true,
19+
},
20+
GRANT_TYPE: {
21+
description: 'Grant type for credentials',
22+
type: 'string',
23+
default: 'client_credentials',
24+
},
25+
BACKGROUND_EXECUTE_MS: {
26+
description:
27+
'The amount of time the background execute should sleep before performing the next request',
28+
type: 'number',
29+
default: 10_000,
30+
},
31+
})
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { InputParameters } from '@chainlink/external-adapter-framework/validation'
2+
3+
export const inputParameters = new InputParameters(
4+
{
5+
fundId: {
6+
required: true,
7+
type: 'number',
8+
description: 'The fund id of the reserves to query',
9+
},
10+
},
11+
[
12+
{
13+
fundId: 3,
14+
},
15+
],
16+
)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { endpoint as nav } from './nav'
2+
export { endpoint as reserve } from './reserve'
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { AdapterEndpoint } from '@chainlink/external-adapter-framework/adapter'
2+
import { config } from '../config'
3+
import { navTransport } from '../transport/nav'
4+
import { inputParameters } from './common'
5+
6+
export type NavResultResponse = {
7+
Result: number
8+
Data: {
9+
fundId: number
10+
fundName: string
11+
netAssetValue: number
12+
navDate: string
13+
}
14+
}
15+
16+
export type BaseEndpointTypes = {
17+
Parameters: typeof inputParameters.definition
18+
Response: NavResultResponse
19+
Settings: typeof config.settings
20+
}
21+
22+
export const endpoint = new AdapterEndpoint({
23+
name: 'nav',
24+
inputParameters,
25+
transport: navTransport,
26+
})
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { AdapterEndpoint } from '@chainlink/external-adapter-framework/adapter'
2+
import { config } from '../config'
3+
import { reserveTransport } from '../transport/reserve'
4+
import { inputParameters } from './common'
5+
6+
export type ReserveResultResponse = {
7+
Result: number
8+
Data: {
9+
fundId: number
10+
fundName: string
11+
totalAUM: number
12+
totalDate: string
13+
ripcord: string
14+
}
15+
}
16+
17+
export type ReserveResultErrorResponse = ReserveResultResponse & {
18+
Data: {
19+
errorMessage: string
20+
ripcordDetails?: string
21+
}
22+
}
23+
24+
export type BaseEndpointTypes = {
25+
Parameters: typeof inputParameters.definition
26+
Response: ReserveResultResponse | ReserveResultErrorResponse
27+
Settings: typeof config.settings
28+
}
29+
30+
export const endpoint = new AdapterEndpoint({
31+
name: 'reserve',
32+
transport: reserveTransport,
33+
inputParameters,
34+
})

0 commit comments

Comments
 (0)