@r2wa-org/eden 0.0.63 → 0.0.65

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.
@@ -402,6 +402,17 @@ export declare const assetConvertProductRouter: Elysia<"/asset_convert_product",
402
402
  updatedAt: Date;
403
403
  description: string | null;
404
404
  status: "active" | "draft" | "paused" | "ended";
405
+ price: {
406
+ latest?: {
407
+ id: string;
408
+ baseAssetId: string;
409
+ quoteAssetId: string;
410
+ price: string;
411
+ source: string;
412
+ effectiveAt: Date;
413
+ } | undefined;
414
+ dailyChangeRate?: string | undefined;
415
+ };
405
416
  productCategoryKey: "gold" | "gov_bond" | "real_estate" | "corporate_credit";
406
417
  targetAssetId: string;
407
418
  payAssetId: string;
@@ -409,6 +420,38 @@ export declare const assetConvertProductRouter: Elysia<"/asset_convert_product",
409
420
  receiveAccountTypeId: string;
410
421
  minPayAmount: string;
411
422
  settlementMode: "available" | "locked";
423
+ targetAsset: {
424
+ symbol: string;
425
+ id: string;
426
+ name: string;
427
+ code: string;
428
+ category: "FIAT" | "CRYPTO" | "POINT" | "RWA";
429
+ isActive: boolean;
430
+ precision: number;
431
+ };
432
+ payAsset: {
433
+ symbol: string;
434
+ id: string;
435
+ name: string;
436
+ code: string;
437
+ category: "FIAT" | "CRYPTO" | "POINT" | "RWA";
438
+ isActive: boolean;
439
+ precision: number;
440
+ };
441
+ payAccountType: {
442
+ id: string;
443
+ name: string;
444
+ description: string | null;
445
+ key: string;
446
+ isActive: boolean;
447
+ };
448
+ receiveAccountType: {
449
+ id: string;
450
+ name: string;
451
+ description: string | null;
452
+ key: string;
453
+ isActive: boolean;
454
+ };
412
455
  }[];
413
456
  pagination: {
414
457
  total: number;
@@ -451,6 +494,17 @@ export declare const assetConvertProductRouter: Elysia<"/asset_convert_product",
451
494
  updatedAt: Date;
452
495
  description: string | null;
453
496
  status: "active" | "draft" | "paused" | "ended";
497
+ price: {
498
+ latest?: {
499
+ id: string;
500
+ baseAssetId: string;
501
+ quoteAssetId: string;
502
+ price: string;
503
+ source: string;
504
+ effectiveAt: Date;
505
+ } | undefined;
506
+ dailyChangeRate?: string | undefined;
507
+ };
454
508
  productCategoryKey: "gold" | "gov_bond" | "real_estate" | "corporate_credit";
455
509
  targetAssetId: string;
456
510
  payAssetId: string;
@@ -458,6 +512,38 @@ export declare const assetConvertProductRouter: Elysia<"/asset_convert_product",
458
512
  receiveAccountTypeId: string;
459
513
  minPayAmount: string;
460
514
  settlementMode: "available" | "locked";
515
+ targetAsset: {
516
+ symbol: string;
517
+ id: string;
518
+ name: string;
519
+ code: string;
520
+ category: "FIAT" | "CRYPTO" | "POINT" | "RWA";
521
+ isActive: boolean;
522
+ precision: number;
523
+ };
524
+ payAsset: {
525
+ symbol: string;
526
+ id: string;
527
+ name: string;
528
+ code: string;
529
+ category: "FIAT" | "CRYPTO" | "POINT" | "RWA";
530
+ isActive: boolean;
531
+ precision: number;
532
+ };
533
+ payAccountType: {
534
+ id: string;
535
+ name: string;
536
+ description: string | null;
537
+ key: string;
538
+ isActive: boolean;
539
+ };
540
+ receiveAccountType: {
541
+ id: string;
542
+ name: string;
543
+ description: string | null;
544
+ key: string;
545
+ isActive: boolean;
546
+ };
461
547
  };
