Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/poller/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ function initializeAdapters(config: MarkConfiguration, logger: Logger): MarkAdap
web3Signer as EthWallet,
logger,
);

// Initialize fill service chain service if FS signer URL is configured
// This allows TAC rebalancing to use a separate sender address for FS
// senderAddress defaults to fillService.address if not explicitly set (same key = same address)
Expand Down Expand Up @@ -328,6 +328,7 @@ export const initPoller = async (): Promise<{ statusCode: number; body: string }
try {
adapters = initializeAdapters(config, logger);
const addresses = await adapters.chainService.getAddress();
const fillServiceAddresses = adapters.fillServiceChainService ? await adapters.fillServiceChainService.getAddress() : undefined;

const context: ProcessingContext = {
...adapters,
Expand All @@ -346,6 +347,7 @@ export const initPoller = async (): Promise<{ statusCode: number; body: string }
stage: config.stage,
environment: config.environment,
addresses,
fillServiceAddresses
});

const rebalanceOperations = await rebalanceMantleEth(context);
Expand Down Expand Up @@ -376,6 +378,7 @@ export const initPoller = async (): Promise<{ statusCode: number; body: string }
stage: config.stage,
environment: config.environment,
addresses,
fillServiceAddresses
});

const rebalanceOperations = await rebalanceTacUsdt(context);
Expand Down Expand Up @@ -406,6 +409,7 @@ export const initPoller = async (): Promise<{ statusCode: number; body: string }
stage: config.stage,
environment: config.environment,
addresses,
fillServiceAddresses
});

const rebalanceOperations = await rebalanceSolanaUsdc(context);
Expand Down Expand Up @@ -438,6 +442,7 @@ export const initPoller = async (): Promise<{ statusCode: number; body: string }
stage: config.stage,
environment: config.environment,
addresses,
fillServiceAddresses
});

invoiceResult = await pollAndProcessInvoices(context);
Expand Down
12 changes: 12 additions & 0 deletions packages/poller/src/rebalance/mantleEth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,18 @@ const evaluateFillServiceRebalance = async (
// PRIORITY 2: Threshold Rebalancing (FS → FS)
// FS sender does not have enough funds on Mantle, rebalance from WETH on Mainnet
// Get FS receiver's mETH balance
const { operations: inFlightOps } = await database.getRebalanceOperations(undefined, undefined, {
status: [RebalanceOperationStatus.PENDING, RebalanceOperationStatus.AWAITING_CALLBACK],
bridge: [SupportedBridge.Mantle, `${SupportedBridge.Across}-mantle`],
earmarkId: null
});
if(inFlightOps.length) {
logger.info(`Found inflight rebalance operations ${inFlightOps.length}. Threshold rebalancing skipping....`, {
requestId,
});
return actions;
}

let fsReceiverMethBalance = 0n;
if (fsConfig.address) {
try {
Expand Down