Skip to main content

Class: ChromaticPosition

Represents a Chromatic position and provides methods to interact with it.

Constructors

constructor

new ChromaticPosition(_client)

Creates a new instance of ChromaticPosition.

Parameters

NameTypeDescription
_clientClientThe Chromatic Client instance.

Defined in

packages/sdk-viem/src/entities/ChromaticPosition.ts:82

Methods

contracts

contracts(): Object

Retrieves the contract instances associated with Chromatic Position.

Returns

Object

An object containing the contract instances of Lens, Market, and Market Factory.

NameType
lensContractChromaticLens
market(marketAddress: `0x${string}`) => ContractChromaticMarket
marketFactoryContractChromaticFactory

Defined in

packages/sdk-viem/src/entities/ChromaticPosition.ts:88


getInterest

getInterest(marketAddress, position): Promise<bigint>

Retrieves the interest for a position in the specified market.

Parameters

NameTypeDescription
marketAddress`0x${string}`The address of the Chromatic Market contract.
positionInterestParamThe position parameters.

Returns

Promise<bigint>

A promise that resolves to the interest.

Defined in

packages/sdk-viem/src/entities/ChromaticPosition.ts:173


getInterestRateRecords

getInterestRateRecords(marketAddress): Promise<InterestRateRecord[]>

Retrieves the interest rate records for the specified market address.

Parameters

NameTypeDescription
marketAddress`0x${string}`The address of the Chromatic Market contract.

Returns

Promise<InterestRateRecord[]>

A promise that resolves to an array of interest rate records.

Defined in

packages/sdk-viem/src/entities/ChromaticPosition.ts:140


getLiquidationPrice

getLiquidationPrice(marketAddress, entryPrice, position): Promise<{ lossCutPrice: undefined | bigint ; profitStopPrice: undefined | bigint }>

Calculates the liquidation price for a position in the specified market.

Parameters

NameTypeDescription
marketAddress`0x${string}`The address of the Chromatic Market contract.
entryPriceundefined | bigintThe entry price of the position.
positionPositionParamThe position parameters.

Returns

Promise<{ lossCutPrice: undefined | bigint ; profitStopPrice: undefined | bigint }>

A promise that resolves to an object containing the profit stop price and loss cut price.

Defined in

packages/sdk-viem/src/entities/ChromaticPosition.ts:229


getPnl

getPnl(marketAddress, entryPrice, exitPrice, position, options?): Promise<bigint>

Calculates the profit and loss (PNL) for a position in the specified market.

Parameters

NameTypeDescription
marketAddress`0x${string}`The address of the Chromatic Market contract.
entryPricebigintThe entry price of the position.
exitPricebigintThe exit price of the position.
positionPositionParamThe position parameters.
optionsObjectOptional parameters for PNL calculation.
options.includeInterestboolean-

Returns

Promise<bigint>

A promise that resolves to the PNL value.

Defined in

packages/sdk-viem/src/entities/ChromaticPosition.ts:206


getPositions

getPositions(marketAddress, positionIds): Promise<IPosition[]>

Retrieves positions from the Chromatic Market contract.

Parameters

NameTypeDescription
marketAddress`0x${string}`The address of the Chromatic Market contract.
positionIdsbigint[]An array of position IDs.

Returns

Promise<IPosition[]>

A promise that resolves to an array of positions.

Defined in

packages/sdk-viem/src/entities/ChromaticPosition.ts:102


lossCutPrice

lossCutPrice(marketAddress, entryPrice, position): Promise<undefined | bigint>

Calculates the loss cut price for a position in the specified market.

Parameters

NameTypeDescription
marketAddress`0x${string}`The address of the Chromatic Market contract.
entryPriceundefined | bigintThe entry price of the position.
positionPositionParamThe position parameters.

Returns

Promise<undefined | bigint>

A promise that resolves to the loss cut price.

Defined in

packages/sdk-viem/src/entities/ChromaticPosition.ts:285


profitStopPrice

profitStopPrice(marketAddress, entryPrice, position): Promise<undefined | bigint>

Calculates the profit stop price for a position in the specified market.

Parameters

NameTypeDescription
marketAddress`0x${string}`The address of the Chromatic Market contract.
entryPriceundefined | bigintThe entry price of the position.
positionPositionParamThe position parameters.

Returns

Promise<undefined | bigint>

A promise that resolves to the profit stop price.

Defined in

packages/sdk-viem/src/entities/ChromaticPosition.ts:268