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
55 changes: 10 additions & 45 deletions contracts/SpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,8 @@ abstract contract SpokePool is SpokePoolInterface, Testable, Lockable, MultiCall
address destinationToken,
address indexed relayer,
address indexed depositor,
address recipient
);
event ExecutedSlowRelayRoot(
bytes32 indexed relayHash,
uint256 amount,
uint256 totalFilledAmount,
uint256 fillAmount,
uint256 indexed originChainId,
uint64 relayerFeePct,
uint64 realizedLpFeePct,
uint32 depositId,
address destinationToken,
address caller,
address indexed depositor,
address recipient
address recipient,
bool isSlowRelay
);
event RelayedRootBundle(uint32 indexed rootBundleId, bytes32 relayerRefundRoot, bytes32 slowRelayRoot);
event ExecutedRelayerRefundRoot(
Expand Down Expand Up @@ -397,7 +384,7 @@ abstract contract SpokePool is SpokePoolInterface, Testable, Lockable, MultiCall

uint256 fillAmountPreFees = _fillRelay(relayHash, relayData, maxTokensToSend, relayerFeePct, false);

_emitFillRelay(relayHash, fillAmountPreFees, repaymentChainId, relayerFeePct, relayData);
_emitFillRelay(relayHash, fillAmountPreFees, repaymentChainId, relayerFeePct, relayData, false);
}

/**
Expand Down Expand Up @@ -451,7 +438,7 @@ abstract contract SpokePool is SpokePoolInterface, Testable, Lockable, MultiCall
bytes32 relayHash = _getRelayHash(relayData);
uint256 fillAmountPreFees = _fillRelay(relayHash, relayData, maxTokensToSend, newRelayerFeePct, false);

_emitFillRelay(relayHash, fillAmountPreFees, repaymentChainId, newRelayerFeePct, relayData);
_emitFillRelay(relayHash, fillAmountPreFees, repaymentChainId, newRelayerFeePct, relayData, false);
}

/**************************************
Expand Down Expand Up @@ -624,11 +611,8 @@ abstract contract SpokePool is SpokePoolInterface, Testable, Lockable, MultiCall
// funds in all cases.
uint256 fillAmountPreFees = _fillRelay(relayHash, relayData, relayData.amount, relayerFeePct, true);

_emitExecutedSlowRelayRoot(relayHash, fillAmountPreFees, relayData);

// Note: Set repayment chain ID to 0 to indicate that there is no repayment to be made. The off-chain data
// worker can use repaymentChainId=0 as a signal to ignore such relays for refunds.
_emitFillRelay(relayHash, fillAmountPreFees, 0, relayerFeePct, relayData);
// Note: Set repayment chain ID to 0 arbitrarily for slow relays.
_emitFillRelay(relayHash, fillAmountPreFees, 0, relayerFeePct, relayData, true);
}

function _setCrossDomainAdmin(address newCrossDomainAdmin) internal {
Expand Down Expand Up @@ -790,7 +774,8 @@ abstract contract SpokePool is SpokePoolInterface, Testable, Lockable, MultiCall
uint256 fillAmount,
uint256 repaymentChainId,
uint64 relayerFeePct,
RelayData memory relayData
RelayData memory relayData,
bool isSlowRelay
) internal {
emit FilledRelay(
relayHash,
Expand All @@ -805,28 +790,8 @@ abstract contract SpokePool is SpokePoolInterface, Testable, Lockable, MultiCall
relayData.destinationToken,
msg.sender,
relayData.depositor,
relayData.recipient
);
}

function _emitExecutedSlowRelayRoot(
bytes32 relayHash,
uint256 fillAmount,
RelayData memory relayData
) internal {
emit ExecutedSlowRelayRoot(
relayHash,
relayData.amount,
relayFills[relayHash],
fillAmount,
relayData.originChainId,
relayData.relayerFeePct,
relayData.realizedLpFeePct,
relayData.depositId,
relayData.destinationToken,
msg.sender,
relayData.depositor,
relayData.recipient
relayData.recipient,
isSlowRelay
);
}

Expand Down
3 changes: 2 additions & 1 deletion test/SpokePool.Relay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ describe("SpokePool Relayer Logic", async function () {
relayData.destinationToken,
relayer.address,
relayData.depositor,
relayData.recipient
relayData.recipient,
false
);

// The collateral should have transferred from relayer to recipient.
Expand Down
41 changes: 2 additions & 39 deletions test/SpokePool.SlowRelay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,44 +101,6 @@ describe("SpokePool Slow Relay Logic", async function () {
);
});

it("Simple SlowRelay ERC20 ExecutedSlowRelayRoot event", async function () {
const relay = relays.find((relay) => relay.destinationToken === destErc20.address)!;

await expect(
spokePool
.connect(relayer)
.executeSlowRelayRoot(
...getExecuteSlowRelayParams(
depositor.address,
recipient.address,
destErc20.address,
consts.amountToRelay,
consts.originChainId,
consts.realizedLpFeePct,
consts.depositRelayerFeePct,
consts.firstDepositId,
0,
tree.getHexProof(relays.find((relay) => relay.destinationToken === destErc20.address)!)
)
)
)
.to.emit(spokePool, "ExecutedSlowRelayRoot")
.withArgs(
tree.hashFn(relay),
consts.amountToRelay,
consts.amountToRelay,
consts.amountToRelay,
consts.originChainId,
consts.depositRelayerFeePct,
consts.realizedLpFeePct,
consts.firstDepositId,
destErc20.address,
relayer.address,
depositor.address,
recipient.address
);
});

it("Simple SlowRelay ERC20 FilledRelay event", async function () {
const relay = relays.find((relay) => relay.destinationToken === destErc20.address)!;

Expand Down Expand Up @@ -174,7 +136,8 @@ describe("SpokePool Slow Relay Logic", async function () {
destErc20.address,
relayer.address,
depositor.address,
recipient.address
recipient.address,
true
);
});

Expand Down