462
548
  422: {
463
549
  type: "validation";
@@ -1,8 +1,159 @@
1
- import { BaseAssetConvertProductService } from "../internal/service";
1
+ import Decimal from "decimal.js";
2
+ import type { TransactionTx } from "../../db/transaction";
3
+ import { assetConvertOrder, assetConvertProduct } from "../schema";
2
4
  import type { AssetConvertOrderCreateInputType, AssetConvertOrderListQueryType, AssetConvertProductListQueryType } from "./dto.schemas";
3
- export declare abstract class UserAssetConvertProductService extends BaseAssetConvertProductService {
5
+ declare abstract class BaseUserAssetConvertProductService {
6
+ protected static validatePayAmount(payAmount: string): Decimal;
7
+ protected static getProductById(productId: string, tx?: TransactionTx): Promise<{
8
+ id: string;
9
+ name: string;
10
+ createdAt: Date;
11
+ updatedAt: Date;
12
+ description: string | null;
13
+ status: "active" | "draft" | "paused" | "ended";
14
+ productCategoryKey: "gold" | "gov_bond" | "real_estate" | "corporate_credit";
15
+ targetAssetId: string;
16
+ payAssetId: string;
17
+ payAccountTypeId: string;
18
+ receiveAccountTypeId: string;
19
+ minPayAmount: string;
20
+ settlementMode: "available" | "locked";
21
+ }>;
22
+ protected static assertProductActive(product: typeof assetConvertProduct.$inferSelect): void;
23
+ protected static ensureProductPayAmount(productMinPayAmount: string, payAmount: Decimal): void;
24
+ protected static calcTargetAmount(payAmount: Decimal, price: string): string;
25
+ protected static getLatestProductPrice(tx: TransactionTx, product: typeof assetConvertProduct.$inferSelect): Promise<{
26
+ id: string;
27
+ createdAt: Date;
28
+ updatedAt: Date;
29
+ baseAssetId: string;
30
+ baseAsset: string;
31
+ quoteAssetId: string;
32
+ quoteAsset: string;
33
+ price: string;
34
+ source: string;
35
+ effectiveAt: Date;
36
+ }>;
37
+ protected static getPayAccountForUser(tx: TransactionTx, userId: string, payAssetId: string, payAccountTypeId: string): Promise<{
38
+ id: string;
39
+ createdAt: Date;
40
+ updatedAt: Date;
41
+ userId: string;
42
+ status: "active" | "frozen" | "disabled";
43
+ assetId: string;
44
+ ledgerAccountTypeId: string;
45
+ available: string;
46
+ locked: string;
47
+ version: number;
48
+ }>;
49
+ protected static getReceiveAccountForUser(tx: TransactionTx, userId: string, product: typeof assetConvertProduct.$inferSelect): Promise<{
50
+ id: string;
51
+ createdAt: Date;
52
+ updatedAt: Date;
53
+ userId: string;
54
+ status: "active" | "frozen" | "disabled";
55
+ assetId: string;
56
+ ledgerAccountTypeId: string;
57
+ available: string;
58
+ locked: string;
59
+ version: number;
60
+ }>;
61
+ protected static assertIdempotentPayload(existing: typeof assetConvertOrder.$inferSelect, input: {
62
+ productId: string;
63
+ payAmount: string;
64
+ idempotencyKey: string;
65
+ }): void;
66
+ }
67
+ export declare abstract class UserAssetConvertProductService extends BaseUserAssetConvertProductService {
4
68
  static listProducts(filters?: AssetConvertProductListQueryType): Promise<{
5
69
  data: {
70
+ targetAsset: {
71
+ symbol: string;
72
+ id: string;
73
+ name: string;
74
+ createdAt: Date;
75
+ updatedAt: Date;
76
+ code: string;
77
+ iconUrl: string;
78
+ category: "FIAT" | "CRYPTO" | "POINT" | "RWA";
79
+ isActive: boolean;
80
+ typeId: string;
81
+ precision: number;
82
+ };
83
+ payAsset: {
84
+ symbol: string;
85
+ id: string;
86
+ name: string;
87
+ createdAt: Date;
88
+ updatedAt: Date;
89
+ code: string;
90
+ iconUrl: string;
91
+ category: "FIAT" | "CRYPTO" | "POINT" | "RWA";
92
+ isActive: boolean;
93
+ typeId: string;
94
+ precision: number;
95
+ };
96
+ payAccountType: {
97
+ id: string;
98
+ name: string;
99
+ createdAt: Date;
100
+ updatedAt: Date;
101
+ description: string | null;
102
+ key: string;
103
+ isActive: boolean;
104
+ allowDeposit: boolean;
105
+ allowWithdraw: boolean;
106
+ minWithdrawAmount: string;
107
+ maxWithdrawAmount: string;
108
+ allowTransfer: boolean;
109
+ minTransferAmount: string;
110
+ maxTransferAmount: string;
111
+ allowInternalTransfer: boolean;
112
+ allowInternalReceiveTransfer: boolean;
113
+ minInternalTransferAmount: string;
114
+ maxInternalTransferAmount: string;
115
+ internalTransferRatio: string;
116
+ allowTransaction: boolean;
117
+ hasExpiry: boolean;
118
+ expiryDays: number | null;
119
+ sortOrder: number;
120
+ };
121
+ receiveAccountType: {
122
+ id: string;
123
+ name: string;
124
+ createdAt: Date;
125
+ updatedAt: Date;
126
+ description: string | null;
127
+ key: string;
128
+ isActive: boolean;
129
+ allowDeposit: boolean;
130
+ allowWithdraw: boolean;
131
+ minWithdrawAmount: string;
132
+ maxWithdrawAmount: string;
133
+ allowTransfer: boolean;
134
+ minTransferAmount: string;
135
+ maxTransferAmount: string;
136
+ allowInternalTransfer: boolean;
137
+ allowInternalReceiveTransfer: boolean;
138
+ minInternalTransferAmount: string;
139
+ maxInternalTransferAmount: string;
140
+ internalTransferRatio: string;
141
+ allowTransaction: boolean;
142
+ hasExpiry: boolean;
143
+ expiryDays: number | null;
144
+ sortOrder: number;
145
+ };
146
+ price: {
147
+ latest: {
148
+ id: string;
149
+ baseAssetId: string;
150
+ quoteAssetId: string;
151
+ price: string;
152
+ source: string;
153
+ effectiveAt: Date;
154
+ } | undefined;
155
+ dailyChangeRate: string | undefined;
156
+ };
6
157
  id: string;
7
158
  name: string;
8
159
  createdAt: Date;
@@ -26,6 +177,97 @@ export declare abstract class UserAssetConvertProductService extends BaseAssetCo
26
177
  };
27
178
  }>;
28
179
  static getProduct(productId: string): Promise<{
180
+ targetAsset: {
181
+ symbol: string;
182
+ id: string;
183
+ name: string;
184
+ createdAt: Date;
185
+ updatedAt: Date;
186
+ code: string;
187
+ iconUrl: string;
188
+ category: "FIAT" | "CRYPTO" | "POINT" | "RWA";
189
+ isActive: boolean;
190
+ typeId: string;
191
+ precision: number;
192
+ };
193
+ payAsset: {
194
+ symbol: string;
195
+ id: string;
196
+ name: string;
197
+ createdAt: Date;
198
+ updatedAt: Date;
199
+ code: string;
200
+ iconUrl: string;
201
+ category: "FIAT" | "CRYPTO" | "POINT" | "RWA";
202
+ isActive: boolean;
203
+ typeId: string;
204
+ precision: number;
205
+ };
206
+ payAccountType: {
207
+ id: string;
208
+ name: string;
209
+ createdAt: Date;
210
+ updatedAt: Date;
211
+ description: string | null;
212
+ key: string;
213
+ isActive: boolean;
214
+ allowDeposit: boolean;
215
+ allowWithdraw: boolean;
216
+ minWithdrawAmount: string;
217
+ maxWithdrawAmount: string;
218
+ allowTransfer: boolean;
219
+ minTransferAmount: string;
220
+ maxTransferAmount: string;
221
+ allowInternalTransfer: boolean;
222
+ allowInternalReceiveTransfer: boolean;
223
+ minInternalTransferAmount: string;
224
+ maxInternalTransferAmount: string;
225
+ internalTransferRatio: string;
226
+ allowTransaction: boolean;
227
+ hasExpiry: boolean;
228
+ expiryDays: number | null;
229
+ sortOrder: number;
230
+ };
231
+ receiveAccountType: {
232
+ id: string;
233
+ name: string;
234
+ createdAt: Date;
235
+ updatedAt: Date;
236
+ description: string | null;
237
+ key: string;
238
+ isActive: boolean;
239
+ allowDeposit: boolean;
240
+ allowWithdraw: boolean;
241
+ minWithdrawAmount: string;
242
+ maxWithdrawAmount: string;
243
+ allowTransfer: boolean;
244
+ minTransferAmount: string;
245
+ maxTransferAmount: string;
246
+ allowInternalTransfer: boolean;
247
+ allowInternalReceiveTransfer: boolean;
248
+ minInternalTransferAmount: string;
249
+ maxInternalTransferAmount: string;
250
+ internalTransferRatio: string;
251
+ allowTransaction: boolean;
252
+ hasExpiry: boolean;
253
+ expiryDays: number | null;
254
+ sortOrder: number;
255
+ };
256
+ price: {
257
+ latest: {
258
+ id: string;
259
+ createdAt: Date;
260
+ updatedAt: Date;
261
+ baseAssetId: string;
262
+ baseAsset: string;
263
+ quoteAssetId: string;
264
+ quoteAsset: string;
265
+ price: string;
266
+ source: string;
267
+ effectiveAt: Date;
268
+ } | undefined;
269
+ dailyChangeRate: string | undefined;
270
+ };
29
271
  id: string;
30
272
  name: string;
31
273
  createdAt: Date;
@@ -122,3 +364,4 @@ export declare abstract class UserAssetConvertProductService extends BaseAssetCo
122
364
  failureReason: string | null;
123
365
  }>;
124
366
  }
367
+ export {};
@@ -23,7 +23,7 @@ export declare const assetPriceAdminResponseSchema: import("@sinclair/typebox").
23
23
  price: import("@sinclair/typebox").TString;
24
24
  source: import("@sinclair/typebox").TString;
25
25
  effectiveAt: import("@sinclair/typebox").TDate;
26
- quoteAssetInfo: import("@sinclair/typebox").TObject<{
26
+ baseAssetInfo: import("@sinclair/typebox").TObject<{
27
27
  symbol: import("@sinclair/typebox").TString;
28
28
  id: import("@sinclair/typebox").TString;
29
29
  name: import("@sinclair/typebox").TString;
@@ -37,7 +37,7 @@ export declare const assetPriceAdminResponseSchema: import("@sinclair/typebox").
37
37
  isActive: import("@sinclair/typebox").TBoolean;
38
38
  precision: import("@sinclair/typebox").TInteger;
39
39
  }>;
40
- baseAssetInfo: import("@sinclair/typebox").TObject<{
40
+ quoteAssetInfo: import("@sinclair/typebox").TObject<{
41
41
  symbol: import("@sinclair/typebox").TString;
42
42
  id: import("@sinclair/typebox").TString;
43
43
  name: import("@sinclair/typebox").TString;
@@ -99,7 +99,7 @@ export declare const assetPriceAdminListResponseSchema: import("@sinclair/typebo
99
99
  price: import("@sinclair/typebox").TString;
100
100
  source: import("@sinclair/typebox").TString;
101
101
  effectiveAt: import("@sinclair/typebox").TDate;
102
- quoteAssetInfo: import("@sinclair/typebox").TObject<{
102
+ baseAssetInfo: import("@sinclair/typebox").TObject<{
103
103
  symbol: import("@sinclair/typebox").TString;
104
104
  id: import("@sinclair/typebox").TString;
105
105
  name: import("@sinclair/typebox").TString;
@@ -113,7 +113,7 @@ export declare const assetPriceAdminListResponseSchema: import("@sinclair/typebo
113
113
  isActive: import("@sinclair/typebox").TBoolean;
114
114
  precision: import("@sinclair/typebox").TInteger;
115
115
  }>;
116
- baseAssetInfo: import("@sinclair/typebox").TObject<{
116
+ quoteAssetInfo: import("@sinclair/typebox").TObject<{
117
117
  symbol: import("@sinclair/typebox").TString;
118
118
  id: import("@sinclair/typebox").TString;
119
119
  name: import("@sinclair/typebox").TString;
@@ -414,7 +414,7 @@ export declare const assetPriceAdminRouter: Elysia<"/asset_prices", {
414
414
  price: string;
415
415
  source: string;
416
416
  effectiveAt: Date;
417
- quoteAssetInfo: {
417
+ baseAssetInfo: {
418
418
  symbol: string;
419
419
  id: string;
420
420
  name: string;
@@ -423,7 +423,7 @@ export declare const assetPriceAdminRouter: Elysia<"/asset_prices", {
423
423
  isActive: boolean;
424
424
  precision: number;
425
425
  };
426
- baseAssetInfo: {
426
+ quoteAssetInfo: {
427
427
  symbol: string;
428
428
  id: string;
429
429
  name: string;
@@ -480,7 +480,7 @@ export declare const assetPriceAdminRouter: Elysia<"/asset_prices", {
480
480
  price: string;
481
481
  source: string;
482
482
  effectiveAt: Date;
483
- quoteAssetInfo: {
483
+ baseAssetInfo: {
484
484
  symbol: string;
485
485
  id: string;
486
486
  name: string;
@@ -489,7 +489,7 @@ export declare const assetPriceAdminRouter: Elysia<"/asset_prices", {
489
489
  isActive: boolean;
490
490
  precision: number;
491
491
  };
492
- baseAssetInfo: {
492
+ quoteAssetInfo: {
493
493
  symbol: string;
494
494
  id: string;
495
495
  name: string;
@@ -538,7 +538,7 @@ export declare const assetPriceAdminRouter: Elysia<"/asset_prices", {
538
538
  price: string;
539
539
  source: string;
540
540
  effectiveAt: Date;
541
- quoteAssetInfo: {
541
+ baseAssetInfo: {
542
542
  symbol: string;
543
543
  id: string;
544
544
  name: string;
@@ -547,7 +547,7 @@ export declare const assetPriceAdminRouter: Elysia<"/asset_prices", {
547
547
  isActive: boolean;
548
548
  precision: number;
549
549
  };
550
- baseAssetInfo: {
550
+ quoteAssetInfo: {
551
551
  symbol: string;
552
552
  id: string;
553
553
  name: string;
@@ -597,7 +597,7 @@ export declare const assetPriceAdminRouter: Elysia<"/asset_prices", {
597
597
  price: string;
598
598
  source: string;
599
599
  effectiveAt: Date;
600
- quoteAssetInfo: {
600
+ baseAssetInfo: {
601
601
  symbol: string;
602
602
  id: string;
603
603
  name: string;
@@ -606,7 +606,7 @@ export declare const assetPriceAdminRouter: Elysia<"/asset_prices", {
606
606
  isActive: boolean;
607
607
  precision: number;
608
608
  };
609
- baseAssetInfo: {
609
+ quoteAssetInfo: {
610
610
  symbol: string;
611
611
  id: string;
612
612
  name: string;