project screenshot 1
project screenshot 2
project screenshot 3

1cmBot

1cmBot is a Telegram bot that offers easy trading on Telegram by leveraging 1inch API to support swaps on multiple chains and get the best rates with 1inch's aggregation router.

1cmBot

Created At

ETHGlobal Singapore

Winner of

1inch - Use the Dev Portal APIs in your dApp 2nd place

Project Description

1cmBot is a Telegram bot that offers users an intuitive trading experience by leveraging the 1inch API for seamless swapping on their preferred network, such as Ethereum, Polygon and Base.

Users can manage their trades efficiently by first customizing the bot with their preferred settings as follows: - Select chain to trade on - Select any pair of tokens to perform swaps - Specify slippage tolerance level (preconfigured default of 0.3%)

The general setup process for a new user is as follows:

  1. Find the Telegram bot via username @onecm_bot or via URL
  2. Press "Start". Server generates a unique wallet address for the user.
  3. User taps on "Set Chain" and inputs the chain ID (e.g. 137 for Polygon)
  4. User taps on "Token0" and inputs the token address (e.g. USDC's address)
  5. User taps on "Token1" and inputs the token address (e.g. XSGD's address)

Before performing swaps, users will have to deposit Token0/Token1 selected during setup, and also deposit the token used for gas in their selected chain (e.g. POL for Polygon).

Once the above steps are done, users are ready to swap their way to huge profits! Buying/selling will then be a straightforward process, with users being able to perform transactions with two taps by first choosing "Buy" or "Sell", and then choosing from a predefined set of amounts to swap (i.e. 25%, 50%, 75%, 100%).

For the users' reference, the default prompt (main menu) will contain a graph of the selected token pair, which can be refreshed easily with one tap of the "Refresh" button. This allows users to be constantly updated with the token pairing's latest trend and make smart trading decisions all within the Telegram bot interface, enabling users to trade ahead of others and always get the best rates with the power of 1inch's smart routing.

Ultimately, this bot simplifies decentralized trading by offering essential controls in Telegram's user-friendly and familiar interface, making it accessible for both beginner and advanced traders.

How it's Made

This project utilizes Telegram as the frontend. To interface with the Telegram bot API, we decided to use python-telegram-bot library as it has a long history and is used by many developers in the community, making it easier to get solutions from the community for common issues.

We use Prisma ORM for database management, as making updates to the database structure is made easy with Prisma Schema Language (PSL). Migrations also make it easy for us two team members to work together and incrementally make changes to the database. Prisma also comes with Prisma Studio, a web-based UI for managing database records, similar to phpMyAdmin. This made debugging database-related issues a breeze.

All components of our application, including development-related components such as above-mentioned Prisma Studio, are hosted using Docker, making it easy to switch between databases as necessary. This came in handy when we realized that it was easier to interact with a MySQL database using mysql-connector-python library instead of Postgres - the switch from Postgres to MySQL was finished within 3 minutes.

For generating wallet addresses, we assign a unique auto-increment integer field in the database for each user and use the derivation path concept to use the unique integer and a master key to generate a unique wallet address and private key for each user. This is done by using the eth_account library.

The blockchain interaction in our application is completely powered by the 1inch API - getting swap quotes, getting token balance, getting chart data, getting token info, performing swaps. Unfortunately for development purposes, we had to implement a 1-second delay between API calls to work around the free API key's 1 RPS limit, making the interaction a bit less smooth than its supposed to be.

background image mobile

Join the mailing list

Get the latest news and updates