Skip to content

Commit 7ee54c9

Browse files
committed
Initial commit
0 parents  commit 7ee54c9

42 files changed

Lines changed: 6956 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# APIs
2+
COINGECKO_API_KEY_1=""
3+
COINGECKO_API_KEY_2=""
4+
CURRENCY_FREAKS_API_KEY=""

.github/workflows/ci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: "CI"
2+
3+
concurrency:
4+
cancel-in-progress: true
5+
group: ${{ github.ref }}
6+
7+
on:
8+
push:
9+
branches: ["main"]
10+
pull_request:
11+
workflow_dispatch:
12+
13+
jobs:
14+
ci:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Check out the repo
18+
uses: actions/checkout@v5
19+
20+
- name: Set up devkit
21+
uses: sablier-labs/devkit/actions/setup@main
22+
with:
23+
package-manager: bun
24+
25+
- uses: cargo-bins/cargo-binstall@main
26+
- run: cargo binstall --no-confirm qsv
27+
28+
- name: Run code checks
29+
run: |
30+
just full-check
31+
just tsv-check
32+
33+
- name: Add summary
34+
run: | #shell
35+
echo "## CI result" >> $GITHUB_STEP_SUMMARY
36+
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Directories
2+
.serena
3+
node_modules
4+
5+
# Files
6+
*.log
7+
*.tsbuildinfo
8+
.claude/settings.local.json
9+
.env
10+
.env.*
11+
!.env.example

.prettierrc.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const baseConfig = require("@sablier/devkit/prettier");
2+
3+
/**
4+
* @see https://prettier.io/docs/configuration
5+
* @type {import("prettier").Config}
6+
*/
7+
const config = baseConfig;
8+
9+
module.exports = config;

