Skip to content

Commit

Permalink
fix(BundleDataClient): Ignore slow fill requests involving lite chains (
Browse files Browse the repository at this point in the history
#715)

Signed-off-by: james-a-morris <jaamorris@cs.stonybrook.edu>
Co-authored-by: james-a-morris <jaamorris@cs.stonybrook.edu>
  • Loading branch information
nicholaspai and james-a-morris committed Aug 30, 2024
1 parent 92db736 commit 1058a22
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion 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.1.28",
"version": "3.1.29",
"license": "AGPL-3.0",
"homepage": "https://docs.across.to/reference/sdk",
"files": [
Expand Down
22 changes: 19 additions & 3 deletions src/clients/BundleDataClient/BundleDataClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,12 @@ export class BundleDataClient {
// If fill replaced a slow fill request, then mark it as one that might have created an
// unexecutable slow fill. We can't know for sure until we check the slow fill request
// events.
if (fill.relayExecutionInfo.fillType === FillType.ReplacedSlowFill) {
// slow fill requests for deposits from or to lite chains are considered invalid
if (
fill.relayExecutionInfo.fillType === FillType.ReplacedSlowFill &&
!v3RelayHashes[relayDataHash].deposit!.fromLiteChain &&
!v3RelayHashes[relayDataHash].deposit!.toLiteChain
) {
fastFillsReplacingSlowFills.push(relayDataHash);
}
}
Expand Down Expand Up @@ -902,7 +907,12 @@ export class BundleDataClient {
quoteTimestamp: matchedDeposit.quoteTimestamp,
});
v3RelayHashes[relayDataHash].deposit = matchedDeposit;
if (fill.relayExecutionInfo.fillType === FillType.ReplacedSlowFill) {
// slow fill requests for deposits from or to lite chains are considered invalid
if (
fill.relayExecutionInfo.fillType === FillType.ReplacedSlowFill &&
!matchedDeposit.fromLiteChain &&
!matchedDeposit.toLiteChain
) {
fastFillsReplacingSlowFills.push(relayDataHash);
}
}
Expand Down Expand Up @@ -1048,6 +1058,11 @@ export class BundleDataClient {
if (!deposit) {
throw new Error("Deposit should exist in relay hash dictionary.");
}
// We should never push fast fills involving lite chains here because slow fill requests for them are invalid:
assert(
!deposit.fromLiteChain && !deposit.toLiteChain,
"fastFillsReplacingSlowFills should not contain lite chain deposits"
);
const destinationBlockRange = getBlockRangeForChain(blockRangesForChains, destinationChainId, chainIds);
if (
// If the slow fill request that was replaced by this fill was in an older bundle, then we don't
Expand Down Expand Up @@ -1130,7 +1145,8 @@ export class BundleDataClient {
// If fill status is RequestedSlowFill, then we might need to mark down an unexecutable
// slow fill that we're going to replace with an expired deposit refund.
// If deposit cannot be slow filled, then exit early.
if (fillStatus !== FillStatus.RequestedSlowFill) {
// slow fill requests for deposits from or to lite chains are considered invalid
if (fillStatus !== FillStatus.RequestedSlowFill || deposit.fromLiteChain || deposit.toLiteChain) {
return;
}
// Now, check if there was a slow fill created for this deposit in a previous bundle which would now be
Expand Down

0 comments on commit 1058a22

Please sign in to comment.