syntax = "proto3";
package osmosis.gamm.v1beta1;

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

option go_package = "github.com/osmosis-labs/osmosis/v13/x/gamm/types";

service Msg {
  rpc JoinPool(MsgJoinPool) returns (MsgJoinPoolResponse);
  rpc ExitPool(MsgExitPool) returns (MsgExitPoolResponse);
  rpc SwapExactAmountIn(MsgSwapExactAmountIn)
      returns (MsgSwapExactAmountInResponse);
  rpc SwapExactAmountOut(MsgSwapExactAmountOut)
      returns (MsgSwapExactAmountOutResponse);
  rpc JoinSwapExternAmountIn(MsgJoinSwapExternAmountIn)
      returns (MsgJoinSwapExternAmountInResponse);
  rpc JoinSwapShareAmountOut(MsgJoinSwapShareAmountOut)
      returns (MsgJoinSwapShareAmountOutResponse);
  rpc ExitSwapExternAmountOut(MsgExitSwapExternAmountOut)
      returns (MsgExitSwapExternAmountOutResponse);
  rpc ExitSwapShareAmountIn(MsgExitSwapShareAmountIn)
      returns (MsgExitSwapShareAmountInResponse);
}

// ===================== MsgJoinPool
// This is really MsgJoinPoolNoSwap
message MsgJoinPool {
  option (amino.name) = "osmosis/gamm/join-pool";

  string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
  uint64 pool_id = 2 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ];
  string share_out_amount = 3 [
    (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
    (gogoproto.moretags) = "yaml:\"pool_amount_out\"",
    (gogoproto.nullable) = false
  ];
  repeated cosmos.base.v1beta1.Coin token_in_maxs = 4 [
    (gogoproto.moretags) = "yaml:\"token_in_max_amounts\"",
    (gogoproto.nullable) = false
  ];
}

message MsgJoinPoolResponse {
  string share_out_amount = 1 [
    (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
    (gogoproto.moretags) = "yaml:\"share_out_amount\"",
    (gogoproto.nullable) = false
  ];
  repeated cosmos.base.v1beta1.Coin token_in = 2 [
    (gogoproto.moretags) = "yaml:\"token_in\"",
    (gogoproto.nullable) = false
  ];
}

// ===================== MsgExitPool
message MsgExitPool {
  option (amino.name) = "osmosis/gamm/exit-pool";

  string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
  uint64 pool_id = 2 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ];
  string share_in_amount = 3 [
    (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
    (gogoproto.moretags) = "yaml:\"share_in_amount\"",
    (gogoproto.nullable) = false
  ];

  repeated cosmos.base.v1beta1.Coin token_out_mins = 4 [
    (gogoproto.moretags) = "yaml:\"token_out_min_amounts\"",
    (gogoproto.nullable) = false
  ];
}

message MsgExitPoolResponse {
  repeated cosmos.base.v1beta1.Coin token_out = 1 [
    (gogoproto.moretags) = "yaml:\"token_out\"",
    (gogoproto.nullable) = false
  ];
}

// ===================== MsgSwapExactAmountIn
message SwapAmountInRoute {
  uint64 pool_id = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ];
  string token_out_denom = 2
      [ (gogoproto.moretags) = "yaml:\"token_out_denom\"" ];
}

