feeder: requests data from the price-server, signs it, and submits it on chain.
Price Server entry points
GET:/health: checks if the price server is up and reachable.
Response:
OK
GET:/latest: requests the latest prices for the configured tokens from different data sources. Returns the value of each token in USD. Additionally, it adds the timestamp when the response has been created.
GET:/alliance/rebalance: queries Terra's blockchain for information on where the Alliance Hub smart contract delegates its stake and checks if the validators are still compliant with the Alliance Hub validator rules. If any validators currently staked to are not compliant or if they have more stake than they should, this endpoint is in charge of rebalancing the stake between all the other eligible validators.
GET:/alliance/delegations: queries Terra's blockchain for information on the current set of validators and the amount of unstaked coins that the Alliance protocol has available. The endpoint applies the Alliance Hub's rules and creates an initial delegation message to stake the coins.
The Feeder CLI receives a single argument from the following list and performs the specified action.
Examples of how to use the feeder are available in the Makefile
(e.g. go run ./cmd/feeder/feeder.go alliance-initial-delegation).
alliance-initial-delegation: initiates a REST request to the GET:/alliance/delegations endpoint, signs the data, and submits it on chain to the Alliance Hub smart contract to perform the initial delegations.
alliance-oracle-feeder: initiates a REST request to the GET:/alliance/protocol endpoint, signs the data, and submits it on chain to the Alliance Oracle smart contract. This data provides the contract with information about the markets and available assets to be delegated.
alliance-rebalance-feeder: initiates a REST request to the endpoint GET:/alliance/rebalance, signs the data, and submits it on chain to the Alliance Hub smart contract. The stake is then rebalanced between the compliant validators according to the rules of Alliance Hub.
Define the following variables in the .env file. These variables can also be found in .env.example:
Note: Keep in mind that the mnemonic below must be the same as controller_addr and controller from the deployed smart contracts on chain.
# Port for the price server to listen
PRICE_SERVER_PORT=8532
# URL used to retreive the prices from
PRICE_SERVER_URL=http://localhost:8532
# Used by the feeder to derive the private key and signs the transactions
MNEMONIC=...
# Used for the feeder to submit the transactions on chain
NODE_GRPC_URL=pisco-grpc.terra.dev:443
# LCD URL used by the feeder to query the chain
TERRA_LCD_URL=https://pisco-lcd.terra.dev
# Address of the oracle contract where the alliance data is stored
ORACLE_ADDRESS=terra19cs0qcqpa5n7wlqjlhvfe235kc20g52enwr0d5cdar5zkmza7skqv54070
# Address of the alliance hub contract
ALLIANCE_HUB_CONTRACT_ADDRESS=terra1q95pe55eea0akft0xezak2s50l4vkkquve5emw7gzw65a7ptdl8qel50ea
# How many retries to do if the feeder fails to submit the transaction
FEEDER_RETRIES=4
# Chain ID where the oracle contract is deployed
CHAIN_ID=pisco-1
# Station API (https://station.terra.money/)
STATION_API=https://pisco-api.terra.dev
# Minimum amount of blocks to be considered as a rebalancing validator
BLOCKS_TO_BE_SENIOR_VALIDATOR=100000
# Minimum amount of votes for proposals to be a rebalancing validator
VOTE_ON_PROPOSALS_TO_BE_SENIOR_VALIDATOR=3
Use the price server start command:
$ make start-price-server
To feed the contracts with data, use the following commands:
$ make start-alliance-initial-delegation
$ make start-alliance-oracle-feeder
$ make start-alliance-rebalance-feeder
$ make start-alliance-update-rewards
$ make start-alliance-rebalance-emissions