exact_poly/constants.rs
1//! On-chain protocol constants matching polygon.move:31-42.
2//! These are HARDCODED — no Config struct, no runtime parameters.
3
4/// Scaling factor: 1 meter in fixed-point space (= 1_000_000 units).
5pub const SCALE: u64 = 1_000_000;
6
7/// Maximum world coordinate (Earth circumference in Web Mercator, scaled).
8pub const MAX_WORLD: u64 = 40_075_017_000_000;
9
10/// Maximum number of convex parts per polygon.
11pub const MAX_PARTS: usize = 10;
12
13/// Maximum vertices per convex part (admin-configurable on-chain, here hardcoded to protocol default).
14pub const MAX_VERTICES_PER_PART: usize = 64;
15
16/// Minimum edge length in fixed-point units (1 meter).
17pub const MIN_EDGE_LENGTH: u64 = 1_000_000;
18
19/// Minimum edge length squared (used to avoid sqrt). 1_000_000^2.
20pub const MIN_EDGE_LENGTH_SQUARED: u128 = 1_000_000_000_000;
21
22/// Minimum compactness ratio in parts-per-million for isoperimetric validation.
23/// Formula: 8_000_000 * twice_area >= MIN_COMPACTNESS_PPM * L1_perimeter^2
24pub const MIN_COMPACTNESS_PPM: u128 = 150_000;
25
26/// Divisor to convert twice_area_fp2 to whole square meters: 2 * SCALE^2.
27pub const AREA_DIVISOR: u128 = 2_000_000_000_000;