Code Monkey home page Code Monkey logo

polars_contracts's People

Contributors

ssharshunov avatar yurivin avatar

Watchers

 avatar  avatar

polars_contracts's Issues

Error: Revert (message: SafeMath: subtraction overflow) in Withdraw from pending orders

In this case:

If user created pending order for less than 166$, than collateral token is withdrew normally

const withdrawCollateral = await deployedPendingOrders.withdrawCollateral();

but, if pending order created for more than 166$, math error occurs

1) Contract: PendingOrders
       should assert PredictionPool whiteBoughtBefore equal whiteBoughtAfter after work pending order:
     Error: Revert (message: SafeMath: subtraction overflow)
      at SafeMath.sub (contracts/SafeMath.sol:58:9)                                                                
      at SafeMath.sub (contracts/SafeMath.sol:45:16)                                                               
      at ERC20._transfer (contracts/ERC20.sol:131:27)                                                              
      at ERC20.transfer (contracts/ERC20.sol:60:9)                                                                 
      at TokenTemplate [address 0x839b836EB65b34CBaED792fEB093FcFdA8e2b57D] (contracts/ERC20.sol:59:5)             
      at PendingOrders.withdrawCollateral (contracts/PendingOrders.sol:284:9)                                      
      at PendingOrders [address 0x5472c2748fE22db92eCb9f0aab1f10ea1B5D3efC] (contracts/PendingOrders.sol:221:5)    
      at Context.<anonymous> (test/pending_orders.js:407:60)                                                       
      at processTicksAndRejections (internal/process/task_queues.js:97:5)                                          
                                                                           
