{"id":50112640,"url":"https://github.com/core-euler/trade_game","last_synced_at":"2026-05-23T13:05:57.228Z","repository":{"id":292672207,"uuid":"981494488","full_name":"core-euler/trade_game","owner":"core-euler","description":"Real Trading mini game","archived":false,"fork":false,"pushed_at":"2025-11-05T12:29:53.000Z","size":486,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-28T18:54:06.818Z","etag":null,"topics":["docker","nestjs","postgresql","redis","ton","tonconnect","vite","vue","websocket"],"latest_commit_sha":null,"homepage":"https://trade.ruble.website/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/core-euler.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-11T08:34:31.000Z","updated_at":"2025-11-05T12:29:57.000Z","dependencies_parsed_at":"2025-06-11T10:27:37.331Z","dependency_job_id":"5ad534e5-6270-4ff3-930e-dbdfd92c25ca","html_url":"https://github.com/core-euler/trade_game","commit_stats":null,"previous_names":["okoloboga/trade_game","core-euler/trade_game"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/core-euler/trade_game","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/core-euler%2Ftrade_game","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/core-euler%2Ftrade_game/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/core-euler%2Ftrade_game/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/core-euler%2Ftrade_game/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/core-euler","download_url":"https://codeload.github.com/core-euler/trade_game/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/core-euler%2Ftrade_game/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33396646,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-23T04:15:53.637Z","status":"ssl_error","status_checked_at":"2026-05-23T04:15:53.242Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","nestjs","postgresql","redis","ton","tonconnect","vite","vue","websocket"],"created_at":"2026-05-23T13:05:54.958Z","updated_at":"2026-05-23T13:05:57.223Z","avatar_url":"https://github.com/core-euler.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ruble Trade Game\n[Ruble Trade Game](https://t.me/ruble_caller_bot) is a Telegram Web App for trading TON/USDT pairs, managing wallet balances, and earning RUBLE tokens based on trading volume. Built with a Vue.js frontend and a NestJS backend, it integrates with the TON blockchain via TonConnect for wallet authentication and transactions. The app supports real-time market data, trade history, and user statistics, with a focus on a seamless user experience in a Telegram environment.\n\n**Features**\n\n- **Trading:** Execute buy/sell trades for TON/USDT with real-time market prices.\n- **Wallet Management:** Deposit and withdraw TON through a smart contract (WalletContract), and withdraw RUBLE tokens to a TON wallet.\n- **RUBLE Tokens:** Earn up to 10 RUBLE tokens daily based on trading volume (1 RUBLE per $10 traded).\n- **Trade History:** View trade history with details like type, amount, price, profit/loss, and date.\n- **Real-time Market Data:** Display current TON/USDT price via WebSocket (market.gateway.ts).\n- **Localization:** Support for English and Russian languages.\n- **Authentication:** Secure wallet-based authentication using TonConnect.\n- **Responsive UI:** Built with Vuetify for a modern, mobile-friendly interface.\n\n## Tech Stack\n### Frontend\n\n- **Vue.js 3:** Component-based UI with Composition API.\n- **Vite:** Build tool for fast development and optimized production builds.\n- **Vuetify:** Material Design component library.\n- **Pinia:** State management for stores (auth, wallet, trading, market).\n- **TonConnect (@townsquarelabs/ui-vue):** TON wallet integration.\n- **vue-i18n:** Localization for EN/RU.\n- **Axios:** HTTP client for API requests.\n- **@twa-dev/sdk:** Telegram Web App integration.\n- **lightweight-charts:** Charting for market data visualization.\n\n### Backend\n\n- **NestJS:** Node.js framework for scalable server-side applications.\n- **TypeORM:** ORM for PostgreSQL database management.\n- **Redis:** Caching for market prices and daily trading volumes.\n- **JWT:** Authentication for secure API endpoints.\n- **Axios:** For fetching market data.\n- **WebSocket:** Real-time market updates via market.gateway.ts.\n- **TON SDK:** Blockchain interactions for token transfers and smart contract integration.\n- **@ton/core:** TON blockchain utilities for building BOC (Bag of Cells) messages.\n\n### Database\n\n- **PostgreSQL:** Stores users, trades, and transactions.\n- **Entities:**\n  - **User:** Stores ton_address, token_balance, balance (TON - trading balance), usdt_balance.\n  - **Trade:** Stores trade details (type, amount, usdt_price, profit_loss, created_at).\n  - **Transaction:** Stores blockchain transactions (type: 'deposit' | 'withdraw' | 'ruble', amount, ton_tx_hash, status).\n\n### Blockchain\n\n- **Smart Contract (WalletContract):** TON smart contract written in Tact for managing user balances.\n  - **Deposit:** Users can deposit TON to the contract, increasing their on-chain balance.\n  - **Withdraw:** Users can withdraw TON from the contract with a configurable fee (withdrawFeeBps).\n  - **Balance Management:** On-chain balances stored in the contract, synchronized with database trading balances.\n  - **Contract Features:** Pause/unpause functionality, emergency withdraw (owner only), and jetton award support.\n\n### Prerequisites\n\n- **Node.js:** v18.x or higher\n- **PostgreSQL:** v13 or higher\n- **Redis:** v6 or higher\n- **Docker:** For containerized deployment\n- **Telegram Web App:** Access via Telegram bot\n- **TON Wallet:** For testing wallet interactions\n\n## Manual Testing\n\n### Wallet Operations\n\n1. **Deposit TON via Smart Contract:**\n   - Connect a TON wallet via TonConnect in the app.\n   - Navigate to Wallet and click Deposit.\n   - Enter amount and confirm transaction.\n   - Verify transaction is sent to WalletContract.\n   - Check that trading balance in database is updated (added to current balance).\n   - Verify transaction record in transactions table with type: 'deposit'.\n\n2. **Withdraw TON via Smart Contract:**\n   - Navigate to Wallet and click Withdraw.\n   - Enter amount (minimum 0.11 TON) and confirm transaction.\n   - Note: 0.05 TON is required for contract call (returned to wallet).\n   - Verify transaction is sent to WalletContract.\n   - Check that trading balance in database is updated (subtracted from current balance).\n   - Verify transaction record in transactions table with type: 'withdraw'.\n   - Confirm TON is received in wallet (amount minus contract fee).\n\n3. **Withdraw RUBLE Tokens:**\n   - Navigate to Wallet and click Withdraw RUBLE.\n   - Enter amount and confirm transaction.\n   - Verify transaction in the transactions table with type: 'ruble'.\n\n### Trading Operations\n\n1. **Execute Buy/Sell Trades:**\n   - Connect a TON wallet via TonConnect in the app.\n   - Navigate to Trading page.\n   - Execute a buy/sell trade in TradeButtons.vue.\n   - Verify that usdt_price is saved in the trades table.\n   - Check trade history in TradeHistory.vue for Price column.\n   - Confirm trading balances (TON and USDT) are updated correctly.\n\n\n## Contributing\n\nFork the repository.\nCreate a feature branch (git checkout -b feature/your-feature).\nCommit changes (git commit -m \"Add your feature\").\nPush to the branch (git push origin feature/your-feature).\nOpen a Pull Request.\n\n### Architecture Notes\n\n**Balance Management:**\n- **On-chain Balance:** Stored in WalletContract smart contract, represents actual TON in the contract.\n- **Trading Balance:** Stored in database (user.balance), used for trading operations.\n- **Synchronization:** \n  - On deposit: Trading balance is increased by deposit amount (added to current balance).\n  - On withdrawal: Trading balance is decreased by withdrawal amount (subtracted from current balance).\n  - Initial sync: If trading balance is null/undefined, it syncs with on-chain balance on first fetch.\n\n**Smart Contract Integration:**\n- Deposit and withdrawal operations require blockchain transactions via TonConnect.\n- Transactions are prepared on the backend (BOC generation) and sent from the frontend.\n- Backend processes transactions after they are sent to sync balances with the contract state.\n\n### Known Issues\n\n- **Dynamic Imports:** auth.js and wallet.js have mixed static/dynamic imports, causing Vite warnings. Consider using fully dynamic imports for better chunk splitting.\n- **Source Maps:** vite-plugin-vue-svg generates incorrect source maps, which may affect debugging. Check for updates or switch to vite-svg-loader.\n- **Buffer Polyfill:** Requires Buffer polyfill for browser environment (configured in vite.config.js).\n\nLicense\nMIT License. See LICENSE for details.\n\n## Authors\n[okoloboga](https://t.me/okolo_boga)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcore-euler%2Ftrade_game","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcore-euler%2Ftrade_game","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcore-euler%2Ftrade_game/lists"}