Skip to content

Add configurable per-token deposit limit gateway (#817) - #887

Merged
mijinummi merged 2 commits into
MDTechLabs:mainfrom
Cybermaxi7:feat/deposit-limit-gateway-817
Jul 30, 2026
Merged

Add configurable per-token deposit limit gateway (#817)#887
mijinummi merged 2 commits into
MDTechLabs:mainfrom
Cybermaxi7:feat/deposit-limit-gateway-817

Conversation

@Cybermaxi7

Copy link
Copy Markdown
Contributor

Closes #817

Summary

  • contracts/bridge/BridgeGateway.sol didn'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 (per DepositGuard's style) + vault.lock(...) dispatch (per the routers' IBridgeVault pattern)
  • mapping(address => uint256) public maxDepositLimit, setMaxDepositLimit (admin-only), deposit(token, amount, destinationChainId, recipient) enforcing the cap before forwarding to the vault
  • The issue's own Requirements text shows require(..., "DepositExceedsLimit()") (a string that merely looks like a custom error), but the Acceptance Criteria explicitly wants a real custom error — implemented error DepositExceedsLimit(uint256 amount, uint256 limit) accordingly
  • maxDepositLimit == 0 means "no cap configured" (unlimited), matching DepositGuard.sol's existing convention for consistency

Acceptance criteria

  • Transactions exceeding the cap revert with custom error DepositExceedsLimit()
  • Owner/Admin role can adjust token deposit caps dynamically

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 warnings

Note

Found (and confirmed independently across the other 3 PRs in this batch) that test/router/NativeBridgeRouter.test.ts and a few other existing test files use import { ethers } from "hardhat", which doesn't work under this repo's actual Hardhat 3 setup — a pre-existing, unrelated break. Used the working hre.network.create() convention (per BatchBridgeRouter.test.ts) for this PR's own test file instead.

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).
@drips-wave

drips-wave Bot commented Jul 30, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@mijinummi

Copy link
Copy Markdown
Collaborator

Hi @Cybermaxi7 , please resolve the conflict

@mijinummi
mijinummi merged commit 9f49c95 into MDTechLabs:main Jul 30, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] Add Configurable Upper Limit for Single Deposit Operations

2 participants