-
Notifications
You must be signed in to change notification settings - Fork 1
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
Fix Review #1
base: main
Are you sure you want to change the base?
Fix Review #1
Conversation
@@ -2,16 +2,17 @@ | |||
pragma solidity ^0.8.19; | |||
|
|||
import "./IAutomation.sol"; | |||
import "../oracle/IPythRelay.sol"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
@@ -2,16 +2,17 @@ | |||
pragma solidity ^0.8.19; | |||
|
|||
import "./IAutomation.sol"; | |||
import "../oracle/IPythRelay.sol"; | |||
import "../libraries/ArrayMutation.sol"; | |||
import "../interfaces/openzeppelin/Ownable.sol"; | |||
import "../interfaces/openzeppelin/ERC20.sol"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
import "../interfaces/openzeppelin/Pausable.sol"; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
import "../libraries/ArrayMutation.sol"; | ||
import "../interfaces/openzeppelin/Ownable.sol"; | ||
import "../interfaces/openzeppelin/ERC20.sol"; | ||
import "../interfaces/openzeppelin/IERC20.sol"; | ||
import "../interfaces/openzeppelin/SafeERC20.sol"; | ||
import "../oracle/IPythRelay.sol"; | ||
import "../interfaces/openzeppelin/Pausable.sol"; | ||
|
||
///@notice This contract owns and handles all of the settings and accounting logic for automated swaps | ||
///@notice This contract should not hold any user funds, only collected fees |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
|
||
///@notice This contract owns and handles all of the settings and accounting logic for automated swaps | ||
///@notice This contract should not hold any user funds, only collected fees | ||
contract AutomationMaster is IAutomationMaster, Ownable { | ||
contract AutomationMaster is IAutomationMaster, Ownable, Pausable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
|
||
///@notice This contract owns and handles all of the settings and accounting logic for automated swaps | ||
///@notice This contract should not hold any user funds, only collected fees | ||
contract AutomationMaster is IAutomationMaster, Ownable { | ||
contract AutomationMaster is IAutomationMaster, Ownable, Pausable { | ||
using SafeERC20 for IERC20; | ||
|
||
///@notice maximum pending orders that may exist at a time, limiting the compute requriement for checkUpkeep |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
@@ -27,6 +28,25 @@ contract AutomationMaster is IAutomationMaster, Ownable { | |||
///each token must have a registered oracle in order to be tradable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
@@ -27,6 +28,25 @@ contract AutomationMaster is IAutomationMaster, Ownable { | |||
///each token must have a registered oracle in order to be tradable | |||
mapping(IERC20 => IPythRelay) public oracles; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
@@ -27,6 +28,25 @@ contract AutomationMaster is IAutomationMaster, Ownable { | |||
///each token must have a registered oracle in order to be tradable | |||
mapping(IERC20 => IPythRelay) public oracles; | |||
mapping(IERC20 => bytes32) public pythIds; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
mapping(address => uint96) private nonces; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
constructor(address owner){ | ||
_transferOwnership(owner); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
function pauseAll( | ||
bool pause, | ||
IOracleLess oracleLessContract | ||
) external override onlyOwner { | ||
if (pause) { | ||
_pause(); | ||
} else { | ||
_unpause(); | ||
} | ||
STOP_LIMIT_CONTRACT.pause(pause); | ||
BRACKET_CONTRACT.pause(pause); | ||
oracleLessContract.pause(pause); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
STOP_LIMIT_CONTRACT.pause(pause); | ||
BRACKET_CONTRACT.pause(pause); | ||
oracleLessContract.pause(pause); | ||
} | ||
|
||
///@notice register Stop Limit and Bracket order contracts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
@@ -87,9 +107,14 @@ contract AutomationMaster is IAutomationMaster, Ownable { | |||
} | |||
|
|||
///@notice generate a random and unique order id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
function generateOrderId( | ||
address sender | ||
) external override returns (uint96) { | ||
uint96 nonce = nonces[sender]++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
function generateOrderId( | ||
address sender | ||
) external override returns (uint96) { | ||
uint96 nonce = nonces[sender]++; | ||
uint256 hashedValue = uint256( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
keccak256( | ||
abi.encodePacked(sender, nonce, blockhash(block.number - 1)) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
keccak256(abi.encodePacked(sender, block.timestamp)) | ||
keccak256( | ||
abi.encodePacked(sender, nonce, blockhash(block.number - 1)) | ||
) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
///@notice determine if a new order meets the minimum order size requirement | ||
///Value of @param amountIn of @param tokenIn must meed the minimum USD value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
function checkMinOrderSize( | ||
IERC20 tokenIn, | ||
uint256 amountIn | ||
) external view override { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
@@ -151,28 +179,32 @@ contract AutomationMaster is IAutomationMaster, Ownable { | |||
|
|||
///@notice check upkeep on all order types |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
@@ -151,28 +179,32 @@ contract AutomationMaster is IAutomationMaster, Ownable { | |||
|
|||
///@notice check upkeep on all order types | |||
function checkUpkeep( | |||
bytes calldata | |||
bytes calldata checkData |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
@@ -151,28 +179,32 @@ contract AutomationMaster is IAutomationMaster, Ownable { | |||
|
|||
///@notice check upkeep on all order types | |||
function checkUpkeep( | |||
bytes calldata | |||
bytes calldata checkData | |||
) | |||
external | |||
view | |||
override | |||
returns (bool upkeepNeeded, bytes memory performData) | |||
{ | |||
//check stop limit order |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
(upkeepNeeded, performData) = STOP_LIMIT_CONTRACT.checkUpkeep( | ||
checkData | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
(upkeepNeeded, performData) = STOP_LIMIT_CONTRACT.checkUpkeep("0x"); | ||
(upkeepNeeded, performData) = STOP_LIMIT_CONTRACT.checkUpkeep( | ||
checkData | ||
); | ||
if (upkeepNeeded) { | ||
return (true, performData); | ||
} | ||
|
||
//check bracket order |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
if (upkeepNeeded) { | ||
return (true, performData); | ||
} | ||
|
||
//check bracket order | ||
(upkeepNeeded, performData) = BRACKET_CONTRACT.checkUpkeep("0x"); | ||
(upkeepNeeded, performData) = BRACKET_CONTRACT.checkUpkeep(checkData); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
if (upkeepNeeded) { | ||
return (true, performData); | ||
} | ||
|
||
//check bracket order | ||
(upkeepNeeded, performData) = BRACKET_CONTRACT.checkUpkeep("0x"); | ||
(upkeepNeeded, performData) = BRACKET_CONTRACT.checkUpkeep(checkData); | ||
if (upkeepNeeded) { | ||
return (true, performData); | ||
} | ||
} | ||
|
||
///@notice perform upkeep on any order type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
function performUpkeep( | ||
bytes calldata performData | ||
) external override whenNotPaused { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
@@ -10,13 +10,14 @@ import "../interfaces/openzeppelin/Ownable.sol"; | |||
import "../interfaces/openzeppelin/IERC20.sol"; | |||
import "../interfaces/openzeppelin/SafeERC20.sol"; | |||
import "../interfaces/openzeppelin/ReentrancyGuard.sol"; | |||
import "../interfaces/openzeppelin/Pausable.sol"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
//emit event | ||
emit OrderCancelled(order.orderId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
} | ||
return false; | ||
//emit event | ||
emit OrderCancelled(order.orderId); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
uint96 pendingOrderIdx, | ||
bool permit, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
bytes calldata permitPayload | ||
) internal { | ||
//fetch order | ||
Order memory order = orders[orderId]; | ||
|
||
require( | ||
order.orderId == pendingOrderIds[pendingOrderIdx], | ||
"order doesn't exist" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
require( | ||
order.orderId == pendingOrderIds[pendingOrderIdx], | ||
"order doesn't exist" | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
require( | ||
order.orderId == pendingOrderIds[pendingOrderIdx], | ||
"order doesn't exist" | ||
); | ||
require(msg.sender == order.recipient, "only order owner"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
@@ -207,6 +249,7 @@ contract OracleLess is IOracleLess, Ownable, ReentrancyGuard { | |||
//refund position partially | |||
order.tokenIn.safeTransfer(order.recipient, amountInDelta); | |||
} | |||
require(newAmountIn != 0, "newAmountIn == 0"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
@@ -207,6 +249,7 @@ contract OracleLess is IOracleLess, Ownable, ReentrancyGuard { | |||
//refund position partially | |||
order.tokenIn.safeTransfer(order.recipient, amountInDelta); | |||
} | |||
require(newAmountIn != 0, "newAmountIn == 0"); | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
target, | ||
(order.tokenIn.allowance(address(this), target)) | ||
); | ||
|
||
uint256 finalTokenIn = order.tokenIn.balanceOf(address(this)); | ||
require(finalTokenIn >= initialTokenIn - order.amountIn, "over spend"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
@@ -8,10 +8,11 @@ import "../interfaces/openzeppelin/Ownable.sol"; | |||
import "../interfaces/openzeppelin/IERC20.sol"; | |||
import "../interfaces/openzeppelin/SafeERC20.sol"; | |||
import "../interfaces/openzeppelin/ReentrancyGuard.sol"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
@@ -8,10 +8,11 @@ import "../interfaces/openzeppelin/Ownable.sol"; | |||
import "../interfaces/openzeppelin/IERC20.sol"; | |||
import "../interfaces/openzeppelin/SafeERC20.sol"; | |||
import "../interfaces/openzeppelin/ReentrancyGuard.sol"; | |||
import "../interfaces/openzeppelin/Pausable.sol"; | |||
|
|||
///@notice This contract owns and handles all logic associated with STOP_LIMIT orders | |||
///STOP_LIMIT orders create a new Bracket order order with the same order ID once filled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
|
||
///@notice This contract owns and handles all logic associated with STOP_LIMIT orders | ||
///STOP_LIMIT orders create a new Bracket order order with the same order ID once filled | ||
contract StopLimit is Ownable, IStopLimit, ReentrancyGuard { | ||
contract StopLimit is Ownable, IStopLimit, ReentrancyGuard, Pausable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
@@ -25,11 +26,25 @@ contract StopLimit is Ownable, IStopLimit, ReentrancyGuard { | |||
constructor( | |||
IAutomationMaster _master, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
IPermit2 _permit2, | ||
address owner |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
) { | ||
MASTER = _master; | ||
BRACKET_CONTRACT = _bracket; | ||
permit2 = _permit2; | ||
_transferOwnership(owner); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
) external override nonReentrant whenNotPaused { | ||
MasterUpkeepData memory data = abi.decode( | ||
performData, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
address(BRACKET_CONTRACT), | ||
(order.tokenIn.allowance(address(this), address(BRACKET_CONTRACT))) | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
address(BRACKET_CONTRACT), | ||
order.tokenIn, | ||
order.amountIn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
@@ -158,19 +195,22 @@ contract StopLimit is Ownable, IStopLimit, ReentrancyGuard { | |||
bool swapOnFill, | |||
bool permit, | |||
bytes calldata permitPayload |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
) external override nonReentrant whenNotPaused { | ||
if (permit) { | ||
require(amountIn < type(uint160).max, "uint160 overflow"); | ||
handlePermit( | ||
recipient, | ||
msg.sender, | ||
permitPayload, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
handlePermit( | ||
recipient, | ||
msg.sender, | ||
permitPayload, | ||
uint160(amountIn), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
} | ||
|
||
MASTER.checkMinOrderSize(tokenIn, amountIn); | ||
|
||
_createOrder( | ||
stopLimitPrice, | ||
takeProfit, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
bytes calldata permitPayload | ||
) external override nonReentrant { | ||
) external override nonReentrant whenNotPaused { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
require( | ||
_amountInDelta < type(uint160).max, | ||
"uint160 overflow" | ||
); | ||
handlePermit( | ||
order.recipient, | ||
permitPayload, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
///@notice allow administrator to cancel any order | ||
///@notice once cancelled, any funds assocaiated with the order are returned to the order recipient | ||
///@notice only pending orders can be cancelled | ||
function adminCancelOrder( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
_cancelOrder(order, pendingOrderIdx); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
@@ -348,37 +419,31 @@ contract StopLimit is Ownable, IStopLimit, ReentrancyGuard { | |||
recipient: recipient, | |||
direction: MASTER.getExchangeRate(tokenIn, tokenOut) > | |||
stopLimitPrice, //compare to stop price for this order's direction | |||
bracketDirection: bracketDirection, | |||
swapOnFill: swapOnFill | |||
}); | |||
pendingOrderIds.push(uint96(orderId)); | |||
//emit | |||
emit OrderCreated(orderId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
//remove from pending array | ||
pendingOrderIds = ArrayMutation.removeFromArray( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
} | ||
|
||
///@notice handle signature and acquisition of asset with permit2 | ||
function handlePermit( | ||
address owner, | ||
address tokenOwner, | ||
bytes calldata permitPayload, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
); | ||
} | ||
permit2.permit(tokenOwner, payload.permitSingle, payload.signature); | ||
permit2.transferFrom(tokenOwner, address(this), amount, token); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to gfx-labs/oku-custom-order-types#1.
Fixes issues: #796, #763, #115, #589, #731, #700, #161, #789, #726, #109, #449, #761, #542, #24, #810, #202, #421, #429, #331, #357, #277, #64, #424, #745, #72, #146, #896, #904, #901, #900, #62, #267, #406, #486, #502, #604, #708, #771, #821, #871
Fix Review of
Repo:
gfx-labs/oku-custom-order-types
Commit Hash:
bc8d82dad10a3e426dc0fded79d5278ef23581c7