- Users deposit stablecoin USDT into the contract.
- Once the relayer detects the deposit event, it invokes the perpetual contract engine API to process the deposit.
- After the deposit is completed, users can place orders, cancel orders, and make withdrawals on the perpetual contract platform.
- The zk calculation service performs calculations and generates zk proofs for transactions such as deposits, withdrawals, order placement, order cancellation, and successful order matching.
- The generated proofs, along with the corresponding transaction list, are sent to the contract to update the user's state root and withdrawal Merkle Root.
- Users send withdrawal proofs to the contract to initiate withdrawals.
function deposit(address user, uint256 amount) public whenNotPaused
- file: interactions/Deposits.sol
- users call this method to deposit funds to a specified user
- emit LogDeposit event
- zk calculation service sends proof
- file: perp/Perp.sol
function forgeBatch( uint256 newRoots, bytes calldata txsData, bytes calldata newOrders, bytes calldata newAccounts, uint8 verifierIdx, uint256[8] calldata proof ) external virtual whenNotPaused {
- file: perp/Perp.sol
- user withdraws
- file: perp/Perp.sol
-
function withdrawMerkleProof( uint192 amount, uint256 babyPubKey, uint32 numExitRoot, uint256[] memory siblings, uint48 idx ) external whenNotPaused
- Install foundry:
https://book.getfoundry.sh/getting-started/installation
- Install dependencies:
forge install foundry-rs/forge-std --no-git
npm install
- Run tests:
forge test
- Files Requiring Audit
- contracts/Perpetual.sol
- contracts/interactions/TokenAssetData.sol
- contracts/interactions/Deposits.sol
- contracts/interfaces/MTokenTransfers.sol
- contracts/components/TokenTransfers.sol
- contracts/components/MainStorage.sol
- contracts/perp/Perp.sol
- contracts/perp/interfaces/VerifierRollupInterface.sol
- contracts/perp/lib/PerpHelpers.sol
- Files Exempt from Audit
- contracts/libraries/Common.sol
- contracts/upgradability/Timelock.sol
- contracts/PerpetualProxy.sol
- contracts/perp/test/VerifierRollupHelper.sol
- contracts/components/Initializable.sol
- contracts/components/Ownable.sol
- contracts/components/Pausable.sol