81 lines
2.7 KiB
TypeScript
Vendored
81 lines
2.7 KiB
TypeScript
Vendored
import type { Logger } from 'winston';
|
|
import { Provider } from 'ethers';
|
|
import { TornadoRouter } from '@tornado/contracts';
|
|
import { NetIdType, TornadoWithdrawParams, RelayerTornadoJobs, RelayerTornadoWithdraw, TornadoFeeOracle, snarkArgs, Config, TornadoWallet } from '@tornado/core';
|
|
import { RelayerConfig } from '../config';
|
|
import { SyncManager } from './sync';
|
|
import { ErrorMessages } from './error';
|
|
export declare enum RelayerStatus {
|
|
QUEUED = "QUEUED",
|
|
ACCEPTED = "ACCEPTED",
|
|
SENT = "SENT",
|
|
MINED = "MINED",
|
|
RESUBMITTED = "RESUBMITTED",
|
|
CONFIRMED = "CONFIRMED",
|
|
FAILED = "FAILED"
|
|
}
|
|
export declare const DEFAULT_GAS_LIMIT = 600000;
|
|
export interface RelayerServices {
|
|
provider: Provider;
|
|
signer: TornadoWallet;
|
|
tornadoFeeOracle: TornadoFeeOracle;
|
|
Router: TornadoRouter;
|
|
}
|
|
export interface CachedRelayerServices {
|
|
[key: NetIdType]: RelayerServices;
|
|
}
|
|
export declare function getFeeParams(config: Config, serviceFee: number, syncManager: SyncManager, { netId, contract, args }: RelayerTornadoQueue): {
|
|
amount: string;
|
|
symbol: string;
|
|
gasPrice: bigint;
|
|
gasLimit: bigint;
|
|
l1Fee: string | undefined;
|
|
denomination: bigint;
|
|
ethRefund: bigint;
|
|
tokenPriceInWei: bigint;
|
|
tokenDecimals: number;
|
|
relayerFeePercent: number;
|
|
isEth: boolean;
|
|
premiumPercent: number;
|
|
};
|
|
export declare function checkWithdrawalFees(relayerWorker: RelayerWorker, work: RelayerTornadoQueue): Promise<{
|
|
gasPrice: bigint;
|
|
gasLimit: bigint;
|
|
status: boolean;
|
|
error?: string;
|
|
}>;
|
|
export declare function processWithdrawals(relayerWorker: RelayerWorker): Promise<void>;
|
|
export interface CreateWorkParams extends TornadoWithdrawParams {
|
|
netId: NetIdType;
|
|
}
|
|
export interface RelayerTornadoQueue extends Omit<RelayerTornadoJobs, 'contract' | 'proof' | 'args'> {
|
|
netId: NetIdType;
|
|
contract: string;
|
|
proof: string;
|
|
args: snarkArgs;
|
|
timestamp: number;
|
|
}
|
|
export interface RelayerQueueGas {
|
|
id: string;
|
|
gasPrice: bigint;
|
|
gasLimit: bigint;
|
|
timestamp: number;
|
|
}
|
|
export declare class RelayerWorker {
|
|
relayerConfig: RelayerConfig;
|
|
logger: Logger;
|
|
syncManager: SyncManager;
|
|
cachedRelayerServices: CachedRelayerServices;
|
|
queue: RelayerTornadoQueue[];
|
|
queueGas: RelayerQueueGas[];
|
|
queueTimer: null | NodeJS.Timeout;
|
|
errors: ErrorMessages[];
|
|
constructor(relayerConfig: RelayerConfig, syncManager: SyncManager);
|
|
doWork(): Promise<void>;
|
|
createWork({ netId, contract, proof, args, }: CreateWorkParams): Promise<RelayerTornadoWithdraw | RelayerTornadoQueue>;
|
|
getWork({ id }: {
|
|
id: string;
|
|
}): RelayerTornadoWithdraw | RelayerTornadoQueue;
|
|
pendingWorks(): number;
|
|
}
|