Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve job spec examples #78

Merged
merged 2 commits into from
Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/spec/ocr2-bootstrap.spec.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ transmitterID = "<insert solana transmitter key id>"

[relayConfig]
nodeEndpointHTTP = "http:..."
ocr2ProgramID = "<insert ocr2 program id>"
transmissionsID = "<insert ocr2 transmissions account>"
storeProgramID = "<insert store program id>"
ocr2ProgramID = "<insert solana ocr2 program ID>"
transmissionsID = "<insert solana ocr2 transmissions account>"
storeProgramID = "<insert solana ocr2 store account>"
46 changes: 46 additions & 0 deletions examples/spec/ocr2-oracle-simple.spec.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
type = "offchainreporting2"
schemaVersion = 1
blockchainTimeout = "20s"
contractConfigConfirmations = 3
contractConfigTrackerPollInterval = "1m"
contractConfigTrackerSubscribeInterval = "2m"
name = "<insert job name here>"
relay = "solana"
contractID = "<insert solana ocr2 state account>"
p2pBootstrapPeers = ["somep2pkey@localhost-tcp:port"]
isBootstrapPeer = false
p2pPeerID = "<insert p2p id>"
ocrKeyBundleID = "<insert ocr2 key bundle id>"
monitoringEndpoint = "<insert monitoring endpoint>"
transmitterID = "<insert solana transmitter key id>"
observationSource = """
// data source 1
ds1 [type="bridge" name="bridge-coingecko" requestData="<{"data": {"from":"LINK","to":"USD"}}>"]
ds1_parse [type="jsonparse" path="result"]
ds1_multiply [type="multiply" times=100000000]
ds1 -> ds1_parse -> ds1_multiply
"""
juelsPerFeeCoinSource = """
// Fetch the LINK price from a data source
// data source 1
ds1_link [type="bridge" name="bridge-coingecko" requestData="<{"data": {"from":"LINK","to":"USD"}}>"]
ds1_link_parse [type="jsonparse" path="result"]
ds1_link -> ds1_link_parse -> divide

// Fetch the SOL price from a data source
// data source 1
ds1_coin [type="bridge" name="bridge-coingecko" requestData="<{"data": {"from":"SOL","to":"USD"}}."]
ds1_coin_parse [type="jsonparse" path="result"]
ds1_coin -> ds1_coin_parse -> divide

divide [type="divide" input="$(ds1_link_parse)" divisor="$(ds1_coin_parse)" precision="9"]
scale [type="multiply" times=1000000000]

divide -> scale
"""

[relayConfig]
nodeEndpointHTTP = "http:..."
ocr2ProgramID = "<insert solana ocr2 program ID>"
transmissionsID = "<insert solana ocr2 transmissions account>"
storeProgramID = "<insert solana ocr2 store account>"
70 changes: 54 additions & 16 deletions examples/spec/ocr2-oracle.spec.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,67 @@ ocrKeyBundleID = "<insert ocr2 key bundle id>"
monitoringEndpoint = "<insert monitoring endpoint>"
transmitterID = "<insert solana transmitter key id>"
observationSource = """
ea [type=bridge name=coingecko requestData=<{"data":{"from":"LINK", "to":"USD"}}>]
parse [type="jsonparse" path="result"]
multiply [type="multiply" times=100000000]

ea -> parse -> multiply
// data source 1
ds1 [type="bridge" name="bridge-tiingo" requestData="<{"data": {"from":"BTC","to":"USD"}}>"]
ds1_parse [type="jsonparse" path="result"]
ds1_multiply [type="multiply" times=100000000]
ds1 -> ds1_parse -> ds1_multiply -> answer
// data source 2
ds2 [type="bridge" name="bridge-nomics" requestData="<{"data": {"from":"BTC","to":"USD"}}>"]
ds2_parse [type="jsonparse" path="result"]
ds2_multiply [type="multiply" times=100000000]
ds2 -> ds2_parse -> ds2_multiply -> answer
// data source 3
ds3 [type="bridge" name="bridge-coinmarketcap" requestData="<{"data": {"from":"BTC","to":"USD"}}>"]
ds3_parse [type="jsonparse" path="result"]
ds3_multiply [type="multiply" times=100000000]
ds3 -> ds3_parse -> ds3_multiply -> answer
answer [type="median" index=0]
"""
juelsPerFeeCoinSource = """
link2usd [type=bridge name=coingecko requestData=<{"data":{"from":"LINK", "to":"USD"}}>]
parseL [type="jsonparse" path="result"]
// Fetch the LINK price from three data sources
// data source 1
ds1_link [type="bridge" name="bridge-tiingo" requestData="<{"data": {"from":"LINK","to":"USD"}}>"]
ds1_link_parse [type="jsonparse" path="result"]
ds1_link -> ds1_link_parse -> median_link
// data source 2
ds2_link [type="bridge" name="bridge-nomics" requestData="<{"data": {"from":"LINK","to":"USD"}}>"]
ds2_link_parse [type="jsonparse" path="result"]
ds2_link -> ds2_link_parse -> median_link
// data source 3
ds3_link [type="bridge" name="bridge-coinmarketcap" requestData="<{"data": {"from":"LINK","to":"USD"}}>"]
ds3_link_parse [type="jsonparse" path="result"]
ds3_link -> ds3_link_parse -> median_link

// Fetch the SOL price from three data sources
// data source 1
ds1_coin [type="bridge" name="bridge-tiingo" requestData="<{"data": {"from":"SOL","to":"USD"}}."]
ds1_coin_parse [type="jsonparse" path="result"]
ds1_coin -> ds1_coin_parse -> median_coin
// data source 2
ds2_coin [type="bridge" name="bridge-nomics" requestData="<{"data": {"from":"SOL","to":"USD"}}>"]
ds2_coin_parse [type="jsonparse" path="result"]
ds2_coin -> ds2_coin_parse -> median_coin
// data source 3
ds3_coin [type="bridge" name="bridge-coinmarketcap" requestData="<{"data": {"from":"SOL","to":"USD"}}>"]
ds3_coin_parse [type="jsonparse" path="result"]
ds3_coin -> ds3_coin_parse -> median_coin

sol2usd [type=bridge name=coingecko requestData=<{"data":{"from":"SOL", "to":"USD"}}>]
parseT [type="jsonparse" path="result"]
// Compute the medians from all data sources
median_link [type="median" values=<[ $(ds1_link_parse), $(ds2_link_parse), $(ds3_link_parse) ]> allowedFaults=1]
median_coin [type="median" values=<[ $(ds1_coin_parse), $(ds2_coin_parse), $(ds3_coin_parse) ]> allowedFaults=1]

divide [type="divide" input="$(parseL)" divisor="$(parseT)" precision="9"]
// Divide and scale appropriately
divide [type="divide" input="$(median_link)" divisor="$(median_coin)" precision="9"]
scale [type="multiply" times=1000000000]

link2usd -> parseL -> divide
sol2usd -> parseT -> divide
divide -> scale
median_link -> divide
median_coin -> divide
divide -> scale
"""

[relayConfig]
nodeEndpointHTTP = "http:..."
ocr2ProgramID = "<insert ocr2 program id>"
transmissionsID = "<insert ocr2 transmissions account>"
storeProgramID = "<insert store program id>"
ocr2ProgramID = "<insert solana ocr2 program ID>"
transmissionsID = "<insert solana ocr2 transmissions account>"
storeProgramID = "<insert solana ocr2 store account>"