Skip to main content

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

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

NameTypeDescription
_exchangeIduint256the 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

NameTypeDescription
_exchangeIduint256the 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

NameTypeDescription
_exchangeIduint256the id of the associated exchange
_newDisputeTimeoutuint256new 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

NameTypeDescription
_exchangeIduint256the 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

NameTypeDescription
_exchangeIdsuint256[]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

NameTypeDescription
_exchangeIduint256the id of the associated exchange
_buyerPercentuint256percentage of the pot that goes to the buyer
_sigRbytes32r part of the signer's signature
_sigSbytes32s part of the signer's signature
_sigVuint8v 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

NameTypeDescription
_exchangeIduint256the 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

NameTypeDescription
_exchangeIduint256the id of the associated exchange
_buyerPercentuint256percentage 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

NameTypeDescription
_exchangeIduint256the 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

NameTypeDescription
_exchangeIduint256the 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

NameTypeDescription
_exchangeIduint256the id of the associated exchange
_exchangeBosonTypes.ExchangeId the id of the associated exchange
_disputeBosonTypes.Disputepointer to dispute storage slot
_disputeDatesBosonTypes.DisputeDatespointer to disputeDates storage slot
_targetStateenum BosonTypes.DisputeStatetarget final state
_buyerPercentuint256percentage 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

NameTypeDescription
_exchangeIduint256the id of the associated exchange

Returns

NameTypeDescription
existsbooltrue if the dispute exists
disputeBosonTypes.Disputethe dispute details. See {BosonTypes.Dispute}
disputeDatesBosonTypes.DisputeDatesthe 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

NameTypeDescription
_exchangeIduint256the 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

NameTypeDescription
_exchangeIduint256the id of the associated exchange

Returns

NameTypeDescription
existsbooltrue if the dispute exists
timeoutuint256the 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

NameTypeDescription
_exchangeIduint256the id of the associated exchange

Returns

NameTypeDescription
existsbooltrue if the dispute exists
isFinalizedbooltrue 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

NameTypeDescription
_exchangeIduint256the id of the associated exchange

Returns

NameTypeDescription
BosonTypes.ExchangeBosonTypes.Exchange
BosonTypes.DisputeBosonTypes.Dispute
BosonTypes.DisputeDatesBosonTypes.DisputeDates

hashResolution

Returns hashed resolution information. Needed for the verfication in resolveDispute.

function hashResolution(uint256 _exchangeId,
uint256 _buyerPercent)
internal
pure
returns(bytes32)

Arguments

NameTypeDescription
_exchangeIduint256the id of the associated exchange
_buyerPercentuint256percentage of the pot that goes to the buyer

Returns

bytes32