From 45a2c01e33a56a76a886198d93466d3bcd68d2c3 Mon Sep 17 00:00:00 2001 From: Alexey Date: Tue, 26 Oct 2021 13:10:30 +0300 Subject: [PATCH] more docs --- contracts/TornadoPool.sol | 12 ++++++++++++ contracts/bridge/CrossChainGuard.sol | 3 +++ contracts/bridge/L1Helper.sol | 11 +++++++++++ 3 files changed, 26 insertions(+) diff --git a/contracts/TornadoPool.sol b/contracts/TornadoPool.sol index 886f26d..51cd01b 100644 --- a/contracts/TornadoPool.sol +++ b/contracts/TornadoPool.sol @@ -19,6 +19,9 @@ import { CrossChainGuard } from "./bridge/CrossChainGuard.sol"; import { IVerifier } from "./interfaces/IVerifier.sol"; import "./MerkleTreeWithHistory.sol"; +/** @dev This contract(pool) allows deposit of an arbitrary amount to it, shielded transfer to another registered user inside the pool + * and withdrawal from the pool. Project utilizes UTXO model to handle users' funds. + */ contract TornadoPool is MerkleTreeWithHistory, IERC20Receiver, ReentrancyGuard, CrossChainGuard { int256 public constant MAX_EXT_AMOUNT = 2**248; uint256 public constant MAX_FEE = 2**248; @@ -71,6 +74,13 @@ contract TornadoPool is MerkleTreeWithHistory, IERC20Receiver, ReentrancyGuard, @dev The constructor @param _verifier2 the address of SNARK verifier for 2 inputs @param _verifier16 the address of SNARK verifier for 16 inputs + @param _levels hight of the commitments merkle tree + @param _hasher hasher address for the merkle tree + @param _token token address for the pool + @param _omniBridge omniBridge address for specified token + @param _l1Unwrapper address of the L1Helper + @param _governance owner address + @param _l1ChainId chain id of L1 */ constructor( IVerifier _verifier2, @@ -98,6 +108,8 @@ contract TornadoPool is MerkleTreeWithHistory, IERC20Receiver, ReentrancyGuard, super._initialize(); } + /** @dev Main function that allows deposits, transfers and withdrawal. + */ function transact(Proof memory _args, ExtData memory _extData) public { if (_extData.extAmount > 0) { // for deposits from L2 diff --git a/contracts/bridge/CrossChainGuard.sol b/contracts/bridge/CrossChainGuard.sol index eab9c91..aceeee2 100644 --- a/contracts/bridge/CrossChainGuard.sol +++ b/contracts/bridge/CrossChainGuard.sol @@ -3,6 +3,9 @@ pragma solidity ^0.7.0; import { IAMB } from "../interfaces/IBridge.sol"; +/** @dev Special cross chain guard that can authorize caller as owner of this contract according to XDAI AMB bridge protocol. + * more info here https://docs.tokenbridge.net/amb-bridge/development-of-a-cross-chain-application/how-to-develop-xchain-apps-by-amb#receive-a-method-call-from-the-amb-bridge + */ contract CrossChainGuard { IAMB public immutable ambBridge; bytes32 public immutable ownerChainId; diff --git a/contracts/bridge/L1Helper.sol b/contracts/bridge/L1Helper.sol index 5831736..4526c93 100644 --- a/contracts/bridge/L1Helper.sol +++ b/contracts/bridge/L1Helper.sol @@ -1,4 +1,15 @@ // SPDX-License-Identifier: MIT +// https://tornado.cash +/* + * d888888P dP a88888b. dP + * 88 88 d8' `88 88 + * 88 .d8888b. 88d888b. 88d888b. .d8888b. .d888b88 .d8888b. 88 .d8888b. .d8888b. 88d888b. + * 88 88' `88 88' `88 88' `88 88' `88 88' `88 88' `88 88 88' `88 Y8ooooo. 88' `88 + * 88 88. .88 88 88 88 88. .88 88. .88 88. .88 dP Y8. .88 88. .88 88 88 88 + * dP `88888P' dP dP dP `88888P8 `88888P8 `88888P' 88 Y88888P' `88888P8 `88888P' dP dP + * ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo + */ + pragma solidity ^0.7.0; pragma abicoder v2;