Events log
    Events emitted during test:
    ---------------------------

    IERC20.Transfer(
      from: <indexed> 0xc15d957555452b08d7786c445eDE16E034F54e6B (type: address),
      to: <indexed> 0x02F9787438Ef1f40fd30256234C1Fa1A029aeeB7 (type: address),
      value: 5000000000000000000 (type: uint256)
    )

    IERC20.Approval(
      owner: <indexed> 0xc15d957555452b08d7786c445eDE16E034F54e6B (type: address),
      spender: <indexed> 0x02F9787438Ef1f40fd30256234C1Fa1A029aeeB7 (type: address),
      value: 999999999999999994999999999999999999 (type: uint256)
    )

    IERC20.Transfer(
      from: <indexed> 0x0000000000000000000000000000000000000000 (type: address),
      to: <indexed> 0xc15d957555452b08d7786c445eDE16E034F54e6B (type: address),
      value: 9970000000000000000 (type: uint256)
    )

    PredictionPool.BuyWhite(
      user: 0xc15d957555452b08d7786c445eDE16E034F54e6B (type: address),
      amount: 9970000000000000000 (type: uint256),
      price: 500000000000000000 (type: uint256)
    )

    IERC20.Transfer(
      from: <indexed> 0xc15d957555452b08d7786c445eDE16E034F54e6B (type: address),
      to: <indexed> 0x02F9787438Ef1f40fd30256234C1Fa1A029aeeB7 (type: address),
      value: 5000000000000000000 (type: uint256)
    )

    IERC20.Approval(
      owner: <indexed> 0xc15d957555452b08d7786c445eDE16E034F54e6B (type: address),
      spender: <indexed> 0x02F9787438Ef1f40fd30256234C1Fa1A029aeeB7 (type: address),
      value: 999999999999999989999999999999999999 (type: uint256)
    )

    IERC20.Transfer(
      from: <indexed> 0x0000000000000000000000000000000000000000 (type: address),
      to: <indexed> 0xc15d957555452b08d7786c445eDE16E034F54e6B (type: address),
      value: 9970000000000000000 (type: uint256)
    )

    PredictionPool.BuyBlack(
      user: 0xc15d957555452b08d7786c445eDE16E034F54e6B (type: address),
      amount: 9970000000000000000 (type: uint256),
      price: 500000000000000000 (type: uint256)
    )

    IERC20.Transfer(
      from: <indexed> 0xc15d957555452b08d7786c445eDE16E034F54e6B (type: address),
      to: <indexed> 0xf758B38Fc95a5c0b5F03f7930C4D6C031Fa4Bc79 (type: address),
      value: 167 (type: uint256)
    )

    IERC20.Approval(
      owner: <indexed> 0xc15d957555452b08d7786c445eDE16E034F54e6B (type: address),
      spender: <indexed> 0xf758B38Fc95a5c0b5F03f7930C4D6C031Fa4Bc79 (type: address),
      value: 999999999999999999999999999999999832 (type: uint256)
    )

    PendingOrders.OrderCreated(
      id: 1 (type: uint256),
      amount: 167 (type: uint256)
    )

    IERC20.Transfer(
      from: <indexed> 0xf758B38Fc95a5c0b5F03f7930C4D6C031Fa4Bc79 (type: address),
      to: <indexed> 0x02F9787438Ef1f40fd30256234C1Fa1A029aeeB7 (type: address),
      value: 167 (type: uint256)
    )

    IERC20.Approval(
      owner: <indexed> 0xf758B38Fc95a5c0b5F03f7930C4D6C031Fa4Bc79 (type: address),
      spender: <indexed> 0x02F9787438Ef1f40fd30256234C1Fa1A029aeeB7 (type: address),
      value: 115792089237316195423570985008687907853269984665640564039457584007913129639768 (type: uint256)
    )

    IERC20.Transfer(
      from: <indexed> 0x0000000000000000000000000000000000000000 (type: address),
      to: <indexed> 0xf758B38Fc95a5c0b5F03f7930C4D6C031Fa4Bc79 (type: address),
      value: 332 (type: uint256)
    )

    PredictionPool.BuyWhite(
      user: 0xf758B38Fc95a5c0b5F03f7930C4D6C031Fa4Bc79 (type: address),
      amount: 332 (type: uint256),
      price: 500000000000000000 (type: uint256)
    )

    EventLifeCycle.GameEventStarted(
      time: 1639396449 (type: uint256),
      eventId: 101 (type: uint256)
    )

    PredictionPool.CurrentWhitePrice(
      currrentWhitePrice: 500000000000000000 (type: uint256)
    )

    PredictionPool.CurrentBlackPrice(
      currentBlackPrice: 500000000000000000 (type: uint256)
    )

    PredictionPool.WhiteBoughtThisCycle(
      whiteBoughtThisCycle: 9970000000000000332 (type: uint256)
    )

    PredictionPool.BlackBoughtThisCycle(
      blackBoughtThisCycle: 9970000000000000000 (type: uint256)
    )

    PredictionPool.WhiteSoldThisCycle(
      whiteSoldThisCycle: 0 (type: uint256)
    )

    PredictionPool.BlackSoldThisCycle(
      blackSoldThisCycle: 0 (type: uint256)
    )

    PredictionPool.WhiteBought(
      whiteBought: 9970000000000000332 (type: uint256)
    )

    PredictionPool.BlackBought(
      blackBought: 9970000000000000000 (type: uint256)
    )

    PredictionPool.ReceivedForWhiteThisCycle(
      receivedForWhiteThisCycle: 4985000000000000166 (type: uint256)
    )

    PredictionPool.ReceivedForBlackThisCycle(
      receivedForBlackThisCycle: 4985000000000000000 (type: uint256)
    )

    PredictionPool.SpentForWhiteThisCycle(
      spentForWhiteThisCycle: 0 (type: uint256)
    )

    PredictionPool.SpentForBlackThisCycle(
      spentForBlackThisCycle: 0 (type: uint256)
    )

    PredictionPool.AllWhiteCollateral(
      allWhiteCollateral: 4985750000000000166 (type: uint256)
    )

    PredictionPool.AllBlackCollateral(
      allBlackCollateral: 4985750000000000000 (type: uint256)
    )

    PredictionPool.TotalFunds(
      totalFundsInSecondaryPool: 9971500000000000166 (type: uint256)
    )

    PredictionPool.WhiteCefficient(
      whiteCoefficient: 999999999999999967 (type: uint256)
    )

    PredictionPool.BlackCefficient(
      blackCoefficient: 1000000000000000033 (type: uint256)
    )

    PredictionPool.ChangePercent(
      changePercent: 50000000000000000 (type: uint256)
    )

    PredictionPool.WhiteWinVolatility(
      whiteWinVolatility: 49999999999999998 (type: uint256)
    )

    PredictionPool.BlackWinVolatility(
      blackWinVolatility: 50000000000000002 (type: uint256)
    )

    PredictionPool.CollateralForWhite(
      collateralForWhite: 5235037500000000164 (type: uint256)
    )

    PredictionPool.CollateralForBlack(
      collateralForBlack: 4736462500000000000 (type: uint256)
    )

    PredictionPool.WhitePrice(
      whitePrice: 525078986960882647 (type: uint256)
    )

    PredictionPool.BlackPrice(
      blackPrice: 475071464393179539 (type: uint256)
    )

    PredictionPool.SecondaryPoolBWPrice(
      secondaryPoolBWPrice: 1000150451354062186 (type: uint256)
    )

    IERC20.Transfer(
      from: <indexed> 0xf758B38Fc95a5c0b5F03f7930C4D6C031Fa4Bc79 (type: address),
      to: <indexed> 0x0000000000000000000000000000000000000000 (type: address),
      value: 332 (type: uint256)
    )

    IERC20.Approval(
      owner: <indexed> 0xf758B38Fc95a5c0b5F03f7930C4D6C031Fa4Bc79 (type: address),
      spender: <indexed> 0x02F9787438Ef1f40fd30256234C1Fa1A029aeeB7 (type: address),
      value: 115792089237316195423570985008687907853269984665640564039457584007913129639603 (type: uint256)
    )

    IERC20.Transfer(
      from: <indexed> 0x02F9787438Ef1f40fd30256234C1Fa1A029aeeB7 (type: address),
      to: <indexed> 0xf758B38Fc95a5c0b5F03f7930C4D6C031Fa4Bc79 (type: address),
      value: 173 (type: uint256)
    )

    PredictionPool.SellWhite(
      user: 0xf758B38Fc95a5c0b5F03f7930C4D6C031Fa4Bc79 (type: address),
      amount: 173 (type: uint256),
      price: 525078986960882647 (type: uint256)
    )

    EventLifeCycle.GameEventEnded(
      result: 1 (type: int8),
      eventId: 101 (type: uint256)
    )

