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: connect core backend #102

Merged
merged 33 commits into from
Aug 26, 2022
Merged

feat: connect core backend #102

merged 33 commits into from
Aug 26, 2022

Conversation

dib542
Copy link
Collaborator

@dib542 dib542 commented Aug 1, 2022

This PR adds the backend of duality (commit duality-labs/duality@0768dd5) and removes the backend of duality-cosmos-mock.

Changes:

  1. replaces old generated code (src/lib/web3/generated/duality/duality.duality/*) with new generated code (src/lib/web3/generated/duality/nicholasdotsol.duality.*/*)
  2. removes custom src/lib/web3/api.ts work
    • why: incorrect assumption that we would only need one Cosmos module and api.ts would handle all of those
    • fix: a new script scripts/update-generated-files.sh transforms each module's index.ts file to meet the minimum requirements needed to call the autogenerated function correctly. In a way this is a step back, as some options are no longer exposed. Overall it could be considered a step forward: running npm run update no longer requires you to manually update api.ts to reflect other autogenerated changes.
  3. Tick structures no longer have price0/price1 values. This has been replaced with price as a decimal ratio (18 decimal place precision) of price1/price0.
  4. the flat ticks array structure in queries has been replaced with a nested structure: an array of Pair objects each with two arrays of Pool objects: poolsZeroToOne and poolsOneToZero.
    • I have preserved both the poolArray structure (ordered pool arrays to act as sortedTicks for the router) and a ticks TickMap structure to lookup individual ticks for individual tick updates (this could however be removed) as it doesn't yet serve a purpose.
  5. PairIDs are sorted by the backend, the frontend is currently treated as if it cannot know the sorting function and attempts to find sorted pairIDs by guessing in both directions. This could be improved by knowing the sort function which may rely of token attributes other than the token ID string and a small refactor may be necessary passing token objects through functions instead of token strings.
  6. The router module does not accept a swap path by a frontend router, instead it accepts tokenA, tokenB, amountIn, and minOut as parameters and calculates the swap path by itself. Therefore the front-end router is treated as an estimator to calculate a reasonable minOut value to pass to the router.
  7. Adds logic to updated tickState in response to NewDeposit, NewWithdraw, and NewSwap events.

Not implemented:

  • this does not implement the MsgSingleDeposit and MsgSingleWithdraw msg actions.
    • why: the pool page is not yet connected to msg actions.
  • this does not implement improvements that would require changes on the backend
    • eg. a TotalShares attribute could be passed by deposit and withdraw events instead of computing current totalShares values

Fixes:

@dib542 dib542 linked an issue Aug 1, 2022 that may be closed by this pull request
@dib542 dib542 force-pushed the 100-connect-core-backend branch 3 times, most recently from 6ac3624 to a42af47 Compare August 3, 2022 03:45
@dib542 dib542 requested a review from nickzoum August 3, 2022 05:17
@dib542 dib542 force-pushed the 100-connect-core-backend branch from a42af47 to f3bde6a Compare August 3, 2022 05:20
@dib542 dib542 force-pushed the 100-connect-core-backend branch from f3bde6a to 695fd32 Compare August 3, 2022 18:23
@dib542 dib542 force-pushed the 100-connect-core-backend branch from 695fd32 to e1df047 Compare August 3, 2022 18:50
@dib542
Copy link
Collaborator Author

dib542 commented Aug 3, 2022

I'm thinking maybe we should remove totalShares from the front end tick state completely. I don't think we're ever going to need it, its a value for backend withdrawal calculations only.

src/lib/web3/indexerProvider.tsx Outdated Show resolved Hide resolved
src/lib/web3/indexerProvider.tsx Outdated Show resolved Hide resolved
dib542 added 2 commits August 5, 2022 12:06
    - pools may be empty in one direction if there is no liquidity of one of the tokens available
Copy link
Contributor

@nickzoum nickzoum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

src/lib/web3/indexerProvider.tsx Outdated Show resolved Hide resolved
dib542 added a commit that referenced this pull request Aug 5, 2022
@dib542 dib542 merged commit 7ca9e8c into main Aug 26, 2022
@dib542 dib542 deleted the 100-connect-core-backend branch August 26, 2022 00:32
dib542 pushed a commit that referenced this pull request Aug 26, 2022
## [0.1.16](v0.1.15...v0.1.16) (2022-08-26)

### Features

* connect core backend ([#102](#102)) ([7ca9e8c](7ca9e8c))
@dib542
Copy link
Collaborator Author

dib542 commented Aug 26, 2022

🎉 This PR is included in version 0.1.16 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

dib542 added a commit that referenced this pull request Jan 10, 2023
    - This is the current used version since release v0.1.58:
        - https://github.com/duality-labs/duality-web-app/releases/tag/v0.1.58
        - #173

    - before that the FE was developed against an unreleased branch:
        - duality-labs/duality@0768dd5
        - #102

    - and before that the FE was developed against an Ethereum chain
      on a different unreleased prototype repository
dib542 added a commit that referenced this pull request Jan 10, 2023
* Add current version of the backend into the ReadMe file:

    - This is the current used version since release v0.1.58:
        - https://github.com/duality-labs/duality-web-app/releases/tag/v0.1.58
        - #173

    - before that the FE was developed against an unreleased branch:
        - duality-labs/duality@0768dd5
        - #102

    - and before that the FE was developed against an Ethereum chain
      on a different unreleased prototype repository

* Generalize backend version note so it only needs to be updated once
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Connect core backend
2 participants