syntax = "proto3";
package osmosis.lockup;

import "gogoproto/gogo.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";
import "cosmos/base/v1beta1/coin.proto";

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

// PeriodLock is a single lock unit by period defined by the x/lockup module.
// It's a record of a locked coin at a specific time. It stores owner, duration,
// unlock time and the number of coins locked. A state of a period lock is
// created upon lock creation, and deleted once the lock has been matured after
// the `duration` has passed since unbonding started.
message PeriodLock {
  // ID is the unique id of the lock.
  // The ID of the lock is decided upon lock creation, incrementing by 1 for
  // every lock.
  uint64 ID = 1;
  // Owner is the account address of the lock owner.
  // Only the owner can modify the state of the lock.
  string owner = 2 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
  // Duration is the time needed for a lock to mature after unlocking has
  // started.
  google.protobuf.Duration duration = 3 [
    (gogoproto.nullable) = false,
    (gogoproto.stdduration) = true,
    (gogoproto.jsontag) = "duration,omitempty",
    (gogoproto.moretags) = "yaml:\"duration\""
  ];
  // EndTime refers to the time at which the lock would mature and get deleted.
  // This value is first initialized when an unlock has started for the lock,
  // end time being block time + duration.
  google.protobuf.Timestamp end_time = 4 [
    (gogoproto.stdtime) = true,
    (gogoproto.nullable) = false,
    (gogoproto.moretags) = "yaml:\"end_time\""
  ];
  // Coins are the tokens locked within the lock, kept in the module account.
  repeated cosmos.base.v1beta1.Coin coins = 5 [
    (gogoproto.nullable) = false,
    (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
  ];
  // Reward Receiver Address is the address that would be receiving rewards for
  // the incentives for the lock. This is set to owner by default and can be
  // changed via separate msg.
  string reward_receiver_address = 6
      [ (gogoproto.moretags) = "yaml:\"reward_receiver_address\"" ];
}

// LockQueryType defines the type of the lock query that can
// either be by duration or start time of the lock.
enum LockQueryType {
  option (gogoproto.goproto_enum_prefix) = false;

  ByDuration = 0;
  ByTime = 1;
  NoLock = 2;
  ByGroup = 3;
}

// QueryCondition is a struct used for querying locks upon different conditions.
// Duration field and timestamp fields could be optional, depending on the
// LockQueryType.
message QueryCondition {
  // LockQueryType is a type of lock query, ByLockDuration | ByLockTime
  LockQueryType lock_query_type = 1;
  // Denom represents the token denomination we are looking to lock up
  string denom = 2;
  // Duration is used to query locks with longer duration than the specified
  // duration. Duration field must not be nil when the lock query type is
  // `ByLockDuration`.
  google.protobuf.Duration duration = 3 [
    (gogoproto.stdduration) = true,
    (gogoproto.nullable) = false,
    (gogoproto.moretags) = "yaml:\"duration\""
  ];
  // Timestamp is used by locks started before the specified duration.
  // Timestamp field must not be nil when the lock query type is `ByLockTime`.
  // Querying locks with timestamp is currently not implemented.
  google.protobuf.Timestamp timestamp = 4 [
    (gogoproto.stdtime) = true,
    (gogoproto.nullable) = false,
    (gogoproto.moretags) = "yaml:\"timestamp\""
  ];
}

// SyntheticLock is creating virtual lockup where new denom is combination of
// original denom and synthetic suffix. At the time of synthetic lockup creation
// and deletion, accumulation store is also being updated and on querier side,
// they can query as freely as native lockup.
message SyntheticLock {
  // Underlying Lock ID is the underlying native lock's id for this synthetic
  // lockup. A synthetic lock MUST have an underlying lock.
  uint64 underlying_lock_id = 1;
  // SynthDenom is the synthetic denom that is a combination of
  // gamm share + bonding status + validator address.
  string synth_denom = 2;
  // used for unbonding synthetic lockups, for active synthetic lockups, this
  // value is set to uninitialized value
  google.protobuf.Timestamp end_time = 3 [
    (gogoproto.stdtime) = true,
    (gogoproto.nullable) = false,
    (gogoproto.moretags) = "yaml:\"end_time\""
  ];
  // Duration is the duration for a synthetic lock to mature
  // at the point of unbonding has started.
  google.protobuf.Duration duration = 4 [
    (gogoproto.nullable) = false,
    (gogoproto.stdduration) = true,
    (gogoproto.jsontag) = "duration,omitempty",
    (gogoproto.moretags) = "yaml:\"duration\""
  ];
}
