Giter VIP home page Giter VIP logo

paraswap-dex-lib's People

Contributors

0xnazarii avatar 0xshad0w avatar 0xsokka avatar aburkut avatar asyx21 avatar bogdoslavik avatar borelien avatar colonelj avatar danielmkm avatar estebgonza avatar fabiencoutant avatar fireboss777 avatar guillaumenervoxs avatar jackiejoo avatar jaimi-io avatar johngrantuk avatar kanievskyidanylo avatar louis-amas avatar madawa avatar mounibec avatar mwamedacen avatar nduchak avatar paraschiv-razvan avatar sakulstra avatar sandy-wombat avatar shresthagrawal avatar skypper avatar tj-wombat avatar verisana avatar wertusser avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

paraswap-dex-lib's Issues

Subgraph endpoint update required

Hey team,

We've noticed that you're referencing a subgraph deployed on The Graph's hosted service in this repository. Just a heads-up: after June 12th, hosted service subgraph endpoints will no longer be available as the offering is being deprecated.

If you are the subgraph owner or maintainer, it's time to upgrade your subgraph to the network. This ensures everything keeps running smoothly and you get access to all the latest features and improvements. Here is a quick guide with all the upgrade steps.

If you're not the subgraph owner or maintainer, check Graph Explorer to see if the subgraph development team has already upgraded to the network. If you don’t find an upgraded subgraph, a friendly nudge to the subgraph development team would be greatly appreciated—it's a quick process that benefits everyone. Here's the upgrade guide with all the necessary steps for the subgraph development team.

Once the subgraph is upgraded to the network, you can create an API key and updated query URL in Subgraph Studio then update this repository to query from the new endpoint, https://api.studio.thegraph.com/query/<ID>/<SUBGRAPH_NAME>/<VERSION>

Need more support or have more questions? Feel free to reach out to [email protected]. We're here to help!

Cheers,

Paka

Connect v9

Hello,

I am writing you from Trezor company with a message that there is a newer version of Connect, v9. More info here: https://www.npmjs.com/package/@trezor/connect.

If you have any questions or want to report a problem, feel free to reach us.

(Not sure if this is the right repo, if not, then I am sorry.)

Invalid Dfyn swap route on Polygon

This route is proposed by Paraswap:

[
  {
    percent: 64,
    swaps: [
      {
        srcToken: '0xc2132d05d31c914a87c6611c10748aeb04b58e8f',
        srcDecimals: 6,
        destToken: '0x2791bca1f2de4661ed88a30c99a7a9449aa84174',
        destDecimals: 6,
        swapExchanges: [
          {
            exchange: 'QuickSwapV3',
            srcAmount: '22397446',
            destAmount: '22404106',
            percent: 100,
            poolAddresses: [ '0x7b925e617aefd7fb3a93abe3a701135d7a1ba710' ],
            data: {
              path: [
                {
                  tokenIn: '0xc2132d05d31c914a87c6611c10748aeb04b58e8f',
                  tokenOut: '0x2791bca1f2de4661ed88a30c99a7a9449aa84174'
                }
              ],
              gasUSD: '0.003357'
            }
          }
        ]
      }
    ]
  },
  {
    percent: 36,
    swaps: [
      {
        srcToken: '0xc2132d05d31c914a87c6611c10748aeb04b58e8f',
        srcDecimals: 6,
        destToken: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
        destDecimals: 18,
        swapExchanges: [
          {
            exchange: 'Dfyn',
            srcAmount: '12598564',
            destAmount: '17170688310077781158',
            percent: 100,
            poolAddresses: [ '0x9045b1762a0bc4BadD08eE7B1A55c3871DE9B7b4' ],
            data: {
              router: '0xf3938337F7294fEf84e9B2c6D548A93F956Cc281',
              path: [
                '0xc2132d05d31c914a87c6611c10748aeb04b58e8f',
                '0x4c28f48448720e9000907bc2611f73022fdce1fa'
              ],
              factory: '0xE7Fb3e833eFE5F9c441105EB65Ef8b261266423B',
              initCode: '0xf187ed688403aa4f7acfada758d8d53698753b998a3071b06f1b777f4330eaf3',
              feeFactor: 10000,
              pools: [
                {
                  address: '0x9045b1762a0bc4BadD08eE7B1A55c3871DE9B7b4',
                  fee: 30,
                  direction: false
                }
              ],
              weth: '0x4c28f48448720e9000907bc2611f73022fdce1fa',
              gasUSD: '0.002772'
            }
          }
        ]
      },
      {
        srcToken: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
        srcDecimals: 18,
        destToken: '0x2791bca1f2de4661ed88a30c99a7a9449aa84174',
        destDecimals: 6,
        swapExchanges: [
          {
            exchange: 'QuickSwapV3',
            srcAmount: '17170688310077781158',
            destAmount: '12615940',
            percent: 100,
            poolAddresses: [ '0xae81fac689a1b4b1e06e7ef4a2ab4cd8ac0a087d' ],
            data: {
              path: [
                {
                  tokenIn: '0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270',
                  tokenOut: '0x2791bca1f2de4661ed88a30c99a7a9449aa84174'
                }
              ],
              gasUSD: '0.003357'
            }
          }
        ]
      }
    ]
  }
]

