syntax = "proto3";

package exchain.nebula.v1;

import "google/protobuf/descriptor.proto";
import "nebula/ext/options.proto";
import "nebula/v1/coin.proto";
import "nebula/v1/order.proto";
import "nebula/v1/pair.proto";

option csharp_namespace = "ExChain.Nebula.V1";
option go_package = "github.com/exchain/go-exchain/exchain/protocol/nebula/v1";
option java_multiple_files = true;
option java_outer_classname = "TransactionProto";
option java_package = "org.exchain.nebula.v1";
option php_namespace = "ExChain\\Nebula\\v1";

enum TxType {
  SignProxyTx = 0;
  DepositTx = 1;
  WithdrawTx = 2;
  CreatePairTx = 3;
  DisablePairTx = 4;
  LimitTx = 5;
  MarketTx = 6;
  CancelTx = 7;
}

message Signature {
  bytes r = 1;
  bytes s = 2;
  bytes v = 3;
}

message Transaction {
  string user = 1;
  bytes nonce = 2;
  TxType tx_type = 3;
  bool proxy = 4;
  oneof tx {
    SignProxyTransaction sign_proxy_tx = 5;
    DepositTransaction deposit_tx = 6;
    WithdrawTransaction withdraw_tx = 7;
    CreatePairTransaction create_pair_tx = 8;
    DisablePairTransaction disable_pair_tx = 9;
    LimitOrderTransaction limit_tx = 10;
    MarketOrderTransaction market_tx = 11;
    CancelOrderTransaction cancel_tx = 12;
  }
  Signature signature = 13;
}

message SignProxyTransaction {
  bytes signer_proxy = 1;
}

message DepositTransaction {
  bytes source_hash = 1; // layer1 tx hash.
  bytes user = 2;
  bytes coin = 3;
  bytes amount = 4;
}

message WithdrawTransaction {
  bytes user = 1;
  string coin = 2;
  bytes amount = 3;
}

message CreatePairTransaction {
  Coin base_coin = 1;
  Coin quote_coin = 2;
  PairParam pair_info = 3;
}

message DisablePairTransaction {
  string pair_name = 1;
}

message LimitOrderTransaction {
  string pair = 1;
  OrderSide side = 2;
  bytes price = 3;
  bytes quantity = 4;
}

message MarketOrderTransaction {
  string pair = 1;
  OrderSide side = 2;
  bytes quantity = 3;
}

message CancelOrderTransaction {
  string order_id = 1;
}