.vscode/settings.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"biome.enabled": true,
3+
"typescript.tsdk": "node_modules/typescript/lib",
4+
"editor.codeActionsOnSave": {
5+
"source.fixAll.biome": "explicit",
6+
"source.organizeImports.biome": "explicit"
7+
},
8+
"rainbow_csv.comment_prefix": "#",
9+
"[css][javascript][javascriptreact][json][jsonc][graphql][typescript][typescriptreact]": {
10+
"editor.defaultFormatter": "biomejs.biome"
11+
},
12+
"[md][yaml]": {
13+
"editor.defaultFormatter": "esbenp.prettier-vscode"
14+
}
15+
}

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Common Changelog](https://common-changelog.org/), and this project adheres to
6+
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
[1.0.0-beta.0]: https://github.com/sablier-labs/price-data/releases/tag/v1.0.0-beta.0
9+
10+
## [1.0.0-beta.0] - 2025-10-11
11+
12+
### Added
13+
14+
- Initial beta release with centralized price data repository
15+
- CLI tools for fetching cryptocurrency prices from CoinGecko
16+
- CLI tools for fetching forex rates from CurrencyFreaks
17+
- TSV data format with schema validation
18+
- Support for 10+ cryptocurrencies (ETH, BTC, USDC, USDT, DAI, WBTC, WETH, ARB, OP, STRK)
19+
- GBP/USD forex exchange rate data

CLAUDE.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Sablier Price Data
2+
3+
This document contains instructions for AI agents working on the Sablier Price Data repository.
4+
5+
## Context
6+
7+
This repo provides centralized cryptocurrency and forex exchange rate data used across Sablier projects. The data is
8+
stored in TSV format and sourced from [CoinGecko](https://coingecko.com/api) (crypto prices) and
9+
[CurrencyFreaks](https://currencyfreaks.com/) (forex rates).
10+
11+
## Development
12+
13+
**WORKFLOW**: After code changes → `just full-check``just full-write` (if errors) → fix remaining issues manually
14+
15+
**COMMON COMMANDS**:
16+
17+
- `just tsc-check` - TypeScript type checking only
18+
- `just tsv-check` - Validate TSV files against schema
19+
- `ni <package>` - Install dependency (`ni -D` for dev dependency)
20+
- `just fetch-crypto <currency>` - Fetch crypto prices from CoinGecko
21+
- `just fetch-forex` - Fetch GBP/USD rates from CurrencyFreaks
22+
23+
## TSV Format
24+
25+
**REQUIREMENT**: All data files use tab-separated values (TSV) format.
26+
27+
- **Date format**: ISO 8601 (`YYYY-MM-DD`) wrapped in double quotes
28+
- **Price format**: Decimal number (high precision), no quotes
29+
- **Structure**: `id` (date) and `output` (price) columns
30+
- **Validation**: Use `just tsv-check` to validate TSV files

LICENSE.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Sablier Labs Ltd
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6+
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8+
persons to whom the Software is furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11+
Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Sablier Price Data
2+
3+
Centralized repository for cryptocurrency and forex exchange rate data used across Sablier projects.
4+
5+
## Overview
6+
7+
This repository serves as a single source of truth for price data shared between multiple Sablier repositories:
8+
9+
- **Indexers** ([sablier-labs/indexers](https://github.com/sablier-labs/indexers)) - Real-time blockchain data indexing
10+
- **Accounting** ([sablier-labs/business](https://github.com/sablier-labs/business)) - Financial reporting and
11+
accounting
12+
13+
By centralizing the data here, we avoid duplication and ensure consistency across projects.
14+
15+
## Data Sources
16+
17+
All price data is sourced from industry-standard APIs:
18+
19+
- **Cryptocurrency Prices**: [CoinGecko API](https://www.coingecko.com/api) - Daily historical prices in USD
20+
- **Forex Exchange Rates**: [CurrencyFreaks API](https://currencyfreaks.com/) - Daily GBP/USD exchange rates
21+
22+
## Data Structure
23+
24+
Price data is organized in `data/crypto/` (cryptocurrency prices in USD) and `data/forex/` (foreign exchange rates).
25+
26+
### TSV Format
27+
28+
All files use tab-separated values (TSV) format with the following structure:
29+
30+
```tsv
31+
id output
32+
"2025-02-01" 3296.390634843652
33+
"2025-02-02" 3125.0386801320924
34+
```
35+
36+
We use this data structure to make it easier to use the files in our
37+
[Envio indexers](https://github.com/sablier-labs/indexers).
38+
39+
**Columns:**
40+
41+
- `id`: Date in ISO 8601 format (`YYYY-MM-DD`), wrapped in double quotes
42+
- `output`: USD price as a decimal number (high precision)
43+
44+
**Notes:**
45+
46+
- Dates are in UTC timezone
47+
- Dates are sorted chronologically
48+
- No duplicate dates within a file
49+
- Prices are daily closing prices (00:00 UTC)
50+
51+
## Installation
52+
53+
Install the package via npm:
54+
55+
```bash
56+
npm install @sablier/price-data
57+
```
58+
59+
Or using Bun:
60+
61+
```bash
62+
bun add @sablier/price-data
63+
```
64+
65+
## Usage
66+
67+
### Package Import
68+
69+
Once installed, you can access the TSV data files from `node_modules/@sablier/price-data/data/`:
70+
71+
```typescript
72+
import { readFileSync } from "node:fs";
73+
import { join } from "node:path";
74+
75+
// Read ETH prices
76+
const dataPath = join(process.cwd(), "node_modules", "@sablier/price-data", "data/crypto/ETH_USD.tsv");
77+
const ethPrices = readFileSync(dataPath, "utf-8");
78+
79+
// Parse TSV (skip header)
80+
const lines = ethPrices.split("\n").slice(1);
81+
const prices = lines.map((line) => {
82+
const [dateQuoted, price] = line.split("\t");
83+
return {
84+
date: dateQuoted.replace(/"/g, ""), // Remove quotes
85+
price: parseFloat(price),
86+
};
87+
});
88+
```
89+
90+
### Direct File Access
91+
92+
Alternatively, you can read the TSV files directly from this repository without installing the package.
93+
94+
**Example: curl:**
95+
96+
```bash
97+
curl -s https://raw.githubusercontent.com/sablier-labs/price-data/main/data/crypto/ETH_USD.tsv | head -n 10
98+
```
99+
100+
**Example (fetch with Node.js):**
101+
102+
```typescript
103+
const response = await fetch("https://raw.githubusercontent.com/sablier-labs/price-data/main/data/crypto/ETH_USD.tsv");
104+
const ethPrices = await response.text();
105+
106+
// Parse TSV (skip header)
107+
const lines = ethPrices.split("\n").slice(1);
108+
const prices = lines.map((line) => {
109+
const [dateQuoted, price] = line.split("\t");
110+
return {
111+
date: dateQuoted.replace(/"/g, ""), // Remove quotes
112+
price: parseFloat(price),
113+
};
114+
});
115+
```
116+
117+
### Git Submodule
118+
119+
For projects that need version-locked data, add this repository as a Git submodule:
120+
121+
```bash
122+
git submodule add https://github.com/sablier-labs/price-data.git
123+
```
124+
125+
## Updating Data
126+
127+
TODO

biome.jsonc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
3+
"extends": ["@sablier/devkit/biome"],
4+
"files": {
5+
"includes": ["**/*.{css,js,jsx,json,jsonc,ts,tsx}"]
6+
},
7+
"formatter": {
8+
"lineWidth": 100
9+
}
10+
}

0 commit comments

Comments
 (0)