diff --git a/chain/pack.py b/chain/pack.py index 5a0a1cf..8088349 100644 --- a/chain/pack.py +++ b/chain/pack.py @@ -60,8 +60,10 @@ def build(E): w('## Events emitted by the contract (%s logs in the window)' % ev.get('total')) for t in ev.get('by_topic', []): w('- %s %s: %d' % (t['topic'][:10], t['name'] or '', t['count'])) for nm, d in (E.get('decoded_events') or {}).items(): - w('- Decoded %s: %d events; sums of number fields (raw integer units; for 18-decimal coins divide by 10^18): %s; top addresses per field: %s; first samples: %s' % ( - nm, d['count'], json.dumps(d['uint_field_sums_raw']), json.dumps(d['top_addresses']), json.dumps(d['first_samples']))) + # also print big sums already divided by 10^18 (2 decimals) so the model never has to convert and the fact gate can match + as18 = {k: round(int(v) / 1e18, 2) for k, v in (d['uint_field_sums_raw'] or {}).items() if isinstance(v, (int, str)) and str(v).isdigit() and int(v) >= 10 ** 12} + w('- Decoded %s: %d events; sums of number fields (raw integer units): %s; the same sums as 18-decimal amounts (%s or an 18-decimal token, 2 decimals): %s; top addresses per field: %s; first samples: %s' % ( + nm, d['count'], json.dumps(d['uint_field_sums_raw']), E['native'], json.dumps(as18), json.dumps(d['top_addresses']), json.dumps(d['first_samples']))) cn = E.get('counts') or {} w('\n## Precomputed counts (use these, do not recount)') w('- Upgraded events total: %s' % cn.get('upgrade_events_total'))