import { MonetaryAmount } from "@interlay/monetary-js"; import { ApiPromise } from "@polkadot/api"; import { AccountId } from "@polkadot/types/interfaces"; import Big from "big.js"; import BN from "bn.js"; import { SystemAPI } from "../parachain/system"; import { ExtrinsicData, GovernanceCurrency, StakedBalance, VotingCurrency } from "../types"; /** * @category BTC Bridge */ export interface EscrowAPI { /** * @param accountId Account whose voting balance to fetch * @param blockNumber The number of block to query state at * @returns The voting balance * @remarks Logic is duplicated from Escrow pallet in the parachain */ votingBalance(accountId: AccountId, blockNumber?: number): Promise>; /** * @param blockNumber The number of block to query state at * @returns The voting balance * @remarks * - Expect poor performance from this function as more blocks are appended to the parachain. * It is not recommended to call this directly, but rather to query through the indexer (currently `interbtc-index`). * - Logic is duplicated from Escrow pallet in the parachain */ totalVotingSupply(blockNumber?: number): Promise>; /** * @param amount Governance token amount to lock (e.g. KINT or INTR) * @param unlockHeight 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 */ createLock(amount: MonetaryAmount, unlockHeight: number): ExtrinsicData; /** * @param accountId ID of the user whose stake to fetch * @returns The staked amount and end block */ getStakedBalance(accountId: AccountId): Promise; /** * @returns The total amount of locked governance tokens * @remarks * - Expect poor performance from this function as more blocks are appended to the parachain. * It is not recommended to call this directly, but rather to query through interbtc-squid once implemented. */ getTotalStakedBalance(): Promise>; /** * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. * @remarks Withdraws all locked governance currency */ withdraw(): ExtrinsicData; /** * @returns All future times are rounded by this. */ getSpan(): Promise; /** * @returns The maximum time for locks. */ getMaxPeriod(): Promise; /** * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. * @remarks Withdraws stake-to-vote rewards */ withdrawRewards(): ExtrinsicData; /** * @param amount 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. */ increaseAmount(amount: MonetaryAmount): ExtrinsicData; /** * @param unlockHeight The unlock height to increase by. * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ increaseUnlockHeight(unlockHeight: number): ExtrinsicData; /** * @param accountId User account ID * @returns The rewards that can be withdrawn by the account * @remarks Implements https://spec.interlay.io/spec/reward.html#computereward */ getRewards(accountId: AccountId): Promise>; /** * 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. * * @param accountId User account ID * @param amountToLock (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. * @param newLockEndHeight (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 The estimated total reward amount and annualized reward percentage (APY). */ getRewardEstimate(accountId: AccountId, amountToLock?: MonetaryAmount, newLockEndHeight?: number): Promise<{ amount: MonetaryAmount; apy: Big; }>; } export declare class DefaultEscrowAPI implements EscrowAPI { private api; private governanceCurrency; private systemApi; constructor(api: ApiPromise, governanceCurrency: GovernanceCurrency, systemApi: SystemAPI); createLock(amount: MonetaryAmount, unlockHeight: number): ExtrinsicData; withdraw(): ExtrinsicData; withdrawRewards(): ExtrinsicData; increaseAmount(amount: MonetaryAmount): ExtrinsicData; increaseUnlockHeight(unlockHeight: number): ExtrinsicData; getRewards(accountId: AccountId): Promise>; getRewardEstimate(accountId: AccountId, amountToLock?: MonetaryAmount, newLockEndHeight?: number): Promise<{ amount: MonetaryAmount; apy: Big; }>; getEscrowStake(accountId: AccountId): Promise; getEscrowTotalStake(): Promise; getRewardTally(accountId: AccountId): Promise; getRewardPerToken(): Promise; getRewardPerBlock(): Promise>; getStakedBalance(accountId: AccountId): Promise; getTotalStakedBalance(): Promise>; votingBalance(accountId: AccountId, blockNumber?: number): Promise>; totalVotingSupply(blockNumber?: number): Promise>; getSpan(): Promise; getMaxPeriod(): Promise; }