syntax = "proto3";
package provenance.flatfees.v1;

option go_package          = "github.com/provenance-io/provenance/x/flatfees/types";
option java_package        = "io.provenance.flatfees.v1";
option java_multiple_files = true;

import "amino/amino.proto";
import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";

// Params defines the set of params for the flatfees module.
message Params {
  option (gogoproto.equal) = false;

  // default_cost is the amount a msg costs when there is no specific msg-fee defined for it.
  // The denom used here should be the same as used to define the specific msg costs.
  // The recommended denom is musd.
  cosmos.base.v1beta1.Coin default_cost = 1 [(gogoproto.nullable) = false];
  // conversion_factor is the ratio used to convert the msg-fees from their defined amounts into the fee denomination.
  // The definition_amount should have the same denom as the default cost.
  // The denom of the converted amount should be the denom that fees are paid in, e.g. nhash.
  ConversionFactor conversion_factor = 3 [(gogoproto.nullable) = false];

  // oracle_addresses is the list of addresses allowed to update the conversion factor without governance.
  repeated string oracle_addresses = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// ConversionFactor equates the values of two coins in different denominations.
// It is used to determine how much of the fee denomination is due.
// actual cost = defined cost * converted_amount / definition_amount (truncated to an integer).
message ConversionFactor {
  option (gogoproto.goproto_stringer) = false;

  // definition_amount is an amount (in the denomination used to define fees) that is equal to the converted_amount.
  // This cannot have an amount of zero.
  // If this has the same denomination as the converted_amount, then the amounts must also be equal.
  // The denom of this field should be the same as the default cost, e.g. musd.
  cosmos.base.v1beta1.Coin definition_amount = 1 [(gogoproto.nullable) = false];
  // converted_amount is an amount in the fee denomination equal to the definition_amount.
  // If this is zero, all msgs will be free.
  // If this has the same denomination as the definition_amount, then the amounts must also be equal.
  // The denom of this field should be the fee denom, e.g. nhash.
  cosmos.base.v1beta1.Coin converted_amount = 2 [(gogoproto.nullable) = false];
}

// MsgFee defines the cost to use a specific message type.
message MsgFee {
  option (gogoproto.goproto_stringer) = false;

  // msg_type_url is the type-url of the message, e.g. "/cosmos.bank.v1beta1.MsgSend".
  string msg_type_url = 1;
  // cost is the Tx fee required for this msg_type_url.
  // It should have the same denomination as the default cost and as the conversion factor's
  // definition_amount, e.g. musdc. Any other denomination will be charged as defined.
  repeated cosmos.base.v1beta1.Coin cost = 2 [
    (gogoproto.nullable)     = false,
    (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
    (amino.dont_omitempty)   = true,
    (amino.encoding)         = "legacy_coins"
  ];
}
