Compare commits

..

No commits in common. "5e3454b502694786d67af5e13e192e3a852c51f2" and "1359f920ca69d0ff401155662b05d292070c7e61" have entirely different histories.

4 changed files with 10 additions and 21 deletions

View File

@ -161,11 +161,6 @@ contract GhostBondDepository is IBondDepository, NoteKeeper {
msg.sender != IGhostAuthority(AUTHORITY).policy() msg.sender != IGhostAuthority(AUTHORITY).policy()
) revert NotGuardianOrPolicy(); ) revert NotGuardianOrPolicy();
if (
!ITreasury(TREASURY).registered(ITreasury.STATUS.RESERVETOKEN, _quoteToken) &&
!ITreasury(TREASURY).registered(ITreasury.STATUS.LIQUIDITYTOKEN, _quoteToken)
) revert NonPermissionedToken();
uint256 secondsToConclusion = _terms[1] - block.timestamp; uint256 secondsToConclusion = _terms[1] - block.timestamp;
uint256 decimals = IERC20Metadata(_quoteToken).decimals(); uint256 decimals = IERC20Metadata(_quoteToken).decimals();
uint64 targetDebt = uint64(_booleans[0] uint64 targetDebt = uint64(_booleans[0]

View File

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

View File

@ -6,7 +6,6 @@ interface IBondDepository {
error DepositoryMaxPrice(uint256 price, uint256 maxPrice); error DepositoryMaxPrice(uint256 price, uint256 maxPrice);
error DepositoryMaxSize(uint256 payout, uint256 maxPayout); error DepositoryMaxSize(uint256 payout, uint256 maxPayout);
error NotGuardianOrPolicy(); error NotGuardianOrPolicy();
error NonPermissionedToken();
event MarketClosed(uint256 indexed id); event MarketClosed(uint256 indexed id);
event Bond(uint256 indexed id, uint256 amount, uint256 price); event Bond(uint256 indexed id, uint256 amount, uint256 price);

View File

@ -6,6 +6,7 @@ interface ITreasury {
error NotAccepted(); error NotAccepted();
error InvalidToken(); error InvalidToken();
error GasExceedsBounty(); error GasExceedsBounty();
error InsufficientReserves();
enum STATUS { enum STATUS {
RESERVEDEPOSITOR, RESERVEDEPOSITOR,
@ -28,7 +29,6 @@ interface ITreasury {
uint256 _profit uint256 _profit
) external returns (uint256); ) external returns (uint256);
function registered(STATUS status, address token) external view returns(bool);
function phantomRefund(uint256 gasSpent, uint256 amount) external returns (uint256); function phantomRefund(uint256 gasSpent, uint256 amount) external returns (uint256);
function buyBack(address receiver, uint256 amount, uint256 index) external returns (address, uint256); function buyBack(address receiver, uint256 amount, uint256 index) external returns (address, uint256);
function withdraw(address token, uint256 amount) external; function withdraw(address token, uint256 amount) external;