Skip to main content

Storage and gas

Verified against: F-014 (2026-11-09), F-015 (2026-11-09), F-034 (2026-11-09), F-041 (2026-11-09), F-042 (2026-11-09) · spec docs/PRD.md §6.6, §6.9 · config.yaml limits · evidence/G1/gas-sandbox.csv (G1 PASS 2026-11-09T20:43Z, commit b721641)

Status: P0 gas measured in the near-workspaces sandbox at G1 (evidence/G1/gas-sandbox.csv, G1 PASS commit b721641). Testnet gas may differ slightly; P1/P2 budgets are not measured yet.

Storage​

NEAR charges storage staking at 10^19 yoctoNEAR per byte (F-014), which is 0.00001 NEAR per byte. A quote or position record is about 300 bytes (PRD §6.9). That is about 0.003 NEAR locked per record, paid by the contract account in this build. PROD adds a per-account storage deposit (NEP-145 style).

Bounded iteration​

BoundValueWhy
Live quotes per asset64 (max_quotes_per_asset)funding beyond this is refunded
Quotes touched per settlement8 (max_quotes_per_settlement)settlement gas stays bounded
Minimum quote$100 (min_quote_usd_e6)storage griefing
Fee accrualO(1) accumulatorno loop over quotes
List viewsfrom_index, limitpagination only

Gas​

Measured P0 values, copied from evidence/G1/gas-sandbox.csv (total gas burnt per call, 1 Tgas = 10^12 gas). ft_transfer_call:* rows include the token transfer and the ft_on_transfer branch named after the colon.

Call (sandbox)Gas burntTgas
apply_price2,271,054,866,0342.27
claim_fees6,623,355,577,7016.62
complete_quote_withdrawal6,733,776,178,7606.73
ft_transfer_call:FundPappusQuote6,757,563,058,5626.76
ft_transfer_call:LockCollateralAndBorrow11,087,671,216,71711.09
ft_transfer_call:Repay(partial)6,445,177,830,3636.45
ft_transfer_call:Repay(refund)6,507,390,100,6266.51
ft_transfer_call:SupplyLendingLiquidity6,270,630,565,4336.27
ft_transfer_call:TopUpQuote6,628,524,629,5566.63
ft_transfer_call:invalid6,370,933,934,5176.37
fund_gas_reserve1,796,782,826,1351.80
initiate_quote_withdrawal2,315,007,889,4162.32
new1,751,354,662,5951.75
pause1,840,940,796,3111.84
propose_price2,080,696,706,1422.08
set_dex_depth2,041,277,668,1712.04
set_fee_split1,814,690,526,4521.81
set_keeper1,814,311,870,1391.81
set_oracle_params1,817,307,324,2121.82
set_quote_params1,817,303,650,0971.82
set_reserve (v1 only; removed in v2, D-024)2,041,323,627,8832.04
set_session2,037,962,774,3532.04
trigger_preliquidation(2 legs)19,979,096,630,72319.98
trigger_preliquidation(8 legs)46,970,045,935,84746.97
unpause1,841,759,818,5591.84
update_owner_price2,118,858,280,2792.12
upsert_collateral2,360,519,213,6732.36

Mock token (mock-ft) calls, for reference:

Call (sandbox)Gas burntTgas
mock-ft:ft_transfer1,937,331,976,8561.94
mock-ft:mint1,728,122,260,8291.73
mock-ft:new1,525,112,786,7601.53
mock-ft:storage_deposit1,727,810,328,3991.73

The worst P0 case is trigger_preliquidation touching 8 quotes (max_quotes_per_settlement) at about 47 Tgas, well under the 300 Tgas per-transaction limit the keeper attaches (KEEPER_GAS_TGAS, default 300).

Call (later phases)BudgetStatus
OutLayer request_execution (P1)gas_tgas: 150 planned; cost from estimate_execution_cost (F-042)pending G4
v1.signer-prod.testnet.sign (P2)from sign_call_gas_attachment_requirement_tera_gas (F-034), not a constant30 Tgas attached in the G7 run (docs/EVIDENCE.md §G7)

OutLayer resource limits planned in config.yaml are max_instructions 1e8, max_memory_mb 128 and max_execution_seconds 30, all within the platform maxima in F-041.

Keeper gas​

The keeper signs with a function-call access key. Such keys cannot attach deposits, and exhausting the allowance makes the key unusable (F-015). The testnet keeper key has a 1 NEAR allowance (evidence/G2/keeper-key-20261109T2050Z.log); a leaked key can burn at most that. When the allowance runs out the key stops working; see Runbook for the replacement procedure.