Tariffs and Fees
TrexWallet uses a flexible, multi-dimensional tariff system to configure fees, limits, and service conditions for every type of financial operation. Tariffs control how much users pay for transfers, exchanges, withdrawals, and other operations.
How Tariff Matching Works
When a transaction is processed, TrexWallet finds the best matching tariff by checking the configured dimensions simultaneously:
| Dimension | Description | Example |
|---|---|---|
| tx_type | Transaction type | InnerTransfer, Exchange, Swap, Outcome |
| from_wallet_gr | Sender's wallet group (bitmask, 0 = any) | Premium users (group bit 3) |
| to_wallet_gr | Recipient's wallet group (bitmask, 0 = any) | Merchant wallets (group bit 5) |
| cur | Rule currency code (empty = any) | USDT, BTC, EUR |
| network | Terminal id (0 = any) | 1, 2 |
| crm_id_from | Sender CRM identity (0 = any) | Specific user |
| crm_id_to | Recipient CRM identity (0 = any) | Specific merchant |
| agent_id | Agent/referral id (0 = any) | Partner commissions |
| app_id | Merchant application id (0 = any) | Per-merchant tariffs |
| project_from / project_to | Project filter on sender/recipient | Multi-project deployments |
| min/max_amount | Amount boundaries | Different fees per amount band |
Priority-Based Selection
Tariffs are sorted by priority (descending). The first matching tariff wins. This allows you to create:
- General rules (low priority) — apply to all users by default
- Specific rules (high priority) — override for certain currencies, user groups, or amounts
Priority 100: BTC withdrawal for Premium users → 0.1% fee
Priority 50: BTC withdrawal for all users → 0.5% fee
Priority 10: Any withdrawal → 1% fee (catch-all)
A Premium user withdrawing BTC matches priority 100 first. A regular user withdrawing ETH falls through to priority 10.
Wallet Groups
Users are assigned to wallet groups (0–63) that act as user tiers. Groups are encoded as bitmask flags, allowing a single tariff to match multiple groups simultaneously.
Common group assignments:
- Group 0 — Default (all new users)
- Group 1 — Verified users
- Group 2 — Premium/VIP
- Group 3 — Merchants
- Group 4 — Agents/partners
Fee Types
Each tariff defines up to three fee components:
| Fee Type | Field | Description |
|---|---|---|
| Percent fee | percent_fee | Percentage of the transaction amount (e.g., 0.5%) |
| Fixed fee | fee | Fixed amount in the transaction currency (e.g., 1.00 USDT) |
| Network fee | UseNetFee flag | Materializes the terminal network fee into the tariff's fixed fee |
The applied fee is amount × percent_fee + fixed_fee. With UseNetFee, the fixed fee is
set to terminal network fee × tariff rate; an empty or zero rate is treated as 1.
Special Fee Scenarios
- Exchange operations use two tariffs: one for the source currency, one for the target
- Swap operations use a pair tariff matching both currencies
- Network fees are dynamic — updated in real-time from blockchain scanners
- Zero-fee tariffs are valid (e.g., free internal transfers) and logged for audit
Tariff Flags
| Value | Flag | Description |
|---|---|---|
| 1 | Deny | Block this operation type entirely |
| 2 | UseNetFee | Add dynamic network fee (from the source network) multiplied by rate |
| 4 | AgentRule | Tariff applies agent commission rules (referral → agent) |
| 8 | ChargeBackProtect | Subtract "fresh" incoming volume from the withdrawable amount |
| 16 | ManualReviewRequired | Payout / settlement requires manual review before execution |
| 32 | IgnoreAddressExpense | Exclude terminal network expense from the profit split for this tariff |
| 1073741824 | Disabled | Tariff exists but is not active |
Fee Preview API
Before executing a transaction, you can preview the exact fee that will be applied:
GET /trex/v1/estimate_fee
?tx_type=Outcome
¤cy=USDT
&amount=1000
&network_from=2
&network_to=4
&app_id=0
For exchange / swap requests pass tx_type=ExchangeToBroker (or SwapToBroker) plus to_currency. The endpoint returns the matched tariff (tag, percentFee, fixedFee, minAmount, maxAmount) and the calculated fee when amount is supplied — using the same matcher as production.
Admin Pages
Tariffs Page
The main tariff management page displays all configured tariff rules with filtering capabilities:
- Filter by tx_type — show tariffs for specific operation types
- Specificity indicator — shows how many dimensions a tariff matches (more specific = higher priority)
- "Any" badges — dimensions set to match everything are marked with gray badges
- app_id column — shows per-project tariff assignments
- Active/Disabled status — visual indication of tariff state
EditTariff Page
Create or modify tariff rules with organized fieldsets:
- General — priority, tag name, transaction type
- Groups — sender/recipient wallet groups
- Commission — percent fee, fixed fee, network fee flag, commission accounts
- Boundaries — minimum and maximum amount limits
- Filters — currency, network, CRM ID, agent, app_id filters
TariffTest Simulator
Test which tariff would apply for a given scenario without executing a real transaction:
- Select transaction type, currencies, networks, and amount
- TrexWallet evaluates the configured tariff rules using the live matching behavior
- Shows the winning tariff, calculated fees, and the match path
- Useful for verifying tariff configuration before going live
Configuration Examples
Basic withdrawal fee
Priority: 10, tx_type: Outcome, percent_fee: 1%, UseNetFee: true
→ All withdrawals: 1% + blockchain network fee
VIP user discount
Priority: 50, tx_type: Outcome, from_wallet_gr: 2, percent_fee: 0.3%, UseNetFee: true
→ VIP users (group 2): 0.3% + network fee (overrides the 1% default)
Free internal transfers
Priority: 10, tx_type: InnerTransfer, percent_fee: 0, fee: 0
→ All internal transfers are free
Per-merchant acquiring fee
Priority: 80, tx_type: PaymentOrder, app_id: 42, network: 190, percent_fee: 2.5%, fee: 0.50
→ Merchant app #42 paying via Stripe (terminal id 190): 2.5% + $0.50 fixed
Payment order tariffs (post-2026-05)
Payment order tariffs are applied exactly once when order_start is called for a chosen terminal
(legacy alias payment_order_start):
network = terminal idfor per-terminal Card / P2P / Crypto rules.network = 0for a terminal-agnostic rule.app_id = 0matches every merchant app; a non-zero value is a per-app override.currency payment spreadis added to the rate for cross-currency orders.
Built-in pay_* methods and merchant continuation flows (flow_path) do not re-apply the
tariff. The fee and rate selected by order_start remain fixed for that order.
Related
- Fees Concept — fee types and calculation logic
- Tokens and Networks — per-terminal
flow_path,capabilities,RequirePartnerInfo - Payment gateway processes —
order_startswitching point - Wallet Management — wallet groups and status flags
- Transaction States — when fees are applied in the lifecycle