Skip to main content

IBosonOfferHandler

View Source: contracts/interfaces/handlers/IBosonOfferHandler.sol

↗ Extends: IBosonOfferEvents

IBosonOfferHandler

Handles creation, voiding, and querying of offers within the protocol.
The ERC-165 identifier for this interface is: 0xa1e3b91c

Functions

createOffer

Creates an offer.
Emits an OfferCreated event if successful.
Reverts if:
- The offers region of protocol is paused
- Caller is not an assistant
- Valid from date is greater than valid until date
- Valid until date is not in the future
- Both voucher expiration date and voucher expiration period are defined
- Neither of voucher expiration date and voucher expiration period are defined
- Voucher redeemable period is fixed, but it ends before it starts
- Voucher redeemable period is fixed, but it ends before offer expires
- Dispute period is less than minimum dispute period
- Resolution period is not between the minimum and the maximum resolution period
- Voided is set to true
- Available quantity is set to zero
- Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver
- Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver
- Seller is not on dispute resolver's seller allow list
- Dispute resolver does not accept fees in the exchange token
- Buyer cancel penalty is greater than price
- Collection does not exist
- When agent id is non zero:
- If Agent does not exist
- If the sum of agent fee amount and protocol fee amount is greater than the offer fee limit

function createOffer(struct BosonTypes.Offer _offer,
struct BosonTypes.OfferDates _offerDates,
struct BosonTypes.OfferDurations _offerDurations,
uint256 _disputeResolverId,
uint256 _agentId)
external

Arguments

NameTypeDescription
_offerBosonTypes.Offerthe fully populated struct with offer id set to 0x0 and voided set to false
_offerDatesBosonTypes.OfferDatesthe fully populated offer dates struct
_offerDurationsBosonTypes.OfferDurationsthe fully populated offer durations struct
_disputeResolverIduint256the id of chosen dispute resolver (can be 0)
_agentIduint256the id of agent

createOfferBatch

Creates a batch of offers.
Emits an OfferCreated event for every offer if successful.
Reverts if:
- The offers region of protocol is paused
- Number of elements in offers, offerDates and offerDurations do not match
- For any offer:
- Caller is not an assistant
- Valid from date is greater than valid until date
- Valid until date is not in the future
- Both voucher expiration date and voucher expiration period are defined
- Neither of voucher expiration date and voucher expiration period are defined
- Voucher redeemable period is fixed, but it ends before it starts
- Voucher redeemable period is fixed, but it ends before offer expires
- Dispute period is less than minimum dispute period
- Resolution period is not between the minimum and the maximum resolution period
- Voided is set to true
- Available quantity is set to zero
- Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver
- Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver
- Seller is not on dispute resolver's seller allow list
- Dispute resolver does not accept fees in the exchange token
- Buyer cancel penalty is greater than price
- Collection does not exist
- When agent ids are non zero:
- If Agent does not exist
- If the sum of agent fee amount and protocol fee amount is greater than the offer fee limit

function createOfferBatch(struct BosonTypes.Offer[] _offers,
struct BosonTypes.OfferDates[] _offerDates,
struct BosonTypes.OfferDurations[] _offerDurations,
uint256[] _disputeResolverIds,
uint256[] _agentIds)
external

Arguments

NameTypeDescription
_offersBosonTypes.Offer[]the array of fully populated Offer structs with offer id set to 0x0 and voided set to false
_offerDatesBosonTypes.OfferDates[]the array of fully populated offer dates structs
_offerDurationsBosonTypes.OfferDurations[]the array of fully populated offer durations structs
_disputeResolverIdsuint256[]the array of ids of chosen dispute resolvers (can be 0)
_agentIdsuint256[]the array of ids of agents

reserveRange

Reserves a range of vouchers to be associated with an offer
Reverts if:
- The offers region of protocol is paused
- The exchanges region of protocol is paused
- Offer does not exist
- Offer already voided
- Caller is not the seller
- Range length is zero
- Range length is greater than quantity available
- Range length is greater than maximum allowed range length
- Call to BosonVoucher.reserveRange() reverts
- _to is not the BosonVoucher contract address or the BosonVoucher contract owner

function reserveRange(uint256 _offerId,
uint256 _length,
address _to)
external

