Git Product home page Git Product logo

Comments (6)

0xClandestine avatar 0xClandestine commented on June 18, 2024

Wouldn't hurt to add complementWad as well:

function complementWad(uint256 x) internal pure returns (uint256 result) {
    assembly {
        result := mul(lt(x, WAD), sub(WAD, x))
    }
}

from solady.

0xClandestine avatar 0xClandestine commented on June 18, 2024

powWad(uint256, uint256) could also be added to FixedPointMathLib

from solady.

Vectorized avatar Vectorized commented on June 18, 2024

I think let's leave it as powWad(int256 x, int256 y).

from solady.

0xClandestine avatar 0xClandestine commented on June 18, 2024

@Vectorized All of this is inspired by Balancer v2 arithmetic:

Complement reference:
https://github.com/balancer/balancer-v2-monorepo/blob/bc3b3fee6e13e01d2efe610ed8118fdb74dfc1f2/pkg/solidity-utils/contracts/math/FixedPoint.sol#L156

Furthermore, for powWad we only need to ensure that the signed integers (params) are greater than zero. Although my main issue is with the return value, which requires me to check that result > 0. So tbh its not a huge issue.

from solady.

0xClandestine avatar 0xClandestine commented on June 18, 2024

I think let's leave it as powWad(int256 x, int256 y).

powWad(int256, int256) -> (uint256) could be a happy median

from solady.

Vectorized avatar Vectorized commented on June 18, 2024

I think I'll let the people who need powWad and wadComplement copy paste from balancer.

Licensing issue, and high risk of edge cases unaccounted for.

from solady.

Related Issues (20)

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.