Giter Club home page Giter Club logo

bentobox's Issues

support 1-tx deposit into LP

currently this is the only way to get into the Pair:

  • approve() to Box, then addAsset()/addCollateral() to LP

which requires 2 transactions on the UI.

addAssetWithPermit() and addCollateralWithPermit() could forward receipts to Box. only useful for some tokens obviously.

Slither does not run

Error HH12: Trying to use a non-local installation of Hardhat, which is not supported.
Please install Hardhat locally using npm or Yarn, and try again.
For more info go to https://hardhat.org/HH12 or run Hardhat with --show-stack-traces

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/slither/__main__.py", line 712, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/usr/lib/python3.9/site-packages/slither/__main__.py", line 71, in process_all
    compilations = compile_all(target, **vars(args))
  File "/home/keno/.local/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 1076, in compile_all
    compilations.append(CryticCompile(target, **kwargs))
  File "/home/keno/.local/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 137, in __init__
    self._compile(**kwargs)
  File "/home/keno/.local/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 987, in _compile
    self._platform.compile(self, **kwargs)
  File "/home/keno/.local/lib/python3.9/site-packages/crytic_compile/platform/hardhat.py", line 81, in compile
    (compiler, version_from_config, optimized) = _get_version_from_config(config_file)
  File "/home/keno/.local/lib/python3.9/site-packages/crytic_compile/platform/hardhat.py", line 193, in _get_version_from_config
    raise InvalidCompilation(f"{config} not found")
crytic_compile.platform.exceptions.InvalidCompilation: cache/solidity-files-cache.json not found
ERROR:root:None
ERROR:root:Error in .
ERROR:root:Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/slither/__main__.py", line 712, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/usr/lib/python3.9/site-packages/slither/__main__.py", line 71, in process_all
    compilations = compile_all(target, **vars(args))
  File "/home/keno/.local/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 1076, in compile_all
    compilations.append(CryticCompile(target, **kwargs))
  File "/home/keno/.local/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 137, in __init__
    self._compile(**kwargs)
  File "/home/keno/.local/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 987, in _compile
    self._platform.compile(self, **kwargs)
  File "/home/keno/.local/lib/python3.9/site-packages/crytic_compile/platform/hardhat.py", line 81, in compile
    (compiler, version_from_config, optimized) = _get_version_from_config(config_file)
  File "/home/keno/.local/lib/python3.9/site-packages/crytic_compile/platform/hardhat.py", line 193, in _get_version_from_config
    raise InvalidCompilation(f"{config} not found")
crytic_compile.platform.exceptions.InvalidCompilation: cache/solidity-files-cache.json not found

SushiSwap Swapper Test has unhandled rejections

SushiSwapSwapper
    Swap
(node:3572) UnhandledPromiseRejectionWarning: AssertionError: Expected "0" to be equal 20000000000000000000
    at assertArgsArraysEqual (/home/runner/work/bentobox/bentobox/node_modules/@ethereum-waffle/chai/dist/cjs/matchers/emit.js:48:52)
    at tryAssertArgsArraysEqual (/home/runner/work/bentobox/bentobox/node_modules/@ethereum-waffle/chai/dist/cjs/matchers/emit.js:54:20)
    at /home/runner/work/bentobox/bentobox/node_modules/@ethereum-waffle/chai/dist/cjs/matchers/emit.js:66:13
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
      ✓ should swap (158ms)
    at runNextTicks (internal/process/task_queues.js:62:3)
    at listOnTimeout (internal/timers.js:523:9)
    at processTimers (internal/timers.js:497:7)
(node:3572) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2822)
(node:3572) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:3572) UnhandledPromiseRejectionWarning: AssertionError: Expected "0" to be equal 20000000000000000000
    at assertArgsArraysEqual (/home/runner/work/bentobox/bentobox/node_modules/@ethereum-waffle/chai/dist/cjs/matchers/emit.js:48:52)
    at tryAssertArgsArraysEqual (/home/runner/work/bentobox/bentobox/node_modules/@ethereum-waffle/chai/dist/cjs/matchers/emit.js:54:20)
    at /home/runner/work/bentobox/bentobox/node_modules/@ethereum-waffle/chai/dist/cjs/matchers/emit.js:66:13
    at runMicrotasks (<anonymous>)
      ✓ should swap with minimum set (159ms)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at runNextTicks (internal/process/task_queues.js:62:3)
    at listOnTimeout (internal/timers.js:523:9)
    at processTimers (internal/timers.js:497:7)
(node:3572) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2841)
      ✓ should not swap with minimum not met (128ms)
