-
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
feat: honey pot #1
Conversation
Signed-off-by: Pablo Maldonado <pablo@umaproject.org>
Signed-off-by: Pablo Maldonado <pablo@umaproject.org>
Signed-off-by: Pablo Maldonado <pablo@umaproject.org>
Signed-off-by: Pablo Maldonado <pablo@umaproject.org>
[submodule "lib/oev-contracts"] | ||
path = lib/oev-contracts | ||
url = git@github.com:UMAprotocol/oev-contracts.git | ||
url = https://github.com/UMAprotocol/oev-contracts.git |
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.
Failing for now in CI as this repo doesn't have access
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.
@md0x we should be able to give github ci access to private repos. Do you know how to do this?
I can add keys to the ci environment if needed!
"Liquidation price reached" | ||
); | ||
payable(msg.sender).transfer(address(this).balance); | ||
} |
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.
should we not set the liquidation price back to 0 when the emptyHoneyPot
is called enabling someone to create a new honey pot right after the previous one is liquidated?
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.
Agree @chrismaree. Fixed!
src/HoneyPot.sol
Outdated
oracle = _oracle; | ||
} | ||
|
||
function createHoneyPot(uint _liquidationPrice) external payable { |
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.
this design means there can only be one honey pot at a time. this might not be ideal. we might want to enable multiple to exist simultaneously enabling multiple people to demo the app at the same time. this would require us to have a mapping, rather than this relationship.
thoughts?
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.
Yes, I think that's easy to implement and will be very helpful during the demo. I've updated the contract and tests accordingly. Thanks you!
Signed-off-by: Pablo Maldonado <pablo@umaproject.org>
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.
Looks great! Mostly minor nits
To test the demo run the following commands: | ||
``` | ||
forge install | ||
export RPC_MAINNET=https://mainnet.infura.io/v3/<YOUR_INFURA_KEY> |
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.
nit: for consistency with other repos, can we use NODE_URL_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.
This is not consistent with oev-contracts repo ;)
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.
Well, it should be consistent across all of our repos if possible!! Seems easier to change these two than the rest :).
I chatted with @md0x offline, and I think we'll decide on this and make a change in a separate PR.
src/HoneyPot.sol
Outdated
} | ||
|
||
mapping(address => HoneyPotDetails) public honeyPots; | ||
HoneyPotOEVShare public oracle; |
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.
nit: to better demonstrate that this contract is talking to something that looks like chainlink (or some other oracle type), what do you think about changing this to AggregatorV3Source (and we can add a comment that notes that this is the OEVShareContract).
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.
Agree!
src/HoneyPot.sol
Outdated
emit OracleUpdated(address(_oracle)); // Emit event | ||
} | ||
|
||
function createHoneyPot(uint _liquidationPrice) external payable { |
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.
nit: why not make this an int256 (since this is what the oracle returns)?
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.
Agree!
src/HoneyPot.sol
Outdated
uint256 amount = userPot.balance; | ||
userPot.balance = 0; // reset the balance | ||
userPot.liquidationPrice = 0; // reset the liquidation price. There was a mistake in the original, missing the assignment. | ||
payable(msg.sender).transfer(amount); |
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.
nit: prefer OZ's sendValue function (safer if gas costs change in the future or a contract is the recipient): https://github.com/OpenZeppelin/openzeppelin-contracts/blob/7c8b7a27284f503ce8ae23d63ac9403096dcf6fe/contracts/utils/Address.sol#L41
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.
Thanks. Updated
src/HoneyPot.sol
Outdated
emit HoneyPotEmptied(honeyPotCreator, msg.sender, amount); // Emit event | ||
} | ||
|
||
function resetPot() external onlyOwner { |
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.
Does this mean the owner can only empty their own honeypot? What about the other addresses that deposit funds?
I think there are probably two setups that make sense:
- Any creator can withdraw their own honeypot.
- The owner can withdraw anyone's honeypot.
Thoughts?
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.
Right! I forgot to remove the onlyOwner there so creators can withdraw their pots.
Updated.
[submodule "lib/oev-contracts"] | ||
path = lib/oev-contracts | ||
url = git@github.com:UMAprotocol/oev-contracts.git | ||
url = https://github.com/UMAprotocol/oev-contracts.git |
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.
@md0x we should be able to give github ci access to private repos. Do you know how to do this?
I can add keys to the ci environment if needed!
Signed-off-by: Pablo Maldonado <pablo@umaproject.org>
emit HoneyPotEmptied(honeyPotCreator, msg.sender, amount); | ||
} | ||
|
||
function resetPot() external { |
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.
the logic in here is repeated directly within the emptyHoneyPot
function. let's pull out the common logic into an internal function that both can call.
Signed-off-by: Pablo Maldonado <pablo@umaproject.org>
@md0x I'm going to merge this and we'll ask @evaldofelipe to deal with the ci issues since it will require a token that can read repos across the entire org to be added. |
Changes proposed in this PR:
UMA-1900