Git Product home page Git Product logo

smart-order-router's Introduction

Uniswap Smart Order Router

This repository contains routing logic for the Uniswap V3 protocol.

It searches for the most efficient way to swap token A for token B, considering splitting swaps across multiple routes and gas costs.

Testing

Unit Tests

First make sure you have run npm install and npm run build.

npm run test

Integration Tests

Make sure the .env file is configured to connect to mainnet and other chains. See the CLI section below for more details.

npm run integ-test

Tenderly Simulations

Quotes can be simulated on Tenderly

Ensure you set the following environment variables:

process.env.TENDERLY_BASE_URL!,
process.env.TENDERLY_USER!,
process.env.TENDERLY_PROJECT!,
process.env.TENDERLY_ACCESS_KEY!,

CLI

The package can be run as a CLI for testing purposes.

First create a .env file in the root of the project and configure:

JSON_RPC_PROVIDER = '<JSON_RPC_PROVIDER>'

To run on chains other than mainnet set up a connection by specifying the environment variable

JSON_RPC_PROVIDER_GORLI = '<JSON_RPC_PROVIDER>'
JSON_RPC_PROVIDER_OPTIMISM = '<JSON_RPC_PROVIDER>'
JSON_RPC_PROVIDER_OPTIMISM_GOERLI = '<JSON_RPC_PROVIDER>'
JSON_RPC_PROVIDER_ARBITRUM_ONE = '<JSON_RPC_PROVIDER>'
JSON_RPC_PROVIDER_ARBITRUM_GOERLI = '<JSON_RPC_PROVIDER>'
JSON_RPC_PROVIDER_POLYGON = '<JSON_RPC_PROVIDER>'
JSON_RPC_PROVIDER_POLYGON_MUMBAI = '<JSON_RPC_PROVIDER>'
JSON_RPC_PROVIDER_CELO = '<JSON_RPC_PROVIDER>'
JSON_RPC_PROVIDER_CELO_ALFAJORES = '<JSON_RPC_PROVIDER>'
JSON_RPC_PROVIDER_BNB = '<JSON_RPC_PROVIDER>'
JSON_RPC_PROVIDER_AVALANCHE = '<JSON_RPC_PROVIDER>'
JSON_RPC_PROVIDER_BASE = '<JSON_RPC_PROVIDER>'

Then from the root directory you can execute the CLI.

Examples

Some examples to use for manual CLI testing.

Mainnet

./bin/cli quote --tokenIn 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48 --tokenOut 0x1f9840a85d5af5bf1d1762f925bdaddc4201f984 --amount 1000 --exactIn --recipient 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B --protocols v2,v3

Best Route:
100.00% = USDC -- 0.3% --> UNI
	Raw Quote Out:
		35.72
	Gas Adjusted Quote Out:
		34.03

Gas Used Quote Token: 1.691772
Gas Used USD: 47.592951
Calldata: 0x414bf389000000000000...
Value: 0x00

  blockNumber: "13088815"
  estimatedGasUsed: "113000"
  gasPriceWei: "130000000000"


./bin/cli quote-to-ratio --token0 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48 --token1 0xdac17f958d2ee523a2206206994597c13d831ec7 --feeAmount 3000 --recipient 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B  --token0Balance 1000 --token1Balance 2000 --tickLower -120 --tickUpper 120

Best Route:
100.00% = USDT -- 0.05% --> USDC
Raw Quote Exact In:
	392.68
Gas Adjusted Quote In}:
	346.13

Gas Used Quote Token: 46.550010
Gas Used USD: 46.342899
Calldata: 0x414bf389000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000ab5801a7d398351b8be11c439e05c5b3259aec9b000000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000176a736c000000000000000000000000000000000000000000000000000000001764f8650000000000000000000000000000000000000000000000000000000000000000
	Value: 0x00

	blockNumber: "13239188"
	estimatedGasUsed: "113000"
	gasPriceWei: "116690684398"

./bin/cli quote --tokenIn 0x0391D2021f89DC339F60Fff84546EA23E337750f --tokenOut 0x4d224452801ACEd8B2F0aebE155379bb5D594381 --amount 10000 --exactIn --recipient 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B --protocols v2,v3,mixed
Best Route:
[V2 + V3] 100.00% = BOND -- [0x6591c4BcD6D7A1eb4E537DA8B78676C1576Ba244] --> USDC -- 0.3% [0xB07Fe2F407F971125D4EB1977f8aCEe8846C7324] --> APE
	Raw Quote Exact In:
		10437.85
	Gas Adjusted Quote In:
		10433.83

Gas Used Quote Token: 4.018625
Gas Used USD: 29.669402
Calldata: 0x5ae401dc0000000000000000000000000000000000000000000000000000000000000064000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000e4472b43f300000000000000000000000000000000000000000000021e19e0c9bab240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000391d2021f89dc339f60fff84546ea23e337750f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000104b858183f00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000080000000000000000000000000ab5801a7d398351b8be11c439e05c5b3259aec9b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002358df5b3b4459a3f5b000000000000000000000000000000000000000000000000000000000000002ba0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000bb84d224452801aced8b2f0aebe155379bb5d59438100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Value: 0x00

  blockNumber: "15303839"
  estimatedGasUsed: "434000"
  gasPriceWei: "38218865879"
Total ticks crossed: 7

Rinkeby

