import { Prometheus } from '../prometheus';
import { CustomJsonRpcProvider } from '../rpc/rpc.service';
import { BigNumber, Contract } from 'ethers';
import { NonceManager } from '@ethersproject/experimental';
import { BatchQueueItem, QueueItem, TxArgsSegmentSubmit, TxArgsSegmentBookFinalizeBatch, TxArgsRemoteOrder } from './types';
import { Logger } from '../utils/logger';
import { Order } from '../order/types';
import EventEmitter from 'node:events';
import { Config } from '../config/config';
import { NetworkIdT3rn } from '../pricer/types';
import { SqsDetails } from '../guardian/types';
export declare class Transmitter extends EventEmitter {
    private readonly config;
    private readonly nonceManager;
    private readonly prometheus;
    readonly rpcProvider: CustomJsonRpcProvider;
    private readonly networkId;
    private readonly name?;
    queue: QueueItem[];
    private queueBatches;
    private txCurrentlyInProcess;
    private queuePendingTxReceipts;
    private queueSendOuts;
    private backoffQueueLength;
    private orderBookContract;
    private payloadGetterContract;
    private biddingBookContract;
    private confirmationBookContract;
    private singleAttestationBookContract;
    private attestationBatchMakerContract;
    private segmentBook;
    private remoteOrderContract;
    private avpBatchSubmitter;
    private attestersContract;
    private readonly queueIntervalSec;
    private readonly pricerApi;
    private sendOutBatchMutex;
    private preLoadNonce;
    private readonly sqsService?;
    private sqsDetails?;
    latestGasPriceReceipts: BigNumber;
    currentPendingNonceMemo: number;
    isInSync: boolean;
    private gasLimitCap;
    constructor(config: Config, nonceManager: NonceManager, prometheus: Prometheus, rpcProvider: CustomJsonRpcProvider | undefined, networkId: NetworkIdT3rn, name?: string | undefined, sqsDetails?: SqsDetails);
    init(_remoteOrderContract: Record<string, Contract>, _attestersContract: Record<string, Contract>, _attestersPortalContract: Contract, _orderBookContract: Contract, _escrowOrderBookContract: Contract, _biddingBookContract: Contract, _confirmationBookContract: Contract, _singleAttestationBookContract: Contract, _attestationBatchMakerContract: Contract, _pendingBookContract?: Contract, _payloadGetterContract?: Contract, _avpBatchSubmitter?: Record<string, Contract>, _segmentBook?: Contract): void;
    get excludedLifecyclesFromBatching(): ("Attest" | "AVPAttest" | "AVPClaim" | "AVPBackdoor" | "Bid" | "Claim" | "ClaimV2" | "ClaimInsurance" | "Execute" | "OrderL3" | "OrdersL3" | "LateOrderDLQL3" | "SingleAttestL3" | "AttestL3" | "AttestBatchPayloadL3" | "ConfirmAttestationL3" | "RemoveGMPUnmatched" | "ConfirmExecutionL3" | "AnchorEscrowGMPPayloadUnmatchedToL3" | "ConfirmClaimedL3" | "ConfirmClaimedRefundL3" | "BatchAttestL3" | "TryConstructBatchL3" | "BatchPopulateL3" | "BatchRevertAttestL3" | "MemoPayloadL3" | "ConstructRevertBatchL3" | "AVPRefundBatches" | "AVPClaimBatches" | "SegmentBookFinalizeBatch" | "SegmentBookMark" | "SegmentSubmit" | "Order" | "ClaimRefundV2OfBatch" | "EmergencyClaimRefundV2OfBatch")[];
    start(): void;
    startOnNewBlockListener(): void;
    private get sendOutLimit();
    private recoverPendingTxReceipts;
    getLatestGasPrice(): Promise<BigNumber>;
    private enqueuePendingTxReceipt;
    private processPendingTxReceiptsFromSQS;
    private processTxReceiptFromSQS;
    private processQueues;
    private sendOutBatch;
    private fetchCostCapFromRemoteOrder;
    private logQueueStats;
    private checkIfExistsInCurrentlyInProcessAndRemove;
    private emitOrderFailure;
    emitOrderSuccess(queueItem: QueueItem | BatchQueueItem): void;
    /**
     * Transmits a transaction based on order data to the blockchain.
     *
     * Shifts (fetch + remove) the first item from the queue and processes it.
     * If successful, emit success to the calling service.
     * Otherwise, schedule the item for retry with exponential backoff.
     */
    transmitSingleItem(queueItem: QueueItem): Promise<void>;
    /**
     * Transmits a batch of transactions to the blockchain.
     *
     * Shifts (fetch + remove) the first item from the batch queue and processes it.
     * If successful, emit success to the calling service.
     * Otherwise, schedule the item for retry with exponential backoff.
     */
    private transmitBatchItem;
    /**
     * Shifts (fetch + remove) the first item from the pending tx receipts queue and tries to
     * recover the pending receipt of the tx in the queue item.
     *
     * If successful - emit success to the calling service. Otherwise, schedule for retry by pushing
     * the item to the back of the queue.
     * If the receipt's waiting recovery time has passed the limit, flag for one last run.
     * After that abort and fail the order.
     */
    private recoverPendingTxReceipt;
    /**
     * Carry out the actual transmission of the order (or batch of orders) as a transaction to the blockchain.
     *
     * @param {QueueItem | BatchQueueItem} queueItem
     * @param {Logger}  childLogger
     * @param {number}  nextStartingNonce
     */
    transmit(queueItem: QueueItem | BatchQueueItem, childLogger: Logger): Promise<void>;
    transmitConfirmExecutionL3(destinationNetwork: NetworkIdT3rn, orderId: string, target: string, amount: BigNumber, asset: number, sender: string, txHash: string): void;
    transmitGMPUnmatched(sourceNetwork: NetworkIdT3rn, orderId: string, escrowPayload: string): void;
    transmitRemoveGMPUnmatched(orderId: string, sourceNetwork: NetworkIdT3rn): void;
    transmitConfirmAttestationL3(sourceNetwork: NetworkIdT3rn, orderId: string, attestationBatchHash: string): void;
    transmitConfirmClaimedL3(sourceNetwork: NetworkIdT3rn, orderId: string, amount: BigNumber, assetAddress: string, sender: string): void;
    transmitConfirmClaimedRefundL3(sourceNetwork: NetworkIdT3rn, orderId: string, amount: BigNumber, assetAddress: string, sender: string): void;
    transmitPopulateOrdersL3(orders: Order[]): void;
    transmitTryConstructBatchL3(encodedNetworkId: string): void;
    transmitAttestationsPopulateBatchL3(populateBatchArray: {
        order: Order;
        bidWinner: string;
    }[], networkId: NetworkIdT3rn): void;
    transmitFormRevertBatchL3(size: number, encodedNetworkId: string, childLogger: Logger): void;
    transmitBatchMemoL3(orderIds: string[], childLogger: Logger): void;
    transmitRevertAttestationsBatchL3(orderIds: string[], childLogger: Logger): void;
    transmitAttestationsBatchL3(attestationsArray: {
        signature: string;
        messagePayloadHash: string;
        messagePayload: string;
        bidWinner: string;
        order: Order;
    }[]): Promise<void>;
    transmitAttestSingleL3(order: Order, beneficiary: string, signature: string, messagePayload: string): void;
    transmitAVPBackdoorBatch(batchHashes: string[], // messageGMPPayload
    batchIndices: number[], // sourceGateway
    batcherVersions: number[], // sourceGateway
    sourceNetwork: NetworkIdT3rn): void;
    transmitAVPPendingRefundsBatches(orderNonce: number[][], rewardAsset: string[][], maxReward: BigNumber[][], orderTimestamp: BigNumber[][], beneficiary: string[], sourceNetwork: NetworkIdT3rn): void;
    isAVPBatchQueueFilled(maxQueueItems: number, maxPendingReceiptItems: number): boolean;
    transmitAVPAttestBatch(orders: Order[], batchPayload: string[], // messageGMPPayload
    messageGMPPayload: string[], // sourceGateway
    signatures: string[][], // signatures
    attestationProof: string[][], // multiProofProof
    attestationProofFlags: boolean[][], // multiProofMembershipFlags
    sourceNetwork: NetworkIdT3rn): void;
    transmitAttestBatch(orders: Order[], encodedBatchPayload: string, messageGMPPayload: string, signatures: string[], attestationProof: string[], attestationProofFlags: boolean[], sourceNetwork: NetworkIdT3rn): void;
    transmitOrder(txArgs: TxArgsRemoteOrder, sourceNetwork: NetworkIdT3rn): void;
    transmitEmergencyRefundOrderV2(orderId: string[], beneficiaries: string[], orderNonce: number[], rewardAsset: string[], maxReward: BigNumber[], sourceNetwork: NetworkIdT3rn): void;
    transmitRefundOrderV2(orderId: string[], beneficiaries: string[], orderNonce: number[], rewardAsset: string[], maxReward: BigNumber[], batchPayloadHash: string, batchPayload: string, sourceNetwork: NetworkIdT3rn): void;
    transmitAttestBatchPayloadL3(batchPayload: string, signature: string, encodedNetworkId: string, batchIndex: number): void;
    transmitAttestBatchL3(orders: Order[], beneficiaryArray: string[], batchPayload: string, signature: string, sourceNetwork: NetworkIdT3rn): void;
    transmitClaimInsuranceById(orderId: string, claimer: string, sourceNetwork?: NetworkIdT3rn): void;
    transmitClaimInsurance(order: Order, claimer: string): void;
    transmitSegmentBookFinalizeBatch(txArgs: TxArgsSegmentBookFinalizeBatch): void;
    transmitSegmentBookMark(batchHash: string, sourceNetwork: NetworkIdT3rn): void;
    countBatchQueueItemsByLifecycle(lifecycle: string): number;
    countBatchQueueItems(): number;
    transmitSubmitSegments(txArgsSegmentSubmit: TxArgsSegmentSubmit): void;
    transmitAVPClaimBatches(orders: Order[], orderId: string[][], rewardAsset: string[][], maxReward: BigNumber[][], orderTimestamp: BigNumber[][], batchPayload: string, batchHash: string, networkId: NetworkIdT3rn): void;
    transmitAVPClaim(orders: Order[], batchPayloads: string[], batchHashes: string[], networkId: NetworkIdT3rn, appendBeneficiary?: string): void;
    transmitClaim(order: Order, settledAmount: BigNumber, isBatch?: boolean): void;
    transmitClaimV2(order: Order, batchPayload: string, settledAmount: BigNumber, isBatch?: boolean): void;
    transmitLateOrderL3(orderId: string, encodedNetworkId: string, networkId: NetworkIdT3rn): void;
    transmitBidBatch(orders: Order[], bidder: string, coalesce: boolean | undefined, insurance: BigNumber): void;
    transmitBid(order: Order, bidder: string, insurance: BigNumber): void;
    transmitExecuteBatch(orders: Order[]): void;
    transmitExecute(order: Order): void;
    transmitOrderL3(order: Order): void;
    /**
     * Check if any of the relevant queue batches are not full and add a queue item to it
     *
     * @param {QueueItem} queueItem
     *
     * @returns {isQueueItemAddedToBatch: boolean}
     */
    fillIncompleteBatch(queueItem: QueueItem): boolean;
    /**
     * Finds items in the queue that match the lifecycle and networkId of the given queueItem.
     *
     * Constructs a batch object, which has the same props as the original queueItem, but
     * the txArgs is an array of the txArgs of all matching items, plus the original queueItem.
     *
     * Collects the indexes of the matching items, so they can be removed from the queue afterwards.
     *
     * @param {QueueItem} queueItem
     *
     * @returns {batch: BatchQueueItem; indexesToRemove: number[]}
     */
    constructBatchForLifecycleAndNetwork(queueItem: QueueItem): {
        batch: BatchQueueItem;
        indexesToRemove: number[];
    };
    /**
     * Removes the given items by index from the queue.
     *
     * @param {number[]} indexesToRemove
     */
    removeItemsFromQueue(indexesToRemove: number[]): void;
    /**
     * Executes a transaction against a certain smart contract.
     *
     * @param {QueueItem} queueItem the queue item containing the transaction arguments and metadata
     * @param {TxParams}  txParams The ethers.js transaction parameters
     *
     * @returns {Promise<TxResponse>} The transaction response
     */
    private executeTxSingleItem;
    /**
     * Executes a transaction against a certain smart contract.
     *
     * @param {BatchQueueItem} queueItem the queue item containing the transaction arguments and metadata
     * @param {PopulatedTransaction}  txParams The ethers.js transaction parameters
     *
     * @returns {Promise<TxResponse>} The transaction response
     */
    private executeTxBatchItem;
    /**
     * Schedules the queue item for retry with backoff time.
     * The item is scheduled back in the same queue as it was - this happens after the backoff period
     * has elapsed.
     *
     * @param {QueueItem | BatchQueueItem} queueItem
     * @param {boolean=}  isNonceUsedError
     */
    scheduleItemForRetryWithBackoff(queueItem: QueueItem | BatchQueueItem, isNonceUsedError?: boolean | undefined): void;
    scheduleTxReceiptItemForRetryWithBackoff(queueItem: QueueItem | BatchQueueItem): void;
    /**
     * Schedules the queue item in the pending tx receipts queue.
     *
     * @param {QueueItem | BatchQueueItem}  queueItem
     * @param {string}  txHash
     * @param {boolean=}  allowBidRetry
     */
    private scheduleItemForPendingTxReceiptsQueue;
    /**
     * Wait for the backoff time of the given queue item to elapse, by sleeping for the given time.
     * Then re-introduce the item to the queue.
     *
     * @param {QueueItem} item
     */
    private waitBackoffForSingleItemAndThenScheduleForRetry;
    /**
     * Wait for the backoff time of the given batch queue item to elapse, by sleeping for the given time.
     * Then re-introduce the item to the batch queue.
     *
     * @param {BatchQueueItem} item
     */
    private waitBackoffForBatchItemAndThenScheduleForRetry;
    /**
     * Wait for the backoff time of the given tx receipt queue item to elapse, by sleeping for the given time.
     * Then re-introduce the item to the pending txReceipts queue.
     *
     * @param {QueueItem | BatchQueueItem} item
     */
    private waitBackoffForTxReceiptAndThenScheduleForRetry;
    /**
     * Updates the prometheus metrics for the service
     *
     * @param {QueueItem | BatchQueueItem} queueItem
     * @param {TxReceipt} txReceipt
     */
    private updatePrometheusMetrics;
    trimLongLogs(data: any, maxLength?: number): string;
    /**
     * Returns True of all Transmitter queues are empty, which means no transactions are being processed.
     * False, otherwise.
     *
     * @return {boolean}
     */
    areQueuesEmpty(): boolean;
    testGetQueueLength(): number;
    testGetQueueBatchesLength(): number;
    testGetBackoffQueueLength(): number;
    testGetBatchOrdersLength(index: number): number;
    testGetQueueBatches(): BatchQueueItem[];
    testSetQueueBatches(newQueue: BatchQueueItem[]): void;
    testSetBackoffQueueLength(newLength: number): void;
}
//# sourceMappingURL=transmitter.service.d.ts.map