ShinobiCashEntrypoint
The central orchestrator for cross-chain operations on the pool chain (Arbitrum Sepolia).
Overview
ShinobiCashEntrypoint inherits from:
Entrypoint(privacy-pools-core)ShinobiCashCrosschainState(cross-chain configuration)IShinobiCashCrossChainHandler(handler interface)
It coordinates all cross-chain deposits and withdrawals, manages settler addresses, and handles refunds for failed intents.
State Variables
// Settler addresses
address public withdrawalInputSettler; // For withdrawal intents
address public depositOutputSettler; // For deposit fills
// Per-chain destination configuration
mapping(uint256 => WithdrawalChainConfig) public withdrawalChainConfig;
// Precommitment replay prevention
mapping(uint256 => bool) public usedPrecommitments;WithdrawalChainConfig
Configuration for each supported destination chain:
struct WithdrawalChainConfig {
bool isConfigured; // Whether this destination is active
uint32 fillDeadline; // Default fill deadline (seconds from now)
uint32 expiry; // Default expiry (seconds from now)
address withdrawalOutputSettler; // ShinobiWithdrawalOutputSettler on destination
address withdrawalFillOracle; // Output oracle on destination chain
address fillOracle; // Fill oracle for validating fills (dest → origin)
}Key Functions
crosschainWithdrawal
Main entry point for cross-chain withdrawals. Validates the ZK proof and creates an OIF intent.
function crosschainWithdrawal(
IPrivacyPool.Withdrawal calldata _withdrawal,
CrossChainProofLib.CrossChainWithdrawProof calldata _proof,
uint256 _scope
) external nonReentrant- Validate
withdrawalInputSettleris configured - Validate withdrawn amount > 0
- Validate processooor is this entrypoint
- Fetch pool by scope, validate exists
- Decode
CrossChainRelayDatafrom withdrawal.data - Validate destination chain is configured
- Validate relay fee ≤ max allowed
- Execute
pool.crosschainWithdraw()(validates ZK proof) - Calculate fees (relay + solver)
- Create OIF intent with configured destination settings
- Transfer relay fee to feeRecipient
- Open intent on
ShinobiInputSettler(escrows funds) - Emit
CrossChainWithdrawalIntentRelayedevent
crosschainDeposit
Handles verified cross-chain deposits. Called by ShinobiDepositOutputSettler after oracle validation.
function crosschainDeposit(
address _depositor,
uint256 _amount,
uint256 _precommitment
) external payable nonReentrant onlyDepositOutputSettler- Validate caller is the configured
depositOutputSettler - Validate precommitment hasn't been used (replay prevention)
- Mark precommitment as used
- Insert commitment into the pool's Merkle tree
- Emit deposit event
handleRefund
Handles refunds for failed cross-chain withdrawals. Called by ShinobiInputSettler when an intent expires.
function handleRefund(
uint256 _refundCommitmentHash,
uint256 _amount,
uint256 _scope
) external payable onlyWithdrawalInputSettler- Validate caller is the configured
withdrawalInputSettler - Fetch pool by scope
- Call
pool.handleRefund()to insert refund commitment - User can later withdraw the refund normally
setWithdrawalChainConfig
Configure a destination chain for cross-chain withdrawals.
function setWithdrawalChainConfig(
uint256 _chainId,
address _outputSettler,
address _outputOracle,
address _fillOracle,
uint32 _fillDeadline,
uint32 _expiry
) external onlyRole(_OWNER_ROLE)Access Control
| Function | Access |
|---|---|
crosschainWithdrawal | Public (anyone with valid proof) |
crosschainDeposit | onlyDepositOutputSettler |
handleRefund | onlyWithdrawalInputSettler |
setWithdrawalChainConfig | onlyRole(_OWNER_ROLE) |
setWithdrawalInputSettler | onlyRole(_OWNER_ROLE) |
setDepositOutputSettler | onlyRole(_OWNER_ROLE) |
Events
event CrossChainWithdrawalIntentRelayed(
bytes32 indexed orderId,
address indexed recipient,
uint256 destinationChainId,
uint256 amount,
uint256 solverFee
);
event CrossChainDepositProcessed(
address indexed depositor,
uint256 amount,
uint256 precommitment
);Security Considerations
- Proof validation — ZK proof is validated in the pool before intent creation
- Replay prevention — Precommitments are marked as used
- Access control — Only authorized settlers can call deposit/refund handlers
- Reentrancy protection — All entry points use
nonReentrant
Source Code
Related
- Privacy Pool — Pool contract that validates proofs
- OIF Settlers — Settlement contracts
- Cross-Chain Architecture — How cross-chain works