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

Invalid Dfyn swap route on Polygon #588

Open
xykota opened this issue Nov 22, 2023 · 0 comments
Open

Invalid Dfyn swap route on Polygon #588

xykota opened this issue Nov 22, 2023 · 0 comments

Comments

@xykota
Copy link

xykota commented Nov 22, 2023

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;
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant