Uncle Fatso 2026-10-12 12:44:54 +03:00
parent 1359f920ca
commit 479755d96a
Signed by: f4ts0
GPG Key ID: 565F4F2860226EBB
2 changed files with 13 additions and 9 deletions

View File

@ -25,9 +25,7 @@ contract GhostTreasury is GhostAccessControlled, ITreasury {
using EnumerableSet for EnumerableSet.AddressSet;
address public immutable FTSO;
uint256 public totalReserves;
uint256 public totalDebt;
mapping(STATUS => EnumerableSet.AddressSet) private _registry;
mapping(STATUS => mapping(address => bool)) private _permissions;
@ -62,9 +60,10 @@ contract GhostTreasury is GhostAccessControlled, ITreasury {
function mint(address recipient, uint256 amount) external override {
if (!_permissions[STATUS.REWARDMANAGER][msg.sender]) revert NotApproved();
if (amount > excessReserves()) revert InsufficientReserves();
IFTSO(FTSO).mint(recipient, amount);
emit Minted(msg.sender, recipient, amount);
if (amount <= excessReserves()) {
IFTSO(FTSO).mint(recipient, amount);
emit Minted(msg.sender, recipient, amount);
}
}
function withdraw(address token, uint256 amount) external onlyGovernor override {
@ -90,8 +89,9 @@ contract GhostTreasury is GhostAccessControlled, ITreasury {
gasValue = tokenValue(reserveToken, gasSpent);
gasValue = FullMath.mulDiv(gasValue, totalSupply, totalReserves);
if (gasValue > excessReserves()) revert InsufficientReserves();
IFTSO(FTSO).mint(msg.sender, gasValue);
if (gasValue <= excessReserves()) {
IFTSO(FTSO).mint(msg.sender, gasValue);
}
}
function buyBack(
@ -257,7 +257,12 @@ contract GhostTreasury is GhostAccessControlled, ITreasury {
}
function excessReserves() public view override returns (uint256) {
return totalReserves - (IFTSO(FTSO).totalSupply() - totalDebt);
uint256 ftsoSupply = IFTSO(FTSO).totalSupply();
uint256 currentTotalReserves = totalReserves;
return currentTotalReserves > ftsoSupply
? currentTotalReserves - ftsoSupply
: 0;
}
function tokenValue(

View File

@ -6,7 +6,6 @@ interface ITreasury {
error NotAccepted();
error InvalidToken();
error GasExceedsBounty();
error InsufficientReserves();
enum STATUS {
RESERVEDEPOSITOR,