SCF #14
Community Vote
Soroswap Protocol
by

Open-source AMM protocol for providing liquidity and trading Stellar Assets in Soroban. With SDK and easy to use frontend.

Awarded
Awarded
Budget request:
$
57,600
*
WebsiteCode

Project Stage

Development

Category

Soroban
DeFi
Tools

Based in

Team size

1

Active since

Products & Services

The Soroswap Protocol is planning to launch the protocol itself (smart contracts in rust) and its ReactJS frontend. In order to do this, Soroswap will support and develop the @soroban-react library, which allows to connect frontend with smart contracts. All products will be 100% open-source.

1) Smart contracts. Provide the ability for users to swap their tokens inside Soroban, as well as for developers to connect their Soroban dApps with the protocol. Written in Rust, inspired by UniswapV2. Include:

  • Factory contract: Creates one Liquidity Pool Token contract per unique token pair.
  • Pair contract (Liquidity Pool Token contract): .They serve as automated market makers (AMM) and keep track of pool token balances. These contracts will implement the token interface
  • Router contract: Supports the basic requirements of a front-end offering trading and liquidity management functionality. Supports multi-pair trades (e.g. x to y to z)

2) The Soroswap front-end: Convenient and user-friendly front-end written in ReactJS and forked from the famous Uniswap UI. Uses the @soroban-react library in order to connect the protocol with Stellar wallets.

Smart contract and front-end audience: any user wanting to swap a token (or provide liquidity) inside Soroban, without needing to use the classic Stellar chain’s AMM, or because they are using a token that was issued inside Soroban and cannot be “unwrapped” to the classic chain. It is also useful for other protocols that need to swap tokens (e.g., a multi-currency NFT marketplace, where the seller wants a certain amount in a certain coin and the buyer can buy with any currency available in the Soroswap protocol).

3) The @soroban-react library: Framework for building modern Soroban dApps using ReactJS. Its development will keep the library updated with the latest versions of Stellar’s libraries and previews. Soroswap will add support for other wallets and write documentation.

Library Audience: Any developer building a web-dapp in Soroban.

No items found.
Previous Project(s)
No items found.
Progress so far
Goals
To get there, we request a budget of  
$
57,600
*
  to:
Additional information

The Soroswap Protocol is committed to contributing to the Soroban ecosystem by providing 100% open-source smart contract protocols and libraries that any project can use as building blocks. The pre-alpha version of the protocol already received recognition, having been awarded 3rd prize in the Soroban Hackathon.

Our goal is to create a user-friendly front-end with tested and working smart contracts that implement UniswapV2, with future plans to incorporate UniswapV3 features to reduce impermanent loss. The Soroswap Protocol will be fully documented, making it easy for developers to build on top of our work and contribute to the ecosystem.

The @soroban-react library, which serves as a framework for building modern Soroban dApps using ReactJS, has already received over 240 commits (where 140 commits since November 2022, when it became library), with 111 of those commits made by me (@esteblock). The library has been utilized in the official Stellar soroban-example-dapp project and will be further developed to include support for other wallets, and a comprehensive documentation.

In addition, I have made significant contributions to the Soroban ecosystem by providing support to the soroban-example-dapp project and creating the @soroban-react library. Our commitment to this project has resulted in the library being always upgraded to the latest SDK, as well as adding new features such as the ability to create multichain dApps.

Moving forward, we aim to continue our efforts by creating tests for the reactJS library and fully documenting it to help developers build innovative applications on Soroban. Our ultimate goal is to make Soroban a go-to blockchain platform for developers and users alike.

Revenue and funding: Soroswap plans to eventually generate revenue through fees similar to AMMs on other chains, but the exact mechanism is still under discussion. As Soroban is still in development, there will be no revenue generated at present, and the library will be published under an open-source license as a public good.

Competition: While decentralized exchanges are a popular use case for decentralized applications, Soroswap will face competition from other protocols such as Stellar core's AMM and Comet, a weighted AMM protocol that was awarded in SCF#12. However, Soroswap will provide a unique offering by allowing swaps for tokens that cannot be traded on Stellar's core AMM due to their inability to be unwrapped as a classic asset. Additionally, the protocol will enable smart contracts to interact with the exchange (stellar core’s AMM cannot). Furthermore, Soroswap plans to implement Uniswapv3 innovations to reduce impermanent loss and become a direct competitor to weighted AMMs such as Comet.

Pitch deck
No items found.
Deliverables
First Deliverable

The initial deliverable, accounting for roughly 10% of the total project workload, was the initial version of the Soroswap Protocol's smart contracts. These were based on UniswapV2 and the liquidity_pool contract from the stellar/soroban-examples repository.

The current version of the Soroswap Protocol consists of:

