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
12 changes: 6 additions & 6 deletions contracts/SpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -225,16 +225,16 @@ abstract contract SpokePool is Testable, Lockable, MultiCaller {
});
bytes32 relayHash = _getRelayHash(relayData);

// Check that the caller is filling a non zero amount of the relay and the relay has not already been completely
// filled. Note that the `relays` mapping will point to the amount filled so far for a particular `relayHash`,
// so this will start at 0 and increment with each fill.
require(maxTokensToSend > 0 && relayFills[relayHash] < totalRelayAmount, "Cannot send 0, or relay filled");
// Check that the relay has not already been completely filled. Note that the `relays` mapping will point to
// the amount filled so far for a particular `relayHash`, so this will start at 0 and increment with each fill.
require(relayFills[relayHash] < totalRelayAmount, "relay filled");

// Stores the equivalent amount to be sent by the relayer before fees have been taken out.
uint256 fillAmountPreFees = _computeAmountPreFees(maxTokensToSend, (realizedLpFeePct + relayerFeePct));
uint256 fillAmountPreFees = 0;

// Adding brackets "stack too deep" solidity error.
{
if (maxTokensToSend > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you think of anywhere that we use the filledAmount stored in the contract as a proxy for the relay being "initialized"? If so, this relay would still be considered uninitialized. I can't think of anywhere this would cause problems, just wanted to ask in case you could.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't, there isn't really a good way of checking whether a relay was initialized at the moment. For that we'd need to expand the data associated with each relay hash

fillAmountPreFees = _computeAmountPreFees(maxTokensToSend, (realizedLpFeePct + relayerFeePct));
// If user's specified max amount to send is greater than the amount of the relay remaining pre-fees,
// we'll pull exactly enough tokens to complete the relay.
uint256 amountToSend = maxTokensToSend;
Expand Down
20 changes: 4 additions & 16 deletions test/SpokePool.Relay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ describe("SpokePool Relayer Logic", async function () {
amountToRelay,
repaymentChainId
)
).to.be.reverted;
).to.be.revertedWith("invalid fees");
await expect(
spokePool
.connect(relayer)
Expand All @@ -178,7 +178,7 @@ describe("SpokePool Relayer Logic", async function () {
amountToRelay,
repaymentChainId
)
).to.be.reverted;
).to.be.revertedWith("invalid fees");
await expect(
spokePool
.connect(relayer)
Expand All @@ -196,19 +196,7 @@ describe("SpokePool Relayer Logic", async function () {
amountToRelay,
repaymentChainId
)
).to.be.reverted;

// Fill amount cannot be 0.
await expect(
spokePool
.connect(relayer)
.fillRelay(
...getRelayHash(depositor.address, recipient.address, firstDepositId, originChainId, destErc20.address)
.relayDataValues,
"0",
repaymentChainId
)
).to.be.reverted;
).to.be.revertedWith("invalid fees");

// Relay already filled
await spokePool.connect(relayer).fillRelay(
Expand All @@ -226,6 +214,6 @@ describe("SpokePool Relayer Logic", async function () {
"1",
repaymentChainId
)
).to.be.reverted;
).to.be.revertedWith("relay filled");
});
});