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

Closed

Conversation

matijamarjanovic
Copy link
Contributor

@matijamarjanovic matijamarjanovic commented Jan 17, 2025

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)

See screenshots of gnoweb

image
image
image
image
image

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
  • Add get pools
  • Fix withdraw liquidity error bug?(gnovm): interface conversion error when trying to burn grc20 #3685
  • Fix links (render hyperlinks, main description, ...) before merging
  • add tests
  • Implement search funcs to be used as abci queries from the front

Note

There is a frontend being developed for gnoXchange, check it out: https://github.com/matijamarjanovic/gnoXchange

All feedback is welcome

@github-actions github-actions bot added the 🧾 package/realm Tag used for new Realms or Packages. label Jan 17, 2025
@Gno2D2
Copy link
Collaborator

Gno2D2 commented Jan 17, 2025

🛠 PR Checks Summary

🔴 Changes to 'docs' folder must be reviewed/authored by at least one devrel and one tech-staff

Manual Checks (for Reviewers):
  • IGNORE the bot requirements for this PR (force green CI check)
  • The pull request description provides enough details
  • Determine if infra needs to be updated before merging
Read More

🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers.

✅ Automated Checks (for Contributors):

🟢 Maintainers must be able to edit this pull request (more info)
🔴 Changes to 'docs' folder must be reviewed/authored by at least one devrel and one tech-staff
🟢 Pending initial approval by a review team member, or review from tech-staff

☑️ Contributor Actions:
  1. Fix any issues flagged by automated checks.
  2. Follow the Contributor Checklist to ensure your PR is ready for review.
    • Add new tests, or document why they are unnecessary.
    • Provide clear examples/screenshots, if necessary.
    • Update documentation, if required.
    • Ensure no breaking changes, or include BREAKING CHANGE notes.
    • Link related issues/PRs, where applicable.
☑️ Reviewer Actions:
  1. Complete manual checks for the PR, including the guidelines and additional checks if applicable.
📚 Resources:
Debug
Automated Checks
Maintainers must be able to edit this pull request (more info)

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 The pull request was created from a fork (head branch repo: matijamarjanovic/gno)

Then

🟢 Requirement satisfied
└── 🟢 Maintainer can modify this pull request

Changes to 'docs' folder must be reviewed/authored by at least one devrel and one tech-staff

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 A changed file matches this pattern: ^docs/ (filename: docs/assets/how-to-guides/creating-grc20/mytoken-1.gno)

Then

🔴 Requirement not satisfied
└── 🔴 And
    ├── 🔴 Or
    │   ├── 🔴 Pull request author is a member of the team: tech-staff
    │   └── 🔴 At least 1 user(s) of the team tech-staff reviewed pull request(with state "APPROVED")
    └── 🔴 Or
        ├── 🔴 Pull request author is a member of the team: devrels
        └── 🔴 At least 1 user(s) of the team devrels reviewed pull request(with state "APPROVED")

Pending initial approval by a review team member, or review from tech-staff

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 Not (🔴 Pull request author is a member of the team: tech-staff)

Then

🟢 Requirement satisfied
└── 🟢 If
    ├── 🟢 Condition
    │   └── 🟢 Or
    │       ├── 🔴 At least 1 user(s) of the organization reviewed the pull request (with state "APPROVED")
    │       ├── 🔴 At least 1 user(s) of the team tech-staff reviewed pull request
    │       └── 🟢 This pull request is a draft
    └── 🟢 Then
        └── 🟢 Not (🔴 This label is applied to pull request: review/triage-pending)

Manual Checks
**IGNORE** the bot requirements for this PR (force green CI check)

If

🟢 Condition met
└── 🟢 On every pull request

Can be checked by

  • Any user with comment edit permission
The pull request description provides enough details

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 Not (🔴 Pull request author is a member of the team: core-contributors)
    └── 🟢 Not (🔴 Pull request author is user: dependabot[bot])

Can be checked by

  • team core-contributors
Determine if infra needs to be updated before merging

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 Or
        ├── 🟢 A changed file matches this pattern: Dockerfile (filename: Dockerfile)
        ├── 🔴 A changed file matches this pattern: ^misc/deployments
        ├── 🔴 A changed file matches this pattern: ^misc/docker-
        ├── 🟢 A changed file matches this pattern: ^.github/workflows/releaser.*\.yml$ (filename: .github/workflows/releaser-master.yml)
        └── 🔴 A changed file matches this pattern: ^.github/workflows/portal-loop\.yml$

Can be checked by

  • team devops

@matijamarjanovic matijamarjanovic changed the title feat: smart contract (token) wallet feat: gnoxchange - simple dex Feb 4, 2025
@matijamarjanovic matijamarjanovic marked this pull request as ready for review February 11, 2025 16:41
@Gno2D2 Gno2D2 added the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Feb 11, 2025
@thehowl thehowl marked this pull request as draft February 20, 2025 09:42
@Gno2D2 Gno2D2 removed the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Feb 20, 2025
@thehowl
Copy link
Member

thehowl commented Feb 20, 2025

Hey; putting this PR into draft seeing as the CI is still failing. Please put it as ready for review once the CI succeeds.

Also, seeing as this is a lot of commits; please squash them when the PR is ready, as they pollute the PR conversation.

-change tokenhub to be a hub for nfts rather than a hub for fungible tokens
@github-actions github-actions bot added 📦 🤖 gnovm Issues or PRs gnovm related 📦 🌐 tendermint v2 Issues or PRs tm2 related 📦 ⛰️ gno.land Issues or PRs gno.land package related labels Feb 20, 2025
@Gno2D2 Gno2D2 requested a review from a team February 20, 2025 16:00
@matijamarjanovic
Copy link
Contributor Author

matijamarjanovic commented Feb 20, 2025

Also, seeing as this is a lot of commits; please squash them when the PR is ready, as they pollute the PR conversation.

Looks like I messed up pretty hard with the squash, I will be closing this PR and opening a new one where I will upload all the files in one commit...

#3793

@matijamarjanovic matijamarjanovic deleted the feat/gnocket branch February 20, 2025 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 🌐 tendermint v2 Issues or PRs tm2 related 📦 ⛰️ gno.land Issues or PRs gno.land package related 📦 🤖 gnovm Issues or PRs gnovm related 🧾 package/realm Tag used for new Realms or Packages.
Projects
Development

Successfully merging this pull request may close these issues.

3 participants