Cost Model

Pricing of compute leases

Lease pricing is fully deterministic. The cost is computed from the resource dimensions and duration using integer arithmetic with milli-XUSD precision. The ledger validates that every lease block carries the exact cost produced by this formula -- no negotiation, no rounding errors.

#Formula

The cost is calculated in two steps: a per-hour rate in milli-XUSD, then converted to whole XUSD:

text
perHourMilli = vCPUs x 20 + ceil(memoryMB / 1024) x 10 + diskGB x 1hours        = ceil(duration / 3600)costMilli    = perHourMilli x hourscost         = ceil(costMilli / 1000)     // minimum 1

In Go:

go
func LeaseCost(vcpus, memoryMB, diskGB, duration uint64) (uint64, error) {    hours := (duration + 3599) / 3600    memGB := (memoryMB + 1023) / 1024    perHourMilli := vcpus*LeaseVCPURate + memGB*LeaseMemGBRate + diskGB*LeaseDiskGBRate    costMilli := perHourMilli * hours  // overflow-checked via safeMul    cost := (costMilli + 999) / 1000   // ceiling divide    if cost == 0 { cost = 1 }    return cost, nil}

#Rate table

ResourceRateUnit
vCPU20 milli-XUSDper vCPU per hour
Memory10 milli-XUSDper GB per hour (rounded up to nearest GB)
Disk1 milli-XUSDper GB per hour

#Derived values

ValueFormulaDescription
CostSee aboveXUSD debited from consumer
Stakecost / 5 (min 1)XUSD locked by provider as collateral
XE RewardSame as cost formulaXE emitted to provider on settlement

The stake uses integer division: a cost of 7 yields a stake of 1 (7/5 = 1 in integer arithmetic). The minimum stake is 1 XUSD regardless of cost.

#Constants

text
const (    LeaseVCPURate     = 20       // milli-XUSD per vCPU per hour    LeaseMemGBRate    = 10       // milli-XUSD per GB memory per hour    LeaseDiskGBRate   = 1        // milli-XUSD per GB disk per hour    LeaseStakeDivisor = 5        // stake = cost / 5    LeaseMinDuration  = 60       // minimum 1 minute    LeaseMaxDuration  = 31536000 // maximum 365 days)

#Examples

vCPUsMemoryDiskDurationPer-Hr MilliHoursCost MilliCost (XUSD)Stake
11024 MB1 GB60s20+10+1=3113111
1512 MB5 GB120s20+10+5=3513511
22048 MB20 GB3600s40+20+20=8018011
48192 MB100 GB3600s80+80+100=260126011
24096 MB50 GB86400s40+40+50=13024312041
816384 MB200 GB86400s160+160+200=5202412480132
48192 MB100 GB2592000s80+80+100=26072018720018837

#Validation

The ledger enforces the following invariants:

CheckRule
Cost matches formulablock.Amount == LeaseCost(vcpus, memoryMB, diskGB, duration)
Stake matches formulalease_accept.Amount == cost / LeaseStakeDivisor (min 1)
XE reward matches formulalease_settle.Amount == LeaseCost(vcpus, memoryMB, diskGB, duration)
Duration in range60 <= duration <= 31,536,000 seconds
Resources non-zeroAt least one resource dimension must be > 0
No overflowMultiplication uses safeMul() with overflow detection via bits.Mul64
Integer arithmeticAll calculations use uint64 -- no floating point