Skip to content
Business logic Audit finding Intermediate

Incorrect processing fee calculation causes venue payouts to be misallocated

The payToVenue function in BelongCheckIn.sol calculates the platform processing fee on the customer's total LONG payment instead of on the platform subsidy amount. As a result, venues receive fewer LONG tokens than intended on every LONG payment, causing cumulative loss of venue revenue.

Oxv1bh4 Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

57221 sc high incorrect processing fee calculation causes venue payouts to be misallocated

Submitted on Oct 24th 2025 at 14:06:45 UTC by @Oxv1bh4 for Audit Comp | Belong

Description

Brief / Intro

The processingFeePercentage is intended to be applied as a fraction of the platformSubsidyPercentage when customers pay with LONG tokens. Due to a logic error, it is instead computed on the total payment amount rather than on the subsidy, causing venues to receive substantially fewer LONG tokens than intended.

Vulnerability Details

In the BelongCheckIn.sol::payToVenue function (link below), when customers pay with LONG tokens:

  • platformSubsidyPercentage is the LONG subsidy the platform adds for the merchant.
  • processingFeePercentage is the portion of that LONG subsidy collected by the platform as a processing fee.

However, the function calculates the processing fee on the total LONG payment amount instead of on the subsidy amount.

Relevant code excerpt:

Solidity
// platform subsidy - processing fee
// @audit - Processing Fee should be calculated on the Platform Subsidy amount.
uint256 subsidyMinusFees =
    _storage.fees.platformSubsidyPercentage.calculateRate(customerInfo.amount)
    - _storage.fees.processingFeePercentage.calculateRate(customerInfo.amount);
_storage.contracts.escrow
    .distributeLONGDiscount(customerInfo.venueToPayFor, address(this), subsidyMinusFees);

This subtracts processing fees calculated over the entire customer payment (customerInfo.amount) instead of the platform subsidy portion.

Impact Details

Affected party: Venue / Merchant

Because processingFeePercentage is applied on the total payment rather than on the platform subsidy, venues receive less LONG than intended.

Example:

  • Payment: 1,000 LONG
  • Customer Discount: 5%
  • Platform Subsidy: 3%
  • Processing Fee: 2.5%
  • Correct payout: 979.25 LONG
  • Current payout: 955 LONG
  • Loss per payment: 24.25 LONG

Repeated across many payments, this yields cumulative financial loss and reduced venue revenue.

Severity: High — aligns with permanent freezing of unclaimed yield.

References

Proof of Concept

The reporter updated the test case payToVenue() (both payment) (w/o promoter) in test/v2/platform/belong-check-in.test.ts to demonstrate the difference between the expected escrow-to-venue transfer (where processing fee is applied to the subsidy) and the actual transfer (where processing fee is incorrectly applied to the total amount).

Test snippet:

TS
it.only('payToVenue() (both payment) (w/o promoter)', async () => {
      const { belongCheckIn, escrow, helper, signer, USDC, ENA, USDC_whale, ENA_whale } = await loadFixture(fixture);

      const uri = 'uriuri';
      const venueAmount = await u(100, USDC);
      const venue = USDC_whale.address;
      const venueMessage = ethers.utils.solidityKeccak256(
        ['address', 'bytes32', 'string', 'uint256'],
        [venue, ethers.constants.HashZero, uri, chainId],
      );
      const venueSignature = EthCrypto.sign(signer.privateKey, venueMessage);
      const venueInfo: VenueInfoStruct = {
        rules: { paymentType: 3, bountyType: 0, longPaymentType: 0 } as VenueRulesStruct,
        venue,
        amount: venueAmount,
        referralCode: ethers.constants.HashZero,
        uri,
        signature: venueSignature,
      };
      const willBeTaken = convenienceFeeAmount.add(venueAmount);
      await USDC.connect(USDC_whale).approve(belongCheckIn.address, willBeTaken);
      await belongCheckIn.connect(USDC_whale).venueDeposit(venueInfo);

      const customerAmount = ethers.utils.parseEther('5');
      const customerMessage = ethers.utils.solidityKeccak256(
        ['bool', 'uint128', 'uint24', 'address', 'address', 'address', 'uint256', 'uint256'],
        [
          false, // paymentInUSDC
          0, // visitBountyAmount (uint24, adjust to uint256 if needed)
          0, // spendBountyPercentage (uint24, adjust to uint256 if needed)
          ENA_whale.address, // customer
          USDC_whale.address, // venueToPayFor
          ethers.constants.AddressZero, // promoter
          customerAmount, // amount
          chainId, // block.chainid
        ],
      );
      const customerSignature = EthCrypto.sign(signer.privateKey, customerMessage);
      const customerInfo: CustomerInfoStruct = {
        paymentInUSDC: false,
        visitBountyAmount: 0,
        spendBountyPercentage: 0,
        customer: ENA_whale.address,
        venueToPayFor: USDC_whale.address,
        promoter: ethers.constants.AddressZero,
        amount: customerAmount,
        signature: customerSignature,
      };

      const platformSubsidy = await helper.calculateRate(
        (
          await belongCheckIn.belongCheckInStorage()
        ).fees.platformSubsidyPercentage,
        customerAmount,
      );
      const processingFee = await helper.calculateRate(
        (
          await belongCheckIn.belongCheckInStorage()
        ).fees.processingFeePercentage,
        platformSubsidy,
      );
      const fromEscrowToVenueExpected = platformSubsidy.sub(processingFee);

      await ENA.connect(ENA_whale).approve(belongCheckIn.address, customerAmount);

      const escrowBalance_before = await ENA.balanceOf(escrow.address);

      await belongCheckIn.connect(ENA_whale).payToVenue(customerInfo);

      const escrowBalance_after = await ENA.balanceOf(escrow.address);

      const fromEscrowToVenueActual = escrowBalance_before.sub(escrowBalance_after);

      expect(fromEscrowToVenueExpected).to.not.eq(fromEscrowToVenueActual);

      const lossAmount = fromEscrowToVenueExpected.sub(fromEscrowToVenueActual);

      console.log("Expected LONG amount to be paid from the escrow to the venue: ", fromEscrowToVenueExpected);
      console.log("Actual LONG amount to be paid from the escrow to the venue: ", fromEscrowToVenueActual);
      console.log("Loss: ",lossAmount);
    });

Run the test with: npm run test


Note: Links and code snippets are preserved from the original report.

The original report as published on Immunefi, by Oxv1bh4. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The processing fee rate is applied to customerInfo.amount (the full payment) rather than to the platform subsidy amount, so the subtraction overstates the fee.

Impact

Venues receive less LONG than intended on each LONG payment, and repeated payments cause cumulative financial loss to venue revenue.

What the attacker needed

Customer pays with LONG tokens; platform subsidy and processing fee configured

The fix

The processing fee should be calculated on the platform subsidy amount rather than on the total customer payment.

How it was found

  1. Set up the test fixture with a venue deposit and a customer paying in LONG tokens.
  2. Compute the expected escrow-to-venue transfer by applying the processing fee to the platform subsidy.
  3. Record the escrow LONG balance before the call.
  4. Call payToVenue with the customer info.
  5. Record the escrow balance after and compare the actual transfer with the expected one to show the shortfall.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When a customer pays with LONG tokens, the platform adds a small bonus (a subsidy) to the venue and keeps a small cut (a processing fee) of that bonus. The code mistakenly takes the cut from the whole payment instead of just the bonus, so the venue gets less money than it should. Over many payments this adds up to a real loss for the venue.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by Oxv1bh4

View all

4 more disclosed reports, best first.

More from Belong

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.