Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
'';
Expand Down
41 changes: 41 additions & 0 deletions test/YieldSpaceMath.t.sol
Original file line number Diff line number Diff line change
@@ -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
);
}
}