(node:3572) UnhandledPromiseRejectionWarning: AssertionError: Expected "2000000000" to be equal 0
    at assertArgsArraysEqual (/home/runner/work/bentobox/bentobox/node_modules/@ethereum-waffle/chai/dist/cjs/matchers/emit.js:48:52)
    at tryAssertArgsArraysEqual (/home/runner/work/bentobox/bentobox/node_modules/@ethereum-waffle/chai/dist/cjs/matchers/emit.js:54:20)
    at /home/runner/work/bentobox/bentobox/node_modules/@ethereum-waffle/chai/dist/cjs/matchers/emit.js:66:13
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at runNextTicks (internal/process/task_queues.js:62:3)
    at listOnTimeout (internal/timers.js:523:9)
    at processTimers (internal/timers.js:497:7)
(node:3572) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2875)
      ✓ should swap in opposite direction (151ms)
(node:3572) UnhandledPromiseRejectionWarning: AssertionError: Expected "2000000000" to be equal 0
    at assertArgsArraysEqual (/home/runner/work/bentobox/bentobox/node_modules/@ethereum-waffle/chai/dist/cjs/matchers/emit.js:48:52)
    at tryAssertArgsArraysEqual (/home/runner/work/bentobox/bentobox/node_modules/@ethereum-waffle/chai/dist/cjs/matchers/emit.js:54:20)
    at /home/runner/work/bentobox/bentobox/node_modules/@ethereum-waffle/chai/dist/cjs/matchers/emit.js:66:13
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at runNextTicks (internal/process/task_queues.js:62:3)
    at listOnTimeout (internal/timers.js:523:9)
    at processTimers (internal/timers.js:497:7)
(node:3572) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2894)
      ✓ should swap in opposite direction with minimum set (152ms)
      ✓ should not swap in opposite direction with minimum not met (114ms)
    Swap Exact
(node:3572) UnhandledPromiseRejectionWarning: AssertionError: Expected "0" to be equal 20068207824754776535
    at assertArgsArraysEqual (/home/runner/work/bentobox/bentobox/node_modules/@ethereum-waffle/chai/dist/cjs/matchers/emit.js:48:52)
    at tryAssertArgsArraysEqual (/home/runner/work/bentobox/bentobox/node_modules/@ethereum-waffle/chai/dist/cjs/matchers/emit.js:54:20)
    at /home/runner/work/bentobox/bentobox/node_modules/@ethereum-waffle/chai/dist/cjs/matchers/emit.js:66:13
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at runNextTicks (internal/process/task_queues.js:62:3)
    at listOnTimeout (internal/timers.js:523:9)
    at processTimers (internal/timers.js:497:7)
(node:3572) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2930)
      ✓ should swap exact (173ms)
(node:3572) UnhandledPromiseRejectionWarning: AssertionError: Expected "0" to be equal 20068207824754776535
    at assertArgsArraysEqual (/home/runner/work/bentobox/bentobox/node_modules/@ethereum-waffle/chai/dist/cjs/matchers/emit.js:48:52)
    at tryAssertArgsArraysEqual (/home/runner/work/bentobox/bentobox/node_modules/@ethereum-waffle/chai/dist/cjs/matchers/emit.js:54:20)
    at /home/runner/work/bentobox/bentobox/node_modules/@ethereum-waffle/chai/dist/cjs/matchers/emit.js:66:13
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at runNextTicks (internal/process/task_queues.js:62:3)
    at listOnTimeout (internal/timers.js:523:9)
    at processTimers (internal/timers.js:497:7)
(node:3572) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2950)
      ✓ should swap exact with exact amountIn (159ms)
      ✓ should not swap exact with not enough amountIn (95ms)
(node:3572) UnhandledPromiseRejectionWarning: AssertionError: Expected "2006820783" to be equal 0
    at assertArgsArraysEqual (/home/runner/work/bentobox/bentobox/node_modules/@ethereum-waffle/chai/dist/cjs/matchers/emit.js:48:52)
    at tryAssertArgsArraysEqual (/home/runner/work/bentobox/bentobox/node_modules/@ethereum-waffle/chai/dist/cjs/matchers/emit.js:54:20)
    at /home/runner/work/bentobox/bentobox/node_modules/@ethereum-waffle/chai/dist/cjs/matchers/emit.js:66:13
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at runNextTicks (internal/process/task_queues.js:62:3)
    at listOnTimeout (internal/timers.js:523:9)
    at processTimers (internal/timers.js:497:7)
(node:3572) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2982)
      ✓ should swap exact in opposite direction (169ms)