./bin/cli quote --tokenIn 0x5592ec0cfb4dbc12d3ab100b257153436a1f0fea --tokenOut 0x4DBCdF9B62e891a7cec5A2568C3F4FAF9E8Abe2b --amount 200000 --exactIn --minSplits 1 --router alpha --chainId 4

Sepolia

./bin/cli quote --tokenIn 0x7AF17A48a6336F7dc1beF9D485139f7B6f4FB5C8 --tokenOut 0x6f14C02Fc1F78322cFd7d707aB90f18baD3B54f5 --amount 10 --exactIn --minSplits 1 --router alpha --chainId 11155111

Kovan

./bin/cli quote --tokenIn 0x4f96fe3b7a6cf9725f59d353f723c1bdb64ca6aa --tokenOut 0xd0a1e359811322d97991e03f863a0c30c2cf029c --amount 10 --exactIn --minSplits 1 --router alpha --chainId 42

Ropsten

./bin/cli quote --tokenIn 0x07865c6e87b9f70255377e024ace6630c1eaa37f --tokenOut 0xc778417e063141139fce010982780140aa0cd5ab --amount 200000 --exactIn --minSplits 1 --router alpha --chainId 3

Optimism

./bin/cli quote --tokenIn 0x7F5c764cBc14f9669B88837ca1490cCa17c31607 --tokenOut 0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1 --amount 200000 --exactIn --minSplits 1 --router alpha --chainId 10

./bin/cli quote --tokenIn 0x7F5c764cBc14f9669B88837ca1490cCa17c31607 --tokenOut 0x4200000000000000000000000000000000000042 --amount 1 --exactIn --minSplits 1 --protocols v2 --router alpha --chainId 10

Optimism-Goerli

./bin/cli quote --tokenIn 0x7E07E15D2a87A24492740D16f5bdF58c16db0c4E --tokenOut 0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1 --amount 200000 --exactIn --minSplits 1 --router alpha --chainId 420

Optimistic-Kovan

./bin/cli quote --tokenIn 0x7F5c764cBc14f9669B88837ca1490cCa17c31607 --tokenOut 0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1 --amount 200 --exactIn --minSplits 1 --router alpha --chainId 69

Arbitrum

./bin/cli quote --tokenIn 0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9 --tokenOut 0x82af49447d8a07e3bd95bd0d56f35241523fbab1 --amount 20000 --exactIn --minSplits 1 --router alpha --chainId 42161 --debug

Arbitrum-Rinkeby

./bin/cli quote --tokenIn 0x09b98f8b2395d076514037ff7d39a091a536206c --tokenOut 0xb47e6a5f8b33b3f17603c83a0535a9dcd7e32681 --amount 200 --exactIn --minSplits 1 --router alpha --chainId 421611

Arbitrum-Goerli

./bin/cli quote --tokenIn 0xe39ab88f8a4777030a534146a9ca3b52bd5d43a3 --tokenOut 0x8FB1E3fC51F3b789dED7557E680551d93Ea9d892 --amount 200 --exactIn --minSplits 1 --router alpha --chainId 421613

Polygon Mumbai

./bin/cli quote --tokenIn 0x001b3b4d0f3714ca98ba10f6042daebf0b1b7b6f --tokenOut 0x9c3c9283d3e44854697cd22d3faa240cfb032889 --amount 1 --exactIn --protocols v3 --recipient 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B --minSplits 1 --router alpha --chainId 80001

Polygon Mainnet

./bin/cli quote --tokenIn 0x2791bca1f2de4661ed88a30c99a7a9449aa84174 --tokenOut 0x7ceb23fd6bc0add59e62ac25578270cff1b9f619 --amount 5 --exactIn --minSplits 1 --protocols v3 --router alpha --chainId 137

Celo Mainnet

./bin/cli quote --tokenIn CELO --tokenOut 0x765DE816845861e75A25fCA122bb6898B8B1282a --amount 5 --exactIn --minSplits 1 --protocols v3 --router alpha --chainId 42220

BNB Mainnet

./bin/cli quote --tokenIn 0x55d398326f99059fF775485246999027B3197955 --tokenOut 0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d --amount 1 --exactIn --minSplits 1 --protocols v3 --router alpha --chainId 56

AVAX Mainnet

./bin/cli quote --tokenIn 0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E --tokenOut 0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7 --amount 1000 --exactIn --minSplits 1 --protocols v3 --router alpha --chainId 43114

BASE Mainnet

./bin/cli quote --tokenIn 0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA --tokenOut 0x4200000000000000000000000000000000000006 --amount 10 --exactIn --minSplits 1 --protocols v3 --router alpha --chainId 8453

ZKSYNC Mainnet

./bin/cli quote --tokenIn 0x5aea5775959fbc2557cc8789bc1bf90a239d9a91 --tokenOut 0x1d17cbcf0d6d143135ae902365d2e5e2a16538d4 --amount 10 --exactIn --minSplits 1 --protocols v3 --router alpha --chainId 324

Adding a new Chain

