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

feat: honey pot #1

Merged
merged 7 commits into from
Oct 25, 2023
Merged

feat: honey pot #1

merged 7 commits into from
Oct 25, 2023

Conversation

md0x
Copy link
Contributor

@md0x md0x commented Oct 23, 2023

Changes proposed in this PR:

  • Add Honey pot and OEVShare honey pot contracts
  • Add tests
  • Add readme

UMA-1900

md0x added 4 commits October 23, 2023 16:27
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
Copy link
Contributor Author

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

Copy link
Member

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);
}
Copy link
Member

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?

Copy link
Contributor Author

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 {
Copy link
Member

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?

Copy link
Contributor Author

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>
@md0x md0x requested a review from chrismaree October 24, 2023 14:30
Copy link
Member

@mrice32 mrice32 left a 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>
Copy link
Member

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?

Copy link
Member

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 ;)

Copy link
Member

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;
Copy link
Member

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).

Copy link
Contributor Author

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 {
Copy link
Member

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)?

Copy link
Contributor Author

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);
Copy link
Member

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

Copy link
Contributor Author

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 {
Copy link
Member

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?

Copy link
Contributor Author

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
Copy link
Member

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>
@md0x md0x requested a review from mrice32 October 24, 2023 16:07
emit HoneyPotEmptied(honeyPotCreator, msg.sender, amount);
}

function resetPot() external {
Copy link
Member

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 md0x requested a review from chrismaree October 25, 2023 15:18
@mrice32
Copy link
Member

mrice32 commented Oct 25, 2023

@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.

@mrice32 mrice32 merged commit efa0ae5 into master Oct 25, 2023
1 check failed
@mrice32 mrice32 deleted the pablo/honey-pot branch October 25, 2023 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants