Skip to content

Commit 742f19b

Browse files
committed
init
0 parents  commit 742f19b

22 files changed

+6764
-0
lines changed

.env.sample

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
COINBASE_KEY=
2+
COINBASE_SECRET=
3+
COINBASE_PASSPHRASE=
4+
5+
ARTIFIX_SECRET=
6+
INFURA_API_URL=
7+
8+
STACKS_API_URL=https://stacks-node-api.mainnet.stacks.co
9+
MAINNET=true

.gitignore

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
keychain.json
2+
extras
3+
4+
# Logs
5+
lib
6+
logs
7+
*.log
8+
npm-debug.log*
9+
yarn-debug.log*
10+
yarn-error.log*
11+
lerna-debug.log*
12+
13+
# Diagnostic reports (https://nodejs.org/api/report.html)
14+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
15+
16+
# Runtime data
17+
pids
18+
*.pid
19+
*.seed
20+
*.pid.lock
21+
22+
# Directory for instrumented libs generated by jscoverage/JSCover
23+
lib-cov
24+
25+
# Coverage directory used by tools like istanbul
26+
coverage
27+
*.lcov
28+
29+
# nyc test coverage
30+
.nyc_output
31+
32+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
33+
.grunt
34+
35+
# Bower dependency directory (https://bower.io/)
36+
bower_components
37+
38+
# node-waf configuration
39+
.lock-wscript
40+
41+
# Compiled binary addons (https://nodejs.org/api/addons.html)
42+
build/Release
43+
44+
# Dependency directories
45+
node_modules/
46+
jspm_packages/
47+
48+
# TypeScript v1 declaration files
49+
typings/
50+
51+
# TypeScript cache
52+
*.tsbuildinfo
53+
54+
# Optional npm cache directory
55+
.npm
56+
57+
# Optional eslint cache
58+
.eslintcache
59+
60+
# Optional REPL history
61+
.node_repl_history
62+
63+
# Output of 'npm pack'
64+
*.tgz
65+
66+
# Yarn Integrity file
67+
.yarn-integrity
68+
69+
# dotenv environment variables file
70+
.env
71+
.env.test
72+
73+
# parcel-bundler cache (https://parceljs.org/)
74+
.cache
75+
76+
# next.js build output
77+
.next
78+
79+
# nuxt.js build output
80+
.nuxt
81+
82+
# vuepress build output
83+
.vuepress/dist
84+
85+
# Serverless directories
86+
.serverless/
87+
88+
# FuseBox cache
89+
.fusebox/
90+
91+
# DynamoDB Local files
92+
.dynamodb/

LICENSE

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

README.md

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# stacks-open-oracle
2+
3+
## Introduction
4+
While waiting for a more distributed solution (Where are you Chainlink?), this provides authenticated feeds (i.e. only the entity with the private key that matches the public key can generate that feed, but you have to trust that entity). If enough other people also upload their feeds, then we can add a layer on top this to aggregate prices, and minimize some feeds misbehaving.
5+
6+
When calling addPrices, the contract will verify that the signature matches the public key for that source, so prices can be retrieved very quickly. Anyone can call addPrices, but the source and public key should verify, and the timestamp needs to be later than the existing value
7+
8+
9+
When a pair has one symbol, the price is against USD, otherwise, againt the second symbol (for example, Binance does not have USD pairs, only USDT or other stable coins)
10+
11+
12+
## Feeds
13+
14+
### Coinbase open oracle feed
15+
doc at: https://docs.pro.coinbase.com/#oracle, api key required, sadly
16+
pairs: BTC, ETH, LINK, COMP, UNI, SNX
17+
Eth address: 0xfCEAdAFab14d46e20144F48824d0C09B1a03F2BC
18+
Compressed public key usable in Clarity: 0x034170a2083dccbc2be253885a8d0e9f7ce859eb370d0c5cae3b6994af4cb9d666
19+
20+
### OKCoin open oracle feed
21+
A feed provided at https://www.okcoin.com/api/market/v3/oracle
22+
pairs: BTC, ETH
23+
Eth address: 0x419c555b739212684432050b7ce459ea8e7b8bda
24+
Compressed public key usable in Clarity: 0x0325df290b8c4930adcf8cd5c883616a1204ccc3d6ba3c4a636d6bcecd08e466d3
25+
26+
### ArtifiX OKCoin feed
27+
A feed pulled from OKCoin, and signed by one of my keys
28+
pairs: BTC, ETH, LINK, STX-BTC, STX, COMP, LTC, UNI
29+
Public key: 0x03743bf7b397e38eb2474f8a9554471c9394ef23cc8f927351f3a6d882cbbe7a12 (TODO(psq): change to deployment address)
30+
31+
### ArtifiX Binance feed
32+
A feed pulled from Binance, and signed by one of my keys
33+
pairs: ETH-BTC, LINK-BTC, LINK-ETH, STX-BTC, STX-USDT, COMP-BTC, LTC-BTC, UNI-BTC, AAVE-BTC, SUSHI-BTC
34+
Public key: 0x03743bf7b397e38eb2474f8a9554471c9394ef23cc8f927351f3a6d882cbbe7a12 (TODO(psq): change to deployment address)
35+
36+
## Retrieving prices
37+
Call `get-price`, for example:
38+
```
39+
(get-price "coinbase" "BTC")
40+
```
41+
42+
Add your own feed (ping @psq on discord and I can add your source public key), or you can fork this repo and deploy your own contract (make sure you change the owner key)
43+
44+
## Deployment
45+
The first version of the contract is deployed on main at SP...000.oracle-v1
46+
47+
Deploying this early so I can figure out what it takes to reliably upload prices, hopefully every blocks, and hopefully the transactions won't be too big for miners to process...
48+
49+
50+
## Credits
51+
Extra credits to @jcnelson for sharing an approach to manipulate buffers (https://gist.github.com/jcnelson/76c44b4209c29a19d2dbc06a0e7b446e)

balances.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[
2+
{
3+
"principal": "ST3J2GVMMM2R07ZFBJDWTYEYAR8FZH5WKDTFJ9AHA",
4+
"amount": 200000000000000
5+
},
6+
{
7+
"principal": "SP30JX68J79SMTTN0D2KXQAJBFVYY56BZJEYS3X0B",
8+
"amount": 200000000000000
9+
},
10+
{
11+
"principal": "SP1EHFWKXQEQD7TW9WWRGSGJFJ52XNGN6MTJ7X462",
12+
"amount": 100000000000000
13+
},
14+
{
15+
"principal": "SP2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKNRV9EJ7",
16+
"amount": 200000000000
17+
},
18+
{
19+
"principal": "S02J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKPVKG2CE",
20+
"amount": 100000000000
21+
},
22+
{
23+
"principal": "SZ2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKQ9H6DPR",
24+
"amount": 100000000000
25+
},
26+
{
27+
"principal": "ST3J2GVMMM2R07ZFBJDWTYEYAR8FZH5WKDTFJ9AHA.names",
28+
"amount": 2000
29+
}
30+
]

0 commit comments

Comments
 (0)