Skip to content

Instantly share code, notes, and snippets.

@Falilah
Last active January 15, 2024 22:12
Show Gist options
  • Save Falilah/9a1197956c8e6240c9629553acc2e127 to your computer and use it in GitHub Desktop.
Save Falilah/9a1197956c8e6240c9629553acc2e127 to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.7;
import {Test, console2} from "forge-std/Test.sol";
import {Curves} from "../contracts/Curves.sol";
import {FeeSplitter} from "../contracts/FeeSplitter.sol";
import {CurvesERC20Factory} from "../contracts/CurvesERC20Factory.sol";
contract testCurve is Test {
FeeSplitter feespliter;
CurvesERC20Factory factory;
Curves curves;
address owner = makeAddr("owner");
address user1 = makeAddr("user1");
function setUp() external {
feespliter = new FeeSplitter();
factory = new CurvesERC20Factory();
curves = new Curves(address(factory), address(feespliter));
vm.deal(owner, 20 ether);
vm.deal(user1, 20 ether);
}
function testEthstuckinCurveContract() public {
vm.prank(owner);
//tokensubject no fee for buying 1 token first
curves.buyCurvesToken(owner, 1);
uint pricewithFee = curves.getBuyPriceAfterFee(owner, 50);
console2.log("user paid for 50 curveTokens", pricewithFee);
// user buycurveToken before all necessary fee parameters are set
vm.prank(user1);
curves.buyCurvesToken{value: pricewithFee}(owner, 50);
//check curve.sol contract balance
uint priceAndFee = address(curves).balance;
console2.log(
"curve.sol balance after purchase is the same as the totalprice paid by users",
address(curves).balance
);
//assert the total money paid by user1 is stucked in curve.sol
assertEq(pricewithFee, priceAndFee);
vm.prank(user1);
curves.sellCurvesToken(owner, 50);
uint priceAndFee2 = address(curves).balance;
console2.log(
"curve.sol balance after sellcurvetoken was interracted with which makes the user not to pay any fee",
priceAndFee2
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment