Borrow and Lend Actions Through CoreWriter

Advanced | 3 min | Last verified 2026-09-07

CoreWriter can submit Portfolio Margin supply and withdraw operations from HyperEVM contracts, making native lending state programmable from the EVM while preserving HyperCore's own risk engine.

Hyperliquid's current CoreWriter interface includes borrow/lend-related Portfolio Margin operations. The documented encoding supports supply and withdraw operations for specified tokens and amounts, including a zero-amount convention for applying the operation maximally. This lets a contract coordinate native lending balances with EVM application logic without recreating the Portfolio Margin engine.

What remains native

Interest rates, collateral eligibility, caps, liquidation logic, and Portfolio Margin health remain HyperCore rules. A HyperEVM contract can request an action but cannot redefine those rules by using CoreWriter.

Composable treasury use

A contract-controlled treasury could move idle eligible balances into native supply, withdraw them when another application needs liquidity, or coordinate a larger strategy across EVM and HyperCore.

The application must treat the native position as an external state dependency and reconcile it after each action.

Zero amount semantics

Current documentation notes that a zero wei value can mean “maximally apply” an operation, such as withdrawing the full available balance. This is convenient but high impact.

Contracts should avoid exposing an unbounded max operation to arbitrary callers. Authorization and explicit risk limits are essential.

Changing feature risk

Portfolio Margin is a rapidly evolving surface. Supported assets, caps, account eligibility, and action semantics should be verified against live documentation at deployment and monitored afterward.

A production contract should fail safely when a previously valid operation becomes unsupported or constrained.

Sources

  1. https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/hyperevm/interacting-with-hypercore
  2. https://hyperliquid.gitbook.io/hyperliquid-docs/trading/portfolio-margin