Skip to content

Commit

Permalink
use yaml config file instead of json
Browse files Browse the repository at this point in the history
  • Loading branch information
Manh Cao committed Oct 4, 2024
1 parent 5423b6f commit 94582e7
Show file tree
Hide file tree
Showing 29 changed files with 544 additions and 676 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/combine-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jobs:
with:
node-version: '20' # Or your preferred version

- name: Install dependencies
run: npm install

- name: Merge JSON files
run: |
node merge-config.js
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/validate-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ jobs:
with:
node-version: '20' # Or your preferred version

- name: Install dependencies
run: npm install

- name: Validate JSON files
run: |
git fetch origin main
Expand Down
55 changes: 22 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This repository contains metadata for integrating external protocols, including

## Metadata Structure

The JSON file includes details for multiple objects (PT, YT, LP), each corresponding to different parts of the protocol with specific chain IDs, addresses, integration URLs, and descriptions.
The YAML file includes details for multiple objects (PT, YT, LP), each corresponding to different parts of the protocol with specific chain IDs, addresses, integration URLs, and descriptions.

### Fields

Expand All @@ -22,45 +22,34 @@ The JSON file includes details for multiple objects (PT, YT, LP), each correspon

### Example

```json
{
"name": "Protocol Name 2",
"icon": "logo.png",
"metadata": {
"pt": [
{
"chainId": 1,
"address": "0x332a8ee60edff0a11cf3994b1b846bbc27d3dcd6",
"integrationUrl": "https://www.pendle.magpiexyz.io/stake",
"description": "hello it's pt"
}
],
"yt": [
{
"chainId": 1,
"address": "0x1cae47aa3e10a77c55ee32f8623d6b5acc947344",
"integrationUrl": "https://www.pendle.magpiexyz.io/stake",
"description": "hello it's yt"
}
],
"lp": [
{
"chainId": 1,
"address": "0xcae62858db831272a03768f5844cbe1b40bb381f",
"integrationUrl": "https://www.pendle.magpiexyz.io/stake",
"description": "hello it's lp"
}
]
}
}
```yaml
name: Protocol Name 2
icon: logo.png
metadata:
pt:
- chainId: 1
address: '0x332a8ee60edff0a11cf3994b1b846bbc27d3dcd6'
integrationUrl: https://www.pendle.magpiexyz.io/stake
description: hello it's pt
yt:
- chainId: 1
address: '0x1cae47aa3e10a77c55ee32f8623d6b5acc947344'
integrationUrl: https://www.pendle.magpiexyz.io/stake
description: hello it's yt
lp:
- chainId: 1
address: '0xcae62858db831272a03768f5844cbe1b40bb381f'
integrationUrl: https://www.pendle.magpiexyz.io/stake
description: hello it's lp