Arguments

NameTypeDescription
_offerIduint256the id of the offer
_lengthuint256the length of the range
_toaddressthe address to send the pre-minted vouchers to (contract address or contract owner)

voidOffer

Voids a given offer.
Existing exchanges are not affected.
No further vouchers can be issued against a voided offer.
Emits an OfferVoided event if successful.
Reverts if:
- The offers region of protocol is paused
- Offer id is invalid
- Caller is not the assistant of the offer
- Offer has already been voided

function voidOffer(uint256 _offerId) 
external

Arguments

NameTypeDescription
_offerIduint256the id of the offer to void

voidOfferBatch

Voids a batch of offers.
Existing exchanges are not affected.
No further vouchers can be issued against a voided offer.
Emits an OfferVoided event for every offer if successful.
Reverts if, for any offer:
- The offers region of protocol is paused
- Offer id is invalid
- Caller is not the assistant of the offer
- Offer has already been voided

function voidOfferBatch(uint256[] _offerIds) 
external

Arguments

NameTypeDescription
_offerIdsuint256[]list of ids of offers to void

extendOffer

Sets new valid until date.
Emits an OfferExtended event if successful.
Reverts if:
- The offers region of protocol is paused
- Offer does not exist
- Caller is not the assistant of the offer
- New valid until date is before existing valid until dates
- Offer has voucherRedeemableUntil set and new valid until date is greater than that

function extendOffer(uint256 _offerId,
uint256 _validUntilDate)
external

Arguments

NameTypeDescription
_offerIduint256the id of the offer to extend
_validUntilDateuint256new valid until date

extendOfferBatch

Sets new valid until date for a batch of offers.
Emits an OfferExtended event for every offer if successful.
Reverts if:
- The offers region of protocol is paused
- For any of the offers:
- Offer does not exist
- Caller is not the assistant of the offer
- New valid until date is before existing valid until dates
- Offer has voucherRedeemableUntil set and new valid until date is greater than that

function extendOfferBatch(uint256[] _offerIds,
uint256 _validUntilDate)
external

Arguments

NameTypeDescription
_offerIdsuint256[]list of ids of the offers to extend
_validUntilDateuint256new valid until date

getOffer

Gets the details about a given offer.

function getOffer(uint256 _offerId) 
external
view
returns(bool exists,
BosonTypes.Offer memory offer,
BosonTypes.OfferDates memory offerDates,
BosonTypes.OfferDurations memory offerDurations,
BosonTypes.DisputeResolutionTerms memory disputeResolutionTerms,
BosonTypes.OfferFees memory offerFees)

Arguments

NameTypeDescription
_offerIduint256the id of the offer to retrieve

Returns

NameTypeDescription
existsboolthe offer was found
offerBosonTypes.Offerthe offer details. See {BosonTypes.Offer}
offerDatesBosonTypes.OfferDatesthe offer dates details. See {BosonTypes.OfferDates}
offerDurationsBosonTypes.OfferDurationsthe offer durations details. See {BosonTypes.OfferDurations}
disputeResolutionTermsBosonTypes.DisputeResolutionTermsthe details about the dispute resolution terms. See {BosonTypes.DisputeResolutionTerms}
offerFeesBosonTypes.OfferFeesthe offer fees details. See {BosonTypes.OfferFees}

getNextOfferId

Gets the next offer id.Does not increment the counter.

function getNextOfferId() 
external
view
returns(uint256 nextOfferId)

Returns

NameTypeDescription
nextOfferIduint256the next offer id

isOfferVoided

Checks if offer is voided or not.

function isOfferVoided(uint256 _offerId) 
external
view
returns(bool exists, bool offerVoided)

Arguments

NameTypeDescription
_offerIduint256the id of the offer to check

Returns

NameTypeDescription
existsboolthe offer was found
offerVoidedbooltrue if voided, false otherwise

getAgentIdByOffer

Gets the agent id for a given offer id.

function getAgentIdByOffer(uint256 _offerId) 
external
view
returns(bool exists, uint256 agentId)

Arguments

NameTypeDescription
_offerIduint256the offer id

Returns

NameTypeDescription
existsboolwhether the agent id exists
agentIduint256the agent id