Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

fix sample calc in library, add getTradeDiffs #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ethzoomer
Copy link

@ethzoomer ethzoomer commented May 5, 2023

Deployed here https://optimistic.etherscan.io/address/0x82959edf06499c3c931c39ebca8737f0b5551bec and being used in nightride UI

Makes _getAmountOut account for differences in the amount of decimals for tokenA and tokenB, instead of just assuming both tokenA and tokenB have the same amount of decimals.

In getTradeDiff(uint,address,address,bool), sample was rounding to 0 in certain cases incorrectly, e.g. if the pool had 0.1 WBTC and 1e9 OptiDoge, sample would be 0, because 0.1 * 1e8 * 1e18/ ( 1e9 * 1e18 ) rounds to 0, so we just directly calculate the derivative instead for volatile pairs in getTradeDiff.

Added a getTradeDiffs function just for convenience to be able to bundle many getTradeDiff calls at once (used by v2 UI).

@ethzoomer
Copy link
Author

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

Successfully merging this pull request may close these issues.

1 participant