Every deposit, trade, and withdrawal you make through Quantum Finance is handled by the TradingVault smart contract deployed on BNB Smart Chain. The contract is written in Solidity, audited against OpenZeppelin’s security primitives, and enforces all fund custody rules on-chain — no centralized server can move your funds. This page describes what each function does, what events the contract emits, and where to find the deployed contract.Documentation Index
Fetch the complete documentation index at: https://quantumfinance.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Deployed contract
The TradingVault is deployed at the following address on BNB Smart Chain Testnet:The Quantum Finance interface calls all contract functions automatically on your behalf. You do not need to interact with the contract directly — this reference is provided for transparency and for developers who want to verify behavior.
Contract overview
The TradingVault is built on top of OpenZeppelin’sOwnable and ReentrancyGuard contracts, which protect against ownership exploits and reentrancy attacks. Key properties enforced by the contract:
- Minimum deposit: 0.01 BNB
- Maximum trade size: 10 BNB (or 5,000 tokens for token-denominated trades)
- Max slippage: 5% per swap on PancakeSwap
- Cooldown: 30 seconds between trades per user
- Fee: 50% of trade output goes to the protocol treasury; 50% is credited to your profit balance
Functions
deposit() — fund your vault
deposit() — fund your vault
Called when you enter an amount and confirm a deposit in the Trading tab. The function is Requirements:
payable, meaning it accepts BNB directly. Your deposited amount is recorded against your wallet address in the contract’s internal ledger.- Amount must be greater than zero
- Amount must be at least 0.01 BNB (
MIN_DEPOSIT)
Deposited(address indexed user, uint256 amount)withdraw(uint256 amount) — pull funds from the vault
withdraw(uint256 amount) — pull funds from the vault
Called when you enter an amount in the Withdraw field and confirm. The contract checks that your recorded balance covers the requested amount before transferring BNB back to your wallet.Requirements:
amountmust be greater than zero- Your vault balance must cover
amount - The contract must hold sufficient BNB
Withdrawn(address indexed user, uint256 amount)executeBuyTrade() — engine opens a position
executeBuyTrade() — engine opens a position
Called automatically by the engine when it enters a trade. The engine swaps BNB from your vault balance into the quote token (USDT or USDC) via PancakeSwap. Your vault balance is debited, and the resulting tokens are held in the contract. After fees, your profit balance is credited.Subject to: 30-second cooldown, MAX_TRADE_SIZE limit, slippage checkEmits:
TradeExecuted(...), ProfitDistributed(...)executeSellTrade() — engine closes a position
executeSellTrade() — engine closes a position
Called automatically by the engine when it exits a trade. The engine swaps tokens from your profit balance back into BNB via PancakeSwap. After fees, your BNB vault balance is increased.Subject to: 30-second cooldown, MAX_TRADE_SIZE_TOKENS limit, slippage checkEmits:
TradeExecuted(...), ProfitDistributed(...)withdrawProfits(address token, uint256 amount) — claim token profits
withdrawProfits(address token, uint256 amount) — claim token profits
Called when you withdraw accumulated USDT or USDC profits. The function transfers the requested token amount from the contract to your wallet.Requirements:
tokenmust be USDT or USDC- Your profit balance must cover
amount - The contract must hold sufficient token balance
getUserInfo(address user) — read vault balances
getUserInfo(address user) — read vault balances
Returns a snapshot of your vault state. The Quantum Finance interface calls this function to display your live balance and profit figures in the dashboard.This is a read-only (
view) call — it costs no gas and does not modify any state.Events
The contract emits the following events. You can query them directly on BscScan or via any EVM-compatible indexer.| Event | When it fires |
|---|---|
Deposited(address indexed user, uint256 amount) | You successfully deposit BNB into the vault |
Withdrawn(address indexed user, uint256 amount) | You successfully withdraw BNB from the vault |
TradeExecuted(address indexed user, string pair, uint256 amountIn, uint256 amountOut, bool isBuy, uint256 fee, uint256 timestamp) | The engine completes a buy or sell swap on PancakeSwap |
ProfitDistributed(address indexed user, uint256 userShare, uint256 treasuryShare) | After a trade, profit is split between your account and the protocol treasury |
EmergencyWithdraw(address indexed user, uint256 amount) | The contract owner invokes emergency recovery (owner-only) |
DEX integration
The TradingVault routes all swaps through PancakeSwap. The router addresses used are:| Network | Router address |
|---|---|
BNB Mainnet (0x38) | 0x10ED43C718714eb63d5aA57B78B54704E256024E |
BNB Testnet (0x61) | 0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3 |