Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporary #16

Closed
wants to merge 17 commits into from
Closed
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
561 changes: 561 additions & 0 deletions certora/GSM/mutations/mutants/Gsm/Gsm.sol0 copy.sol

Large diffs are not rendered by default.

558 changes: 558 additions & 0 deletions certora/GSM/mutations/mutants/Gsm/Gsm.sol0.sol

Large diffs are not rendered by default.

561 changes: 561 additions & 0 deletions certora/GSM/mutations/mutants/Gsm/Gsm.sol1 copy.sol

Large diffs are not rendered by default.

561 changes: 561 additions & 0 deletions certora/GSM/mutations/mutants/Gsm/Gsm.sol1.sol

Large diffs are not rendered by default.

561 changes: 561 additions & 0 deletions certora/GSM/mutations/mutants/Gsm/Gsm.sol2 copy.sol

Large diffs are not rendered by default.

561 changes: 561 additions & 0 deletions certora/GSM/mutations/mutants/Gsm/Gsm.sol2.sol

Large diffs are not rendered by default.

561 changes: 561 additions & 0 deletions certora/GSM/mutations/mutants/Gsm/Gsm.sol3 copy.sol

Large diffs are not rendered by default.

561 changes: 561 additions & 0 deletions certora/GSM/mutations/mutants/Gsm/Gsm.sol3.sol

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;

import {Math} from '@openzeppelin/contracts/utils/math/Math.sol';
import {PercentageMath} from '@aave/core-v3/contracts/protocol/libraries/math/PercentageMath.sol';
import {IGsmFeeStrategy} from './interfaces/IGsmFeeStrategy.sol';

