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

[Bug]: Liquidity Pool look giving inconsistent responses #64

Closed
pblake81239 opened this issue Sep 6, 2023 · 19 comments
Closed

[Bug]: Liquidity Pool look giving inconsistent responses #64

pblake81239 opened this issue Sep 6, 2023 · 19 comments
Labels
bug Something isn't working

Comments

@pblake81239
Copy link

Data Provider

Kupo

DEX

All

Description

Pool response is inconsistent poolid and poolfeepercent arent populated particularly on sundae & minswap

        let sellToken: Token  = 'lovelace'
        let buyToken: Token = new Asset('1d7f33bd23d85e1a25d87d86fac4f199c3197a2f7afeb662a0f34e1e', '776f726c646d6f62696c65746f6b656e', 6);

        let tokenPairs: Array<Token[]> = [];
        tokenPairs.push([sellToken, buyToken]);

        let liquidityPools: LiquidityPool[] = await dexter.newFetchRequest().onAllDexs()
            .forTokenPairs(tokenPairs).getLiquidityPools();
@pblake81239 pblake81239 added the bug Something isn't working label Sep 6, 2023
@pblake81239 pblake81239 changed the title [Bug]: [Bug]: Liquidity Pool look giving inconsistent responses Sep 6, 2023
@Sluder
Copy link
Collaborator

Sluder commented Sep 6, 2023

@pblake81239 Would you have an example response of a pool without those values? Bot Sundae & Minswap supply both of those values

@pblake81239
Copy link
Author

[ { "identifier": "df88a770e300f248b776231b96da4525ce0f54bc457310efe27a03f2c14bb18f", "poolFeePercent": 0.3, "extra": {}, "dex": "Minswap", "assetA": "lovelace", "assetB": { "policyId": "1d7f33bd23d85e1a25d87d86fac4f199c3197a2f7afeb662a0f34e1e", "nameHex": "776f726c646d6f62696c65746f6b656e", "decimals": 0 }, "reserveA": 3823103853880, "reserveB": 8945596491542, "address": "addr1z8snz7c4974vzdpxu65ruphl3zjdvtxw8strf2c2tmqnxzwccf8ywaly0m99ngq68lus48lmafut7ku9geawu8u6k49suv42qq", "marketOrderAddress": "addr1wxn9efv2f6w82hagxqtn62ju4m293tqvw0uhmdl64ch8uwc0h43gt", "limitOrderAddress": "addr1zxn9efv2f6w82hagxqtn62ju4m293tqvw0uhmdl64ch8uw6j2c79gy9l76sdg0xwhd7r0c0kna0tycz4y5s6mlenh8pq6s3z70", "lpToken": { "policyId": "e4214b7cce62ac6fbba385d164df48e157eae5863521b4b67ca71d86", "nameHex": "df88a770e300f248b776231b96da4525ce0f54bc457310efe27a03f2c14bb18f", "decimals": 0 } }, { "identifier": "", "poolFeePercent": 0, "extra": {}, "dex": "SundaeSwap", "assetA": "lovelace", "assetB": { "policyId": "1d7f33bd23d85e1a25d87d86fac4f199c3197a2f7afeb662a0f34e1e", "nameHex": "776f726c646d6f62696c65746f6b656e", "decimals": 0 }, "reserveA": 2161163311719, "reserveB": 5053424752269, "address": "addr1w9qzpelu9hn45pefc0xr4ac4kdxeswq7pndul2vuj59u8tqaxdznu", "marketOrderAddress": "addr1wxaptpmxcxawvr3pzlhgnpmzz3ql43n2tc8mn3av5kx0yzs09tqh8", "limitOrderAddress": "addr1wxaptpmxcxawvr3pzlhgnpmzz3ql43n2tc8mn3av5kx0yzs09tqh8", "lpToken": { "policyId": "0029cb7c88c7567b63d1a512c0ed626aa169688ec980730c0473b913", "nameHex": "6c702004", "decimals": 0 } }, { "identifier": "", "poolFeePercent": 0, "extra": {}, "dex": "MuesliSwap", "assetA": "lovelace", "assetB": { "policyId": "1d7f33bd23d85e1a25d87d86fac4f199c3197a2f7afeb662a0f34e1e", "nameHex": "776f726c646d6f62696c65746f6b656e", "decimals": 0 }, "reserveA": 189255061864, "reserveB": 440982733346, "address": "addr1z9cy2gmar6cpn8yymll93lnd7lw96f27kn2p3eq5d4tjr7rshnr04ple6jjfc0cvcmcpcxmsh576v7j2mjk8tw890vespzvgwd", "marketOrderAddress": "addr1zyq0kyrml023kwjk8zr86d5gaxrt5w8lxnah8r6m6s4jp4g3r6dxnzml343sx8jweqn4vn3fz2kj8kgu9czghx0jrsyqqktyhv", "limitOrderAddress": "addr1zyq0kyrml023kwjk8zr86d5gaxrt5w8lxnah8r6m6s4jp4g3r6dxnzml343sx8jweqn4vn3fz2kj8kgu9czghx0jrsyqqktyhv", "lpToken": { "policyId": "af3d70acf4bd5b3abb319a7d75c89fb3e56eafcdd46b2e9b57a2557f", "nameHex": "f6602f7b01ba8ca752f4859092d403d753ea425061eb78bc13bb9d328e221608", "decimals": 0 } }, { "identifier": "", "poolFeePercent": 0.35, "extra": {}, "dex": "WingRiders", "assetA": "lovelace", "assetB": { "policyId": "1d7f33bd23d85e1a25d87d86fac4f199c3197a2f7afeb662a0f34e1e", "nameHex": "776f726c646d6f62696c65746f6b656e", "decimals": 0 }, "reserveA": 1300482933631, "reserveB": 3043643189240, "address": "addr1z8nvjzjeydcn4atcd93aac8allvrpjn7pjr2qsweukpnay2tqrfwamagnyfv43jgm94yvkmsnfvpzlytmkl0cs0uh8zqszu5da", "marketOrderAddress": "addr1wxr2a8htmzuhj39y2gq7ftkpxv98y2g67tg8zezthgq4jkg0a4ul4", "limitOrderAddress": "addr1wxr2a8htmzuhj39y2gq7ftkpxv98y2g67tg8zezthgq4jkg0a4ul4", "lpToken": { "policyId": "026a18d04a0c642759bb3d83b12e3344894e5c1c7b2aeb1a2113a570", "nameHex": "377949fb80c44ab5647e7609bef787c344a1ef079e47e66a23d0a1ccf8f11ffb", "decimals": 0 } }, { "identifier": "", "poolFeePercent": 0.3, "extra": {}, "dex": "VyFinance", "assetA": "lovelace", "assetB": { "policyId": "1d7f33bd23d85e1a25d87d86fac4f199c3197a2f7afeb662a0f34e1e", "nameHex": "776f726c646d6f62696c65746f6b656e", "decimals": 0 }, "reserveA": 1606014541917, "reserveB": 3755875258037, "address": "addr1z9vgl40qezca5s8ajz6wnpuwevt98l3jqx2ce5nlu8h8nnw60wckas4haxwwclas0g39cc8cvt2r8yalrfa9e8vxx92qsss9sx", "marketOrderAddress": "addr1w87a8c4kfdmwlwwetkrlj47pnxsta8c3vqzsgh5dazja29cmjc2p9", "limitOrderAddress": "addr1w87a8c4kfdmwlwwetkrlj47pnxsta8c3vqzsgh5dazja29cmjc2p9", "lpToken": { "policyId": "8a0eaaa579fe4268afa858d8a3c5f181ee8098d48597911d7e5a0752", "nameHex": "567946695f4144412f574d545f4c50", "decimals": 0 } } ]

@Sluder
Copy link
Collaborator

Sluder commented Sep 6, 2023

You are using Kupo correct?

@pblake81239
Copy link
Author

Yes Kupo.

Just to give some more info.

I have narrowed the issue down to server side call to getLiquidityPools... I just now tested with client side and no issues...

@pblake81239
Copy link
Author

pblake81239 commented Sep 7, 2023

export default async function handler(request: NextApiRequest, res: NextApiResponse) {
    const requestObj = JSON.parse(JSON.stringify(request.body));

    if (requestObj.sellCoin.policyId != '' && requestObj.buyCoin.policyId != '') {
        let sellToken: Token;
        let buyToken: Token;

        if (requestObj.sellCoin.policyId === 'lovelace') {
            sellToken = 'lovelace'
        } else {
            sellToken = new Asset(requestObj.sellCoin.policyId, requestObj.sellCoin.nameHex, requestObj.sellCoin.decimals)
        }

        if (requestObj.buyCoin.policyId === 'lovelace') {
            buyToken = 'lovelace'
        } else {
            buyToken = new Asset(requestObj.buyCoin.policyId, requestObj.buyCoin.nameHex, requestObj.buyCoin.decimals)
        }

        const dexter: Dexter = getDexter();//KUPO
        let liquidityPools: LiquidityPool[] = await dexter.newFetchRequest().onAllDexs()
            .forTokenPairs([[sellToken, buyToken]]).getLiquidityPools();

        let liquidityPoolsForPairJSON = JSON.stringify(liquidityPools, (key, value) =>
            typeof value === 'bigint'
                ? value.toString()
                : value // return everything else unchanged
        )

        return res.status(200).json({
            data: JSON.parse(liquidityPoolsForPairJSON),
            error: null,
          });
    }
}

