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 #3793

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

Conversation

matijamarjanovic
Copy link
Contributor

@matijamarjanovic matijamarjanovic commented Feb 20, 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

commit 15341be
Author: matijamarjanovic <[email protected]>
Date:   Thu Feb 20 16:17:25 2025 +0100

    update grc20 reg

commit 83174f8
Author: matijamarjanovic <[email protected]>
Date:   Thu Feb 20 16:15:05 2025 +0100

    update with new names from 0a239e1

commit 76a1d96
Merge: 947a456 b04ca6c
Author: matija marjanovic <[email protected]>
Date:   Thu Feb 20 16:12:30 2025 +0100

    Merge branch 'master' into feat/token-hub

commit 947a456
Merge: 05982b2 d7e18a2
Author: matija marjanovic <[email protected]>
Date:   Tue Feb 18 22:57:14 2025 +0100

    Merge branch 'master' into feat/token-hub

commit 05982b2
Merge: 272e065 9130063
Author: matija marjanovic <[email protected]>
Date:   Mon Feb 17 14:38:55 2025 +0100

    Merge branch 'master' into feat/token-hub

commit 272e065
Author: matijamarjanovic <[email protected]>
Date:   Sat Feb 15 18:53:07 2025 +0100

    replace wrong name

commit 971170e
Author: matijamarjanovic <[email protected]>
Date:   Sat Feb 15 17:08:30 2025 +0100

    add getalltokenswithdetails

commit 6161301
Merge: 997eeea fcd0e04
Author: matijamarjanovic <[email protected]>
Date:   Sat Feb 15 17:02:01 2025 +0100

    Merge branch 'feat/token-hub' of https://github.com/matijamarjanovic/gno into feat/token-hub

commit 997eeea
Author: matijamarjanovic <[email protected]>
Date:   Sat Feb 15 17:01:59 2025 +0100

    add get all tokens with info

commit fcd0e04
Merge: f3b4f2b 9884ba1
Author: matijamarjanovic <[email protected]>
Date:   Sat Feb 15 16:58:42 2025 +0100

    Merge branch 'master' into feat/token-hub

commit f3b4f2b
Merge: bd10800 2e49141
Author: matijamarjanovic <[email protected]>
Date:   Fri Feb 14 00:04:03 2025 +0100

    Merge branch 'master' into feat/token-hub

commit bd10800
Merge: beca663 d0201fb
Author: matijamarjanovic <[email protected]>
Date:   Wed Feb 12 11:36:54 2025 +0100

    Merge branch 'master' into feat/token-hub

commit beca663
Author: matijamarjanovic <[email protected]>
Date:   Wed Feb 12 10:54:41 2025 +0100

    replace paths for tokenhub

commit 7028ad3
Author: matijamarjanovic <[email protected]>
Date:   Wed Feb 12 00:22:43 2025 +0100

    run make test.sync in examples

commit 5918dd5
Author: matijamarjanovic <[email protected]>
Date:   Wed Feb 12 00:13:27 2025 +0100

    fix test?

commit 2675fc0
Author: matijamarjanovic <[email protected]>
Date:   Wed Feb 12 00:04:33 2025 +0100

    fix tests

commit 5fa00c8
Author: matijamarjanovic <[email protected]>
Date:   Tue Feb 11 23:58:28 2025 +0100

    move tokenhub back to my namespace

commit 3f32a32
Author: matijamarjanovic <[email protected]>
Date:   Tue Feb 11 23:57:46 2025 +0100

    fix formatting

commit edd676b
Author: matijamarjanovic <[email protected]>
Date:   Tue Feb 11 23:53:53 2025 +0100

    simplify logic

commit 9ee19b1
Author: matijamarjanovic <[email protected]>
Date:   Tue Feb 11 23:47:58 2025 +0100

    fix formatting, remove new lines

commit 2a2a029
Author: matijamarjanovic <[email protected]>
Date:   Tue Feb 11 23:44:34 2025 +0100

    fix links

commit b9580c8
Author: matijamarjanovic <[email protected]>
Date:   Tue Feb 11 23:37:23 2025 +0100

    add renderFooter

commit 13d327c
Author: matijamarjanovic <[email protected]>
Date:   Tue Feb 11 23:31:58 2025 +0100

    don't export renders. move consts to render.gno

