proto/market/v1/msg.proto
2025-08-03 13:36:38 +03:30

195 lines
5.0 KiB
Protocol Buffer

syntax = "proto3";
package market.v1;
import "auth/v1/msg.proto";
import "wallet/v1/msg.proto";
enum MarketParticipantType {
MO_PT_UNKNOWN = 0;
MO_PT_MAKER = 1;
MO_PT_TAKER = 2;
}
enum MarketOrderSide {
MO_UNKNOWN = 0;
MO_BUY = 1;
MO_SELL = 2;
}
enum MarketOrderStatus {
MO_UNKNOWN_MP_STATUS = 0; // Unknown
MO_CREATED = 1; // Order is just created and awaits confirmation
MO_OPEN = 2; // Order is open and waiting to be completed
MO_CANCEL = 3; // Cancelled by user
MO_COMPLETED = 4; // Order is completed
MO_FAILED = 5; // Order is failed - bad trx , etc.
MO_REFUNDED = 6; // Order is refunded by platform to user due to regulation
// MO_EXPIRED = 7; // Order is expired
}
message CalcMarketReq {
optional auth.v1.InternalIAM iam = 1; // For whitelist :')
int64 asset_id = 2;
int64 counter_asset_id = 3;
double amount = 4;
double unit_price = 5;
MarketParticipantType participant_type = 6;
optional wallet.v1.BuyAssetSide req_side =
7; // For Calculation : can be from asset or irt
}
message CalcMarketRes {
double calculated_irt_amount = 1;
double calculated_asset_amount = 2;
wallet.v1.EffectiveCommission commission = 3;
MarketParticipantType participant_type = 4;
wallet.v1.BuyAssetSide req_side =
5; // For Calculation : can be from asset or irt
}
message MPHistoryFilter {}
message MPListFilter {}
message MarketOrder {
uint64 id = 1;
uint64 trx_id = 2;
wallet.v1.Asset asset = 3;
wallet.v1.Asset counter_asset = 4;
double amount = 5;
double unit_price = 6;
double total_price = 7;
MarketOrderSide side = 8;
MarketOrderStatus status = 9;
int64 from = 10;
MarketParticipantType participant_type = 11;
auth.v1.UserIdentityBasic from_identity = 12;
wallet.v1.Commission commission = 13;
double completed_amount = 14;
double available_amount = 15;
string created_at = 16;
string updated_at = 17;
bool is_public = 18;
wallet.v1.TransactionList trx = 19;
repeated string tags = 20;
repeated string comment = 21;
optional MarketOrder source = 22; // purchase is done via this field
// repeated string attachments = 14; // possible files included by
// seller/buyer
}
message MarketAssetListReq {
optional auth.v1.InternalIAM iam =
1; // If not set, will returns only public orders which are limited by a
optional uint32 page_no = 2;
optional uint32 page_size = 3;
}
message MarketAssetList {
repeated wallet.v1.Asset list = 1;
uint32 page_no = 2;
uint32 page_size = 3;
uint32 total_count = 4;
}
message PurchaseReq {
auth.v1.InternalIAM iam = 1;
uint64 order_id = 2;
double amount = 3;
wallet.v1.BuyAssetSide req_side =
7; // For Calculation : can be from asset or irt
optional bool accepted_contract = 4;
optional auth.v1.TFA tfa = 5;
}
message PurchaseRes {
uint64 order_id = 1;
double calculated_irt_amount = 2;
double calculated_asset_amount = 3;
wallet.v1.EffectiveCommission commission = 4;
MarketOrderStatus status = 5;
}
message MarketOrderList {
repeated MarketOrder list = 1;
uint32 page_no = 2;
uint32 page_size = 3;
uint32 total_count = 4;
}
message NewMarketReq {
auth.v1.InternalIAM iam = 1;
int64 asset_id = 2;
int64 counter_asset_id = 3;
double amount = 4;
double unit_price = 5;
// TODO: Change name
MarketParticipantType participant_type = 6;
// For Calculation : can be from asset or irt
wallet.v1.BuyAssetSide req_side = 7;
MarketOrderSide side = 8;
// TODO: maker market order as optional
}
enum MarketOrdersSortBy {
MO_SORT_UNKNOWN = 0;
MO_CREATED_AT_ASC = 1;
MO_CREATED_AT_DESC = 2;
MO_UNIT_PRICE_ASC = 3;
MO_UNIT_PRICE_DESC = 4;
MO_TOTAL_PRICE_ASC = 5;
MO_TOTAL_PRICE_DESC = 6;
MO_AVAILABLE_AMOUNT_ASC = 7;
MO_AVAILABLE_AMOUNT_DESC = 8;
}
message OrderListFilter {
optional auth.v1.InternalIAM iam = 1;
optional string search = 3;
optional MarketOrderSide side = 4;
repeated MarketOrderStatus status = 5;
repeated string from = 6;
repeated string to = 7;
optional double starting_price = 8;
optional double ending_price = 9;
repeated uint64 asset = 10;
optional uint64 order_id = 11;
optional uint64 trx_id = 12;
optional bool is_public = 13;
optional MarketParticipantType participant_type = 14;
optional uint64 maker_order_id = 15;
optional string from_date = 16;
optional string to_date = 17;
optional MarketOrdersSortBy sort_by = 18;
optional uint32 page_no = 19;
optional uint32 page_size = 20;
}
/* Contract */
message ContractMarketRes {
string link = 1;
uint64 asset_id = 2;
uint64 agreement_id = 3;
uint64 transaction_id = 4;
string contract_hash = 5;
string contract_content = 6;
}
message DeclineMarketContractReq {
auth.v1.InternalIAM iam = 1;
uint64 agreement_id = 2;
}
message ConfirmMarketContractReq {
auth.v1.InternalIAM iam = 1;
uint64 agreement_id = 2;
optional auth.v1.TFA tfa = 3;
}
message MarketContractReq {
auth.v1.InternalIAM iam = 1;
// uint64 asset_id = 2;
uint64 order_id = 2; // Maker OrderID
// double amount = 4;
// wallet.v1.BuyAssetSide req_side = 5;
}