1. The Pair contract: A dual-purpose Liquidity Pool and LP token.2. The Factory contract: Allows users to create unique Pair contracts for each tuple of (token_a, token_b).

Initially, each AMM required multiple liquidity_pool contracts, each deploying a unique "share" token. This led to a fragmented system without an on-chain register of existing pairs, complicating scalability.

The first task was to transform the liquidity_pool into a Pair contract that behaves as a Stellar Asset Contract (SAC), alongside developing a Factory contract in Rust, akin to UniswapV2's Factory contract.  By integrating the token interface, the Pair contract now functions as a token itself, eliminating the need for a separate "share" token to control liquidity pool participation. The Factory contract allows users to create Pair contracts for any combination of token pairs (token_a, token_b) or (token_b, token_a). Additionally, the Factory contract maintains an on-chain registry of existing pairs, streamlining the management of liquidity pools.

The following steps were adopted:

  1. Forked the liquidity_pool contract into our Soroswap core repository and renamed it to pair.
  2. Integrated the token interface into the Pair contract.
  3. Replaced functions interacting with the external “share” token with the internal Pair token functions.
  4. Created the SoroswapFactory contract in /core/factory from scratch, mirroring UniswapFactory V2.
  5. Conducted unit and integration testing for the Factory contract using rust.
  6. Created bash scripts for hands-on experimentation / test using the soroban CLI (`initialize_pair.sh` and `initialize_factory.sh`)
  7. Deploying an initial version of the contracts in Futurenet (documentation on interaction is available).
  8. Documented the contracts (and how to experiment with them) in our docs repository and on dev.to (https://dev.to/esteblock/series/22986), also available in docs.soroswap.finance.

Compatibility issues with the soroban-examples repository were tackled by downgrading to a stable Soroban SDK version. Active engagement with the Soroban community on Discord helped overcome challenges. The protocol was also presented to the community.

This task saw 101 commits, and 7 new issues were opened in the soroswap/core repository, with two already resolved.

How can a reviewer check you completed your first deliverable?

The reviewer can check that the first deliverable has been completed by following these steps:

  1. Clone the soroswap/core repository: https://github.com/soroswap/core
  2. Follow the instructions in the README.md file to set up the local environment and compile the Pair and Factory contracts.
  3. Verify the transformation of the Pair contract into a token-like behavior, as outlined in the deliverable.
  4. Run the tests for the Factory and Pair contracts, ensuring that they pass both unit and integration testing. The testing instructions can also be found in the README.md file.
  5. Experiment with the contracts using the provided bash scripts, such as `initialize_pair.sh` and `initialize_factory.sh`, or interact directly with the already deployed contract on Futurenet using the `interact_futurenet.sh` script.
  6. Validate the completion of the deliverable by reviewing the commits made in the soroswap/core repository.
  7. Verify the opened and closed issues in the soroswap/core repository, which reflect the engagement and problem-solving efforts undertaken during the development of the first deliverable.
  8. Check the availability of the tutorial on the [soroswap/docs](https://github.com/soroswap/docs) repository or [docs.soroswap.finance](https://docs.soroswap.finance/) website. Additionally, verify that the tutorial has been published on dev.to in the series [here](https://dev.to/esteblock/series/22986). This documentation serves as a comprehensive guide for users and developers, providing detailed explanations and guidelines on using the Soroswap Protocol.
  9. As a supplementary step, the reviewer can also search for messages sent by the user "esteblock#1508" in the Stellar Developers Discord community. By doing so, they can observe the active engagement, participation in discussions, and contributions made by the user, further validating their involvement in the project.


By following these steps, the reviewer will have a clear and comprehensive view of the completed first deliverable, including code verification, testing, documentation availability, and community engagement.

Links:
https://www.youtube.com/watch?v=bdZc0-IH5Xs

Team

Esteban (esteblock#1508)
Founder / Blockchain Developer

As a self-motivated, versatile, and polyglot professional with over 10 years of experience in full-stack development, I am passionate about innovation, decentralization, and the power of blockchain technology. I am a Chilean with a background in electrical engineering and a master's degree in applied economics with studies in France (École Centrale Paris), UK (University of Oxford), and Chile (Universidad de Chile).

Personal Web Page / Linkedin / Github

I am set up for success because:

I am committed to creating open-source tools for the success of Soroban and helping to build a thriving community around this powerful platform. As a developer at the @soroban-react library, I am dedicated to providing high-quality code, good documentation, and easy-to-follow tutorials that make it simple for developers to get up and running with Soroban.

My experience in blockchain development includes working with Avalanche, Ethereum, and Stellar. I am proud to have won the 3rd prize at the Soroban hackathon. Additionally, I recently had the opportunity to participate in the Stellar annual conference Meridian 2022 in Rome, where I had the chance to network with other blockchain developers and share my passion for Soroban with a wider audience.