Notice the second 36% part suggests:

  • USDT to WETH (Dfyn, 0x4c28f4) on Dfyn
  • WMATIC (0xeee) to USDC.e on Quickswap V3

I suspect there is some confusion in how Dfyn is treating 0xeee as its own WETH in

getPoolIdentifiers(
from: Token,
to: Token,
side: SwapSide,
blockNumber: number,
): Promise<string[]> {
const _from = WrapDfynWETH(from);
const _to = WrapDfynWETH(to);
return super.getPoolIdentifiers(_from, _to, side, blockNumber);
}
async getPricesVolume(
from: Token,
to: Token,
amounts: bigint[],
side: SwapSide,
blockNumber: number,
limitPools?: string[],
): Promise<ExchangePrices<UniswapV2Data> | null> {
const _from = WrapDfynWETH(from);
const _to = WrapDfynWETH(to);
const prices = await super.getPricesVolume(
_from,
_to,
amounts,
side,
blockNumber,
limitPools,
);
return prices
? prices.map(p => ({ ...p, data: { ...p.data, weth: DfynWETH.address } }))
: null;
}
}

Error when building yarn build

src/dex/curve-v1/pools/ustpool.ts:31:5 - error TS2742: The inferred type of '_PRECISION_MUL' cannot be named without a reference to '@paraswap/dex-lib/node_modules/bignumber.js'. This is likely not portable. A type annotation is necessary.

31     _PRECISION_MUL = PRECISION_MUL,
       ~~~~~~~~~~~~~~

Please make the documentation more clear

Hi Paraswap Team,

can you improve the documention. Things that i stumpled accross and would make the devs live easier:

  • high level archicture how the lib is basically working and what functions from a dex integration are called
  • Better code documentation. There some basic comments on the test files, but for example there could be more documentation in the template files where devs need to complete the code
  • Please make it clear what environment variables should be set. It looks like that the Tenderly variables are not enough. For example you also need the HTTP Provider set for each chain (e.g for Fantom HTTP_PROVIDER_250)

Thanks in advance,

wagmi / viem

Hi there 👋

Our code uses wagmi and viem. It would make integration a little easier if we could use these.

Would there be any interest in allowing us to add wagmi and / or viem as dependencies to the repo?

PS: I did search and didn't see this issue raised before but my search skills are notoriously bad. Apologies if this has been discussed already.

TypeError: Do not know how to serialize a BigInt Error

I am integrating squadswap v3, and I get the following two errors while testing. I pass the e2e test completely successfully. Can you help me with these errors?

`yarn run v1.22.19
$ ts-node scripts/dex-integration.ts test squadswap-v3
FAIL src/dex/squadswap-v3/squadswap-v3-integration.test.ts
● Test suite failed to run

TypeError: Do not know how to serialize a BigInt
    at stringify (<anonymous>)

  at messageParent (node_modules/jest-worker/build/workers/messageParent.js:29:19)

FAIL src/dex/squadswap-v3/squadswap-v3-events.test.ts
● Test suite failed to run

TypeError: Do not know how to serialize a BigInt
    at stringify (<anonymous>)

  at messageParent (node_modules/jest-worker/build/workers/messageParent.js:29:19)`