(node:3572) UnhandledPromiseRejectionWarning: AssertionError: Expected "2006820783" to be equal 0
    at assertArgsArraysEqual (/home/runner/work/bentobox/bentobox/node_modules/@ethereum-waffle/chai/dist/cjs/matchers/emit.js:48:52)
    at tryAssertArgsArraysEqual (/home/runner/work/bentobox/bentobox/node_modules/@ethereum-waffle/chai/dist/cjs/matchers/emit.js:54:20)
    at /home/runner/work/bentobox/bentobox/node_modules/@ethereum-waffle/chai/dist/cjs/matchers/emit.js:66:13
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at runNextTicks (internal/process/task_queues.js:62:3)
    at listOnTimeout (internal/timers.js:523:9)
    at processTimers (internal/timers.js:497:7)
(node:3572) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3002)
      ✓ should swap exact in opposite direction with exact AmountIn (151ms)
      ✓ should not swap exact in opposite direction with not enough amountIn (92ms)
      ```

possible size reduction?

Are these checks necessary?

      require(amount >= 0, 'LendingPair: amount should be >= 0');
      require(balanceOf[to] + amount >= balanceOf[to], 'LendingPair: overflow detected');

SLP oracle should respect token decimals

i've tested the SLPTWAP oracle with different decimals. here is what i get:

collateral 1e21, asset 1e9 => oracle price 1e6
collateral 1e18, asset 1e9 => oracle price 1e9
collateral 1e18, asset 1e18 => oracle price 1e18
collateral 1e9, asset 1e18 => oracle price 1e27

it always giving the price for 1e18 of the ask currency, no matter what the decimals.

i expect the following values:

collateral 1e21, asset 1e9 => oracle price 1e9
collateral 1e18, asset 1e9 => oracle price 1e9
collateral 1e18, asset 1e18 => oracle price 1e18
collateral 1e9, asset 1e18 => oracle price 1e18

so giving the price for 1 full unit of the ask currency, considering the decimals. would make the implementation of isSolvent() and liquiditations more simple, imo.

Interface IPair defined twice

The interface IPair is defined once in interfaces/IPair.sol (

interface IPair {
event AddAsset(address indexed user, uint256 amount, uint256 share);
event AddBorrow(address indexed user, uint256 amount, uint256 share);
event AddCollateral(address indexed user, uint256 amount, uint256 share);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
event NewExchangeRate(uint256 rate);
event RemoveAsset(address indexed user, uint256 amount, uint256 share);
event RemoveBorrow(address indexed user, uint256 amount, uint256 share);
event RemoveCollateral(address indexed user, uint256 amount, uint256 share);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
function approve(address spender, uint256 amount) external returns (bool success);
function balanceOf(address) external view returns (uint256);
function colRate() external view returns (uint256);
function decimals() external view returns (uint8);
function exchangeRate() external view returns (uint256);
function feesPending() external view returns (uint256);
function interestPerBlock() external view returns (uint256);
function lastBlockAccrued() external view returns (uint256);
function lastInterestBlock() external view returns (uint256);
function liqMultiplier() external view returns (uint256);
function name() external view returns (string memory);
function openColRate() external view returns (uint256);
function oracle() external view returns (IOracle);
function symbol() external view returns (string memory);
function tokenAsset() external view returns (IERC20);
function tokenCollateral() external view returns (IERC20);
function totalAsset() external view returns (uint256);
function totalBorrow() external view returns (uint256);
function totalBorrowShare() external view returns (uint256);
function totalCollateral() external view returns (uint256);
function totalCollateralShare() external view returns (uint256);
function totalSupply() external view returns (uint256);
function transfer(address to, uint256 amount) external returns (bool success);
function transferFrom(address from, address to, uint256 amount) external returns (bool success);
function userBorrowShare(address) external view returns (uint256);
function userCollateralShare(address) external view returns (uint256);
function vault() external view returns (IVault);
function init(IVault vault_, IERC20 collateral_address, IERC20 asset_address, IOracle oracle_address, bytes calldata oracleData) external;
function accrue() external;
function withdrawFees() external;
function isSolvent(address user, bool open) external view returns (bool);
function updateExchangeRate() external returns (uint256);
function updateInterestRate() external;
function addCollateral(uint256 amount) external;
function addAsset(uint256 amount) external;
function removeCollateral(uint256 share, address to) external;
function removeAsset(uint256 share, address to) external;
function borrow(uint256 amount, address to) external;
function repay(uint256 share) external;
function short(address swapper, uint256 amountAsset, uint256 minAmountCollateral) external;
function unwind(address swapper, uint256 borrowShare, uint256 maxAmountCollateral) external;
function liquidate(address[] calldata users, uint256[] calldata borrowShares, address to, address swapper, bool open) external;
}
) and again in Vault.sol (
interface IPair {
function init(address vault_, IERC20 tokenCollateral, IERC20 tokenAsset, address oracle_, bytes calldata oracleData) external;
}
)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.