Skip to main content

On-Chain Implementation & Monitoring

1. Smart Contract Functions

The following functions must be implemented or extended in the Kaia smart contracts to support the inventory skew system:

FunctionParametersDescription
getInventoryRatio()corridor, stablecoinReturns real-time IR for the specified side of a corridor
calculateSkewOffset()corridor, oracleMidReturns skew offset in bps, incorporating dead zone, k, state cap, VaR amplifier
getAdjustedMid()corridorReturns Oracle MID ± skew offset; this is what the spread is applied to
updateSkewConfig()corridor, k, maxSkew, deadZoneAdmin-only; updates corridor parameters. Emits SkewConfigUpdated event.

2. On-Chain Events

The following events must be emitted for audit trail and analytics:

EventData CapturedPurpose
SkewAppliedcorridor, IR, skewBps, adjustedMid, oracleMid, stateAtExecution, varUtilisationFull audit trail per quote; enables post-trade skew effectiveness analysis
SkewConfigUpdatedcorridor, old_k, new_k, old_maxSkew, new_maxSkew, old_deadZone, new_deadZone, updatedByTracks all parameter changes; governance and compliance
SkewEmergencyAmplifiedcorridor, varUtilisation, amplifier, effectiveKSignals VaR-triggered amplification; alerts Ops dashboard

3. Gas Optimisation Notes (Kaia-Specific)

The inventory skew calculation is computationally lightweight (one division, one multiplication, one clamp). On Kaia, this adds approximately 3,000–5,000 gas to each quote request. However, the real-time Active Pool balance read requires a storage SLOAD, which on Kaia costs approximately 2,100 gas per slot.

To minimise gas overhead, the recommended implementation caches the inventory ratio and skew offset in a transient storage slot that is updated atomically during each swap execution. This avoids redundant SLOADs when multiple quotes are requested in rapid succession within the same block.

4. Monitoring, Analytics & Ops Dashboard

4.1 Key Metrics

The following metrics must be tracked in the Ops dashboard to monitor skew system effectiveness:

MetricCalculationTarget / Alert Threshold
Skew Effectiveness RatioVolume attracted in skew direction / Total volume for corridorTarget > 55%; Alert if < 45% for 24h
Avg Skew MagnitudeRolling 1h average of |InventorySkew_bps|Alert if > 75% of MaxSkew for 4h
Time at Max SkewCumulative minutes per day at |Skew| = MaxSkewAlert if > 60 min/day
Skew-Avoided RebalancingEstimated external rebalancing volume avoided due to skew-attracted offsetting flowReport weekly; target > $50K/week for USD-IDR
IR DistributionHistogram of IR values per corridor per dayHealthy: 80% of time within dead zone or mild range

4.2 Alerting Tiers

Alert LevelConditionActionChannel
INFOSkew > 50% of MaxSkew for > 1hLog only; Ops review next business dayDashboard log
WARNINGSkew at MaxSkew for > 30 minTrigger Phase 1 internal rebalancing evaluationSlack + Dashboard
CRITICALSkew at MaxSkew + VaR > 80%Immediate Ops escalation; Emergency RFQ per Reserve Pool VaRPagerDuty + Slack

5. Parameter Governance & Review Cadence

5.1 Review Schedule

ParameterReview CadenceReview Criteria
k (sensitivity)MonthlyIs skew attracting sufficient offsetting flow? Compare Skew Effectiveness Ratio against target.
MaxSkew_bpsMonthlyIs the cap being hit too frequently? If Time at Max Skew is excessive, consider increasing cap or triggering rebalancing sooner.
Dead ZoneQuarterlyIs the dead zone correctly sized for the corridor's typical flow pattern? Review IR Distribution histogram.
State Cap ModifiersQuarterlyAre elevated state skew caps providing sufficient correction without excessive LP exposure?
VaR AmplifiersQuarterlyIs the amplification curve correctly reducing Emergency RFQ frequency?

5.2 Change Authority

All parameter changes require:

  1. Written justification referencing the specific metric or incident that triggered the review.
  2. Approval from at least one member of the Risk Committee and one member of the Engineering team.
  3. Execution via the updateSkewConfig() admin function, which emits the SkewConfigUpdated on-chain event.
  4. Post-change monitoring for 24 hours with automated rollback capability if Skew Effectiveness Ratio drops below 40%.