Custos docs

Reference

Testnet proof

Everything on this page can be checked on HashScan. The addresses are also in packages/foundry/deployments/296.json; the full record is packages/foundry/TESTNET.md.

Deployment#

The final deployment, 2026-10-02.

ContractHedera IDEVM address
PerpMarket (keeper)0.0.10833087(opens in a new tab)0xb79Cc40A4b1d3C135f71Ed6dc4e9a231cC369b67
LiquidityPool0.0.10833082(opens in a new tab)0x06061a60D2f9E99410F1D2B310DCF51A1ff2A3b1
PriceGuard0.0.10833074(opens in a new tab)0x293e90142cc9dDF603d9Ab405B43236e8077EF75
cUSDC-LP share token (HTS, created by the pool)0.0.10833090(opens in a new tab)0x0000000000000000000000000000000000a54cc2
HbarDepositZap (LPs deposit with HBAR via SaucerSwap)0xdD40EBFf…Ef185C(opens in a new tab)0xdD40EBFf88aaDc52B31D9E698803e47B04Ef185C
USDC (SaucerSwap testnet's)0.0.5449(opens in a new tab)0x0000000000000000000000000000000000001549
HCS audit log topic0.0.10839050(opens in a new tab)—

Keeper: interval 1,800 s, gas limit 3,000,000, gas price 82 tinybar/gas (2.46 ℏ held per run), 36 ℏ reserve. PriceGuard: Chainlink HBAR/USD checked against Supra HBAR/USDT (pair 75), max staleness 43,200 s (raised from 7,200 s on 3 Oct with setParams, 0x51cf5b7f…6745fc(opens in a new tab): Chainlink's testnet HBAR/USD goes hours between pushes), max deviation 500 bps. Min collateral 1 USDC. Refuel band 300 bps. Collateral: SaucerSwap testnet USDC 0.0.5449.

Every flow, on chain#

FlowTransaction
Pool creates its HTS share token (cUSDC-LP)0xf405eade…340a5a(opens in a new tab)
Keeper books its first tick (revive)0xa1b7d249…fa1b71(opens in a new tab), schedule 0.0.10833097(opens in a new tab)
Deposit 361.79 USDC, pool mints cUSDC-LP0x55d081b2…54d722(opens in a new tab)
Open with HBAR: 50x long, 1 ℏ swapped to USDC on SaucerSwap0x62868b09…3986e7(opens in a new tab)
Open with USDC: 50x short, 1.2 USDC0xfac6b7ec…b7bdba(opens in a new tab)
Open with USDC: 2x long, 1 USDC0xd3f325cf…443de8(opens in a new tab)
Close, paid out in USDC0xbaa65216…c61df6(opens in a new tab)
Close straight to HBAR: the USDC payout swapped on SaucerSwap (closeToHbar)0x1e427e54…d91c36(opens in a new tab)
Deposit with HBAR: 0.5 ℏ swapped to 1.12 USDC on SaucerSwap and deposited for the caller (HbarDepositZap.depositWithHbar), 1,114,696 cUSDC-LP minted to them0x3c23d3b3…6ca098(opens in a new tab)
Redeem 10 cUSDC-LP, pool burns the shares0x90487242…2d7422(opens in a new tab)

The network keeps the market#

Each tick is executed by the Schedule Service from a schedule the previous tick booked; msg.sender is the market itself, and no one signs it.

TickExecutedWhat it did
10x5bebf1d8…0038f6(opens in a new tab) (schedule 0.0.10833097(opens in a new tab), 1790983197.030564046)Accrued funding, swept the 2 open positions (none underwater), recorded the gas price it ran at (84 tinybar/gas), booked tick 2. Paid by the market itself: 1.359 ℏ for 1,618,265 gas
20x756e4e8e…8c518a(opens in a new tab) (1790984996.012)Funding, sweep (none underwater), booked tick 3. 1.327 ℏ for 1,580,037 gas
30xcaaa44b5…38aef3(opens in a new tab) (1790986794.024)Funding, sweep (none underwater), booked tick 4. 1.315 ℏ for 1,584,087 gas
40x7c37d2a7…de59a9(opens in a new tab) (1790988593.014)Liquidated the 50x short 0xebBA…F393 at $0.10277 (its liquidation price was $0.10266): Liquidated(byNetwork = true, by = 0x0, reward = 0), all collateral to the pool. Nobody signed it. 1.980 ℏ for 2,385,537 gas
180x963bf611…ec8303(opens in a new tab) (1791013775.07)Liquidated the other demo position, the 50x long 0xA807…6Ec6, at $0.10062 (its liquidation price was $0.10083): byNetwork = true, reward = 0

Ticks 12–16 skipped the sweep

Ticks 12–16 ran while Chainlink's testnet feed was hours old and skipped the sweep (SweepSkipped(Stale)): the keeper refuses to liquidate at a stale price, exactly as designed. See Learned on Hedera, item 9.

The same history on HCS

Every keeper event is mirrored to HCS topic 0.0.10839050(opens in a new tab) by scripts-js/hcsLog.js. Its first 38 messages cover ticks 1–18: message #7 is the tick-4 liquidation and #36 the tick-18 one.

Source verification#

Source verified on Sourcify: LiquidityPool exact match; PerpMarket and PriceGuard match (identical bytecode, source reformatted after the deploy).

Earlier deploy: the first liquidation nobody signed#

The first version (PerpMarket 0.0.10776702(opens in a new tab), since retired) proved the whole loop on 2026-09-29. Every tick below was executed by the Schedule Service from a schedule the previous tick booked.

TickScheduleExecutedWhat it did
10.0.10776713(opens in a new tab)1790687748.000592261(opens in a new tab)Funding accrued, swept 2 traders, none underwater
20.0.10777055(opens in a new tab)1790689547.018645425(opens in a new tab)Swept 2 traders, none underwater yet
30.0.10777398(opens in a new tab)1790691346.057913123(opens in a new tab)Liquidated the 50x long 0xA807…6Ec6 at 0.11304294 (liquidation price 0.11353): Liquidated(byNetwork = true, reward = 0), all 0.1425 USDC collateral to the pool. Charged 1.755 ℏ for 1.61M gas used of 2.5M

Tick 3 ran one second before its nextRunAt (Hedera's block timestamp lag), which the 5 s tolerance absorbs. That deploy's chain later stopped with INSUFFICIENT_PAYER_BALANCE: Hedera holds a run's whole gas limit up front, and its 6M-gas runs needed more than the reserve held. The final deploy accounts for this (Learned on Hedera, item 2).

Probes#

Throwaway contracts that answered a question.

QuestionContractAnswer
Who is msg.sender when the Schedule Service runs a booked call?0xd603925b…a6143b(opens in a new tab)The contract itself (msg.sender and tx.origin)
What is tx.gasprice inside a scheduled run?0x2B8ac8aC…9b6d8e(opens in a new tab)82 (tinybars per gas)
Does Hedera hold the whole gas limit before a scheduled run?sameYes: a 5M-gas run with 3.6 ℏ in the contract failed INSUFFICIENT_PAYER_BALANCE (needs 4.1 ℏ), schedule 0.0.10832561(opens in a new tab); the failed attempt cost 0.018 ℏ