diff --git a/contracts/OrderLib.sol b/contracts/OrderLib.sol index 894631df..e0160ac8 100644 --- a/contracts/OrderLib.sol +++ b/contracts/OrderLib.sol @@ -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"; /** @@ -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, @@ -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, diff --git a/contracts/helpers/DutchAuctionCalculator.sol b/contracts/extensions/DutchAuctionCalculator.sol similarity index 92% rename from contracts/helpers/DutchAuctionCalculator.sol rename to contracts/extensions/DutchAuctionCalculator.sol index f331b88a..435f303b 100644 --- a/contracts/helpers/DutchAuctionCalculator.sol +++ b/contracts/extensions/DutchAuctionCalculator.sol @@ -5,6 +5,8 @@ pragma solidity 0.8.19; import "@openzeppelin/contracts/utils/math/Math.sol"; import "../interfaces/IAmountGetter.sol"; +/// @title A helper that implements price decay over time from max to min +/// @notice The contract implements Dutch auction price calculation for 1inch limit orders, it is used by 1inch Fusion contract DutchAuctionCalculator is IAmountGetter { using Math for uint256; diff --git a/contracts/helpers/ERC1155Proxy.sol b/contracts/extensions/ERC1155Proxy.sol similarity index 100% rename from contracts/helpers/ERC1155Proxy.sol rename to contracts/extensions/ERC1155Proxy.sol diff --git a/contracts/helpers/ERC721Proxy.sol b/contracts/extensions/ERC721Proxy.sol similarity index 100% rename from contracts/helpers/ERC721Proxy.sol rename to contracts/extensions/ERC721Proxy.sol diff --git a/contracts/helpers/ERC721ProxySafe.sol b/contracts/extensions/ERC721ProxySafe.sol similarity index 100% rename from contracts/helpers/ERC721ProxySafe.sol rename to contracts/extensions/ERC721ProxySafe.sol diff --git a/contracts/helpers/ETHOrders.sol b/contracts/extensions/ETHOrders.sol similarity index 97% rename from contracts/helpers/ETHOrders.sol rename to contracts/extensions/ETHOrders.sol index 13e93fad..3d0c8924 100644 --- a/contracts/helpers/ETHOrders.sol +++ b/contracts/extensions/ETHOrders.sol @@ -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 must be deposited into the contract. contract ETHOrders is IPostInteraction, OnlyWethReceiver { using SafeERC20 for IWETH; using OrderLib for IOrderMixin.Order; diff --git a/contracts/helpers/ImmutableOwner.sol b/contracts/extensions/ImmutableOwner.sol similarity index 100% rename from contracts/helpers/ImmutableOwner.sol rename to contracts/extensions/ImmutableOwner.sol diff --git a/contracts/helpers/OrderIdInvalidator.sol b/contracts/extensions/OrderIdInvalidator.sol similarity index 100% rename from contracts/helpers/OrderIdInvalidator.sol rename to contracts/extensions/OrderIdInvalidator.sol diff --git a/contracts/helpers/PrioirityFeeLimiter.sol b/contracts/extensions/PrioirityFeeLimiter.sol similarity index 100% rename from contracts/helpers/PrioirityFeeLimiter.sol rename to contracts/extensions/PrioirityFeeLimiter.sol diff --git a/contracts/helpers/RangeAmountCalculator.sol b/contracts/extensions/RangeAmountCalculator.sol similarity index 100% rename from contracts/helpers/RangeAmountCalculator.sol rename to contracts/extensions/RangeAmountCalculator.sol diff --git a/contracts/helpers/WethUnwrapper.sol b/contracts/extensions/WethUnwrapper.sol similarity index 84% rename from contracts/helpers/WethUnwrapper.sol rename to contracts/extensions/WethUnwrapper.sol index 8eedf8f8..86ae203e 100644 --- a/contracts/helpers/WethUnwrapper.sol +++ b/contracts/extensions/WethUnwrapper.sol @@ -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 The extension to unwrap WETH and do payout in ETH in limit order postInteraction +/// @notice The feature was embedded into TakerTraits, so it is obsolete and will be removed contract WethUnwrapper is OnlyWethReceiver { using SafeERC20 for IWETH; diff --git a/contracts/helpers/AmountCalculator.sol b/contracts/libraries/AmountCalculatorLib.sol similarity index 89% rename from contracts/helpers/AmountCalculator.sol rename to contracts/libraries/AmountCalculatorLib.sol index aabd626b..3faa19cc 100644 --- a/contracts/helpers/AmountCalculator.sol +++ b/contracts/libraries/AmountCalculatorLib.sol @@ -2,8 +2,8 @@ pragma solidity 0.8.19; -/// @title A helper contract for calculations related to order amounts -library AmountCalculator { +/// @title The helper library to calculate linearly taker amount from maker amount and vice versa. +library AmountCalculatorLib { /// @notice Calculates maker amount /// @return Result Floored maker amount function getMakingAmount(uint256 orderMakerAmount, uint256 orderTakerAmount, uint256 swapTakerAmount) internal pure returns(uint256) {