Skip to main content

PositionsModule

@liquidium/client


@liquidium/client / PositionsModule

Class: PositionsModule

Defined in: packages/client/src/modules/positions/positions.ts:31

Profile position, health factor, and reserve valuation helpers.

Constructors

Constructor

new PositionsModule(canisterContext, market): PositionsModule

Defined in: packages/client/src/modules/positions/positions.ts:32

Parameters

canisterContext

CanisterContext

market

MarketModule

Returns

PositionsModule

Properties

market

readonly market: MarketModule

Defined in: packages/client/src/modules/positions/positions.ts:34

Methods

getFullWithdrawAmount()

getFullWithdrawAmount(profileId, poolId): Promise<FullWithdrawAmount>

Defined in: packages/client/src/modules/positions/positions.ts:283

Returns the current full withdraw amount for a position.

Position.deposited already reflects the current supplied balance at the latest lending index; do not add earnedInterest to this amount. Pass amount to withdraw calls and use decimals for display formatting.

Parameters

profileId

string

The Liquidium profile principal text.

poolId

string

The pool principal text.

Returns

Promise<FullWithdrawAmount>

Full withdraw amount in the supplied asset's base units.


getHealthFactor()

getHealthFactor(profileId): Promise<HealthFactor>

Defined in: packages/client/src/modules/positions/positions.ts:113

Returns the current health factor for a profile.

Parameters

profileId

string

The Liquidium profile principal text.

Returns

Promise<HealthFactor>

The current health factor for the requested profile.


getMaxRepayAmount()

getMaxRepayAmount(profileId, poolId, bufferBps?): Promise<MaxRepayAmount>

Defined in: packages/client/src/modules/positions/positions.ts:252

Returns the full repayment amount for a position, with a small buffer to account for interest that accrues between quote and submit.

Parameters

profileId

string

The Liquidium profile principal text.

poolId

string

The pool principal text.

bufferBps?

bigint = DEFAULT_REPAY_BUFFER_BPS

Optional buffer in basis points (default 10 = 0.1%).

Returns

Promise<MaxRepayAmount>

Buffered repayment amount in the borrowed asset's base units.


getPosition()

getPosition(profileId, poolId): Promise<Position | null>

Defined in: packages/client/src/modules/positions/positions.ts:44

Returns a single position for a profile and pool.

Parameters

profileId

string

The Liquidium profile principal text.

poolId

string

The pool principal text.

Returns

Promise<Position | null>

The position for the requested profile and pool, or null when no position exists.


getUserPositionSummary()

getUserPositionSummary(profileId): Promise<UserPositionSummary>

Defined in: packages/client/src/modules/positions/positions.ts:167

Returns an aggregate summary of a profile's position.

Single canister round-trip (get_health_factor). Derived fields: availableBorrowsUsd = max(0, maxBorrowableUsd - debt), netWorthUsd = collateral - debt (may be negative if underwater), currentLtvBps = debt * 10_000 / collateral (0 when collateral is 0).

Parameters

profileId

string

The Liquidium profile principal text.

Returns

Promise<UserPositionSummary>

Derived position summary for the requested profile.


getUserReserves()

getUserReserves(profileId): Promise<UserReserve[]>

Defined in: packages/client/src/modules/positions/positions.ts:203

Returns the per-reserve breakdown of a profile's supplies and borrows, joined with pool metadata, rates, and current USD prices.

USD values are scaled to 27 decimals.

Parameters

profileId

string

The Liquidium profile principal text.

Returns

Promise<UserReserve[]>

Per-reserve position rows joined with pool metadata and USD values.


getUserStats()

getUserStats(profileId): Promise<UserStats>

Defined in: packages/client/src/modules/positions/positions.ts:140

Returns aggregate borrowing and collateral stats for a profile.

Parameters

profileId

string

The Liquidium profile principal text.

Returns

Promise<UserStats>

Aggregate debt, collateral, and borrowing power metrics for the requested profile.


listPositions()

listPositions(profileId): Promise<Position[]>

Defined in: packages/client/src/modules/positions/positions.ts:79

Lists all positions for a profile.

Parameters

profileId

string

The Liquidium profile principal text.

Returns

Promise<Position[]>

All positions currently associated with the requested profile.