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_MOBILE_NUMBER = 2010;
INVALID_ARGUMENT_IBAN_NUMBER = 2011;
INVALID_ARGUMENT_UNKNOWN_TYPE = 2012;
// Resource errors
NOT_FOUND = 3000;

View File

@ -6,6 +6,47 @@ import "auth/v1/msg.proto";
import "base/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 MPListFilter {}
message MarketOrder {
@ -29,12 +70,14 @@ message MarketOrder {
repeated string tags = 18;
repeated string comment = 19;
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 {
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 {
@ -47,7 +90,6 @@ message PurchaseReq {
double amount = 3;
optional bool accepted_contract = 4;
optional auth.v1.TFA tfa = 5;
}
message PurchaseRes {
uint64 order_id = 1;
@ -65,30 +107,15 @@ message MarketOrderList {
message NewMarketReq {
auth.v1.InternalIAM iam = 1;
// wallet.v1.Asset asset = 2;
int64 asset_id = 2;
int64 counter_asset_id = 3;
double amount = 4;
double unit_price = 5;
MarketOrderSide side = 6;
optional auth.v1.TFA tfa = 7;
optional bool accepted_contract = 8;
}
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
MarketParticipantType type = 6;
wallet.v1.BuyAssetSide req_side = 7; // For Calculation : can be from asset or irt
MarketOrderSide side = 8;
optional auth.v1.TFA tfa = 9;
optional bool accepted_contract = 10;
}
message OrderListFilter {

View File

@ -7,6 +7,8 @@ import "base/v1/msg.proto";
import "market/v1/msg.proto";
service MarketplaceSrv {
rpc CalcMarketOrder(CalcMarketReq) returns (CalcMarketRes);
rpc MarketplaceSrvHealth(base.v1.Empty) returns (base.v1.StatusRes);
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
*/
message InternalTransactionData { int64 transaction_id = 1; }
message InternalTransactionData {
int64 transaction_id = 1;
}
/*
Federation
@ -107,8 +109,8 @@ message Asset {
AssetPrice price = 35;
bool is_base_asset = 36;
bool is_locked = 37;
Commission commission = 38;
AssetType type = 39;
// Commission commission = 38;
AssetType type = 38;
}
enum AssetTokenType {
@ -136,7 +138,9 @@ enum AssetType {
ASSET_TYPE_NETWORK_GAS = 3;
}
message AssetList { repeated Asset list = 1; }
message AssetList {
repeated Asset list = 1;
}
message AssetFilter {
repeated int64 ids = 1;
@ -166,8 +170,7 @@ message AssetDiscountRes {
double static_amount = 4;
double percentage = 5;
double max_amount = 6;
double effective_amount =
7; // based of asset price and discount amount in req
double effective_amount = 7; // based of asset price and discount amount in req
optional int64 supported_asset = 8;
}
@ -182,7 +185,9 @@ message GetAssetReq {
optional string code = 3;
}
message AssetMeta { PropertyMeta property = 1; }
message AssetMeta {
PropertyMeta property = 1;
}
message PropertyMeta {
string description = 1;
@ -199,7 +204,7 @@ message PropertyMeta {
string location_image = 12;
float lat = 13;
float lng = 14;
string map_link= 15;
string map_link = 15;
PropertyDetail detail = 16;
}
@ -281,8 +286,7 @@ message UserBNPLReq {
optional float amount = 7;
optional PaymentPeriodInfo payment_period = 8;
optional bool has_agreed_contract = 9;
optional int32 current_step =
10; // Can be useful for admin to change the current step
optional int32 current_step = 10; // Can be useful for admin to change the current step
optional int64 asset_id = 11;
}
@ -306,7 +310,9 @@ message BNPLInfo {
string expires_at = 14;
}
message BNPLList { repeated BNPLInfo list = 1; }
message BNPLList {
repeated BNPLInfo list = 1;
}
/*
Transaction
@ -446,7 +452,9 @@ message RedeemTokenRes {
optional auth.v1.BankInfo bank_info = 10;
optional string receipt = 11;
}
message RedeemTokenResList { repeated RedeemTokenRes list = 1; }
message RedeemTokenResList {
repeated RedeemTokenRes list = 1;
}
/*
Utility: Get Public Key from national id
@ -457,7 +465,9 @@ message NationalIDReq {
string national_id = 2;
}
message PubKeyRes { string pub_key = 1; }
message PubKeyRes {
string pub_key = 1;
}
/*
Network Details
@ -483,11 +493,22 @@ message Network {
string created_at = 11;
}
message NetworkList { repeated Network list = 1; }
message NetworkList {
repeated Network list = 1;
}
/*
* 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 {
uint64 id = 1;
string name = 2;
@ -495,10 +516,16 @@ message Commission {
double service_percentage = 4;
double tax_static = 5;
double tax_percentage = 6;
optional string collector = 7;
optional string description = 8;
string updated_at = 9;
string created_at = 10;
Asset asset = 7;
CommissionType type = 8;
optional string collector = 9;
optional string description = 10;
string updated_at = 11;
string created_at = 12;
}
message CommissionList {
repeated Commission list = 1;
}
message EffectiveCommission {
@ -555,7 +582,9 @@ message IPGConfirmReq {
string final_amount = 7;
}
message IPGConfirmRes { string receipt_link = 1; }
message IPGConfirmRes {
string receipt_link = 1;
}
message SaleManualReq {
auth.v1.InternalIAM iam = 1;
@ -628,7 +657,6 @@ message BuyAssetRes {
}
/* Contract */
enum ContractType {
CONTRACT_TYPE_ICO = 0;
CONTRACT_TYPE_MARKET = 1;

View File

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