The main components to complete are:

  • Deploy contracts on chain, add the pools to subgraph
  • Populate v3 providers in src/providers/v3/subgraph-provider and src/providers/v3/static-subgraph-provider
  • Populate chainId and addresses in src/util/chains.ts and src/util/addresses.ts
  • Populate token providers in src/providers/caching-token-provider and src/providers/token-provider.ts
  • Populate gas constants in src/routers/alpha-router/gas-models/*
  • Populate bases in src/routers/legacy-router/bases.ts
  • Populate test/integ/routers/alpha-router/alpha-router.integration.test.ts and src/providers/v2/static-subgraph-provider.ts
  • Populate src/routers/alpha-router/*
  • Add a log to /CHANGELOG.md
  • Run npm run integ-test successfully

Troubleshooting

ProviderGasLimit errors

The package sends many large multicall requests to nodes. You must ensure that your node provider's eth_call gas limit is high enough to successfully process the RPC calls.

By default each eth_call will consume up to:

  • 132,000,000 gas on Optimism
  • 120,000,000 gas on Arbitrum
  • 50,000,000 gas on Celo
  • 150,000,000 gas on every other network (Mainnet, Goerli, etc.)

These parameters should work on Infura and Alchemy by default.

This total amount of gas each eth_call can consume is equal to the multicallChunk config value multiplied by the gasLimitPerCall config value. If you are using a node provider with a lower gas limit per eth_call you will need to override the default V3QuoteProvider with an instance that lowers the multicallChunk and gasLimitPerCall parameters such that the multiplication is below your node providers limit. Lowering these values will cause each multicall to consume less gas. See here for examples of how to set these values. Note some providers have different limits per chain.

If you are running your own node, we recommend you configure start your node with a higher gas limit per call. For example, on Geth you can use the command line argument --rpc.gascap 150000000 to raise the limit to 150m, which is enough to run the default configuration of this package.

If you are using Hardhat mainnet forking, you should add blockGasLimit: 150_000_000 to your Hardhat config to use the default package configuration.

smart-order-router's People

Contributors

andysmith415 avatar cgkol avatar conjunctivenormalform avatar ewilz avatar github-actions[bot] avatar gzeoneth avatar hensha256 avatar iluxonchik avatar jesse-sawa avatar jsy1218 avatar just-toby avatar lint-action avatar lynnshaoyu avatar marktoda avatar mikeki avatar mr-uniswap avatar noahzinsmeister avatar passabilities avatar rachel-eichenberger avatar raghava-pamula avatar sismanis avatar smartcontracts avatar snreynolds avatar timnugent avatar unicorn-here avatar willpote avatar xrsv avatar yabirgb avatar zhongeric avatar zzmp 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

smart-order-router's Issues

Forward compatible with ERC20 which is`function symbol() view returns (bytes32)`

  • I'm submitting a bug report and feature request
    When I trade with RING/ETH pair at app.uniswap.org. An HTTP 500 error occur.
~ curl 'https://api.uniswap.org/v1/quote?protocols=v2%2Cv3&tokenInAddress=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2&tokenInChainId=1&tokenOutAddress=0x9469D013805bFfB7D3DEBe5E7839237e535ec483&tokenOutChainId=1&amount=11613710000000&type=exactIn' \
        -H 'authority: api.uniswap.org' \
        -H 'pragma: no-cache' \
        -H 'cache-control: no-cache' \
        -H 'accept: */*' \
        -H 'origin: https://app.uniswap.org' \
        -H 'sec-fetch-site: same-site' \
        -H 'sec-fetch-mode: cors' \
        -H 'sec-fetch-dest: empty' \
        -H 'referer: https://app.uniswap.org/' \
        --compressed

{"errorCode":"INTERNAL_ERROR","detail":"Unexpected error","id":"1e381"}

I figure out that is a smart-order-router API query, and then I try it by smart-order-router CLI.

~ ./bin/cli quote --tokenIn 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 --tokenOut 0x9469d013805bffb7d3debe5e7839237e535ec483 --amount 1000 --exactIn --recipient 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B --protocols v2,v3 --debug
INFO:  [Metric]: TokenListLoad: 1 | Milliseconds
  key: "TokenListLoad"
  value: 1
  unit: "Milliseconds"
INFO:  Found 1 out of 2 tokens in local cache. Checking primary token provider for 1 tokens

  addressesToFindInPrimary: ["0x9469d013805bffb7d3debe5e7839237e535ec483"]
INFO:  Found 0 tokens in primary. Checking secondary token provider for 1 tokens
  addressesToFindInSecondary: ["0x9469d013805bffb7d3debe5e7839237e535ec483"]
