CoinAlpha / gateway-api

Apache License 2.0
47 stars 25 forks source link

fix broken getPosition function and add feature to estimate gas fee f… #103

Closed vic-en closed 2 years ago

vic-en commented 3 years ago

This PR fixes the broken getPosition function. It also adds a feature to the /remove-position endpoint to make it possible for the client to get a more accurate estimate of gas that will be used to close a specified position.

james-hummingbot commented 2 years ago

@PtrckM @vic-en Is the postman for /eth/uniswap/v3/start up to date? It should be a GET to something like this https://localhost:{{port}}/eth/uniswap/v3/start?pairs=["WETH-USDC"]&gasPrice=30. That works for me on this branch.

james-hummingbot commented 2 years ago

I am getting a similar error from the following routes

12:51:14 0|index  | info:       Request from IP: ::1 POST /eth/uniswap/v3/price {"timestamp":"2021-07-13T10:51:14.319Z"}
12:51:14 0|index  | Error: invalid hexlify value (argument="value", value="eyJuYW1lIjoiaHVtbWluZ2JvdCIsImFkZHJlc3MiOiJ0ZXJyYTFnNjBldXplNmRycHpjdmt5eDN3M3pma2ZsbHZnMzBlc3E1cGdrdSIsImVuY3J5cHRlZF9rZXkiOiJhZGZiZGE1MjQwMzQ2MWJkYWFhYjhhYjNlNTQ3ODlhN2NiMGE2MDM2ODAyMWUxMWQ4MmFhMWVlNjFkMGY3M2QzS0kwU1dUZjdDNkNTYU5RTjg0MnV1VkVZb0JuNk1FMnVjVkNVZ0hBNEtpalRNOTJBVGpqRXk2WTBVa2RKQ09oa25lbFN6OHZ5WjZwa3lVa05LRGhqME9iNkFQeHdmZ2hMSkJmdzRyYnNUdTQ9In0=", code=INVALID_ARGUMENT, version=bytes/5.4.0)
12:51:14 0|index  |     at Logger.makeError (/home/james/work/hummingbot/gateway-api/node_modules/@ethersproject/logger/src.ts/index.ts:213:28)
12:51:14 0|index  |     at Logger.throwError (/home/james/work/hummingbot/gateway-api/node_modules/@ethersproject/logger/src.ts/index.ts:225:20)
12:51:14 0|index  |     at Logger.throwArgumentError (/home/james/work/hummingbot/gateway-api/node_modules/@ethersproject/logger/src.ts/index.ts:229:21)
12:51:14 0|index  |     at Object.hexlify (/home/james/work/hummingbot/gateway-api/node_modules/@ethersproject/bytes/src.ts/index.ts:247:19)
12:51:14 0|index  |     at new SigningKey (/home/james/work/hummingbot/gateway-api/node_modules/@ethersproject/signing-key/src.ts/index.ts:35:44)
12:51:14 0|index  |     at new Wallet (/home/james/work/hummingbot/gateway-api/node_modules/@ethersproject/wallet/src.ts/index.ts:89:36)
12:51:14 0|index  |     at /home/james/work/hummingbot/gateway-api/src/routes/uniswap_v3.ts:355:5
12:51:14 0|index  |     at Generator.next (<anonymous>)
12:51:14 0|index  |     at /home/james/work/hummingbot/gateway-api/dist/routes/uniswap_v3.js:8:71
12:51:14 0|index  |     at new Promise (<anonymous>) {
12:51:14 0|index  |   reason: 'invalid hexlify value',
12:51:14 0|index  |   code: 'INVALID_ARGUMENT',
12:51:14 0|index  |   argument: 'value',
12:51:14 0|index  |   value: 'eyJuYW1lIjoiaHVtbWluZ2JvdCIsImFkZHJlc3MiOiJ0ZXJyYTFnNjBldXplNmRycHpjdmt5eDN3M3pma2ZsbHZnMzBlc3E1cGdrdSIsImVuY3J5cHRlZF9rZXkiOiJhZGZiZGE1MjQwMzQ2MWJkYWFhYjhhYjNlNTQ3ODlhN2NiMGE2MDM2ODAyMWUxMWQ4MmFhMWVlNjFkMGY3M2QzS0kwU1dUZjdDNkNTYU5RTjg0MnV1VkVZb0JuNk1FMnVjVkNVZ0hBNEtpalRNOTJBVGpqRXk2WTBVa2RKQ09oa25lbFN6OHZ5WjZwa3lVa05LRGhqME9iNkFQeHdmZ2hMSkJmdzRyYnNUdTQ9In0='
12:51:14 0|index  | }
vic-en commented 2 years ago

