Enabling Oracles

Overview

This document outlines the procedures for enabling a oracle feeding on a Minitia.

The Initia team developed a custom implementation of Slinky for L2 to use L1's oracle data feed. The high-level architecture involves relaying the oracle vote extension feed from L1 to L2 and using the IBC client state to verify this vote extension.

Tutorial

Step 1: Connect with Minitia

If you used minitia launch command, you can skip this step.

To enable the Slinky Oracle on your L2, you need to prepare an IBC client ID that is connected to the initial L1. See Hermes Relayer (IBC).

minitiad tx opchild set-bridge-info ${BRIDGE_ID} ${BRIDGE_ADDR} ${L1_CHAIN_ID} ${L1_CLIENT_ID} ${BRIDGE_CONFIG_PATH}

For example,

# `L1_CLIENT_ID` is `07-tendermint-0` in general
minitiad tx opchild set-bridge-info 44 init1raxlej4cyxhwd4mxstcycpj7lwpzmsyfjn29nhaycv3djr8gfv0qjyregt mahalo-3 07-tendermint-0 bridge-config-example.json
// bridge-config-example.json
{
        "challenger": "init1fhsl44zah6yw96ugf54nua2mxw4f3rz7dxx7ra",
        "proposer": "init1plcch8hdyc5pklaequpuzvdr053vfyjpupe6e8",
        "batch_info": {
          "submitter": "init1uhkwm573qp4vf9wmze8uxcwf8hx7f3ld9anfvm",
          "chain": "l1"
        },
        "submission_interval": "3600s",
        "finalization_period": "3600s",
        "submission_start_time": "2024-05-01T00:00:00.000Z",
        "metadata": null
}

Other than utilizing CLI, you can also use the OPinit bots. See Setting Up OPinit Bots.

Step 2: Add Currency Pairs

Although Minitias receive the oracle data through relayers, the currency_pair data still should be registered on a Minitia in order to use the oracle data from the Minitia.

minitiad tx opchild execute-messages ${MESASGE_PATH}

For example,

minitiad tx opchild execute-messages add-currency-example.json
// add-currency-example.json
{
    "messages": [{
        "@type": "/slinky.oracle.v1.MsgAddCurrencyPairs",
        "authority": "init1gz9n8jnu9fgqw7vem9ud67gqjk5q4m2w0aejne",
        "currency_pairs": [{
            "Base": "BTC",
            "Quote": "USD"
        }]
    }]
}

If the chain is yet to be created, the genesis setting is also available.

// genesis.json
... 
"oracle": {
    "currency_pair_genesis": [
        "currency_pair": {
            "Base": "BTC",
            "Quote": "USD"
        }
    ]
}
...

Step 3: Check Prices

minitiad q oracle price BITCOIN USDC

This command retrieves the latest price data for Bitcoin in USD, as fetched by the oracle.

Last updated

Logo

© 2024 Initia Foundation, All rights reserved.