{"abstract":"The payout differs by a minor unit from converting the net amount once.","category":"Currency rounding and FX conversion","checks":8,"contract":"solve(amount, rate, src_exp, dst_exp, fee_bps, min_fee): amount and min_fee are source minor units, fee_bps a non-negative integer. fee = max(min_fee, ceil(amount*fee_bps/10000)) in source minor units, deducted before conversion. A fee greater than or equal to the amount returns 'ERR:amount-below-fee'; a non-positive amount or negative bps returns 'ERR:input'. The net amount is converted exactly (net * rate * 10**(dst_exp - src_exp)) and rounded half-even. Return [fee, converted].","contract_signature":"amount, rate, src_exp, dst_exp, fee_bps, min_fee","evaluation_group":"w2-currency_rounding_and_fx_conversion-conversion-fee-bps","failed_approach":"Subtracting the unconverted source fee from the converted gross mixes currencies.","family":"w2-currency_rounding_and_fx_conversion-conversion-fee-bps-fee-conversion-order","id":"FA-62061","implementations":{"attempt":{"sha256":"dedd75083014e9ee46a782476316efb42e719e3ca73b7036f7df511d39b82d58","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nfrom decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN\nN = 1\nobservations = []\ndef solve(amount, rate, src_exp, dst_exp, fee_bps, min_fee):\n    if fee_bps < 0 or amount <= 0: return 'ERR:input'\n    conv = lambda m: Decimal(m) * Decimal(rate) * Decimal(10) ** (dst_exp - src_exp)\n    rq = lambda d: int(d.quantize(Decimal(1), rounding=ROUND_HALF_EVEN))\n    pct = -(-amount * fee_bps // 10000)\n    fee = max(min_fee, pct)\n    if fee >= amount: return 'ERR:amount-below-fee'\n    return [fee, rq(conv(amount)) - fee]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression fee-conversion-order 1', (123456, '0.92', 2, 2, 250, 199), [3087, 110739]),\n  ('regression fee-conversion-order 2', (314862, '122.2171', 2, 2, 5, 1000), [1000, 38359303]),\n  ('partial repair guard 1', (10000, '151.37', 2, 0, 150, 50), [150, 14910]),\n  ('partial repair guard 2', (20000, '0.3071', 2, 3, 25, 100), [100, 61113]),\n  ('control: fee rounds up', (1001, '1', 2, 2, 100, 0), [11, 990]),\n  ('control: fee equals amount', (500, '0.9', 2, 2, 10, 500), 'ERR:amount-below-fee'),\n  ('control: zero bps', (777, '1.0833', 2, 2, 0, 0), [0, 842]),\n  ('control: invalid amount', (0, '1.1', 2, 2, 10, 0), 'ERR:input')],\n [('regression fee-conversion-order 1', (234309, '91.3439', 3, 3, 333, 100), [7803, 20689941]),\n  ('regression fee-conversion-order 2', (440114, '2728.61', 0, 0, 333, 1), [14656, 1160908953]),\n  ('partial repair guard 1', (123456, '0.92', 2, 2, 250, 199), [3087, 110739]),\n  ('partial repair guard 2', (197637, '16116.34', 0, 2, 333, 100), [6582, 307910733870]),\n  ('control: minimum fee applies', (20000, '0.3071', 2, 3, 25, 100), [100, 61113]),\n  ('control: zero bps', (777, '1.0833', 2, 2, 0, 0), [0, 842]),\n  ('control: invalid amount', (0, '1.1', 2, 2, 10, 0), 'ERR:input'),\n  ('control: minimum exceeds amount', (99, '1.2', 2, 2, 5, 150), 'ERR:amount-below-fee')],\n [('regression fee-conversion-order 1', (41069, '21.2905', 3, 3, 333, 1000), [1368, 845254]),\n  ('regression fee-conversion-order 2', (449567, '33.1467', 2, 0, 150, 50), [6744, 146781]),\n  ('partial repair guard 1', (22226, '179.9447', 0, 2, 150, 100), [334, 393934937]),\n  ('partial repair guard 2', (50411, '12342.04', 3, 3, 333, 1), [1679, 601452293]),\n  ('control: invalid amount', (0, '1.1', 2, 2, 10, 0), 'ERR:input'),\n  ('control: minimum exceeds amount', (99, '1.2', 2, 2, 5, 150), 'ERR:amount-below-fee'),\n  ('control: yen payout', (10000, '151.37', 2, 0, 150, 50), [150, 14910]),\n  ('control: fee rounds up', (1001, '1', 2, 2, 100, 0), [11, 990])],\n [('regression fee-conversion-order 1', (55979, '2.35354', 3, 0, 0, 1000), [1000, 129]),\n  ('regression fee-conversion-order 2', (409473, '130.7752', 3, 3, 333, 1), [13636, 51765663]),\n  ('partial repair guard 1', (268603, '16.66106', 2, 0, 150, 50), [4030, 44081]),\n  ('partial repair guard 2', (269350, '9.84392', 0, 3, 333, 0), [8970, 2563159890]),\n  ('control: fee rounds up', (1001, '1', 2, 2, 100, 0), [11, 990]),\n  ('control: fee equals amount', (500, '0.9', 2, 2, 10, 500), 'ERR:amount-below-fee'),\n  ('control: minimum fee applies', (20000, '0.3071', 2, 3, 25, 100), [100, 61113]),\n  ('control: zero bps', (777, '1.0833', 2, 2, 0, 0), [0, 842])],\n [('regression fee-conversion-order 1', (34239, '182.6706', 2, 0, 25, 1), [86, 62387]),\n  ('regression fee-conversion-order 2', (180714, '131.9673', 3, 0, 150, 0), [2711, 23491]),\n  ('partial repair guard 1', (314862, '122.2171', 2, 2, 5, 1000), [1000, 38359303]),\n  ('partial repair guard 2', (84375, '129.7381', 0, 0, 99, 250), [836, 10838191]),\n  ('control: zero bps', (777, '1.0833', 2, 2, 0, 0), [0, 842]),\n  ('control: large percentage fee', (123456, '0.92', 2, 2, 250, 199), [3087, 110739]),\n  ('control: invalid amount', (0, '1.1', 2, 2, 10, 0), 'ERR:input'),\n  ('control: minimum exceeds amount', (99, '1.2', 2, 2, 5, 150), 'ERR:amount-below-fee')]]\nfor label, args, expected in cases[N - 1]:\n    check(label, solve(*args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"cbea911503b7615d386c8d4bfb0e7fcaa83dd8a682cab7f8313374743d04d89a","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nfrom decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN\nN = 1\nobservations = []\ndef solve(amount, rate, src_exp, dst_exp, fee_bps, min_fee):\n    if fee_bps < 0 or amount <= 0: return 'ERR:input'\n    conv = lambda m: Decimal(m) * Decimal(rate) * Decimal(10) ** (dst_exp - src_exp)\n    rq = lambda d: int(d.quantize(Decimal(1), rounding=ROUND_HALF_EVEN))\n    pct = -(-amount * fee_bps // 10000)\n    fee = max(min_fee, pct)\n    if fee >= amount: return 'ERR:amount-below-fee'\n    return [fee, rq(conv(amount)) - rq(conv(fee))]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression fee-conversion-order 1', (123456, '0.92', 2, 2, 250, 199), [3087, 110739]),\n  ('regression fee-conversion-order 2', (314862, '122.2171', 2, 2, 5, 1000), [1000, 38359303]),\n  ('partial repair guard 1', (10000, '151.37', 2, 0, 150, 50), [150, 14910]),\n  ('partial repair guard 2', (20000, '0.3071', 2, 3, 25, 100), [100, 61113]),\n  ('control: fee rounds up', (1001, '1', 2, 2, 100, 0), [11, 990]),\n  ('control: fee equals amount', (500, '0.9', 2, 2, 10, 500), 'ERR:amount-below-fee'),\n  ('control: zero bps', (777, '1.0833', 2, 2, 0, 0), [0, 842]),\n  ('control: invalid amount', (0, '1.1', 2, 2, 10, 0), 'ERR:input')],\n [('regression fee-conversion-order 1', (234309, '91.3439', 3, 3, 333, 100), [7803, 20689941]),\n  ('regression fee-conversion-order 2', (440114, '2728.61', 0, 0, 333, 1), [14656, 1160908953]),\n  ('partial repair guard 1', (123456, '0.92', 2, 2, 250, 199), [3087, 110739]),\n  ('partial repair guard 2', (197637, '16116.34', 0, 2, 333, 100), [6582, 307910733870]),\n  ('control: minimum fee applies', (20000, '0.3071', 2, 3, 25, 100), [100, 61113]),\n  ('control: zero bps', (777, '1.0833', 2, 2, 0, 0), [0, 842]),\n  ('control: invalid amount', (0, '1.1', 2, 2, 10, 0), 'ERR:input'),\n  ('control: minimum exceeds amount', (99, '1.2', 2, 2, 5, 150), 'ERR:amount-below-fee')],\n [('regression fee-conversion-order 1', (41069, '21.2905', 3, 3, 333, 1000), [1368, 845254]),\n  ('regression fee-conversion-order 2', (449567, '33.1467', 2, 0, 150, 50), [6744, 146781]),\n  ('partial repair guard 1', (22226, '179.9447', 0, 2, 150, 100), [334, 393934937]),\n  ('partial repair guard 2', (50411, '12342.04', 3, 3, 333, 1), [1679, 601452293]),\n  ('control: invalid amount', (0, '1.1', 2, 2, 10, 0), 'ERR:input'),\n  ('control: minimum exceeds amount', (99, '1.2', 2, 2, 5, 150), 'ERR:amount-below-fee'),\n  ('control: yen payout', (10000, '151.37', 2, 0, 150, 50), [150, 14910]),\n  ('control: fee rounds up', (1001, '1', 2, 2, 100, 0), [11, 990])],\n [('regression fee-conversion-order 1', (55979, '2.35354', 3, 0, 0, 1000), [1000, 129]),\n  ('regression fee-conversion-order 2', (409473, '130.7752', 3, 3, 333, 1), [13636, 51765663]),\n  ('partial repair guard 1', (268603, '16.66106', 2, 0, 150, 50), [4030, 44081]),\n  ('partial repair guard 2', (269350, '9.84392', 0, 3, 333, 0), [8970, 2563159890]),\n  ('control: fee rounds up', (1001, '1', 2, 2, 100, 0), [11, 990]),\n  ('control: fee equals amount', (500, '0.9', 2, 2, 10, 500), 'ERR:amount-below-fee'),\n  ('control: minimum fee applies', (20000, '0.3071', 2, 3, 25, 100), [100, 61113]),\n  ('control: zero bps', (777, '1.0833', 2, 2, 0, 0), [0, 842])],\n [('regression fee-conversion-order 1', (34239, '182.6706', 2, 0, 25, 1), [86, 62387]),\n  ('regression fee-conversion-order 2', (180714, '131.9673', 3, 0, 150, 0), [2711, 23491]),\n  ('partial repair guard 1', (314862, '122.2171', 2, 2, 5, 1000), [1000, 38359303]),\n  ('partial repair guard 2', (84375, '129.7381', 0, 0, 99, 250), [836, 10838191]),\n  ('control: zero bps', (777, '1.0833', 2, 2, 0, 0), [0, 842]),\n  ('control: large percentage fee', (123456, '0.92', 2, 2, 250, 199), [3087, 110739]),\n  ('control: invalid amount', (0, '1.1', 2, 2, 10, 0), 'ERR:input'),\n  ('control: minimum exceeds amount', (99, '1.2', 2, 2, 5, 150), 'ERR:amount-below-fee')]]\nfor label, args, expected in cases[N - 1]:\n    check(label, solve(*args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"A deterministic, bounded teaching model with a stipulated toy contract; it makes no claim of conformance to any real regulation, standard, or institution's rules. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"w2-currency_rounding_and_fx_conversion-conversion-fee-bps-fee-conversion-order","generated_at":"2026-09-29T14:47:01.081881+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Currency amounts must be rounded at the right stage and in the right unit, or ledgers, quotes and settlements drift by minor units.","root_cause":"Gross amount and fee are each converted and rounded, then subtracted.","sha256":"e406d24ef04aa53bd162fe5898e8d756d2a649d2d9712d74b93b6ea9bc155f14","title":"The fee is converted and rounded separately from the gross amount · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verified":true,"visibility":"public","verification":{"attempt":{"elapsed_ms":40.868,"exit_code":1,"observations":[{"actual":[3087,110493],"check":"regression fee-conversion-order 1","expected":[3087,110739],"passed":false},{"actual":[1000,38480521],"check":"regression fee-conversion-order 2","expected":[1000,38359303],"passed":false},{"actual":[150,14987],"check":"partial repair guard 1","expected":[150,14910],"passed":false},{"actual":[100,61320],"check":"partial repair guard 2","expected":[100,61113],"passed":false},{"actual":[11,990],"check":"control: fee rounds up","expected":[11,990],"passed":true},{"actual":"ERR:amount-below-fee","check":"control: fee equals amount","expected":"ERR:amount-below-fee","passed":true},{"actual":[0,842],"check":"control: zero bps","expected":[0,842],"passed":true},{"actual":"ERR:input","check":"control: invalid amount","expected":"ERR:input","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression fee-conversion-order 1\", \"actual\": [3087, 110493], \"expected\": [3087, 110739], \"passed\": false}, {\"check\": \"regression fee-conversion-order 2\", \"actual\": [1000, 38480521], \"expected\": [1000, 38359303], \"passed\": false}, {\"check\": \"partial repair guard 1\", \"actual\": [150, 14987], \"expected\": [150, 14910], \"passed\": false}, {\"check\": \"partial repair guard 2\", \"actual\": [100, 61320], \"expected\": [100, 61113], \"passed\": false}, {\"check\": \"control: fee rounds up\", \"actual\": [11, 990], \"expected\": [11, 990], \"passed\": true}, {\"check\": \"control: fee equals amount\", \"actual\": \"ERR:amount-below-fee\", \"expected\": \"ERR:amount-below-fee\", \"passed\": true}, {\"check\": \"control: zero bps\", \"actual\": [0, 842], \"expected\": [0, 842], \"passed\": true}, {\"check\": \"control: invalid amount\", \"actual\": \"ERR:input\", \"expected\": \"ERR:input\", \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":42.689,"exit_code":1,"observations":[{"actual":[3087,110740],"check":"regression fee-conversion-order 1","expected":[3087,110739],"passed":false},{"actual":[1000,38359304],"check":"regression fee-conversion-order 2","expected":[1000,38359303],"passed":false},{"actual":[150,14910],"check":"partial repair guard 1","expected":[150,14910],"passed":true},{"actual":[100,61113],"check":"partial repair guard 2","expected":[100,61113],"passed":true},{"actual":[11,990],"check":"control: fee rounds up","expected":[11,990],"passed":true},{"actual":"ERR:amount-below-fee","check":"control: fee equals amount","expected":"ERR:amount-below-fee","passed":true},{"actual":[0,842],"check":"control: zero bps","expected":[0,842],"passed":true},{"actual":"ERR:input","check":"control: invalid amount","expected":"ERR:input","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression fee-conversion-order 1\", \"actual\": [3087, 110740], \"expected\": [3087, 110739], \"passed\": false}, {\"check\": \"regression fee-conversion-order 2\", \"actual\": [1000, 38359304], \"expected\": [1000, 38359303], \"passed\": false}, {\"check\": \"partial repair guard 1\", \"actual\": [150, 14910], \"expected\": [150, 14910], \"passed\": true}, {\"check\": \"partial repair guard 2\", \"actual\": [100, 61113], \"expected\": [100, 61113], \"passed\": true}, {\"check\": \"control: fee rounds up\", \"actual\": [11, 990], \"expected\": [11, 990], \"passed\": true}, {\"check\": \"control: fee equals amount\", \"actual\": \"ERR:amount-below-fee\", \"expected\": \"ERR:amount-below-fee\", \"passed\": true}, {\"check\": \"control: zero bps\", \"actual\": [0, 842], \"expected\": [0, 842], \"passed\": true}, {\"check\": \"control: invalid amount\", \"actual\": \"ERR:input\", \"expected\": \"ERR:input\", \"passed\": true}], \"passed\": false}\n"}},"member_only":{"stages":["fixed"],"fields":["implementations.fixed","verification.fixed","harness","repair"],"note":"The verified repair, its recorded checks, the repair description, and the scoring harness are available to members."}}