syntax = "proto3";
package osmosis.incentives;

import "gogoproto/gogo.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";
import "cosmos/base/v1beta1/coin.proto";
import "osmosis/lockup/lock.proto";
import "osmosis/incentives/gauge.proto";

option go_package = "github.com/osmosis-labs/osmosis/v26/x/incentives/types";

// SplittingPolicy determines the way we want to split incentives in groupGauges
enum SplittingPolicy {
  option (gogoproto.goproto_enum_prefix) = false;

  ByVolume = 0;
}

// Note that while both InternalGaugeInfo and InternalGaugeRecord could
// technically be replaced by DistrInfo and DistrRecord from the pool-incentives
// module, we create separate types here to keep our abstractions clean and
// readable (pool-incentives distribution abstractions are used in a very
// specific way that does not directly relate to gauge logic). This also helps
// us sidestep a refactor to avoid an import cycle.
message InternalGaugeInfo {
  string total_weight = 1 [
    (gogoproto.customtype) = "cosmossdk.io/math.Int",
    (gogoproto.moretags) = "yaml:\"total_weight\"",
    (gogoproto.nullable) = false
  ];
  repeated InternalGaugeRecord gauge_records = 2
      [ (gogoproto.nullable) = false ];
}

message InternalGaugeRecord {
  option (gogoproto.equal) = true;

  uint64 gauge_id = 1 [ (gogoproto.moretags) = "yaml:\"gauge_id\"" ];
  // CurrentWeight is the current weight of this gauge being distributed to for
  // this epoch. For instance, for volume splitting policy, this stores the
  // volume generated in the last epoch of the linked pool.
  string current_weight = 2 [
    (gogoproto.customtype) = "cosmossdk.io/math.Int",
    (gogoproto.nullable) = false
  ];
  // CumulativeWeight serves as a snapshot of the accumulator being tracked
  // based on splitting policy. For instance, for volume splitting policy, this
  // stores the cumulative volume for the linked pool at time of last update.
  string cumulative_weight = 3 [
    (gogoproto.customtype) = "cosmossdk.io/math.Int",
    (gogoproto.nullable) = false
  ];
}

// Group is an object that stores a 1:1 mapped gauge ID, a list of pool gauge
// info, and a splitting policy. These are grouped into a single abstraction to
// allow for distribution of group incentives to internal gauges according to
// the specified splitting policy.
message Group {
  uint64 group_gauge_id = 1;
  InternalGaugeInfo internal_gauge_info = 2 [ (gogoproto.nullable) = false ];
  SplittingPolicy splitting_policy = 3;
}

// CreateGroup is called via governance to create a new group.
// It takes an array of pool IDs to split the incentives across.
message CreateGroup { repeated uint64 pool_ids = 1; }

// GroupsWithGauge is a helper struct that stores a group and its
// associated gauge.
message GroupsWithGauge {
  Group group = 1 [ (gogoproto.nullable) = false ];
  Gauge gauge = 2 [ (gogoproto.nullable) = false ];
}
