BandoRouter
BandoRouter
Overview
The BandoRouter
serves as the main entry point for users to submit fulfillment requests. It routes requests to the appropriate fulfillable contracts, validates service information, and ensures that tokens and amounts meet the required criteria before processing.
The BandoRouter
is responsible for:
Validating service IDs and references against the registry
Calculating fee amounts based on service configurations
Routing native currency fulfillment requests to the
BandoFulfillable
contractRouting ERC20 token fulfillment requests to the
BandoERC20Fulfillable
contractValidating that ERC20 tokens are registered in the token registry
The contract follows a versioned inheritance pattern:
BandoRouterV1
: Base functionality for request routingBandoRouterV1_1
: Enhanced functionality and optimizations
The BandoRouter
responsibilities can be broken down into the following concepts:
Request Routing
The following methods are called by users to submit fulfillment requests:
requestService
Allows a user to request a fulfillment using native currency. The function validates the service information, calculates the fee amount, and forwards the request to the BandoFulfillable
contract for escrow.
Effects:
Validates the service ID and reference
Retrieves the service details and fee percentage from the registry
Calculates the fee amount based on the sent value and fee percentage
Creates a
FulFillmentRequest
with the caller as the payerCalls
IBandoFulfillable(_escrow).escrow(serviceId, request)
to escrow the fundsEmits
FulfillmentRequested(serviceId, serviceRef, fiatAmount, msg.sender, msg.value)
event
Requirements:
serviceId
MUST be a valid service ID in the registryserviceRef
MUST be a valid reference for the servicefiatAmount
MUST be greater than zeroSent value MUST be greater than zero
requestERC20Service
) external
Validates if a service ID and reference are valid.
Fee Calculation
Calculates the fee amount based on the total amount and fee basis points.
Events
Emitted when a native currency fulfillment is requested.
Emitted when an ERC20 token fulfillment is requested.
Errors
Emitted when an invalid service ID is provided.
Emitted when an invalid service reference is provided.
Emitted when an unregistered token is used for fulfillment.
Access Control
The router is designed to be used by any user, with validation performed through the service registry:
Service validation ensures that only valid service IDs and references are processed
Token validation ensures that only registered tokens are used for ERC20 fulfillments
Integration Points
Interacts with
IFulfillableRegistry
to validate services and get fee informationInteracts with
IERC20TokenRegistry
to validate tokens for ERC20 fulfillmentsCalls
IBandoFulfillable.escrow()
to escrow native currency for fulfillmentCalls
IBandoERC20Fulfillable.escrow()
to escrow ERC20 tokens for fulfillment
Last updated
Was this helpful?