#!/usr/bin/env bash
set -ex

# shellcheck source=/dev/null
. load-addresses

type=$(jq -r ".tokens.${1} | .pip | .type" "./out/config.json")
if [ "${type}" = "value" ]; then
    # Set DSValue price
    eval seth send "\$VAL_${1} 'poke(bytes32)' $(seth --to-uint256 "$(seth --to-wei "$2" ETH)")"
fi

if [ "$(eval echo "\$PIP_${1}")" != "$(eval echo "\$VAL_${1}")" ]; then
    # Poke OSM
    seth send "$(eval echo "\$PIP_${1}")" 'poke()'
fi
