@arbiwallet/contracts 1.0.152 → 1.0.201
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/gen/exchange_rates.ts +118 -0
- package/gen/referral.ts +361 -0
- package/gen/user.ts +1 -0
- package/package.json +1 -1
- package/proto/exchange_rates.proto +75 -0
- package/proto/referral.proto +239 -0
- package/proto/user.proto +1 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
|
+
// versions:
|
|
3
|
+
// protoc-gen-ts_proto v2.11.4
|
|
4
|
+
// protoc v7.34.0
|
|
5
|
+
// source: exchange_rates.proto
|
|
6
|
+
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
|
|
9
|
+
import { Observable } from "rxjs";
|
|
10
|
+
|
|
11
|
+
export const protobufPackage = "exchange_rates";
|
|
12
|
+
|
|
13
|
+
export interface CalculateExchangeRequest {
|
|
14
|
+
managerUserId: number;
|
|
15
|
+
inputCurrency: string;
|
|
16
|
+
outputCurrency: string;
|
|
17
|
+
currencyForAmount: string;
|
|
18
|
+
amount: number;
|
|
19
|
+
adjustment?: number | undefined;
|
|
20
|
+
promoDiscount?: number | undefined;
|
|
21
|
+
customerId?: number | undefined;
|
|
22
|
+
disableRounding?: boolean | undefined;
|
|
23
|
+
fixedRate?: number | undefined;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface CalculateExchangeResponse {
|
|
27
|
+
result: boolean;
|
|
28
|
+
calculationId?: number | undefined;
|
|
29
|
+
inputCurrencyQuantity: number;
|
|
30
|
+
outputCurrencyQuantity: number;
|
|
31
|
+
exchangeRateForMessage: string;
|
|
32
|
+
exchangeRate: number;
|
|
33
|
+
realExchangeRate: number;
|
|
34
|
+
finalPercent: number;
|
|
35
|
+
adjustment: number;
|
|
36
|
+
hasCustomer: boolean;
|
|
37
|
+
customerId?: number | undefined;
|
|
38
|
+
availableAgents: number[];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface GetExchangeCalculationRequest {
|
|
42
|
+
calculationId?: number | undefined;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface ExchangeCalculation {
|
|
46
|
+
id: number;
|
|
47
|
+
customerId?: number | undefined;
|
|
48
|
+
managerId?: number | undefined;
|
|
49
|
+
inputCurrencyId: number;
|
|
50
|
+
outputCurrencyId: number;
|
|
51
|
+
currencyForAmountId: number;
|
|
52
|
+
amount: number;
|
|
53
|
+
inputCurrencyQuantity: number;
|
|
54
|
+
outputCurrencyQuantity: number;
|
|
55
|
+
exchangeRate: number;
|
|
56
|
+
realExchangeRate: number;
|
|
57
|
+
finalPercent: number;
|
|
58
|
+
adjustment: number;
|
|
59
|
+
promoDiscount: number;
|
|
60
|
+
createdAt: string;
|
|
61
|
+
updatedAt: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface GetExchangeCalculationResponse {
|
|
65
|
+
result: boolean;
|
|
66
|
+
calculation?: ExchangeCalculation | undefined;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface GetExchanheRatesRequest {
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface GetExchanheRatesResponse {
|
|
73
|
+
dataJson: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export const EXCHANGE_RATES_PACKAGE_NAME = "exchange_rates";
|
|
77
|
+
|
|
78
|
+
export interface ExchangeRatesServiceClient {
|
|
79
|
+
calculateExchange(request: CalculateExchangeRequest): Observable<CalculateExchangeResponse>;
|
|
80
|
+
|
|
81
|
+
getExchangeCalculation(request: GetExchangeCalculationRequest): Observable<GetExchangeCalculationResponse>;
|
|
82
|
+
|
|
83
|
+
getExchanheRates(request: GetExchanheRatesRequest): Observable<GetExchanheRatesResponse>;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface ExchangeRatesServiceController {
|
|
87
|
+
calculateExchange(
|
|
88
|
+
request: CalculateExchangeRequest,
|
|
89
|
+
): Promise<CalculateExchangeResponse> | Observable<CalculateExchangeResponse> | CalculateExchangeResponse;
|
|
90
|
+
|
|
91
|
+
getExchangeCalculation(
|
|
92
|
+
request: GetExchangeCalculationRequest,
|
|
93
|
+
):
|
|
94
|
+
| Promise<GetExchangeCalculationResponse>
|
|
95
|
+
| Observable<GetExchangeCalculationResponse>
|
|
96
|
+
| GetExchangeCalculationResponse;
|
|
97
|
+
|
|
98
|
+
getExchanheRates(
|
|
99
|
+
request: GetExchanheRatesRequest,
|
|
100
|
+
): Promise<GetExchanheRatesResponse> | Observable<GetExchanheRatesResponse> | GetExchanheRatesResponse;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function ExchangeRatesServiceControllerMethods() {
|
|
104
|
+
return function (constructor: Function) {
|
|
105
|
+
const grpcMethods: string[] = ["calculateExchange", "getExchangeCalculation", "getExchanheRates"];
|
|
106
|
+
for (const method of grpcMethods) {
|
|
107
|
+
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
108
|
+
GrpcMethod("ExchangeRatesService", method)(constructor.prototype[method], method, descriptor);
|
|
109
|
+
}
|
|
110
|
+
const grpcStreamMethods: string[] = [];
|
|
111
|
+
for (const method of grpcStreamMethods) {
|
|
112
|
+
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
113
|
+
GrpcStreamMethod("ExchangeRatesService", method)(constructor.prototype[method], method, descriptor);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export const EXCHANGE_RATES_SERVICE_NAME = "ExchangeRatesService";
|
package/gen/referral.ts
ADDED
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
|
+
// versions:
|
|
3
|
+
// protoc-gen-ts_proto v2.11.4
|
|
4
|
+
// protoc v7.34.0
|
|
5
|
+
// source: referral.proto
|
|
6
|
+
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
|
|
9
|
+
import { Observable } from "rxjs";
|
|
10
|
+
|
|
11
|
+
export const protobufPackage = "referral.v1";
|
|
12
|
+
|
|
13
|
+
export enum ReferralProfileStatus {
|
|
14
|
+
REFERRAL_PROFILE_STATUS_ACTIVE = 0,
|
|
15
|
+
REFERRAL_PROFILE_STATUS_BLOCKED = 1,
|
|
16
|
+
UNRECOGNIZED = -1,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export enum ReferralBonusType {
|
|
20
|
+
REFERRAL_BONUS_TYPE_PROFIT = 0,
|
|
21
|
+
REFERRAL_BONUS_TYPE_VOLUME = 1,
|
|
22
|
+
UNRECOGNIZED = -1,
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export enum ReferralCommissionStatus {
|
|
26
|
+
REFERRAL_COMMISSION_STATUS_CONFIRMED = 0,
|
|
27
|
+
REFERRAL_COMMISSION_STATUS_CANCELLED = 1,
|
|
28
|
+
UNRECOGNIZED = -1,
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export enum ReferralPayoutStatus {
|
|
32
|
+
REFERRAL_PAYOUT_STATUS_CREATED = 0,
|
|
33
|
+
REFERRAL_PAYOUT_STATUS_CONFIRMED = 1,
|
|
34
|
+
REFERRAL_PAYOUT_STATUS_CANCELLED = 2,
|
|
35
|
+
UNRECOGNIZED = -1,
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface EnsureReferralProfileRequest {
|
|
39
|
+
walletUserId: string;
|
|
40
|
+
legacyCustomerId?: number | undefined;
|
|
41
|
+
telegramId?: string | undefined;
|
|
42
|
+
refCode?: string | undefined;
|
|
43
|
+
referrerCode?: string | undefined;
|
|
44
|
+
source?: string | undefined;
|
|
45
|
+
utmJson?: string | undefined;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface ReferralProfileResponse {
|
|
49
|
+
id: string;
|
|
50
|
+
walletUserId: string;
|
|
51
|
+
legacyCustomerId?: number | undefined;
|
|
52
|
+
telegramId?: string | undefined;
|
|
53
|
+
refCode: string;
|
|
54
|
+
referrerProfileId?: string | undefined;
|
|
55
|
+
bonusType: ReferralBonusType;
|
|
56
|
+
refPercent: string;
|
|
57
|
+
status: ReferralProfileStatus;
|
|
58
|
+
createdAt: string;
|
|
59
|
+
updatedAt: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface GetReferralLinkRequest {
|
|
63
|
+
walletUserId: string;
|
|
64
|
+
baseUrl?: string | undefined;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface GetReferralLinkResponse {
|
|
68
|
+
refCode: string;
|
|
69
|
+
link: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface BindReferralByCodeRequest {
|
|
73
|
+
walletUserId: string;
|
|
74
|
+
refCode: string;
|
|
75
|
+
source?: string | undefined;
|
|
76
|
+
utmJson?: string | undefined;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface BindReferralByCodeResponse {
|
|
80
|
+
success: boolean;
|
|
81
|
+
profile: ReferralProfileResponse | undefined;
|
|
82
|
+
referrer?: ReferralProfileResponse | undefined;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface GetReferralSummaryRequest {
|
|
86
|
+
walletUserId: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface ReferralBalanceItem {
|
|
90
|
+
currency: string;
|
|
91
|
+
total: string;
|
|
92
|
+
available: string;
|
|
93
|
+
heldCurrentWeek: string;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface GetReferralSummaryResponse {
|
|
97
|
+
profile: ReferralProfileResponse | undefined;
|
|
98
|
+
balances: ReferralBalanceItem[];
|
|
99
|
+
referralsCount: number;
|
|
100
|
+
totalUsdVolume: string;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface ListReferralsRequest {
|
|
104
|
+
walletUserId: string;
|
|
105
|
+
page?: number | undefined;
|
|
106
|
+
limit?: number | undefined;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface ReferralListItem {
|
|
110
|
+
profileId: string;
|
|
111
|
+
walletUserId: string;
|
|
112
|
+
legacyCustomerId?: number | undefined;
|
|
113
|
+
telegramId?: string | undefined;
|
|
114
|
+
refCode: string;
|
|
115
|
+
createdAt: string;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface ListReferralsResponse {
|
|
119
|
+
items: ReferralListItem[];
|
|
120
|
+
total: number;
|
|
121
|
+
page: number;
|
|
122
|
+
limit: number;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface ApplyExchangeCompletedRequest {
|
|
126
|
+
exchangeId: string;
|
|
127
|
+
walletUserId: string;
|
|
128
|
+
legacyCustomerId?: number | undefined;
|
|
129
|
+
outputAmount: string;
|
|
130
|
+
factOutputAmount?: string | undefined;
|
|
131
|
+
outputCurrency: string;
|
|
132
|
+
profitAmount: string;
|
|
133
|
+
profitCurrency: string;
|
|
134
|
+
courierExpenses?: string | undefined;
|
|
135
|
+
usdtRate?: string | undefined;
|
|
136
|
+
completedAt?: string | undefined;
|
|
137
|
+
calculationSnapshotJson?: string | undefined;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface ApplyExchangeCompletedResponse {
|
|
141
|
+
created: boolean;
|
|
142
|
+
commission?: ReferralCommissionItem | undefined;
|
|
143
|
+
balances: ReferralBalanceItem[];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface ApplyExchangeCancelledRequest {
|
|
147
|
+
exchangeId: string;
|
|
148
|
+
reason?: string | undefined;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export interface ApplyExchangeCancelledResponse {
|
|
152
|
+
cancelledCount: number;
|
|
153
|
+
balances: ReferralBalanceItem[];
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export interface ListCommissionsRequest {
|
|
157
|
+
walletUserId: string;
|
|
158
|
+
page?: number | undefined;
|
|
159
|
+
limit?: number | undefined;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export interface ReferralCommissionItem {
|
|
163
|
+
id: string;
|
|
164
|
+
exchangeId: string;
|
|
165
|
+
referrerProfileId: string;
|
|
166
|
+
referredProfileId: string;
|
|
167
|
+
level: number;
|
|
168
|
+
bonusType: ReferralBonusType;
|
|
169
|
+
percent: string;
|
|
170
|
+
baseAmount: string;
|
|
171
|
+
amount: string;
|
|
172
|
+
currency: string;
|
|
173
|
+
status: ReferralCommissionStatus;
|
|
174
|
+
createdAt: string;
|
|
175
|
+
cancelledAt?: string | undefined;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export interface ListCommissionsResponse {
|
|
179
|
+
items: ReferralCommissionItem[];
|
|
180
|
+
total: number;
|
|
181
|
+
page: number;
|
|
182
|
+
limit: number;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export interface CreatePayoutRequest {
|
|
186
|
+
walletUserId: string;
|
|
187
|
+
amount: string;
|
|
188
|
+
currency: string;
|
|
189
|
+
paymentMethod: string;
|
|
190
|
+
outputCurrency?: string | undefined;
|
|
191
|
+
comment?: string | undefined;
|
|
192
|
+
createdByManagerId?: string | undefined;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export interface ConfirmPayoutRequest {
|
|
196
|
+
payoutId: string;
|
|
197
|
+
confirmedByManagerId?: string | undefined;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export interface ReferralPayoutResponse {
|
|
201
|
+
id: string;
|
|
202
|
+
profileId: string;
|
|
203
|
+
amount: string;
|
|
204
|
+
currency: string;
|
|
205
|
+
paymentMethod: string;
|
|
206
|
+
outputCurrency?: string | undefined;
|
|
207
|
+
status: ReferralPayoutStatus;
|
|
208
|
+
comment?: string | undefined;
|
|
209
|
+
createdAt: string;
|
|
210
|
+
updatedAt: string;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export interface ListPayoutsRequest {
|
|
214
|
+
walletUserId: string;
|
|
215
|
+
page?: number | undefined;
|
|
216
|
+
limit?: number | undefined;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export interface ListPayoutsResponse {
|
|
220
|
+
items: ReferralPayoutResponse[];
|
|
221
|
+
total: number;
|
|
222
|
+
page: number;
|
|
223
|
+
limit: number;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export interface AdminRecalculateExchangeRequest {
|
|
227
|
+
exchangeId: string;
|
|
228
|
+
dryRun: boolean;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export interface AdminRecalculateExchangeResponse {
|
|
232
|
+
changed: boolean;
|
|
233
|
+
commission?: ReferralCommissionItem | undefined;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export const REFERRAL_V1_PACKAGE_NAME = "referral.v1";
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* ReferralService owns referral attribution, referral commissions, bonus balances,
|
|
240
|
+
* weekly payout holds, and payout lifecycle for ArbiExchange/ArbiWallet.
|
|
241
|
+
*/
|
|
242
|
+
|
|
243
|
+
export interface ReferralServiceClient {
|
|
244
|
+
ensureReferralProfile(request: EnsureReferralProfileRequest): Observable<ReferralProfileResponse>;
|
|
245
|
+
|
|
246
|
+
getReferralLink(request: GetReferralLinkRequest): Observable<GetReferralLinkResponse>;
|
|
247
|
+
|
|
248
|
+
bindReferralByCode(request: BindReferralByCodeRequest): Observable<BindReferralByCodeResponse>;
|
|
249
|
+
|
|
250
|
+
getReferralSummary(request: GetReferralSummaryRequest): Observable<GetReferralSummaryResponse>;
|
|
251
|
+
|
|
252
|
+
listReferrals(request: ListReferralsRequest): Observable<ListReferralsResponse>;
|
|
253
|
+
|
|
254
|
+
applyExchangeCompleted(request: ApplyExchangeCompletedRequest): Observable<ApplyExchangeCompletedResponse>;
|
|
255
|
+
|
|
256
|
+
applyExchangeCancelled(request: ApplyExchangeCancelledRequest): Observable<ApplyExchangeCancelledResponse>;
|
|
257
|
+
|
|
258
|
+
listCommissions(request: ListCommissionsRequest): Observable<ListCommissionsResponse>;
|
|
259
|
+
|
|
260
|
+
createPayout(request: CreatePayoutRequest): Observable<ReferralPayoutResponse>;
|
|
261
|
+
|
|
262
|
+
confirmPayout(request: ConfirmPayoutRequest): Observable<ReferralPayoutResponse>;
|
|
263
|
+
|
|
264
|
+
listPayouts(request: ListPayoutsRequest): Observable<ListPayoutsResponse>;
|
|
265
|
+
|
|
266
|
+
adminRecalculateExchange(request: AdminRecalculateExchangeRequest): Observable<AdminRecalculateExchangeResponse>;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* ReferralService owns referral attribution, referral commissions, bonus balances,
|
|
271
|
+
* weekly payout holds, and payout lifecycle for ArbiExchange/ArbiWallet.
|
|
272
|
+
*/
|
|
273
|
+
|
|
274
|
+
export interface ReferralServiceController {
|
|
275
|
+
ensureReferralProfile(
|
|
276
|
+
request: EnsureReferralProfileRequest,
|
|
277
|
+
): Promise<ReferralProfileResponse> | Observable<ReferralProfileResponse> | ReferralProfileResponse;
|
|
278
|
+
|
|
279
|
+
getReferralLink(
|
|
280
|
+
request: GetReferralLinkRequest,
|
|
281
|
+
): Promise<GetReferralLinkResponse> | Observable<GetReferralLinkResponse> | GetReferralLinkResponse;
|
|
282
|
+
|
|
283
|
+
bindReferralByCode(
|
|
284
|
+
request: BindReferralByCodeRequest,
|
|
285
|
+
): Promise<BindReferralByCodeResponse> | Observable<BindReferralByCodeResponse> | BindReferralByCodeResponse;
|
|
286
|
+
|
|
287
|
+
getReferralSummary(
|
|
288
|
+
request: GetReferralSummaryRequest,
|
|
289
|
+
): Promise<GetReferralSummaryResponse> | Observable<GetReferralSummaryResponse> | GetReferralSummaryResponse;
|
|
290
|
+
|
|
291
|
+
listReferrals(
|
|
292
|
+
request: ListReferralsRequest,
|
|
293
|
+
): Promise<ListReferralsResponse> | Observable<ListReferralsResponse> | ListReferralsResponse;
|
|
294
|
+
|
|
295
|
+
applyExchangeCompleted(
|
|
296
|
+
request: ApplyExchangeCompletedRequest,
|
|
297
|
+
):
|
|
298
|
+
| Promise<ApplyExchangeCompletedResponse>
|
|
299
|
+
| Observable<ApplyExchangeCompletedResponse>
|
|
300
|
+
| ApplyExchangeCompletedResponse;
|
|
301
|
+
|
|
302
|
+
applyExchangeCancelled(
|
|
303
|
+
request: ApplyExchangeCancelledRequest,
|
|
304
|
+
):
|
|
305
|
+
| Promise<ApplyExchangeCancelledResponse>
|
|
306
|
+
| Observable<ApplyExchangeCancelledResponse>
|
|
307
|
+
| ApplyExchangeCancelledResponse;
|
|
308
|
+
|
|
309
|
+
listCommissions(
|
|
310
|
+
request: ListCommissionsRequest,
|
|
311
|
+
): Promise<ListCommissionsResponse> | Observable<ListCommissionsResponse> | ListCommissionsResponse;
|
|
312
|
+
|
|
313
|
+
createPayout(
|
|
314
|
+
request: CreatePayoutRequest,
|
|
315
|
+
): Promise<ReferralPayoutResponse> | Observable<ReferralPayoutResponse> | ReferralPayoutResponse;
|
|
316
|
+
|
|
317
|
+
confirmPayout(
|
|
318
|
+
request: ConfirmPayoutRequest,
|
|
319
|
+
): Promise<ReferralPayoutResponse> | Observable<ReferralPayoutResponse> | ReferralPayoutResponse;
|
|
320
|
+
|
|
321
|
+
listPayouts(
|
|
322
|
+
request: ListPayoutsRequest,
|
|
323
|
+
): Promise<ListPayoutsResponse> | Observable<ListPayoutsResponse> | ListPayoutsResponse;
|
|
324
|
+
|
|
325
|
+
adminRecalculateExchange(
|
|
326
|
+
request: AdminRecalculateExchangeRequest,
|
|
327
|
+
):
|
|
328
|
+
| Promise<AdminRecalculateExchangeResponse>
|
|
329
|
+
| Observable<AdminRecalculateExchangeResponse>
|
|
330
|
+
| AdminRecalculateExchangeResponse;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
export function ReferralServiceControllerMethods() {
|
|
334
|
+
return function (constructor: Function) {
|
|
335
|
+
const grpcMethods: string[] = [
|
|
336
|
+
"ensureReferralProfile",
|
|
337
|
+
"getReferralLink",
|
|
338
|
+
"bindReferralByCode",
|
|
339
|
+
"getReferralSummary",
|
|
340
|
+
"listReferrals",
|
|
341
|
+
"applyExchangeCompleted",
|
|
342
|
+
"applyExchangeCancelled",
|
|
343
|
+
"listCommissions",
|
|
344
|
+
"createPayout",
|
|
345
|
+
"confirmPayout",
|
|
346
|
+
"listPayouts",
|
|
347
|
+
"adminRecalculateExchange",
|
|
348
|
+
];
|
|
349
|
+
for (const method of grpcMethods) {
|
|
350
|
+
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
351
|
+
GrpcMethod("ReferralService", method)(constructor.prototype[method], method, descriptor);
|
|
352
|
+
}
|
|
353
|
+
const grpcStreamMethods: string[] = [];
|
|
354
|
+
for (const method of grpcStreamMethods) {
|
|
355
|
+
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
356
|
+
GrpcStreamMethod("ReferralService", method)(constructor.prototype[method], method, descriptor);
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export const REFERRAL_SERVICE_NAME = "ReferralService";
|
package/gen/user.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arbiwallet/contracts",
|
|
3
3
|
"descriptions": "Generate and manage smart contracts for ArbiWallet",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.201",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"generate": "protoc -I ./proto ./proto/*.proto --ts_proto_out=./gen --ts_proto_opt=nestJs=true,package=omit"
|
|
7
7
|
},
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package exchange_rates;
|
|
4
|
+
|
|
5
|
+
option csharp_namespace = "ExchangeRates";
|
|
6
|
+
option java_multiple_files = true;
|
|
7
|
+
option java_package = "com.arbiwallet.exchange.rates";
|
|
8
|
+
|
|
9
|
+
service ExchangeRatesService {
|
|
10
|
+
rpc CalculateExchange(CalculateExchangeRequest) returns (CalculateExchangeResponse);
|
|
11
|
+
rpc GetExchangeCalculation(GetExchangeCalculationRequest) returns (GetExchangeCalculationResponse);
|
|
12
|
+
rpc GetExchanheRates(GetExchanheRatesRequest) returns (GetExchanheRatesResponse);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
message CalculateExchangeRequest {
|
|
16
|
+
int64 manager_user_id = 1;
|
|
17
|
+
string input_currency = 2;
|
|
18
|
+
string output_currency = 3;
|
|
19
|
+
string currency_for_amount = 4;
|
|
20
|
+
double amount = 5;
|
|
21
|
+
optional double adjustment = 6;
|
|
22
|
+
optional double promo_discount = 7;
|
|
23
|
+
optional int64 customer_id = 8;
|
|
24
|
+
optional bool disable_rounding = 9;
|
|
25
|
+
optional double fixed_rate = 10;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
message CalculateExchangeResponse {
|
|
29
|
+
bool result = 1;
|
|
30
|
+
optional int64 calculation_id = 2;
|
|
31
|
+
double input_currency_quantity = 3;
|
|
32
|
+
double output_currency_quantity = 4;
|
|
33
|
+
string exchange_rate_for_message = 5;
|
|
34
|
+
double exchange_rate = 6;
|
|
35
|
+
double real_exchange_rate = 7;
|
|
36
|
+
double final_percent = 8;
|
|
37
|
+
double adjustment = 9;
|
|
38
|
+
bool has_customer = 10;
|
|
39
|
+
optional int64 customer_id = 11;
|
|
40
|
+
repeated int64 available_agents = 12;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
message GetExchangeCalculationRequest {
|
|
44
|
+
optional int64 calculation_id = 1;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
message ExchangeCalculation {
|
|
48
|
+
int64 id = 1;
|
|
49
|
+
optional int64 customer_id = 2;
|
|
50
|
+
optional int64 manager_id = 3;
|
|
51
|
+
int64 input_currency_id = 4;
|
|
52
|
+
int64 output_currency_id = 5;
|
|
53
|
+
int64 currency_for_amount_id = 6;
|
|
54
|
+
double amount = 7;
|
|
55
|
+
double input_currency_quantity = 8;
|
|
56
|
+
double output_currency_quantity = 9;
|
|
57
|
+
double exchange_rate = 10;
|
|
58
|
+
double real_exchange_rate = 11;
|
|
59
|
+
double final_percent = 12;
|
|
60
|
+
double adjustment = 13;
|
|
61
|
+
double promo_discount = 14;
|
|
62
|
+
string created_at = 15;
|
|
63
|
+
string updated_at = 16;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
message GetExchangeCalculationResponse {
|
|
67
|
+
bool result = 1;
|
|
68
|
+
optional ExchangeCalculation calculation = 2;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
message GetExchanheRatesRequest {}
|
|
72
|
+
|
|
73
|
+
message GetExchanheRatesResponse {
|
|
74
|
+
string data_json = 1;
|
|
75
|
+
}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package referral.v1;
|
|
4
|
+
|
|
5
|
+
// ReferralService owns referral attribution, referral commissions, bonus balances,
|
|
6
|
+
// weekly payout holds, and payout lifecycle for ArbiExchange/ArbiWallet.
|
|
7
|
+
service ReferralService {
|
|
8
|
+
rpc EnsureReferralProfile(EnsureReferralProfileRequest) returns (ReferralProfileResponse);
|
|
9
|
+
rpc GetReferralLink(GetReferralLinkRequest) returns (GetReferralLinkResponse);
|
|
10
|
+
rpc BindReferralByCode(BindReferralByCodeRequest) returns (BindReferralByCodeResponse);
|
|
11
|
+
rpc GetReferralSummary(GetReferralSummaryRequest) returns (GetReferralSummaryResponse);
|
|
12
|
+
rpc ListReferrals(ListReferralsRequest) returns (ListReferralsResponse);
|
|
13
|
+
rpc ApplyExchangeCompleted(ApplyExchangeCompletedRequest) returns (ApplyExchangeCompletedResponse);
|
|
14
|
+
rpc ApplyExchangeCancelled(ApplyExchangeCancelledRequest) returns (ApplyExchangeCancelledResponse);
|
|
15
|
+
rpc ListCommissions(ListCommissionsRequest) returns (ListCommissionsResponse);
|
|
16
|
+
rpc CreatePayout(CreatePayoutRequest) returns (ReferralPayoutResponse);
|
|
17
|
+
rpc ConfirmPayout(ConfirmPayoutRequest) returns (ReferralPayoutResponse);
|
|
18
|
+
rpc ListPayouts(ListPayoutsRequest) returns (ListPayoutsResponse);
|
|
19
|
+
rpc AdminRecalculateExchange(AdminRecalculateExchangeRequest) returns (AdminRecalculateExchangeResponse);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
enum ReferralProfileStatus {
|
|
23
|
+
REFERRAL_PROFILE_STATUS_ACTIVE = 0;
|
|
24
|
+
REFERRAL_PROFILE_STATUS_BLOCKED = 1;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
enum ReferralBonusType {
|
|
28
|
+
REFERRAL_BONUS_TYPE_PROFIT = 0;
|
|
29
|
+
REFERRAL_BONUS_TYPE_VOLUME = 1;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
enum ReferralCommissionStatus {
|
|
33
|
+
REFERRAL_COMMISSION_STATUS_CONFIRMED = 0;
|
|
34
|
+
REFERRAL_COMMISSION_STATUS_CANCELLED = 1;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
enum ReferralPayoutStatus {
|
|
38
|
+
REFERRAL_PAYOUT_STATUS_CREATED = 0;
|
|
39
|
+
REFERRAL_PAYOUT_STATUS_CONFIRMED = 1;
|
|
40
|
+
REFERRAL_PAYOUT_STATUS_CANCELLED = 2;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
message EnsureReferralProfileRequest {
|
|
44
|
+
string wallet_user_id = 1;
|
|
45
|
+
optional int64 legacy_customer_id = 2;
|
|
46
|
+
optional string telegram_id = 3;
|
|
47
|
+
optional string ref_code = 4;
|
|
48
|
+
optional string referrer_code = 5;
|
|
49
|
+
optional string source = 6;
|
|
50
|
+
optional string utm_json = 7;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
message ReferralProfileResponse {
|
|
54
|
+
string id = 1;
|
|
55
|
+
string wallet_user_id = 2;
|
|
56
|
+
optional int64 legacy_customer_id = 3;
|
|
57
|
+
optional string telegram_id = 4;
|
|
58
|
+
string ref_code = 5;
|
|
59
|
+
optional string referrer_profile_id = 6;
|
|
60
|
+
ReferralBonusType bonus_type = 7;
|
|
61
|
+
string ref_percent = 8;
|
|
62
|
+
ReferralProfileStatus status = 9;
|
|
63
|
+
string created_at = 10;
|
|
64
|
+
string updated_at = 11;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
message GetReferralLinkRequest {
|
|
68
|
+
string wallet_user_id = 1;
|
|
69
|
+
optional string base_url = 2;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
message GetReferralLinkResponse {
|
|
73
|
+
string ref_code = 1;
|
|
74
|
+
string link = 2;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
message BindReferralByCodeRequest {
|
|
78
|
+
string wallet_user_id = 1;
|
|
79
|
+
string ref_code = 2;
|
|
80
|
+
optional string source = 3;
|
|
81
|
+
optional string utm_json = 4;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
message BindReferralByCodeResponse {
|
|
85
|
+
bool success = 1;
|
|
86
|
+
ReferralProfileResponse profile = 2;
|
|
87
|
+
optional ReferralProfileResponse referrer = 3;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
message GetReferralSummaryRequest {
|
|
91
|
+
string wallet_user_id = 1;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
message ReferralBalanceItem {
|
|
95
|
+
string currency = 1;
|
|
96
|
+
string total = 2;
|
|
97
|
+
string available = 3;
|
|
98
|
+
string held_current_week = 4;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
message GetReferralSummaryResponse {
|
|
102
|
+
ReferralProfileResponse profile = 1;
|
|
103
|
+
repeated ReferralBalanceItem balances = 2;
|
|
104
|
+
int32 referrals_count = 3;
|
|
105
|
+
string total_usd_volume = 4;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
message ListReferralsRequest {
|
|
109
|
+
string wallet_user_id = 1;
|
|
110
|
+
optional int32 page = 2;
|
|
111
|
+
optional int32 limit = 3;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
message ReferralListItem {
|
|
115
|
+
string profile_id = 1;
|
|
116
|
+
string wallet_user_id = 2;
|
|
117
|
+
optional int64 legacy_customer_id = 3;
|
|
118
|
+
optional string telegram_id = 4;
|
|
119
|
+
string ref_code = 5;
|
|
120
|
+
string created_at = 6;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
message ListReferralsResponse {
|
|
124
|
+
repeated ReferralListItem items = 1;
|
|
125
|
+
int32 total = 2;
|
|
126
|
+
int32 page = 3;
|
|
127
|
+
int32 limit = 4;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
message ApplyExchangeCompletedRequest {
|
|
131
|
+
string exchange_id = 1;
|
|
132
|
+
string wallet_user_id = 2;
|
|
133
|
+
optional int64 legacy_customer_id = 3;
|
|
134
|
+
string output_amount = 4;
|
|
135
|
+
optional string fact_output_amount = 5;
|
|
136
|
+
string output_currency = 6;
|
|
137
|
+
string profit_amount = 7;
|
|
138
|
+
string profit_currency = 8;
|
|
139
|
+
optional string courier_expenses = 9;
|
|
140
|
+
optional string usdt_rate = 10;
|
|
141
|
+
optional string completed_at = 11;
|
|
142
|
+
optional string calculation_snapshot_json = 12;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
message ApplyExchangeCompletedResponse {
|
|
146
|
+
bool created = 1;
|
|
147
|
+
optional ReferralCommissionItem commission = 2;
|
|
148
|
+
repeated ReferralBalanceItem balances = 3;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
message ApplyExchangeCancelledRequest {
|
|
152
|
+
string exchange_id = 1;
|
|
153
|
+
optional string reason = 2;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
message ApplyExchangeCancelledResponse {
|
|
157
|
+
int32 cancelled_count = 1;
|
|
158
|
+
repeated ReferralBalanceItem balances = 2;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
message ListCommissionsRequest {
|
|
162
|
+
string wallet_user_id = 1;
|
|
163
|
+
optional int32 page = 2;
|
|
164
|
+
optional int32 limit = 3;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
message ReferralCommissionItem {
|
|
168
|
+
string id = 1;
|
|
169
|
+
string exchange_id = 2;
|
|
170
|
+
string referrer_profile_id = 3;
|
|
171
|
+
string referred_profile_id = 4;
|
|
172
|
+
int32 level = 5;
|
|
173
|
+
ReferralBonusType bonus_type = 6;
|
|
174
|
+
string percent = 7;
|
|
175
|
+
string base_amount = 8;
|
|
176
|
+
string amount = 9;
|
|
177
|
+
string currency = 10;
|
|
178
|
+
ReferralCommissionStatus status = 11;
|
|
179
|
+
string created_at = 12;
|
|
180
|
+
optional string cancelled_at = 13;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
message ListCommissionsResponse {
|
|
184
|
+
repeated ReferralCommissionItem items = 1;
|
|
185
|
+
int32 total = 2;
|
|
186
|
+
int32 page = 3;
|
|
187
|
+
int32 limit = 4;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
message CreatePayoutRequest {
|
|
191
|
+
string wallet_user_id = 1;
|
|
192
|
+
string amount = 2;
|
|
193
|
+
string currency = 3;
|
|
194
|
+
string payment_method = 4;
|
|
195
|
+
optional string output_currency = 5;
|
|
196
|
+
optional string comment = 6;
|
|
197
|
+
optional string created_by_manager_id = 7;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
message ConfirmPayoutRequest {
|
|
201
|
+
string payout_id = 1;
|
|
202
|
+
optional string confirmed_by_manager_id = 2;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
message ReferralPayoutResponse {
|
|
206
|
+
string id = 1;
|
|
207
|
+
string profile_id = 2;
|
|
208
|
+
string amount = 3;
|
|
209
|
+
string currency = 4;
|
|
210
|
+
string payment_method = 5;
|
|
211
|
+
optional string output_currency = 6;
|
|
212
|
+
ReferralPayoutStatus status = 7;
|
|
213
|
+
optional string comment = 8;
|
|
214
|
+
string created_at = 9;
|
|
215
|
+
string updated_at = 10;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
message ListPayoutsRequest {
|
|
219
|
+
string wallet_user_id = 1;
|
|
220
|
+
optional int32 page = 2;
|
|
221
|
+
optional int32 limit = 3;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
message ListPayoutsResponse {
|
|
225
|
+
repeated ReferralPayoutResponse items = 1;
|
|
226
|
+
int32 total = 2;
|
|
227
|
+
int32 page = 3;
|
|
228
|
+
int32 limit = 4;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
message AdminRecalculateExchangeRequest {
|
|
232
|
+
string exchange_id = 1;
|
|
233
|
+
bool dry_run = 2;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
message AdminRecalculateExchangeResponse {
|
|
237
|
+
bool changed = 1;
|
|
238
|
+
optional ReferralCommissionItem commission = 2;
|
|
239
|
+
}
|