diff --git a/flake.nix b/flake.nix index 6462f98b5..41f94c930 100644 --- a/flake.nix +++ b/flake.nix @@ -16,8 +16,10 @@ in { devShell = with pkgs; mkShell { + SOLHINT_PATH = "$HOME/.solhint.json"; SOLC_VERSION = "0.8.15"; - buildInputs = [ foundry.defaultPackage.${system} solc-select yarn ]; + buildInputs = + [ foundry.defaultPackage.${system} solc-select yarn nodejs-14_x ]; shellHook = '' solc-select install $SOLC_VERSION ''; diff --git a/test/YieldSpaceMath.t.sol b/test/YieldSpaceMath.t.sol new file mode 100644 index 000000000..d271a9a9c --- /dev/null +++ b/test/YieldSpaceMath.t.sol @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: Apache-2.0 +pragma solidity ^0.8.13; + +import { Test } from "forge-std/Test.sol"; +import { YieldSpaceMath } from "contracts/libraries/YieldSpaceMath.sol"; + +contract YieldSpaceMathTest is Test { + function test__calculateOutGivenIn_1() public { + assertEq( + YieldSpaceMath.calculateOutGivenIn( + 56.79314253e18, // shareReserves + 62.38101813e18, // bondReserves + 119.1741606776616e18, // bondReserveAdjustment + 5.03176076e18, // amountOut + 0.08065076081220067e18, // t + 1e18, // s + 1e18, // c + 1e18, // mu + true // isBondIn + ), + 5.500250311701939082e18 + ); + } + + function test__calculateOutGivenIn_2() public { + assertEq( + YieldSpaceMath.calculateOutGivenIn( + 61.824903300361854e18, // shareReserves + 56.92761678068477e18, // bondReserves + 119.1741606776616e18, // bondReserveAdjustment + 5.500250311701939e18, // amountOut + 0.08065076081220067e18, // t + 1e18, // s + 1e18, // c + 1e18, // mu + false // isBondIn + ), + 5.031654806080805188e18 + ); + } +}