Add configurable per-token deposit limit gateway (#817) - #887
Merged
mijinummi merged 2 commits intoJul 30, 2026
Conversation
Introduce BridgeGateway.sol, a single-ERC20-deposit entry point modeled on the existing BatchBridgeRouter/NativeBridgeRouter IBridgeVault pattern. Deposits are bounded by an admin-configurable maxDepositLimit[token] mapping, rejecting oversized single-transaction deposits with a custom DepositExceedsLimit(amount, limit) error before forwarding tokens and dispatching vault.lock(...). Caps default to 0 (unlimited) until an admin opts a token into a bound via setMaxDepositLimit, following DepositGuard's existing convention. Covered by test/bridge/BridgeGateway.test.ts (12 cases: cap enforcement, admin-gated dynamic cap updates, non-admin rejection, vault forwarding/lock args, event emission, and input validation).
|
@Cybermaxi7 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Collaborator
|
Hi @Cybermaxi7 , please resolve the conflict |
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #817
Summary
contracts/bridge/BridgeGateway.soldidn't exist — this repo's existing single-deposit-cap logic (contracts/core/DepositGuard.sol) has no lock/burn dispatch at all, and the existing routers (BatchBridgeRouter/NativeBridgeRouter) handle multi-token/native deposits but not a plain single-ERC20 gateway. Built the missing piece, modeled on both:AccessControl-gated admin (perDepositGuard's style) +vault.lock(...)dispatch (per the routers'IBridgeVaultpattern)mapping(address => uint256) public maxDepositLimit,setMaxDepositLimit(admin-only),deposit(token, amount, destinationChainId, recipient)enforcing the cap before forwarding to the vaultrequire(..., "DepositExceedsLimit()")(a string that merely looks like a custom error), but the Acceptance Criteria explicitly wants a real custom error — implementederror DepositExceedsLimit(uint256 amount, uint256 limit)accordinglymaxDepositLimit == 0means "no cap configured" (unlimited), matchingDepositGuard.sol's existing convention for consistencyAcceptance criteria
DepositExceedsLimit()Test plan
test/bridge/BridgeGateway.test.ts— 12/12 passing (cap enforcement w/ exact args, boundary at exact cap, unlimited-when-zero, admin set/update, non-admin rejection, vault forwarding +lock()args, event emission, input validation)npx hardhat compile— clean, no new warningsNote
Found (and confirmed independently across the other 3 PRs in this batch) that
test/router/NativeBridgeRouter.test.tsand a few other existing test files useimport { ethers } from "hardhat", which doesn't work under this repo's actual Hardhat 3 setup — a pre-existing, unrelated break. Used the workinghre.network.create()convention (perBatchBridgeRouter.test.ts) for this PR's own test file instead.