commit f64687c
Merge: 0db4ec8 31fcf6a
Author: matijamarjanovic <[email protected]>
Date:   Mon Feb 10 22:52:40 2025 +0100

    Merge branch 'master' into feat/token-hub

commit 0db4ec8
Author: matijamarjanovic <[email protected]>
Date:   Thu Feb 6 18:23:25 2025 +0100

    try and fix tsts

commit ecd1b52
Author: matijamarjanovic <[email protected]>
Date:   Thu Feb 6 17:05:32 2025 +0100

    fix fmt

commit 7bcf274
Author: matijamarjanovic <[email protected]>
Date:   Thu Feb 6 17:02:13 2025 +0100

    add tests for getters

commit 0bf5388
Merge: e70b81a a01a030
Author: matijamarjanovic <[email protected]>
Date:   Thu Feb 6 16:54:52 2025 +0100

    Merge branch 'master' into feat/token-hub

commit e70b81a
Merge: 50305aa 0b76b0b
Author: matijamarjanovic <[email protected]>
Date:   Wed Feb 5 20:30:24 2025 +0100

    Merge branch 'master' into feat/token-hub

commit 50305aa
Author: matijamarjanovic <[email protected]>
Date:   Tue Feb 4 18:15:44 2025 +0100

    add hof registration

commit d09eebc
Merge: 403efc5 85a8740
Author: matijamarjanovic <[email protected]>
Date:   Tue Feb 4 14:54:01 2025 +0100

    Merge branch 'master' into feat/token-hub

commit 403efc5
Author: matijamarjanovic <[email protected]>
Date:   Fri Jan 31 02:22:17 2025 +0100

    fix tests

commit 1c3b939
Merge: cbfe597 57da324
Author: matijamarjanovic <[email protected]>
Date:   Fri Jan 31 02:05:03 2025 +0100

    Merge branch 'master' into feat/token-hub

commit cbfe597
Merge: baeadcb a885c78
Author: Leon Hudak <[email protected]>
Date:   Tue Jan 28 23:08:08 2025 +0100

    Merge branch 'master' into feat/token-hub

commit baeadcb
Author: matijamarjanovic <[email protected]>
Date:   Thu Jan 23 19:55:42 2025 +0100

    remove files

commit 7c5c2a7
Merge: 13e4992 dabdf61
Author: matijamarjanovic <[email protected]>
Date:   Thu Jan 23 19:55:03 2025 +0100

    Merge branch 'feat/token-hub' of https://github.com/matijamarjanovic/gno into feat/token-hub

commit 13e4992
Author: matijamarjanovic <[email protected]>
Date:   Thu Jan 23 19:54:47 2025 +0100

    -move token hub to r/demo
    -adapt grc20reg to use the right key

commit dabdf61
Merge: 8d85cf1 8e1c532
Author: matijamarjanovic <[email protected]>
Date:   Thu Jan 23 19:54:04 2025 +0100

    Merge branch 'master' into feat/token-hub

commit 8d85cf1
Merge: 0adea0e fd24486
Author: matijamarjanovic <[email protected]>
Date:   Thu Jan 23 18:14:25 2025 +0100

    Merge branch 'master' into feat/token-hub

commit 0adea0e
Author: matijamarjanovic <[email protected]>
Date:   Wed Jan 22 14:38:01 2025 +0100

    set page size to 10

commit 1e0f60c
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 21 21:40:50 2025 +0100

    fix fmt again

commit 7be170b
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 21 21:37:28 2025 +0100

    fix fmt

commit 387ebd9
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 21 21:32:11 2025 +0100

    \n placement

commit 93075f3
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 21 21:30:46 2025 +0100

    add working tests

commit 92305e9
Merge: a946cc4 92c41eb
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 21 21:12:03 2025 +0100

    Merge branch 'master' into feat/token-hub

commit a946cc4
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 21 19:35:03 2025 +0100

    add documentation

commit 1c598a3
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 21 19:25:15 2025 +0100

    move errors in separate file for better readability

commit c9edff9
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 21 19:22:21 2025 +0100

    add formatting, fix ufmt print

commit 385fdf9
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 21 19:17:28 2025 +0100

    add get non zero balances

