-
Notifications
You must be signed in to change notification settings - Fork 11
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
test: add BancorExchangeProvider pricing tests #532
test: add BancorExchangeProvider pricing tests #532
Conversation
This reverts commit d45a22e.
(result, precision) = power(_reserveBalance, baseD, _reserveWeight, MAX_WEIGHT); | ||
uint256 temp1 = _supply * result; | ||
uint256 temp2 = _supply << precision; | ||
return (temp1 - temp2 - 1) / result + 1; |
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'm not entrenched in context enough to assess the potential implications for this implementation.
But at the minimum, the setting of baseD
, temp1
& temp2
as variables in this function can be removed to improve gas efficiency.
(result, precision) = power(_reserveBalance, (_reserveBalance - _amount), _reserveWeight, MAX_WEIGHT);
return ((_supply * result) - (_supply << precision) - 1) / result + 1;
```
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.
Great job ✅
Co-authored-by: baroooo <baranseltekin@gmail.com>
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.
Looks good! Only nitpik on the temp variables for gas but likely very low impact
7704a9b chore: reserve storage gap in new contracts 040b7fe GoodDollar Fork Tests (#530) 2ee14b4 Feat(454): Exchange provider tests (#529) 578747c test: add BancorExchangeProvider pricing tests (#532) fcd3d02 feat: improve tests around the expansion controller (#533) d3a31fa Streamline comments and errors (#528) ec64f0a fix: ☦ pray to the lords of echidna 13d3a98 fix: add back forge install to the CI step c236009 fix: echidna tests c50a198 feat: add Broker liquidity check (#523) 914ba7d Address Slither Issues in GoodDollar/Bancor Contracts (#526) 8bcf3fd Feat/change gdollar modifiers (#524) 379a511 feat: make validate() internal bcbd9aa chore: added "yarn todo" task to log out open todos in the code 0631c60 refactor: renamed SafeERC20 to SafeERC20MintableBurnable 2800297 feat: simplified SafeERC20 e858391 feat: extend open zeppelin's IERC20 instead of duplicating it 196f6be chore: fixed linter and compiler warnings 096efe2 test: fix fork integration test e5308d9 feat: add GoodDollar contracts + tests 3135626 feat: update Broker + TradingLimits to 0.8 and make G$ changes
Description
This Pr adds tests for the pricing logic of the bancor exchange provider.
During the testing, we realized that the BancorFormula.sol contract is missing one function we need.
This function is getAmountIn for the tokenIn being the BancorToken. The new function is called
saleCost()
The math formula for this function is derived from the
saleTargetAmount()
function already implemented. It's important that the base of power operation is larger one otherwise the power function in that contract reverts.These are the current formulas used for the different pricing functions:
This is how we derived the formula for
saleCost()
Related issues
How to review