Skip to content

Commit

Permalink
Improve job spec examples
Browse files Browse the repository at this point in the history
  • Loading branch information
krebernisak committed Jan 11, 2022
1 parent 04850d8 commit 3c98348
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 13 deletions.
47 changes: 47 additions & 0 deletions examples/spec/ocr2-oracle-simple.spec.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
type = "offchainreporting2"
schemaVersion = 1
blockchainTimeout = "20s"
contractConfigConfirmations = 3
contractConfigTrackerPollInterval = "1m"
contractConfigTrackerSubscribeInterval = "2m"
name = "<insert job name here>"
relay = "solana"
contractID = "<insert solana ocr2 program ID>"
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:..."
nodeEndpointWS = "ws:..."
stateID = "<insert ocr2 state account>"
transmissionsID = "<insert ocr2 transmissions account>"
validatorProgramID = "<insert validator program id>"
64 changes: 51 additions & 13 deletions examples/spec/ocr2-oracle.spec.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,63 @@ 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]
Expand Down

0 comments on commit 3c98348

Please sign in to comment.