Skip to content

Commit

Permalink
refactor(Dataworker): Simplify legacy/UBA proposal flow (#1114)
Browse files Browse the repository at this point in the history
No intended change in behaviour, but this commit collapses the code
somewhat.
  • Loading branch information
pxrl authored Dec 13, 2023
1 parent 24f328c commit 3bd4932
Showing 1 changed file with 17 additions and 43 deletions.
60 changes: 17 additions & 43 deletions src/dataworker/Dataworker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,55 +350,29 @@ export class Dataworker {
return;
}

const hubPoolChainId = this.clients.hubPoolClient.chainId;
const { chainId: hubPoolChainId, latestBlockNumber } = this.clients.hubPoolClient;
const [mainnetBundleStartBlock, mainnetBundleEndBlock] = getBlockRangeForChain(
blockRangesForProposal,
hubPoolChainId,
this.chainIdListForBundleEvaluationBlockNumbers
);

let rootBundleData: ProposeRootBundleReturnType;
let isUBA = false;
if (
sdk.clients.isUBAActivatedAtBlock(
this.clients.hubPoolClient,
mainnetBundleStartBlock,
this.clients.hubPoolClient.chainId
)
) {
isUBA = true;
}
if (!isUBA) {
this.logger.debug({
at: "Dataworker#propose",
message: "Proposing Legacy root bundle",
blockRangesForProposal,
});
const _rootBundleData = await this.Legacy_proposeRootBundle(
blockRangesForProposal,
spokePoolClients,
this.clients.hubPoolClient.latestBlockNumber,
true
);
rootBundleData = {
..._rootBundleData,
};
} else {
this.logger.debug({
at: "Dataworker#propose",
message: "Proposing UBA root bundle",
blockRangesForProposal,
});
const _rootBundleData = await this.UBA_proposeRootBundle(
blockRangesForProposal,
ubaClient,
spokePoolClients,
true
);
rootBundleData = {
..._rootBundleData,
};
}
const isUBA = sdk.clients.isUBAActivatedAtBlock(
this.clients.hubPoolClient,
mainnetBundleStartBlock,
hubPoolChainId
);

const rootBundleDataProducer = isUBA
? this.UBA_proposeRootBundle(blockRangesForProposal, ubaClient, spokePoolClients, true)
: this.Legacy_proposeRootBundle(blockRangesForProposal, spokePoolClients, latestBlockNumber, true);

this.logger.debug({
at: "Dataworker#propose",
message: `Proposing ${isUBA ? "UBA" : "Legacy"} root bundle`,
blockRangesForProposal,
});
const rootBundleData = { ...(await rootBundleDataProducer) };

if (usdThresholdToSubmitNewBundle !== undefined) {
// Exit early if volume of pool rebalance leaves exceeds USD threshold. Volume includes netSendAmounts only since
Expand Down

0 comments on commit 3bd4932

Please sign in to comment.