Issues With BalancerV2 Liquidity Bootstrapping Pool Amounts

I wanted to report an issue we’ve been having with routes including a specific token 0x5c1892bb9e42b4bf89e5b0b21542e2f8622a0bb8. It looks like its using liquidity from the Balancer V2 “Liquidity Bootstrapping Pool” id 0xe9f7be5f534057b7ed5be82553e4da3c7aaac8b40002000000000000000001f9.

I noticed that the price route that is computed usually expects a much higher USDC return over what it is actually receiving. Just speculating, but could it be related to the fact that this pool has a dynamic fee or that the pool has gradual weight updates?

AFAICT, all price routes involving the above LBP are having issues.

Resources:

JS script that causes issue with ParaSwap API
const priceQuery = await fetch(
  "https://api.paraswap.io/prices/?srcToken=0x5C1892Bb9e42B4bf89e5b0B21542e2F8622a0bB8&destToken=0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE&amount=5000000000000000000000&srcDecimals=18&destDecimals=18&side=SELL&network=1&otherExchangePrices=true&partner=paraswap.io&userAddress=0xdBC682D0eC19bd276Fd6C2af4E0189B584BB31E1",
);
const { priceRoute } = await priceQuery.json();
console.log("route:", JSON.stringify(priceRoute, undefined, "  "));

const transactionQuery = await fetch("https://api.paraswap.io/transactions/1/?ignoreChecks=true", {
  method: "POST",
  headers: {
    "content-type": "application/json",
  },
  body: JSON.stringify({
    srcToken: "0x5C1892Bb9e42B4bf89e5b0B21542e2F8622a0bB8",
    destToken: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
    srcAmount: "5000000000000000000000",
    destAmount: "1",
    userAddress: "0x30123e49FE5f703b6675943c1520a422D1705DB6",
    priceRoute,
  }),
});
const transaction = await transactionQuery.json();

