clawchain/x/oracle/spec/04_messages.md
2026-05-15 19:18:10 +03:00

95 lines
4.9 KiB
Markdown

<!--
order: 4
-->
# Messages
## MsgExchangeRatePrevote (Deprecated)
`Hash` is a hex string generated by the leading 20 bytes of the SHA256 hash (hex string) of a string of the format `{salt}:{exchange_rate}:{denom}:{voter}`, the metadata of the actual `MsgExchangeRateVote` to follow in the next `VotePeriod`. You can use the `GetVoteHash()` function to help encode this hash. Note that since in the subsequent `MsgExchangeRateVote`, the salt will have to be revealed, the salt used must be regenerated for each prevote submission.
`Denom` is the denomination of the currency for which the vote is being cast. For example, if the voter wishes to submit a prevote for the usd, then the correct `Denom` is `uusd`.
The exchange rate used in the hash must be the open market exchange rate of Luna, with respect to the denomination matching `Denom`. For example, if `Denom` is `uusd` and the going exchange rate for Luna is 1 USD, then "1" must be used as the exchange rate, as `1 uluna = 1 uusd`.
`Feeder` (`terra-` address) is used if the validator wishes to delegate oracle vote signing to a separate key (who "feeds" the price in lieu of the operator) to de-risk exposing their validator signing key.
`Validator` is the validator address (`terravaloper-` address) of the original validator.
```go
// Deprecated: normal prevote and vote will be deprecated after columbus-4
// MsgExchangeRatePrevote - struct for prevoting on the ExchangeRateVote.
// The purpose of prevote is to hide vote exchange rate with hash
// which is formatted as hex string in SHA256("{salt}:{exchange_rate}:{denom}:{voter}")
type MsgExchangeRatePrevote struct {
Hash VoteHash
Denom string
Feeder sdk.AccAddress
Validator sdk.ValAddress
}
```
## MsgExchangeRateVote (Deprecated)
The `MsgExchangeRateVote` contains the actual exchange rate vote. The `Salt` parameter must match the salt used to create the prevote, otherwise the voter cannot be rewarded.
```go
// Deprecated: normal prevote and vote will be deprecated after columbus-4
// MsgExchangeRateVote - struct for voting on the exchange rate of Luna denominated in various Terra assets.
// For example, if the validator believes that the effective exchange rate of Luna in USD is 10.39, that's
// what the exchange rate field would be, and if 1213.34 for KRW, same.
type MsgExchangeRateVote struct {
ExchangeRate sdk.Dec // the effective rate of Luna in {Denom}
Salt string
Denom string
Feeder sdk.AccAddress
Validator sdk.ValAddress
}
```
## MsgDelegateFeedConsent
Validators may also elect to delegate voting rights to another key to prevent the block signing key from being kept online. To do so, they must submit a `MsgDelegateFeedConsent`, delegating their oracle voting rights to a `Delegate` that sign `MsgExchangeRatePrevote` and `MsgExchangeRateVote` on behalf of the validator.
> Delegate validators will likely require you to deposit some funds (in Terra or Luna) which they can use to pay fees, sent in a separate MsgSend. This agreement is made off-chain and not enforced by the Terra protocol.
The `Operator` field contains the operator address of the validator (prefixed `terravaloper-`). The `Delegate` field is the account address (prefixed `terra-`) of the delegate account that will be submitting exchange rate related votes and prevotes on behalf of the `Operator`.
```go
// MsgDelegateFeedConsent - struct for delegating oracle voting rights to another address.
type MsgDelegateFeedConsent struct {
Operator sdk.ValAddress
Delegate sdk.AccAddress
}
```
## MsgAggregateExchangeRatePrevote
`Hash` is a hex string generated by the leading 20 bytes of the SHA256 hash (hex string) of a string of the format `{salt}:{exchange rate}{denom},...,{exchange rate}{denom}:{voter}`, the metadata of the actual `MsgAggregateExchangeRateVote` to follow in the next `VotePeriod`. You can use the `GetAggregateVoteHash()` function to help encode this hash. Note that since in the subsequent `MsgAggregateExchangeRateVote`, the salt will have to be revealed, the salt used must be regenerated for each prevote submission.
```go
// MsgAggregateExchangeRatePrevote - struct for aggregate prevoting on the ExchangeRateVote.
// The purpose of aggregate prevote is to hide vote exchange rates with hash
// which is formatted as hex string in SHA256("{salt}:{exchange rate}{denom},...,{exchange rate}{denom}:{voter}")
type MsgAggregateExchangeRatePrevote struct {
Hash AggregateVoteHash
Feeder sdk.AccAddress
Validator sdk.ValAddress
}
```
## MsgAggregateExchangeRateVote
The `MsgAggregateExchangeRateVote` contains the actual exchange rates vote. The `Salt` parameter must match the salt used to create the prevote, otherwise the voter cannot be rewarded.
```go
// MsgAggregateExchangeRateVote - struct for voting on the exchange rates of Luna denominated in various Terra assets.
type MsgAggregateExchangeRateVote struct {
Salt string
ExchangeRates string
Feeder sdk.AccAddress
Validator sdk.ValAddress
}
```