Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Simple version of clean architecture

- Interfaces for API, request and payload interfaces, each enums and value types are considered an entity
- Usually each entity will be in each own file, and named with proper prefixes that gives the most relevant context
- Prefer interface over type, use type if union is needed

## View layer

Expand Down
15 changes: 15 additions & 0 deletions module/portfolio/data/entities/hyperlend/CoreHealthData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { CoreLendingPosition } from './CoreLendingPosition';

/**
* Entity representing health and position data for HyperLend Core module
*/
export interface CoreHealthData {
/** Array of lending positions in Core module */
positions: CoreLendingPosition[];
/** Health factor (null if no borrows, meaning no liquidation risk) */
healthFactor: string | null;
/** Total supplied in USD across all assets */
totalSuppliedUSD: string;
/** Total borrowed in USD across all assets */
totalBorrowedUSD: string;
}
23 changes: 23 additions & 0 deletions module/portfolio/data/entities/hyperlend/CoreLendingPosition.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Entity representing a lending position in HyperLend Core module (Aave v3.2 fork)
*/
export interface CoreLendingPosition {
/** Asset symbol (e.g., "USDC", "HYPE") */
asset: string;
/** Supply balance in token units */
supplyBalance: string;
/** Supply balance in USD */
supplyBalanceUSD: string;
/** Borrow balance in token units */
borrowBalance: string;
/** Borrow balance in USD */
borrowBalanceUSD: string;
/** Supply APY (annual percentage yield) as percentage */
supplyAPY: string;
/** Borrow APY (annual percentage rate) as percentage */
borrowAPY: string;
/** Whether this asset is being used as collateral */
isCollateral: boolean;
/** Liquidation price (optional, only when borrowed) */
liquidationPrice?: string;
}
12 changes: 12 additions & 0 deletions module/portfolio/data/entities/hyperlend/HyperLendData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { CoreHealthData } from './CoreHealthData';
import type { IsolatedHealthData } from './IsolatedHealthData';

/**
* Entity representing aggregated HyperLend data across both Core and Isolated modules
*/
export interface HyperLendData {
/** Core module (Aave v3.2 fork) lending data */
core: CoreHealthData;
/** Isolated module (pair-based) lending data */
isolated: IsolatedHealthData;
}
15 changes: 15 additions & 0 deletions module/portfolio/data/entities/hyperlend/IsolatedHealthData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { IsolatedLendingPosition } from './IsolatedLendingPosition';

/**
* Entity representing health and position data for HyperLend Isolated module
*/
export interface IsolatedHealthData {
/** Array of lending positions in Isolated module */
positions: IsolatedLendingPosition[];
/** Health factor (null if no borrows, meaning no liquidation risk) */
healthFactor: string | null;
/** Total supplied in USD across all pairs */
totalSuppliedUSD: string;
/** Total borrowed in USD across all pairs */
totalBorrowedUSD: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Entity representing a lending position in HyperLend Isolated module (pair-based lending)
*/
export interface IsolatedLendingPosition {
/** Pair contract address */
pairAddress: string;
/** Asset symbol being supplied */
assetSymbol: string;
/** Collateral symbol being used */
collateralSymbol: string;
/** Supply balance in token units */
supplyBalance: string;
/** Supply balance in USD */
supplyBalanceUSD: string;
/** Borrow balance in token units */
borrowBalance: string;
/** Borrow balance in USD */
borrowBalanceUSD: string;
/** Supply APY (annual percentage yield) as percentage */
supplyAPY: string;
/** Borrow APY (annual percentage rate) as percentage */
borrowAPY: string;
/** Liquidation price for this isolated pair */
liquidationPrice: string;
}
7 changes: 4 additions & 3 deletions module/portfolio/data/repository/PortfolioRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import type {
SpotClearinghouseState,
PerpClearinghouseState,
OpenOrder,
HyperLendPosition,
PendleMarketPosition,
ERC20Balance,
} from '../types';
import type { HyperLendData } from '../entities/hyperlend/HyperLendData';

/**
* Repository interface for portfolio data retrieval
Expand Down Expand Up @@ -33,9 +33,10 @@ export interface PortfolioRepository {
getHyperEvmBalance(address: string): Promise<string>;

/**
* Get HyperLend positions for an address
* Get HyperLend data (Core and Isolated modules) for an address
* Includes positions, health factors, and totals
*/
getHyperLendPositions(address: string): Promise<HyperLendPosition[]>;
getHyperLendData(address: string): Promise<HyperLendData>;

/**
* Get Pendle positions for an address
Expand Down
6 changes: 3 additions & 3 deletions module/portfolio/data/repository/PortfolioRepositoryImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import type {
SpotClearinghouseState,
PerpClearinghouseState,
OpenOrder,
HyperLendPosition,
PendleMarketPosition,
ERC20Balance,
} from '../types';
import type { HyperLendData } from '../entities/hyperlend/HyperLendData';

// Smart contract addresses
const CONTRACT_ADDRESSES = {
Expand Down Expand Up @@ -67,8 +67,8 @@ export class PortfolioRepositoryImpl implements PortfolioRepository {
return this.hyperliquidService.getHyperEvmBalance(address);
}

async getHyperLendPositions(address: string): Promise<HyperLendPosition[]> {
return this.hyperLendService.getPositions(address);
async getHyperLendData(address: string): Promise<HyperLendData> {
return this.hyperLendService.getAllData(address);
}

async getPendlePositions(address: string): Promise<PendleMarketPosition[]> {
Expand Down
Loading