Inspiration
Many platforms today allow fiat currency payments, which may be utilized for things like investing, paying employees, making purchases, etc. However, these platforms have a number of drawbacks, such as:
- The majority of platforms do not provide recurring payment automation. When the task is finished, users must manually transfer the funds.
- Theft of wages is a constant concern for employees.
- Employers of labor could be at risk of receiving unsatisfactory work, for instance, if payment is paid upfront.
- To collect or spend the money, employees must wait for a certain date, typically each month or after the contract expires.
- The majority of platforms do not allow token payments.
Calamus Finance wants to make the continual payment and token vesting processes transparent and secure.
We choose NEAR and AURORA because the market is relatively new and potential. As a result, we can seize the opportunities and quickly acquire users. In addition, our team is experienced with building dApp on NEAR and AURORA, so we are confident that we can build a comprehensive product on this ecosystem.
What it does
Calamus Finance is a decentralized crypto streaming app that automates real-time payments, such as salary, token vesting, airdrop, etc. It allows people to send/receive payments on any time basis (per second/minute/day/…/year) by creating streams of money. The app is currently available on NEAR, AURORA, BNB Chain, Polygon, Tron and Evmos.
Our main features
- Payroll: Pay your employees by the second quickly. The company will have complete control over frequency, liquidity amount, and duration. Cancellation is possible at any time by the payer and/or payee.
- Token Vesting: Reward your team, advisors and investors with tokens automatically without any fear of foul-play
- Multisig wallet (coming soon): Wallet is owned by many people and transactions are only made under agreements from multiple owners.
How we built it
- All-in-one app for all features and all chains.
- Every time users change their blockchain, the app will use Network adapters to be able to execute code that matches that chain.
- Linked to each network adapter is a set of supporting JS libraries to connect to different wallets and call smart contracts.
- The app uses a cloud database to store user data such as account and connection history. This database helps enhance the customer experience in managing their connected wallets and reduce the number of smart contract calls.
- The app architecture is built to scale quickly and adopt more Blockchains without affecting any features running on existing Blockchains.
We divided our journey into 3 phases: Build Smart Contracts, Build DApp and Deploy & Debug. To build smart contract
For NEAR contracts:
- Use near-sdk (rust) version 4.0.0
- Use near-contract-standards version 4.0.0
- For AURORA contracts:
- Use Solidity version 0.8.0
- Use OpenZeppelin library: Address, IERC20, SafeERC20, ReentrancyGuard.
- Use CarefulMath with references from Sablier.finance and Compound.finance
- Include most important smart contract: Calamus.
Our tech stack:
- NodeJS, React, NextJS, Redux, Typescript…
- Chakra UI: a React UI component highly suitable for building beauty apps.
- Javascript libraries like Web3 and Ethers to interact with smart contracts and MetaMask wallet. near-api-js to interact with Near wallet and smart contracts.
- ChartJS to build reports on the dashboard.
- Moment JS to process stream time on the Frontend and contribute to data reporting.
- Mongo Atlas DB to store Recipient’s extra information because storing unnecessary information on-chain will increase fee when creating streams and sometimes exceed the logic limit of a Solidity Smart Contract.
- Covalenthq API & our custom API to collect the user’s token balance on the registered wallet address. Binance public API to collect token to USD price information, thus providing an insightful display for users.
- Subgraph for easier querying for pagination, searching and sorting of streams. To deploy Smart Contracts on near we use near-cli and on Aurora Testnet, we use Truffle to deploy and debug Smart Contracts.
Challenges we ran into
Throughout the process of building Calamus Finance on multi-chains, we encountered multiple technical problems which took some time to solve:
Since NEAR is a web wallet and EVM wallets are an extension, so data storage of contract titles or emails will not be done by waiting for the event to log out and then saving to our database. We decided to use Subgraph to deal with this storage issue.
Scalability and dependency: To ensure that the adoption of more chains in the future will not affect current features and users, we apply Clean Architecture and Facade design patterns to build adapters and separate the application interface & underlying operating logic. As a result, every time a new chain is added, the developer can freely use the supporting libraries and wallets without interfering with the user experience.
Gas fee and security optimization: This is a complex problem and has not been wholly solved, even though we have followed some recommended best practices. We tried our best to secure and optimize both dApps and Smart Contracts.
Get available assets on NEAR: With Near, we built a custom API by the near indexer for the explorer public database. In addition, we also used graphql API of nearblocks.io but their explorer is out of sync currently so we had to go back to the old plan using a custom API.
In addition, we also have business-related problems that are by no means less challenging:
- The problem of rounding and handling residuals when creating a stream by the second, minute, hour, day, month, and year.
- The problem of transferring or canceling the stream midway, which interrupts the current stream data.
- The problem of account security and validation in the process of manipulating streams.
Accomplishments that we're proud of
- Build a Money Streaming protocol on a new platform and support all tokens available.
- Overcome technical challenges to accomplish goals.
- Develop technical functions so that users on NEAR and AURORA can pay, receive and vest tokens easily.
- Gain a lot of in-depth knowledge about blockchain and finance.
- 2nd Place Winner TRON HACKATHON Season 2 🏅
- BNB Chain Web3 Stars Accelerator (Vietnam): Top 10 Winners 🏅
- Listed in the Honorable Mention projects from EVMOS Momentum Hackathon.
- Built a strong community with 10k+ members in different channels
What we learned
Throughout the journey, we have learned to
- Build a complete dApp on multiple chains, either non-EVM based like NEAR or EVM based like AURORA on the same app and still be able to expand the chain integration
- Understand the Crypto Payment model & usage on a DeFi app.
- General knowledge of libraries and APIs in various languages.
- Technical knowledge on how to solve existing problems of fiat payment systems.
What's next for Calamus Finance
- Go live on NEAR and AURORA Mainnet.
- Multisig Wallet
- Raise Fund - Seed round
- Enhance UI/UX
- Integrate Invoice-related features when creating a stream.
- Develop API for Developers to easily interact with our data.
- Integrate with more wallets, opening more choices for users.
Built With
- chartis
- javascript
- moment.js
- mongodb
- nextjs
- react
- solidity
Log in or sign up for Devpost to join the conversation.