v2: code formate + market support for calculation amount ( from taker/maker + seller/buyer )

Signed-off-by: nfel <nfilsaraee@gmail.com>
This commit is contained in:
nfel 2025-06-03 13:48:45 +03:30
parent 930441f7eb
commit 132e5d787b
Signed by: nfel
GPG Key ID: DCC0BF3F92B0D45F
5 changed files with 105 additions and 46 deletions

View File

@ -31,6 +31,7 @@ enum ErrCode {
INVALID_ARGUMENT_RRN = 2009; INVALID_ARGUMENT_RRN = 2009;
INVALID_ARGUMENT_MOBILE_NUMBER = 2010; INVALID_ARGUMENT_MOBILE_NUMBER = 2010;
INVALID_ARGUMENT_IBAN_NUMBER = 2011; INVALID_ARGUMENT_IBAN_NUMBER = 2011;
INVALID_ARGUMENT_UNKNOWN_TYPE = 2012;
// Resource errors // Resource errors
NOT_FOUND = 3000; NOT_FOUND = 3000;

View File

@ -6,6 +6,47 @@ import "auth/v1/msg.proto";
import "base/v1/msg.proto"; import "base/v1/msg.proto";
import "wallet/v1/msg.proto"; import "wallet/v1/msg.proto";
enum MarketParticipantType {
MO_PT_UNKOWN = 0;
MO_PT_MAKER = 1;
MO_PT_TAKER = 2;
}
enum MarketOrderSide {
MO_UNKOWN = 0;
MO_BUY = 1;
MO_SELL = 2;
}
enum MarketOrderStatus {
MO_UNKOWN_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 type = 6;
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 type = 4;
wallet.v1.BuyAssetSide req_side = 5; // For Calculation : can be from asset or irt
}
message MPHistoryFilter {} message MPHistoryFilter {}
message MPListFilter {} message MPListFilter {}
message MarketOrder { message MarketOrder {
@ -29,12 +70,14 @@ message MarketOrder {
repeated string tags = 18; repeated string tags = 18;
repeated string comment = 19; repeated string comment = 19;
optional MarketOrder source = 20; // purchase is done via this field optional MarketOrder source = 20; // purchase is done via this field
// repeated string attachments = 14; // possible files included by seller/buyer // repeated string attachments = 14; // possible files included by
// seller/buyer
} }
message MarketAssetListReq { message MarketAssetListReq {
base.v1.BaseQueryParam base = 1; base.v1.BaseQueryParam base = 1;
optional auth.v1.InternalIAM iam = 2; // If not set, will returns only public orders which are limited by a white list optional auth.v1.InternalIAM iam = 2; // If not set, will returns only public orders which are limited by a
// white list
} }
message MarketAssetList { message MarketAssetList {
@ -47,7 +90,6 @@ message PurchaseReq {
double amount = 3; double amount = 3;
optional bool accepted_contract = 4; optional bool accepted_contract = 4;
optional auth.v1.TFA tfa = 5; optional auth.v1.TFA tfa = 5;
} }
message PurchaseRes { message PurchaseRes {
uint64 order_id = 1; uint64 order_id = 1;
@ -65,30 +107,15 @@ message MarketOrderList {
message NewMarketReq { message NewMarketReq {
auth.v1.InternalIAM iam = 1; auth.v1.InternalIAM iam = 1;
// wallet.v1.Asset asset = 2;
int64 asset_id = 2; int64 asset_id = 2;
int64 counter_asset_id = 3; int64 counter_asset_id = 3;
double amount = 4; double amount = 4;
double unit_price = 5; double unit_price = 5;
MarketOrderSide side = 6; MarketParticipantType type = 6;
optional auth.v1.TFA tfa = 7; wallet.v1.BuyAssetSide req_side = 7; // For Calculation : can be from asset or irt
optional bool accepted_contract = 8; MarketOrderSide side = 8;
} optional auth.v1.TFA tfa = 9;
optional bool accepted_contract = 10;
enum MarketOrderSide {
MO_UNKOWN = 0;
MO_BUY = 1;
MO_SELL = 2;
}
enum MarketOrderStatus {
MO_UNKOWN_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 OrderListFilter { message OrderListFilter {

View File

@ -7,6 +7,8 @@ import "base/v1/msg.proto";
import "market/v1/msg.proto"; import "market/v1/msg.proto";
service MarketplaceSrv { service MarketplaceSrv {
rpc CalcMarketOrder(CalcMarketReq) returns (CalcMarketRes);
rpc MarketplaceSrvHealth(base.v1.Empty) returns (base.v1.StatusRes); rpc MarketplaceSrvHealth(base.v1.Empty) returns (base.v1.StatusRes);
rpc GetMarketOrderDet(auth.v1.IdReqWithIAM) returns (MarketOrder); // details of an order by id rpc GetMarketOrderDet(auth.v1.IdReqWithIAM) returns (MarketOrder); // details of an order by id

View File

@ -9,7 +9,9 @@ import "base/v1/msg.proto";
INTERNAL DATA INTERNAL DATA
*/ */
message InternalTransactionData { int64 transaction_id = 1; } message InternalTransactionData {
int64 transaction_id = 1;
}
/* /*
Federation Federation
@ -107,8 +109,8 @@ message Asset {
AssetPrice price = 35; AssetPrice price = 35;
bool is_base_asset = 36; bool is_base_asset = 36;
bool is_locked = 37; bool is_locked = 37;
Commission commission = 38; // Commission commission = 38;
AssetType type = 39; AssetType type = 38;
} }
enum AssetTokenType { enum AssetTokenType {
@ -136,11 +138,13 @@ enum AssetType {
ASSET_TYPE_NETWORK_GAS = 3; ASSET_TYPE_NETWORK_GAS = 3;
} }
message AssetList { repeated Asset list = 1; } message AssetList {
repeated Asset list = 1;
}
message AssetFilter { message AssetFilter {
repeated int64 ids = 1; repeated int64 ids = 1;
repeated AssetType type = 2; // AssetType repeated AssetType type = 2; // AssetType
repeated AssetType token_type = 3; // AssetType repeated AssetType token_type = 3; // AssetType
repeated AssetStatus status = 4; repeated AssetStatus status = 4;
repeated string name = 5; repeated string name = 5;
@ -166,8 +170,7 @@ message AssetDiscountRes {
double static_amount = 4; double static_amount = 4;
double percentage = 5; double percentage = 5;
double max_amount = 6; double max_amount = 6;
double effective_amount = double effective_amount = 7; // based of asset price and discount amount in req
7; // based of asset price and discount amount in req
optional int64 supported_asset = 8; optional int64 supported_asset = 8;
} }
@ -182,7 +185,9 @@ message GetAssetReq {
optional string code = 3; optional string code = 3;
} }
message AssetMeta { PropertyMeta property = 1; } message AssetMeta {
PropertyMeta property = 1;
}
message PropertyMeta { message PropertyMeta {
string description = 1; string description = 1;
@ -199,12 +204,12 @@ message PropertyMeta {
string location_image = 12; string location_image = 12;
float lat = 13; float lat = 13;
float lng = 14; float lng = 14;
string map_link= 15; string map_link = 15;
PropertyDetail detail = 16; PropertyDetail detail = 16;
} }
message PropertyDetail { message PropertyDetail {
repeated Content badge = 1; // 2> repeated Content badge = 1; // 2>
repeated Content content = 2; // 4> repeated Content content = 2; // 4>
} }
@ -281,8 +286,7 @@ message UserBNPLReq {
optional float amount = 7; optional float amount = 7;
optional PaymentPeriodInfo payment_period = 8; optional PaymentPeriodInfo payment_period = 8;
optional bool has_agreed_contract = 9; optional bool has_agreed_contract = 9;
optional int32 current_step = optional int32 current_step = 10; // Can be useful for admin to change the current step
10; // Can be useful for admin to change the current step
optional int64 asset_id = 11; optional int64 asset_id = 11;
} }
@ -306,7 +310,9 @@ message BNPLInfo {
string expires_at = 14; string expires_at = 14;
} }
message BNPLList { repeated BNPLInfo list = 1; } message BNPLList {
repeated BNPLInfo list = 1;
}
/* /*
Transaction Transaction
@ -446,7 +452,9 @@ message RedeemTokenRes {
optional auth.v1.BankInfo bank_info = 10; optional auth.v1.BankInfo bank_info = 10;
optional string receipt = 11; optional string receipt = 11;
} }
message RedeemTokenResList { repeated RedeemTokenRes list = 1; } message RedeemTokenResList {
repeated RedeemTokenRes list = 1;
}
/* /*
Utility: Get Public Key from national id Utility: Get Public Key from national id
@ -457,7 +465,9 @@ message NationalIDReq {
string national_id = 2; string national_id = 2;
} }
message PubKeyRes { string pub_key = 1; } message PubKeyRes {
string pub_key = 1;
}
/* /*
Network Details Network Details
@ -483,11 +493,22 @@ message Network {
string created_at = 11; string created_at = 11;
} }
message NetworkList { repeated Network list = 1; } message NetworkList {
repeated Network list = 1;
}
/* /*
* Commission * Commission
* */ * */
enum CommissionType {
COMMISSION_TYPE_ICO = 0;
COMMISSION_TYPE_MARKET_MAKER = 1;
COMMISSION_TYPE_MARKET_TAKER = 2;
COMMISSION_TYPE_BNPL = 3;
COMMISSION_TYPE_REDEEM = 4;
}
message Commission { message Commission {
uint64 id = 1; uint64 id = 1;
string name = 2; string name = 2;
@ -495,10 +516,16 @@ message Commission {
double service_percentage = 4; double service_percentage = 4;
double tax_static = 5; double tax_static = 5;
double tax_percentage = 6; double tax_percentage = 6;
optional string collector = 7; Asset asset = 7;
optional string description = 8; CommissionType type = 8;
string updated_at = 9; optional string collector = 9;
string created_at = 10; optional string description = 10;
string updated_at = 11;
string created_at = 12;
}
message CommissionList {
repeated Commission list = 1;
} }
message EffectiveCommission { message EffectiveCommission {
@ -555,7 +582,9 @@ message IPGConfirmReq {
string final_amount = 7; string final_amount = 7;
} }
message IPGConfirmRes { string receipt_link = 1; } message IPGConfirmRes {
string receipt_link = 1;
}
message SaleManualReq { message SaleManualReq {
auth.v1.InternalIAM iam = 1; auth.v1.InternalIAM iam = 1;
@ -604,7 +633,7 @@ message DeclineBuyContractReq {
message ConfirmBuyAssetReq { message ConfirmBuyAssetReq {
auth.v1.InternalIAM iam = 1; auth.v1.InternalIAM iam = 1;
uint64 agreement_id = 2; // Only in asset that require agreement contract uint64 agreement_id = 2; // Only in asset that require agreement contract
optional auth.v1.TFA tfa = 3; // This might be used in the future optional auth.v1.TFA tfa = 3; // This might be used in the future
} }
@ -628,7 +657,6 @@ message BuyAssetRes {
} }
/* Contract */ /* Contract */
enum ContractType { enum ContractType {
CONTRACT_TYPE_ICO = 0; CONTRACT_TYPE_ICO = 0;
CONTRACT_TYPE_MARKET = 1; CONTRACT_TYPE_MARKET = 1;

View File

@ -21,6 +21,7 @@ service WalletService {
// rpc UserGetAssetList(auth.v1.InternalIAM) returns (AssetList); // rpc UserGetAssetList(auth.v1.InternalIAM) returns (AssetList);
// rpc AdminGetAssetList(base.v1.Empty) returns (AssetList); // rpc AdminGetAssetList(base.v1.Empty) returns (AssetList);
rpc GetAsset(GetAssetReq) returns (Asset); rpc GetAsset(GetAssetReq) returns (Asset);
rpc GetAssetCommissions(base.v1.IdReq) returns (CommissionList);
rpc GetAssetPrice(base.v1.IdReq) returns (AssetPrice); rpc GetAssetPrice(base.v1.IdReq) returns (AssetPrice);
rpc UserInitWallet(UserInitWalletReq) returns (base.v1.StatusRes); rpc UserInitWallet(UserInitWalletReq) returns (base.v1.StatusRes);