@PtrckM @vic-en Is the postman for /eth/uniswap/v3/start up to date? It should be a GET to something like this https://localhost:{{port}}/eth/uniswap/v3/start?pairs=["WETH-USDC"]&gasPrice=30. That works for me on this branch.

We don't pass gasPrice to this endpoint. This is how it should be https://localhost:{{port}}/eth/uniswap/v3/start?pairs=["COIN1-COIN3", "COIN2-COIN1"]. So no need to update postman.

vic-en commented 2 years ago

I am getting a similar error from the following routes

* /eth/uniswap/v3/price current and historical

* /eth/uniswap/v3/trade
12:51:14 0|index  | info:       Request from IP: ::1 POST /eth/uniswap/v3/price {"timestamp":"2021-07-13T10:51:14.319Z"}
12:51:14 0|index  | Error: invalid hexlify value (argument="value", value="eyJuYW1lIjoiaHVtbWluZ2JvdCIsImFkZHJlc3MiOiJ0ZXJyYTFnNjBldXplNmRycHpjdmt5eDN3M3pma2ZsbHZnMzBlc3E1cGdrdSIsImVuY3J5cHRlZF9rZXkiOiJhZGZiZGE1MjQwMzQ2MWJkYWFhYjhhYjNlNTQ3ODlhN2NiMGE2MDM2ODAyMWUxMWQ4MmFhMWVlNjFkMGY3M2QzS0kwU1dUZjdDNkNTYU5RTjg0MnV1VkVZb0JuNk1FMnVjVkNVZ0hBNEtpalRNOTJBVGpqRXk2WTBVa2RKQ09oa25lbFN6OHZ5WjZwa3lVa05LRGhqME9iNkFQeHdmZ2hMSkJmdzRyYnNUdTQ9In0=", code=INVALID_ARGUMENT, version=bytes/5.4.0)
12:51:14 0|index  |     at Logger.makeError (/home/james/work/hummingbot/gateway-api/node_modules/@ethersproject/logger/src.ts/index.ts:213:28)
12:51:14 0|index  |     at Logger.throwError (/home/james/work/hummingbot/gateway-api/node_modules/@ethersproject/logger/src.ts/index.ts:225:20)
12:51:14 0|index  |     at Logger.throwArgumentError (/home/james/work/hummingbot/gateway-api/node_modules/@ethersproject/logger/src.ts/index.ts:229:21)
12:51:14 0|index  |     at Object.hexlify (/home/james/work/hummingbot/gateway-api/node_modules/@ethersproject/bytes/src.ts/index.ts:247:19)
12:51:14 0|index  |     at new SigningKey (/home/james/work/hummingbot/gateway-api/node_modules/@ethersproject/signing-key/src.ts/index.ts:35:44)
12:51:14 0|index  |     at new Wallet (/home/james/work/hummingbot/gateway-api/node_modules/@ethersproject/wallet/src.ts/index.ts:89:36)
12:51:14 0|index  |     at /home/james/work/hummingbot/gateway-api/src/routes/uniswap_v3.ts:355:5
12:51:14 0|index  |     at Generator.next (<anonymous>)
12:51:14 0|index  |     at /home/james/work/hummingbot/gateway-api/dist/routes/uniswap_v3.js:8:71
12:51:14 0|index  |     at new Promise (<anonymous>) {
12:51:14 0|index  |   reason: 'invalid hexlify value',
12:51:14 0|index  |   code: 'INVALID_ARGUMENT',
12:51:14 0|index  |   argument: 'value',
12:51:14 0|index  |   value: 'eyJuYW1lIjoiaHVtbWluZ2JvdCIsImFkZHJlc3MiOiJ0ZXJyYTFnNjBldXplNmRycHpjdmt5eDN3M3pma2ZsbHZnMzBlc3E1cGdrdSIsImVuY3J5cHRlZF9rZXkiOiJhZGZiZGE1MjQwMzQ2MWJkYWFhYjhhYjNlNTQ3ODlhN2NiMGE2MDM2ODAyMWUxMWQ4MmFhMWVlNjFkMGY3M2QzS0kwU1dUZjdDNkNTYU5RTjg0MnV1VkVZb0JuNk1FMnVjVkNVZ0hBNEtpalRNOTJBVGpqRXk2WTBVa2RKQ09oa25lbFN6OHZ5WjZwa3lVa05LRGhqME9iNkFQeHdmZ2hMSkJmdzRyYnNUdTQ9In0='
12:51:14 0|index  | }

I think something is wrong with your configuration. It works fine on my side.

james-hummingbot commented 2 years ago

@vic-en ok I will check again