Skip to main content

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.

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.

Deployed contract

The TradingVault is deployed at the following address on BNB Smart Chain Testnet:
0x1f81d955D1348721553F8948Fb032973e9Db6Eff
You can inspect every transaction, balance, and event on the block explorer: View on BscScan 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’s Ownable 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

Called when you enter an amount and confirm a deposit in the Trading tab. The function is payable, meaning it accepts BNB directly. Your deposited amount is recorded against your wallet address in the contract’s internal ledger.
function deposit() external payable
Requirements:
  • Amount must be greater than zero
  • Amount must be at least 0.01 BNB (MIN_DEPOSIT)
Emits: Deposited(address indexed user, uint256 amount)
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.
function withdraw(uint256 amount) external
Requirements:
  • amount must be greater than zero
  • Your vault balance must cover amount
  • The contract must hold sufficient BNB
Emits: Withdrawn(address indexed user, uint256 amount)
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.
function executeBuyTrade(
  string memory pair,
  address tokenOut,
  uint256 amountIn,
  uint256 minAmountOut
) external
Subject to: 30-second cooldown, MAX_TRADE_SIZE limit, slippage checkEmits: TradeExecuted(...), ProfitDistributed(...)
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.
function executeSellTrade(
  string memory pair,
  address tokenIn,
  uint256 amountIn,
  uint256 minAmountOut
) external
Subject to: 30-second cooldown, MAX_TRADE_SIZE_TOKENS limit, slippage checkEmits: TradeExecuted(...), ProfitDistributed(...)
Called when you withdraw accumulated USDT or USDC profits. The function transfers the requested token amount from the contract to your wallet.
function withdrawProfits(address token, uint256 amount) external
Requirements:
  • token must be USDT or USDC
  • Your profit balance must cover amount
  • The contract must hold sufficient token balance
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.
function getUserInfo(address user)
  external
  view
  returns (
    uint256 balance,
    uint256 profit,
    uint256 lastTradeTime,
    uint256 tradeCount
  )
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.
EventWhen 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:
NetworkRouter address
BNB Mainnet (0x38)0x10ED43C718714eb63d5aA57B78B54704E256024E
BNB Testnet (0x61)0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3
PancakeSwap Testnet has limited liquidity. Real on-chain swaps may fail if a liquidity pool does not exist for the selected pair. Use Demo mode to test trading logic without requiring on-chain liquidity.