Skip to content

Commit

Permalink
Fix prettierrc file, re-run prettier on .sol files in protocol dir
Browse files Browse the repository at this point in the history
  • Loading branch information
pizzaman1337 committed Jul 24, 2024
1 parent e52e3b4 commit b43873a
Show file tree
Hide file tree
Showing 40 changed files with 541 additions and 1,774 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ node_modules
# Local Netlify folder
.netlify

<<<<<<< HEAD
# forge libraries.
protocol/lib/
=======
>>>>>>> master

9 changes: 1 addition & 8 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
"singleQuote": false,
"semi": true,
"trailingComma": "none",
<<<<<<< HEAD

"plugins": ["prettier-plugin-solidity"],
"overrides": [
{
Expand All @@ -17,11 +15,7 @@
"singleQuote": false,
"bracketSpacing": false
}
}
]
}
=======
"overrides": [
},
{
"files": "projects/subgraph-*/**",
"options": {
Expand All @@ -30,4 +24,3 @@
}
]
}
>>>>>>> master
87 changes: 20 additions & 67 deletions protocol/contracts/beanstalk/barn/UnripeFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,12 @@ contract UnripeFacet is Invariable, ReentrancyGuard {
* @param token The Unripe Token to change the Ripe Token of.
* @param underlyingToken The new Ripe Token.
*/
event SwitchUnderlyingToken(
address indexed token,
address indexed underlyingToken
);
event SwitchUnderlyingToken(address indexed token, address indexed underlyingToken);

/**
* @notice emitted when a Farmer Chops.
*/
event Chop(
address indexed account,
address indexed token,
uint256 amount,
uint256 underlying
);
event Chop(address indexed account, address indexed token, uint256 amount, uint256 underlying);

/**
* @notice emitted when a user `picks`.
Expand All @@ -92,12 +84,7 @@ contract UnripeFacet is Invariable, ReentrancyGuard {
) external payable fundsSafu noSupplyChange nonReentrant returns (uint256) {
// burn the token from the user address
uint256 supply = IBean(unripeToken).totalSupply();
amount = LibTransfer.burnToken(
IBean(unripeToken),
amount,
LibTractor._user(),
fromMode
);
amount = LibTransfer.burnToken(IBean(unripeToken), amount, LibTractor._user(), fromMode);
// get ripe address and ripe amount
(address underlyingToken, uint256 underlyingAmount) = LibChop.chop(
unripeToken,
Expand All @@ -106,11 +93,7 @@ contract UnripeFacet is Invariable, ReentrancyGuard {
);
// send the corresponding amount of ripe token to the user address
require(underlyingAmount > 0, "Chop: no underlying");
IERC20(underlyingToken).sendToken(
underlyingAmount,
LibTractor._user(),
toMode
);
IERC20(underlyingToken).sendToken(underlyingAmount, LibTractor._user(), toMode);
// emit the event
emit Chop(LibTractor._user(), unripeToken, amount, underlyingAmount);
return underlyingAmount;
Expand All @@ -129,22 +112,15 @@ contract UnripeFacet is Invariable, ReentrancyGuard {
address unripeToken,
uint256 amount
) public view returns (uint256 underlyingAmount) {
return
LibUnripe.unripeToUnderlying(
unripeToken,
amount,
IBean(unripeToken).totalSupply()
);
return LibUnripe.unripeToUnderlying(unripeToken, amount, IBean(unripeToken).totalSupply());
}

/**
* @notice Getter function to get the corresponding penalty associated with an unripe asset.
* @param unripeToken The address of the unripe token.
* @return penalty The current penalty for converting unripe --> ripe
*/
function getPenalty(
address unripeToken
) external view returns (uint256 penalty) {
function getPenalty(address unripeToken) external view returns (uint256 penalty) {
return getPenalizedUnderlying(unripeToken, LibUnripe.DECIMALS);
}

Expand Down Expand Up @@ -195,8 +171,7 @@ contract UnripeFacet is Invariable, ReentrancyGuard {
address unripeToken,
address account
) external view returns (uint256 underlying) {
return
getUnderlying(unripeToken, IERC20(unripeToken).balanceOf(account));
return getUnderlying(unripeToken, IERC20(unripeToken).balanceOf(account));
}

/**
Expand All @@ -209,21 +184,15 @@ contract UnripeFacet is Invariable, ReentrancyGuard {
address unripeToken,
address account
) external view returns (uint256 underlying) {
return
getPenalizedUnderlying(
unripeToken,
IERC20(unripeToken).balanceOf(account)
);
return getPenalizedUnderlying(unripeToken, IERC20(unripeToken).balanceOf(account));
}

/**
* @notice Returns the % of Ripe Tokens that have been recapiatlized for a given Unripe Token.
* @param unripeToken The address of the Unripe Token.
* @return percent The recap % of the token.
*/
function getRecapFundedPercent(
address unripeToken
) public view returns (uint256 percent) {
function getRecapFundedPercent(address unripeToken) public view returns (uint256 percent) {
if (unripeToken == C.UNRIPE_BEAN) {
return LibUnripe.percentBeansRecapped();
} else if (unripeToken == C.UNRIPE_LP) {
Expand All @@ -237,13 +206,8 @@ contract UnripeFacet is Invariable, ReentrancyGuard {
* @param unripeToken The address of the Unripe Token.
* @return penalty The penalty % of Chopping.
*/
function getPercentPenalty(
address unripeToken
) external view returns (uint256 penalty) {
return
LibUnripe.getRecapPaidPercentAmount(
getRecapFundedPercent(unripeToken)
);
function getPercentPenalty(address unripeToken) external view returns (uint256 penalty) {
return LibUnripe.getRecapPaidPercentAmount(getRecapFundedPercent(unripeToken));
}

/**
Expand Down Expand Up @@ -277,9 +241,7 @@ contract UnripeFacet is Invariable, ReentrancyGuard {
* @param unripeToken The address of the unripe token.
* @return underlying The total balance of the token.
*/
function getTotalUnderlying(
address unripeToken
) external view returns (uint256 underlying) {
function getTotalUnderlying(address unripeToken) external view returns (uint256 underlying) {
return s.sys.silo.unripeSettings[unripeToken].balanceOfUnderlying;
}

Expand All @@ -295,11 +257,7 @@ contract UnripeFacet is Invariable, ReentrancyGuard {
bytes32 root
) external payable fundsSafu noNetFlow noSupplyChange nonReentrant {
LibDiamond.enforceIsOwnerOrContract();
s
.sys
.silo
.unripeSettings[unripeToken]
.underlyingToken = underlyingToken;
s.sys.silo.unripeSettings[unripeToken].underlyingToken = underlyingToken;
emit AddUnripeToken(unripeToken, underlyingToken, root);
}

Expand Down Expand Up @@ -328,8 +286,11 @@ contract UnripeFacet is Invariable, ReentrancyGuard {
uint256 amount
) external payable fundsSafu noNetFlow noSupplyChange nonReentrant {
LibDiamond.enforceIsContractOwner();
IERC20(s.sys.silo.unripeSettings[unripeToken].underlyingToken)
.safeTransferFrom(LibTractor._user(), address(this), amount);
IERC20(s.sys.silo.unripeSettings[unripeToken].underlyingToken).safeTransferFrom(
LibTractor._user(),
address(this),
amount
);
LibUnripe.incrementUnderlying(unripeToken, amount);
}

Expand Down Expand Up @@ -366,11 +327,7 @@ contract UnripeFacet is Invariable, ReentrancyGuard {
/**
* @notice Returns the number of Beans that are locked underneath the Unripe Bean token.
*/
function getLockedBeansUnderlyingUnripeBean()
external
view
returns (uint256)
{
function getLockedBeansUnderlyingUnripeBean() external view returns (uint256) {
return
LibLockedUnderlying.getLockedUnderlying(
C.UNRIPE_BEAN,
Expand All @@ -381,11 +338,7 @@ contract UnripeFacet is Invariable, ReentrancyGuard {
/**
* @notice Returns the number of Beans that are locked underneath the Unripe LP Token.
*/
function getLockedBeansUnderlyingUnripeLP()
external
view
returns (uint256)
{
function getLockedBeansUnderlyingUnripeLP() external view returns (uint256) {
uint256[] memory twaReserves = LibWell.getTwaReservesFromPump(
LibBarnRaise.getBarnRaiseWell()
);
Expand Down
39 changes: 8 additions & 31 deletions protocol/contracts/beanstalk/market/MarketplaceFacet/Order.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,15 @@ contract Order is Listing {
uint256 beanAmount
) internal returns (bytes32 id) {
require(beanAmount > 0, "Marketplace: Order amount must be > 0.");
require(
podOrder.pricePerPod > 0,
"Marketplace: Pod price must be greater than 0."
);
require(podOrder.pricePerPod > 0, "Marketplace: Pod price must be greater than 0.");
require(
podOrder.minFillAmount > 0,
"Marketplace: Minimum fill amount must be greater than 0."
);

id = _getOrderId(podOrder);

if (s.sys.podOrders[id] > 0)
_cancelPodOrder(podOrder, LibTransfer.To.INTERNAL);
if (s.sys.podOrders[id] > 0) _cancelPodOrder(podOrder, LibTransfer.To.INTERNAL);
s.sys.podOrders[id] = beanAmount;

emit PodOrderCreated(
Expand Down Expand Up @@ -97,26 +93,19 @@ contract Order is Listing {
"Marketplace: Fill must be >= minimum amount."
);
require(
s.accts[filler].fields[podOrder.fieldId].plots[index] >=
(start + podAmount),
s.accts[filler].fields[podOrder.fieldId].plots[index] >= (start + podAmount),
"Marketplace: Invalid Plot."
);
require(
(index +
start +
podAmount -
s.sys.fields[podOrder.fieldId].harvestable) <=
(index + start + podAmount - s.sys.fields[podOrder.fieldId].harvestable) <=
podOrder.maxPlaceInLine,
"Marketplace: Plot too far in line."
);

bytes32 id = _getOrderId(podOrder);

uint256 costInBeans = (podAmount * podOrder.pricePerPod) / 1000000;
require(
costInBeans <= s.sys.podOrders[id],
"Marketplace: Not enough beans in order."
);
require(costInBeans <= s.sys.podOrders[id], "Marketplace: Not enough beans in order.");
s.sys.podOrders[id] = s.sys.podOrders[id] - costInBeans;

LibTransfer.sendToken(C.bean(), costInBeans, filler, mode);
Expand All @@ -125,14 +114,7 @@ contract Order is Listing {
LibMarket._cancelPodListing(filler, podOrder.fieldId, index);
}

_transferPlot(
filler,
podOrder.orderer,
podOrder.fieldId,
index,
start,
podAmount
);
_transferPlot(filler, podOrder.orderer, podOrder.fieldId, index, start, podAmount);

if (s.sys.podOrders[id] == 0) {
delete s.sys.podOrders[id];
Expand All @@ -153,10 +135,7 @@ contract Order is Listing {
/*
* Cancel
*/
function _cancelPodOrder(
PodOrder memory podOrder,
LibTransfer.To mode
) internal {
function _cancelPodOrder(PodOrder memory podOrder, LibTransfer.To mode) internal {
bytes32 id = _getOrderId(podOrder);
uint256 amountBeans = s.sys.podOrders[id];
LibTransfer.sendToken(C.bean(), amountBeans, podOrder.orderer, mode);
Expand All @@ -168,9 +147,7 @@ contract Order is Listing {
* Get
*/

function _getOrderId(
PodOrder memory podOrder
) internal pure returns (bytes32 id) {
function _getOrderId(PodOrder memory podOrder) internal pure returns (bytes32 id) {
return
keccak256(
abi.encodePacked(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,7 @@ contract PodTransfer is ReentrancyGuard {
emit PlotTransfer(from, to, index + start, amount);
}

function insertPlot(
address account,
uint256 fieldId,
uint256 index,
uint256 amount
) internal {
function insertPlot(address account, uint256 fieldId, uint256 index, uint256 amount) internal {
s.accts[account].fields[fieldId].plots[index] = amount;
s.accts[account].fields[fieldId].plotIndexes.push(index);
}
Expand All @@ -76,8 +71,7 @@ contract PodTransfer is ReentrancyGuard {
uint256 start,
uint256 end
) internal {
uint256 amountAfterEnd = s.accts[account].fields[fieldId].plots[index] -
end;
uint256 amountAfterEnd = s.accts[account].fields[fieldId].plots[index] - end;

if (start > 0) {
s.accts[account].fields[fieldId].plots[index] = start;
Expand Down
3 changes: 1 addition & 2 deletions protocol/contracts/beanstalk/metadata/MetadataFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ contract MetadataFacet is MetadataImage {
// 1) a token in the silo whitelist (by checking milestone season)
// 2) a stem that is less than or equal to the stem tip
require(
s.sys.silo.assetSettings[token].milestoneSeason != 0 &&
stemTip >= stem,
s.sys.silo.assetSettings[token].milestoneSeason != 0 && stemTip >= stem,
"Silo: metadata does not exist"
);
bytes memory attributes = abi.encodePacked(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@ library LibTokenApprove {
uint256 amount
);

function approve(
address account,
address spender,
IERC20 token,
uint256 amount
) internal {
function approve(address account, address spender, IERC20 token, uint256 amount) internal {
AppStorage storage s = LibAppStorage.diamondStorage();
s.a[account].tokenAllowances[spender][token] = amount;
emit TokenApproval(account, spender, token, amount);
Expand All @@ -38,18 +33,10 @@ library LibTokenApprove {
return s.a[account].tokenAllowances[spender][token];
}

function spendAllowance(
address owner,
address spender,
IERC20 token,
uint256 amount
) internal {
function spendAllowance(address owner, address spender, IERC20 token, uint256 amount) internal {
uint256 currentAllowance = allowance(owner, spender, token);
if (currentAllowance != type(uint256).max) {
require(
currentAllowance >= amount,
"Token: insufficient allowance"
);
require(currentAllowance >= amount, "Token: insufficient allowance");
approve(owner, spender, token, currentAllowance - amount);
}
}
Expand Down
Loading

0 comments on commit b43873a

Please sign in to comment.