89 lines
3.6 KiB
Plaintext
89 lines
3.6 KiB
Plaintext
pragma solidity 0.8.20;
|
|
|
|
import {Test} from "forge-std/Test.sol";
|
|
|
|
import {Fatso} from "../../src/FatsoERC20.sol";
|
|
import {GhostAuthority} from "../../src/GhostAuthority.sol";
|
|
import {GhostTreasury} from "../../src/Treasury.sol";
|
|
import {GhostBondingCalculator} from "../../src/StandardBondingCalculator.sol";
|
|
import {WETH9} from "../../src/mocks/WETH9.sol";
|
|
|
|
import {ITreasury} from "../../src/interfaces/ITreasury.sol";
|
|
import {UniswapV2Pair} from "@uniswap-v2-contracts/UniswapV2Pair.sol";
|
|
import {UniswapV2Factory} from "@uniswap-v2-contracts/UniswapV2Factory.sol";
|
|
import {UniswapV2Router} from "@uniswap-v2-contracts/UniswapV2Router.sol";
|
|
import {IERC20} from "@openzeppelin-contracts/token/ERC20/IERC20.sol";
|
|
|
|
// TODO: remove fucking old uniswap dependencies
|
|
|
|
contract GhostTreasuryCumulativePriceTest is Test {
|
|
address public constant OWNER = 0x0000000000000000000000000000000000000001;
|
|
address public constant GOVERNOR = 0x0000000000000000000000000000000000000002;
|
|
address public constant GUARDIAN = 0x0000000000000000000000000000000000000003;
|
|
address public constant ALICE = 0x0000000000000000000000000000000000000004;
|
|
|
|
uint256 public constant AMOUNT = 2000 ether;
|
|
|
|
Fatso ftso;
|
|
WETH9 weth;
|
|
UniswapV2Factory factory;
|
|
UniswapV2Router router;
|
|
GhostTreasury treasury;
|
|
GhostAuthority authority;
|
|
GhostBondingCalculator calculator;
|
|
|
|
function setUp() public {
|
|
vm.startPrank(OWNER);
|
|
authority = new GhostAuthority(GOVERNOR, GUARDIAN, OWNER, OWNER);
|
|
weth = new WETH9();
|
|
ftso = new Fatso(address(authority), "Fatso", "FTSO");
|
|
treasury = new GhostTreasury(address(ftso), address(authority));
|
|
calculator = new GhostBondingCalculator(address(ftso), 2000, 1);
|
|
factory = new UniswapV2Factory(OWNER);
|
|
router = new UniswapV2Router(address(factory), address(weth));
|
|
vm.stopPrank();
|
|
|
|
vm.startPrank(GOVERNOR);
|
|
authority.pushVault(address(treasury));
|
|
treasury.enable(ITreasury.STATUS.RESERVEDEPOSITOR, ALICE, address(0));
|
|
treasury.enable(ITreasury.STATUS.RESERVETOKEN, address(weth), address(calculator));
|
|
treasury.enable(ITreasury.STATUS.DEXROUTER, address(router), address(0));
|
|
vm.stopPrank();
|
|
|
|
vm.deal(ALICE, 4 ether);
|
|
vm.startPrank(ALICE);
|
|
weth.deposit{value: 2 ether}();
|
|
weth.approve(address(treasury), type(uint256).max);
|
|
treasury.deposit(address(weth), 1 ether, 0);
|
|
vm.stopPrank();
|
|
|
|
vm.startPrank(ALICE);
|
|
ftso.approve(address(router), type(uint256).max);
|
|
(,, uint256 liquidity) = router.addLiquidityETH{value: 1 ether}(
|
|
address(ftso), AMOUNT, AMOUNT, 1 ether, ALICE, 69
|
|
);
|
|
vm.stopPrank();
|
|
|
|
address lpToken = factory.getPair(address(ftso), address(weth));
|
|
require(lpToken != address(0), "pair not created");
|
|
|
|
vm.startPrank(GOVERNOR);
|
|
treasury.enable(ITreasury.STATUS.LIQUIDITYTOKEN, lpToken, address(calculator));
|
|
vm.stopPrank();
|
|
|
|
vm.startPrank(ALICE);
|
|
IERC20(lpToken).approve(address(treasury), type(uint256).max);
|
|
treasury.deposit(lpToken, liquidity, treasury.tokenValue(lpToken, liquidity));
|
|
vm.stopPrank();
|
|
}
|
|
|
|
function test_initialTreasuryPricingEmpty() public view {
|
|
assertEq(treasury.blockTimestampLast(), 0);
|
|
assertEq(treasury.cummulativePriceLast(), 0);
|
|
assertEq(treasury.reservesValuationPrice(), 0);
|
|
}
|
|
|
|
// TODO: after creation price should be correct but Treasury does not know anything
|
|
// TODO: change price as hard as possible, and then check the treasury cummulative
|
|
}
|