@r2wa-org/eden 0.0.63 → 0.0.64

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.
@@ -396,6 +396,15 @@ export declare const assetConvertProductRouter: Elysia<"/asset_convert_product",
396
396
  response: {
397
397
  200: {
398
398
  data: {
399
+ latestPriceInfo?: {
400
+ id: string;
401
+ baseAssetId: string;
402
+ quoteAssetId: string;
403
+ price: string;
404
+ source: string;
405
+ effectiveAt: Date;
406
+ } | undefined;
407
+ dailyChangeRate?: string | undefined;
399
408
  id: string;
400
409
  name: string;
401
410
  createdAt: Date;
@@ -409,6 +418,38 @@ export declare const assetConvertProductRouter: Elysia<"/asset_convert_product",
409
418
  receiveAccountTypeId: string;
410
419
  minPayAmount: string;
411
420
  settlementMode: "available" | "locked";
421
+ targetAssetInfo: {
422
+ symbol: string;
423
+ id: string;
424
+ name: string;
425
+ code: string;
426
+ category: "FIAT" | "CRYPTO" | "POINT" | "RWA";
427
+ isActive: boolean;
428
+ precision: number;
429
+ };
430
+ payAssetInfo: {
431
+ symbol: string;
432
+ id: string;
433
+ name: string;
434
+ code: string;
435
+ category: "FIAT" | "CRYPTO" | "POINT" | "RWA";
436
+ isActive: boolean;
437
+ precision: number;
438
+ };
439
+ payAccountTypeInfo: {
440
+ id: string;
441
+ name: string;
442
+ description: string | null;
443
+ key: string;
444
+ isActive: boolean;
445
+ };
446
+ receiveAccountTypeInfo: {
447
+ id: string;
448
+ name: string;
449
+ description: string | null;
450
+ key: string;
451
+ isActive: boolean;
452
+ };
412
453
  }[];
413
454
  pagination: {
414
455
  total: number;
@@ -445,6 +486,15 @@ export declare const assetConvertProductRouter: Elysia<"/asset_convert_product",
445
486
  headers: {};
446
487
  response: {
447
488
  200: {
489
+ latestPriceInfo?: {
490
+ id: string;
491
+ baseAssetId: string;
492
+ quoteAssetId: string;
493
+ price: string;
494
+ source: string;
495
+ effectiveAt: Date;
496
+ } | undefined;
497
+ dailyChangeRate?: string | undefined;
448
498
  id: string;
449
499
  name: string;
450
500
  createdAt: Date;
@@ -458,6 +508,38 @@ export declare const assetConvertProductRouter: Elysia<"/asset_convert_product",
458
508
  receiveAccountTypeId: string;
459
509
  minPayAmount: string;
460
510
  settlementMode: "available" | "locked";
511
+ targetAssetInfo: {
512
+ symbol: string;
513
+ id: string;
514
+ name: string;
515
+ code: string;
516
+ category: "FIAT" | "CRYPTO" | "POINT" | "RWA";
517
+ isActive: boolean;
518
+ precision: number;
519
+ };
520
+ payAssetInfo: {
521
+ symbol: string;
522
+ id: string;
523
+ name: string;
524
+ code: string;
525
+ category: "FIAT" | "CRYPTO" | "POINT" | "RWA";
526
+ isActive: boolean;
527
+ precision: number;
528
+ };
529
+ payAccountTypeInfo: {
530
+ id: string;
531
+ name: string;
532
+ description: string | null;
533
+ key: string;
534
+ isActive: boolean;
535
+ };
536
+ receiveAccountTypeInfo: {
537
+ id: string;
538
+ name: string;
539
+ description: string | null;
540
+ key: string;
541
+ isActive: boolean;
542
+ };
461
543
  };
462
544
  422: {
463
545
  type: "validation";
@@ -1,8 +1,157 @@
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
+ targetAssetInfo: {
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
+ payAssetInfo: {
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
+ payAccountTypeInfo: {
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
+ receiveAccountTypeInfo: {
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
+ latestPriceInfo: {
147
+ id: string;
148
+ baseAssetId: string;
149
+ quoteAssetId: string;
150
+ price: string;
151
+ source: string;
152
+ effectiveAt: Date;
153
+ } | undefined;
154
+ dailyChangeRate: string | undefined;
6
155
  id: string;
7
156
  name: string;
8
157
  createdAt: Date;
@@ -26,6 +175,95 @@ export declare abstract class UserAssetConvertProductService extends BaseAssetCo
26
175
  };
27
176
  }>;
28
177
  static getProduct(productId: string): Promise<{
178
+ targetAssetInfo: {
179
+ symbol: string;
180
+ id: string;
181
+ name: string;
182
+ createdAt: Date;
183
+ updatedAt: Date;
184
+ code: string;
185
+ iconUrl: string;
186
+ category: "FIAT" | "CRYPTO" | "POINT" | "RWA";
187
+ isActive: boolean;
188
+ typeId: string;
189
+ precision: number;
190
+ };
191
+ payAssetInfo: {
192
+ symbol: string;
193
+ id: string;
194
+ name: string;
195
+ createdAt: Date;
196
+ updatedAt: Date;
197
+ code: string;
198
+ iconUrl: string;
199
+ category: "FIAT" | "CRYPTO" | "POINT" | "RWA";
200
+ isActive: boolean;
201
+ typeId: string;
202
+ precision: number;
203
+ };
204
+ payAccountTypeInfo: {
205
+ id: string;
206
+ name: string;
207
+ createdAt: Date;
208
+ updatedAt: Date;
209
+ description: string | null;
210
+ key: string;
211
+ isActive: boolean;
212
+ allowDeposit: boolean;
213
+ allowWithdraw: boolean;
214
+ minWithdrawAmount: string;
215
+ maxWithdrawAmount: string;
216
+ allowTransfer: boolean;
217
+ minTransferAmount: string;
218
+ maxTransferAmount: string;
219
+ allowInternalTransfer: boolean;
220
+ allowInternalReceiveTransfer: boolean;
221
+ minInternalTransferAmount: string;
222
+ maxInternalTransferAmount: string;
223
+ internalTransferRatio: string;
224
+ allowTransaction: boolean;
225
+ hasExpiry: boolean;
226
+ expiryDays: number | null;
227
+ sortOrder: number;
228
+ };
229
+ receiveAccountTypeInfo: {
230
+ id: string;
231
+ name: string;
232
+ createdAt: Date;
233
+ updatedAt: Date;
234
+ description: string | null;
235
+ key: string;
236
+ isActive: boolean;
237
+ allowDeposit: boolean;
238
+ allowWithdraw: boolean;
239
+ minWithdrawAmount: string;
240
+ maxWithdrawAmount: string;
241
+ allowTransfer: boolean;
242
+ minTransferAmount: string;
243
+ maxTransferAmount: string;
244
+ allowInternalTransfer: boolean;
245
+ allowInternalReceiveTransfer: boolean;
246
+ minInternalTransferAmount: string;
247
+ maxInternalTransferAmount: string;
248
+ internalTransferRatio: string;
249
+ allowTransaction: boolean;
250
+ hasExpiry: boolean;
251
+ expiryDays: number | null;
252
+ sortOrder: number;
253
+ };
254
+ latestPriceInfo: {
255
+ id: string;
256
+ createdAt: Date;
257
+ updatedAt: Date;
258
+ baseAssetId: string;
259
+ baseAsset: string;
260
+ quoteAssetId: string;
261
+ quoteAsset: string;
262
+ price: string;
263
+ source: string;
264
+ effectiveAt: Date;
265
+ } | undefined;
266
+ dailyChangeRate: string | undefined;
29
267
  id: string;
30
268
  name: string;
31
269
  createdAt: Date;
@@ -122,3 +360,4 @@ export declare abstract class UserAssetConvertProductService extends BaseAssetCo
122
360
  failureReason: string | null;
123
361
  }>;
124
362
  }
363
+ export {};
@@ -9365,6 +9365,15 @@ declare const app: Elysia<"/api", {
9365
9365
  response: {
9366
9366
  200: {
9367
9367
  data: {
9368
+ latestPriceInfo?: {
9369
+ id: string;
9370
+ baseAssetId: string;
9371
+ quoteAssetId: string;
9372
+ price: string;
9373
+ source: string;
9374
+ effectiveAt: Date;
9375
+ } | undefined;
9376
+ dailyChangeRate?: string | undefined;
9368
9377
  id: string;
9369
9378
  name: string;
9370
9379
  createdAt: Date;
@@ -9378,6 +9387,38 @@ declare const app: Elysia<"/api", {
9378
9387
  receiveAccountTypeId: string;
9379
9388
  minPayAmount: string;
9380
9389
  settlementMode: "available" | "locked";
9390
+ targetAssetInfo: {
9391
+ symbol: string;
9392
+ id: string;
9393
+ name: string;
9394
+ code: string;
9395
+ category: "FIAT" | "CRYPTO" | "POINT" | "RWA";
9396
+ isActive: boolean;
9397
+ precision: number;
9398
+ };
9399
+ payAssetInfo: {
9400
+ symbol: string;
9401
+ id: string;
9402
+ name: string;
9403
+ code: string;
9404
+ category: "FIAT" | "CRYPTO" | "POINT" | "RWA";
9405
+ isActive: boolean;
9406
+ precision: number;
9407
+ };
9408
+ payAccountTypeInfo: {
9409
+ id: string;
9410
+ name: string;
9411
+ description: string | null;
9412
+ key: string;
9413
+ isActive: boolean;
9414
+ };
9415
+ receiveAccountTypeInfo: {
9416
+ id: string;
9417
+ name: string;
9418
+ description: string | null;
9419
+ key: string;
9420
+ isActive: boolean;
9421
+ };
9381
9422
  }[];
9382
9423
  pagination: {
9383
9424
  total: number;
@@ -9414,6 +9455,15 @@ declare const app: Elysia<"/api", {
9414
9455
  headers: {};
9415
9456
  response: {
9416
9457
  200: {
9458
+ latestPriceInfo?: {
9459
+ id: string;
9460
+ baseAssetId: string;
9461
+ quoteAssetId: string;
9462
+ price: string;
9463
+ source: string;
9464
+ effectiveAt: Date;
9465
+ } | undefined;
9466
+ dailyChangeRate?: string | undefined;
9417
9467
  id: string;
9418
9468
  name: string;
9419
9469
  createdAt: Date;
@@ -9427,6 +9477,38 @@ declare const app: Elysia<"/api", {
9427
9477
  receiveAccountTypeId: string;
9428
9478
  minPayAmount: string;
9429
9479
  settlementMode: "available" | "locked";
9480
+ targetAssetInfo: {
9481
+ symbol: string;
9482
+ id: string;
9483
+ name: string;
9484
+ code: string;
9485
+ category: "FIAT" | "CRYPTO" | "POINT" | "RWA";
9486
+ isActive: boolean;
9487
+ precision: number;
9488
+ };
9489
+ payAssetInfo: {
9490
+ symbol: string;
9491
+ id: string;
9492
+ name: string;
9493
+ code: string;
9494
+ category: "FIAT" | "CRYPTO" | "POINT" | "RWA";
9495
+ isActive: boolean;
9496
+ precision: number;
9497
+ };
9498
+ payAccountTypeInfo: {
9499
+ id: string;
9500
+ name: string;
9501
+ description: string | null;
9502
+ key: string;
9503
+ isActive: boolean;
9504
+ };
9505
+ receiveAccountTypeInfo: {
9506
+ id: string;
9507
+ name: string;
9508
+ description: string | null;
9509
+ key: string;
9510
+ isActive: boolean;
9511
+ };
9430
9512
  };
9431
9513
  422: {
9432
9514
  type: "validation";
@@ -189,6 +189,11 @@ export declare const ledgerAccountByTypeAndAssetParamsSchema: import("@sinclair/
189
189
  assetCode: import("@sinclair/typebox").TString;
190
190
  }>;
191
191
  export type LedgerAccountByTypeAndAssetParamsType = typeof ledgerAccountByTypeAndAssetParamsSchema.static;
192
+ export declare const ledgerAccountByTypeIdAndAssetIdParamsSchema: import("@sinclair/typebox").TObject<{
193
+ ledgerAccountTypeId: import("@sinclair/typebox").TString;
194
+ assetId: import("@sinclair/typebox").TString;
195
+ }>;
196
+ export type LedgerAccountByTypeIdAndAssetIdParamsType = typeof ledgerAccountByTypeIdAndAssetIdParamsSchema.static;
192
197
  export declare const ledgerAccountResponseSchema: import("drizzle-typebox").BuildSchema<"select", {
193
198
  createdAt: import("drizzle-orm/pg-core").PgColumn<{
194
199
  name: "created_at";
@@ -440,6 +440,67 @@ export declare const ledgerAccountRouter: Elysia<"/ledger_accounts", {
440
440
  };
441
441
  };
442
442
  };
443
+ } & {
444
+ ledger_accounts: {
445
+ "account-type-ids": {
446
+ ":ledgerAccountTypeId": {
447
+ assets: {
448
+ ":assetId": {
449
+ get: {
450
+ body: {};
451
+ params: {
452
+ assetId: string;
453
+ ledgerAccountTypeId: string;
454
+ };
455
+ query: {};
456
+ headers: {};
457
+ response: {
458
+ 200: {
459
+ id: string;
460
+ createdAt: Date;
461
+ updatedAt: Date;
462
+ userId: string;
463
+ status: "active" | "frozen" | "disabled";
464
+ asset: {
465
+ symbol: string;
466
+ id: string;
467
+ name: string;
468
+ code: string;
469
+ iconUrl: string;
470
+ category: "FIAT" | "CRYPTO" | "POINT" | "RWA";
471
+ isActive: boolean;
472
+ precision: number;
473
+ };
474
+ assetId: string;
475
+ ledgerAccountTypeId: string;
476
+ available: string;
477
+ locked: string;
478
+ version: number;
479
+ ledgerAccountType: {
480
+ id: string;
481
+ name: string;
482
+ description: string | null;
483
+ key: string;
484
+ isActive: boolean;
485
+ };
486
+ };
487
+ 422: {
488
+ type: "validation";
489
+ on: string;
490
+ summary?: string;
491
+ message?: string;
492
+ found?: unknown;
493
+ property?: string;
494
+ expected?: string;
495
+ };
496
+ 401: "Unauthorized";
497
+ };
498
+ };
499
+ };
500
+ };
501
+ };
502
+ };
503
+ };
443
504
  } & {
444
505
  ledger_accounts: {
445
506
  ":id": {
@@ -1,5 +1,5 @@
1
1
  import { BaseLedgerAccountService } from "../internal/service";
2
- import type { LedgerAccountByTypeAndAssetParamsType, LedgerAccountIdParamsType } from "./dto.schemas";
2
+ import type { LedgerAccountByTypeAndAssetParamsType, LedgerAccountByTypeIdAndAssetIdParamsType, LedgerAccountIdParamsType } from "./dto.schemas";
3
3
  export declare abstract class UserLedgerAccountService extends BaseLedgerAccountService {
4
4
  static getAccountByTypeAndAsset(userId: string, params: LedgerAccountByTypeAndAssetParamsType): Promise<{
5
5
  id: string;
@@ -101,4 +101,54 @@ export declare abstract class UserLedgerAccountService extends BaseLedgerAccount
101
101
  sortOrder: number;
102
102
  };
103
103
  }>;
104
+ static getAccountByTypeIdAndAssetId(userId: string, params: LedgerAccountByTypeIdAndAssetIdParamsType): Promise<{
105
+ id: string;
106
+ createdAt: Date;
107
+ updatedAt: Date;
108
+ userId: string;
109
+ status: "active" | "frozen" | "disabled";
110
+ assetId: string;
111
+ ledgerAccountTypeId: string;
112
+ available: string;
113
+ locked: string;
114
+ version: number;
115
+ asset: {
116
+ symbol: string;
117
+ id: string;
118
+ name: string;
119
+ createdAt: Date;
120
+ updatedAt: Date;
121
+ code: string;
122
+ iconUrl: string;
123
+ category: "FIAT" | "CRYPTO" | "POINT" | "RWA";
124
+ isActive: boolean;
125
+ typeId: string;
126
+ precision: number;
127
+ };
128
+ ledgerAccountType: {
129
+ id: string;
130
+ name: string;
131
+ createdAt: Date;
132
+ updatedAt: Date;
133
+ description: string | null;
134
+ key: string;
135
+ isActive: boolean;
136
+ allowDeposit: boolean;
137
+ allowWithdraw: boolean;
138
+ minWithdrawAmount: string;
139
+ maxWithdrawAmount: string;
140
+ allowTransfer: boolean;
141
+ minTransferAmount: string;
142
+ maxTransferAmount: string;
143
+ allowInternalTransfer: boolean;
144
+ allowInternalReceiveTransfer: boolean;
145
+ minInternalTransferAmount: string;
146
+ maxInternalTransferAmount: string;
147
+ internalTransferRatio: string;
148
+ allowTransaction: boolean;
149
+ hasExpiry: boolean;
150
+ expiryDays: number | null;
151
+ sortOrder: number;
152
+ };
153
+ }>;
104
154
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@r2wa-org/eden",
3
- "version": "0.0.63",
3
+ "version": "0.0.64",
4
4
  "description": "Elysia API type definitions for Eden Treaty",
5
5
  "types": "./dist/src/index.d.ts",
6
6
  "files": [
@@ -10,7 +10,7 @@
10
10
  "release": "npm version patch && npm publish --access public"
11
11
  },
12
12
  "peerDependencies": {
13
- "@elysiajs/eden": "^1.4.5"
13
+ "@elysiajs/eden": "^1.4.9"
14
14
  },
15
15
  "publishConfig": {
16
16
  "access": "public",