Created
July 1, 2025 09:25
-
-
Save Phathdt/afc7b3d15e81495800c0b293dcab4672 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| model Lending { | |
| id String @id @default(dbgenerated("gen_uuid_v7()")) @map("id") @db.Uuid | |
| lendingId String @unique @map("lending_id") | |
| status String @default("pending") @map("status") // procesing, liquid, withdrawal | |
| userAddress String @map("user_address") | |
| ... | |
| } | |
| model LendingEvent { | |
| id Int @id @default(autoincrement()) @map("id") | |
| lendingId String @map("lending_id") | |
| targetId String @map("target_id") | |
| action String @map("action") | |
| txId String? @map("tx_id") | |
| blockNumber Int @map("block_number") | |
| inputData Json @map("input_data") | |
| createdAt DateTime @default(now()) @map("created_at") | |
| updatedAt DateTime @updatedAt @map("updated_at") | |
| @@unique([lendingId, targetId]) | |
| @@map("lending_events") | |
| } | |
| model Loan { | |
| id Int @id @default(autoincrement()) @map("id") | |
| lendingId String @map("lending_id") | |
| loanId String @unique @map("loan_id") | |
| ... | |
| } | |
| model Deposit { | |
| id String @id @default(dbgenerated("gen_uuid_v7()")) @map("id") @db.Uuid | |
| lendingId String @map("lending_id") | |
| sessionId String @map("session_id") | |
| depositId String? @unique @map("deposit_id") | |
| positionId String @unique @map("position_id") | |
| fromTokenId String @map("from_token_id") | |
| fromNetworkId String @default("") @map("from_network_id") | |
| amount String @map("amount") | |
| fromUserAddress String @map("from_user_address") | |
| rawUserAddress String @default("") @map("raw_user_address") | |
| depositVault String @map("deposit_vault") // not unique | |
| depositTx String? @map("deposit_tx") | |
| userEphemeralAssetChainPubkey String @map("user_ephemeral_asset_chain_pubkey") | |
| userEphemeralL2Address String @map("user_ephemeral_l2_address") | |
| mpcAssetChainPubkey String @map("mpc_asset_chain_pubkey") | |
| userRefundPubkey String @map("user_refund_pubkey") | |
| scriptTimeout Int? @map("script_timeout") // 1 day | |
| status String? @default("INIT") @map("status") | |
| createdAt DateTime @default(now()) @map("created_at") | |
| updatedAt DateTime @updatedAt @map("updated_at") | |
| @@index([status, createdAt]) | |
| @@index([sessionId]) | |
| @@index([depositId]) | |
| @@map("deposits") | |
| } | |
| // should use lendingId instead vault | |
| model VaultBalance { | |
| id Int @id @default(autoincrement()) @map("id") | |
| lendingId String @map("lending_id") | |
| vaultId String @unique @map("vault_id") // Same as depositVault | |
| userAddress String @map("user_address") | |
| tokenId String @map("token_id") | |
| vaultAddress String @map("vault_address") | |
| // Total balances | |
| totalDeposited Decimal @default(0) @map("total_deposited") @db.Decimal(36, 0) | |
| totalSupplied Decimal @default(0) @map("total_supplied") @db.Decimal(36, 0) | |
| // Available balance | |
| availableBalance Decimal @default(0) @map("available_balance") @db.Decimal(36, 0) | |
| // Status | |
| isActive Boolean @default(true) @map("is_active") | |
| // Timestamps | |
| createdAt DateTime @default(now()) @map("created_at") | |
| updatedAt DateTime @updatedAt @map("updated_at") | |
| @@unique([userAddress, tokenId, vaultAddress]) | |
| @@index([userAddress]) | |
| @@index([vaultAddress]) | |
| @@index([tokenId]) | |
| @@index([isActive]) | |
| @@map("vault_balances") | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment