Skip to content

Commit 6a4eb0e

Browse files
committed
fix: updated usage to fib failing build
1 parent 77338fb commit 6a4eb0e

File tree

6 files changed

+49
-37
lines changed

6 files changed

+49
-37
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@across-protocol/sdk",
33
"author": "UMA Team",
4-
"version": "4.3.38",
4+
"version": "4.3.41",
55
"license": "AGPL-3.0",
66
"homepage": "https://docs.across.to/reference/sdk",
77
"files": [

src/clients/BundleDataClient/utils/DataworkerUtils.ts

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -153,21 +153,15 @@ export function _buildPoolRebalanceRoot(
153153
([l2TokenAddress, { realizedLpFees: totalRealizedLpFee, totalRefundAmount }]) => {
154154
// If the repayment token and repayment chain ID do not map to a PoolRebalanceRoute graph, then
155155
// there are no relevant L1 running balances.
156-
if (
157-
!clients.hubPoolClient.l2TokenHasPoolRebalanceRoute(
158-
toAddressType(l2TokenAddress, repaymentChainId),
159-
repaymentChainId,
160-
mainnetBundleEndBlock
161-
)
162-
) {
163-
chainWithRefundsOnly.add(repaymentChainId);
164-
return;
165-
}
166156
const l1Token = clients.hubPoolClient.getL1TokenForL2TokenAtBlock(
167157
toAddressType(l2TokenAddress, repaymentChainId),
168158
repaymentChainId,
169159
mainnetBundleEndBlock
170160
);
161+
if (!l1Token) {
162+
chainWithRefundsOnly.add(repaymentChainId);
163+
return;
164+
}
171165
const l1TokenAddr = l1Token.toNative();
172166
assert(l1Token.isEVM(), `Expected an EVM address: ${l1TokenAddr}`);
173167

@@ -193,6 +187,9 @@ export function _buildPoolRebalanceRoot(
193187
destinationChainId,
194188
mainnetBundleEndBlock
195189
);
190+
if (!l1TokenCounterpart) {
191+
return;
192+
}
196193
const lpFee = deposit.lpFeePct.mul(deposit.inputAmount).div(fixedPointAdjustment);
197194
updateRunningBalance(
198195
runningBalances,
@@ -222,6 +219,9 @@ export function _buildPoolRebalanceRoot(
222219
destinationChainId,
223220
mainnetBundleEndBlock
224221
);
222+
if (!l1TokenCounterpart) {
223+
return;
224+
}
225225
const lpFee = deposit.lpFeePct.mul(deposit.inputAmount).div(fixedPointAdjustment);
226226
updateRunningBalance(
227227
runningBalances,
@@ -277,21 +277,15 @@ export function _buildPoolRebalanceRoot(
277277
deposits.forEach((deposit) => {
278278
// If the repayment token and repayment chain ID do not map to a PoolRebalanceRoute graph, then
279279
// there are no relevant L1 running balances.
280-
if (
281-
!clients.hubPoolClient.l2TokenHasPoolRebalanceRoute(
282-
deposit.inputToken,
283-
deposit.originChainId,
284-
mainnetBundleEndBlock
285-
)
286-
) {
287-
chainWithRefundsOnly.add(deposit.originChainId);
288-
return;
289-
}
290280
const l1TokenCounterpart = clients.hubPoolClient.getL1TokenForL2TokenAtBlock(
291281
toAddressType(inputToken, originChainId),
292282
originChainId,
293283
mainnetBundleEndBlock
294284
);
285+
if (!l1TokenCounterpart) {
286+
chainWithRefundsOnly.add(deposit.originChainId);
287+
return;
288+
}
295289
updateRunningBalance(runningBalances, originChainId, l1TokenCounterpart.toEvmAddress(), deposit.inputAmount);
296290
});
297291
});

src/clients/BundleDataClient/utils/FillUtils.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@ import _ from "lodash";
22
import assert from "assert";
33
import { providers } from "ethers";
44
import { DepositWithBlock, Fill, FillWithBlock } from "../../../interfaces";
5-
import { isSlowFill, isValidEvmAddress, isDefined, chainIsEvm, Address, toAddressType } from "../../../utils";
5+
import {
6+
isSlowFill,
7+
isValidEvmAddress,
8+
isDefined,
9+
chainIsEvm,
10+
Address,
11+
toAddressType,
12+
EvmAddress,
13+
} from "../../../utils";
614
import { HubPoolClient } from "../../HubPoolClient";
715
import { SVMProvider } from "../../../arch/svm";
816

@@ -37,18 +45,18 @@ export function getRefundInformationFromFill(
3745

3846
// Now figure out the equivalent L2 token for the repayment token. If the inputToken doesn't have a
3947
// PoolRebalanceRoute, then the repayment chain would have been the originChainId after the getRepaymentChainId()
40-
// call and we would have returned already, so the following call should always succeed.
48+
// call and we would have returned already, so the following call should always succeed and we can safely cast.
4149
const l1TokenCounterpart = hubPoolClient.getL1TokenForL2TokenAtBlock(
4250
relayData.inputToken,
4351
relayData.originChainId,
4452
bundleEndBlockForMainnet
45-
);
53+
) as EvmAddress;
4654

4755
const repaymentToken = hubPoolClient.getL2TokenForL1TokenAtBlock(
4856
l1TokenCounterpart,
4957
chainToSendRefundTo,
5058
bundleEndBlockForMainnet
51-
);
59+
) as Address;
5260

5361
return {
5462
chainToSendRefundTo,
@@ -183,6 +191,9 @@ function _repaymentChainTokenIsValid(
183191
relayData.originChainId,
184192
bundleEndBlockForMainnet
185193
);
194+
if (!l1TokenCounterpart) {
195+
return false;
196+
}
186197
if (
187198
!hubPoolClient.l2TokenEnabledForL1TokenAtBlock(
188199
l1TokenCounterpart,

src/clients/BundleDataClient/utils/PoolRebalanceUtils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ export function updateRunningBalanceForDeposit(
198198
deposit.originChainId,
199199
mainnetBundleEndBlock
200200
);
201+
if (!l1TokenCounterpart) {
202+
return;
203+
}
201204
updateRunningBalance(runningBalances, deposit.originChainId, l1TokenCounterpart.toEvmAddress(), updateAmount);
202205
}
203206

src/clients/SpokePoolClient/SpokePoolClient.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -472,18 +472,22 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
472472
)
473473
) {
474474
return false;
475-
} else {
476-
const l1Token = this.hubPoolClient?.getL1TokenForL2TokenAtBlock(
477-
deposit.inputToken,
478-
deposit.originChainId,
479-
deposit.quoteBlockNumber
480-
);
481-
return this.hubPoolClient.l2TokenEnabledForL1TokenAtBlock(
482-
l1Token,
483-
deposit.destinationChainId,
484-
deposit.quoteBlockNumber
485-
);
486475
}
476+
477+
const l1Token = this.hubPoolClient?.getL1TokenForL2TokenAtBlock(
478+
deposit.inputToken,
479+
deposit.originChainId,
480+
deposit.quoteBlockNumber
481+
);
482+
if (!l1Token) {
483+
return false;
484+
}
485+
486+
return this.hubPoolClient.l2TokenEnabledForL1TokenAtBlock(
487+
l1Token,
488+
deposit.destinationChainId,
489+
deposit.quoteBlockNumber
490+
);
487491
}
488492

489493
/**

src/clients/mocks/MockHubPoolClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export class MockHubPoolClient extends HubPoolClient {
118118
delete this.spokePoolTokens[l1Token]?.[chainId];
119119
}
120120

121-
getL1TokenForL2TokenAtBlock(l2Token: Address, chainId: number, blockNumber: number): EvmAddress {
121+
getL1TokenForL2TokenAtBlock(l2Token: Address, chainId: number, blockNumber: number): EvmAddress | undefined {
122122
const l1Token = Object.keys(this.spokePoolTokens).find(
123123
(l1Token) => this.spokePoolTokens[l1Token]?.[chainId].eq(l2Token)
124124
);

0 commit comments

Comments
 (0)