BandoFulfillmentManager
BandoFulfillmentManager
Overview
The BandoFulfillmentManager is the central component of the EVM Fulfillment Protocol that manages the registration of fulfillment results and coordinates between fulfillable contracts and the service registry. It serves as the primary entry point for fulfillers to register the results of fulfillment operations and manages the withdrawal of funds for both native currency and ERC20 tokens.
The BandoFulfillmentManager is responsible for:
Validating that only authorized fulfillers can register results for their services
Registering fulfillment results with the appropriate fulfillable contracts
Managing withdrawals of released funds to beneficiaries
Managing withdrawals of accumulated fees to fulfillers
In V1_2, managing DEX aggregator whitelisting and token swapping to stablecoins
The contract follows a versioned inheritance pattern:
BandoFulfillmentManagerV1: Base functionality for fulfillment registrationBandoFulfillmentManagerV1_1: Enhanced functionality and optimizationsBandoFulfillmentManagerV1_2: Added support for stablecoin swapping via DEX aggregators
The BandoFulfillmentManager responsibilities can be broken down into the following concepts:
Fulfillment Registration
The following methods are called by fulfillers to register the results of fulfillment operations:
registerFulfillment
Registers a fulfillment result for a native currency service. The function validates that the caller is the authorized fulfiller for the service and then registers the result with the native currency fulfillable contract.
Effects:
Validates the caller is the authorized fulfiller for the service
Calls
IBandoFulfillable(_escrow).registerFulfillment(serviceID, result)to register the resultEmits
FulfillmentRegistered(serviceID, result)event
Requirements:
Caller MUST be the authorized fulfiller for the service or the contract owner
registerERC20Fulfillment
Registers a fulfillment result for an ERC20 token service. The function validates that the caller is the authorized fulfiller for the service and then registers the result with the ERC20 token fulfillable contract.
Effects:
Validates the caller is the authorized fulfiller for the service
Calls
IBandoERC20Fulfillable(_erc20_escrow).registerFulfillment(serviceID, result)to register the resultEmits
ERC20FulfillmentRegistered(serviceID, result)event
Requirements:
Caller MUST be the authorized fulfiller for the service or the contract owner
Fund Withdrawal
The following methods are called by fulfillers to withdraw funds for their services:
beneficiaryWithdraw
Withdraws the beneficiary's available native currency balance to release (fulfilled with success). Only the fulfiller can withdraw the releaseable pool.
Effects:
Validates the caller is the authorized fulfiller for the service
Calls
IBandoFulfillable(_escrow).beneficiaryWithdraw(serviceId)to withdraw fundsEmits
WithdrawnToBeneficiary(serviceId, service.beneficiary)event
Requirements:
Caller MUST be the authorized fulfiller for the service
beneficiaryWithdrawERC20
Withdraws the beneficiary's available ERC20 token balance to release (fulfilled with success). Only the fulfiller can withdraw the releaseable pool.
Effects:
Validates the caller is the authorized fulfiller for the service
Calls
IBandoERC20Fulfillable(_erc20_escrow).beneficiaryWithdraw(serviceId, token)to withdraw tokensEmits
WithdrawnToBeneficiary(serviceId, service.beneficiary)event
Requirements:
Caller MUST be the authorized fulfiller for the service
tokenMUST be a valid token address
Stablecoin Swapping
The following methods are available in V1_2 for swapping funds to stablecoins:
fulfillERC20AndSwap
Registers a fulfillment result and optionally swaps both releaseable pool and accumulated fees to stablecoins in a single transaction for ERC20 tokens. The swap is done using an off-chain generated DEX aggregator call.
Effects:
Validates the caller is the authorized fulfiller for the service
Validates the result status is SUCCESS
Validates the aggregator is whitelisted
Calls
IBandoERC20Fulfillable(_erc20_escrow).registerFulfillment(serviceID, result)to register the resultIf
swapis true, callsIBandoERC20FulfillableV1_2(_erc20_escrow).swapPoolsToStable(serviceID, result.id, swapData)to swap tokensCalls
_accumulateFulfillerReleaseablePoolAndFees(serviceID, swapData.toToken)to accumulate fundsEmits
ERC20FulfillmentRegistered(serviceID, result)event
Requirements:
Caller MUST be the authorized fulfiller for the service or the contract owner
result.statusMUST beFulFillmentResultState.SUCCESSswapData.callToMUST be a whitelisted aggregator
DEX Aggregator Management
The following methods are available in V1_2 for managing DEX aggregators:
addAggregator
Adds a DEX aggregator address to the whitelist. Only the contract owner can add aggregators.
Effects:
Validates the aggregator address is not zero
Adds the aggregator to the whitelist
Emits
AggregatorAdded(aggregator)event
Requirements:
Caller MUST be the contract owner
aggregatorMUST NOT be the zero address
Parameterization
_escrow: Address of the native currency fulfillable contract_erc20_escrow: Address of the ERC20 token fulfillable contract_serviceRegistry: Address of the service registry contract
Last updated
Was this helpful?