-
Notifications
You must be signed in to change notification settings - Fork 13
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
feat: use automatic routing #531
Conversation
I've added some codechanges that already indicate what code adjustment i'm intending to implement. Please go through them and point out some decisions that are incorrect/in fact harmful. E.g. https://github.com/sidestream-tech/unified-auctions-ui/pull/531/files#diff-c6b4bdf1b82a84a00b56df1404f49c064a303b5919e55e1335c7afecaab1a7edR12 seems questionable. |
Encountering error when
|
The call of Possible reason: chain id is actually hardcoded :/ . SO when the router is created on main, the chain id corresponds to the actual one. On local setup it does not. Even on main branch the error appears (in the dashboard). So i would guess that setting the actual chain id should work (via fetching it with the existing method).
@valiafetisov do you have the instant idea on how to solve this? If not, i then go investigate |
If by "local setup" you mean "hardhat fork", then yes. It seems to be hardcoded:
Maybe making it dynamic will already solve the error? |
This paragraph was intended to let know that I've already tried your suggestion above. See the error is that is thrown ('No address for Uniswap Multicall...') in the same comment. |
Sorry, I thought that reinstalling the dependencies solved the original error #531 (comment)
This error is expected, since 1337 is a chain id that exist only for us. Uniswap SDK doesn't have an idea what is this chain id, as they have to unfortunately still hardcode some staff per chain id in the SDK (eg contract addresses). So for the hardhat fork we would still need to provide chain id that the hardhat is forking, not the one it is calling itself. This will solve the above problem and will bring us back to the initial:
Which according to a quick search originates from https://stackoverflow.com/questions/64674034/uniswap-typeerror-cannot-read-property-sortsbefore-of-undefined invalid |
Currently some tests started to fail after the 'eth-a' collateral was extended with the automatic routing config. See commit 87dfced which pinpoints the place. Adjusting the mocha test timeout to 100 seconds instead of 40s did not solve the problem. |
It's certainly the timeout. Dashboard on the hardhat first time took a very long time for me to load. So a lot of requests are made to get all pools, I assume. Not sure how to go about it, but to fix tests (until we have cache) we might want to skip this fetching |
|
'Uniswap V3 Autorouter': { | ||
callee: 'UniswapV3Callee', | ||
automaticRouter: true, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests fixed, code approved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- UI Test on
goerli
looks good ✅ - Tested keeper on
goerli
and executed ETH auction via swap (including auth txs) ✅ - Tested keeper on
hardhat fork
with ETH-A simulation running- authorisation steps successfully executed ✅
- for swap tx I get the following error in the console (see below)
ℹ collateral keeper: auction "ETH-A:840": attempting swap execution
ERROR collateral keeper: unexpected error: Cannot read properties of undefined (reading 'addresses')
Raising this as I am not able to reproduce it on main
branch.
Current bugs seem to be related to:
|
I need more context / info in order to properly decide how to proceed here:
|
no, this is a code logic issue.
(1) requires me to put more thinking in to figure out how to wire up things properly, @valiafetisov might come up with the fix faster. |
Ok, then I'd suggest to have @valiafetisov look into it in order to get this PR over the last mile and proceed with release. |
Yes, it seems like |
I've fixed (2), the side effect of this seems to be advance for (1) - the error is changed now with
The error is I was able to use the old Uniswap V3 router to execute swap |
core/src/calleeFunctions/index.ts
Outdated
const route = | ||
'route' in calleeConfig ? calleeConfig.route : await getCalleeAutoRoute(network, collateral, marketId, amount); | ||
return await routeToPool(network, route, collateral.symbol); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As pointed out in the issue several times:
We should expect that intermediate tokens might be tokens that are not part of the collateral config
we CAN NOT assume that the route
provided from the auto router will ONLY contain symbols that are known to the maker. Therefore we CAN NOT convert automatic route
to pool. Instead, the information provided by the AlphaRouter should contain enough information to build a pool object: addresses, symbols and fees.
const pools = await routeToPool(network, route, collateral.symbol, fees); | ||
const daiAmount = await convertCollateralToDaiUsingPool( | ||
network, | ||
collateral.symbol, | ||
marketId, | ||
collateralAmount, | ||
pools | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a better explanation would've been: previously we expected that pools (/routes) are static. Now we should receive and store pools together with prices (because re-requesting price via auto-router can change the pool) – so if the pool is generated, it have to be stored in the auction together with the price (unless the price is not an auction price, but just a reference price)
Next round of tests:
|
We will tackle these problems in a dedicated follow up issue and proceed with the merge of this PR for now. |
Closes #527
Checklist:
#
)