DEBUG: About to multicall for symbol across 1 addresses
  calls: [{"target":"0x9469d013805bffb7d3debe5e7839237e535ec483","callData":"0x95d89b41...
DEBUG: About to multicall for decimals across 1 addresses
  calls: [{"target":"0x9469d013805bffb7d3debe5e7839237e535ec483","callData":"0x313ce567...
DEBUG: Results for multicall on decimals across 1 addresses as of block 13900877
  results: [{"success":true,"result":[18]}]
    Error: call revert exception (method="symbol()", errorArgs=null, errorName=null,
    errorSignature=null, reason=null, code=CALL_EXCEPTION, version=abi/5.5.0)
    Code: CALL_EXCEPTION

A call revert error occurred, I think the reason is RING's symbol type is bytes32 not the string. This is a historical reason. dapphub/ds-token#28
And there is a lot of token like MKR have the same issue, but the MKR token is in the @uniswap/default-token-list, so it has no effect on MRK.
But other tokens like RING got hit. And I file an issue at Uniswap/default-token-list#1031.
To verify my idea, I added RING to @uniswap/default-token-list locally. It works 🚀

~ ./bin/cli quote --tokenIn 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 --tokenOut 0x9469d013805bffb7d3debe5e7839237e535ec483 --amount 1000 --exactIn --recipient 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B --protocols v2,v3
Best Route:
[V2] 85.00% = WETH --> RING, [V3] 15.00% = WETH -- 0.3% --> RING
        Raw Quote Exact In:
                16472715.82
        Gas Adjusted Quote In:
                16470330.17

Gas Used Quote Token: 2385.644467
Gas Used USD: 104.133692
Calldata: 0x5ae401dc0000000000000000000000000000000000000000000000000000000000000064000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000e4472b43f300000000000000000000000000000000000000000000002e141ea081ca0800000000000000000000000000000000000000000000000b658b561723e7673ef0a70000000000000000000000000000000000000000000000000000000000000080000000000000000000000000ab5801a7d398351b8be11c439e05c5b3259aec9b0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000009469d013805bffb7d3debe5e7839237e535ec4830000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e404e45aaf000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000009469d013805bffb7d3debe5e7839237e535ec4830000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000ab5801a7d398351b8be11c439e05c5b3259aec9b00000000000000000000000000000000000000000000000821ab0d44149800000000000000000000000000000000000000000000000238f21b6c7dcd9b6dd4cb000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Value: 0x00

  blockNumber: "13900919"
  estimatedGasUsed: "228000"
  gasPriceWei: "121520560130"
  • Summary
    There are two ways to fix the issue, Add RING token to @uniswap/default-token-list Uniswap/default-token-list#1031 or support ERC20 which isfunction symbol() view returns (bytes32)

EIP1559GasPriceProvider: doesn't work with hardhat node (mainnet fork)

I'm submitting a bug report.

Summary
When trying to run smart-order-router agains local mainnet fork, I get this error:

  code: 'SERVER_ERROR',
  body: '{"jsonrpc":"2.0","id":52,"error":{"code":-32602,"message":"Errors encountered in param 0: Invalid value 4 supplied to : QUANTITY"}}',
  error: Error: Errors encountered in param 0: Invalid value 4 supplied to : QUANTITY
      at getResult (/snapshot/liquidator/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:142:21)
      at processJsonFunc (/snapshot/liquidator/node_modules/@ethersproject/web/lib/index.js:344:22)
      at /snapshot/liquidator/node_modules/@ethersproject/web/lib/index.js:276:46
      at step (/snapshot/liquidator/node_modules/@ethersproject/web/lib/index.js:33:23)
      at Object.next (/snapshot/liquidator/node_modules/@ethersproject/web/lib/index.js:14:53)
      at fulfilled (/snapshot/liquidator/node_modules/@ethersproject/web/lib/index.js:5:58)
      at processTicksAndRejections (node:internal/process/task_queues:96:5) {
    code: -32602,
    data: undefined
  },
  requestBody: '{"method":"eth_feeHistory","params":[4,"latest",[50]],"id":52,"jsonrpc":"2.0"}',
  requestMethod: 'POST',
  url: 'http://127.0.0.1:8550/'
}

Other information
According to this spec, 1st argument of eth_feeHistory needs to be hex-encoded

Similar issue: web3/web3.js#4510

We worked around this by forking EIP1559GasPriceProvider and changing this:

      const feeHistoryRaw = (await this.provider.send('eth_feeHistory', [
        this.blocksToConsider,
        'latest',
        [this.priorityFeePercentile],
      ])) as RawFeeHistoryResponse;

to this:

      const feeHistoryRaw = (await this.provider.send('eth_feeHistory', [
        "0x" + this.blocksToConsider.toString(16),
        'latest',
        [this.priorityFeePercentile],
      ])) as RawFeeHistoryResponse;

Could not find route

Trying to find a route between e.g. NMR and BAL, this fails:

NMR : 0x1776e1F26f98b1A5dF9cD347953a26dd3Cb46671
BAL : 0xba100000625a3754423978a60c9317c58a424e3D

./bin/cli quote --tokenIn 0x1776e1F26f98b1A5dF9cD347953a26dd3Cb46671 --tokenOut 0xba100000625a3754423978a60c9317c58a424e3D --amount 1000 --exactIn --recipient 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B
Could not find route. Run in debug mode for more info.

But it seems to work ok at https://app.uniswap.org/#/swap

Other pairs do work as expected.

I ran with the debugger (--inspect) but this doesn't give me any more info. I'm using Alchemy as the JSON-RPC host

ProviderGasError

  • I'm submitting a ...
    [ ] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [V] question about how to use this project

  • Summary

  • Other information (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

I got ProviderGasError from my own node, I saw the same issue in #10 , but Im not sure what configuration of node should i change

Swapping on route involving non-stablecoin ERC20 exactOut does not result in exact output

  • I'm submitting a ...
    [x ] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary
    routing-api integration tests fail when testing the eth->erc20 (UNI) with exactOut and through V2 pools. Namely, an exact output is not achieved, rather:

      AssertionError: expected '10000.000000000000000171' to equal '10000'
      + expected - actual

      -10000.000000000000000171
      +10000
  • Other information (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

This branch on my fork of routing-api repo reproduces https://github.com/zhongeric/routing-api/tree/eric/swapped-dust-bug-repro

Additionally, the bug can be seen on my fork of this repo SOR: https://github.com/zhongeric/smart-order-router/tree/eric/refactor-integ-tests

Error post "npm run build"

  • I'm submitting a ...
    [X] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary

  • Other information (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

getting below error :

C:\Users\smart-order-router-main>npm run build
npm WARN config global --global, --local are deprecated. Use --location=global instead.

@uniswap/[email protected] build
run-p compile-v3-types compile-v2-types compile-router compile-external-types && run-p build:*

@uniswap/[email protected] compile-external-types
npx typechain --target ethers-v5 --out-dir src/types/other 'src/abis/**/*.json'

@uniswap/[email protected] compile-v3-types
npx typechain --target ethers-v5 --out-dir src/types/v3 './node_modules/@uniswap/?(v3-core|v3-periphery)/artifacts/contracts/**/*.json'

@uniswap/[email protected] compile-router
npx typechain --target ethers-v5 --out-dir src/types/other './node_modules/@uniswap/swap-router-contracts/artifacts/contracts/**/*.json'

@uniswap/[email protected] compile-v2-types
npx typechain --target ethers-v5 --out-dir src/types/v2 './node_modules/@uniswap/?(v2-core|v2-periphery)/build/UniswapV2.json'

'v3-periphery)' is not recognized as an internal or external command,
operable program or batch file.
'v2-periphery)' is not recognized as an internal or external command,
operable program or batch file.
ERROR: "compile-v3-types" exited with 255.

image

Force rebasing tokens to use V2

  • I'm submitting a ...
    [ X ] bug report
    [ X ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary
    Rebasing tokens, such as AMPL, do not work correctly on V3. However users can still create pools using them, and those pools end up with invalid prices that can cause the auto router to try and route through them.

We haven't seen an instance of this happening yet, but this is what happened with Fee On Transfer tokens here, which we solved using the TokenValidator lens.

We should find a way to detect rebasing tokens in the auto router and force them to use V2.

  • Other information (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

Optimizations

I'm running this code with a local JSON-RPC node but finding it to be pretty slow (8 core 4ghz, 32 GB RAM, all SSDs etc) . It averages around 7 seconds to generate a route, vs ~2-3 seconds for the public endpoint that serves the Uniswap UI. Are there any optimizations that might be used to speed things up? Caching, or excluding certain pools perhaps?

Error: Convert JSBI instances to native numbers using `toNumber`.

  • I'm submitting a ...
    [ x ] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary

If you are using the smart-order-router and calling the route function, when the router calculates the gas price by converting the liquidity in the pool into a number, it throws an error. See error stack V3HeuristicGasModelFactory.getHighestLiquidityUSDPool
Pool address where this error ocurse is: 0x9957c4795ab663622db54fc48fda874da59150ff
ChainId is 1

I assume the number is bigger than Number.MAX_SAFE_INTEGER?

  • Other information (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)
Call Stack
JSBI.valueOf
node_modules/jsbi/dist/jsbi.mjs (1:1233)
baseGt
node_modules/@uniswap/smart-order-router/node_modules/lodash/lodash.js (3124:0)
baseExtremum
node_modules/@uniswap/smart-order-router/node_modules/lodash/lodash.js (2909:0)
Function.maxBy
node_modules/@uniswap/smart-order-router/node_modules/lodash/lodash.js (16407:0)
V3HeuristicGasModelFactory.getHighestLiquidityUSDPool
node_modules/@uniswap/smart-order-router/build/module/src/routers/alpha-router/gas-models/v3/v3-heuristic-gas-model.js (201:25)
async V3HeuristicGasModelFactory.buildGasModel
node_modules/@uniswap/smart-order-router/build/module/src/routers/alpha-router/gas-models/v3/v3-heuristic-gas-model.js (67:0)
async AlphaRouter.getV3Quotes
node_modules/@uniswap/smart-order-router/build/module/src/routers/alpha-router/alpha-router.js (370:0)
async AlphaRouter.route
node_modules/@uniswap/smart-order-router/build/module/src/routers/alpha-router/alpha-router.js (293:0)

Fix L2 gas estimates

Both Arbitrum and Optimism account for gas differently.

Known differences (not exhaustive list)
Arbitrum gas units are different- opcodes are priced differently, so swaps cost different amounts
Optimism charges a fee based on the size of the calldata that would need to be sent to L1
Arbitrum has 2 seperate gas meters- one for compute and one for storage

We likely need changes to:

  1. The heuristics we use for estimating gas on V3 and V2 swaps. Probably need to make this code chain aware and adjust the values

https://github.com/Uniswap/smart-order-router/blob/main/src/routers/alpha-router/gas-models/v3/v3-heuristic-gas-model.ts#L16-L26
https://github.com/Uniswap/smart-order-router/blob/main/src/routers/alpha-router/gas-models/v2/v2-heuristic-gas-model.ts

Easiest way to figure out the new values might be to use Tenderly to fork Arb/Opt, use the CLI to generate swaps that cross different amount of ticks and get the calldata, then simulate the swaps on the Tenderly forks to see how much gas they use

  1. How we compute gas price. On Optimism for example eth_gasPrice always return 1000000, which I'm not sure is correct. On Arb its not clear if we capture everything we need by querying eth_gasPrice (also unclear if we need to capture both when estimating gas)

https://github.com/Uniswap/smart-order-router/blob/main/src/providers/on-chain-gas-price-provider.ts

Update Optimism swap calldata based on compression alg

Optimism is updating their sequencer to use a compression alg for lower gas costs. Since we are calculating the gas manually in the gas model we'll need to update the calldata bytes to reflect how the compression is generating calldata.

Referencing this post

Failed to get ... quotes. Reasons: ProviderGasError, ProviderGasError, ProviderGasError

Getting this error for WETH->DAI and other pairs, e.g.

WETH : 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
DAI : 0x6B175474E89094C44Da98b954EedeAC495271d0F

./bin/cli quote --tokenIn 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 --tokenOut 0x6B175474E89094C44Da98b954EedeAC495271d0F --amount 1000 --exactIn --recipient 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B

Error: Failed to get 3 quotes. Reasons: ProviderGasError, ProviderGasError, ProviderGasError

package.json doesn't support bash

  • I'm submitting a ...
    [ ] question about how to use this project

npm run build keeps failing. It says

'v3-periphery)' is not recognized as an internal or external command,
operable program or batch file.

details:

> @uniswap/[email protected] build
> run-p compile-v3-types compile-v2-types compile-router compile-external-types && run-p build:*


> @uniswap/[email protected] compile-v2-types
> npx typechain --target ethers-v5 --out-dir src/types/v2 './node_modules/@uniswap/?(v2-core|v2-periphery)/build/*UniswapV2*.json'


> @uniswap/[email protected] compile-v3-types
> npx typechain --target ethers-v5 --out-dir src/types/v3 './node_modules/@uniswap/?(v3-core|v3-periphery)/artifacts/contracts/**/*.json'


> @uniswap/[email protected] compile-router
> npx typechain --target ethers-v5 --out-dir src/types/other './node_modules/@uniswap/swap-router-contracts/artifacts/contracts/**/*.json'


> @uniswap/[email protected] compile-external-types
> npx typechain --target ethers-v5 --out-dir src/types/other 'src/abis/**/*.json'

'v3-periphery)' is not recognized as an internal or external command,
operable program or batch file.
'v2-periphery)' is not recognized as an internal or external command,
operable program or batch file.
ERROR: "compile-v3-types" exited with 255.

Have tried clear cache and reinstall node_modules,but not working.

Could anybody help me out? Thanks a lot !

Export calculateRatioAmountIn() function

  • I'm submitting a ...
    [ ] bug report
    [*] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary

This function...

https://github.com/Uniswap/smart-order-router/blob/main/src/routers/alpha-router/functions/calculate-ratio-amount-in.ts#L4

.. is highly useful outside the context of the Alpha Router, but it's not exported from:

https://github.com/Uniswap/smart-order-router/blob/main/src/routers/alpha-router/index.ts

  • Other information (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

routeToRatio() throws error 'Could not parse fraction' when output balance is zero.

  • I'm submitting a ...
    [*] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary

  • Other information (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

Consider a "swap and add liquidity" transaction using the alpha router where the account has some WETH, some ETH for gas, and no USDC. I want to add liquidity to the WETH/USDC pool, for which I need to first swap about half my WETH to USDC (because my range happens to straddle the current price in the pool pretty evenly).

Calling AlphaRouter.routeToRatio() and passing in a token1Balance of zero USDC will result in this line in the stack...

.subtract(optimalRatio.multiply(outputBalance.quotient))

... throwing an error 'Could not parse fraction'. Multiplying a Fraction by a CurrencyAmount (both from sdk-core) that is zero throws the error.

My stack trace is:

/home/e/r/dro/smart-order-router/node_modules/@uniswap/sdk-core/src/entities/fractions/fraction.ts:38
    throw new Error('Could not parse fraction')
          ^
Error: Could not parse fraction
    at Function.tryParseFraction (/home/e/r/dro/smart-order-router/node_modules/@uniswap/sdk-core/src/entities/fractions/fraction.ts:38:11)
    at Fraction.multiply (/home/e/r/dro/smart-order-router/node_modules/@uniswap/sdk-core/src/entities/fractions/fraction.ts:108:34)
    at Object.calculateRatioAmountIn (/home/e/r/dro/smart-order-router/src/routers/alpha-router/functions/calculate-ratio-amount-in.ts:18:60)
    at AlphaRouter.routeToRatio (/home/e/r/dro/smart-order-router/src/routers/alpha-router/alpha-router.ts:613:26)
    at DRO.<anonymous> (/home/e/r/dro/dro/src/dro.ts:700:70)
    at step (/home/e/r/dro/dro/src/dro.ts:33:23)
    at Object.next (/home/e/r/dro/dro/src/dro.ts:14:53)
    at fulfilled (/home/e/r/dro/dro/src/dro.ts:5:58)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

I'd expect this to be quite a common starting state for the account - some of one asset and none of the other in the pool. The SDK docs at https://docs.uniswap.org/sdk/guides/liquidity/swap-and-add use an example with some USDC but no WETH. Nevertheless, could it be that there are no tests that cover this scenario?

Pool type is incompatible with v3-sdk

  • I'm submitting a ...
    [*] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary

Does the smart-order-router repo use a different definition of the Pool class to the v3-sdk repo? I don't understand why I'm getting this error in the IDE:

Argument of type 'import("/home/e/r/dro/dro/node_modules/@uniswap/v3-sdk/dist/entities/position").Position' is not assignable to parameter of type 'import("/home/e/r/dro/dro/node_modules/@uniswap/smart-order-router/node_modules/@uniswap/v3-sdk/dist/entities/position").Position'.
  Types of property 'pool' are incompatible.
    Type 'import("/home/e/r/dro/dro/node_modules/@uniswap/v3-sdk/dist/entities/pool").Pool' is not assignable to type 'import("/home/e/r/dro/dro/node_modules/@uniswap/smart-order-router/node_modules/@uniswap/v3-sdk/dist/entities/pool").Pool'.
      Types have separate declarations of a private property '_token0Price'.ts(2345)

Here's my code:

    ...
    import { CurrencyAmount, Percent, BigintIsh, TradeType, Currency, Fraction } from "@uniswap/sdk-core"
    import { rangeOrderPoolContract, swapPoolContract, quoterContract, positionManagerContract, usdcToken, wethToken, rangeOrderPoolTick, rangeOrderPoolPriceUsdc, rangeOrderPoolPriceUsdcAsBigNumber, rangeOrderPoolTickSpacing, extractTokenId, positionByTokenId, positionWebUrl, tokenOrderIsWethFirst, DEADLINE_SECONDS, VALUE_ZERO_ETHER } from './uniswap'
    import { AlphaRouter } from '@uniswap/smart-order-router'

    async swapAndAddLiquidity() {
      // The order of the tokens in the pool varies from chain to chain, annoyingly.
      // Ethereum mainnet: USDC is first
      // Arbitrum mainnet: WETH is first
      let token0Balance
      let token1Balance

      // The wallet gives us BigNumbers for balances, but Uniswap's CurrencyAmount takes a
      // BigintIsh, which is a JSBI, string or number.
      if (this.wethFirst) {
        token0Balance = CurrencyAmount.fromRawAmount(wethToken, await (await wallet.weth()).toString())
        token1Balance = CurrencyAmount.fromRawAmount(usdcToken, await (await wallet.usdc()).toString())
      }
      else {
        token0Balance = CurrencyAmount.fromRawAmount(usdcToken, await (await wallet.usdc()).toString())
        token1Balance = CurrencyAmount.fromRawAmount(wethToken, await (await wallet.weth()).toString())
      }

      const slot = await rangeOrderPoolContract.slot0()
      const liquidity = await rangeOrderPoolContract.liquidity()

      // A position instance requires a Pool instance.
      let rangeOrderPool: Pool

      if (CHAIN_CONFIG.isTestnet) {
        rangeOrderPool = new Pool(
          usdcToken,
          wethToken,
          FeeAmount.MEDIUM, // Fee: 0.30%
          slot[0].toString(), // SqrtRatioX96
          liquidity.toString(), // Liquidity
          slot[1], // Tick
          // ticks
        )

        // Rather than require minTick and maxTick to be valid, replace them with valid values on
        // testnets. These were observed on a manually created position, therefore they're valid.
        this.minTick = 191580
        this.maxTick = 195840
      }
      else {
        rangeOrderPool = new Pool(
          usdcToken,
          wethToken,
          slot[5], // Fee: 0.30%
          slot[0].toString(), // SqrtRatioX96
          liquidity.toString(), // Liquidity
          slot[1] // Tick
        )
      }

      const p = new Position({
        pool: rangeOrderPool,
        tickLower: this.minTick,
        tickUpper: this.maxTick,
        liquidity: 1
      })

      const router = new AlphaRouter({ chainId: CHAIN_CONFIG.chainId, provider: CHAIN_CONFIG.provider()})

      const routeToRatioResponse = await router.routeToRatio(
        token0Balance,
        token1Balance,
        p, // <-- IDE complains here
        // swapAndAddConfig
        {
          ratioErrorTolerance: new Fraction(1, 100),
          maxIterations: 6,
        },
        // swapAndAddOptions
        {
           swapConfig: {
             recipient: wallet.address,
             slippage: new Percent(5, 100),
             deadline: 100
           },
           addLiquidityOptions: {
             recipient: wallet.address,
           }
         }
      )
    }
  • Other information (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

Unable to validate token SHINJA

  • I'm submitting a ...
    [x] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary
    Upon trying to calculate a route to swap WETH to Holdenomics or Para Token, we have found that in the routers attempts to find a route, it fails to validate the SHINJA contract during route calculation and fails to return a route.

  • Other information (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)
    I've attached a debug trace of the swap with holdenomics - the same occurs on Para.
    debug.txt

Token1Balance.currency.wrapped returning Undefined

  • I'm submitting a ...
    [ ] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [X ] question about how to use this project

  • Summary
    I am trying to use the routeToRatio() function in AlphaRouter and I am following the steps given in the SDK guide. I receive this error when trying WETH and USDC pool on mainnet..

""if (token1Balance.currency.wrapped.sortsBefore(token0Balance.currency.wrapped)) {
^
TypeError: Cannot read properties of undefined (reading 'currency')
at AlphaRouter.routeToRatio (/Users/adrian/Documents/ARC/node_modules/@uniswap/smart-order-router/build/main/src/routers/alpha-router/alpha-router.js:148:27)""

To get the token1Balance/token0Balance I am using CurrencyAmount.fromRawAmount() and when I print the Token object returned by this function I see there is no ".wrapped" property, similar to what the error says. Also, when I print token1Balance.currency.wrapped, I receive the Token object, NOT undefined like the error would suggest. I am not sure why I would receive a valid value on my local machine but not once the token1Balance variable is sent to the SDK. I also have tried using parseAmount() as used in the alphaRouter test files but I get the same errors. I have run out of ideas of parameters to change or functions to try, any guidance on this problem would be greatly appreciated.

Here is my code:

const slot0 = await ETH_USDC_MAIN_30.methods.slot0().call();
const feeTier = await ETH_USDC_MAIN_30.methods.fee().call();

const liquidity = await ETH_USDC_MAIN_30.methods.liquidity().call();

const token0 = await ETH_USDC_MAIN_30.methods.token0().call();
const token1 = await ETH_USDC_MAIN_30.methods.token1().call();

let TokenA = new Token(1, token0, 6 , USDC);

console.log("Token A ", TokenA.wrapped);

const TokenB = new Token(1, WETH_Address_Main, 18, "WETH", "Wrapped Ether");
console.log("Token B ", TokenB.wrapped);

const token0Balance = CurrencyAmount.fromRawAmount(TokenA, "1000000000000000000");
// const token0Balance = parseAmount("1000000000000000000", WETH_ethers);
console.log("TOken 0 balance ", token0Balance);

const token1Balance = CurrencyAmount.fromRawAmount(TokenB, "1000000000000000000000");
// const token1Balance = parseAmount("20", TokenB);
console.log("TOken 1 balance ", token1Balance);

const routeToRatioResponse = await router.routeToRatio({
token0Balance: token0Balance,
token1Balance: token1Balance,
position: await new Position({
pool: await new Pool(
TokenA,
TokenB,
Number(feeTier),
slot0.sqrtPriceX96.toString(),
liquidity,
Number(slot0.tick),

  ),
  tickLower: Number("193380"),
  tickUpper: Number("203160"),
  liquidity: 1, //leave as 1
 }),

calculateRatioAmountIn() throws an Error when the optimalRatio is zero.

  • I'm submitting a ...
    [*] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary

  • Other information (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)
    This line:

https://github.com/Uniswap/smart-order-router/blob/main/src/routers/alpha-router/functions/calculate-ratio-amount-in.ts#L12

will throw an Error when the optimalRatio passed in is zero, ie. a Fraction with a denominator of 1 but no numerator.

Such a Fraction is easily produced by AlphaRouter.routeToRatio() here:

https://github.com/Uniswap/smart-order-router/blob/main/src/routers/alpha-router/alpha-router.ts#L559

Here's the stack trace from my project code:

/home/e/r/dro/smart-order-router/node_modules/@uniswap/sdk-core/src/entities/fractions/fraction.ts:38
    throw new Error('Could not parse fraction')
          ^
Error: Could not parse fraction
    at Function.tryParseFraction (/home/e/r/dro/smart-order-router/node_modules/@uniswap/sdk-core/src/entities/fractions/fraction.ts:38:11)
    at Fraction.multiply (/home/e/r/dro/smart-order-router/node_modules/@uniswap/sdk-core/src/entities/fractions/fraction.ts:108:34)
    at Object.calculateRatioAmountIn (/home/e/r/dro/smart-order-router/src/routers/alpha-router/functions/calculate-ratio-amount-in.ts:12:28)
    at AlphaRouter.routeToRatio (/home/e/r/dro/smart-order-router/src/routers/alpha-router/alpha-router.ts:606:26)
    at DRO.<anonymous> (/home/e/r/dro/dro/src/dro.ts:670:70)
    at step (/home/e/r/dro/dro/src/dro.ts:33:23)
    at Object.next (/home/e/r/dro/dro/src/dro.ts:14:53)
    at fulfilled (/home/e/r/dro/dro/src/dro.ts:5:58)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

In case it matters, the version of JSBI in my codebase is:

"jsbi": "^3.2.4",

whereas in sdk-core v3.0.1 it's:

"jsbi": "^3.1.4",

got null route with EXACT_INPUT when swap FRAX with USDC

  • I'm submitting a ...
    [ ] question about how to use this project

  • Summary
    I am going to swap some FRAX with USDC. When I use the EXACT_INPUT mode, the route returns is null. But If I choose the EXACT_OUTPUT mode, the route is correct. I can't figure out what's going on with these two modes. The code is as follows.

  • Other information (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

const FRAX = new Token(
	ChainId.POLYGON,
	'0x45c32fA6DF82ead1e2EF74d17b76547EDdFaFF89',
	18,
	'FRAX',
	'Frax'
);

const USDC = new Token(
	ChainId.POLYGON,
	'0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
	6,
	'USDC',
	'USD//C'
);
  1. When swap with EXACT_INPUT
        const usdcAmount = CurrencyAmount.fromRawAmount(USDC, JSBI.BigInt(rawAmount));
	const route = await router.route(
		usdcAmount,
		FRAX,
		TradeType.EXACT_INPUT,
		{
			recipient: signer.address,
			slippageTolerance: new Percent(5, 100),
			deadline: Date.now() + 1800
		}
	);

Then I got null route.
2. swap with EXACT_OUTPUT

        const fraxAmount = CurrencyAmount.fromRawAmount(FRAX, JSBI.BigInt(rawAmount));
	const route = await router.route(
		fraxAmount,
		USDC,
		TradeType.EXACT_OUTPUT,
		{
			recipient: signer.address,
			slippageTolerance: new Percent(5, 100),
			deadline: Date.now() + 1800
		}
	);

the route is ok.

Client-side Routing: Integrate smart-order-router v2 into interface

  • I'm submitting a ...
    [ ] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary

  • Other information (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

Ratio returned by AlphaRouter.calculateOptimalRatio() is out by about 2%

  • I'm submitting a ...
    [*] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary

For my test position (a symmetrical, in-range position in the WETH/USDC pool with the 0.3% fee), AlphaRouter.calculateOptimalRatio() returns a ratio that is out by about 2%. I've provided a failing test for this in #77.

  • Other information (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

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.