commit 9b9767f
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 21 19:14:56 2025 +0100

    optimization so each token types should be gettable separately to reduce gas costs

commit f48d034
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 21 18:05:22 2025 +0100

    -refactor  private getter
    -remove test

commit 59586e5
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 21 17:50:10 2025 +0100

    - change the pagination implement pager from p/demo/avl
    - instead of iteration in grc20reg use read only tree from avl

commit 43b4b52
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 21 16:59:09 2025 +0100

    render refactor;  new functions for each case, use string concat instead of sb

commit 3c5d8dc
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 21 16:29:32 2025 +0100

    divide realm into multiple files for better readability

commit b5a8206
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 21 15:58:38 2025 +0100

    remove fqname and just use concat

commit 3f8bb51
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 21 15:50:49 2025 +0100

    update naming to be consistent

commit 99b44ac
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 21 15:33:50 2025 +0100

    implement return tokens themselves instead of getters in grc1155 too (and a simple test)

commit 0a63572
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 21 15:18:42 2025 +0100

    return the tokens themselves instead of getters

commit 3b94b2e
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 21 12:51:41 2025 +0100

    fix naming

commit 35fa7e2
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 21 12:49:18 2025 +0100

    remove get my balacnces - does the same as getuserbalances for the caller address

    rename getusrebalancesall to withoutzeros

commit 7ac568f
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 21 12:29:08 2025 +0100

    - remove getorigcaller use function
    - remove comments

commit 005e64b
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 21 11:57:56 2025 +0100

    - change slugs to slug
    - use addr.isvalid

commit 1c4b72a
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 21 11:41:42 2025 +0100

    remove not needed new lines

commit 88b0a7e
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 21 11:35:16 2025 +0100

    make errors start with lowercase

commit 8c09725
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 21 11:22:28 2025 +0100

    fix page size, remove test

commit be510bc
Merge: 5ed07c2 6f37334
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 21 11:20:23 2025 +0100

    Merge branch 'master' into feat/token-hub

commit 5ed07c2
Merge: d538723 8702da9
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 21 00:25:15 2025 +0100

    Merge branch 'master' into feat/token-hub

commit d538723
Merge: 038cb50 fc40183
Author: matijamarjanovic <[email protected]>
Date:   Mon Jan 20 17:05:31 2025 +0100

    Merge branch 'master' into feat/token-hub

commit 038cb50
Author: matijamarjanovic <[email protected]>
Date:   Mon Jan 20 17:04:50 2025 +0100

    - add seing anyones balances
    - minor fix (show non zero balances)

commit c333c42
Author: matijamarjanovic <[email protected]>
Date:   Sat Jan 18 01:02:07 2025 +0100

    add different funcs for prevrealm and orig caller

commit dabf342
Author: matijamarjanovic <[email protected]>
Date:   Sat Jan 18 00:39:47 2025 +0100

    - add get all tokens without nfts
    - remove public get all tokens for a specific address

commit 936f181
Author: matijamarjanovic <[email protected]>
Date:   Fri Jan 17 20:27:00 2025 +0100

    write only key for nfts, no need for balance

commit b107e7d
Author: matijamarjanovic <[email protected]>
Date:   Fri Jan 17 20:16:57 2025 +0100

    fix: show only nfts and grc1155 owner has, because there could be who knows how many of those he does not

commit 8ab9a26
Author: matijamarjanovic <[email protected]>
Date:   Fri Jan 17 20:01:13 2025 +0100

    fix nft registration, now each minted can be registered

commit 87aac01
Author: matijamarjanovic <[email protected]>
Date:   Fri Jan 17 14:22:55 2025 +0100

    update so nft doesn't allow optional slug, but has to include tokenid

commit c0ca4a5
Merge: 48c6cd1 d2813f8
Author: matijamarjanovic <[email protected]>
Date:   Fri Jan 17 13:54:39 2025 +0100

    Merge branch 'master' into feat/token-hub

commit 48c6cd1
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 14 14:28:01 2025 +0100

    more fix fmt

commit c484774
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 14 14:24:53 2025 +0100

    fix fmt

commit f084ceb
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 14 14:23:57 2025 +0100

    remove test realm

commit 2ab9221
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 14 14:22:40 2025 +0100

    add tests and remove  (fake) test file

