Skip to content

Conversation

@Ang-dot
Copy link
Contributor

@Ang-dot Ang-dot commented Jan 6, 2026

PR changes:

  • add evaluator rejection reason
  • DRY hydrate job function
  • implement payableAmount in SDK level

@Ang-dot Ang-dot requested a review from Zuhwa January 6, 2026 07:49
@Ang-dot Ang-dot force-pushed the feat/yang-fix-rejection-reason branch from 9136129 to 0d059da Compare January 6, 2026 09:54
@Ang-dot Ang-dot changed the title feat: rejectionReason to cover evaluator rejection SDK clean-ups Jan 6, 2026
@Ang-dot Ang-dot force-pushed the feat/yang-fix-rejection-reason branch from 47f8011 to 7f59360 Compare January 8, 2026 06:54
@JohnsonChin1009
Copy link
Collaborator

Performed two main testings for netPayableAmount calculation in SDK level.

USDC (6 Decimals)

Since USDC has a maximum of 6 decimals, the edge case that I aimed to test is if the calculated service fee is < 1μ it should default to 1μ (in this case, 0.005 will be 0.0000005 which translates to 0.5μ).

  • Input: Use fund_transfer with Pepechad, transfer 0.005 USDC to <target_address>
  • Expected Output: target_address gets 0.000001 USDC, <agent> gets 0.004999 USDC
  • Actual Output: target_address gets 0.005 USDC, <agent> gets 0 USDC

This contradicts with the design where any service fee that is <1μ should always default to 1μ

*Important to note that μ in solidity only supports integer and not values such as 0.5

Next Steps: Identify the issue and where to fix it by @Ang-dot

Ether (18 Decimals)

For tokens that have 18 decimals, the function that truncates to decimals is actually making the calculation lose accuracy because it only truncates to 6 decimals as shown below:

// acpFare.ts
constructor(fareAmount: number, fare: Fare) {
  const truncateTo6Decimals = (input: string): number => {
    const [intPart, decPart = ""] = input.split(".");

    if (decPart === "") {
      return parseFloat(intPart);
    }

    const truncated = decPart.slice(0, 6).padEnd(6, "0");

    return parseFloat(`${intPart}.${truncated}`);
  };

  super(fare.formatAmount(truncateTo6Decimals(fareAmount.toString())), fare);
}

Hence, I've implemented a fix for it by letting it truncate to take in the decimal from the Fare object

constructor(fareAmount: number, fare: Fare) {
  const truncateToTokenDecimals = (input: string, decimals: number): number => {
    const [intPart, decPart = ""] = input.split(".");

    if (decPart === "") {
      return parseFloat(intPart);
    }

    const truncated = decPart.slice(0, decimals);

    return parseFloat(`${intPart}.${truncated}`);
  };

  super(fare.formatAmount(truncateToTokenDecimals(fareAmount.toString(), fare.decimals)), fare);
}

Next Steps: Review the code and make sure that it is backward compatible with USDC (tested out by @JohnsonChin1009, but needs someone to help review)
Results

truncateTo6Decimals truncateToTokenDecimals
Input 0.003456789123 0.003456789123
Truncated Output 0.003456 0.003456789123

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants