-
Notifications
You must be signed in to change notification settings - Fork 5
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
Purchase Orders #161
base: openzeppelin-v5
Are you sure you want to change the base?
Purchase Orders #161
Conversation
Signed-off-by: Jonas Lekevicius <[email protected]>
Signed-off-by: Jonas Lekevicius <[email protected]>
Signed-off-by: Jonas Lekevicius <[email protected]>
src/OwnershipRegistry.sol
Outdated
onlyKeeperHeld(orbId) | ||
onlyKeeperSolvent(orbId) | ||
{ | ||
function purchase(uint256 orbId, uint256 newPrice_) external payable virtual onlyKeeperHeld(orbId) { |
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.
Shouldn't this function also revert if there's a standing purchase order? (purchaseOrder[orbId].purchaser != address(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.
Hmm, my thinking was to allow immediate risky purchase, if you don't want to to wait until Orb recharges, and accept the rug risk.
Immediate risky purchase is allowed before a purchase order, and in here it also compensates the purchase order maker. Can't see large pros or cons either way. Maybe will remove this feature to keep it simpler.
Overall lgtm, but we should probably add some tests! |
There are no tests for the entire new system yet, will work on that once we feature-freeze. Not ideal, but main branch won't be merged until we have full test coverage. |
Signed-off-by: Jonas Lekevicius <[email protected]>
Signed-off-by: Jonas Lekevicius <[email protected]>
Signed-off-by: Jonas Lekevicius <[email protected]>
Signed-off-by: Jonas Lekevicius <[email protected]>
Purchase Orders aim to solve potential ruggability of Orbs.
Problem: Orb could get abandoned at any point, even if there’s a pledge. If you purchase the Orb before its cooldown expires, then you might never get to ask a question (or claim the pledge, as it goes to the last invoker), despite paying for the Orb.
Solution: replacing immediate purchases with purchase orders while Orb is charging, holding these funds until Orb is invokable, and then executing the purchase. If the pledge is claimed, or Orb does not become invokable until an expiration date, then the order is cancelled, and funds are returned to the purchasers.
Additional mechanics: