Skip to content

Commit f3952db

Browse files
ilanDoronAnyhowclickmanhlx3006ayobuenavista
authored
Development to master (#618)
* Development to master (#581) (#606) * Development to master (#581) * Shifted arbitrage check to FeeBurner * Shifted relevant tests from expectedRate to feeBurner * Modified failing test, as it requires less gas to fail * Removed redundan >0 rate check, test for feeBurner * Added test for src==dest token * Istanbul fix, zero rate handling * Arbitrage check shifted to FeeBurner (#433) * Shifted arbitrage check to FeeBurner * Shifted relevant tests from expectedRate to feeBurner * Modified failing test, as it requires less gas to fail * Removed redundan >0 rate check, test for feeBurner * Added test for src==dest token * Revert "Merge branch 'clicky/zero_rate' into development" This reverts commit 795d2f1d28131534604586b7786cba4e79f21e04, reversing changes made to 80af391c738395ac57017f4e18eab904869cf6f7. * Clicky/buidl integration (#459) * Pulling stuff from KN/clicky/buidl-integration branch * Pull changes from expected rate and fee burner * Update kyberNetwork test file * Update kyberNetwork.js * Merge Mike's PR on enhanced step functions (#458) * [WIP] Add new conversion rate contract with step function enhancement (#416) * [WIP] Add new conversion rate contract with step function enhancement * Add more tests to kyberReserve for testing new conversion rate contract * Add more tests for kybetNetwork with new conversion rate contract * Add verify qty and imbalance step function amounts must be increasing * Add case set qty and balance step func with only one or zero element * Check for qty step function all amounts are non negative * Update conversion rate contract and kyber network tests * Fallback to old logics when qty is 0 * Update new conversion rate with inherite from old one, update logics for some edge cases and tests * Fixed typo * Add check for empty step function before executing step function * Fix issue when qty is negative and greater than all step qty * Fix issue with executing step func with 0 as qty (#417) * Remove unnecessary tests in conversionRate2, add more cases to test for new execute step function * Fix issue with execute step func for 0 qty * expose getImbalance function in conversionRate2.sol file (#419) * Update conversion rate contract 2 with new logics for executing step function * Resolve some comments, change name new conversion rates contract to EnhancedStepFunctions * Remove qty step function, compress data for imbalance steps * Resolve solhint max line length * Avoid modifying function params in execute step func * Update comments for each test case of getting correct bps for step func * Update with some comments, add more tests * Add await keyword * Update some comments, fix some old tests in kyber reserve * Fix wrong calculate imbalance of token in reserve test * Change default max imbalance to return when overflow, fix some tests with missing await keyword * Blocking setting qty step function in new conversion rate * Update execute step func with blocking rate, remove updatedRateBlock in getImbalance * Remove redundant stepX value in last step * Add check data when encoding step func, using MAX_VAL as default for last step X * Add checking for max value of step X and tests * Add check for max bps adjustment, check max_imbalance value test * Fixed Failing Tests (#462) * Istanbul fix * Fixed failing tests as per Ilan's feedback * Fixed failing tests * Minor fixes * Minor fixes * Sync enhanced step functions test file * Reduce getDecimals call in findBestRateTokenToToken in network contract (#467) * Reduce getDecimals call in findBestRateTokenToToken in network contract * Fix new line end file * Remove some tests in utils3 * Avoid decimals call when calling handleFees on FeeBurner (#468) * Ilan/merge master (#460) * reserve deployment scripts (#233) * reserve deployment scripts * read valid block duration from config file. (#423) * Weth Reserve Implementation (#304) * Weth Reserve Implementation Includes testing. Also includes an addition in helper to make throw catching more neat. * Add weth reserve test * Add deploy script for oasis reserve * Organize folder structure and update WrapConversionRate.sol #441 && #452 (#453) * Organize folder structure according to issue #441 this includes organizing audit folder and organizing reserves. Remove multisig support from WrapConversionRate.sol according to issue #452 * enable admin to call transfer admin of base contract * enable wrapConversionRate to control all adminOnly functions in conversionRate (#461) * Ilan/modify wrap conversion rate (#466) * enable wrapConversionRate to control all adminOnly functions in conversionRate * enable wrap conversion rate to control all admin functions in conversion rate contract * set admin as msg.sender. to follow base contract logic * remove redundant test. adopt to chainge in admin logic * add CR LF * rename folders. (#469) * rename folders. (remove contract from folder name.) * reset package - lock * move new mock contracts to mock folder. * create web3 object * Upgraded to ganache-cli@istanbul * Removed header * Istanbul fix (#457) * Return zero rate for same src and dest token (#475) * Return zero rate for same src & dest token * Removed unnecessary tests * Echo fork choice, fix broken logic * Try committing new package-lock.json * Added more info * Bumped to node v12.13.0 * Update package fix npm (#474) * Update package fix npm * Update package-lock file * Remove unused packages * Removed eslint * Add colour for better readability of fork choice * Add spacing between example commands * Resolve package-lock conflict * Revert "Bumped to node v12.13.0" This reverts commit 85cb734ed5bfae4fdc5fc0dc8c8dfcc8c3c426ed. * Fixed conflicting files * Revert "Merge branch 'clicky/ganacheIstanbul' into development" This reverts commit 654a1c3e7971319bd802df0cd70daf32337caa95, reversing changes made to 6c0a21c59eb55b44cfe8616a513e7e76533fc9c5. * Upgrade to ganache-cli@istanbul for testing with Istanbul fork (#482) * Added colour and newline to fork choice * Add node and npm version used * Removed eslint * Removed eslint * Got latest changes from Mike's PR * added colour and newline to fork choice * Fix coloring (I hope) * Changed BG to make text stand out * handle zero qty in get rate permission less reserve (#472) * handle zero qty in get rate permission less reserve * undo wrong change * Increase gas limit for 1 test due to Istanbul (#487) * [455] Enable unlist orderbook permissionless reserve (#485) * Add comments in FeeBurner for KNC decimals (#489) * Revert "Arbitrage check shifted to FeeBurner" (#488) * Revert "Arbitrage check shifted to FeeBurner (#433)" This reverts commit 80af391c738395ac57017f4e18eab904869cf6f7. * reverse un needed test changes for kyber NEtwork * Zero Src Qty Handling (#483) * Initial commit for zero rate handling. Need to rewrite tests * Improved comment to code * Modified getConversionRate function to require srcAmt > 0 * Removed tests, added one * Updated contracts as per feedback * Updated comment in test file * Added fix to expectedRateSmallQty * Remove extra = * Add additional section to check network.getExpectedRate doesn't revert as well * Removed redundant tests due to zero rate handling in network contract (#494) * update solidity coverage version (#491) * Added new deployment script and input files (#495) * Ilan/add rates getter (#493) * update solidity coverage version * add getter function for rates * update getter API and return values, add tests * Clicky/rename compile file (#496) * renamed compileOutput.js to compileContracts.js, added more contracts for reserveDeployer * Renamed compileOutput -> compileContracts * Minor spelling edit * update addresses for deployment (#497) * remove multi sig support. add admin functionality (#498) * remove multi sig support. add admin functionality * refactor wrapper contracts, update tests * update tests according to PR comments, add one missing check * Add some comments * Revert "[455] Enable unlist orderbook permissionless reserve (#485)" (#504) This reverts commit 8b63c0ea023b7965a7c00e452279cf52e03f32f2. * Fix deployment script after staging deployment (#505) * Added new deployment script and input files * Remove old file * Added contract instantiation if deployer script breaks halfway through * avoid query to uniswap with zero rate (#510) * avoid query to uniswap with zero rate * test situation where trade result is 0 * enable setting min record resultion in conversion rates using wrapper (#513) * enable setting min record resultion in conversion rates using wrapper * linting, and add missing test * fix uniswap bridge for small amounts src qty (1) (#518) * fix uniswap bridge for smal amounts src qty (1) * avoid reading fee twice * fix uniswap deployer script * Ilan/deployment helper (#516) * some deployment changes, and helper contract" " * add kyber uniswap bridge to compilation. remove wrap conversion rate * small fixes in deployer * Add CR LF * Ilan/merge master (#519) * update some packages. fix solc version to 0.4.18 (#503) * fixed FPR deployment script (#508) * add smartdec audit for APR * use correct package-lock * Ilan/master to development (#525) * Development to Master. Istanbul changes. buidl. (#471) * Shifted arbitrage check to FeeBurner * Shifted relevant tests from expectedRate to feeBurner * Modified failing test, as it requires less gas to fail * Removed redundan >0 rate check, test for feeBurner * Added test for src==dest token * Istanbul fix, zero rate handling * Arbitrage check shifted to FeeBurner (#433) * Shifted arbitrage check to FeeBurner * Shifted relevant tests from expectedRate to feeBurner * Modified failing test, as it requires less gas to fail * Removed redundan >0 rate check, test for feeBurner * Added test for src==dest token * Revert "Merge branch 'clicky/zero_rate' into development" This reverts commit 795d2f1d28131534604586b7786cba4e79f21e04, reversing changes made to 80af391c738395ac57017f4e18eab904869cf6f7. * Clicky/buidl integration (#459) * Pulling stuff from KN/clicky/buidl-integration branch * Pull changes from expected rate and fee burner * Update kyberNetwork test file * Update kyberNetwork.js * Merge Mike's PR on enhanced step functions (#458) * [WIP] Add new conversion rate contract with step function enhancement (#416) * [WIP] Add new conversion rate contract with step function enhancement * Add more tests to kyberReserve for testing new conversion rate contract * Add more tests for kybetNetwork with new conversion rate contract * Add verify qty and imbalance step function amounts must be increasing * Add case set qty and balance step func with only one or zero element * Check for qty step function all amounts are non negative * Update conversion rate contract and kyber network tests * Fallback to old logics when qty is 0 * Update new conversion rate with inherite from old one, update logics for some edge cases and tests * Fixed typo * Add check for empty step function before executing step function * Fix issue when qty is negative and greater than all step qty * Fix issue with executing step func with 0 as qty (#417) * Remove unnecessary tests in conversionRate2, add more cases to test for new execute step function * Fix issue with execute step func for 0 qty * expose getImbalance function in conversionRate2.sol file (#419) * Update conversion rate contract 2 with new logics for executing step function * Resolve some comments, change name new conversion rates contract to EnhancedStepFunctions * Remove qty step function, compress data for imbalance steps * Resolve solhint max line length * Avoid modifying function params in execute step func * Update comments for each test case of getting correct bps for step func * Update with some comments, add more tests * Add await keyword * Update some comments, fix some old tests in kyber reserve * Fix wrong calculate imbalance of token in reserve test * Change default max imbalance to return when overflow, fix some tests with missing await keyword * Blocking setting qty step function in new conversion rate * Update execute step func with blocking rate, remove updatedRateBlock in getImbalance * Remove redundant stepX value in last step * Add check data when encoding step func, using MAX_VAL as default for last step X * Add checking for max value of step X and tests * Add check for max bps adjustment, check max_imbalance value test * Fixed Failing Tests (#462) * Istanbul fix * Fixed failing tests as per Ilan's feedback * Fixed failing tests * Minor fixes * Minor fixes * Sync enhanced step functions test file * Reduce getDecimals call in findBestRateTokenToToken in network contract (#467) * Reduce getDecimals call in findBestRateTokenToToken in network contract * Fix new line end file * Remove some tests in utils3 * Avoid decimals call when calling handleFees on FeeBurner (#468) * Ilan/merge master (#460) * reserve deployment scripts (#233) * reserve deployment scripts * read valid block duration from config file. (#423) * Weth Reserve Implementation (#304) * Weth Reserve Implementation Includes testing. Also includes an addition in helper to make throw catching more neat. * Add weth reserve test * Add deploy script for oasis reserve * Organize folder structure and update WrapConversionRate.sol #441 && #452 (#453) * Organize folder structure according to issue #441 this includes organizing audit folder and organizing reserves. Remove multisig support from WrapConversionRate.sol according to issue #452 * enable admin to call transfer admin of base contract * enable wrapConversionRate to control all adminOnly functions in conversionRate (#461) * Ilan/modify wrap conversion rate (#466) * enable wrapConversionRate to control all adminOnly functions in conversionRate * enable wrap conversion rate to control all admin functions in conversion rate contract * set admin as msg.sender. to follow base contract logic * remove redundant test. adopt to chainge in admin logic * add CR LF * rename folders. (#469) * rename folders. (remove contract from folder name.) * reset package - lock * move new mock contracts to mock folder. * create web3 object * Upgraded to ganache-cli@istanbul * Removed header * Istanbul fix (#457) * Return zero rate for same src and dest token (#475) * Return zero rate for same src & dest token * Removed unnecessary tests * Echo fork choice, fix broken logic * Try committing new package-lock.json * Added more info * Bumped to node v12.13.0 * Update package fix npm (#474) * Update package fix npm * Update package-lock file * Remove unused packages * Removed eslint * Add colour for better readability of fork choice * Add spacing between example commands * Resolve package-lock conflict * Revert "Bumped to node v12.13.0" This reverts commit 85cb734ed5bfae4fdc5fc0dc8c8dfcc8c3c426ed. * Fixed conflicting files * Revert "Merge branch 'clicky/ganacheIstanbul' into development" This reverts commit 654a1c3e7971319bd802df0cd70daf32337caa95, reversing changes made to 6c0a21c59eb55b44cfe8616a513e7e76533fc9c5. * Upgrade to ganache-cli@istanbul for testing with Istanbul fork (#482) * Added colour and newline to fork choice * Add node and npm version used * Removed eslint * Removed eslint * Got latest changes from Mike's PR * added colour and newline to fork choice * Fix coloring (I hope) * Changed BG to make text stand out * handle zero qty in get rate permission less reserve (#472) * handle zero qty in get rate permission less reserve * undo wrong change * Increase gas limit for 1 test due to Istanbul (#487) * [455] Enable unlist orderbook permissionless reserve (#485) * Add comments in FeeBurner for KNC decimals (#489) * Revert "Arbitrage check shifted to FeeBurner" (#488) * Revert "Arbitrage check shifted to FeeBurner (#433)" This reverts commit 80af391c738395ac57017f4e18eab904869cf6f7. * reverse un needed test changes for kyber NEtwork * Zero Src Qty Handling (#483) * Initial commit for zero rate handling. Need to rewrite tests * Improved comment to code * Modified getConversionRate function to require srcAmt > 0 * Removed tests, added one * Updated contracts as per feedback * Updated comment in test file * Added fix to expectedRateSmallQty * Remove extra = * Add additional section to check network.getExpectedRate doesn't revert as well * Removed redundant tests due to zero rate handling in network contract (#494) * update solidity coverage version (#491) * Added new deployment script and input files (#495) * Ilan/add rates getter (#493) * update solidity coverage version * add getter function for rates * update getter API and return values, add tests * Clicky/rename compile file (#496) * renamed compileOutput.js to compileContracts.js, added more contracts for reserveDeployer * Renamed compileOutput -> compileContracts * Minor spelling edit * update addresses for deployment (#497) * remove multi sig support. add admin functionality (#498) * remove multi sig support. add admin functionality * refactor wrapper contracts, update tests * update tests according to PR comments, add one missing check * Add some comments * Revert "[455] Enable unlist orderbook permissionless reserve (#485)" (#504) This reverts commit 8b63c0ea023b7965a7c00e452279cf52e03f32f2. * Fix deployment script after staging deployment (#505) * Added new deployment script and input files * Remove old file * Added contract instantiation if deployer script breaks halfway through * avoid query to uniswap with zero rate (#510) * avoid query to uniswap with zero rate * test situation where trade result is 0 * enable setting min record resultion in conversion rates using wrapper (#513) * enable setting min record resultion in conversion rates using wrapper * linting, and add missing test * fix uniswap bridge for small amounts src qty (1) (#518) * fix uniswap bridge for smal amounts src qty (1) * avoid reading fee twice * fix uniswap deployer script * Ilan/deployment helper (#516) * some deployment changes, and helper contract" " * add kyber uniswap bridge to compilation. remove wrap conversion rate * small fixes in deployer * Add CR LF * Ilan/merge master (#519) * update some packages. fix solc version to 0.4.18 (#503) * fixed FPR deployment script (#508) * add smartdec audit for APR * use correct package-lock * Add Eth2Dai reserve and test (#523) * [WIP] Eth2Dai Reserve enhancement (#449) * Add eth2dai contract * Update Eth2Dai reserve * Update Eth2DaiReserve contract and tests * Update trade function tests for eth2dai reserve * Make single test can run on its own * Separate source codes, add some v5 contracts * Update contracts fixed some review comments, remove some unused functions * Update eth2dai contract with enable/disable internal inventory for token * Add test for set internal inventory enable/disable * Put enable/disable internal inventory into internal inventory data * Add internal inventory tests * Change overlow to out of range * Update v5 contracts * Update file name and folder structure * Update folder structure * Fix can not find artifacts for WethTokenV5 * Update test folder structure * Remove KyberOasisReserve source code + test, change WethTokenV5 to WethToken (#524) * remove duplicate files and v5 example * update git ignore * update development (#547) * update git ignore (#544) * Kyber Bancor bridge reserve (#546) * Shifted arbitrage check to FeeBurner * Shifted relevant tests from expectedRate to feeBurner * Modified failing test, as it requires less gas to fail * Removed redundan >0 rate check, test for feeBurner * Added test for src==dest token * Istanbul fix, zero rate handling * Arbitrage check shifted to FeeBurner (#433) * Shifted arbitrage check to FeeBurner * Shifted relevant tests from expectedRate to feeBurner * Modified failing test, as it requires less gas to fail * Removed redundan >0 rate check, test for feeBurner * Added test for src==dest token * Revert "Merge branch 'clicky/zero_rate' into development" This reverts commit 795d2f1d28131534604586b7786cba4e79f21e04, reversing changes made to 80af391c738395ac57017f4e18eab904869cf6f7. * Clicky/buidl integration (#459) * Pulling stuff from KN/clicky/buidl-integration branch * Pull changes from expected rate and fee burner * Update kyberNetwork test file * Update kyberNetwork.js * Merge Mike's PR on enhanced step functions (#458) * [WIP] Add new conversion rate contract with step function enhancement (#416) * [WIP] Add new conversion rate contract with step function enhancement * Add more tests to kyberReserve for testing new conversion rate contract * Add more tests for kybetNetwork with new conversion rate contract * Add verify qty and imbalance step function amounts must be increasing * Add case set qty and balance step func with only one or zero element * Check for qty step function all amounts are non negative * Update conversion rate contract and kyber network tests * Fallback to old logics when qty is 0 * Update new conversion rate with inherite from old one, update logics for some edge cases and tests * Fixed typo * Add check for empty step function before executing step function * Fix issue when qty is negative and greater than all step qty * Fix issue with executing step func with 0 as qty (#417) * Remove unnecessary tests in conversionRate2, add more cases to test for new execute step function * Fix issue with execute step func for 0 qty * expose getImbalance function in conversionRate2.sol file (#419) * Update conversion rate contract 2 with new logics for executing step function * Resolve some comments, change name new conversion rates contract to EnhancedStepFunctions * Remove qty step function, compress data for imbalance steps * Resolve solhint max line length * Avoid modifying function params in execute step func * Update comments for each test case of getting correct bps for step func * Update with some comments, add more tests * Add await keyword * Update some comments, fix some old tests in kyber reserve * Fix wrong calculate imbalance of token in reserve test * Change default max imbalance to return when overflow, fix some tests with missing await keyword * Blocking setting qty step function in new conversion rate * Update execute step func with blocking rate, remove updatedRateBlock in getImbalance * Remove redundant stepX value in last step * Add check data when encoding step func, using MAX_VAL as default for last step X * Add checking for max value of step X and tests * Add check for max bps adjustment, check max_imbalance value test * Fixed Failing Tests (#462) * Istanbul fix * Fixed failing tests as per Ilan's feedback * Fixed failing tests * Minor fixes * Minor fixes * Sync enhanced step functions test file * Reduce getDecimals call in findBestRateTokenToToken in network contract (#467) * Reduce getDecimals call in findBestRateTokenToToken in network contract * Fix new line end file * Remove some tests in utils3 * Avoid decimals call when calling handleFees on FeeBurner (#468) * Ilan/merge master (#460) * reserve deployment scripts (#233) * reserve deployment scripts * read valid block duration from config file. (#423) * Weth Reserve Implementation (#304) * Weth Reserve Implementation Includes testing. Also includes an addition in helper to make throw catching more neat. * Add weth reserve test * Add deploy script for oasis reserve * Organize folder structure and update WrapConversionRate.sol #441 && #452 (#453) * Organize folder structure according to issue #441 this includes organizing audit folder and organizing reserves. Remove multisig support from WrapConversionRate.sol according to issue #452 * enable admin to call transfer admin of base contract * enable wrapConversionRate to control all adminOnly functions in conversionRate (#461) * Ilan/modify wrap conversion rate (#466) * enable wrapConversionRate to control all adminOnly functions in conversionRate * enable wrap conversion rate to control all admin functions in conversion rate contract * set admin as msg.sender. to follow base contract logic * remove redundant test. adopt to chainge in admin logic * add CR LF * rename folders. (#469) * rename folders. (remove contract from folder name.) * reset package - lock * move new mock contracts to mock folder. * create web3 object * Upgraded to ganache-cli@istanbul * Removed header * Istanbul fix (#457) * Return zero rate for same src and dest token (#475) * Return zero rate for same src & dest token * Removed unnecessary tests * Echo fork choice, fix broken logic * Try committing new package-lock.json * Added more info * Bumped to node v12.13.0 * Update package fix npm (#474) * Update package fix npm * Update package-lock file * Remove unused packages * Removed eslint * Add colour for better readability of fork choice * Add spacing between example commands * Resolve package-lock conflict * Revert "Bumped to node v12.13.0" This reverts commit 85cb734ed5bfae4fdc5fc0dc8c8dfcc8c3c426ed. * Fixed conflicting files * Revert "Merge branch 'clicky/ganacheIstanbul' into development" This reverts commit 654a1c3e7971319bd802df0cd70daf32337caa95, reversing changes made to 6c0a21c59eb55b44cfe8616a513e7e76533fc9c5. * Upgrade to ganache-cli@istanbul for testing with Istanbul fork (#482) * Added colour and newline to fork choice * Add node and npm version used * Removed eslint * Removed eslint * Got latest changes from Mike's PR * added colour and newline to fork choice * Fix coloring (I hope) * Changed BG to make text stand out * handle zero qty in get rate permission less reserve (#472) * handle zero qty in get rate permission less reserve * undo wrong change * Increase gas limit for 1 test due to Istanbul (#487) * [455] Enable unlist orderbook permissionless reserve (#485) * Add comments in FeeBurner for KNC decimals (#489) * Revert "Arbitrage check shifted to FeeBurner" (#488) * Revert "Arbitrage check shifted to FeeBurner (#433)" This reverts commit 80af391c738395ac57017f4e18eab904869cf6f7. * reverse un needed test changes for kyber NEtwork * Zero Src Qty Handling (#483) * Initial commit for zero rate handling. Need to rewrite tests * Improved comment to code * Modified getConversionRate function to require srcAmt > 0 * Removed tests, added one * Updated contracts as per feedback * Updated comment in test file * Added fix to expectedRateSmallQty * Remove extra = * Add additional section to check network.getExpectedRate doesn't revert as well * Removed redundant tests due to zero rate handling in network contract (#494) * update solidity coverage version (#491) * Added new deployment script and input files (#495) * Ilan/add rates getter (#493) * update solidity coverage version * add getter function for rates * update getter API and return values, add tests * Clicky/rename compile file (#496) * renamed compileOutput.js to compileContracts.js, added more contracts for reserveDeployer * Renamed compileOutput -> compileContracts * Minor spelling edit * update addresses for deployment (#497) * remove multi sig support. add admin functionality (#498) * remove multi sig support. add admin functionality * refactor wrapper contracts, update tests * update tests according to PR comments, add one missing check * Add some comments * Revert "[455] Enable unlist orderbook permissionless reserve (#485)" (#504) This reverts commit 8b63c0ea023b7965a7c00e452279cf52e03f32f2. * Fix deployment script after staging deployment (#505) * Added new deployment script and input files * Remove old file * Added contract instantiation if deployer script breaks halfway through * avoid query to uniswap with zero rate (#510) * avoid query to uniswap with zero rate * test situation where trade result is 0 * enable setting min record resultion in conversion rates using wrapper (#513) * enable setting min record resultion in conversion rates using wrapper * linting, and add missing test * fix uniswap bridge for small amounts src qty (1) (#518) * fix uniswap bridge for smal amounts src qty (1) * avoid reading fee twice * fix uniswap deployer script * Ilan/deployment helper (#516) * some deployment changes, and helper contract" " * add kyber uniswap bridge to compilation. remove wrap conversion rate * small fixes in deployer * Add CR LF * Ilan/merge master (#519) * update some packages. fix solc version to 0.4.18 (#503) * fixed FPR deployment script (#508) * add smartdec audit for APR * use correct package-lock * Ilan/master to development (#525) * Development to Master. Istanbul changes. buidl. (#471) * Shifted arbitrage check to FeeBurner * Shifted relevant tests from expectedRate to feeBurner * Modified failing test, as it requires less gas to fail * Removed redundan >0 rate check, test for feeBurner * Added test for src==dest token * Istanbul fix, zero rate handling * Arbitrage check shifted to FeeBurner (#433) * Shifted arbitrage check to FeeBurner * Shifted relevant tests from expectedRate to feeBurner * Modified failing test, as it requires less gas to fail * Removed redundan >0 rate check, test for feeBurner * Added test for src==dest token * Revert "Merge branch 'clicky/zero_rate' into development" This reverts commit 795d2f1d28131534604586b7786cba4e79f21e04, reversing changes made to 80af391c738395ac57017f4e18eab904869cf6f7. * Clicky/buidl integration (#459) * Pulling stuff from KN/clicky/buidl-integration branch * Pull changes from expected rate and fee burner * Update kyberNetwork test file * Update kyberNetwork.js * Merge Mike's PR on enhanced step functions (#458) * [WIP] Add new conversion rate contract with step function enhancement (#416) * [WIP] Add new conversion rate contract with step function enhancement * Add more tests to kyberReserve for testing new conversion rate contract * Add more tests for kybetNetwork with new conversion rate contract * Add verify qty and imbalance step function amounts must be increasing * Add case set qty and balance step func with only one or zero element * Check for qty step function all amounts are non negative * Update conversion rate contract and kyber network tests * Fallback to old logics when qty is 0 * Update new conversion rate with inherite from old one, update logics for some edge cases and tests * Fixed typo * Add check for empty step function before executing step function * Fix issue when qty is negative and greater than all step qty * Fix issue with executing step func with 0 as qty (#417) * Remove unnecessary tests in conversionRate2, add more cases to test for new execute step function * Fix issue with execute step func for 0 qty * expose getImbalance function in conversionRate2.sol file (#419) * Update conversion rate contract 2 with new logics for executing step function * Resolve some comments, change name new conversion rates contract to EnhancedStepFunctions * Remove qty step function, compress data for imbalance steps * Resolve solhint max line length * Avoid modifying function params in execute step func * Update comments for each test case of getting correct bps for step func * Update with some comments, add more tests * Add await keyword * Update some comments, fix some old tests in kyber reserve * Fix wrong calculate imbalance of token in reserve test * Change default max imbalance to return when overflow, fix some tests with missing await keyword * Blocking setting qty step function in new conversion rate * Update execute step func with blocking rate, remove updatedRateBlock in getImbalance * Remove redundant stepX value in last step * Add check data when encoding step func, using MAX_VAL as default for last step X * Add checking for max value of step X and tests * Add check for max bps adjustment, check max_imbalance value test * Fixed Failing Tests (#462) * Istanbul fix * Fixed failing tests as per Ilan's feedback * Fixed failing tests * Minor fixes * Minor fixes * Sync enhanced step functions test file * Reduce getDecimals call in findBestRateTokenToToken in network contract (#467) * Reduce getDecimals call in findBestRateTokenToToken in network contract * Fix new line end file * Remove some tests in utils3 * Avoid decimals call when calling handleFees on FeeBurner (#468) * Ilan/merge master (#460) * reserve deployment scripts (#233) * reserve deployment scripts * read valid block duration from config file. (#423) * Weth Reserve Implementation (#304) * Weth Reserve Implementation Includes testing. Also includes an addition in helper to make throw catching more neat. * Add weth reserve test * Add deploy script for oasis reserve * Organize folder structure and update WrapConversionRate.sol #441 && #452 (#453) * Organize folder structure according to issue #441 this includes organizing audit folder and organizing reserves. Remove multisig support from WrapConversionRate.sol according to issue #452 * enable admin to call transfer admin of base contract * enable wrapConversionRate to control all adminOnly functions in conversionRate (#461) * Ilan/modify wrap conversion rate (#466) * enable wrapConversionRate to control all adminOnly functions in conversionRate * enable wrap conversion rate to control all admin functions in conversion rate contract * set admin as msg.sender. to follow base contract logic * remove redundant test. adopt to chainge in admin logic * add CR LF * rename folders. (#469) * rename folders. (remove contract from folder name.) * reset package - lock * move new mock contracts to mock folder. * create web3 object * Upgraded to ganache-cli@istanbul * Removed header * Istanbul fix (#457) * Return zero rate for same src and dest token (#475) * Return zero rate for same src & dest token * Removed unnecessary tests * Echo fork choice, fix broken logic * Try committing new package-lock.json * Added more info * Bumped to node v12.13.0 * Update package fix npm (#474) * Update package fix npm * Update package-lock file * Remove unused packages * Removed eslint * Add colour for better readability of fork choice * Add spacing between example commands * Resolve package-lock conflict * Revert "Bumped to node v12.13.0" This reverts commit 85cb734ed5bfae4fdc5fc0dc8c8dfcc8c3c426ed. * Fixed conflicting files * Revert "Merge branch 'clicky/ganacheIstanbul' into development" This reverts commit 654a1c3e7971319bd802df0cd70daf32337caa95, reversing changes made to 6c0a21c59eb55b44cfe8616a513e7e76533fc9c5. * Upgrade to ganache-cli@istanbul for testing with Istanbul fork (#482) * Added colour and newline to fork choice * Add node and npm version used * Removed eslint * Removed eslint * Got latest changes from Mike's PR * added colour and newline to fork choice * Fix coloring (I hope) * Changed BG to make text stand out * handle zero qty in get rate permission less reserve (#472) * handle zero qty in get rate permission less reserve * undo wrong change * Increase gas limit for 1 test due to Istanbul (#487) * [455] Enable unlist orderbook permissionless reserve (#485) * Add comments in FeeBurner for KNC decimals (#489) * Revert "Arbitrage check shifted to FeeBurner" (#488) * Revert "Arbitrage check shifted to FeeBurner (#433)" This reverts commit 80af391c738395ac57017f4e18eab904869cf6f7. * reverse un needed test changes for kyber NEtwork * Zero Src Qty Handling (#483) * Initial commit for zero rate handling. Need to rewrite tests * Improved comment to code * Modified getConversionRate function to require srcAmt > 0 * Removed tests, added one * Updated contracts as per feedback * Updated comment in test file * Added fix to expectedRateSmallQty * Remove extra = * Add additional section to check network.getExpectedRate doesn't revert as well * Removed redundant tests due to zero rate handling in network contract (#494) * update solidity coverage version (#491) * Added new deployment script and input files (#495) * Ilan/add rates getter (#493) * update solidity coverage version * add getter function for rates * update getter API and return values, add tests * Clicky/rename compile file (#496) * renamed compileOutput.js to compileContracts.js, added more contracts for reserveDeployer * Renamed compileOutput -> compileContracts * Minor spelling edit * update addresses for deployment (#497) * remove multi sig support. add admin functionality (#498) * remove multi sig support. add admin functionality * refactor wrapper contracts, update tests * update tests according to PR comments, add one missing check * Add some comments * Revert "[455] Enable unlist orderbook permissionless reserve (#485)" (#504) This reverts commit 8b63c0ea023b7965a7c00e452279cf52e03f32f2. * Fix deployment script after staging deployment (#505) * Added new deployment script and input files * Remove old file * Added contract instantiation if deployer script breaks halfway through * avoid query to uniswap with zero rate (#510) * avoid query to uniswap with zero rate * test situation where trade result is 0 * enable setting min record resultion in conversion rates using wrapper (#513) * enable setting min record resultion in conversion rates using wrapper * linting, and add missing test * fix uniswap bridge for small amounts src qty (1) (#518) * fix uniswap bridge for smal amounts src qty (1) * avoid reading fee twice * fix uniswap deployer script * Ilan/deployment helper (#516) * some deployment changes, and helper contract" " * add kyber uniswap bridge to compilation. remove wrap conversion rate * small fixes in deployer * Add CR LF * Ilan/merge master (#519) * update some packages. fix solc version to 0.4.18 (#503) * fixed FPR deployment script (#508) * add smartdec audit for APR * use correct package-lock * Add Eth2Dai reserve and test (#523) * [WIP] Eth2Dai Reserve enhancement (#449) * Add eth2dai contract * Update Eth2Dai reserve * Update Eth2DaiReserve contract and tests * Update trade function tests for eth2dai reserve * Make single test can run on its own * Separate source codes, add some v5 contracts * Update contracts fixed some review comments, remove some unused functions * Update eth2dai contract with enable/disable internal inventory for token * Add test for set internal inventory enable/disable * Put enable/disable internal inventory into internal inventory data * Add internal inventory tests * Change overlow to out of range * Update v5 contracts * Update file name and folder structure * Update folder structure * Fix can not find artifacts for WethTokenV5 * Update test folder structure * Remove KyberOasisReserve source code + test, change WethTokenV5 to WethToken (#524) * remove duplicate files and v5 example * Add KyberBancorReserve and test * Fix some tests for kyber bancor reserve * Add more tests for kyber bancor reserve * Remove default value for bnt and bancor eth token * Add end of file line * Update contracts from review comments * Fix contract and test based on comments * Return 0 for rate and revert in trade when srcQty is 0 * Remove v5 example test file' Co-authored-by: Desmond <[email protected]> Co-authored-by: Ilan Doron <[email protected]> Co-authored-by: Le Xuan Manh <[email protected]> Co-authored-by: Desmond <[email protected]> * Upgrade web3 version to 1.2.4 (#514) * [WIP] Upgrade web3 version to 1.2.4 * Update conversion rate and enhance step func rate tests * Remove openzeplin test helper * Development to Master. Istanbul changes. buidl. (#471) * Shifted arbitrage check to FeeBurner * Shifted relevant tests from expectedRate to feeBurner * Modified failing test, as it requires less gas to fail * Removed redundan >0 rate check, test for feeBurner * Added test for src==dest token * Istanbul fix, zero rate handling * Arbitrage check shifted to FeeBurner (#433) * Shifted arbitrage check to FeeBurner * Shifted relevant tests from expectedRate to feeBurner * Modified failing test, as it requires less gas to fail * Removed redundan >0 rate check, test for feeBurner * Added test for src==dest token * Revert "Merge branch 'clicky/zero_rate' into development" This reverts commit 795d2f1d28131534604586b7786cba4e79f21e04, reversing changes made to 80af391c738395ac57017f4e18eab904869cf6f7. * Clicky/buidl integration (#459) * Pulling stuff from KN/clicky/buidl-integration branch * Pull changes from expected rate and fee burner * Update kyberNetwork test file * Update kyberNetwork.js * Merge Mike's PR on enhanced step functions (#458) * [WIP] Add new conversion rate contract with step function enhancement (#416) * [WIP] Add new conversion rate contract with step function enhancement * Add more tests to kyberReserve for testing new conversion rate contract * Add more tests for kybetNetwork with new conversion rate contract * Add verify qty and imbalance step function amounts must be increasing * Add case set qty and balance step func with only one or zero element * Check for qty step function all amounts are non negative * Update conversion rate contract and kyber network tests * Fallback to old logics when qty is 0 * Update new conversion rate with inherite from old one, update logics for some edge cases and tests * Fixed typo * Add check for empty step function before executing step function * Fix issue when qty is negative and greater than all step qty * Fix issue with executing step func with 0 as qty (#417) * Remove unnecessary tests in conversionRate2, add more cases to test for new execute step function * Fix issue with execute step func for 0 qty * expose getImbalance function in conversionRate2.sol file (#419) * Update conversion rate contract 2 with new logics for executing step function * Resolve some comments, change name new conversion rates contract to EnhancedStepFunctions * Remove qty step function, compress data for imbalance steps * Resolve solhint max line length * Avoid modifying function params in execute step func * Update comments for each test case of getting correct bps for step func * Update with some comments, add more tests * Add await keyword * Update some comments, fix some old tests in kyber reserve * Fix wrong calculate imbalance of token in reserve test * Change default max imbalance to return when overflow, fix some tests with missing await keyword * Blocking setting qty step function in new conversion rate * Update execute step func with blocking rate, remove updatedRateBlock in getImbalance * Remove redundant stepX value in last step * Add check data when encoding step func, using MAX_VAL as default for last step X * Add checking for max value of step X and tests * Add check for max bps adjustment, check max_imbalance value test * Fixed Failing Tests (#462) * Istanbul fix * Fixed failing tests as per Ilan's feedback * Fixed failing tests * Minor fixes * Minor fixes * Sync enhanced step functions test file * Reduce getDecimals call in findBestRateTokenToToken in network contract (#467) * Reduce getDecimals call in findBestRateTokenToToken in network contract * Fix new line end file * Remove some tests in utils3 * Avoid decimals call when calling handleFees on FeeBurner (#468) * Ilan/merge master (#460) * reserve deployment scripts (#233) * reserve deployment scripts * read valid block duration from config file. (#423) * Weth Reserve Implementation (#304) * Weth Reserve Implementation Includes testing. Also includes an addition in helper to make throw catching more neat. * Add weth reserve test * Add deploy script for oasis reserve * Organize folder structure and update WrapConversionRate.sol #441 && #452 (#453) * Organize folder structure according to issue #441 this includes organizing audit folder and organizing reserves. Remove multisig support from WrapConversionRate.sol according to issue #452 * enable admin to call transfer admin of base contract * enable wrapConversionRate to control all adminOnly functions in conversionRate (#461) * Ilan/modify wrap conversion rate (#466) * enable wrapConversionRate to control all adminOnly functions in conversionRate * enable wrap conversion rate to control all admin functions in conversion rate contract * set admin as msg.sender. to follow base contract logic * remove redundant test. adopt to chainge in admin logic * add CR LF * rename folders. (#469) * rename folders. (remove contract from folder name.) * reset package - lock * move new mock contracts to mock folder. * create web3 object * Upgraded to ganache-cli@istanbul * Removed header * Istanbul fix (#457) * Return zero rate for same src and dest token (#475) * Return zero rate for same src & dest token * Removed unnecessary tests * Echo fork choice, fix broken logic * Try committing new package-lock.json * Added more info * Bumped to node v12.13.0 * Update package fix npm (#474) * Update package fix npm * Update package-lock file * Remove unused packages * Removed eslint * Add colour for better readability of fork choice * Add spacing between example commands * Resolve package-lock conflict * Revert "Bumped to node v12.13.0" This reverts commit 85cb734ed5bfae4fdc5fc0dc8c8dfcc8c3c426ed. * Fixed conflicting files * Revert "Merge branch 'clicky/ganacheIstanbul' into development" This reverts commit 654a1c3e7971319bd802df0cd70daf32337caa95, reversing changes made to 6c0a21c59eb55b44cfe8616a513e7e76533fc9c5. * Upgrade to ganache-cli@istanbul for testing with Istanbul fork (#482) * Added colour and newline to fork choice * Add node and npm version used * Removed eslint * Removed eslint * Got latest changes from Mike's PR * added colour and newline to fork choice * Fix coloring (I hope) * Changed BG to make text stand out * handle zero qty in get rate permission less reserve (#472) * handle zero qty in get rate permission less reserve * undo wrong change * Increase gas limit for 1 test due to Istanbul (#487) * [455] Enable unlist orderbook permissionless reserve (#485) * Add comments in FeeBurner for KNC decimals (#489) * Revert "Arbitrage check shifted to FeeBurner" (#488) * Revert "Arbitrage check shifted to FeeBurner (#433)" This reverts commit 80af391c738395ac57017f4e18eab904869cf6f7. * reverse un needed test changes for kyber NEtwork * Zero Src Qty Handling (#483) * Initial commit for zero rate handling. Need to rewrite tests * Improved comment to code * Modified getConversionRate function to require srcAmt > 0 * Removed tests, added one * Updated contracts as per feedback * Updated comment in test file * Added fix to expectedRateSmallQty * Remove extra = * Add additional section to check network.getExpectedRate doesn't revert as well * Removed redundant tests due to zero rate handling in network contract (#494) * update solidity coverage version (#491) * Added new deployment script and input files (#495) * Ilan/add rates getter (#493) * update solidity coverage version * add getter function for rates * update getter API and return values, add tests * Clicky/rename compile file (#496) * renamed compileOutput.js to compileContracts.js, added more contracts for reserveDeployer * Renamed compileOutput -> compileContracts * Minor spelling edit * update addresses for deployment (#497) * remove multi sig support. add admin functionality (#498) * remove multi sig support. add admin functionality * refactor wrapper contracts, update tests * update tests according to PR comments, add one missing check * Add some comments * Revert "[455] Enable unlist orderbook permissionless reserve (#485)" (#504) This reverts commit 8b63c0ea023b7965a7c00e452279cf52e03f32f2. * Fix deployment script after staging deployment (#505) * Added new deployment script and input files * Remove old file * Added contract instantiation if deployer script breaks halfway through * avoid query to uniswap with zero rate (#510) * avoid query to uniswap with zero rate * test situation where trade result is 0 * enable setting min record resultion in conversion rates using wrapper (#513) * enable setting min record resultion in conversion rates using wrapper * linting, and add missing test * fix uniswap bridge for small amounts src qty (1) (#518) * fix uniswap bridge for smal amounts src qty (1) * avoid reading fee twice * fix uniswap deployer script * Ilan/deployment helper (#516) * some deployment changes, and helper contract" " * add kyber uniswap bridge to compilation. remove wrap conversion rate * small fixes in deployer * Add CR LF * Ilan/merge master (#519) * update some packages. fix solc version to 0.4.18 (#503) * fixed FPR deployment script (#508) * add smartdec audit for APR * use correct package-lock * Add Eth2Dai reserve and test (#523) * [WIP] Eth2Dai Reserve enhancement (#449) * Add eth2dai contract * Update Eth2Dai reserve * Update Eth2DaiReserve contract and tests * Update trade function tests for eth2dai reserve * Make single test can run on its own * Separate source codes, add some v5 contracts * Update contracts fixed some review comments, remove some unused functions * Update eth2dai contract with enable/disable internal inventory for token * Add test for set internal inventory enable/disable * Put enable/disable internal inventory into internal inventory data * Add internal inventory tests * Change overlow to out of range * Update v5 contracts * Update file name and folder structure * Update folder structure * Fix can not find artifacts for WethTokenV5 * Update test folder structure * Rebase from development * Modify kyberNetwork script to be web3 1.x compatible * Clicky's web3 compatibility upgrade (#531) * KNP.js web3 1.x compatible * DutchXReserve.js * Removed addBps function, since we using Helper one * remove web3 instantiation * kyberUniswapReserve.js * Update test for expected rate and fee burner (#532) * Update test for expected rate and fee burner * Remove unused codes * support new web3 lib, especailly new BN (#533) * support new web3 lib, especailly new BN * upgrade kyber weth reserve to web3 * remove unused log function * kyberReserve.js, permissionGroups.js, whitelist.js, volumeImbalanceRecorder.js (#535) * KNP.js web3 1.x compatible * DutchXReserve.js * Removed addBps function, since we using Helper one * remove web3 instantiation * kyberUniswapReserve.js * kyberReserve.js * permissionGroups.js * Small code refactor for volumeImbalanceRecorder * whitelist.js * Remove valueOf() * Move calc src & dst qty functions to helper * wrapper files(3), orderIdManager, orderList, mockDepositxx, mockExchnagexxx, permission less order book reserve lister (#537) * update for web3 version * update wrappers to work with new web3 version * correct use artifacts * order list upgrade web3 * remove some debug info * upgrade permission less oreder book reserve lister to test to new Web3 version * fix some typos * remove some more valueOf() in assert (#538) * remove some valueOf() that are not required. * add CR LF on end * add back correct package lock * add back correct package lock * Update test for helper, liquidity conversion rates and formula (#536) * Update test for helper, liquidity conversion rates and formula * Remove unused logs * Update codes based on comments * Add new line for helper * remove valueOf(), user helper file to assert (#540) * remove valueOf() calls assert.equal --> Helper.assertEqual() * remove valueOf(), use Helper to assert * remove valueOf() * [WIP] Web3 upgrade for eth2 dai (#542) * eth2Dai initial commit * add helper changes * add issues * Fix failing tests, using helper assert func (#543) Co-authored-by: Le Xuan Manh <[email protected]> * remove example test file (#545) * Utils.js, Utils2.js, Utils3.js, update to web3 v1.2.4 (#534) * Updated utils.js to web3 1.2.4 * Updated utils2.js to web3 1.2.4 * Updated utils3.js to web3 1.2.4 * Updated utils*.js, fixed bugs on helper.js * Added modifications from Ilan's feedback * orderbookReserve.js update to web3 v1.2.4 (#555) * orderbookReserve.js update to web3 v1.2.4 * Implemented changes from feedback * Updated TokenWei var to Token18Dec * Changed Token18Dec var to camel case * Web3 upgrade bancor (#577) * update git ignore * update development (#547) * update git ignore (#544) * Kyber Bancor bridge reserve (#546) * Shifted arbitrage check to FeeBurner * Shifted relevant tests from expectedRate to feeBurner * Modified failing test, as it requires less gas to fail * Removed redundan >0 rate check, test for feeBurner * Added test for src==dest token * Istanbul fix, zero rate handling * Arbitrage check shifted to FeeBurner (#433) * Shifted arbitrage check to FeeBurner * Shifted relevant tests from expectedRate to feeBurner * Modified failing test, as it requires less gas to fail * Removed redundan >0 rate check, test for feeBurner * Added test for src==dest token * Revert "Merge branch 'clicky/zero_rate' into development" This reverts commit 795d2f1d28131534604586b7786cba4e79f21e04, reversing changes made to 80af391c738395ac57017f4e18eab904869cf6f7. * Clicky/buidl integration (#459) * Pulling stuff from KN/clicky/buidl-integration branch * Pull changes from expected rate and fee burner * Update kyberNetwork test file * Update kyberNetwork.js * Merge Mike's PR on enhanced step functions (#458) * [WIP] Add new conversion rate contract with step function enhancement (#416) * [WIP] Add new conversion rate contract with step function enhancement * Add more tests to kyberReserve for testing new conversion rate contract * Add more tests for kybetNetwork with new conversion rate contract * Add verify qty and imbalance step function amounts must be increasing * Add case set qty and balance step func with only one or zero element * Check for qty step function all amounts are non negative * Update conversion rate contract and kyber network tests * Fallback to old logics when qty is 0 * Update new conversion rate with inherite from old one, update logics for some edge cases and tests * Fixed typo * Add check for empty step function before executing step function * Fix issue when qty is negative and greater than all step qty * Fix issue with executing step func with 0 as qty (#417) * Remove unnecessary tests in conversionRate2, add more cases to test for new execute step function * Fix issue with execute step func for 0 qty * expose getImbalance function in conversionRate2.sol file (#419) * Update conversion rate contract 2 with new logics for executing step function * Resolve some comments, change name new conversion rates contract to EnhancedStepFunctions * Remove qty step function, compress data for imbalance steps * Resolve solhint max line length * Avoid modifying function params in execute step func * Update comments for each test case of getting correct bps for step func * Update with some comments, add more tests * Add await keyword * Update some comments, fix some old tests in kyber reserve * Fix wrong calculate imbalance of token in reserve test * Change default max imbalance to return when overflow, fix some tests with missing await keyword * Blocking setting qty step function in new conversion rate * Update execute step func with blocking rate, remove updatedRateBlock in getImbalance * Remove redundant stepX value in last step * Add check data when encoding step func, using MAX_VAL as default for last step X * Add checking for max value of step X and tests * Add check for max bps adjustment, check max_imbalance value test * Fixed Failing Tests (#462) * Istanbul fix * Fixed failing tests as per Ilan's feedback * Fixed failing tests * Minor fixes * Minor fixes * Sync enhanced step functions test file * Reduce getDecimals call in findBestRateTokenToToken in network contract (#467) * Reduce getDecimals call in findBestRateTokenToToken in network contract * Fix new line end file * Remove some tests in utils3 * Avoid decimals call when calling handleFees on FeeBurner (#468) * Ilan/merge master (#460) * reserve deployment scripts (#233) * reserve deployment scripts * read valid block duration from config file. (#423) * Weth Reserve Implementation (#304) * Weth Reserve Implementation Includes testing. Also includes an addition in helper to make throw catching more neat. * Add weth reserve test * Add deploy script for oasis reserve * Organize folder structure and update WrapConversionRate.sol #441 && #452 (#453) * Organize folder structure according to issue #441 this includes organizing audit folder and organizing reserves. Remove multisig support from WrapConversionRate.sol according to issue #452 * enable admin to call transfer admin of base contract * enable wrapConversionRate to control all adminOnly functions in conversionRate (#461) * Ilan/modify wrap conversion rate (#466) * enable wrapConversionRate to control all adminOnly functions in conversionRate * enable wrap conversion rate to control all admin functions in conversion rate contract * set admin as msg.sender. to follow base contract logic * remove redundant test. adopt to chainge in admin logic * add CR LF * rename folders. (#469) * rename folders. (remove contract from folder name.) * reset package - lock * move new mock contracts to mock folder. * create web3 object * Upgraded to ganache-cli@istanbul * Removed header * Istanbul fix (#457) * Return zero rate for same src and dest token (#475) * Return zero rate for same src & dest token * Removed unnecessary tests * Echo fork choice, fix broken logic * Try committing new package-lock.json * Added more info * Bumped to node v12.13.0 * Update package fix npm (#474) * Update package fix npm * Update package-lock file * Remove unused packages * Removed eslint * Add colour for better readability of fork choice * Add spacing between example commands * Resolve package-lock conflict * Revert "Bumped to node v12.13.0" This reverts commit 85cb734ed5bfae4fdc5fc0dc8c8dfcc8c3c426ed. * Fixed conflicting files * Revert "Merge branch 'clicky/ganacheIstanbul' into development" This reverts commit 654a1c3e7971319bd802df0cd70daf32337caa95, reversing changes made to 6c0a21c59eb55b44cfe8616a513e7e76533fc9c5. * Upgrade to ganache-cli@istanbul for testing with Istanbul fork (#482) * Added colour and newline to fork choice * Add node and npm version used * Removed eslint * Removed eslint * Got latest changes from Mike's PR * added colour and newline to fork choice * Fix coloring (I hope) * Changed BG to make text stand out * handle zero qty in get rate permission less reserve (#472) * handle zero qty in get rate permission less reserve * undo wrong change * Increase gas limit for 1 test due to Istanbul (#487) * [455] Enable unlist orderbook permissionless reserve (#485) * Add comments in FeeBurner for KNC decimals (#489) * Revert "Arbitrage check shifted to FeeBurner" (#488) * Revert "Arbitrage check shifted to FeeBurner (#433)" This reverts commit 80af391c738395ac57017f4e18eab904869cf6f7. * reverse un needed test changes for kyber NEtwork * Zero Src Qty Handling (#483) * Initial commit for zero rate handling. Need to rewrite tests * Improved comment to code * Modified getConversionRate function to require srcAmt > 0 * Removed tests, added one * Updated contracts as per feedback * Updated comment in test file * Added fix to expectedRateSmallQty * Remove extra = * Add additional section to check network.getExpectedRate doesn't revert as well * Removed redundant tests due to zero rate handling in network contract (#494) * update solidity coverage version (#491) * Added new deployment script and input files (#495) * Ilan/add rates getter (#493) * update solidity coverage version * add getter function for rates * update getter API and return values, add tests * Clicky/rename compile file (#496) * renamed compileOutput.js to compileContracts.js, added more contracts for reserveDeployer * Renamed compileOutput -> compileContracts * Minor spelling edit * update addresses for deployment (#497) * remove multi sig support. add admin functionality (#498) * remove multi sig support. add admin functionality * refactor wrapper contracts, update tests * update tests according to PR comments, add one missing check * Add some comments * Revert "[455] Enable unlist orderbook permissionless reserve (#485)" (#504) This reverts commit 8b63c0ea023b7965a7c00e452279cf52e03f32f2. * Fix deployment script after staging deployment (#505) * Added new deployment script and input files * Remove old file * Added contract instantiation if deployer script breaks halfway through * avoid query to uniswap with zero rate (#510) * avoid query to uniswap with zero rate * test situation where trade result is 0 * enable setting min record resultion in conversion rates using wrapper (#513) * enable setting min record resultion in conversion rates using wrapper * linting, and add missing test * fix uniswap bridge for small amounts src qty (1) (#518) * fix uniswap bridge for smal amounts src qty (1) * avoid reading fee twice * fix uniswap deployer script * Ilan/deployment helper (#516) * some deployment changes, and helper contract" " * add kyber uniswap bridge to compilation. remove wrap conversion rate * small fixes in deployer * Add CR LF * Ilan/merge master (#519) * update some packages. fix solc version to 0.4.18 (#503) * fixed FPR deployment script (#508) * add smartdec audit for APR * use correct package-lock * Ilan/master to development (#525) * Development to Master. Istanbul changes. buidl. (#471) * Shifted arbitrage check to FeeBurner * Shifted relevant tests from expectedRate to feeBurner * Modified failing test, as it requires less gas to fail * Removed redundan >0 rate check, test for feeBurner * Added test for src==dest token * Istanbul fix, zero rate handling * Arbitrage check shifted to FeeBurner (#433) * Shifted arbitrage check to FeeBurner * Shifted relevant tests from expectedRate to feeBurner * Modified failing test, as it requires less gas to fail * Removed redundan >0 rate check, test for feeBurner * Added test for src==dest token * Revert "Merge branch 'clicky/zero_rate' into development" This reverts commit 795d2f1d28131534604586b7786cba4e79f21e04, reversing changes made to 80af391c738395ac57017f4e18eab904869cf6f7. * Clicky/buidl integration (#459) * Pulling stuff from KN/clicky/buidl-integra…
1 parent 2e001dc commit f3952db

File tree

7 files changed

+462
-224
lines changed

7 files changed

+462
-224
lines changed

contractsV5/PermissionGroupsV5.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ contract PermissionGroups {
1111
address[] internal alertersGroup;
1212
uint constant internal MAX_GROUP_SIZE = 50;
1313

14-
constructor() public {
15-
admin = msg.sender;
14+
constructor(address _admin) public {
15+
require(_admin != address(0), "Admin 0");
16+
admin = _admin;
1617
}
1718

1819
modifier onlyAdmin() {

contractsV5/WithdrawableV5.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import "./PermissionGroupsV5.sol";
66

77
contract Withdrawable is PermissionGroups {
88

9+
constructor(address _admin) public
10+
PermissionGroups(_admin)
11+
{}
12+
913
event TokenWithdraw(IERC20 token, uint amount, address sendTo);
1014

1115
/**

contractsV5/bridges/bancor/KyberBancorReserve.sol

Lines changed: 35 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -8,45 +8,33 @@ import "./mock/IBancorNetwork.sol";
88

99
contract KyberBancorReserve is IKyberReserve, Withdrawable, Utils {
1010

11-
uint constant internal BPS = 10000; // 10^4
1211
uint constant ETH_BNT_DECIMALS = 18;
1312

1413
address public kyberNetwork;
1514
bool public tradeEnabled;
16-
uint public feeBps;
1715

18-
IBancorNetwork public bancorNetwork; // 0x0e936B11c2e7b601055e58c7E32417187aF4de4a
16+
IBancorNetwork public bancorNetwork;
1917

20-
IERC20 public bancorEth; // 0xc0829421C1d260BD3cB3E0F06cfE2D52db2cE315
21-
IERC20 public bancorETHBNT; // 0xb1CD6e4153B2a390Cf00A6556b0fC1458C4A5533
22-
IERC20 public bancorToken; // 0x1F573D6Fb3F13d689FF844B4cE37794d79a7FF1C
18+
IERC20 public bancorToken;
19+
IERC20[] public ethToBntPath;
20+
IERC20[] public bntToEthPath;
2321

2422
constructor(
2523
address _bancorNetwork,
2624
address _kyberNetwork,
27-
uint _feeBps,
28-
address _bancorEth,
29-
address _bancorETHBNT,
3025
address _bancorToken,
3126
address _admin
3227
)
33-
public
28+
public Withdrawable(_admin)
3429
{
3530
require(_bancorNetwork != address(0), "constructor: bancorNetwork address is missing");
3631
require(_kyberNetwork != address(0), "constructor: kyberNetwork address is missing");
37-
require(_bancorEth != address(0), "constructor: bancorEth address is missing");
38-
require(_bancorETHBNT != address(0), "constructor: bancorETHBNT address is missing");
3932
require(_bancorToken != address(0), "constructor: bancorToken address is missing");
40-
require(_admin != address(0), "constructor: admin address is missing");
41-
require(_feeBps < BPS, "constructor: fee is too big");
42-
33+
4334
bancorNetwork = IBancorNetwork(_bancorNetwork);
4435
bancorToken = IERC20(_bancorToken);
45-
bancorEth = IERC20(_bancorEth);
46-
bancorETHBNT = IERC20(_bancorETHBNT);
4736

4837
kyberNetwork = _kyberNetwork;
49-
feeBps = _feeBps;
5038
admin = _admin;
5139
tradeEnabled = true;
5240

@@ -73,8 +61,6 @@ contract KyberBancorReserve is IKyberReserve, Withdrawable, Utils {
7361
// src and dest can be only BNT or ETH
7462
uint rate = calcRateFromQty(srcQty, destQty, ETH_BNT_DECIMALS, ETH_BNT_DECIMALS);
7563

76-
rate = valueAfterReducingFee(rate);
77-
7864
return rate;
7965
}
8066

@@ -125,24 +111,14 @@ contract KyberBancorReserve is IKyberReserve, Withdrawable, Utils {
125111
function setBancorContract(address _bancorNetwork) public onlyAdmin {
126112
require(_bancorNetwork != address(0), "setBancorContract: bancorNetwork address is missing");
127113

128-
if (address(bancorNetwork) != address(0)) {
129-
require(bancorToken.approve(address(bancorNetwork), 0), "setBancorContract: can not reset approve token");
130-
}
114+
require(bancorToken.approve(address(bancorNetwork), 0), "setBancorContract: can not reset allowance");
115+
131116
bancorNetwork = IBancorNetwork(_bancorNetwork);
132-
require(bancorToken.approve(address(bancorNetwork), 2 ** 255), "setBancorContract: can not approve token");
117+
require(bancorToken.approve(_bancorNetwork, 2 ** 255), "setBancorContract: can not approve token");
133118

134119
emit BancorNetworkSet(_bancorNetwork);
135120
}
136121

137-
event FeeBpsSet(uint feeBps);
138-
139-
function setFeeBps(uint _feeBps) public onlyAdmin {
140-
require(_feeBps < BPS, "setFeeBps: feeBps >= BPS");
141-
142-
feeBps = _feeBps;
143-
emit FeeBpsSet(feeBps);
144-
}
145-
146122
event TradeEnabled(bool enable);
147123

148124
function enableTrade() public onlyAdmin returns(bool) {
@@ -152,6 +128,29 @@ contract KyberBancorReserve is IKyberReserve, Withdrawable, Utils {
152128
return true;
153129
}
154130

131+
event NewPathsSet(IERC20[] ethToBntPath, IERC20[] bntToEthPath);
132+
133+
function setNewEthBntPath(IERC20[] memory _ethToBntPath, IERC20[] memory _bntToEthPath) public onlyAdmin {
134+
require(_ethToBntPath.length != 0, "setNewEthBntPath: path should have some elements");
135+
require(_bntToEthPath.length != 0, "setNewEthBntPath: path should have some elements");
136+
137+
// verify if path returns value for rate
138+
// both ETH + BNT has same decimals of 18, using 1 ETH/BNT to get rate
139+
uint amount = PRECISION;
140+
uint destQty;
141+
142+
(destQty, ) = bancorNetwork.getReturnByPath(_ethToBntPath, amount);
143+
require(destQty > 0, "setNewEthBntPath: no rate from eth to bnt with this path");
144+
145+
(destQty, ) = bancorNetwork.getReturnByPath(_bntToEthPath, amount);
146+
require(destQty > 0, "setNewEthBntPath: no rate from bnt to eth with this path");
147+
148+
ethToBntPath = _ethToBntPath;
149+
bntToEthPath = _bntToEthPath;
150+
151+
emit NewPathsSet(_ethToBntPath, _bntToEthPath);
152+
}
153+
155154
function disableTrade() public onlyAlerter returns(bool) {
156155
tradeEnabled = false;
157156
emit TradeEnabled(false);
@@ -213,24 +212,10 @@ contract KyberBancorReserve is IKyberReserve, Withdrawable, Utils {
213212

214213
function getConversionPath(IERC20 src, IERC20 dest) public view returns(IERC20[] memory path) {
215214
if (src == bancorToken) {
216-
// trade from BNT to ETH
217-
path = new IERC20[](3);
218-
path[0] = bancorToken;
219-
path[1] = bancorETHBNT;
220-
path[2] = bancorEth;
221-
return path;
215+
path = bntToEthPath;
222216
} else if (dest == bancorToken) {
223-
// trade from ETH to BNT
224-
path = new IERC20[](3);
225-
path[0] = bancorEth;
226-
path[1] = bancorETHBNT;
227-
path[2] = bancorToken;
228-
return path;
217+
path = ethToBntPath;
229218
}
230-
}
231-
232-
function valueAfterReducingFee(uint val) internal view returns(uint) {
233-
require(val <= MAX_QTY, "valueAfterReducingFee: val > MAX_QTY");
234-
return ((BPS - feeBps) * val) / BPS;
219+
return path;
235220
}
236221
}

contractsV5/bridges/bancor/mock/MockBancorNetwork.sol

Lines changed: 52 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,18 @@ import "../../../UtilsV5.sol";
66

77
contract MockBancorNetwork is IBancorNetwork, Utils {
88

9-
IERC20 public bancorETH;
10-
IERC20 public bancorETHBNT;
119
IERC20 public bancorBNT;
1210

11+
IERC20[] public ethToBntPath;
12+
IERC20[] public bntToEthPath;
13+
1314
uint public rateEthToBnt;
1415
uint public rateBntToETh;
1516

16-
constructor(address _bancorETH, address _bancorETHBNT, address _bancorBNT) public {
17-
bancorETH = IERC20(_bancorETH);
18-
bancorBNT = IERC20(_bancorBNT);
19-
bancorETHBNT = IERC20(_bancorETHBNT);
17+
constructor(IERC20 _bancorBNT, IERC20[] memory _ethToBntPath, IERC20[] memory _bntToEthPath) public {
18+
bancorBNT = _bancorBNT;
19+
ethToBntPath = _ethToBntPath;
20+
bntToEthPath = _bntToEthPath;
2021
}
2122

2223
function() external payable { }
@@ -26,24 +27,48 @@ contract MockBancorNetwork is IBancorNetwork, Utils {
2627
rateBntToETh = _rateBntToEth;
2728
}
2829

30+
function setNewEthBntPath(IERC20[] memory _ethToBntPath, IERC20[] memory _bntToEthPath) public {
31+
ethToBntPath = _ethToBntPath;
32+
bntToEthPath = _bntToEthPath;
33+
}
34+
2935
function getReturnByPath(IERC20[] calldata _path, uint256 _amount) external view returns (uint256, uint256) {
3036
require(_amount > 0);
31-
if (_path.length != 3) { return (0, 0); }
32-
if (_path[0] == bancorBNT && _path[1] == bancorETHBNT && _path[2] == bancorETH) {
33-
// rate btn to eth
34-
uint destAmount = calcDstQty(_amount, getDecimals(bancorBNT), ETH_DECIMALS, rateBntToETh);
35-
if (destAmount > address(this).balance) {
36-
return (0, 0);
37+
// verify if path is ethToBntPath
38+
if (_path.length == ethToBntPath.length) {
39+
bool isPathOk = true;
40+
for(uint i = 0; i < _path.length; i++) {
41+
if (_path[i] != ethToBntPath[i]) {
42+
isPathOk = false;
43+
break;
44+
}
45+
}
46+
if (isPathOk) {
47+
// rate eth to bnt
48+
uint destAmount = calcDstQty(_amount, ETH_DECIMALS, getDecimals(bancorBNT), rateEthToBnt);
49+
if (destAmount > bancorBNT.balanceOf(address(this))) {
50+
return (0, 0);
51+
}
52+
return (destAmount, 0);
3753
}
38-
return (destAmount, 0);
3954
}
40-
if (_path[0] == bancorETH && _path[1] == bancorETHBNT && _path[2] == bancorBNT) {
41-
// rate eth to bnt
42-
uint destAmount = calcDstQty(_amount, ETH_DECIMALS, getDecimals(bancorBNT), rateEthToBnt);
43-
if (destAmount > bancorBNT.balanceOf(address(this))) {
44-
return (0, 0);
55+
// verify if path is from bnt to eth
56+
if (_path.length == bntToEthPath.length) {
57+
bool isPathOk = true;
58+
for(uint i = 0; i < _path.length; i++) {
59+
if (_path[i] != bntToEthPath[i]) {
60+
isPathOk = false;
61+
break;
62+
}
63+
}
64+
if (isPathOk) {
65+
// rate btn to eth
66+
uint destAmount = calcDstQty(_amount, getDecimals(bancorBNT), ETH_DECIMALS, rateBntToETh);
67+
if (destAmount > address(this).balance) {
68+
return (0, 0);
69+
}
70+
return (destAmount, 0);
4571
}
46-
return (destAmount, 0);
4772
}
4873
return (0, 0);
4974
}
@@ -55,9 +80,11 @@ contract MockBancorNetwork is IBancorNetwork, Utils {
5580
address,
5681
uint256
5782
) external payable returns (uint256) {
58-
require(_path.length == 3);
5983
// trade eth to bnt
60-
require(_path[0] == bancorETH && _path[1] == bancorETHBNT && _path[2] == bancorBNT);
84+
require(_path.length == ethToBntPath.length);
85+
for(uint i = 0; i < _path.length; i++) {
86+
require(_path[i] == ethToBntPath[i]);
87+
}
6188
require(msg.value == _amount && _amount > 0);
6289
require(rateEthToBnt > 0);
6390
uint destAmount = calcDstQty(_amount, ETH_DECIMALS, getDecimals(bancorBNT), rateEthToBnt);
@@ -74,9 +101,10 @@ contract MockBancorNetwork is IBancorNetwork, Utils {
74101
address,
75102
uint256
76103
) external returns (uint256) {
77-
require(_path.length == 3);
78-
// trade eth to bnt
79-
require(_path[0] == bancorBNT && _path[1] == bancorETHBNT && _path[2] == bancorETH);
104+
require(_path.length == bntToEthPath.length);
105+
for(uint i = 0; i < _path.length; i++) {
106+
require(_path[i] == bntToEthPath[i]);
107+
}
80108
// collect bnt
81109
require(_amount > 0);
82110
require(bancorBNT.transferFrom(msg.sender, address(this), _amount));

contractsV5/bridges/eth2dai/Eth2DaiReserve.sol

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ contract Eth2DaiReserve is IKyberReserve, Withdrawable, Utils {
2424
bool public tradeEnabled;
2525
uint public feeBps;
2626

27-
IOtc public otc;// = IOtc(0x39755357759cE0d7f32dC8dC45414CCa409AE24e);
27+
IOtc public otc;
2828
IWeth public wethToken;// = IWeth(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
2929

3030
mapping(address => bool) public isTokenListed;
@@ -66,13 +66,14 @@ contract Eth2DaiReserve is IKyberReserve, Withdrawable, Utils {
6666
uint id;
6767
}
6868

69-
constructor(address _kyberNetwork, uint _feeBps, address _otc, address _weth, address _admin) public {
69+
constructor(address _kyberNetwork, uint _feeBps, address _otc, address _weth, address _admin)
70+
public Withdrawable(_admin)
71+
{
7072
require(_kyberNetwork != address(0), "constructor: kyberNetwork's address is missing");
7173
require(_otc != address(0), "constructor: otc's address is missing");
7274
require(_weth != address(0), "constructor: weth's address is missing");
7375
require(_feeBps < BPS, "constructor: fee >= bps");
74-
require(_admin != address(0), "constructor: admin is missing");
75-
76+
7677
wethToken = IWeth(_weth);
7778
require(getDecimals(wethToken) == MAX_DECIMALS, "constructor: wethToken's decimals is not MAX_DECIMALS");
7879
require(wethToken.approve(_otc, 2**255), "constructor: failed to approve otc (wethToken)");
@@ -237,7 +238,13 @@ contract Eth2DaiReserve is IKyberReserve, Withdrawable, Utils {
237238
require(_otc != address(0), "setContracts: otc's address is missing");
238239

239240
kyberNetwork = _kyberNetwork;
240-
otc = IOtc(_otc);
241+
242+
if (_otc != address(otc)) {
243+
// new otc address
244+
require(wethToken.approve(address(otc), 0), "setContracts: failed to reset allowance for old otc (wethToken)");
245+
otc = IOtc(_otc);
246+
require(wethToken.approve(_otc, 2**255), "setContracts: failed to approve otc (wethToken)");
247+
}
241248

242249
emit ContractsSet(_kyberNetwork, _otc);
243250
}
@@ -645,13 +652,7 @@ contract Eth2DaiReserve is IKyberReserve, Withdrawable, Utils {
645652

646653
if (!isEthToToken) {
647654
// only need to use median when token -> eth trade
648-
// rate eth/dai: order0Buy / order0Pay
649655
order0Pay = ask.payAmount;
650-
// sell eth rate : ask.buyAmount / ask.payAmount
651-
// buy eth rate : bid.payAmount / bid.buyAmount
652-
// median rate (eth/dai): (ask.buyAmount / ask.payAmount + bid.payAmount / bid.buyAmount) / 2;
653-
// take amt dai : ask.payAmount
654-
// -> amt eth : ask.payAmount * (ask.buyAmount / ask.payAmount + bid.payAmount / bid.buyAmount) / 2;
655656
order0Buy = (ask.buyAmount + ask.payAmount * bid.payAmount / bid.buyAmount) / 2;
656657
}
657658

@@ -710,13 +711,6 @@ contract Eth2DaiReserve is IKyberReserve, Withdrawable, Utils {
710711
return false;
711712
}
712713

713-
// sell eth rate : ask.payAmount / ask.buyAmount
714-
// buy eth rate : bid.buyAmount / bid.payAmount
715-
// sell > buy -> ask.payAmount / ask.buyAmount > bid.buyAmount / bid.payAmount
716-
// -> ask.payAmount * bid.payA mount > ask.buyAmount * bid.buyAmount;
717-
// slippage : (sell - buy) / buy
718-
// -> (ask.payAmount / ask.buyAmount - bid.buyAmount / bid.payAmount) / (bid.buyAmount / bid.payAmount);
719-
720714
uint x1 = ask.payAmount * bid.payAmount;
721715
uint x2 = ask.buyAmount * bid.buyAmount;
722716

0 commit comments

Comments
 (0)