Skip to main content

PositionsModule

@liquidium/client


@liquidium/client / PositionsModule

Class: PositionsModule

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

Profile position, health factor, and reserve valuation helpers.

Constructors​

Constructor​

new PositionsModule(canisterContext, market): PositionsModule

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

Parameters​

canisterContext​

CanisterContext

market​

MarketModule

Returns​

PositionsModule

Properties​

market​

readonly market: MarketModule

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

Methods​

getFullWithdrawAmount()​

getFullWithdrawAmount(profileId, poolId): Promise<FullWithdrawAmount>

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

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:131

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:279

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:45

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:188

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:230

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

Supplied-only reserves below their pool's same-asset dust threshold are omitted. Reserves with active debt remain, with their supplied amount and earned interest set to zero when the supplied balance is below the threshold.

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:161

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:81

Lists visible positions for a profile. Supply balances below their pool's same-asset dust threshold are hidden without removing active debt.

Parameters​

profileId​

string

The Liquidium profile principal text.

Returns​

Promise<Position[]>

Visible positions currently associated with the requested profile.