Soroban needs a Liquidity Pool AMM with a good user interface. My inspirations:
- LiquidityPool contract: https://github.com/stellar/soroban-examples/tree/main/liquidity_pool
- The Soroban React Library : https://github.com/esteblock/soroban-react
- soroban-example-dapp: https://github.com/stellar/soroban-example-dapp/
What it does
Implementation of the Liquidity Pool contract with all the necessary interactions with the user using the @soroban-react library. Mint tokens, provide liquidity to the pool, swap tokens.
The front-end calculates the necessary INPUT tokens to send in order to get the correct amout of OUTPUT tokens. As it is developed in React.js, provides a smooth user experience.
All the necessary script to deploy the project are available in the repositoty.
How I built it
[rust]: Smart contract and backend: Fork of soroban-examples smart contract written in rust (liquidity_pool and token)
[bash]: Scripts to deploy and initialize the smart contracts as well as a local standalone network
[react.js]: Front end with hook implementing the @soroban-react library
[typescript]: necessary functions and new hooks
Challenges I ran into
- Create custom hooks
- Upgrade the environment in order to use the lastest skd versions.
- Transform variables to ScVal in order to pass them to the useContractValue or useSendTransaction functions of the @soroban-react library
- Write the inverse functions to calculate the correct input/output amount of tokens of the constant product AMM
- Write Signatures in js-soroban-client
- Get wasm hash using soroban-cli
Accomplishments that I'm proud of
Moved code to @soroban-react When I realize that a code will be copied and paste in a future Dapp development, I move this code to a new version of the @soroban-react library that I am supporting. I am happy that everyone can profit from my development
What I learned
Everything is much difficult than it seems to be at the beggining 😅 Stellar team and the community is ready to help! ✌️
What's next for Soroswap: Liquidity Pool Dapp in Soroban
Even if the Dapp works ok now, still needs to be improved, both on the Smart Contract side, as well as in the front end. I write all necesary things in the project's issues page in https://github.com/esteblock/soroswap/issues
- Implement remove liquidity as well as a dashboard to see positions
- Implement liquidity providers fee (now fee=0)
- Solve other issues (refresh balances after signing messages, show the user what she/he's signing, etc...)
- Give a fresh design
Regarding the Smart Contract, I want to directly collaborate in the stellar's soroban-examples repo.