Hyperdrive SDK
Classes
- ReadErc20
- ReadErc4626
- ReadErc4626Hyperdrive
- ReadEth
- ReadEzEthHyperdrive
- ReadHyperdrive
- ReadLsEth
- ReadLsEthHyperdrive
- ReadMetaMorphoHyperdrive
- ReadMockErc4626
- ReadMockErc4626Hyperdrive
- ReadModel
- ReadREth
- ReadREthHyperdrive
- ReadStEth
- ReadStEthHyperdrive
- ReadWriteErc20
- ReadWriteErc4626
- ReadWriteErc4626Hyperdrive
- ReadWriteEth
- ReadWriteEzEthHyperdrive
- ReadWriteHyperdrive
- ReadWriteLsEth
- ReadWriteLsEthHyperdrive
- ReadWriteMockErc4626
- ReadWriteMockErc4626Hyperdrive
- ReadWriteModel
- ReadWriteREth
- ReadWriteREthHyperdrive
- ReadWriteStEth
- ReadWriteStEthHyperdrive
Interfaces
- ClosedLong
- ClosedLpShares
- ClosedShort
- ContractFactoryOptions
- Long
- OpenShort
- ReadErc20Options
- ReadEthOptions
- ReadHyperdriveOptions
- ReadModelOptions
- ReadStEthHyperdriveOptions
- ReadToken
- ReadWriteErc20Options
- ReadWriteEthOptions
- ReadWriteHyperdriveOptions
- ReadWriteModelOptions
- ReadWriteStEthHyperdriveOptions
- ReadWriteToken
- RedeemedWithdrawalShares
- Short
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
Name | Type |
---|---|
TAbi | extends Abi = Abi |
Parameters
Name | Type |
---|---|
options | ContractFactoryOptions <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
Name | Type |
---|---|
TAbi | extends Abi = Abi |
Parameters
Name | Type |
---|---|
options | ContractFactoryOptions <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
Name | Type |
---|---|
«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
Name | Type |
---|---|
«destructured» | Object |
› baseAmount | bigint |
› bondAmount | bigint |
› positionDuration | bigint |
Returns
bigint
Defined in
packages/hyperdrive-js-core/src/hyperdrive/utils/calculateAprFromPrice.ts:12
calculateMatureLongYieldAfterFees
▸ calculateMatureLongYieldAfterFees(«destructured»
): bigint
Parameters
Name | Type |
---|---|
«destructured» | Object |
› baseAmountPaid | bigint |
› bondAmount | bigint |
› decimals | number |
› flatFee | bigint |
Returns
bigint
Defined in
packages/hyperdrive-js-core/src/longs/calculateMatureLongYieldAfterFees.ts:2
getCheckpointId
▸ getCheckpointId(blockTimestamp
, checkpointDuration
): bigint
Parameters
Name | Type |
---|---|
blockTimestamp | bigint |
checkpointDuration | bigint |
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
Name | Type | Description |
---|---|---|
values | bigint [] | The bigints to multiply. |
decimals | number | The 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