From cdb5b05d42fb5dce9969cdb19595fb787ce9cf2d Mon Sep 17 00:00:00 2001 From: bigben-7 <103938678+BigBen-7@users.noreply.github.com> Date: Fri, 19 Jun 2026 00:21:52 +0100 Subject: [PATCH] fix(defi): flatten src/defi/defi/ redundant nesting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Moves all files from the nested src/defi/defi/ directory up one level to src/defi/, matching the flat structure used by other domain modules. - git mv all 19 files: controllers, module, dto, entities, services, protocols - Update src/defi/trade.controller.ts import: ../../core/auth → ../core/auth - Update entity imports: ../../../core/user/entities → ../../core/user/entities - Update src/app.module.ts: ./defi/defi/ → ./defi/ for module and entity imports - Replace src/defi/protocols/aave.adapter.ts and protocol-adapter.interface.ts with the more complete versions from src/defi/defi/protocols/ - Remove empty src/defi/defi/ directory Closes #5 --- .eslintrc.js | 11 + src/app.module.ts | 12 +- src/blockchain/oracle/oracle.controller.ts | 2 +- src/blockchain/oracle/oracle.module.ts | 2 +- .../oracle/submission-verifier.controller.ts | 2 +- .../oracle/submission-verifier.service.ts | 2 +- src/common/guard/nonce.guard.spec.ts | 2 +- src/common/guard/nonce.guard.ts | 2 +- src/common/guard/quota.guard.ts | 2 +- src/core/auth/auth.controller.ts | 6 +- src/core/auth/enhanced-auth.service.ts | 2 +- src/core/auth/entities/auth.entity.ts | 2 +- src/core/auth/entities/wallet.entity.ts | 2 +- .../strategies/api-key/api-key.strategy.ts | 2 +- .../auth/strategies/oauth/oauth.strategy.ts | 2 +- .../traditional/traditional.strategy.ts | 2 +- .../auth/strategies/wallet/wallet.strategy.ts | 4 +- src/core/user/entities/user.entity.ts | 4 +- src/defi/{defi => }/defi.controller.ts | 0 src/defi/{defi => }/defi.module.ts | 0 src/defi/defi/protocols/aave.adapter.ts | 530 ------------------ .../protocols/protocol-adapter.interface.ts | 147 ----- src/defi/{defi => }/dto/defi.dto.ts | 0 src/defi/{defi => }/dto/yield-strategy.dto.ts | 0 .../entities/defi-position.entity.ts | 2 +- .../entities/defi-risk-assessment.entity.ts | 0 .../entities/defi-transaction.entity.ts | 0 .../entities/defi-yield-record.entity.ts | 0 .../entities/defi-yield-strategy.entity.ts | 2 +- src/defi/protocols/aave.adapter.ts | 13 +- .../{defi => }/protocols/compound.adapter.ts | 0 .../protocols/protocol-adapter.interface.ts | 147 +++-- .../{defi => }/protocols/protocol-registry.ts | 0 .../services/position-tracking.service.ts | 0 .../services/risk-assessment.service.ts | 0 .../transaction-optimization.service.ts | 0 .../services/yield-optimization.service.ts | 0 src/defi/{defi => }/trade-lock.service.ts | 0 src/defi/{defi => }/trade.controller.ts | 2 +- .../audit/entities/agent-event.entity.ts | 2 +- .../audit/entities/compute-result.entity.ts | 2 +- .../entities/oracle-submission.entity.ts | 2 +- .../entities/provenance-record.entity.ts | 2 +- .../audit/guards/provenance-access.guard.ts | 2 +- .../audit/provenance.controller.ts | 2 +- .../portfolio/entities/risk-profile.entity.ts | 2 +- .../risk-management.controller.ts | 2 +- tsconfig.json | 3 + 48 files changed, 164 insertions(+), 761 deletions(-) rename src/defi/{defi => }/defi.controller.ts (100%) rename src/defi/{defi => }/defi.module.ts (100%) delete mode 100644 src/defi/defi/protocols/aave.adapter.ts delete mode 100644 src/defi/defi/protocols/protocol-adapter.interface.ts rename src/defi/{defi => }/dto/defi.dto.ts (100%) rename src/defi/{defi => }/dto/yield-strategy.dto.ts (100%) rename src/defi/{defi => }/entities/defi-position.entity.ts (98%) rename src/defi/{defi => }/entities/defi-risk-assessment.entity.ts (100%) rename src/defi/{defi => }/entities/defi-transaction.entity.ts (100%) rename src/defi/{defi => }/entities/defi-yield-record.entity.ts (100%) rename src/defi/{defi => }/entities/defi-yield-strategy.entity.ts (97%) rename src/defi/{defi => }/protocols/compound.adapter.ts (100%) rename src/defi/{defi => }/protocols/protocol-registry.ts (100%) rename src/defi/{defi => }/services/position-tracking.service.ts (100%) rename src/defi/{defi => }/services/risk-assessment.service.ts (100%) rename src/defi/{defi => }/services/transaction-optimization.service.ts (100%) rename src/defi/{defi => }/services/yield-optimization.service.ts (100%) rename src/defi/{defi => }/trade-lock.service.ts (100%) rename src/defi/{defi => }/trade.controller.ts (93%) diff --git a/.eslintrc.js b/.eslintrc.js index 901998d..0603049 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -21,5 +21,16 @@ module.exports = { '@typescript-eslint/explicit-module-boundary-types': 'off', '@typescript-eslint/no-explicit-any': 'off', "@typescript-eslint/no-namespace": "off", + 'no-restricted-imports': [ + 'warn', + { + patterns: [ + { + group: ['../../*'], + message: 'Use src/ absolute imports instead of relative parent imports crossing module boundaries.', + }, + ], + }, + ], }, }; diff --git a/src/app.module.ts b/src/app.module.ts index 7e9d984..2e5c932 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -27,7 +27,7 @@ import { PortfolioModule } from "./investment/portfolio/portfolio.module"; import { RiskManagementModule } from "./investment/risk-management/risk-management.module"; // Modules – defi -import { DeFiModule } from "./defi/defi/defi.module"; +import { DeFiModule } from "./defi/defi.module"; // Modules – growth import { AlertsModule } from "./growth/alerts/alerts.module"; @@ -56,11 +56,11 @@ import { PerformanceMetric } from "./investment/portfolio/entities/performance-m import { BacktestResult } from "./investment/portfolio/entities/backtest-result.entity"; // DeFi entities -import { DeFiPosition } from "./defi/defi/entities/defi-position.entity"; -import { DeFiYieldRecord } from "./defi/defi/entities/defi-yield-record.entity"; -import { DeFiTransaction } from "./defi/defi/entities/defi-transaction.entity"; -import { DeFiYieldStrategy } from "./defi/defi/entities/defi-yield-strategy.entity"; -import { DeFiRiskAssessment } from "./defi/defi/entities/defi-risk-assessment.entity"; +import { DeFiPosition } from "./defi/entities/defi-position.entity"; +import { DeFiYieldRecord } from "./defi/entities/defi-yield-record.entity"; +import { DeFiTransaction } from "./defi/entities/defi-transaction.entity"; +import { DeFiYieldStrategy } from "./defi/entities/defi-yield-strategy.entity"; +import { DeFiRiskAssessment } from "./defi/entities/defi-risk-assessment.entity"; // Alerts entities import { Alert } from "./growth/alerts/entities/alert.entity"; diff --git a/src/blockchain/oracle/oracle.controller.ts b/src/blockchain/oracle/oracle.controller.ts index 78f6958..d5cd3c5 100644 --- a/src/blockchain/oracle/oracle.controller.ts +++ b/src/blockchain/oracle/oracle.controller.ts @@ -12,7 +12,7 @@ import { Logger, } from "@nestjs/common"; import { OracleService } from "./services/oracle.service"; -import { JwtAuthGuard } from "../../core/auth/jwt.guard"; +import { JwtAuthGuard } from "src/core/auth/jwt.guard"; import { CreatePayloadDto } from "./dto/create-payload.dto"; import { SignPayloadDto } from "./dto/sign-payload.dto"; import { SubmitPayloadDto } from "./dto/submit-payload.dto"; diff --git a/src/blockchain/oracle/oracle.module.ts b/src/blockchain/oracle/oracle.module.ts index c192762..cfcf204 100644 --- a/src/blockchain/oracle/oracle.module.ts +++ b/src/blockchain/oracle/oracle.module.ts @@ -10,7 +10,7 @@ import { SubmissionBatchService } from "./services/submission-batch.service"; import { SubmissionVerifierService } from "./submission-verifier.service"; import { SignedPayload } from "./entities/signed-payload.entity"; import { SubmissionNonce } from "./entities/submission-nonce.entity"; -import { AuditModule } from "../../infrastructure/audit/audit.module"; +import { AuditModule } from "src/infrastructure/audit/audit.module"; /** * Oracle Module diff --git a/src/blockchain/oracle/submission-verifier.controller.ts b/src/blockchain/oracle/submission-verifier.controller.ts index 3857982..36eaabe 100644 --- a/src/blockchain/oracle/submission-verifier.controller.ts +++ b/src/blockchain/oracle/submission-verifier.controller.ts @@ -2,7 +2,7 @@ import { Controller, Get, UseGuards } from "@nestjs/common"; import { SubmissionVerifierService } from "./submission-verifier.service"; -import { AuditLogService } from "../../infrastructure/audit/audit-log.service"; +import { AuditLogService } from "src/infrastructure/audit/audit-log.service"; @Controller("verifier") export class SubmissionVerifierController { diff --git a/src/blockchain/oracle/submission-verifier.service.ts b/src/blockchain/oracle/submission-verifier.service.ts index 21d4982..3c3d812 100644 --- a/src/blockchain/oracle/submission-verifier.service.ts +++ b/src/blockchain/oracle/submission-verifier.service.ts @@ -1,7 +1,7 @@ // src/oracle/submission-verifier.service.ts import { Injectable, Logger } from "@nestjs/common"; -import { AuditLogService } from "../../infrastructure/audit/audit-log.service"; +import { AuditLogService } from "src/infrastructure/audit/audit-log.service"; interface OnChainSubmission { id: string; diff --git a/src/common/guard/nonce.guard.spec.ts b/src/common/guard/nonce.guard.spec.ts index 52abe5a..700146c 100644 --- a/src/common/guard/nonce.guard.spec.ts +++ b/src/common/guard/nonce.guard.spec.ts @@ -2,7 +2,7 @@ import { Test, TestingModule } from '@nestjs/testing'; import { ExecutionContext, ConflictException, BadRequestException } from '@nestjs/common'; import { getRepositoryToken } from '@nestjs/typeorm'; import { NonceGuard } from './nonce.guard'; -import { SubmissionNonce } from '../../blockchain/oracle/entities/submission-nonce.entity'; +import { SubmissionNonce } from 'src/blockchain/oracle/entities/submission-nonce.entity'; const mockNonceRepository = { findOne: jest.fn(), diff --git a/src/common/guard/nonce.guard.ts b/src/common/guard/nonce.guard.ts index 80b7c43..47be227 100644 --- a/src/common/guard/nonce.guard.ts +++ b/src/common/guard/nonce.guard.ts @@ -6,7 +6,7 @@ import { BadRequestException, } from "@nestjs/common"; import { InjectRepository } from "@nestjs/typeorm"; -import { SubmissionNonce } from "../../blockchain/oracle/entities/submission-nonce.entity"; +import { SubmissionNonce } from "src/blockchain/oracle/entities/submission-nonce.entity"; import { Repository } from "typeorm"; /** diff --git a/src/common/guard/quota.guard.ts b/src/common/guard/quota.guard.ts index b1fd9f0..dca0ff4 100644 --- a/src/common/guard/quota.guard.ts +++ b/src/common/guard/quota.guard.ts @@ -11,7 +11,7 @@ import { RATE_LIMIT_KEY, RateLimitOptions, } from "../decorators/rate-limit.decorator"; -import { QUOTA_LEVELS, DEFAULT_QUOTA } from "../../config/quota.config"; +import { QUOTA_LEVELS, DEFAULT_QUOTA } from "src/config/quota.config"; @Injectable() export class QuotaGuard implements CanActivate { diff --git a/src/core/auth/auth.controller.ts b/src/core/auth/auth.controller.ts index 5caf73d..3573d54 100644 --- a/src/core/auth/auth.controller.ts +++ b/src/core/auth/auth.controller.ts @@ -33,9 +33,9 @@ import { LinkWalletDto } from "./dto/link-wallet.dto"; import { UnlinkWalletDto } from "./dto/unlink-wallet.dto"; import { RecoverWalletDto } from "./dto/recover-wallet.dto"; import { Throttle } from "@nestjs/throttler"; -import { SensitiveRateLimit } from "../../common/decorators/rate-limit.decorator"; -import { Roles, Role } from "../../common/decorators/roles.decorator"; -import { RolesGuard } from "../../common/guard/roles.guard"; +import { SensitiveRateLimit } from "src/common/decorators/rate-limit.decorator"; +import { Roles, Role } from "src/common/decorators/roles.decorator"; +import { RolesGuard } from "src/common/guard/roles.guard"; export class RequestChallengeDto { @ApiProperty({ diff --git a/src/core/auth/enhanced-auth.service.ts b/src/core/auth/enhanced-auth.service.ts index 9c8befc..ee4c7fc 100644 --- a/src/core/auth/enhanced-auth.service.ts +++ b/src/core/auth/enhanced-auth.service.ts @@ -14,7 +14,7 @@ import { JwtService } from "@nestjs/jwt"; import * as speakeasy from "speakeasy"; import * as qrcode from "qrcode"; import { EmailService } from "./email.service"; -import { User } from "../../core/user/entities/user.entity"; +import { User } from "src/core/user/entities/user.entity"; import { RefreshToken, TwoFactorAuth, TwoFactorType, TwoFactorStatus } from "./entities/auth.entity"; import { LoginDto, RegisterDto, RefreshTokenDto, TwoFactorVerifyDto } from "./dto/auth.dto"; import { TwoFactorSetupDto } from "./dto/kyc.dto"; diff --git a/src/core/auth/entities/auth.entity.ts b/src/core/auth/entities/auth.entity.ts index f47708f..fcae1b4 100644 --- a/src/core/auth/entities/auth.entity.ts +++ b/src/core/auth/entities/auth.entity.ts @@ -8,7 +8,7 @@ import { JoinColumn, Index, } from "typeorm"; -import { User } from "../../user/entities/user.entity"; +import { User } from "src/core/user/entities/user.entity"; @Entity("refresh_tokens") export class RefreshToken { diff --git a/src/core/auth/entities/wallet.entity.ts b/src/core/auth/entities/wallet.entity.ts index 404c34d..357d700 100644 --- a/src/core/auth/entities/wallet.entity.ts +++ b/src/core/auth/entities/wallet.entity.ts @@ -8,7 +8,7 @@ import { ManyToOne, JoinColumn, } from "typeorm"; -import { User } from "../../user/entities/user.entity"; +import { User } from "src/core/user/entities/user.entity"; export enum WalletStatus { ACTIVE = "active", diff --git a/src/core/auth/strategies/api-key/api-key.strategy.ts b/src/core/auth/strategies/api-key/api-key.strategy.ts index ca45418..c332785 100644 --- a/src/core/auth/strategies/api-key/api-key.strategy.ts +++ b/src/core/auth/strategies/api-key/api-key.strategy.ts @@ -15,7 +15,7 @@ import { AuthPayload, ApiKeyCredentials, } from "../interfaces/auth-strategy.interface"; -import { User } from "../../../user/entities/user.entity"; +import { User } from "src/core/user/entities/user.entity"; /** * API Key metadata diff --git a/src/core/auth/strategies/oauth/oauth.strategy.ts b/src/core/auth/strategies/oauth/oauth.strategy.ts index aea30a0..f7025a0 100644 --- a/src/core/auth/strategies/oauth/oauth.strategy.ts +++ b/src/core/auth/strategies/oauth/oauth.strategy.ts @@ -14,7 +14,7 @@ import { AuthPayload, OAuthCredentials, } from "../interfaces/auth-strategy.interface"; -import { User } from "../../../user/entities/user.entity"; +import { User } from "src/core/user/entities/user.entity"; /** * OAuth provider configuration diff --git a/src/core/auth/strategies/traditional/traditional.strategy.ts b/src/core/auth/strategies/traditional/traditional.strategy.ts index b1b9d4b..6aa5fe3 100644 --- a/src/core/auth/strategies/traditional/traditional.strategy.ts +++ b/src/core/auth/strategies/traditional/traditional.strategy.ts @@ -16,7 +16,7 @@ import { AuthPayload, TraditionalCredentials, } from "../interfaces/auth-strategy.interface"; -import { User } from "../../../user/entities/user.entity"; +import { User } from "src/core/user/entities/user.entity"; /** * Traditional email/password authentication strategy diff --git a/src/core/auth/strategies/wallet/wallet.strategy.ts b/src/core/auth/strategies/wallet/wallet.strategy.ts index c034401..88f2fbe 100644 --- a/src/core/auth/strategies/wallet/wallet.strategy.ts +++ b/src/core/auth/strategies/wallet/wallet.strategy.ts @@ -15,8 +15,8 @@ import { AuthPayload, WalletCredentials, } from "../interfaces/auth-strategy.interface"; -import { ChallengeService } from "../../challenge.service"; -import { User } from "../../../user/entities/user.entity"; +import { ChallengeService } from "src/core/auth/challenge.service"; +import { User } from "src/core/user/entities/user.entity"; /** * Wallet-based authentication strategy diff --git a/src/core/user/entities/user.entity.ts b/src/core/user/entities/user.entity.ts index 5bbd53a..84eea41 100644 --- a/src/core/user/entities/user.entity.ts +++ b/src/core/user/entities/user.entity.ts @@ -9,8 +9,8 @@ import { ManyToOne, JoinColumn, } from "typeorm"; -import { ProvenanceRecord } from "../../../infrastructure/audit/entities/provenance-record.entity"; -import { Wallet } from "../../auth/entities/wallet.entity"; +import { ProvenanceRecord } from "src/infrastructure/audit/entities/provenance-record.entity"; +import { Wallet } from "src/core/auth/entities/wallet.entity"; export enum UserRole { USER = "user", diff --git a/src/defi/defi/defi.controller.ts b/src/defi/defi.controller.ts similarity index 100% rename from src/defi/defi/defi.controller.ts rename to src/defi/defi.controller.ts diff --git a/src/defi/defi/defi.module.ts b/src/defi/defi.module.ts similarity index 100% rename from src/defi/defi/defi.module.ts rename to src/defi/defi.module.ts diff --git a/src/defi/defi/protocols/aave.adapter.ts b/src/defi/defi/protocols/aave.adapter.ts deleted file mode 100644 index 29d8f7f..0000000 --- a/src/defi/defi/protocols/aave.adapter.ts +++ /dev/null @@ -1,530 +0,0 @@ -import { Injectable, Logger } from "@nestjs/common"; -import { ConfigService } from "@nestjs/config"; -import { ethers } from "ethers"; -import { - ProtocolAdapter, - PositionData, - TransactionData, - CollateralData, - RewardData, - ProtocolMetrics, - RiskMetrics, - GasEstimate, - SimulationResult, -} from "./protocol-adapter.interface"; - -// Aave contract ABIs (simplified) -const AAVE_LENDING_POOL_ABI = [ - "function deposit(address asset,uint256 amount,address onBehalfOf,uint16 referralCode)", - "function withdraw(address asset,uint256 amount,address to)", - "function borrow(address asset,uint256 amount,uint256 interestRateMode,uint16 referralCode,address onBehalfOf)", - "function repay(address asset,uint256 amount,uint256 rateMode,address onBehalfOf)", - "function getUserAccountData(address user) returns (tuple)", - "function getReservesList() returns (address[])", -]; - -const AAVE_REWARDS_CONTROLLER_ABI = [ - "function getRewardsBalance(address[] calldata assets,address user) returns (uint256)", - "function claimRewards(address[] calldata assets,uint256 amount,address to) returns (uint256)", -]; - -@Injectable() -export class AaveAdapter implements ProtocolAdapter { - private logger = new Logger("AaveAdapter"); - name = "Aave"; - supportedChains = ["ethereum", "arbitrum", "polygon", "optimism"]; - - private providers: Map = new Map(); - private lendingPoolAddress = "0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9"; // Ethereum mainnet - private rewardsControllerAddress = - "0xd784927Ff2f95ba7a3F00302f7F038858F1b3c6e"; - - constructor(private readonly configService: ConfigService) { - this.initializeProviders(); - } - - private initializeProviders() { - this.providers.set( - "ethereum", - new ethers.JsonRpcProvider(this.configService.get("ETH_RPC_URL", "")), - ); - this.providers.set( - "arbitrum", - new ethers.JsonRpcProvider(this.configService.get("ARB_RPC_URL", "")), - ); - this.providers.set( - "polygon", - new ethers.JsonRpcProvider(this.configService.get("POLY_RPC_URL", "")), - ); - this.providers.set( - "optimism", - new ethers.JsonRpcProvider(this.configService.get("OPT_RPC_URL", "")), - ); - } - - async getPosition( - address: string, - token: string, - chain: string = "ethereum", - ): Promise { - try { - const provider = this.providers.get(chain); - if (!provider) throw new Error(`Unsupported chain: ${chain}`); - - const lendingPool = new ethers.Contract( - this.lendingPoolAddress, - AAVE_LENDING_POOL_ABI, - provider, - ); - - // Get user's aToken balance (aETH, aUSDC, etc) - const aTokenAddress = await this.getATokenAddress(token, chain); - const erc20 = new ethers.Contract( - aTokenAddress, - [ - "function balanceOf(address) returns (uint256)", - "function decimals() returns (uint8)", - ], - provider, - ); - - const balance = await erc20.balanceOf(address); - const decimals = await erc20.decimals(); - const balanceFormatted = Number(ethers.formatUnits(balance, decimals)); - - // Get token price - const priceUSD = await this.getTokenPrice(token); - const valueUSD = balanceFormatted * priceUSD; - - // Get APY - const apy = await this.getAPY(token, chain); - - // Get rewards - const rewards = await this.getRewards([aTokenAddress], address, chain); - - return { - token, - balance: balanceFormatted, - valueUSD, - apy, - rewards, - }; - } catch (error) { - this.logger.error( - `Error getting position for ${address} on ${token}`, - error, - ); - throw error; - } - } - - async getAllPositions( - address: string, - chain: string = "ethereum", - ): Promise { - try { - const provider = this.providers.get(chain); - if (!provider) throw new Error(`Unsupported chain: ${chain}`); - - const lendingPool = new ethers.Contract( - this.lendingPoolAddress, - AAVE_LENDING_POOL_ABI, - provider, - ); - const reservesList = await lendingPool.getReservesList(); - - const positions = await Promise.all( - reservesList.map((token) => this.getPosition(address, token, chain)), - ); - - return positions.filter((p) => p.balance > 0); - } catch (error) { - this.logger.error(`Error getting all positions for ${address}`, error); - throw error; - } - } - - async deposit( - address: string, - token: string, - amount: number, - chain: string = "ethereum", - ): Promise { - try { - const provider = this.providers.get(chain); - const signer = await provider.getSigner(address); - const lendingPool = new ethers.Contract( - this.lendingPoolAddress, - AAVE_LENDING_POOL_ABI, - signer, - ); - - const tokenAddress = token === "ETH" ? ethers.ZeroAddress : token; - const amountWei = ethers.parseEther(amount.toString()); - - const tx = await lendingPool.deposit.populateTransaction( - tokenAddress, - amountWei, - address, - 0, - ); - - return { - to: tx.to || "", - from: address, - value: tx.value?.toString() || "0", - data: tx.data || "", - }; - } catch (error) { - this.logger.error(`Error creating deposit transaction`, error); - throw error; - } - } - - async withdraw( - address: string, - token: string, - amount: number, - chain: string = "ethereum", - ): Promise { - try { - const provider = this.providers.get(chain); - const signer = await provider.getSigner(address); - const lendingPool = new ethers.Contract( - this.lendingPoolAddress, - AAVE_LENDING_POOL_ABI, - signer, - ); - - const tokenAddress = token === "ETH" ? ethers.ZeroAddress : token; - const amountWei = - amount === Infinity - ? ethers.MaxUint256 - : ethers.parseEther(amount.toString()); - - const tx = await lendingPool.withdraw.populateTransaction( - tokenAddress, - amountWei, - address, - ); - - return { - to: tx.to || "", - from: address, - value: tx.value?.toString() || "0", - data: tx.data || "", - }; - } catch (error) { - this.logger.error(`Error creating withdraw transaction`, error); - throw error; - } - } - - async borrow( - address: string, - token: string, - amount: number, - chain: string = "ethereum", - ): Promise { - try { - const provider = this.providers.get(chain); - const signer = await provider.getSigner(address); - const lendingPool = new ethers.Contract( - this.lendingPoolAddress, - AAVE_LENDING_POOL_ABI, - signer, - ); - - const tokenAddress = token === "ETH" ? ethers.ZeroAddress : token; - const amountWei = ethers.parseEther(amount.toString()); - const interestRateMode = 2; // Variable rate - - const tx = await lendingPool.borrow.populateTransaction( - tokenAddress, - amountWei, - interestRateMode, - 0, - address, - ); - - return { - to: tx.to || "", - from: address, - value: tx.value?.toString() || "0", - data: tx.data || "", - }; - } catch (error) { - this.logger.error(`Error creating borrow transaction`, error); - throw error; - } - } - - async repay( - address: string, - token: string, - amount: number, - chain: string = "ethereum", - ): Promise { - try { - const provider = this.providers.get(chain); - const signer = await provider.getSigner(address); - const lendingPool = new ethers.Contract( - this.lendingPoolAddress, - AAVE_LENDING_POOL_ABI, - signer, - ); - - const tokenAddress = token === "ETH" ? ethers.ZeroAddress : token; - const amountWei = - amount === Infinity - ? ethers.MaxUint256 - : ethers.parseEther(amount.toString()); - const interestRateMode = 2; // Variable rate - - const tx = await lendingPool.repay.populateTransaction( - tokenAddress, - amountWei, - interestRateMode, - address, - ); - - return { - to: tx.to || "", - from: address, - value: tx.value?.toString() || "0", - data: tx.data || "", - }; - } catch (error) { - this.logger.error(`Error creating repay transaction`, error); - throw error; - } - } - - async getCollateralData( - address: string, - chain: string = "ethereum", - ): Promise { - try { - const provider = this.providers.get(chain); - const lendingPool = new ethers.Contract( - this.lendingPoolAddress, - AAVE_LENDING_POOL_ABI, - provider, - ); - - const accountData = await lendingPool.getUserAccountData(address); - const [ - totalCollateral, - totalBorrowed, - , - currentLtv, - maxLtv, - healthFactor, - ] = accountData; - - return { - totalCollateral: Number(ethers.formatEther(totalCollateral)), - totalBorrowed: Number(ethers.formatEther(totalBorrowed)), - availableToBorrow: Math.max( - 0, - Number(ethers.formatEther(totalCollateral)) - - Number(ethers.formatEther(totalBorrowed)), - ), - ltv: Number(currentLtv), - maxLtv: Number(maxLtv), - liquidationThreshold: Number(maxLtv) * 0.8, - healthFactor: Number(ethers.formatEther(healthFactor)), - collateralBreakdown: [], - }; - } catch (error) { - this.logger.error(`Error getting collateral data`, error); - throw error; - } - } - - async getRewards( - addresses: string[], - user: string, - chain: string = "ethereum", - ): Promise { - try { - if (addresses.length === 0) return []; - - const provider = this.providers.get(chain); - const rewardsController = new ethers.Contract( - this.rewardsControllerAddress, - AAVE_REWARDS_CONTROLLER_ABI, - provider, - ); - - const rewardsBalance = await rewardsController.getRewardsBalance( - addresses, - user, - ); - const rewardsFormatted = Number(ethers.formatEther(rewardsBalance)); - - if (rewardsFormatted === 0) return []; - - return [ - { - token: "AAVE", - amount: rewardsFormatted, - valueUSD: rewardsFormatted * (await this.getTokenPrice("AAVE")), - apy: 0, // Variable - claimable: true, - }, - ]; - } catch (error) { - this.logger.error(`Error getting rewards`, error); - return []; - } - } - - async claimRewards( - address: string, - token?: string, - chain: string = "ethereum", - ): Promise { - try { - const provider = this.providers.get(chain); - const signer = await provider.getSigner(address); - const rewardsController = new ethers.Contract( - this.rewardsControllerAddress, - AAVE_REWARDS_CONTROLLER_ABI, - signer, - ); - - const positions = await this.getAllPositions(address, chain); - const aTokens = positions.map((p) => - this.getATokenAddress(p.token, chain), - ); - - const tx = await rewardsController.claimRewards.populateTransaction( - aTokens, - ethers.MaxUint256, - address, - ); - - return { - to: tx.to || "", - from: address, - value: tx.value?.toString() || "0", - data: tx.data || "", - }; - } catch (error) { - this.logger.error(`Error creating claim rewards transaction`, error); - throw error; - } - } - - async getAPY(token: string, chain: string = "ethereum"): Promise { - // Simplified - in production would fetch from protocol - return Math.random() * 15; // 0-15% APY - } - - async getTVL(): Promise { - return 10000000000; // $10B (simplified) - } - - async getProtocolMetrics(): Promise { - return { - tvl: 10000000000, - apy: 7.5, - users: 500000, - audits: ["ConsenSys", "Trail of Bits", "OpenZeppelin"], - insurance: true, - }; - } - - async getRiskMetrics( - address: string, - token: string, - chain: string = "ethereum", - ): Promise { - const collateral = await this.getCollateralData(address, chain); - - return { - smartContractRisk: 15, // 15/100 - liquidationRisk: Math.min( - 100, - (collateral.ltv / collateral.maxLtv) * 100, - ), - counterpartyRisk: 20, - priceVolatilityRisk: 30, - composabilityRisk: 25, - }; - } - - async estimateGas(tx: TransactionData): Promise { - try { - const provider = this.providers.get("ethereum"); - const gasEstimate = await provider.estimateGas({ - to: tx.to, - from: tx.from, - value: tx.value, - data: tx.data, - }); - - const feeData = await provider.getFeeData(); - const totalCost = (gasEstimate * feeData.gasPrice).toString(); - - return { - gas: Number(gasEstimate), - gasPrice: feeData.gasPrice?.toString() || "0", - totalCost, - costUSD: Number(ethers.formatEther(totalCost)) * 2500, // ETH price ~$2500 - }; - } catch (error) { - this.logger.error("Error estimating gas", error); - throw error; - } - } - - async simulateTransaction(tx: TransactionData): Promise { - try { - const provider = this.providers.get("ethereum"); - - const result = await provider.call({ - to: tx.to, - from: tx.from, - data: tx.data, - value: tx.value, - }); - - return { - success: true, - slippage: 0.5, // 0.5% assumed - }; - } catch (error) { - return { - success: false, - error: error instanceof Error ? error.message : String(error), - }; - } - } - - private async getATokenAddress( - token: string, - chain: string, - ): Promise { - // In production, would fetch from protocol data provider - const tokenMap: Record = { - USDC: "0xBcca60bB61934080951369a648Fb03DF4F96eeA3", - USDT: "0x3Ed3B47Dd13EC9a98b44e6C4C38F4c5b5e9CFaFe", - DAI: "0x028171bCA77440897B824Ca71D1c56caC55b68A3e", - }; - return tokenMap[token] || ethers.ZeroAddress; - } - - private async getTokenPrice(token: string): Promise { - // Simplified - would integrate with price oracle - const prices: Record = { - USDC: 1, - USDT: 1, - DAI: 1, - AAVE: 150, - ETH: 2500, - }; - return prices[token] || 0; - } -} \ No newline at end of file diff --git a/src/defi/defi/protocols/protocol-adapter.interface.ts b/src/defi/defi/protocols/protocol-adapter.interface.ts deleted file mode 100644 index 4b49073..0000000 --- a/src/defi/defi/protocols/protocol-adapter.interface.ts +++ /dev/null @@ -1,147 +0,0 @@ -export interface ProtocolAdapter { - name: string; - supportedChains: string[]; - - // Position Management - getPosition(address: string, token: string): Promise; - getAllPositions(address: string): Promise; - deposit( - address: string, - token: string, - amount: number, - ): Promise; - withdraw( - address: string, - token: string, - amount: number, - ): Promise; - - // Lending/Borrowing - borrow?( - address: string, - token: string, - amount: number, - ): Promise; - repay?( - address: string, - token: string, - amount: number, - ): Promise; - getCollateralData?(address: string): Promise; - - // Staking/Farming - stake?( - address: string, - token: string, - amount: number, - ): Promise; - unstake?( - address: string, - token: string, - amount: number, - ): Promise; - - // Rewards - getRewards(addresses: string[], user: string, chain?: string): Promise; - claimRewards(address: string, token?: string): Promise; - - // Metrics - getAPY(token: string): Promise; - getTVL(): Promise; - getProtocolMetrics(): Promise; - - // Risk Assessment - getRiskMetrics(address: string, token: string): Promise; - - // Gas Optimization - estimateGas(tx: TransactionData): Promise; - simulateTransaction(tx: TransactionData): Promise; - - // Swap Integration - getSwapRoute?( - tokenIn: string, - tokenOut: string, - amount: number, - ): Promise; - executeSwap?(route: SwapRoute): Promise; -} - -export interface PositionData { - token: string; - balance: number; - valueUSD: number; - apy: number; - rewards?: RewardData[]; - metadata?: Record; -} - -export interface CollateralData { - totalCollateral: number; - totalBorrowed: number; - availableToBorrow: number; - ltv: number; - maxLtv: number; - liquidationThreshold: number; - healthFactor: number; - collateralBreakdown: { token: string; amount: number; value: number }[]; -} - -export interface RewardData { - token: string; - amount: number; - valueUSD: number; - apy: number; - claimable: boolean; - nextClaimDate?: Date; -} - -export interface TransactionData { - to: string; - from: string; - value: string; - data: string; - gasLimit?: string; - gasPrice?: string; - nonce?: number; -} - -export interface GasEstimate { - gas: number; - gasPrice: string; - totalCost: string; - costUSD: number; -} - -export interface SimulationResult { - success: boolean; - outputAmount?: number; - priceImpact?: number; - slippage?: number; - error?: string; -} - -export interface ProtocolMetrics { - tvl: number; - apy: number; - users: number; - audits: string[]; - insurance?: boolean; -} - -export interface RiskMetrics { - smartContractRisk: number; - liquidationRisk: number; - counterpartyRisk: number; - priceVolatilityRisk: number; - composabilityRisk?: number; -} - -export interface SwapRoute { - tokenIn: string; - tokenOut: string; - amountIn: number; - amountOut: number; - route: string[]; - priceImpact: number; - fee: number; -} diff --git a/src/defi/defi/dto/defi.dto.ts b/src/defi/dto/defi.dto.ts similarity index 100% rename from src/defi/defi/dto/defi.dto.ts rename to src/defi/dto/defi.dto.ts diff --git a/src/defi/defi/dto/yield-strategy.dto.ts b/src/defi/dto/yield-strategy.dto.ts similarity index 100% rename from src/defi/defi/dto/yield-strategy.dto.ts rename to src/defi/dto/yield-strategy.dto.ts diff --git a/src/defi/defi/entities/defi-position.entity.ts b/src/defi/entities/defi-position.entity.ts similarity index 98% rename from src/defi/defi/entities/defi-position.entity.ts rename to src/defi/entities/defi-position.entity.ts index 86ffaed..e00c8aa 100644 --- a/src/defi/defi/entities/defi-position.entity.ts +++ b/src/defi/entities/defi-position.entity.ts @@ -8,7 +8,7 @@ import { UpdateDateColumn, Index, } from "typeorm"; -import { User } from "../../../core/user/entities/user.entity"; +import { User } from "src/core/user/entities/user.entity"; import { DeFiYieldRecord } from "./defi-yield-record.entity"; import { DeFiTransaction } from "./defi-transaction.entity"; diff --git a/src/defi/defi/entities/defi-risk-assessment.entity.ts b/src/defi/entities/defi-risk-assessment.entity.ts similarity index 100% rename from src/defi/defi/entities/defi-risk-assessment.entity.ts rename to src/defi/entities/defi-risk-assessment.entity.ts diff --git a/src/defi/defi/entities/defi-transaction.entity.ts b/src/defi/entities/defi-transaction.entity.ts similarity index 100% rename from src/defi/defi/entities/defi-transaction.entity.ts rename to src/defi/entities/defi-transaction.entity.ts diff --git a/src/defi/defi/entities/defi-yield-record.entity.ts b/src/defi/entities/defi-yield-record.entity.ts similarity index 100% rename from src/defi/defi/entities/defi-yield-record.entity.ts rename to src/defi/entities/defi-yield-record.entity.ts diff --git a/src/defi/defi/entities/defi-yield-strategy.entity.ts b/src/defi/entities/defi-yield-strategy.entity.ts similarity index 97% rename from src/defi/defi/entities/defi-yield-strategy.entity.ts rename to src/defi/entities/defi-yield-strategy.entity.ts index cb9241a..b81005e 100644 --- a/src/defi/defi/entities/defi-yield-strategy.entity.ts +++ b/src/defi/entities/defi-yield-strategy.entity.ts @@ -7,7 +7,7 @@ import { UpdateDateColumn, Index, } from "typeorm"; -import { User } from "../../../core/user/entities/user.entity"; +import { User } from "src/core/user/entities/user.entity"; export enum StrategyType { HIGHEST_YIELD = "highest_yield", diff --git a/src/defi/protocols/aave.adapter.ts b/src/defi/protocols/aave.adapter.ts index 7d5bbb2..29d8f7f 100644 --- a/src/defi/protocols/aave.adapter.ts +++ b/src/defi/protocols/aave.adapter.ts @@ -1,4 +1,5 @@ import { Injectable, Logger } from "@nestjs/common"; +import { ConfigService } from "@nestjs/config"; import { ethers } from "ethers"; import { ProtocolAdapter, @@ -38,26 +39,26 @@ export class AaveAdapter implements ProtocolAdapter { private rewardsControllerAddress = "0xd784927Ff2f95ba7a3F00302f7F038858F1b3c6e"; - constructor() { + constructor(private readonly configService: ConfigService) { this.initializeProviders(); } private initializeProviders() { this.providers.set( "ethereum", - new ethers.JsonRpcProvider(process.env.ETH_RPC_URL || ""), + new ethers.JsonRpcProvider(this.configService.get("ETH_RPC_URL", "")), ); this.providers.set( "arbitrum", - new ethers.JsonRpcProvider(process.env.ARB_RPC_URL || ""), + new ethers.JsonRpcProvider(this.configService.get("ARB_RPC_URL", "")), ); this.providers.set( "polygon", - new ethers.JsonRpcProvider(process.env.POLY_RPC_URL || ""), + new ethers.JsonRpcProvider(this.configService.get("POLY_RPC_URL", "")), ); this.providers.set( "optimism", - new ethers.JsonRpcProvider(process.env.OPT_RPC_URL || ""), + new ethers.JsonRpcProvider(this.configService.get("OPT_RPC_URL", "")), ); } @@ -526,4 +527,4 @@ export class AaveAdapter implements ProtocolAdapter { }; return prices[token] || 0; } -} +} \ No newline at end of file diff --git a/src/defi/defi/protocols/compound.adapter.ts b/src/defi/protocols/compound.adapter.ts similarity index 100% rename from src/defi/defi/protocols/compound.adapter.ts rename to src/defi/protocols/compound.adapter.ts diff --git a/src/defi/protocols/protocol-adapter.interface.ts b/src/defi/protocols/protocol-adapter.interface.ts index c6e5d8c..4b49073 100644 --- a/src/defi/protocols/protocol-adapter.interface.ts +++ b/src/defi/protocols/protocol-adapter.interface.ts @@ -1,16 +1,78 @@ +export interface ProtocolAdapter { + name: string; + supportedChains: string[]; + + // Position Management + getPosition(address: string, token: string): Promise; + getAllPositions(address: string): Promise; + deposit( + address: string, + token: string, + amount: number, + ): Promise; + withdraw( + address: string, + token: string, + amount: number, + ): Promise; + + // Lending/Borrowing + borrow?( + address: string, + token: string, + amount: number, + ): Promise; + repay?( + address: string, + token: string, + amount: number, + ): Promise; + getCollateralData?(address: string): Promise; + + // Staking/Farming + stake?( + address: string, + token: string, + amount: number, + ): Promise; + unstake?( + address: string, + token: string, + amount: number, + ): Promise; + + // Rewards + getRewards(addresses: string[], user: string, chain?: string): Promise; + claimRewards(address: string, token?: string): Promise; + + // Metrics + getAPY(token: string): Promise; + getTVL(): Promise; + getProtocolMetrics(): Promise; + + // Risk Assessment + getRiskMetrics(address: string, token: string): Promise; + + // Gas Optimization + estimateGas(tx: TransactionData): Promise; + simulateTransaction(tx: TransactionData): Promise; + + // Swap Integration + getSwapRoute?( + tokenIn: string, + tokenOut: string, + amount: number, + ): Promise; + executeSwap?(route: SwapRoute): Promise; +} + export interface PositionData { token: string; balance: number; valueUSD: number; apy: number; - rewards: RewardData[]; -} - -export interface TransactionData { - to: string; - from: string; - value: string; - data: string; + rewards?: RewardData[]; + metadata?: Record; } export interface CollateralData { @@ -21,7 +83,7 @@ export interface CollateralData { maxLtv: number; liquidationThreshold: number; healthFactor: number; - collateralBreakdown: any[]; + collateralBreakdown: { token: string; amount: number; value: number }[]; } export interface RewardData { @@ -30,22 +92,17 @@ export interface RewardData { valueUSD: number; apy: number; claimable: boolean; + nextClaimDate?: Date; } -export interface ProtocolMetrics { - tvl: number; - apy: number; - users: number; - audits: string[]; - insurance: boolean; -} - -export interface RiskMetrics { - smartContractRisk: number; - liquidationRisk: number; - counterpartyRisk: number; - priceVolatilityRisk: number; - composabilityRisk: number; +export interface TransactionData { + to: string; + from: string; + value: string; + data: string; + gasLimit?: string; + gasPrice?: string; + nonce?: number; } export interface GasEstimate { @@ -57,26 +114,34 @@ export interface GasEstimate { export interface SimulationResult { success: boolean; + outputAmount?: number; + priceImpact?: number; slippage?: number; error?: string; } -export interface ProtocolAdapter { - name: string; - supportedChains: string[]; - getPosition(address: string, token: string, chain?: string): Promise; - getAllPositions(address: string, chain?: string): Promise; - deposit(address: string, token: string, amount: number, chain?: string): Promise; - withdraw(address: string, token: string, amount: number, chain?: string): Promise; - borrow(address: string, token: string, amount: number, chain?: string): Promise; - repay(address: string, token: string, amount: number, chain?: string): Promise; - getCollateralData(address: string, chain?: string): Promise; - getRewards(addresses: string[], user: string, chain?: string): Promise; - claimRewards(address: string, token?: string, chain?: string): Promise; - getAPY(token: string, chain?: string): Promise; - getTVL(): Promise; - getProtocolMetrics(): Promise; - getRiskMetrics(address: string, token: string, chain?: string): Promise; - estimateGas(tx: TransactionData): Promise; - simulateTransaction(tx: TransactionData): Promise; +export interface ProtocolMetrics { + tvl: number; + apy: number; + users: number; + audits: string[]; + insurance?: boolean; +} + +export interface RiskMetrics { + smartContractRisk: number; + liquidationRisk: number; + counterpartyRisk: number; + priceVolatilityRisk: number; + composabilityRisk?: number; +} + +export interface SwapRoute { + tokenIn: string; + tokenOut: string; + amountIn: number; + amountOut: number; + route: string[]; + priceImpact: number; + fee: number; } diff --git a/src/defi/defi/protocols/protocol-registry.ts b/src/defi/protocols/protocol-registry.ts similarity index 100% rename from src/defi/defi/protocols/protocol-registry.ts rename to src/defi/protocols/protocol-registry.ts diff --git a/src/defi/defi/services/position-tracking.service.ts b/src/defi/services/position-tracking.service.ts similarity index 100% rename from src/defi/defi/services/position-tracking.service.ts rename to src/defi/services/position-tracking.service.ts diff --git a/src/defi/defi/services/risk-assessment.service.ts b/src/defi/services/risk-assessment.service.ts similarity index 100% rename from src/defi/defi/services/risk-assessment.service.ts rename to src/defi/services/risk-assessment.service.ts diff --git a/src/defi/defi/services/transaction-optimization.service.ts b/src/defi/services/transaction-optimization.service.ts similarity index 100% rename from src/defi/defi/services/transaction-optimization.service.ts rename to src/defi/services/transaction-optimization.service.ts diff --git a/src/defi/defi/services/yield-optimization.service.ts b/src/defi/services/yield-optimization.service.ts similarity index 100% rename from src/defi/defi/services/yield-optimization.service.ts rename to src/defi/services/yield-optimization.service.ts diff --git a/src/defi/defi/trade-lock.service.ts b/src/defi/trade-lock.service.ts similarity index 100% rename from src/defi/defi/trade-lock.service.ts rename to src/defi/trade-lock.service.ts diff --git a/src/defi/defi/trade.controller.ts b/src/defi/trade.controller.ts similarity index 93% rename from src/defi/defi/trade.controller.ts rename to src/defi/trade.controller.ts index b804a18..945e7bc 100644 --- a/src/defi/defi/trade.controller.ts +++ b/src/defi/trade.controller.ts @@ -1,5 +1,5 @@ import { Controller, Post, Body, Req, UseGuards, Headers } from '@nestjs/common'; -import { JwtAuthGuard } from '../../core/auth/jwt.guard'; +import { JwtAuthGuard } from 'src/core/auth/jwt.guard'; import { TradeLockService } from './trade-lock.service'; @Controller('trading') diff --git a/src/infrastructure/audit/entities/agent-event.entity.ts b/src/infrastructure/audit/entities/agent-event.entity.ts index 8262857..aeefc44 100644 --- a/src/infrastructure/audit/entities/agent-event.entity.ts +++ b/src/infrastructure/audit/entities/agent-event.entity.ts @@ -7,7 +7,7 @@ import { ManyToOne, JoinColumn, } from "typeorm"; -import { User } from "../../../core/user/entities/user.entity"; +import { User } from "src/core/user/entities/user.entity"; export enum AgentEventType { CREATED = "created", diff --git a/src/infrastructure/audit/entities/compute-result.entity.ts b/src/infrastructure/audit/entities/compute-result.entity.ts index bdf2ae9..9d119d3 100644 --- a/src/infrastructure/audit/entities/compute-result.entity.ts +++ b/src/infrastructure/audit/entities/compute-result.entity.ts @@ -8,7 +8,7 @@ import { ManyToOne, JoinColumn, } from "typeorm"; -import { User } from "../../../core/user/entities/user.entity"; +import { User } from "src/core/user/entities/user.entity"; export enum ComputeResultStatus { PENDING = "pending", diff --git a/src/infrastructure/audit/entities/oracle-submission.entity.ts b/src/infrastructure/audit/entities/oracle-submission.entity.ts index c64d30d..8b6a9cb 100644 --- a/src/infrastructure/audit/entities/oracle-submission.entity.ts +++ b/src/infrastructure/audit/entities/oracle-submission.entity.ts @@ -8,7 +8,7 @@ import { ManyToOne, JoinColumn, } from "typeorm"; -import { User } from "../../../core/user/entities/user.entity"; +import { User } from "src/core/user/entities/user.entity"; export enum OracleSubmissionStatus { PENDING = "pending", diff --git a/src/infrastructure/audit/entities/provenance-record.entity.ts b/src/infrastructure/audit/entities/provenance-record.entity.ts index d70b736..b3fa177 100644 --- a/src/infrastructure/audit/entities/provenance-record.entity.ts +++ b/src/infrastructure/audit/entities/provenance-record.entity.ts @@ -7,7 +7,7 @@ import { ManyToOne, JoinColumn, } from "typeorm"; -import { User } from "../../../core/user/entities/user.entity"; +import { User } from "src/core/user/entities/user.entity"; export enum ProvenanceStatus { PENDING = "pending", diff --git a/src/infrastructure/audit/guards/provenance-access.guard.ts b/src/infrastructure/audit/guards/provenance-access.guard.ts index df897d1..4ca7696 100644 --- a/src/infrastructure/audit/guards/provenance-access.guard.ts +++ b/src/infrastructure/audit/guards/provenance-access.guard.ts @@ -4,7 +4,7 @@ import { ExecutionContext, ForbiddenException, } from "@nestjs/common"; -import { UserRole } from "../../../core/user/entities/user.entity"; +import { UserRole } from "src/core/user/entities/user.entity"; /** * Guard that ensures users can only access their own provenance records. diff --git a/src/infrastructure/audit/provenance.controller.ts b/src/infrastructure/audit/provenance.controller.ts index 949b6b5..abd3c58 100644 --- a/src/infrastructure/audit/provenance.controller.ts +++ b/src/infrastructure/audit/provenance.controller.ts @@ -31,7 +31,7 @@ import { ProvenanceVerificationResultDto, ProvenanceTimelineResponseDto, } from "./dto/provenance-response.dto"; -import { JwtAuthGuard } from "../../core/auth/jwt.guard"; +import { JwtAuthGuard } from "src/core/auth/jwt.guard"; import { ProvenanceAccessGuard } from "./guards/provenance-access.guard"; @ApiTags("Provenance") diff --git a/src/investment/portfolio/entities/risk-profile.entity.ts b/src/investment/portfolio/entities/risk-profile.entity.ts index a33f226..78e5ac0 100644 --- a/src/investment/portfolio/entities/risk-profile.entity.ts +++ b/src/investment/portfolio/entities/risk-profile.entity.ts @@ -7,7 +7,7 @@ import { ManyToOne, JoinColumn, } from "typeorm"; -import { User } from "../../../core/user/entities/user.entity"; +import { User } from "src/core/user/entities/user.entity"; export enum RiskTolerance { VERY_CONSERVATIVE = "very_conservative", diff --git a/src/investment/risk-management/risk-management.controller.ts b/src/investment/risk-management/risk-management.controller.ts index 3ab8927..8bcf2b0 100644 --- a/src/investment/risk-management/risk-management.controller.ts +++ b/src/investment/risk-management/risk-management.controller.ts @@ -7,7 +7,7 @@ import { Query, UseGuards, } from "@nestjs/common"; -import { JwtAuthGuard } from "../../core/auth/jwt.guard"; +import { JwtAuthGuard } from "src/core/auth/jwt.guard"; import { RiskManagementService } from "./risk-management.service"; import { RiskConfigDto, PositionSizeDto } from "./dto/risk.dto"; import { CircuitBreakerService } from "./circuit-breaker.service"; diff --git a/tsconfig.json b/tsconfig.json index e08f633..73138c5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,6 +12,9 @@ "outDir": "./dist", "rootDir": "./src", "baseUrl": "./", + "paths": { + "src/*": ["src/*"] + }, "types": ["node", "jest"], "moduleResolution": "node", "resolveJsonModule": true,