-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
At the moment an auction can only be ended (i.e. endAuction()) if the following criteria is met:
- The message sender who calls
endAuction()is the owner of the auction (checked byonlyAuctionOwner()modifier). - The given auction has not already ended.
- The auction deadline is past (i.e.
block.timestamp >= auction.blockDeadline).
It would be great to automatise the end of an auction (and more) with Chainlink, but still allow the auction owner to manually finish it.
Early draft
- New Chainlinked contract (i.e. ChainlinkedContract):
- It must inherit from
ChainlinkClientandOwnable(for transferring the ownership of some methods to AuctionRepository). request():- Protected by
onlyOwnermodifier. - Arguments: oracle address, job ID, payment?, callback address, callback function signature, and timestamp (auction block deadline).
- Request adapter: Sleep.
- Protected by
validateChainlinkCallback(): given the chosen design pattern (AuctionRepository.soldoes not inherit fromChainlinkClient.sol). AuctionRepository must be protected against malicious callers (e.g. check both sender and requestId).- Arguments: requestId.
- Protected by
onlyOwnermodifier.
cancelRequest():- Arguments: requestId, payment, callback function signature, expiration.
- Protected by
onlyOwnermodifier.
withdrawLink(): TBC- Protected by
onlyOwnermodifier.
- Protected by
- AuctionRepository.sol contract:
initialize():- Initialise the trusted
ChainlinkedContractand store its reference within the contract. - Transfer its ownership to the contract address.
- Store the oracle address and the jobId within the contract.
- LINK (token) address?
- Initialise the trusted
createAuction():- Call the
ChainlinkedContract.request()with:auction.blockDeadline - block.timestampas a deltaunit. Double check this.this.addressas a_callbackAddress.endAuction()as a_callbackFunctionSignature.- payment?
- Store the request ID and the auction ID in a mapping (i.e.
mapping(bytes32 => uint256) private requestIdAuctionId).
- Call the
endAuction():- Use a new access modifier that only allows access to the auction owner and
ChainlinkedContract. - Check against
ChainlinkedContract.validateChainlinkCallback(). - Remove the
requestIdAuctionIdmapping entry.
- Use a new access modifier that only allows access to the auction owner and
cancelAuction():- Beware of the 5 minutes requirement .
- Remove the
requestIdAuctionIdmapping entry. - Call
ChainlinkedContract.cancelRequest().
cancelledRequestFulfill(): TBC, transfer link back to the auction owner.updateOracleAddress()updateJobId()
Open questions
- Contracts design: create a specific Chainlinked contract as described (composition) above or make
AuctionRepository.solinherit fromChainlinkClient? (inheritance). Furthermore the design must be compatible with theAuctionRepository.solupgradeable capabilities (via OpenZeppelin upgradeable contracts). - Adapter: is the
sleepadapter "built-in" one or do I have to ask a node operator to list it? It seems not avaiable right now. - LINK payment/withdrawal: find the best way to fund the Chainlinked contract, and to withdraw the LINK after cancelling an auction. Important.
- endAuction(): what happens if the auction owner ends the auction before the Chainlink job response? The same block could have the owner and the job tx, making one of them revert. Important.
- cancelAuction(): instead of allowing the auction owner to withdraw the funds, an alternative would be to integrate VRF and make a lottery among the bidders (if there aren't either do not penalise the owner or add them to a lottery pot).
References
Chainlink API Reference
Chainlink alarms
Sleep adapter
OZ Upgradeable Contracts
OZ Upgradeable Contracts + Chainlinked 1
OZ Upgradeable Contracts + Chainlinked 2
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request