Skip to main content

makeOffer

Function Type: external
Function Signature: makeOffer(address,uint256,string,uint256,uint256,uint256,bytes,uint256,bool,bytes) Function Selector: 0x52649c2e

Allows a user (_user) to make a formal, time-limited offer to purchase an existing username (_username) by committing principal tokens. This function must be executed by an sMATE staker (msg.sender).

Parameters

ParameterTypeDescription
useraddressThe address of the end-user making the offer (offeror).
usernamestringThe target username for which the offer is being made.
expireDateuint256The Unix timestamp when this offer automatically expires if not accepted or withdrawn.
amountuint256The total gross amount of principal tokens the offeror commits. This includes the actual offer value plus a 0.5% service fee.
nonceuint256The offeror's nonce specific to this NameService contract for replay protection of this makeOffer action.
signaturebytesThe EIP-191 signature from user authorizing this make offer action.
priorityFee_EVVMuint256Optional fee (in MATE) paid by user to the msg.sender (staker executing the transaction) via the EVVM contract for prioritized processing.
nonce_EVVMuint256user's nonce for the EVVM payment function call used to transfer the total payment.
priorityFlag_EVVMboolPriority flag (sync/async) for the EVVM payment function call.
signature_EVVMbytesuser's signature authorizing the EVVM payment call to transfer the total payment.

Returns: offerID - Unique identifier for the created offer

note

Execution Methods

This function can be executed by any address.

Fisher Execution

When the executor is the fisher:

  1. The user sends the payment request to the fishing spot
  2. The fisher captures the transaction and validates all parameters
  3. The fisher submits the transaction to the contract for processing

Direct Execution

When the executor is the user or a service:

  1. The user/service submits their transaction directly to the contract

Workflow

  1. NameService Nonce Verification: Checks if the provided nonce is unused for the user using the verifyIfNonceIsAvailable modifier. Reverts if used.

  2. Offer Validation: Validates the offer parameters:

    • Ensures the target username exists and is not flagged as a pre-registration
    • Verifies amount > 0 and expireDate > block.timestamp
    • Reverts with PreRegistrationNotValid if validation fails
  3. Make Offer Signature Validation: Verifies the signature provided by user using verifyMessageSignedForMakeOffer. Reverts with InvalidSignatureOnNameService if invalid.

  4. Payment Execution: Calls makePay to transfer the amount and priorityFee_EVVM from user to the service via EVVM. Reverts if payment fails.

  5. Offer ID Assignment: Finds the next available sequential ID for an offer by looping through existing offer slots until an empty one (address(0) offerer) is found.

  6. Offer Creation: Creates and stores the offer in the usernameOffers mapping with:

    • offerer: user
    • expireDate: provided expiration timestamp
    • amount: net offer amount (99.5% of input amount after 0.5% fee)
  7. Reward Distribution: Distributes rewards to the executor via makeCaPay:

    • Base MATE reward (getRewardAmount())
    • Plus 0.125% of the gross amount
    • Plus the priorityFee_EVVM
  8. Token Locking: Updates mateTokenLockedForWithdrawOffers to track locked tokens for future withdrawals.

  9. Offer Slot Management: Updates the username's offerMaxSlots if this offer exceeds the current maximum slot count.

  10. Nonce Management: Marks the user's nonce as used in the nameServiceNonce mapping.

makeOffer fisher execution makeOffer direct execution