Skip to main content

Hyperdrive SDK

Classes

Interfaces

Type Aliases

Checkpoint

Ƭ Checkpoint: FunctionReturn<typeof IHyperdrive.abi, "getCheckpoint">

Defined in

packages/hyperdrive-js-core/src/pool/Checkpoint.ts:4


PoolConfig

Ƭ PoolConfig: FunctionReturn<typeof IHyperdrive.abi, "getPoolConfig">

Defined in

packages/hyperdrive-js-core/src/pool/PoolConfig.ts:7


PoolInfo

Ƭ PoolInfo: FunctionReturn<typeof IHyperdrive.abi, "getPoolInfo">

Defined in

packages/hyperdrive-js-core/src/pool/PoolInfo.ts:7


ReadContractFactory

Ƭ ReadContractFactory: <TAbi>(options: ContractFactoryOptions<TAbi>) => CachedReadContract<TAbi>

A factory function that creates a CachedReadContract instance.

Type declaration

▸ <TAbi>(options): CachedReadContract<TAbi>

Type parameters
NameType
TAbiextends Abi = Abi
Parameters
NameType
optionsContractFactoryOptions<TAbi>
Returns

CachedReadContract<TAbi>

Defined in

packages/hyperdrive-js-core/src/evm-client/contractFactory.ts:18


ReadContractModelOptions

Ƭ ReadContractModelOptions: Prettify<ReadModelOptions & Omit<ContractFactoryOptions, "abi">>

The options required to create a read model that represents a specific contract.

Defined in

packages/hyperdrive-js-core/src/model/ReadModel.ts:42


ReadWriteContractFactory

Ƭ ReadWriteContractFactory: <TAbi>(options: ContractFactoryOptions<TAbi>) => CachedReadWriteContract<TAbi>

A factory function that creates a CachedReadWriteContract instance.

Type declaration

▸ <TAbi>(options): CachedReadWriteContract<TAbi>

Type parameters
NameType
TAbiextends Abi = Abi
Parameters
NameType
optionsContractFactoryOptions<TAbi>
Returns

CachedReadWriteContract<TAbi>

Defined in

packages/hyperdrive-js-core/src/evm-client/contractFactory.ts:25


ReadWriteContractModelOptions

Ƭ ReadWriteContractModelOptions: Prettify<ReadWriteModelOptions & Omit<ContractFactoryOptions, "abi">>

The options required to create a read-write model that represents a specific contract.

Defined in

packages/hyperdrive-js-core/src/model/ReadWriteModel.ts:30

Functions

adjustAmountByPercentage

adjustAmountByPercentage(«destructured»): bigint

Adjusts a given amount by some percentage. Useful for slippage calculations.

Example:

adjustAmountByPercentage({
amount: parseUnits("100", 18),
decimals: 18,
percentage: 1n
direction: "down",
}) === parseUnits("99")
adjustAmountByPercentage({
amount: parseUnits("100", 18),
decimals: 18,
percentage: 1n
direction: "up",
}) === parseUnits("101")

Parameters

NameType
«destructured»AdjustAmountByPercentageOptions

Returns

bigint

Defined in

packages/hyperdrive-js-core/src/base/adjustAmountByPercentage.ts:41


calculateAprFromPrice

calculateAprFromPrice(«destructured»): bigint

From alex:

APR (fixed rate) t = term length in year fractions (0.5 = 6 months) p0 = base amount p1 = bond amount r = ((p1 / p0) - 1) / t

Parameters

NameType
«destructured»Object
› baseAmountbigint
› bondAmountbigint
› positionDurationbigint

Returns

bigint

Defined in

packages/hyperdrive-js-core/src/hyperdrive/utils/calculateAprFromPrice.ts:12


calculateMatureLongYieldAfterFees

calculateMatureLongYieldAfterFees(«destructured»): bigint

Parameters

NameType
«destructured»Object
› baseAmountPaidbigint
› bondAmountbigint
› decimalsnumber
› flatFeebigint

Returns

bigint

Defined in

packages/hyperdrive-js-core/src/longs/calculateMatureLongYieldAfterFees.ts:2


getCheckpointId

getCheckpointId(blockTimestamp, checkpointDuration): bigint

Parameters

NameType
blockTimestampbigint
checkpointDurationbigint

Returns

bigint

Defined in

packages/hyperdrive-js-core/src/pool/getCheckpointId.ts:1


multiplyBigInt

multiplyBigInt(values, decimals): bigint

Multiply an array of bigints together and preserve the correct scaling for decimals.

Parameters

NameTypeDescription
valuesbigint[]The bigints to multiply.
decimalsnumberThe number of decimal places the bigints are scaled to.

Returns

bigint

Example

// 5.00 * .50 = 2.50
multiplyBigInt([500n, 50n], 2);
// 250n

@deprecated use dnum instead

#### Defined in

packages/hyperdrive-js-core/src/base/multiplyBigInt/multiplyBigInt.ts:17