GovernanceToken.sol solhint:warning

  • 13:5 warning solhint:warning Explicitly mark visibility of state state-visibility
mapping(address => uint256) balances;
  • 14:5 warning solhint:warning Explicitly mark visibility of state state-visibility
mapping(address => mapping(address => uint256)) allowed;
  • 15:5 warning solhint:warning Explicitly mark visibility of state state-visibility
uint256 totalSupply_;

  • 41:9 warning solhint:warning Provide an error message for require reason-string
require(numTokens <= balances[msg.sender]);
  • 72:9 warning solhint:warning Provide an error message for require reason-string
require(numTokens <= balances[owner]);
  • 73:9 warning solhint:warning Provide an error message for require reason-string
require(numTokens <= allowed[owner][msg.sender]);

PendingOrders.sol solhint:warning

  • 30:5 warning solhint:warning Explicitly mark visibility of state state-visibility
uint256 _collectedFee;
  • 39:5 warning solhint:warning Explicitly mark visibility of state state-visibility
// mapping from order ID to Order detail
mapping(uint256 => Order) _orders;
  • 42:5 warning solhint:warning Explicitly mark visibility of state state-visibility
// mapping from user address to order IDs for that user
mapping(address => uint256[]) _ordersOfUser;
  • 58:5 warning solhint:warning Explicitly mark visibility of state state-visibility
// mapping from event ID to detail for that event
mapping(uint256 => Detail) _detailForEvent;

  • 171:9 warning solhint:warning Possible reentrancy vulnerabilities. Avoid state changes after transfer reentrancy
order.isWhite
    ? _detailForEvent[order.eventId].whiteCollateral = _detailForEvent[order.eventId].whiteCollateral.sub(order.amount)
    : _detailForEvent[order.eventId].blackCollateral = _detailForEvent[order.eventId].blackCollateral.sub(order.amount);
  • 175:9 warning solhint:warning Possible reentrancy vulnerabilities. Avoid state changes after transfer reentrancy
_orders[orderId].isPending = false;
  • 337:9 warning solhint:warning Possible reentrancy vulnerabilities. Avoid state changes after transfer reentrancy
_collectedFee = 0;

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.