Giter Club home page Giter Club logo

bentobox's Introduction

Sushi Monorepo

Sushi 2.0 ๐Ÿฃ

Getting Started

https://pnpm.io/installation

Install

pnpm install

Dev

pnpm exec turbo run dev --filter=evm

Vercel APIs

These need to be run from their own folder at the moment in development.

pnpm exec vercel dev

Build

pnpm run build

Single Repository

pnpm exec turbo run build --filter=api/app/package/protocol

Test

pnpm run test

Single Repository

pnpm exec turbo run test --filter=api/app/package/protocol

Clean

pnpm run clean

Single Repository

pnpm exec turbo run clean --filter=api/app/package/protocol

APIs

...

Creating a new API

git checkout -b feature/example-api

Apps

...

Creating a new app

git checkout -b feature/example-app

Config

...

Creating a new config

git checkout -b feature/example-config

Packages

...

Creating a new package

git checkout -b feature/example-package

Protocols

...

Creating a new protocol

git checkout -b feature/example-protocol

Subgraphs

...

Creating a new subgraph

git checkout -b feature/example-subgraph

Disclaimer

These smart contracts and code are being provided as is. No guarantee, representation or warranty is being made, express or implied, as to the safety or correctness of the user interface or the smart contracts and code. There can be no assurance they will work as intended, and users may experience delays, failures, errors, omissions or loss of transmitted information. In addition, using these smart contracts and code should be conducted in accordance with applicable law. Nothing in this repo should be construed as investment advice or legal advice for any particular facts or circumstances and is not meant to replace competent counsel. It is strongly advised for you to contact a reputable attorney in your jurisdiction for any questions or concerns with respect thereto. SushiSwap is not liable for any use of the foregoing and users should proceed with caution and use at their own risk.

Any stated APY (the 'Rate') is purely informational based on publicly available blockchain data, and is a forward-looking projection based on our good faith belief of how to reasonably project results over the relevant period, but such belief is subject to numerous assumptions, risks and uncertainties (including smart contract security risks and third-party actions) which could result in a materially different (lower or higher) token-denominated Rates. The Rate is not a promise, guarantee or undertaking on the part of any person or group of persons, but depends entirely on the results of operation of smart contracts and other autonomous systems (including third-party systems) and how third parties interact with those systems after the time of your deposit or other interactions. Even if the Rate is achieved as projected, you may still suffer a financial loss in fiat-denominated terms if the fiat-denominated value of the relevant tokens (your deposit and any tokens allocated or distributed to you pursuant to the Rate) declines during the deposit period.

bentobox's People

Contributors

boringcrypto avatar clearwood avatar dangerousfood avatar davidkutik avatar fifikobayashi avatar jiro-ono avatar johannbarbie avatar levx-me avatar lufycz avatar matthewlilley avatar nd-certora avatar pinkiebell avatar shellygr avatar steviezhang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bentobox's Issues

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');

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.

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;
}
)

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.

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.