/**
* @title FixedFeeStrategy
* @author Aave
* @notice Fee strategy using a fixed rate to calculate buy/sell fees
*/
contract FixedFeeStrategy is IGsmFeeStrategy {
using Math for uint256;

uint256 internal immutable _buyFee;
uint256 internal immutable _sellFee;

/**
* @dev Constructor
* @dev Fees must be lower than 5000 bps (e.g. 50.00%)
* @param buyFee The fee paid when buying the underlying asset in exchange for GHO, expressed in bps
* @param sellFee The fee paid when selling the underlying asset in exchange for GHO, expressed in bps
*/
constructor(uint256 buyFee, uint256 sellFee) {
require(buyFee < 5000, 'INVALID_BUY_FEE');
require(sellFee < 5000, 'INVALID_SELL_FEE');
require(buyFee > 0 || sellFee > 0, 'MUST_HAVE_ONE_NONZERO_FEE');
_buyFee = buyFee;
_sellFee = sellFee;
}

/// @inheritdoc IGsmFeeStrategy
function getBuyFee(uint256 grossAmount) external view returns (uint256) {
return grossAmount.mulDiv(_buyFee, PercentageMath.PERCENTAGE_FACTOR, Math.Rounding.Up);
}

/// @inheritdoc IGsmFeeStrategy
function getSellFee(uint256 grossAmount) external view returns (uint256) {
return grossAmount.mulDiv(_sellFee, PercentageMath.PERCENTAGE_FACTOR, Math.Rounding.Up);
}

/// @inheritdoc IGsmFeeStrategy
function getGrossAmountFromTotalBought(uint256 totalAmount) external view returns (uint256) {
if (totalAmount == 0) {
return 0;
} else if (_buyFee == 0) {
return totalAmount;
} else {
return
/// FunctionCallMutation of: totalAmount.mulDiv(
PercentageMath.PERCENTAGE_FACTOR;
}
}

/// @inheritdoc IGsmFeeStrategy
function getGrossAmountFromTotalSold(uint256 totalAmount) external view returns (uint256) {
if (totalAmount == 0) {
return 0;
} else if (_sellFee == 0) {
return totalAmount;
} else {
return
totalAmount.mulDiv(
PercentageMath.PERCENTAGE_FACTOR,
PercentageMath.PERCENTAGE_FACTOR - _sellFee,
Math.Rounding.Up
);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;

import {Math} from '@openzeppelin/contracts/utils/math/Math.sol';
import {PercentageMath} from '@aave/core-v3/contracts/protocol/libraries/math/PercentageMath.sol';
import {IGsmFeeStrategy} from './interfaces/IGsmFeeStrategy.sol';

/**
* @title FixedFeeStrategy
* @author Aave
* @notice Fee strategy using a fixed rate to calculate buy/sell fees
*/
contract FixedFeeStrategy is IGsmFeeStrategy {
using Math for uint256;

uint256 internal immutable _buyFee;
uint256 internal immutable _sellFee;

/**
* @dev Constructor
* @dev Fees must be lower than 5000 bps (e.g. 50.00%)
* @param buyFee The fee paid when buying the underlying asset in exchange for GHO, expressed in bps
* @param sellFee The fee paid when selling the underlying asset in exchange for GHO, expressed in bps
*/
constructor(uint256 buyFee, uint256 sellFee) {
require(buyFee < 5000, 'INVALID_BUY_FEE');
require(sellFee < 5000, 'INVALID_SELL_FEE');
require(buyFee > 0 || sellFee > 0, 'MUST_HAVE_ONE_NONZERO_FEE');
_buyFee = buyFee;
_sellFee = sellFee;
}

/// @inheritdoc IGsmFeeStrategy
function getBuyFee(uint256 grossAmount) external view returns (uint256) {
return grossAmount.mulDiv(_buyFee, PercentageMath.PERCENTAGE_FACTOR, Math.Rounding.Up);
}

/// @inheritdoc IGsmFeeStrategy
function getSellFee(uint256 grossAmount) external view returns (uint256) {
return grossAmount.mulDiv(_sellFee, PercentageMath.PERCENTAGE_FACTOR, Math.Rounding.Up);
}

/// @inheritdoc IGsmFeeStrategy
function getGrossAmountFromTotalBought(uint256 totalAmount) external view returns (uint256) {
if (totalAmount == 0) {
return 0;
} else if (_buyFee == 0) {
return totalAmount;
} else {
return
totalAmount.mulDiv(
PercentageMath.PERCENTAGE_FACTOR,
/// BinaryOpMutation of: PercentageMath.PERCENTAGE_FACTOR + _buyFee,
PercentageMath.PERCENTAGE_FACTOR / _buyFee,
Math.Rounding.Down
);
}
}

/// @inheritdoc IGsmFeeStrategy
function getGrossAmountFromTotalSold(uint256 totalAmount) external view returns (uint256) {
if (totalAmount == 0) {
return 0;
} else if (_sellFee == 0) {
return totalAmount;
} else {
return
totalAmount.mulDiv(
PercentageMath.PERCENTAGE_FACTOR,
PercentageMath.PERCENTAGE_FACTOR - _sellFee,
Math.Rounding.Up
);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;

import {Math} from '@openzeppelin/contracts/utils/math/Math.sol';
import {PercentageMath} from '@aave/core-v3/contracts/protocol/libraries/math/PercentageMath.sol';
import {IGsmFeeStrategy} from './interfaces/IGsmFeeStrategy.sol';

/**
* @title FixedFeeStrategy
* @author Aave
* @notice Fee strategy using a fixed rate to calculate buy/sell fees
*/
contract FixedFeeStrategy is IGsmFeeStrategy {
using Math for uint256;

uint256 internal immutable _buyFee;
uint256 internal immutable _sellFee;

/**
* @dev Constructor
* @dev Fees must be lower than 5000 bps (e.g. 50.00%)
* @param buyFee The fee paid when buying the underlying asset in exchange for GHO, expressed in bps
* @param sellFee The fee paid when selling the underlying asset in exchange for GHO, expressed in bps
*/
constructor(uint256 buyFee, uint256 sellFee) {
require(buyFee < 5000, 'INVALID_BUY_FEE');
require(sellFee < 5000, 'INVALID_SELL_FEE');
require(buyFee > 0 || sellFee > 0, 'MUST_HAVE_ONE_NONZERO_FEE');
_buyFee = buyFee;
_sellFee = sellFee;
}

/// @inheritdoc IGsmFeeStrategy
function getBuyFee(uint256 grossAmount) external view returns (uint256) {
return grossAmount.mulDiv(_buyFee, PercentageMath.PERCENTAGE_FACTOR, Math.Rounding.Up);
}

/// @inheritdoc IGsmFeeStrategy
function getSellFee(uint256 grossAmount) external view returns (uint256) {
return grossAmount.mulDiv(_sellFee, PercentageMath.PERCENTAGE_FACTOR, Math.Rounding.Up);
}

/// @inheritdoc IGsmFeeStrategy
function getGrossAmountFromTotalBought(uint256 totalAmount) external view returns (uint256) {
/// IfStatementMutation of: if (totalAmount == 0) {
if (!(totalAmount == 0)) {
return 0;
} else if (_buyFee == 0) {
return totalAmount;
} else {
return
totalAmount.mulDiv(
PercentageMath.PERCENTAGE_FACTOR,
PercentageMath.PERCENTAGE_FACTOR + _buyFee,
Math.Rounding.Down
);
}
}

/// @inheritdoc IGsmFeeStrategy
function getGrossAmountFromTotalSold(uint256 totalAmount) external view returns (uint256) {
if (totalAmount == 0) {
return 0;
} else if (_sellFee == 0) {
return totalAmount;
} else {
return
totalAmount.mulDiv(
PercentageMath.PERCENTAGE_FACTOR,
PercentageMath.PERCENTAGE_FACTOR - _sellFee,
Math.Rounding.Up
);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;

import {Math} from '@openzeppelin/contracts/utils/math/Math.sol';
import {PercentageMath} from '@aave/core-v3/contracts/protocol/libraries/math/PercentageMath.sol';
import {IGsmFeeStrategy} from './interfaces/IGsmFeeStrategy.sol';

/**
* @title FixedFeeStrategy
* @author Aave
* @notice Fee strategy using a fixed rate to calculate buy/sell fees
*/
contract FixedFeeStrategy is IGsmFeeStrategy {
using Math for uint256;

uint256 internal immutable _buyFee;
uint256 internal immutable _sellFee;

/**
* @dev Constructor
* @dev Fees must be lower than 5000 bps (e.g. 50.00%)
* @param buyFee The fee paid when buying the underlying asset in exchange for GHO, expressed in bps
* @param sellFee The fee paid when selling the underlying asset in exchange for GHO, expressed in bps
*/
constructor(uint256 buyFee, uint256 sellFee) {
require(buyFee < 5000, 'INVALID_BUY_FEE');
require(sellFee < 5000, 'INVALID_SELL_FEE');
require(buyFee > 0 || sellFee > 0, 'MUST_HAVE_ONE_NONZERO_FEE');
_buyFee = buyFee;
_sellFee = sellFee;
}

/// @inheritdoc IGsmFeeStrategy
function getBuyFee(uint256 grossAmount) external view returns (uint256) {
return grossAmount.mulDiv(_buyFee, PercentageMath.PERCENTAGE_FACTOR, Math.Rounding.Up);
}

/// @inheritdoc IGsmFeeStrategy
function getSellFee(uint256 grossAmount) external view returns (uint256) {
return grossAmount.mulDiv(_sellFee, PercentageMath.PERCENTAGE_FACTOR, Math.Rounding.Up);
}

/// @inheritdoc IGsmFeeStrategy
function getGrossAmountFromTotalBought(uint256 totalAmount) external view returns (uint256) {
if (totalAmount == 0) {
return 0;
} else if (_buyFee == 0) {
return totalAmount;
} else {
return
totalAmount.mulDiv(
PercentageMath.PERCENTAGE_FACTOR,
PercentageMath.PERCENTAGE_FACTOR + _buyFee,
Math.Rounding.Down
);
}
}

/// @inheritdoc IGsmFeeStrategy
function getGrossAmountFromTotalSold(uint256 totalAmount) external view returns (uint256) {
if (totalAmount == 0) {
return 0;
} else if (_sellFee == 0) {
return totalAmount;
} else {
return
totalAmount.mulDiv(
PercentageMath.PERCENTAGE_FACTOR,
/// BinaryOpMutation of: PercentageMath.PERCENTAGE_FACTOR - _sellFee,
PercentageMath.PERCENTAGE_FACTOR + _sellFee,
Math.Rounding.Up
);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;

import {Math} from '@openzeppelin/contracts/utils/math/Math.sol';
import {IGsmPriceStrategy} from './interfaces/IGsmPriceStrategy.sol';

/**
* @title FixedPriceStrategy
* @author Aave
* @notice Price strategy involving a fixed-rate conversion from an underlying asset to GHO
*/
contract FixedPriceStrategy is IGsmPriceStrategy {
using Math for uint256;

/// @inheritdoc IGsmPriceStrategy
uint256 public constant GHO_DECIMALS = 18;

/// @inheritdoc IGsmPriceStrategy
address public immutable UNDERLYING_ASSET;

/// @inheritdoc IGsmPriceStrategy
uint256 public immutable UNDERLYING_ASSET_DECIMALS;

/// @dev The price ratio from underlying asset to GHO (expressed in WAD), e.g. a ratio of 2e18 means 2 GHO per 1 underlying asset
uint256 public immutable PRICE_RATIO;

/// @dev Underlying asset units represent units for the underlying asset
uint256 internal immutable _underlyingAssetUnits;

/**
* @dev Constructor
* @param priceRatio The price ratio from underlying asset to GHO (expressed in WAD)
* @param underlyingAsset The address of the underlying asset
* @param underlyingAssetDecimals The number of decimals of the underlying asset
*/
constructor(uint256 priceRatio, address underlyingAsset, uint8 underlyingAssetDecimals) {
require(priceRatio > 0, 'INVALID_PRICE_RATIO');
PRICE_RATIO = priceRatio;
UNDERLYING_ASSET = underlyingAsset;
UNDERLYING_ASSET_DECIMALS = underlyingAssetDecimals;
/// AssignmentMutation of: _underlyingAssetUnits = 10 ** underlyingAssetDecimals;
_underlyingAssetUnits = 1;
}

/// @inheritdoc IGsmPriceStrategy
function getAssetPriceInGho(uint256 assetAmount, bool roundUp) external view returns (uint256) {
return
assetAmount.mulDiv(
PRICE_RATIO,
_underlyingAssetUnits,
roundUp ? Math.Rounding.Up : Math.Rounding.Down
);
}

/// @inheritdoc IGsmPriceStrategy
function getGhoPriceInAsset(uint256 ghoAmount, bool roundUp) external view returns (uint256) {
return
ghoAmount.mulDiv(
_underlyingAssetUnits,
PRICE_RATIO,
roundUp ? Math.Rounding.Up : Math.Rounding.Down
);
}
}
Loading
Loading