interbtc-api

@interlay/interbtc-api / Exports / DefaultEscrowAPI

Class: DefaultEscrowAPI

Implements

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new DefaultEscrowAPI(api, governanceCurrency, systemApi): DefaultEscrowAPI

Parameters

Name Type
api ApiPromise
governanceCurrency Currency
systemApi SystemAPI

Returns

DefaultEscrowAPI

Defined in

src/parachain/escrow.ts:108

Properties

api

Private api: ApiPromise

Defined in

src/parachain/escrow.ts:109


governanceCurrency

Private governanceCurrency: Currency

Defined in

src/parachain/escrow.ts:110


systemApi

Private systemApi: SystemAPI

Defined in

src/parachain/escrow.ts:111

Methods

createLock

createLock(amount, unlockHeight): ExtrinsicData

Parameters

Name Type Description
amount MonetaryAmount<Currency> Governance token amount to lock (e.g. KINT or INTR)
unlockHeight number Block number to lock until

Returns

ExtrinsicData

A submittable extrinsic and an event that is emitted when extrinsic is submitted.

Remarks

The amount can’t be less than the max period (getMaxPeriod getter) to prevent rounding errors

Implementation of

EscrowAPI.createLock

Defined in

src/parachain/escrow.ts:114


getEscrowStake

getEscrowStake(accountId): Promise<Big>

Parameters

Name Type
accountId AccountId

Returns

Promise<Big>

Defined in

src/parachain/escrow.ts:206


getEscrowTotalStake

getEscrowTotalStake(): Promise<Big>

Returns

Promise<Big>

Defined in

src/parachain/escrow.ts:211


getMaxPeriod

getMaxPeriod(): Promise<BN>

Returns

Promise<BN>

The maximum time for locks.

Implementation of

EscrowAPI.getMaxPeriod

Defined in

src/parachain/escrow.ts:265


getRewardEstimate

getRewardEstimate(accountId, amountToLock?, newLockEndHeight?): Promise<{ amount: MonetaryAmount<Currency> ; apy: Big }>

Estimate the annualized rewards for an account’s staked amounts while applying an optional amount to increase the locked stake by, and an optional lock time extension.

Parameters

Name Type Description
accountId AccountId User account ID
amountToLock? MonetaryAmount<Currency> (optional) New amount to add to the current stake. Zero, null, or undefined are interpreted as no changes to the current stake for the estimation.
newLockEndHeight? number (optional) At which block number the stake lock should end. Zero, null, or undefined are interpreted as no lock extension used for the estimate.

Returns

Promise<{ amount: MonetaryAmount<Currency> ; apy: Big }>

The estimated total reward amount and annualized reward percentage (APY).

Implementation of

EscrowAPI.getRewardEstimate

Defined in

src/parachain/escrow.ts:147


getRewardPerBlock

getRewardPerBlock(): Promise<MonetaryAmount<Currency>>

Returns

Promise<MonetaryAmount<Currency>>

Defined in

src/parachain/escrow.ts:228


getRewardPerToken

getRewardPerToken(): Promise<Big>

Returns

Promise<Big>

Defined in

src/parachain/escrow.ts:222


getRewardTally

getRewardTally(accountId): Promise<Big>

Parameters

Name Type
accountId AccountId

Returns

Promise<Big>

Defined in

src/parachain/escrow.ts:216


getRewards

getRewards(accountId): Promise<MonetaryAmount<Currency>>

Parameters

Name Type Description
accountId AccountId User account ID

Returns

Promise<MonetaryAmount<Currency>>

The rewards that can be withdrawn by the account

Remarks

Implements https://spec.interlay.io/spec/reward.html#computereward

Implementation of

EscrowAPI.getRewards

Defined in

src/parachain/escrow.ts:139


getSpan

getSpan(): Promise<BN>

Returns

Promise<BN>

All future times are rounded by this.

Implementation of

EscrowAPI.getSpan

Defined in

src/parachain/escrow.ts:261


getStakedBalance

getStakedBalance(accountId): Promise<StakedBalance>

Parameters

Name Type Description
accountId AccountId ID of the user whose stake to fetch

Returns

Promise<StakedBalance>

The staked amount and end block

Implementation of

EscrowAPI.getStakedBalance

Defined in

src/parachain/escrow.ts:233


getTotalStakedBalance

getTotalStakedBalance(): Promise<MonetaryAmount<Currency>>

Returns

Promise<MonetaryAmount<Currency>>

The total amount of locked governance tokens

Remarks

Implementation of

EscrowAPI.getTotalStakedBalance

Defined in

src/parachain/escrow.ts:238


increaseAmount

increaseAmount(amount): ExtrinsicData

Parameters

Name Type Description
amount MonetaryAmount<Currency> Governance token amount to lock (e.g. KINT or INTR)

Returns

ExtrinsicData

A submittable extrinsic and an event that is emitted when extrinsic is submitted.

Implementation of

EscrowAPI.increaseAmount

Defined in

src/parachain/escrow.ts:129


increaseUnlockHeight

increaseUnlockHeight(unlockHeight): ExtrinsicData

Parameters

Name Type Description
unlockHeight number The unlock height to increase by.

Returns

ExtrinsicData

A submittable extrinsic and an event that is emitted when extrinsic is submitted.

Implementation of

EscrowAPI.increaseUnlockHeight

Defined in

src/parachain/escrow.ts:134


totalVotingSupply

totalVotingSupply(blockNumber?): Promise<MonetaryAmount<Currency>>

Parameters

Name Type Description
blockNumber? number The number of block to query state at

Returns

Promise<MonetaryAmount<Currency>>

The voting balance

Remarks

Implementation of

EscrowAPI.totalVotingSupply

Defined in

src/parachain/escrow.ts:255


votingBalance

votingBalance(accountId, blockNumber?): Promise<MonetaryAmount<Currency>>

Parameters

Name Type Description
accountId AccountId Account whose voting balance to fetch
blockNumber? number The number of block to query state at

Returns

Promise<MonetaryAmount<Currency>>

The voting balance

Remarks

Logic is duplicated from Escrow pallet in the parachain

Implementation of

EscrowAPI.votingBalance

Defined in

src/parachain/escrow.ts:249


withdraw

withdraw(): ExtrinsicData

Returns

ExtrinsicData

A submittable extrinsic and an event that is emitted when extrinsic is submitted.

Remarks

Withdraws all locked governance currency

Implementation of

EscrowAPI.withdraw

Defined in

src/parachain/escrow.ts:119


withdrawRewards

withdrawRewards(): ExtrinsicData

Returns

ExtrinsicData

A submittable extrinsic and an event that is emitted when extrinsic is submitted.

Remarks

Withdraws stake-to-vote rewards

Implementation of

EscrowAPI.withdrawRewards

Defined in

src/parachain/escrow.ts:124