```

## How to Contribute

To add a new protocol or update existing data:

1. Fork this repository.
2. Add or update the JSON file with the new protocol information in the specified format.
2. Add or update the YAML file with the new protocol information in the specified format.
3. Add a logo.png file to your protocol folder if there isn't any yet
4. Submit a pull request for review.

Expand Down
28 changes: 21 additions & 7 deletions merge-config.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,39 @@
const fs = require('fs');
const path = require('path');
const crypto = require('crypto');
const yaml = require("js-yaml");

async function run() {
const protocolsPath = path.join(__dirname, 'protocols');
const combinedConfigPath = path.join(__dirname, 'config.json');

const protocolIds = fs.readdirSync(protocolsPath, { withFileTypes: true })
.filter(dirent => dirent.isDirectory()) // Filter only directories
.filter(dirent => fs.existsSync(path.join(protocolsPath, dirent.name, 'config.json'))) // Check if config.json exists
.filter(dirent =>
fs.existsSync(path.join(protocolsPath, dirent.name, 'config.yaml')) ||
fs.existsSync(path.join(protocolsPath, dirent.name, 'config.json')))
.map(dirent => dirent.name);

const data = {protocols: []};

for (const protocolId of protocolIds) {
const configPath = path.join(protocolsPath, protocolId, 'config.json');
const protocolConfigStr = fs.readFileSync(configPath, 'utf8');
const protocolConfig = formatProtocolConfig({
id: protocolId,
...JSON.parse(protocolConfigStr)
})
let protocolConfig;

const yamlConfigPath = path.join(protocolsPath, protocolId, 'config.yaml');
if (fs.existsSync(yamlConfigPath)) {
const protocolConfigStr = fs.readFileSync(yamlConfigPath, 'utf8');
protocolConfig = formatProtocolConfig({
id: protocolId,
...yaml.load(protocolConfigStr)
})
} else {
let jsonConfigPath = path.join(protocolsPath, protocolId, 'config.json');
const protocolConfigStr = fs.readFileSync(jsonConfigPath, 'utf8');
protocolConfig = protocolConfig = formatProtocolConfig({
id: protocolId,
...JSON.parse(protocolConfigStr)
})
}

const {icon} = protocolConfig;

Expand Down
30 changes: 30 additions & 0 deletions package-lock.json

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

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"js-yaml": "^4.1.0"
}
}
130 changes: 0 additions & 130 deletions protocols/beefy/config.json

This file was deleted.

86 changes: 86 additions & 0 deletions protocols/beefy/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Beefy
icon: logo.png
metadata:
pt: []
yt: []
lp:
- chainId: 1
address: '0x36d3ca43ae7939645c306e26603ce16e39a89192'
integrationUrl: https://app.beefy.com/vault/pendle-ebtc-26dec24
description: LP yield optimization through Beefy
- chainId: 1
address: '0x6010676bc2534652ad1ef5fa8073dcf9ad7ebfbe'
integrationUrl: https://app.beefy.com/vault/pendle-ageth-26dec24
description: LP yield optimization through Beefy
- chainId: 1
address: '0x84a50177a84dad50fdbf665dfbfb39914b52dff2'
integrationUrl: https://app.beefy.com/vault/pendle-rseth-26dec24
description: LP yield optimization through Beefy
- chainId: 42161
address: '0x281fe15fd3e08a282f52d5cf09a4d13c3709e66d'
integrationUrl: https://app.beefy.com/vault/pendle-arb-usde-28nov24
description: LP yield optimization through Beefy
- chainId: 1
address: '0x40789e8536c668c6a249af61c81b9dfac3eb8f32'
integrationUrl: https://app.beefy.com/vault/pendle-weeths-26dec24
description: LP yield optimization through Beefy
- chainId: 1
address: '0x00b321d89a8c36b3929f20b7955080baed706d1b'
integrationUrl: https://app.beefy.com/vault/pendle-usd0-31oct24
description: LP yield optimization through Beefy
- chainId: 1
address: '0x038c1b03dab3b891afbca4371ec807edaa3e6eb6'
integrationUrl: https://app.beefy.com/vault/pendle-rsweth-26sep24
description: LP yield optimization through Beefy
- chainId: 1
address: '0xbae2df4dfcd0c613018d6056a40077f2d1eff28a'
integrationUrl: https://app.beefy.com/vault/pendle-unieth-26sep24
description: LP yield optimization through Beefy
- chainId: 42161
address: '0xa877a0e177b54a37066c1786f91a1dab68f094af'
integrationUrl: https://app.beefy.com/vault/pendle-arb-gusdc-26dec24
description: LP yield optimization through Beefy
- chainId: 42161
address: '0x279b44e48226d40ec389129061cb0b56c5c09e46'
integrationUrl: https://app.beefy.com/vault/pendle-arb-unieth-26dec24
description: LP yield optimization through Beefy
- chainId: 1
address: '0x905a5a4792a0c27a2adb2777f98c577d320079ef'
integrationUrl: https://app.beefy.com/vault/pendle-weethk-26sep24
description: LP yield optimization through Beefy
- chainId: 42161
address: '0xb4781463a1261f60fca37732efa510c22dec5ada'
integrationUrl: https://app.beefy.com/vault/equilibria-arb-seth-ezeth-26sep24
description: LP yield optimization through Beefy
- chainId: 42161
address: '0x5f3c781b3a20299db27c8fc5f4415d895677c885'
integrationUrl: https://app.beefy.com/vault/equilibria-arb-seth-eeth-26sep24
description: LP yield optimization through Beefy
- chainId: 42161
address: '0x2ad746fa3faa0ad586021a633d10f4e2785a0349'
integrationUrl: hhttps://app.beefy.com/vault/equilibria-arb-seth-rseth-26sep24
description: LP yield optimization through Beefy
- chainId: 42161
address: '0xf9f9779d8ff604732eba9ad345e6a27ef5c2a9d6'
integrationUrl: https://app.beefy.com/vault/pendle-arb-eeth-26sep24
description: LP yield optimization through Beefy
- chainId: 42161
address: '0xed99fc8bdb8e9e7b8240f62f69609a125a0fbf14'
integrationUrl: https://app.beefy.com/vault/pendle-arb-rseth-26sep24
description: LP yield optimization through Beefy
- chainId: 42161
address: '0x35f3db08a6e9cb4391348b0b404f493e7ae264c0'
integrationUrl: https://app.beefy.com/vault/pendle-arb-ezeth-26sep24
description: LP yield optimization through Beefy
- chainId: 42161
address: '0x2fb73d98b1d60b35fd12508933578098f352ce7e'
integrationUrl: https://app.beefy.com/vault/pendle-arb-dusdc-26sep24
description: LP yield optimization through Beefy
- chainId: 1
address: '0x386f90eb964a477498b528a39d9405e73ed4032b'
integrationUrl: https://app.beefy.com/vault/pendle-crvusd-26sep24
description: LP yield optimization through Beefy
- chainId: 1
address: '0xc374f7ec85f8c7de3207a10bb1978ba104bda3b2'
integrationUrl: https://app.beefy.com/vault/pendle-steth-25dec25
description: LP yield optimization through Beefy
Loading

0 comments on commit 94582e7

Please sign in to comment.