Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: gnoxchange - simple dex #3543

Draft
wants to merge 145 commits into
base: master
Choose a base branch
from

Conversation

matijamarjanovic
Copy link
Contributor

@matijamarjanovic matijamarjanovic commented Jan 17, 2025

WIP
note : depends on tokenhub PR

Desciption

GnoXchange is a simple dex providing multiple ways to swap tokens (and coins) on gno.land's chain. It offers 2 different approaches to swap assets: AMM and P2P (inspired by #2510).

The first approach allows users to create pools between 2 tokens, add and withdraw liquidty to/from them and use existing pools to swap tokens. As expected, the pools regulate their prices when swapping happens. Price regulation formula:

amountOut = (amountIn * 0.997 * reserveOut) / (reserveIn + (amountIn * 0.997)) 

which is just the base CPMM formula with 0.3% fee (exactly like the one used in Uniswap V1). The liquidity providers get minted LP tokens.

Second one provides a chance for users to trade directly with other users, while atomic swap provides a secure private way for 2 parties to trade, gnoxchange p2p system allows users to create tickets that are public and preset an expiration timer. This way anyone who finds the offer suiting can accept it. The security is guaranteed as the offerer's assets are locked in the realm on ticket creation.

GnoXchange also provides an open NFT market. Since the ticketing system was already in place, anyone who wants to sell an nft (that is registered in the #3479 - gno.land/r/demo/tokenhub) he can just make a ticket and the nft will be up for sale for any amount of any asset (just like any other token/coin in the P2P part of the exhange). All other P2P functionalities apply as well, such as cancelling, preset expiration, etc.

(For more detailed, technical description please read godocs in gnoxhange.gno)

Contributors checklists
  • Init pool registry, add pool structure
  • CreatePool and AddLiquidity functions
  • Swap functionality
  • Cover case when tokens have different decimals
  • Add overall and missing godocs
  • Add hof registration
  • Add see all tickets page
  • Add NFT marketplace
  • Fix withdraw liquidity error bug(?): interface conversion error when trying to burn grc20 #3685
  • Fix links (render hyperlinks, main description, ...)
  • add tests

All feedback is welcome

matijamarjanovic and others added 28 commits January 10, 2025 16:34
-change tokenhub to be a hub for nfts rather than a hub for fungible tokens
…okens

- match registering grc721 to grc20 registration which now go by pck path (and custom slug) instead of symbol
- combine the two in the token hub
…ion to grc20reg.gno but this might help with iteration in that realm as well)
-update the getbalances functions so they're easier to parse
- set up ownable
- connect to tokenhub
- start setting up transfer all assets from address to wallet on NewWallet
@github-actions github-actions bot added the 🧾 package/realm Tag used for new Realms or Packages. label Jan 17, 2025
@matijamarjanovic matijamarjanovic changed the title feat: smart contract (token) wallet feat: gnoxchange - simple dex Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧾 package/realm Tag used for new Realms or Packages.
Projects
Status: In Progress
Status: Triage
Development

Successfully merging this pull request may close these issues.

3 participants