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

chore(SC-940): Move extensions to separate folder #278

Merged
merged 4 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 3 additions & 3 deletions contracts/OrderLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import "@1inch/solidity-utils/contracts/libraries/AddressLib.sol";
import "./interfaces/IOrderMixin.sol";
import "./libraries/MakerTraitsLib.sol";
import "./libraries/ExtensionLib.sol";
import "./helpers/AmountCalculator.sol";
import "./libraries/AmountCalculatorLib.sol";
import "./interfaces/IAmountGetter.sol";

/**
Expand Down Expand Up @@ -96,7 +96,7 @@ import "./interfaces/IAmountGetter.sol";
bytes calldata data = extension.makingAmountData();
if (data.length == 0) {
// Linear proportion
return AmountCalculator.getMakingAmount(order.makingAmount, order.takingAmount, requestedTakingAmount);
return AmountCalculatorLib.getMakingAmount(order.makingAmount, order.takingAmount, requestedTakingAmount);
}
return IAmountGetter(address(bytes20(data))).getMakingAmount(
order,
Expand Down Expand Up @@ -130,7 +130,7 @@ import "./interfaces/IAmountGetter.sol";
bytes calldata data = extension.takingAmountData();
if (data.length == 0) {
// Linear proportion
return AmountCalculator.getTakingAmount(order.makingAmount, order.takingAmount, requestedMakingAmount);
return AmountCalculatorLib.getTakingAmount(order.makingAmount, order.takingAmount, requestedMakingAmount);
}
return IAmountGetter(address(bytes20(data))).getTakingAmount(
order,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ pragma solidity 0.8.19;
import "@openzeppelin/contracts/utils/math/Math.sol";
import "../interfaces/IAmountGetter.sol";

/// @title A helper that implement price decay over time from max to min
artall64 marked this conversation as resolved.
Show resolved Hide resolved
artall64 marked this conversation as resolved.
Show resolved Hide resolved
/// @notice This contact is used in 1inch Fusion orders
artall64 marked this conversation as resolved.
Show resolved Hide resolved
artall64 marked this conversation as resolved.
Show resolved Hide resolved
contract DutchAuctionCalculator is IAmountGetter {
using Math for uint256;

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import "@1inch/solidity-utils/contracts/OnlyWethReceiver.sol";
import "../interfaces/IPostInteraction.sol";
import "../OrderLib.sol";

/// @title ETH limit orders contract
/// @title Extension that will allow to create limit order that sell ETH. ETH would need to be deposited to contract
artall64 marked this conversation as resolved.
Show resolved Hide resolved
artall64 marked this conversation as resolved.
Show resolved Hide resolved
contract ETHOrders is IPostInteraction, OnlyWethReceiver {
using SafeERC20 for IWETH;
using OrderLib for IOrderMixin.Order;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import "@1inch/solidity-utils/contracts/OnlyWethReceiver.sol";
import "@1inch/solidity-utils/contracts/interfaces/IWETH.sol";
import "@1inch/solidity-utils/contracts/libraries/SafeERC20.sol";

/// @title A contract that can be called within postPredicate to unwrap WETH and do payout in ETH
artall64 marked this conversation as resolved.
Show resolved Hide resolved
/// @notice This functionality was embedded into TakerTraits, so this file probably will be removed
artall64 marked this conversation as resolved.
Show resolved Hide resolved
contract WethUnwrapper is OnlyWethReceiver {
using SafeERC20 for IWETH;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

pragma solidity 0.8.19;

/// @title A helper contract for calculations related to order amounts
library AmountCalculator {
/// @title A helper library for calculations related to order amounts
artall64 marked this conversation as resolved.
Show resolved Hide resolved
library AmountCalculatorLib {
/// @notice Calculates maker amount
/// @return Result Floored maker amount
function getMakingAmount(uint256 orderMakerAmount, uint256 orderTakerAmount, uint256 swapTakerAmount) internal pure returns(uint256) {
Expand Down
Loading