Skip to content

Commit a208a1f

Browse files
authored
improve: Make MockSpokePool.depositV2 virtual (#430)
* feat: Add depositV2 to MockSpokePool to support relayer-v2/sdk-v2 unit tests These unit tests expect to query FundsDeposited events so we should add a function to the MockSpokePool so that they can access these older events using functions exported out of dist/test-utils * Add back logic * Update package.json * Update MockSpokePool.sol * Update package.json * WIP * Update HubPool.Fixture.ts
1 parent 0944d6a commit a208a1f

File tree

3 files changed

+6
-22
lines changed

3 files changed

+6
-22
lines changed

contracts/test/MockSpokePool.sol

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -122,30 +122,14 @@ contract MockSpokePool is SpokePool, OwnableUpgradeable {
122122
uint32 quoteTimestamp,
123123
bytes memory message,
124124
uint256 // maxCount
125-
) public payable nonReentrant unpausedDeposits {
126-
// Check that deposit route is enabled.
127-
require(enabledDepositRoutes[originToken][destinationChainId], "Disabled route");
128-
129-
// We limit the relay fees to prevent the user spending all their funds on fees.
130-
require(SignedMath.abs(relayerFeePct) < 0.5e18, "Invalid relayer fee");
131-
require(amount <= MAX_TRANSFER_SIZE, "Amount too large");
132-
133-
// Require that quoteTimestamp has a maximum age so that depositors pay an LP fee based on recent HubPool usage.
134-
// It is assumed that cross-chain timestamps are normally loosely in-sync, but clock drift can occur. If the
135-
// SpokePool time stalls or lags significantly, it is still possible to make deposits by setting quoteTimestamp
136-
// within the configured buffer. The owner should pause deposits if this is undesirable. This will underflow if
137-
// quoteTimestamp is more than depositQuoteTimeBuffer; this is safe but will throw an unintuitive error.
138-
139-
// slither-disable-next-line timestamp
140-
require(getCurrentTime() - quoteTimestamp <= depositQuoteTimeBuffer, "invalid quoteTimestamp");
141-
125+
) public payable virtual nonReentrant unpausedDeposits {
142126
// Increment count of deposits so that deposit ID for this spoke pool is unique.
143127
uint32 newDepositId = numberOfDeposits++;
144128

145129
// If the address of the origin token is a wrappedNativeToken contract and there is a msg.value with the
146130
// transaction then the user is sending ETH. In this case, the ETH should be deposited to wrappedNativeToken.
147131
if (originToken == address(wrappedNativeToken) && msg.value > 0) {
148-
require(msg.value == amount, "msg.value must match amount");
132+
require(msg.value == amount);
149133
wrappedNativeToken.deposit{ value: msg.value }();
150134
// Else, it is a normal ERC20. In this case pull the token from the user's wallet as per normal.
151135
// Note: this includes the case where the L2 user has WETH (already wrapped ETH) and wants to bridge them.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@across-protocol/contracts-v2",
3-
"version": "2.5.0-beta.4",
3+
"version": "2.5.0-beta.5",
44
"author": "UMA Team",
55
"license": "AGPL-3.0-only",
66
"repository": {

test/fixtures/HubPool.Fixture.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const hubPoolFixture = hre.deployments.createFixture(async ({ ethers }) =
88
return await deployHubPool(ethers);
99
});
1010

11-
export async function deployHubPool(ethers: any) {
11+
export async function deployHubPool(ethers: any, spokePoolName = "MockSpokePool") {
1212
const [signer, crossChainAdmin] = await ethers.getSigners();
1313

1414
// This fixture is dependent on the UMA ecosystem fixture. Run it first and grab the output. This is used in the
@@ -44,7 +44,7 @@ export async function deployHubPool(ethers: any) {
4444
// Deploy a mock chain adapter and add it as the chainAdapter for the test chainId. Set the SpokePool to address 0.
4545
const mockAdapter = await (await getContractFactory("Mock_Adapter", signer)).deploy();
4646
const mockSpoke = await hre.upgrades.deployProxy(
47-
await getContractFactory("MockSpokePool", signer),
47+
await getContractFactory(spokePoolName, signer),
4848
[0, crossChainAdmin.address, hubPool.address],
4949
{ kind: "uups", unsafeAllow: ["delegatecall"], constructorArgs: [weth.address] }
5050
);
@@ -55,7 +55,7 @@ export async function deployHubPool(ethers: any) {
5555
const mainnetChainId = await hre.getChainId();
5656
const mockAdapterMainnet = await (await getContractFactory("Mock_Adapter", signer)).deploy();
5757
const mockSpokeMainnet = await hre.upgrades.deployProxy(
58-
await getContractFactory("MockSpokePool", signer),
58+
await getContractFactory(spokePoolName, signer),
5959
[0, crossChainAdmin.address, hubPool.address],
6060
{ kind: "uups", unsafeAllow: ["delegatecall"], constructorArgs: [weth.address] }
6161
);

0 commit comments

Comments
 (0)