Skip to content

Commit

Permalink
Merge branch 'master' into base-fee-multiplier
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholaspai committed Jan 2, 2025
2 parents 765ef85 + a7615d0 commit 90c9e89
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@across-protocol/sdk",
"author": "UMA Team",
"version": "3.3.28",
"version": "3.3.32",
"license": "AGPL-3.0",
"homepage": "https://docs.across.to/reference/sdk",
"files": [
Expand Down Expand Up @@ -99,7 +99,7 @@
},
"dependencies": {
"@across-protocol/across-token": "^1.0.0",
"@across-protocol/constants": "^3.1.24",
"@across-protocol/constants": "^3.1.25",
"@across-protocol/contracts": "^3.0.19",
"@eth-optimism/sdk": "^3.3.1",
"@ethersproject/bignumber": "^5.7.0",
Expand Down
19 changes: 17 additions & 2 deletions src/clients/BundleDataClient/BundleDataClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
isSlowFill,
mapAsync,
bnUint32Max,
isZeroValueDeposit,
} from "../../utils";
import winston from "winston";
import {
Expand Down Expand Up @@ -778,6 +779,9 @@ export class BundleDataClient {
continue;
}
originClient.getDepositsForDestinationChain(destinationChainId).forEach((deposit) => {
if (isZeroValueDeposit(deposit)) {
return;
}
depositCounter++;
const relayDataHash = this.getRelayHashFromEvent(deposit);
if (v3RelayHashes[relayDataHash]) {
Expand All @@ -793,6 +797,14 @@ export class BundleDataClient {
slowFillRequest: undefined,
};

// Once we've saved the deposit hash into v3RelayHashes, then we can exit early here if the inputAmount
// is 0 because there can be no expired amount to refund and no unexecutable slow fill amount to return
// if this deposit did expire. Input amount can only be zero at this point if the message is non-empty,
// but the message doesn't matter for expired deposits and unexecutable slow fills.
if (deposit.inputAmount.eq(0)) {
return;
}

// If deposit block is within origin chain bundle block range, then save as bundle deposit.
// If deposit is in bundle and it has expired, additionally save it as an expired deposit.
// If deposit is not in the bundle block range, then save it as an older deposit that
Expand Down Expand Up @@ -840,7 +852,10 @@ export class BundleDataClient {
await forEachAsync(
destinationClient
.getFillsForOriginChain(originChainId)
.filter((fill) => fill.blockNumber <= destinationChainBlockRange[1]),
// We can remove fills for deposits with input amount equal to zero because these will result in 0 refunded
// tokens to the filler. We can't remove non-empty message deposit here in case there is a slow fill
// request for the deposit, we'd want to see the fill took place.
.filter((fill) => fill.blockNumber <= destinationChainBlockRange[1] && !isZeroValueDeposit(fill)),
async (fill) => {
const relayDataHash = this.getRelayHashFromEvent(fill);
fillCounter++;
Expand Down Expand Up @@ -933,7 +948,7 @@ export class BundleDataClient {
await forEachAsync(
destinationClient
.getSlowFillRequestsForOriginChain(originChainId)
.filter((request) => request.blockNumber <= destinationChainBlockRange[1]),
.filter((request) => request.blockNumber <= destinationChainBlockRange[1] && !isZeroValueDeposit(request)),
async (slowFillRequest: SlowFillRequestWithBlock) => {
const relayDataHash = this.getRelayHashFromEvent(slowFillRequest);

Expand Down
2 changes: 1 addition & 1 deletion src/providers/retryProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ export class RetryProvider extends ethers.providers.StaticJsonRpcProvider {
}

// getBlockByNumber should only use the quorum if it's not asking for the latest block.
if (method === "eth_getBlockByNumber" && params[0] !== "latest") {
if (method === "eth_getBlockByNumber" && params[0] !== "latest" && params[0] !== "pending") {
return this.nodeQuorumThreshold;
}

Expand Down
12 changes: 12 additions & 0 deletions src/utils/DepositUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,18 @@ export async function queryHistoricalDepositForFill(
};
}

/**
* Returns true if filling this deposit (as a slow or fast fill) or refunding it would not change any state
* on-chain. The dataworker functions can use this to conveniently filter out useless deposits.
* @dev The reason we allow a 0-input deposit to have a non-empty message is that the message might be used
* to pay the filler in an indirect way so it might have economic value as a fast or slow fill.
* @param deposit Deposit to check.
* @returns True if deposit's input amount is 0 and message is empty.
*/
export function isZeroValueDeposit(deposit: Pick<Deposit, "inputAmount" | "message">): boolean {
return deposit.inputAmount.eq(0) && isMessageEmpty(deposit.message);
}

/**
* Determines if a message is empty or not.
* @param message The message to check.
Expand Down
6 changes: 1 addition & 5 deletions src/utils/Multicall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,15 @@ const NON_DETERMINISTIC_MULTICALL_ADDRESSES = {
[CHAIN_IDs.ZK_SYNC]: "0xF9cda624FBC7e059355ce98a31693d299FACd963",
};

// Multicall3 is an OP stack predeploy, so don't specify it here.
// @notice Multicall3 is an OP stack preinstall, so don't specify it here.
const DETERMINISTIC_MULTICALL_CHAINS = [
CHAIN_IDs.ALEPH_ZERO,
CHAIN_IDs.ARBITRUM,
CHAIN_IDs.INK,
CHAIN_IDs.LINEA,
CHAIN_IDs.MAINNET,
CHAIN_IDs.POLYGON,
CHAIN_IDs.SCROLL,
// Testnet:
CHAIN_IDs.BASE_SEPOLIA,
CHAIN_IDs.BLAST_SEPOLIA,
CHAIN_IDs.INK_SEPOLIA,
CHAIN_IDs.POLYGON_AMOY,
CHAIN_IDs.SCROLL_SEPOLIA,
CHAIN_IDs.SEPOLIA,
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
resolved "https://registry.yarnpkg.com/@across-protocol/constants/-/constants-3.1.24.tgz#01fe49330bb467dd01813387ddbac741bc74a035"
integrity sha512-guKtvIbif//vsmSZbwGubTWVtfkWiyWenr2sVyo63U/68GOW89ceJRLu4efLjeLVGiSrNAJtFUCv9dTwrrosWA==

"@across-protocol/constants@^3.1.25":
version "3.1.25"
resolved "https://registry.yarnpkg.com/@across-protocol/constants/-/constants-3.1.25.tgz#60d6d9814582ff91faf2b6d9f51d6dccb447b4ce"
integrity sha512-GpZoYn7hETYL2BPMM2GqXAer6+l/xuhder+pvpb00HJcb/sqCjF7vaaeKxjKJ3jKtyeulYmdu0NDkeNm5KbNWA==

"@across-protocol/contracts@^0.1.4":
version "0.1.4"
resolved "https://registry.yarnpkg.com/@across-protocol/contracts/-/contracts-0.1.4.tgz#64b3d91e639d2bb120ea94ddef3d160967047fa5"
Expand Down

0 comments on commit 90c9e89

Please sign in to comment.