message MsgSwapExactAmountIn {
  option (amino.name) = "osmosis/gamm/swap-exact-amount-in";

  string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
  repeated SwapAmountInRoute routes = 2 [ (gogoproto.nullable) = false ];
  cosmos.base.v1beta1.Coin token_in = 3 [
    (gogoproto.moretags) = "yaml:\"token_in\"",
    (gogoproto.nullable) = false
  ];
  string token_out_min_amount = 4 [
    (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
    (gogoproto.moretags) = "yaml:\"token_out_min_amount\"",
    (gogoproto.nullable) = false
  ];
}

message MsgSwapExactAmountInResponse {
  string token_out_amount = 1 [
    (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
    (gogoproto.moretags) = "yaml:\"token_out_amount\"",
    (gogoproto.nullable) = false
  ];
}

// ===================== MsgSwapExactAmountOut
message SwapAmountOutRoute {
  uint64 pool_id = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ];
  string token_in_denom = 2
      [ (gogoproto.moretags) = "yaml:\"token_out_denom\"" ];
}

message MsgSwapExactAmountOut {
  option (amino.name) = "osmosis/gamm/swap-exact-amount-out";

  string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
  repeated SwapAmountOutRoute routes = 2 [ (gogoproto.nullable) = false ];
  string token_in_max_amount = 3 [
    (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
    (gogoproto.moretags) = "yaml:\"token_in_max_amount\"",
    (gogoproto.nullable) = false
  ];
  cosmos.base.v1beta1.Coin token_out = 4 [
    (gogoproto.moretags) = "yaml:\"token_out\"",
    (gogoproto.nullable) = false
  ];
}

message MsgSwapExactAmountOutResponse {
  string token_in_amount = 1 [
    (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
    (gogoproto.moretags) = "yaml:\"token_in_amount\"",
    (gogoproto.nullable) = false
  ];
}

// ===================== MsgJoinSwapExternAmountIn
// TODO: Rename to MsgJoinSwapExactAmountIn
message MsgJoinSwapExternAmountIn {
  option (amino.name) = "osmosis/gamm/join-swap-extern-amount-in";

  string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
  uint64 pool_id = 2 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ];
  cosmos.base.v1beta1.Coin token_in = 3 [
    (gogoproto.moretags) = "yaml:\"token_in\"",
    (gogoproto.nullable) = false
  ];
  string share_out_min_amount = 4 [
    (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
    (gogoproto.moretags) = "yaml:\"share_out_min_amount\"",
    (gogoproto.nullable) = false
  ];
  // repeated cosmos.base.v1beta1.Coin tokensIn = 5 [
  //   (gogoproto.moretags) = "yaml:\"tokens_in\"",
  //   (gogoproto.nullable) = false
  // ];
}

message MsgJoinSwapExternAmountInResponse {
  string share_out_amount = 1 [
    (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
    (gogoproto.moretags) = "yaml:\"share_out_amount\"",
    (gogoproto.nullable) = false
  ];
}

// ===================== MsgJoinSwapShareAmountOut
message MsgJoinSwapShareAmountOut {
  option (amino.name) = "osmosis/gamm/join-swap-share-amount-out";

  string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
  uint64 pool_id = 2 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ];
  string token_in_denom = 3
      [ (gogoproto.moretags) = "yaml:\"token_in_denom\"" ];
  string share_out_amount = 4 [
    (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
    (gogoproto.moretags) = "yaml:\"share_out_amount\"",
    (gogoproto.nullable) = false
  ];
  string token_in_max_amount = 5 [
    (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
    (gogoproto.moretags) = "yaml:\"token_in_max_amount\"",
    (gogoproto.nullable) = false
  ];
}

message MsgJoinSwapShareAmountOutResponse {
  string token_in_amount = 1 [
    (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
    (gogoproto.moretags) = "yaml:\"token_in_amount\"",
    (gogoproto.nullable) = false
  ];
}

// ===================== MsgExitSwapShareAmountIn
message MsgExitSwapShareAmountIn {
  option (amino.name) = "osmosis/gamm/exit-swap-share-amount-in";

  string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
  uint64 pool_id = 2 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ];
  string token_out_denom = 3
      [ (gogoproto.moretags) = "yaml:\"token_out_denom\"" ];
  string share_in_amount = 4 [
    (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
    (gogoproto.moretags) = "yaml:\"share_in_amount\"",
    (gogoproto.nullable) = false
  ];
  string token_out_min_amount = 5 [
    (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
    (gogoproto.moretags) = "yaml:\"token_out_min_amount\"",
    (gogoproto.nullable) = false
  ];
}

message MsgExitSwapShareAmountInResponse {
  string token_out_amount = 1 [
    (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
    (gogoproto.moretags) = "yaml:\"token_out_amount\"",
    (gogoproto.nullable) = false
  ];
}

// ===================== MsgExitSwapExternAmountOut
message MsgExitSwapExternAmountOut {
  option (amino.name) = "osmosis/gamm/exit-swap-extern-amount-out";

  string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
  uint64 pool_id = 2 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ];
  cosmos.base.v1beta1.Coin token_out = 3 [
    (gogoproto.moretags) = "yaml:\"token_out\"",
    (gogoproto.nullable) = false
  ];
  string share_in_max_amount = 4 [
    (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
    (gogoproto.moretags) = "yaml:\"share_in_max_amount\"",
    (gogoproto.nullable) = false
  ];
}

message MsgExitSwapExternAmountOutResponse {
  string share_in_amount = 1 [
    (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
    (gogoproto.moretags) = "yaml:\"share_in_amount\"",
    (gogoproto.nullable) = false
  ];
}
