import { StatusCode } from "../interfaces/default"; import { u64, u128 } from "@polkadot/types/primitive"; import { AccountId, BlockNumber, Moment } from "@polkadot/types/interfaces/runtime"; import { ApiPromise } from "@polkadot/api"; import { Bytes } from "@polkadot/types"; import BN from "bn.js"; import Big from "big.js"; import { Network } from "bitcoinjs-lib"; import { AddressOrPair } from "@polkadot/api/types"; import { DefaultTransactionAPI, TransactionAPI } from "./transaction"; import { ElectrsAPI } from ".."; /** * @category PolkaBTC Bridge * The type Big represents Wrapped or Collateral large denominations, * while the type BN represents Planck or Satoshi denominations. */ export interface StakedRelayerAPI extends TransactionAPI { /** * @returns An array containing tuples of type [stakedRelayerId, backingCollateral] */ list(): Promise; /** * @returns A mapping from vault IDs to their collateralization */ getMonitoredVaultsCollateralizationRate(): Promise>; /** * @returns A tuple denoting [lastBTCDOTExchangeRate, lastBTCDOTExchangeRateTime] */ getLastBTCDOTExchangeRateAndTime(): Promise<[u128, Moment]>; /** * @returns A parachain status code object */ getCurrentStateOfBTCParachain(): Promise; /** * @param stakedRelayerId The ID of a staked relayer * @returns Total rewards in PolkaBTC for the given staked relayer */ getWrappingFees(stakedRelayerId: AccountId): Promise; /** * @param stakedRelayerId The ID of a staked relayer * @returns Total rewards in Collateral tokens for the given staked relayer */ getCollateralFees(stakedRelayerId: AccountId): Promise; /** * Get the total APY for a staked relayer based on the income in Wrapped and Collateral tokens * divided by the locked Collateral tokens. * * @note this does not account for interest compounding * * @param stakedRelayerId the id of the relayer * @returns the APY as a percentage string */ getAPY(stakedRelayerId: AccountId): Promise; /** * @param stakedRelayerId The ID of a staked relayer * @returns The SLA score, an integer in the range [0, MaxSLA] */ getSLA(stakedRelayerId: AccountId): Promise; /** * @returns The maximum SLA score, a positive integer */ getMaxSLA(): Promise; /** * @param planckStake Stake amount (denoted in Planck) to register with */ register(planckStake: BN): Promise; /** * Deregister the Staked Relayer */ deregister(): Promise; /** * A Staked Relayer reports misbehavior by a Vault, providing a fraud proof * (malicious Bitcoin transaction and the corresponding transaction inclusion proof). * @remarks If `txId` is not set, the `merkleProof` and `rawTx` must both be set. * * @param vault_id The account of the vault to check. * @param tx_id The hash of the transaction * @param merkle_proof The proof of tx inclusion. * @param raw_tx The raw Bitcoin transaction. */ reportVaultTheft(vaultId: string, btcTxId?: string, merkleProof?: Bytes, rawTx?: Bytes): Promise; } export interface PendingStatusUpdate { statusUpdateStorageKey: u64; statusUpdateEnd: BlockNumber; statusUpdateAyes: number; statusUpdateNays: number; } export declare class DefaultStakedRelayerAPI extends DefaultTransactionAPI implements StakedRelayerAPI { private electrsAPI; private vaultsAPI; private collateralAPI; private feeAPI; constructor(api: ApiPromise, btcNetwork: Network, electrsAPI: ElectrsAPI, account?: AddressOrPair); register(planckStake: BN): Promise; deregister(): Promise; reportVaultTheft(vaultId: string, btcTxId?: string, merkleProof?: Bytes, rawTx?: Bytes): Promise; list(): Promise; getMonitoredVaultsCollateralizationRate(): Promise>; private isMonitoredVaultCollateralizationDefined; getLastBTCDOTExchangeRateAndTime(): Promise<[u128, Moment]>; getCurrentStateOfBTCParachain(): Promise; getWrappingFees(stakedRelayerId: AccountId): Promise; getCollateralFees(stakedRelayerId: AccountId): Promise; getAPY(stakedRelayerId: AccountId): Promise; getSLA(stakedRelayerId: AccountId): Promise; getMaxSLA(): Promise; }