POST body

{
  "sellCoin": {
    "policyId": "lovelace",
    "nameHex": "",
    "decimals": 0
  },
  "buyCoin": {
    "policyId": "1d7f33bd23d85e1a25d87d86fac4f199c3197a2f7afeb662a0f34e1e",
    "nameHex": "776f726c646d6f62696c65746f6b656e",
    "decimals": 6
  }
}

@pblake81239
Copy link
Author

TypeError: Cannot read properties of null (reading 'PlutusData')
at Object.from (webpack-internal:///(api)/./node_modules/@indigo-labs/dexter/node_modules/lucid-cardano/esm/src/plutus/data.js:299:74)
at eval (webpack-internal:///(api)/./node_modules/@indigo-labs/dexter/build/providers/data/kupo-provider.js:49:91)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SundaeSwap.liquidityPoolFromUtxo (webpack-internal:///(api)/./node_modules/@indigo-labs/dexter/build/dex/sundaeswap.js:79:27)
at async eval (webpack-internal:///(api)/./node_modules/@indigo-labs/dexter/build/dex/sundaeswap.js:43:20)
at async Promise.all (index 216)
at async SundaeSwap.liquidityPools (webpack-internal:///(api)/./node_modules/@indigo-labs/dexter/build/dex/sundaeswap.js:42:16)
at async Promise.all (index 0)
at async FetchRequest.getLiquidityPools (webpack-internal:///(api)/./node_modules/@indigo-labs/dexter/build/requests/fetch-request.js:128:16)
at async Promise.all (index 0)
at async handler (webpack-internal:///(api)/./pages/api/liquiditypoolsforpair.tsx:45:38)

@Sluder
Copy link
Collaborator

Sluder commented Sep 7, 2023

Very weird.. You should at least be getting the pool fee percent since those are hardcoded in, which version of dexter are you using?

@pblake81239
Copy link
Author

Latest dexter and

kupo:
image: cardanosolutions/kupo:latest

Found this..... 


data: {
      hint: "The server is (too) busy! There's no resource available to handle this request. While the requested *could be* enqueued for later, this error is meant to give that choice to you, the client, to chose whether to retry it now or prioritize some other more important query. Depending on your hardware resources, you may also want to increase the server's maximum internal connections using '--max-concurrency'."
    }

@Sluder
Copy link
Collaborator

Sluder commented Sep 7, 2023

Latest dexter and

kupo: image: cardanosolutions/kupo:latest

Found this..... 


data: {
      hint: "The server is (too) busy! There's no resource available to handle this request. While the requested *could be* enqueued for later, this error is meant to give that choice to you, the client, to chose whether to retry it now or prioritize some other more important query. Depending on your hardware resources, you may also want to increase the server's maximum internal connections using '--max-concurrency'."
    }

Ah! I had a similar issue, I've had luck running kupo with the --max-concurrency 500 flag to resolve this. And/or retrying the request if it fails

@pblake81239
Copy link
Author

[2.6.0] - 2023-08-16

Removed

  • --max-concurrency command-line option is gone; Kupo now use sensible defaults based on the machine's detected capabilities.

:(

@Sluder
Copy link
Collaborator

Sluder commented Sep 7, 2023

[2.6.0] - 2023-08-16

Removed

  • --max-concurrency command-line option is gone; Kupo now use sensible defaults based on the machine's detected capabilities.

:(

WHAT. Im working on an outdated version then.
Actually.. Lets try something. When you create the dexter instance, you can pass in a request config. new Dexter({ dexter config }, { timeout: 15000, retries: 10 })

@pblake81239
Copy link
Author

This is my setup

export const getDexter =() : Dexter => { const dexterConfig: DexterConfig = { shouldFetchMetadata: true, // Whether to fetch asset metadata (Best to leave this true` for accurate pool info)
shouldFallbackToApi: true, // Only use when using Blockfrost or Kupo as data providers. On failure, fallback to the DEX API to grab necessary data
shouldSubmitOrders: false, // Allow Dexter to submit orders from swap requests. Useful during development
metadataMsgBranding: 'ADAMarkets', // Prepend branding name in Tx message
};
const requestConfig: RequestConfig = {
timeout: 15000, // How long outside network requests have to reply
proxyUrl: '', // URL to prepend to all outside URLs. Useful when dealing with CORs
retries: 10, // Number of times to reattempt any outside request
};
const kupoProvider: BaseDataProvider = new KupoProvider(
{
url: 'KUPOURL'

},
requestConfig

);
return new Dexter(dexterConfig, requestConfig).withDataProvider(kupoProvider).withMetadataProvider(new KoiosTokenRegistryProvider(requestConfig));`

@pblake81239
Copy link
Author

[2.6.0] - 2023-08-16

Removed

  • --max-concurrency command-line option is gone; Kupo now use sensible defaults based on the machine's detected capabilities.

:(

WHAT. Im working on an outdated version then. Actually.. Lets try something. When you create the dexter instance, you can pass in a request config. new Dexter({ dexter config }, { timeout: 15000, retries: 10 })

what version you using?

@Sluder
Copy link
Collaborator

Sluder commented Sep 7, 2023

v2.4.0

@pblake81239
Copy link
Author

pblake81239 commented Sep 7, 2023

Ok tried that and same issue

TypeError: Cannot read properties of null (reading 'PlutusData')
    at Object.from (webpack-internal:///(api)/./node_modules/lucid-cardano/esm/src/plutus/data.js:176:74)
    at eval (webpack-internal:///(api)/./node_modules/@indigo-labs/dexter/build/providers/data/kupo-provider.js:49:91)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async SundaeSwap.liquidityPoolFromUtxo (webpack-internal:///(api)/./node_modules/@indigo-labs/dexter/build/dex/sundaeswap.js:79:27)       
    at async eval (webpack-internal:///(api)/./node_modules/@indigo-labs/dexter/build/dex/sundaeswap.js:43:20)
    at async Promise.all (index 1)
    at async SundaeSwap.liquidityPools (webpack-internal:///(api)/./node_modules/@indigo-labs/dexter/build/dex/sundaeswap.js:42:16)
    at async Promise.all (index 0)
    at async FetchRequest.getLiquidityPools (webpack-internal:///(api)/./node_modules/@indigo-labs/dexter/build/requests/fetch-request.js:128:16)
    at async Promise.all (index 0)
    at async handler (webpack-internal:///(api)/./pages/api/liquiditypoolsforpair.tsx:45:38)

This is my docker compose... long shot maybe

    image: cardanosolutions/kupo:v2.4.0
    ports:
      - "1442:1442"
    restart: on-failure
    command:
      - --max-concurrency 
      - "5500"
      - --node-socket
      - /opt/cardano/cnode/sockets/node0.socket
      - --node-config
      - /opt/cardano/cnode/files/config.json    
      - --host
      - 0.0.0.0
      - --workdir
      - /opt/cardano/cnode/db
      - --prune-utxo
      - --since
      - origin
      - --match
      - "de9b756719341e79785aa13c164e7fe68c189ed04d61c9876b2fe53f.4d7565736c69537761705f414d4d"
      - --match
      - "026a18d04a0c642759bb3d83b12e3344894e5c1c7b2aeb1a2113a570.4c"
      - --match
      - "13aa2accf2e1561723aa26871e071fdf32c867cff7e7d50ad470d62f.4d494e53574150"
      - --match
      - "addr1w9qzpelu9hn45pefc0xr4ac4kdxeswq7pndul2vuj59u8tqaxdznu" 
      ```

@pblake81239
Copy link
Author

Just tested with blockfrost and it worked but slow!!!

It took 400+ blockfrost requests to get all liquidity pools for ADA-WMT on all dex's.

@Sluder
Copy link
Collaborator

Sluder commented Sep 7, 2023

Just tested with blockfrost and it worked but slow!!!

It took 400+ blockfrost requests to get all liquidity pools for ADA-WMT on all dex's.

Ill investigate more into kupo (which is weird because blockfrost & kupo use the same flow).
So many requests are needed because you cant really filter pools before the request is made. So you have to pull all the available pools on-chain, then filter from there

@pblake81239
Copy link
Author

Here is a sample app you just need to add a kupo url.

https://github.com/ADA-Markets/kupotest

@pblake81239
Copy link
Author

So the issue I believe is a next issue. I am able to replicate the same issue as the below links...

vercel/next.js#51605
vercel/next.js#49578

@Sluder Sluder closed this as completed Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants