DisputeHandlerFacet
View Source: contracts/protocol/facets/DisputeHandlerFacet.sol
↗ Extends: DisputeBase, IBosonDisputeHandler
DisputeHandlerFacet
Handles disputes associated with exchanges within the protocol.
Contract Members
Constants & Variables
bytes32 private constant RESOLUTION_TYPEHASH;
Functions
- initialize()
- raiseDispute(uint256 _exchangeId)
- retractDispute(uint256 _exchangeId)
- extendDisputeTimeout(uint256 _exchangeId, uint256 _newDisputeTimeout)
- expireDispute(uint256 _exchangeId)
- expireDisputeBatch(uint256[] _exchangeIds)
- resolveDispute(uint256 _exchangeId, uint256 _buyerPercent, bytes32 _sigR, bytes32 _sigS, uint8 _sigV)
- escalateDispute(uint256 _exchangeId)
- decideDispute(uint256 _exchangeId, uint256 _buyerPercent)
- refuseEscalatedDispute(uint256 _exchangeId)
- expireEscalatedDispute(uint256 _exchangeId)
- finalizeDispute(uint256 _exchangeId, struct BosonTypes.Exchange _exchange, struct BosonTypes.Dispute _dispute, struct BosonTypes.DisputeDates _disputeDates, enum BosonTypes.DisputeState _targetState, uint256 _buyerPercent)
- getDispute(uint256 _exchangeId)
- getDisputeState(uint256 _exchangeId)
- getDisputeTimeout(uint256 _exchangeId)
- isDisputeFinalized(uint256 _exchangeId)
- disputeResolverChecks(uint256 _exchangeId)
- hashResolution(uint256 _exchangeId, uint256 _buyerPercent)
initialize
Initializes Facet.
This function is callable only once.
function initialize()
public
onlyUnInitialized
raiseDispute
Raises a dispute.
Reverts if:
- Caller does not hold a voucher for the given exchange id
- Exchange does not exist
- Exchange is not in a Redeemed state
- Dispute period has elapsed already
function raiseDispute(uint256 _exchangeId)
external
disputesNotPaused nonReentrant
Arguments
Name | Type | Description |
---|---|---|
_exchangeId | uint256 | the id of the associated exchange |
retractDispute
Retracts the dispute and release the funds.
Emits a DisputeRetracted event if successful.
Reverts if:
- The disputes region of protocol is paused
- Exchange does not exist
- Exchange is not in a Disputed state
- Caller is not the buyer for the given exchange id
- Dispute is in some state other than Resolving or Escalated
- Dispute was escalated and escalation period has elapsed
function retractDispute(uint256 _exchangeId)
external
disputesNotPaused nonReentrant
Arguments
Name | Type | Description |
---|---|---|
_exchangeId | uint256 | the id of the associated exchange |
extendDisputeTimeout
Extends the dispute timeout, allowing more time for mutual resolution.
As a consequence, buyer also gets more time to escalate the dispute.
Emits a DisputeTimeoutExtened event if successful.
Reverts if:
- The disputes region of protocol is paused
- Exchange does not exist
- Exchange is not in a Disputed state
- Caller is not the seller
- Dispute has expired already
- New dispute timeout is before the current dispute timeout
- Dispute is in some state other than Resolving
function extendDisputeTimeout(uint256 _exchangeId,
uint256 _newDisputeTimeout)
external
disputesNotPaused nonReentrant
Arguments
Name | Type | Description |
---|---|---|
_exchangeId | uint256 | the id of the associated exchange |
_newDisputeTimeout | uint256 | new date when resolution period ends |
expireDispute
Expires the dispute and releases the funds.
Emits a DisputeExpired event if successful.
Reverts if:
- The disputes region of protocol is paused
- Exchange does not exist
- Exchange is not in a Disputed state
- Dispute is still valid
- Dispute is in some state other than Resolving
function expireDispute(uint256 _exchangeId)
public
disputesNotPaused nonReentrant
Arguments
Name | Type | Description |
---|---|---|
_exchangeId | uint256 | the id of the associated exchange |
expireDisputeBatch
Expires a batch of disputes and releases the funds.
Emits a DisputeExpired event for every dispute if successful.
Reverts if:
- The disputes region of protocol is paused
- Number of disputes exceeds maximum allowed number per batch
- For any dispute:
- Exchange does not exist
- Exchange is not in a Disputed state
- Dispute is still valid
- Dispute is in some state other than Resolving
function expireDisputeBatch(uint256[] _exchangeIds)
external
disputesNotPaused
Arguments
Name | Type | Description |
---|---|---|
_exchangeIds | uint256[] | the array of ids of the associated exchanges |
resolveDispute
Resolves a dispute by providing the information about the funds split.
Callable by the buyer or seller, but the caller must provide the resolution signed by the other party.
Emits a DisputeResolved event if successful.
Reverts if:
- The disputes region of protocol is paused
- Specified buyer percent exceeds 100%
- Dispute has expired (resolution period has ended and dispute was not escalated)
- Exchange does not exist
- Exchange is not in the Disputed state
- Caller is neither the seller nor the buyer
- Signature does not belong to the address of the other party
- Dispute state is neither Resolving nor escalated
- Dispute was escalated and escalation period has elapsed
function resolveDispute(uint256 _exchangeId,
uint256 _buyerPercent,
bytes32 _sigR,
bytes32 _sigS,
uint8 _sigV)
external
disputesNotPaused nonReentrant
Arguments
Name | Type | Description |
---|---|---|
_exchangeId | uint256 | the id of the associated exchange |
_buyerPercent | uint256 | percentage of the pot that goes to the buyer |
_sigR | bytes32 | r part of the signer's signature |
_sigS | bytes32 | s part of the signer's signature |
_sigV | uint8 | v part of the signer's signature |
escalateDispute
Puts the dispute into the Escalated state.
Emits a DisputeEscalated event if successful.
Reverts if:
- The disputes region of protocol is paused
- Exchange does not exist
- Exchange is not in a Disputed state
- Caller is not the buyer
- Dispute is already expired
- Dispute is not in a Resolving state
- Dispute resolver is not specified (absolute zero offer)
- Offer price is in native token and caller does not send enough
- Offer price is in some ERC20 token and caller also sends native currency
- If contract at token address does not support ERC20 function transferFrom
- If calling transferFrom on token fails for some reason (e.g. protocol is not approved to transfer)
- Received ERC20 token amount differs from the expected value
function escalateDispute(uint256 _exchangeId)
external
payabledisputesNotPaused nonReentrant
Arguments
Name | Type | Description |
---|---|---|
_exchangeId | uint256 | the id of the associated exchange |
decideDispute
Decides a dispute by providing the information about the funds split. Callable by the dispute resolver specified in the offer.
Emits a DisputeDecided event if successful.
Reverts if:
- The disputes region of protocol is paused
- Specified buyer percent exceeds 100%
- Exchange does not exist
- Exchange is not in the Disputed state
- Caller is not the dispute resolver for this dispute
- Dispute state is not Escalated
- Dispute escalation response period has elapsed
function decideDispute(uint256 _exchangeId,
uint256 _buyerPercent)
external
disputesNotPaused nonReentrant
Arguments
Name | Type | Description |
---|---|---|
_exchangeId | uint256 | the id of the associated exchange |
_buyerPercent | uint256 | percentage of the pot that goes to the buyer |
refuseEscalatedDispute
Enables dispute resolver to explicitly refuse to resolve a dispute in Escalated state and releases the funds.
Emits an EscalatedDisputeRefused event if successful.
Reverts if:
- The disputes region of protocol is paused
- Exchange does not exist
- Exchange is not in a Disputed state
- Dispute is in some state other than Escalated
- Dispute escalation response period has elapsed
- Caller is not the dispute resolver for this dispute
function refuseEscalatedDispute(uint256 _exchangeId)
external
disputesNotPaused nonReentrant
Arguments
Name | Type | Description |
---|---|---|
_exchangeId | uint256 | the id of the associated exchange |
expireEscalatedDispute
Expires the dispute in escalated state and release the funds.
Emits an EscalatedDisputeExpired event if successful.
Reverts if:
- The disputes region of protocol is paused
- Exchange does not exist
- Exchange is not in a Disputed state
- Dispute is in some state other than Escalated
- Dispute escalation period has not passed yet
function expireEscalatedDispute(uint256 _exchangeId)
external
disputesNotPaused nonReentrant
Arguments
Name | Type | Description |
---|---|---|
_exchangeId | uint256 | the id of the associated exchange |
finalizeDispute
Transitions a dispute to a "finalized" state.
Target state must be Retracted, Resolved, or Decided.
Sets finalized date for exchange and dispute. Stores the resolution, if exists, and releases the funds.
Reverts if the current dispute state is not Resolving or Escalated.
function finalizeDispute(uint256 _exchangeId,
struct BosonTypes.Exchange _exchange,
struct BosonTypes.Dispute _dispute,
struct BosonTypes.DisputeDates _disputeDates,
enum BosonTypes.DisputeState _targetState,
uint256 _buyerPercent)
internal
Arguments
Name | Type | Description |
---|---|---|
_exchangeId | uint256 | the id of the associated exchange |
_exchange | BosonTypes.Exchange | Id the id of the associated exchange |
_dispute | BosonTypes.Dispute | pointer to dispute storage slot |
_disputeDates | BosonTypes.DisputeDates | pointer to disputeDates storage slot |
_targetState | enum BosonTypes.DisputeState | target final state |
_buyerPercent | uint256 | percentage of the pot that goes to the buyer |
getDispute
Gets the details about a given dispute.
function getDispute(uint256 _exchangeId)
external
view
returns(bool exists,
Dispute memory dispute,
DisputeDates memory disputeDates)
Arguments
Name | Type | Description |
---|---|---|
_exchangeId | uint256 | the id of the associated exchange |
Returns
Name | Type | Description |
---|---|---|
exists | bool | true if the dispute exists |
dispute | BosonTypes.Dispute | the dispute details. See {BosonTypes.Dispute} |
disputeDates | BosonTypes.DisputeDates | the dispute dates details {BosonTypes.DisputeDates} |
getDisputeState
Gets the state of a given dispute.
function getDisputeState(uint256 _exchangeId)
external
view
returns(bool exists, enum BosonTypes.DisputeState state)
Arguments
Name | Type | Description |
---|---|---|
_exchangeId | uint256 | the id of the associated exchange |
Returns
BosonTypes.DisputeState
getDisputeTimeout
Gets the timeout of a given dispute.
function getDisputeTimeout(uint256 _exchangeId)
external
view
returns(bool exists, uint256 timeout)
Arguments
Name | Type | Description |
---|---|---|
_exchangeId | uint256 | the id of the associated exchange |
Returns
Name | Type | Description |
---|---|---|
exists | bool | true if the dispute exists |
timeout | uint256 | the end of resolution period |
isDisputeFinalized
Checks if the given dispute is in a Finalized state.
Returns true if
- Dispute state is Retracted, Resolved, Decided or Refused
function isDisputeFinalized(uint256 _exchangeId)
external
view
returns(bool exists, bool isFinalized)
Arguments
Name | Type | Description |
---|---|---|
_exchangeId | uint256 | the id of the associated exchange |
Returns
Name | Type | Description |
---|---|---|
exists | bool | true if the dispute exists |
isFinalized | bool | true if the dispute is finalized |
disputeResolverChecks
Validates that exchange and dispute are in the correct state and that the caller is the dispute resolver for this dispute.
Reverts if:
- Exchange does not exist
- Exchange is not in a Disputed state
- Dispute is in some state other than Escalated
- Dispute escalation response period has elapsed
- Caller is not the dispute resolver for this dispute
function disputeResolverChecks(uint256 _exchangeId)
internal
view
returns(Exchange storage exchange,
Dispute storage dispute,
DisputeDates storage disputeDates)
Arguments
Name | Type | Description |
---|---|---|
_exchangeId | uint256 | the id of the associated exchange |
Returns
Name | Type | Description |
---|---|---|
BosonTypes.Exchange | BosonTypes.Exchange | |
BosonTypes.Dispute | BosonTypes.Dispute | |
BosonTypes.DisputeDates | BosonTypes.DisputeDates |
hashResolution
Returns hashed resolution information. Needed for the verfication in resolveDispute.
function hashResolution(uint256 _exchangeId,
uint256 _buyerPercent)
internal
pure
returns(bytes32)
Arguments
Name | Type | Description |
---|---|---|
_exchangeId | uint256 | the id of the associated exchange |
_buyerPercent | uint256 | percentage of the pot that goes to the buyer |
Returns
bytes32