-
Notifications
You must be signed in to change notification settings - Fork 139
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
FxPool rounding errors fixes #393
Merged
brunoguerios
merged 57 commits into
balancer:develop
from
xave-finance:fxpool-rounding-fixes
Jul 4, 2023
Merged
Changes from all commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
bf44477
WIP fxPool rounding error
andreiashu 37b6ef3
fixed regression in xaveFxPool.spec.ts
andreiashu e9f50e1
🍜 minor amends; removed obsolete bnum conversions; rearranged checks …
andreiashu c1f880b
🎐 wip
andreiashu 1ab80f6
wip; broken branch for now
andreiashu a44635b
⛽ fixed 10 wei precision issue; still wip;
andreiashu f0b3516
breaking polygon test
0xAplki 519d418
🍅 fix the subgraph values. Tests passing on Polygon
andreiashu 29f16c1
added new values for subgraph return
0xAplki 7b753bd
🏈 code formatting
andreiashu fdeb41b
🍿 minor changes: code reuse
andreiashu 7a79166
🦄 added documentation
andreiashu c1f4c35
Removed obsolete documentation
andreiashu 91a3076
⛑ switched back to `ALCHEMY_URL`; fixed one test in `xaveFxPool.spec.ts`
andreiashu b9d6c90
🎣 fixed several test cases; still wip
andreiashu 6e35042
🎣 added tests for expectedSwapOutput values
andreiashu 4e736d8
🎤 minor changes
andreiashu ba76227
⚓ added _inHigherPrecision function to workaround the SOR limitation …
andreiashu 559e0bd
⛄ pull from upstream/develop
andreiashu 820bf11
🏈 lint fixes
andreiashu adc7836
🍁 added xaveFxPool.math.spec.ts
andreiashu c33c58c
🌳 removed debug module
andreiashu e464e24
🌳 removed debug module
andreiashu 19ad8be
🚗 removed FXPoolMath tests from integration
andreiashu 49094af
🐙 removed code change from `src/pools/index.ts` (oops)
andreiashu 09253c6
🍳 enabled FX pool type
andreiashu a965343
🍵 xavePool run tests against polygon fork; better organize test files;
andreiashu c578d17
🐟 fixed bug where OldBigNumber.config.DECIMAL_PLACES was left as 36 i…
andreiashu 4d98aa8
💻 removed comment about innacuracy test since it is irrelevant now
andreiashu 2576c4d
test cases + bug
0xAplki c2590b0
🦩 new fxpool test cases
0xAplki af3eb5c
🍎 removed rounding of values in xaveFxPool.spec.ts; the values for `e…
andreiashu 61a9774
🐨 fixed bug whereby the way we calculated our derivative would have p…
andreiashu f62a047
🐨 lint fixes
andreiashu 9c82d4b
⛰ removed obsolete comments
andreiashu 60071d9
💾 do not use floats in calculations; found a place where we were roun…
andreiashu 090466f
⛏ viewRawAmount and viewNumeraireAmount using BigInt internally
andreiashu 5e537cc
🐼 calculateMicroFee is using BigNumber now
andreiashu 2f8f87b
😮 oops I deleted some of the test cases by mistake. fixed now
andreiashu 94b2616
🐬 calculateTrade uses BigNumber internally
andreiashu 71ab58b
👽 alpha, beta, delta, epsilon, viewRawAmount, viewNumeraire using Big…
andreiashu ac20365
tokenOutLatestFXPrice and tokenInLatestFXPrice are BigNumber now
andreiashu a3d7557
⚽ amount -> amount_36 [wip]
andreiashu 2673734
🎻 viewRawAmount amount -> amount_36
andreiashu 83cc506
ParsedFxPoolData uses BigNumber
andreiashu b90f725
🖖 spotPriceBeforeSwap uses BigNumber amount
andreiashu 4635ed9
🚣 params to param_64
andreiashu e5b7a8d
_derivativeSpotPriceAfterSwapTokenInForExactTokenOut and _derivativeS…
andreiashu 3471d7d
🐺 viewRawAmount and spotPriceBeforeSwap return BigNumber
andreiashu edc0b95
🍳bnum(10).pow(36) -> OLD_ONE_36
andreiashu 2350377
⛰ default to 8 for `fxOracleDecimals`
andreiashu 1e0d545
🍜 removed redundant operations; thanks @brunoguerios
andreiashu 2cf04c2
🏺 parseFixedCurveParam test
andreiashu 1bbc298
🙅🏻♂️ removed the conditional that was previously used on other funct…
0xAplki 3d347f5
🍳 removed the rounding down from spot price related functions;
andreiashu 7191c7b
⛲ formatting
andreiashu 6a15ae4
🍎 reverted the changes in `_derivativeSpotPriceAfterSwapExactTokenInF…
andreiashu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Now that you're using fixed point math with 36 decimals on fxPoolMath, you should be able to remove this
inHigherPrecision
wrapper, right?I'm just thinking of ways to reduce complexity whenever possible.
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.
It seems this one might have to wait until we have SOR converted to fixed-point math as well.
For example, in
_derivativeSpotPriceAfterSwapTokenInForExactTokenOut
, because we still have to useOldBigNumber
in_spotPriceAfterSwapTokenInForExactTokenOut
, that means that for bothspotPriceBeforeSwap
and_spotPriceAfterSwapTokenInForExactTokenOut
we're doing.div(OLD_ONE_36).decimalPlaces(....)
. I believe this will be easier to fix once we have fixed-point math across SOR. Thoughts?