-
Notifications
You must be signed in to change notification settings - Fork 465
Conversation
149a57a
to
3b6b660
Compare
let bestPath: Fill[] = []; | ||
let bestPathInput = ZERO_AMOUNT; | ||
let bestPathRate = ZERO_AMOUNT; | ||
const _maxSteps = Math.max(maxSteps, 16); |
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.
Also cap the minimum so everyone gets some action.
3b6b660
to
51ce376
Compare
// Unique ID of the original source path this fill belongs to. | ||
// This is generated when the path is generated and is useful to distinguish | ||
// paths that have the same `source` IDs but are distinct (e.g., Curves). | ||
sourcePathId: string; |
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.
New field to tell consolidated sources apart.
51ce376
to
e3526e2
Compare
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.
overall approach look good to me
return ZERO_AMOUNT; | ||
} | ||
return side === MarketOperation.Sell ? output.div(input) : input.div(output); | ||
return side === MarketOperation.Sell ? output.div(targetInput) : targetInput.div(output); |
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.
hm yeah idk about this –– have you AB tested this change alone?
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.
🤷 whatever wins I guess
@@ -112,6 +114,7 @@ function dexQuotesToPaths( | |||
ethToOutputRate: BigNumber, | |||
fees: FeeSchedule, | |||
): Fill[][] { | |||
const sourcePathId = hexUtils.random(); |
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.
this should be inside the for loop I think
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.
I want it to be unique to the whole path. So we can tell which fill belongs to which curve.
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.
nvm ur rite
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.
yay that fixed my sims
packages/asset-swapper/src/utils/market_operation_utils/path_optimizer.ts
Outdated
Show resolved
Hide resolved
b5b688e
to
43a7d59
Compare
[ERC20BridgeSource.Native], | ||
[ERC20BridgeSource.Eth2Dai, ERC20BridgeSource.Curve], | ||
[ERC20BridgeSource.Eth2Dai], |
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.
wait what's going on here?
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.
Yeah it's a little funky that Curve comes right after Uniswap now, but both ways are technically valid so I'm like w/e 🤷
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.
sus but ok
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.
welcome to asset-swapper lol
[ERC20BridgeSource.Native], | ||
[ERC20BridgeSource.Eth2Dai, ERC20BridgeSource.Curve], | ||
[ERC20BridgeSource.Eth2Dai], |
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.
sus but ok
bb64233
to
2d29014
Compare
ec54580
to
ec1006a
Compare
ec1006a
to
d071054
Compare
Description
We can reduce the number of iterations we go through (
runLimit
) to find a decent path if we:targetInput
(fill amount) instead ofmin(targetInput, pathSize)
.runLimit
decay rate to0.5
(prev0.8
). So we halve the number of iterations for each subsequent call tomixPaths()
.bestPath
inmixPaths()
off with the left path (the previous mixed path), instead of starting with none.This makes it more likely that we walk the viable paths first, so we can cut
runLimit
down to something like2**8
(previously2**13
).This results in a much faster (2-3x) response time with small change in quotes:
Notes:
runLimit = 2**8
runLimit = 2**13
We can probably tweak
runLimit
to improve results. This should buy us a little breathing room until we can entirely replace the algorithm with something better.Testing instructions
Types of changes
Checklist:
[WIP]
if necessary.