console.log(`block: ${priceRoute.blockNumber}`);
console.log(`from: ${transaction.from}`);
console.log(`to: ${transaction.to}`);
console.log(`data: ${transaction.data}`);
Example invocation of script 👆 with issue
route: {
  "blockNumber": 14809912,
  "network": 1,
  "srcToken": "0x5c1892bb9e42b4bf89e5b0b21542e2f8622a0bb8",
  "srcDecimals": 18,
  "srcAmount": "5000000000000000000000",
  "destToken": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
  "destDecimals": 18,
  "destAmount": "25844237307996337",
  "bestRoute": [
    {
      "percent": 100,
      "swaps": [
        {
          "srcToken": "0x5c1892bb9e42b4bf89e5b0b21542e2f8622a0bb8",
          "srcDecimals": 18,
          "destToken": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
          "destDecimals": 6,
          "swapExchanges": [
            {
              "exchange": "BalancerV2",
              "srcAmount": "5000000000000000000000",
              "destAmount": "47226070",
              "percent": 100,
              "poolAddresses": [
                "0xe9f7be5f534057b7ed5be82553e4da3c7aaac8b4"
              ],
              "data": {
                "swaps": [
                  {
                    "poolId": "0xe9f7be5f534057b7ed5be82553e4da3c7aaac8b40002000000000000000001f9",
                    "amount": "5000000000000000000000"
                  }
                ],
                "gasUSD": "4.876344"
              }
            }
          ]
        },
        {
          "srcToken": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
          "srcDecimals": 6,
          "destToken": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
          "destDecimals": 18,
          "swapExchanges": [
            {
              "exchange": "BalancerV2",
              "srcAmount": "47226070",
              "destAmount": "25844237307996337",
              "percent": 100,
              "poolAddresses": [
                "0xe7b1d394f3b40abeaa0b64a545dbcf89da1ecb3f"
              ],
              "data": {
                "swaps": [
                  {
                    "poolId": "0xe7b1d394f3b40abeaa0b64a545dbcf89da1ecb3f00010000000000000000009a",
                    "amount": "47226070"
                  }
                ],
                "gasUSD": "4.876344"
              }
            }
          ]
        }
      ]
    }
  ],
  "gasCostUSD": "12.155099",
  "gasCost": "373900",
  "others": [],
  "side": "SELL",
  "tokenTransferProxy": "0x216b4b4ba9f3e719726886d34a177484278bfcae",
  "contractAddress": "0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",
  "contractMethod": "multiSwap",
  "partnerFee": 0,
  "srcUSD": "49.0849782376",
  "destUSD": "52.5105798047",
  "partner": "paraswap.io",
  "maxImpactReached": false,
  "hmac": "9657fc26ecd1d5e1ab2044dfed9cd98fd8ff5ca4"
}
block: 14809912
from: 0xba12222222228d8ba445958a75a0704d566bf2c8
to: 0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57
data: 0xa94e78ef00000000000000000000000000000000000000000000000000000000000000200000000000000000000000005c1892bb9e42b4bf89e5b0b21542e2f8622a0bb800000000000000000000000000000000000000000000010f0cf064dd592000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000005bd132683be8b1000000000000000000000000dbc682d0ec19bd276fd6c2af4e0189b584bb31e10000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000bc00000000000000000000000000000000000000000000000000000000062879efae8920f60d81211ec9579bb691cb2090c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000540000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000fc2ba6e830a04c25e207b8214b26d8c713f6881f000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000009000000000000000000000000ba12222222228d8ba445958a75a0704d566bf2c8000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee5700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000260ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020e9f7be5f534057b7ed5be82553e4da3c7aaac8b40002000000000000000001f90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000010f0cf064dd5920000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000005c1892bb9e42b4bf89e5b0b21542e2f8622a0bb8000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000000000000027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000fc2ba6e830a04c25e207b8214b26d8c713f6881f000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000009000000000000000000000000ba12222222228d8ba445958a75a0704d566bf2c8000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee5700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000260ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020e7b1d394f3b40abeaa0b64a545dbcf89da1ecb3f00010000000000000000009a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000002d09cd600000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000

When simulating with Tenderly (with a fork where I set required allowances), I see that the actual swapped amount is:

image

Despite the route reporting that:

{
  "exchange": "BalancerV2",
  "srcAmount": "5000000000000000000000",
  "destAmount": "47226070",
  "percent": 100,
  "poolAddresses": [
    "0xe9f7be5f534057b7ed5be82553e4da3c7aaac8b4"
  ],
  "data": {
    "swaps": [
      {
        "poolId": "0xe9f7be5f534057b7ed5be82553e4da3c7aaac8b40002000000000000000001f9",
        "amount": "5000000000000000000000"
      }
    ],
    "gasUSD": "4.876344"
  }
}

Which is a 5% difference.

Paraswap won't let you swap Eth for WSTETH unless you have a huge overhead for fees.

Paraswap's gas fee calculation claims if you're swapping 10.05 Eth to WSTETH, and you have 10.059 that you do not have enough Eth for the fees. But, that's definitely more than enough Eth for covering the swap fees. You have to pull your Eth order all the way down to 10 Eth, and that's 0.059 Eth more than the amount traded. That's definitely way more than enough to cover fees.

Uniswap V3: how to update local state?

Hi! I need to fetch current state on chain and perform swaps locally (mutable and immutable ones). As I understood, I can perform immutable ones using uniswapV3Math.queryOutputs, but how can I perform mutable ones? uniswapV3Math contains _modifyPosition method, but how can I calculate ModifyPositionParams params for it if I know only params for uniswapV3Math.queryOutputs? Thank you in advance.

yarn test-integration not working

Hi paraswap team,

working on swapline integration for paraswap. I tryed to run the first tests but (at least on windows) it seams that test script calls the wrong jest file

The script "script/dex-integration" calls require('../node_modules/jest-cli/build/cli').run(...) but on my node-modules their is no "cli" file within the jest-cli folder.

Can you check if the path is still valid?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.