Oracle Setup

1- Download Slinky

cd $HOME
git clone https://github.com/skip-mev/slinky.git
cd slinky
git checkout v0.4.3
make build

2- Create Service

Edit --market-map-endpoint value to your node gRPC endpoint.

sudo tee /etc/systemd/system/initia-oracle.service > /dev/null <<EOF
[Unit]
Description=Initia Oracle
After=network.target

[Service]
User=$USER
Type=simple
ExecStart=$(which slinky) --oracle-config-path $HOME/slinky/config/core/oracle.json --market-map-endpoint 0.0.0.0:9090
Restart=on-failure
LimitNOFILE=65535

[Install]
WantedBy=multi-user.target
EOF

3- Validate Prices

cd $HOME/slinky && \
make run-oracle-client

If everything was configured correctly, the logs should look like this:

2024/06/15 14:13:37 Calling Prices RPC...
2024/06/15 14:13:37 Currency Pair, Price: (AAVE/USD, 8566150205)
2024/06/15 14:13:37 Currency Pair, Price: (ADA/USD, 4107134981)
2024/06/15 14:13:37 Currency Pair, Price: (AEVO/USD, 636502486)
2024/06/15 14:13:37 Currency Pair, Price: (AGIX/USD, 6323550769)
2024/06/15 14:13:37 Currency Pair, Price: (ALGO/USD, 1539588484)
2024/06/15 14:13:37 Currency Pair, Price: (APE/USD, 1065534544)
2024/06/15 14:13:37 Currency Pair, Price: (APT/USD, 7825113003)
2024/06/15 14:13:37 Currency Pair, Price: (ARB/USD, 927420800)
2024/06/15 14:13:37 Currency Pair, Price: (ARKM/USD, 1897814762)
2024/06/15 14:13:37 Currency Pair, Price: (ASTR/USD, 803000000)
2024/06/15 14:13:37 Currency Pair, Price: (ATOM/USD, 7139541161)
2024/06/15 14:13:37 Currency Pair, Price: (AVAX/USD, 3019114480)
2024/06/15 14:13:37 Currency Pair, Price: (AXL/USD, 769359831)
2024/06/15 14:13:37 Currency Pair, Price: (BCH/USD, 4296316832).....

4 - Enable Oracle Vote Extension

ORACLE_GRPC_ENDPOINT="0.0.0.0:8080"
ORACLE_CLIENT_TIMEOUT="500ms"
NODE_APP_CONFIG_PATH="$HOME/.initia/config/app.toml"

sed -i '/\[oracle\]/!b;n;c\
enabled = "true"' $NODE_APP_CONFIG_PATH

sed -i "/oracle_address =/c\oracle_address = \"$ORACLE_GRPC_ENDPOINT\"" $NODE_APP_CONFIG_PATH

sed -i "/client_timeout =/c\client_timeout = \"$ORACLE_CLIENT_TIMEOUT\"" $NODE_APP_CONFIG_PATH

sed -i '/metrics_enabled =/c\metrics_enabled = "false"' $NODE_APP_CONFIG_PATH

The configuration file located at $NODE_APP_CONFIG_PATH should have these fields:

###############################################################################
###                                  Oracle                                 ###
###############################################################################
[oracle]
# Enabled indicates whether the oracle is enabled.
enabled = "true"

# Oracle Address is the URL of the out-of-process oracle sidecar. This is used to
# connect to the oracle sidecar when the application boots up. Note that the address
# can be modified at any point, but will only take effect after the application is
# restarted. This can be the address of an oracle container running on the same
# machine or a remote machine.
oracle_address = "0.0.0.0:8080"

# Client Timeout is the time that the client is willing to wait for responses from 
# the oracle before timing out.
client_timeout = "500ms"

# MetricsEnabled determines whether oracle metrics are enabled. Specifically,
# this enables instrumentation of the oracle client and the interaction between
# the oracle and the app.
metrics_enabled = "false"

Last updated