commit 99a5ca7
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 14 14:09:29 2025 +0100

    add getAll tokens + get tokens by type

commit 2770485
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 14 03:01:57 2025 +0100

    fix fmt

commit ad2b368
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 14 03:01:22 2025 +0100

    fix up test

commit d3af61c
Author: matijamarjanovic <[email protected]>
Date:   Tue Jan 14 02:06:24 2025 +0100

    add testing

commit fadc509
Author: matijamarjanovic <[email protected]>
Date:   Mon Jan 13 20:12:45 2025 +0100

    fix fmt

commit 3978697
Author: matijamarjanovic <[email protected]>
Date:   Mon Jan 13 17:19:15 2025 +0100

    add namespace support

commit 1d7a4bf
Merge: 3181a38 cc5cb36
Author: matijamarjanovic <[email protected]>
Date:   Mon Jan 13 16:24:39 2025 +0100

    Merge branch 'master' into feat/token-hub

commit 3181a38
Author: matijamarjanovic <[email protected]>
Date:   Sun Jan 12 18:18:19 2025 +0100

    fix fmt

commit 0186c2d
Author: matijamarjanovic <[email protected]>
Date:   Sun Jan 12 17:27:19 2025 +0100

    add get and must get for all token types

commit 8727cc6
Author: matijamarjanovic <[email protected]>
Date:   Sun Jan 12 17:13:48 2025 +0100

    -update saving grc1155 so it makes most sense
    -update the getbalances functions so they're easier to parse

commit b5967e4
Author: matijamarjanovic <[email protected]>
Date:   Sun Jan 12 16:16:44 2025 +0100

    add a getter function for tokens with non zero balances

commit c6ea858
Author: matijamarjanovic <[email protected]>
Date:   Sun Jan 12 16:12:25 2025 +0100

    add pagination for grc1155

commit c07116f
Author: matijamarjanovic <[email protected]>
Date:   Sun Jan 12 16:08:38 2025 +0100

    add pagination to grc721 page as well

commit 42152f4
Author: matijamarjanovic <[email protected]>
Date:   Sun Jan 12 16:00:12 2025 +0100

    add pagination for grc20 (this includes adding 1 more iteration function to grc20reg.gno but this might help with iteration in that realm as well)

commit af1631f
Author: matijamarjanovic <[email protected]>
Date:   Sun Jan 12 15:40:50 2025 +0100

    display different token types on different pages

commit 04ee40e
Author: matijamarjanovic <[email protected]>
Date:   Sat Jan 11 22:02:55 2025 +0100

    -add support for grc1155 (not perfect)

commit 0931341
Author: matijamarjanovic <[email protected]>
Date:   Sat Jan 11 20:24:23 2025 +0100

    add getter  to grc1155

commit a02b955
Author: matijamarjanovic <[email protected]>
Date:   Sat Jan 11 19:38:40 2025 +0100

    remove unused var

commit 9c397a5
Author: matijamarjanovic <[email protected]>
Date:   Sat Jan 11 19:35:42 2025 +0100

    - add iterate function to grc20reg to be able to get all registered tokens
    - 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

commit 7970e42
Author: matijamarjanovic <[email protected]>
Date:   Fri Jan 10 20:27:07 2025 +0100

    fix fmt

commit 7ec4dc7
Author: matijamarjanovic <[email protected]>
Date:   Fri Jan 10 20:05:33 2025 +0100

    -add getter to basic nft and igrc721 interface
    -change tokenhub to be a hub for nfts rather than a hub for fungible tokens

commit 6b9ceb7
Author: matijamarjanovic <[email protected]>
Date:   Fri Jan 10 16:34:01 2025 +0100

    initial commit
@github-actions github-actions bot added the 🧾 package/realm Tag used for new Realms or Packages. label Feb 20, 2025
@Gno2D2 Gno2D2 requested a review from a team February 20, 2025 16:25
@Gno2D2
Copy link
Collaborator

Gno2D2 commented Feb 20, 2025

🛠 PR Checks Summary

All Automated Checks passed. ✅

Manual Checks (for Reviewers):
  • IGNORE the bot requirements for this PR (force green CI check)
  • The pull request description provides enough details
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)
🟢 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

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

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: Triage
Development

Successfully merging this pull request may close these issues.

2 participants