syntax = "proto3";
package provlabs.vault.v1;

import "gogoproto/gogo.proto";
import "provlabs/vault/v1/params.proto";
import "provlabs/vault/v1/vault.proto";

option go_package = "github.com/provlabs/vault/types";

// QueueEntry is a (time, addr) pair used by various vault timeout queues
// (e.g., payout deferral and fee collection).
message QueueEntry {
  // time is the UNIX timestamp (in seconds) when the entry becomes eligible.
  uint64 time = 1;
  // addr is the bech32 vault address associated with the entry.
  string addr = 2;
}

// PendingSwapOutQueueEntry represents a single pending swap-out request queued for later processing.
message PendingSwapOutQueueEntry {
  // time is the UNIX timestamp (in seconds) when this pending swap-out was enqueued or becomes eligible.
  int64 time = 1;
  // id is the unique identifier of the pending swap-out request.
  uint64 id = 2;
  // swap_out contains the pending swap-out details.
  PendingSwapOut swap_out = 3 [(gogoproto.nullable) = false];
}

// PendingSwapOutQueue holds the latest sequence number and all queued swap-out entries.
message PendingSwapOutQueue {
  // latest_sequence_number is the most recently assigned pending swap-out ID.
  uint64 latest_sequence_number = 1;
  // entries contains all currently queued pending swap-out entries.
  repeated PendingSwapOutQueueEntry entries = 2 [(gogoproto.nullable) = false];
}

// VaultNAVEntry pairs a vault address with one of its internal NAV records for
// genesis import and export.
message VaultNAVEntry {
  // vault_address is the bech32 address of the vault that owns this NAV record.
  string vault_address = 1;
  // nav is the internal NAV record held by the vault.
  VaultNAV nav = 2 [(gogoproto.nullable) = false];
}

// GenesisState defines the vault module's genesis state.
// NOTE: payout verification queue is not imported or exported.  It will always be empty after endblocker processes it.
message GenesisState {
  // vaults defines the vaults that exist at genesis.
  repeated VaultAccount vaults = 1 [(gogoproto.nullable) = false];

  // payout_timeout_queue contains (time, addr) entries for vaults that are
  // temporarily deferred from automatic payout/interest verification until the
  // given UNIX timestamp (seconds). These entries are re-enqueued on InitGenesis.
  repeated QueueEntry payout_timeout_queue = 2 [(gogoproto.nullable) = false];

  // pending_swap_out_queue contains entries for pending swap outs.
  PendingSwapOutQueue pending_swap_out_queue = 3 [(gogoproto.nullable) = false];

  // fee_timeout_queue contains (time, addr) entries for vaults that are
  // temporarily deferred from automatic AUM fee collection until the
  // given UNIX timestamp (seconds). These entries are re-enqueued on InitGenesis.
  repeated QueueEntry fee_timeout_queue = 4 [(gogoproto.nullable) = false];

  // params defines the module parameters.
  Params params = 5 [(gogoproto.nullable) = false];

  // navs contains the internal NAV table entries for all vaults at genesis.
  repeated VaultNAVEntry navs = 6 [(gogoproto.nullable) = false];
}
