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.