--- name: avax-benqi description: Integrate BENQI lending and sAVAX with native/ERC20 entry points, error codes and queued withdrawals. --- # BENQI Core and liquid staking 1. Choose Core lending or sAVAX explicitly. Resolve `examples/protocols/benqi/manifest.json` against [Core markets](https://docs.benqi.fi/resources/contracts/core-markets) or [staking contracts](https://docs.benqi.fi/resources/contracts/liquid-staking). Commands/paths resolve from the executable bundle root. Compound-style qiTokens and non-rebasing sAVAX shares are different systems, neither a generic ERC-4626 vault. 2. Run `inspect({provider,blockTag,owner,amount})` from `examples/protocols/benqi/recipe.mjs`. Verify raw chain 43114, runtime/custom proxy implementations, market→Comptroller, underlying, listing/pause, balances, cash, current exchange rates and collateral membership. For staking inspect pool cap, pauses, cooldown/window, requests, historical redemption rates and actual native cash. 3. Select supply-avax: qiAVAX payable mint() with exact value and gas reserve; or supply-usdc: approve qiUSDCn and call mint(uint256) with native-USDC base units and zero native value. Redemption uses raw qiToken units, not underlying units. USDC has 6 decimals, qiTokens 8, AVAX/sAVAX 18. 4. Apply raw-unit arithmetic: underlyingRaw = qiRaw × exchangeRate / 1e18; mintedQiRaw = underlyingRaw × 1e18 / exchangeRate, with contract rounding. A pinned exchangeRateCurrent eth_call includes accrual; exchangeRateStored may lag. BENQI accrues by timestamp, not an assumed Ethereum per-block formula. 5. Decode protocol success. ERC20 mint/redeem can return nonzero uint256 errors without reverting. Use exported assertCoreSuccess, inspect Failure events and reconcile deltas even when receipt.status=1. Native mint() has no uint256 return: require non-reversion, Mint event and qiToken delta. 6. For staking choose stake-avax (submit payable), request-unlock (sAVAX share amount) or redeem-unlock (request index). Requests transfer shares into custody, not immediate AVAX redemption. Reinspect indexes after mutations. Require strictly after start+cooldown and no later than that point+redemption window, historical request rate and enough staking-contract cash. 7. Construct `plan({chainId:43114,owner,operation,amount},evidence)`; redemption adds unlockIndex. Reinspect within 300 seconds and simulate after approvals. The output is unsigned, not broadcast. Run the commands below and distinguish public reads from artificial local state transitions. ```sh node --test examples/protocols/benqi/recipe.test.mjs node research/parity-aave-benqi/live-proof.mjs node research/parity-aave-benqi/fork-proof.mjs ``` ## Anchors and boundaries Comptroller: 0x486Af39519B4Dc9a7fCcd318217352830E8AD9b4. qiAVAX: 0x5C0401e81Bc07Ca70fAD469b451682c0d747Ef1c. qiUSDCn: 0xB715808a78F6041E46d61Cb123C9B4A27056AE9C. sAVAX: 0x2b2C81e08f1Af8835a78Bb2A90AE924ACE0eA4bE. Confirm underlying rather than confusing qiUSDCn with bridged-USDC markets. The planner rejects collateral-enabled qiToken redemption without exact per-amount risk simulation. Borrowing and collateral changes are outside scope. Staking previews do not encode a minimum-output guarantee. Fork proof covers AVAX/USDC mint+redeem, sAVAX stake+unlock request and early-redemption rejection. Successful mature redemption is not demonstrated; planner timing/rate/cash checks do not turn it into an executed path. An expired window requires the implementation's overdue-share flow, not blind ordinary-redeem retries. **Deliver:** system/market identity; unit conversions; account/cash constraints; unsigned plan; decoded outcomes/deltas; queued state and unproved cases. Sources: official registries above; [pinned BENQI source](https://github.com/Benqi-fi/BENQI-Smart-Contracts/tree/e0cfd244726719dfe027c9740878d64d1cad98f2), exact QiToken/QiAvax/Comptroller/StakedAvax links in the manifest.