Bridge
Purpose: Cross-system token bridging into/out of Mercata.
Functional summary:
Bridge-in (deposit): Off-chain relayer attests an external-chain deposit. The bridge records the deposit with replay protection and, upon confirmation, mints either USDST or the wrapped STRATO token to the recipient.
Bridge-out (withdrawal): User escrows tokens on STRATO. Relayer creates and executes the custody transaction on the external chain; the bridge burns escrowed tokens and finalizes. A deterministic abort path refunds escrowed tokens if unprocessed after a timeout.
Key contracts:
MercataBridge.sol: Handles deposit/withdraw workflows, tracking and mint/burn or escrow logic.
Trust model & guarantees:
Trust model: A designated relayer coordinates verification and execution. No light-client; external finality and replay protection are enforced by the relayer and on-chain checks.
Guarantees:
Canonical mint once per
(externalChainId, externalTxHash)via replay protectionEscrowed withdrawal funds remain safe and are refundable via abort if not progressed
Independent circuit breakers for deposit and withdrawal legs
Flows and events:
Deposit (Bridge-in):
Relayer observes external deposit and calls
deposit(externalChainId, externalSender, externalTxHash, stratoToken, amount, stratoRecipient, mintUSDST)Checks: chain enabled; asset permissions; token active (or USDST mint path); unique
(chainId, txHash)Emits:
DepositInitiated(externalChainId, externalTxHash, stratoToken, amount, stratoRecipient, externalSender, mintUSDST)2a) If verified OK:confirmDeposit(externalChainId, externalTxHash)→ mintsUSDST_ADDRESSorstratoToken→DepositCompleted2b) If verification fails:reviewDeposit(externalChainId, externalTxHash)→DepositPendingReview
Withdrawal (Bridge-out):
User calls
requestWithdrawal(externalChainId, externalRecipient, stratoToken, amount, mintUSDST)Pulls escrow:
transferFrom(msg.sender, bridge, amount)for USDST orstratoTokenCreates deterministic
withdrawalIdand storesWithdrawalInfoEmits:
WithdrawalRequested(withdrawalId, destChainId, token, amount, user, dest, mint)
Relayer creates custody tx off-chain and calls
confirmWithdrawal(id, custodyTxHash)→ statusPENDING_REVIEW→WithdrawalPendingAfter execution on custody:
finaliseWithdrawal(id, custodyTxHash)→ burns escrow (USDST or token) →WithdrawalCompletedAbort path:
abortWithdrawal(id)Relayer may abort while
INITIATED|PENDING_REVIEWUser may abort only while
INITIATEDand afterrequestedAt + WITHDRAWAL_ABORT_DELAY (172800s)Refunds escrowed tokens and emits
WithdrawalAborted
Permissions & registries:
Assets are registered per
(stratoToken, externalChainId)with:permissionsbitmask:PERMISSION_WRAP=0b01,PERMISSION_MINT=0b10maxPerTxhard cap (0 = unlimited)
Chains include custody, deposit router,
enabled, andlastProcessedBlockhints.
Replay protection:
Deposits keyed by
(externalChainId, externalTxHash)must be unique; duplicates revert.
Pause & admin controls:
setPause(depositsPaused, withdrawalsPaused);setRelayer;setTokenFactory;setUSDSTAddress.
USDST vs wrapped tokens:
mintUSDST=true: USDST minted/burned; otherwise the configuredstratoToken.
Batch ops:
depositBatch,confirmDepositBatch,reviewDepositBatch,confirmWithdrawalBatch,finaliseWithdrawalBatch,abortWithdrawalBatch.
Constraints & checks (selected):
Chain enabled; asset exists; correct permissions for path; token activity rules; per-tx cap.
Simulate full flows; verify event sequences, replay protection, permissions, and pause/abort.
Prod:
Connect relayer and custody; enforce confirmation windows, review process, and monitor for anomalies. Use pause toggles during incidents.
Last updated