Giter Site home page Giter Site logo

oracle's People

Contributors

0xlucian avatar chechu avatar coreyar avatar debugger022 avatar gitguru7 avatar kkirka avatar narayanprusty avatar roserompkxm avatar toolsvenus avatar uravgdeveloper avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

oracle's Issues

Nitpicks for the oracle

I have reviewed the code carefully, and I'm really impressed by the code quality and consistency. @RoseRompkxm thank you for doing the great job here! Here are a couple of nitpicks I have, let's discuss them and address the issues. After that I'd say we're good to go with the audits.

1. We should handle reverts gracefully

Oracles may sometimes revert, e.g. when Chainlink drops the feeds support, they remove the implementation entirely and the call to functions like decimals() revert. Ideally, we should, ofc, monitor these events, but since we're working with external parties, sometimes things out of our control happen. I propose we handle such cases with try-catch blocks (i.e. try getting the underlying price and return INVALID_PRICE if the call reverts).

https://github.com/VenusProtocol/oracle/blob/develop/contracts/ResilientOracle.sol#L203
https://github.com/VenusProtocol/oracle/blob/develop/contracts/ResilientOracle.sol#L176

2. Incompatibilities with v0.8

These lines in PancakeLibrary suggest that the overflow is desired. However, 0.8 would throw an error in case of overflow:

// subtraction overflow is desired
uint32 timeElapsed = blockTimestamp - blockTimestampLast;
// addition overflow is desired
// counterfactual
price0Cumulative += uint(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed;
// counterfactual
price1Cumulative += uint(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed;

If the overflow is desired, let's use an unchecked { ... } block here.

3. Let SafeMath die finally?

We're using solidity >= 0.8 here, so I propose we remove the dependency on SafeMath and use arithmetic operators directly.

4. Remove ancient code

        // @TODO: This is some history code, keep it here in case of messing up 
        } else if (_compareStrings(symbol, "XVS")) {
            return prices[address(vToken)];
        }

I don't know why we have it. Do we even have a vToken with "XVS" as a symbol? getUnderlyingPrice(XVS.address) returns zero now, assetPrices(XVS.address) returns zero as well ๐Ÿคท

5. Typo :)

require(tokenConfigs[vToken].vToken != address(0), "vTokne not exist");

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.