import { Order, OrderStatus } from '../order/types';
import { DynamoDB } from 'aws-sdk';
import { Config } from '../config/config';
import { APITimeSeriesStats, DynamoChain, DynamoChainAPI, DynamoExecutor, DynamoExecutorAPI, DynamoOrder, DynamoOrderAccount, DynamoOrderSourceAccountEntry, DynamoOrderStatusEntry, DynamoUser, DynamoUserAPI, DynamoSybil } from './types';
import { BigNumber } from 'ethers';
import { Prometheus } from '../prometheus';
import { Key } from 'aws-sdk/clients/dynamodb';
import { NetworkIdT3rn } from '../pricer/types';
import { EventName } from '../types';
import { TransactionsTimeSeriesRedshift } from '../redshift/types';
export interface AggregatedStatement {
    PK: string;
    SK: string;
    hour: number;
    networkId: string;
    assetName: string;
    account?: string;
    ingress: string;
    egress: string;
    confirmedRefund?: string;
    type: string;
}
export declare class Dynamo {
    private readonly config;
    db: DynamoDB.DocumentClient;
    prometheus: Prometheus;
    constructor(config: Config, prometheus: Prometheus);
    fetchMessiahStatements(PK: string, startSK: string, endSK: string): Promise<never[] | DynamoDB.DocumentClient.QueryOutput>;
    putMessiahStatement(statement: AggregatedStatement): Promise<void>;
    putMessiahLatestBlock(podNumber: number, networkId: NetworkIdT3rn, block: number): Promise<boolean>;
    putMessiahCurrentHour(podNumber: number, hour: number): Promise<boolean>;
    fetchMessiahCurrentHour(podNumber: number): Promise<number>;
    getMessiahLatestBlock(podNumber: number, networkId: NetworkIdT3rn): Promise<number>;
    getAccountOrdersWithStatus(accountId: string, status: OrderStatus, limit?: number): Promise<DynamoOrderSourceAccountEntry[]>;
    fetchAccountOrderIds(accountId: string): Promise<string[]>;
    fetchAccountFullOrders(accountId: string, limit: number, lastKey?: string): Promise<{
        orders: DynamoOrder[];
        count: number;
        nextKey?: string;
    } | null>;
    fetchAccountFullOrdersByStatus(accountId: string, status: OrderStatus, limit: number, lastKey?: string): Promise<{
        orders: DynamoOrder[];
        count: number;
        nextKey?: string;
    } | null>;
    fetchOrdersByAccount(wallet: string, limit: number, lastKey?: string): Promise<{
        orders: DynamoOrder[];
        count: number;
        nextKey?: string;
    } | null>;
    /**
     * Inserts a new order to table containing all orders made
     *
     * @param order
     */
    insertOrder(order: Order): Promise<[DynamoOrder | null, boolean]>;
    /**
     * Inserts a new entry to guardian-orders-accounts table.
     *
     * @param order
     */
    insertOrderAccount(orderId: string, sourceAccount: string, targetAccount: string, orderTimestamp: number): Promise<DynamoOrderAccount | null>;
    fetchExecutorIds(): Promise<string[]>;
    /**
     * Inserts a new entry to guardian-accounts-balances table.
     *
     * @param order
     */
    insertAccountBalance(account: string, balances: Record<string, Record<string, string>>): Promise<boolean>;
    getAccountBalance(account: string): Promise<{
        account: string;
        timestamp: number;
        balances: Record<string, Record<string, string>>;
    } | null>;
    /**
     * Updates field(s) in a record in the `guardian-orders` table.
     *
     * @param {string} orderId The ID of the order for which to update the record.
     * @param {Record<string, any>} fields A record containing key-value pairs, where each key is the field to update and the corresponding value is the new data.
     */
    updateOrderFields(orderId: string, fields: Record<string, any>): Promise<boolean>;
    updateOrder(order: DynamoOrder): Promise<void>;
    verifyDisallowedStatus(orderId: string, statusNew: string, currentStatus: string, context?: string): boolean;
    checkUpdateConfirmedRefundStatus(order: Order, forExecutor: string, eventName?: EventName): Promise<boolean>;
    updateOrderStatus(orderId: string, statusNew: OrderStatus, statusOld: OrderStatus, context: string): Promise<boolean>;
    updateOrderHistory(orderId: string, statusNew: OrderStatus, statusOld: OrderStatus | undefined, context: string | undefined): Promise<false | undefined>;
    fetchOrderOrThrow(orderId: string, context: string): Promise<Order | null>;
    fetchDBOrder(orderId: string, context: string): Promise<DynamoOrder | null>;
    fetchOrderHistory(orderId: string, context: string): Promise<any>;
    fetchOrder(orderId: string, context: string): Promise<Order | null>;
    removeOrder(orderId: string, orderTimestamp: number): Promise<void>;
    fetchOrders(limit?: number, lastKey?: string, youngerThan?: number, oldestFirst?: boolean): Promise<{
        orders: Order[];
        nextKey?: string;
        count: number;
    } | null>;
    fetchOrdersSegmentByStatus(status: OrderStatus, startKey?: Key, limit?: number): Promise<{
        orders: DynamoOrder[];
        nextKey?: Key | null;
        count: number;
    } | null>;
    fetchOrdersSegmentByStatusNetwork(status: OrderStatus, networkId: NetworkIdT3rn, startKey?: Key, limit?: number): Promise<{
        orders: DynamoOrder[];
        nextKey?: Key | null;
        count: number;
    } | null>;
    /**
     * Fetches orders that are still in Pending state and returns their IDs.
     *
     * @returns {Promise<string[]>}
     */
    fetchPendingOrderIds(limit: number, scanIndexForward?: boolean): Promise<string[]>;
    /**
     * Fetches orders that are still in Pending state and returns their IDs.
     *
     * @param {number} [offset] - The maximum age of the orders to fetch, in minutes
     * @returns {Promise<string[]>}
     */
    fetchPendingOrderIdsOffset(offset: number, limit: number): Promise<string[]>;
    fetchOrderIdsByStatus(status: OrderStatus): Promise<string[]>;
    fetchOrderIdByTxHash(txHash: string): Promise<{
        id: string;
        txHash: string;
    } | null>;
    fetchLatestOrders(): Promise<DynamoOrder[]>;
    fetchOrdersByStatusOrderTimestamp(status: string, limit?: number): Promise<string[]>;
    fetchFullOrdersByStatusLastKey(status: OrderStatus, limit: number, lastKey?: DynamoDB.DocumentClient.Key): Promise<{
        orders: Order[];
        nextKey?: string;
    }>;
    fetchFullOrdersByStatus(status: OrderStatus, minOrderTimestamp: number, limit?: number): Promise<Order[]>;
    fetchOrdersStatusLatest(status: string, offset: number, // in minutes
    limit?: number): Promise<DynamoOrder[]>;
    fetchOrdersByStatusTraverse(status: string, scanIndexForward?: boolean, lastKey?: DynamoDB.DocumentClient.Key, limit?: number): Promise<{
        ids: string[];
        nextKey?: DynamoDB.DocumentClient.Key;
        count: number;
    } | null>;
    fetchOrdersByStatusNetworkTraverse(status: string, networkId: NetworkIdT3rn, scanIndexForward?: boolean, lastKey?: DynamoDB.DocumentClient.Key, limit?: number): Promise<{
        ids: string[];
        nextKey?: DynamoDB.DocumentClient.Key;
        count: number;
    } | null>;
    fetchOrdersByStatus(status: string, limit?: number): Promise<string[]>;
    fetchOrdersByStatusSorted(status: string, offset?: number, scanIndexForward?: boolean, limit?: number, useOffsetAsYoungerThan?: boolean, rawOrderTimestamp?: boolean): Promise<DynamoOrderStatusEntry[]>;
    fetchOrderIdsByStatusSorted(status: string, offset?: number, scanIndexForward?: boolean, // False - The results are returned in descending order based on the sort key
    limit?: number, useOffsetAsYoungerThan?: boolean, rawOrderTimestamp?: boolean): Promise<string[]>;
    fetchOrderStatusCountTotal(status: OrderStatus): Promise<number>;
    fetchOrderStatusCount(offset?: number): Promise<Record<string, number>>;
    fetchForExecutor(executor: string, limit: number): Promise<DynamoOrderStatusEntry[]>;
    fetchPendingClaims(executor: string, limit: number): Promise<DynamoOrderStatusEntry[]>;
    fetchPendingExecutions(executor: string, limit?: number): Promise<Order[]>;
    fetchExecutorExecutedNetworks(executorId: string): Promise<Record<string, number>>;
    fetchExecutorOrdersWithConfirmation(executorId: string, limit: number, lastKey?: string): Promise<{
        orders: DynamoOrder[];
        nextKey?: string;
        count: number;
    }>;
    updateChainStats(chain: DynamoChain): Promise<boolean>;
    updateOrderStatsValue(identifier: string, value: number): Promise<boolean>;
    updateOrderStatsAttributes(identifier: string, attributes: Record<string, any>): Promise<boolean>;
    fetchOrderStats<T = number | Record<string, any>>(identifier: string, context?: string): Promise<T>;
    fetchChains(enabledNetworkIds: string[]): Promise<DynamoChainAPI[]>;
    fetchAvgOrderValue(): Promise<number>;
    fetchChainsCount(enabledNetworkIds: string[]): Promise<number>;
    insertAIxecutor(id: string): Promise<boolean>;
    updateExecutorStats(executors: DynamoExecutor[]): Promise<import("aws-sdk/lib/request").PromiseResult<DynamoDB.DocumentClient.TransactWriteItemsOutput, import("aws-sdk").AWSError>>;
    fetchExecutor(id: string, context: string): Promise<DynamoExecutorAPI | null>;
    fetchExecutors(limit: number, lastKey?: string): Promise<{
        executors: DynamoExecutorAPI[];
        nextKey?: string;
        count: number;
    } | null>;
    updateUserStats(users: DynamoUser[]): Promise<import("aws-sdk/lib/request").PromiseResult<DynamoDB.DocumentClient.TransactWriteItemsOutput, import("aws-sdk").AWSError>>;
    fetchUser(id: string, context: string): Promise<DynamoUserAPI | null>;
    updateTimeSeriesStats(stats: TransactionsTimeSeriesRedshift[]): Promise<void>;
    fetchTimeSeriesTransactionsByBucket(bucketType: 'HOUR' | 'DAY' | 'WEEK' | 'MONTH'): Promise<APITimeSeriesStats[]>;
    fetchTimeSeriesTransactionsByBucketAndRange(bucketType: 'HOUR' | 'DAY' | 'WEEK' | 'MONTH', fromTs: number, toTs: number): Promise<APITimeSeriesStats[]>;
    getOrderExecutorField(orderId: string): Promise<string | undefined>;
    getOrderConfirmedAmountField(orderId: string): Promise<BigNumber | undefined>;
    fetchOrderStatus(orderId: string): Promise<OrderStatus | undefined>;
    insertSybil(address: string, passportScore: number, passportStamps: any, passportResponse: any): Promise<[DynamoSybil | null, boolean]>;
    fetchSybil(address: string): Promise<DynamoSybil | null>;
    /**
     * Updates field(s) in a record in the `guardian-brn-sybils` table.
     *
     * @param {string} address The address (key) for the Sybil record.
     * @param {Record<string, any>} fields A record containing key-value pairs to update.
     * @returns {Promise<boolean>} True if update succeeded, false otherwise.
     */
    updateSybilFields(address: string, fields: Record<string, any>): Promise<boolean>;
    private insert;
    get(params: DynamoDB.DocumentClient.GetItemInput, context: string): Promise<DynamoDB.DocumentClient.GetItemOutput>;
    query(params: DynamoDB.DocumentClient.QueryInput, context: string): Promise<DynamoDB.DocumentClient.QueryOutput>;
    update(data: DynamoDB.DocumentClient.UpdateItemInput, logParams?: Record<string, unknown>): Promise<boolean>;
    transact(data: DynamoDB.DocumentClient.TransactWriteItemsInput): Promise<boolean>;
    transactWrite(data: DynamoDB.DocumentClient.TransactWriteItemsInput): Promise<import("aws-sdk/lib/request").PromiseResult<DynamoDB.DocumentClient.TransactWriteItemsOutput, import("aws-sdk").AWSError>>;
    testSetMockDynamoInstance(dynamoDb: DynamoDB.DocumentClient): void;
}
//# sourceMappingURL=dynamo.service.d.ts.map