@etherna/sdk-js
Version:
Etherna SDKs for operations on the network
74 lines • 2.21 kB
TypeScript
import type { GatewayBatch, PostageBatch } from "../clients";
/**
* Get postage batch space utilization (in bytes)
*
* @param batch Batch data
* @returns An object with total, used and available space
*/
export declare const getBatchSpace: (batch: PostageBatch | GatewayBatch) => {
total: number;
used: number;
available: number;
};
/**
* Get batch capacity
*
* @param batchOrDepth Batch data or depth
* @returns Batch total capcity in bytes
*/
export declare const getBatchCapacity: (batchOrDepth: PostageBatch | GatewayBatch | number) => number;
/**
* Get batch utilization in percentage (0-1)
*
* @param batch Batch data
* @returns Batch percent usage
*/
export declare const getBatchPercentUtilization: (batch: PostageBatch | GatewayBatch) => number;
/**
* Get the batch expiration day
*
* @param batch Batch data
* @returns Expiration dayjs object
*/
export declare const getBatchExpiration: (batch: PostageBatch | GatewayBatch) => "unlimited" | Date;
/**
* Parse a default postage batch to a gateway batch
*
* @param batch Postage batch
* @returns Gateway batch
*/
export declare const parsePostageBatch: (batch: PostageBatch) => GatewayBatch;
/**
* Parse a gateway batch to a standard postage batch
*
* @param batch Gateway batch
* @returns Postage batch
*/
export declare const parseGatewayBatch: (batch: GatewayBatch) => PostageBatch;
/**
* Convert TTL to batch amount
*
* @param ttl TTL in seconds
* @param price Token price
* @param blockTime Chain blocktime
* @returns Batch amount
*/
export declare const ttlToAmount: (ttl: number, price: number, blockTime: number) => bigint;
/**
* Calc batch price from depth & amount
*
* @param depth Batch depth
* @param amount Batch amount
* @returns Price in BZZ
*/
export declare const calcBatchPrice: (depth: number, amount: bigint | string) => string;
/**
* Calculate the batch TTL after a dilute
*
* @param currentTTL Current batch TTL
* @param currentDepth Current batch depth
* @param newDepth New batch depth
* @returns The projected batch TTL
*/
export declare const calcDilutedTTL: (currentTTL: number, currentDepth: number, newDepth: number) => number;
//# sourceMappingURL=batches.d.ts.map