AGENT SKILL

0xklen-reconcile-mev-pnl-across-blocks

暂无简介

License 许可
MIT
最近更新
2026-11-15
Stars
★ 81
Forks
17

02 资源文件 3

03 SKILL.md 正文

Reconcile MEV PnL across blocks

An internal ledger of "what we extracted" drifts from the chain over any period because bundles you logged as wins never landed, refunds arrived silently, and internal transfers moved value you did not record, so the two must be tied out block by block.

Procedure

  1. Fix the range and the identity. List every address the strategy controls, including the hot wallet, the funder, and any throwaway searchers, because value moves between them and a single-address view misses the net.

  2. Take the on-chain net: sum balance changes across the range for every controlled address, per asset:

    cast balance $ADDR --block $START --rpc-url $RPC
    cast balance $ADDR --block $END --rpc-url $RPC
    
  3. Sum the ledger: gross extracted minus builder bids minus gas, matching the line items used in per-block accounting. Convert both sides to one unit at each block's price before comparing.

  4. Compute the residual: on_chain_net - ledger_net. A nonzero residual is not noise; it has a cause, and each block where it moved should be identified.

  5. Attribute residuals in this order:

    • a bundle logged as sent but never included (ledger too high)
    • a relay or auction refund (on-chain too high, often a small ETH transfer from a contract)
    • an unrecorded internal transfer between controlled addresses (net cancels, so only a single-address view shows a gap)
    • a gas rebate or a subsidised transaction
  6. Walk the blocks that carry a residual and match each to a transaction with cast run traces. Do not accept "rounding" — token amounts are integers, so the residual is a discrete event, not a precision artefact.

  7. Close the period: adjust the ledger for the identified items, re-run the sum, and confirm the residual falls below a threshold set by base fees alone (a few dollars per address). Anything larger is an unexplained event you must name.

  8. Keep the reconciliation as a saved artefact per period with the block range, addresses, both sides, and the residual. The next period's opening balance is this period's close.

Pitfalls

  • Reconciling one address. Internal transfers move value without touching the outside world, so a per-address sum shows phantom gains and losses.
  • Treating a missed bundle as a cost. It is zero on-chain; if your ledger counted the expected profit, that is the residual.
  • Forgetting refunds from orderflow auctions, which arrive as separate small transfers and look like unexplained income.
  • Mixing assets without converting at the right block, so a price move looks like an accounting error.
  • Calling a leftover amount dust. Token integers mean the residual is exact; the discrepancy is a real event.
  • Ignoring gas paid from a different funder address than the one you are reconciling, which shifts the residual to the wrong side.

Verification

echo "on-chain net vs ledger net"; cast balance $ADDR --block $END --rpc-url $RPC

After adjusting for identified items, the residual should be within base-fee noise per address. Report the block range, addresses, on-chain net, ledger net, each attributed residual, and the final residual.

04 同仓库更多 Skills

jiayaoqijia
jiayaoqijia/cryptoskill

troves

Deposit and withdraw from Troves DeFi yield vault strategies on Starknet. View available strategies, check positions, and manage vault deposits. Use this skill when the user mentions Troves, vault, yield vault, DeFi vault, strategy, yield farming, vault deposit, vault withdraw, earning yield through vaults, passive yield strategies, or wants to deposit into or withdraw from a yield strategy — even if they don't say "Troves" explicitly.

★ 81
jiayaoqijia
jiayaoqijia/cryptoskill

trade

Swap tokens on Starknet via Fibrous DEX aggregator. Supports per-provider selection (avnu, ekubo, or auto to race all). Use this skill when the user wants to swap, exchange, trade, convert, buy, or sell one token for another on Starknet. Also use when the user asks about token prices, exchange rates, DEX routing, best swap route, or wants to check how much they would receive for a given amount — even if they don't explicitly say "swap".

★ 81
jiayaoqijia
jiayaoqijia/cryptoskill

staking

Stake, unstake, claim, and compound rewards for STRK, WBTC, tBTC, SolvBTC, and LBTC on Starknet. View validators, pools, and staking positions. Use this skill when the user mentions staking, delegating, validators, staking pools, rewards, compounding, unstaking, earning yield, passive income on crypto, or wants to earn on their STRK or BTC tokens — even if they don't say "stake" explicitly.

★ 81
jiayaoqijia
jiayaoqijia/cryptoskill

send

Send STRK, ETH, or any ERC-20 token to a Starknet address. Supports simulation (dry-run) before execution. Use this skill when the user wants to send, transfer, pay, tip, or move tokens to another wallet address on Starknet. Also trigger when the user mentions sending funds to someone, making a payment, transferring assets, or moving crypto to a specific address — even if they just say "pay 10 STRK to 0x...".

★ 81
jiayaoqijia
jiayaoqijia/cryptoskill

portfolio

View a comprehensive DeFi portfolio dashboard and optimize portfolio allocation via automated rebalancing. Use this skill when the user wants an overview, summary, dashboard, total value, net worth, portfolio rebalancing, target allocation, or wants to see all their DeFi positions across Starknet at once. Also trigger when the user asks "what do I have", "show me everything", "how much am I worth", "my positions", "my investments", "rebalance my portfolio", "I want 50% ETH", "optimize my holdings", or any request for a holistic view of their Starknet holdings — even if they don't explicitly say "portfolio".

★ 81
jiayaoqijia
jiayaoqijia/cryptoskill

multi-swap

Execute multiple token swaps in a single Starknet transaction via Fibrous (default). Supports per-provider selection (avnu, ekubo, or auto to race all). Supports 2-3 swap pairs bundled into one multicall. Use this skill when the user wants to swap multiple token pairs at once, do batch swaps, execute several trades simultaneously, perform parallel swaps, or do bulk trading in one transaction. Also trigger when the user mentions "two swaps", "three swaps", "swap X and Y at the same time", or wants to convert multiple tokens in a single call.

★ 81