Steth treasury

From jiayaoqijia/cryptoskill · View interactive version

Steth treasury is an AI agent skill from the GitHub repository jiayaoqijia/cryptoskill. Build and interact with stETH Agent Treasury contracts. Yield-bearing operating budgets backed by wstETH where agents spend only yield, never touching principal. Use when asked about agent treasury, yield-funded budgets, stETH yield spending, or principal-protected vaults.

How to use this skill

Skill file

stETH Agent Treasury

A contract primitive where humans give AI agents yield-bearing operating budgets backed by wstETH. Only yield flows to the agent — principal is structurally inaccessible.

Core Concept

  1. Human deposits wstETH into treasury contract
  2. Contract records deposit exchange rate (stEthPerToken() at deposit time)
  3. wstETH value grows as staking rewards accrue (exchange rate increases)
  4. Agent can only withdraw the yield (difference between current and deposit value)
  5. Principal (original wstETH amount) is permanently locked from agent access

How wstETH Yield Works

wstETH is non-rebasing — its balance stays constant, but its value in stETH increases:

depositValue = wstETHAmount * depositExchangeRate
currentValue = wstETHAmount * currentExchangeRate
accruedYield = currentValue - depositValue

Get current exchange rate:

exec command="curl -s -X POST https://eth.llamarpc.com -H 'Content-Type: application/json' -d '{\"jsonrpc\":\"2.0\",\"method\":\"eth_call\",\"params\":[{\"to\":\"0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0\",\"data\":\"0x035faf82\"},\"latest\"],\"id\":1}'"

0x035faf82 = stEthPerToken(). Divide by 1e18. At ~3.2% APR, 100 wstETH earns ~3.2 stETH/year.

Contract Architecture

Key State Variables

mapping(address => uint256) public depositRate;       // exchange rate at deposit
mapping(address => uint256) public depositAmount;      // wstETH deposited
mapping(address => address) public agentAddress;       // authorized agent
mapping(address => address[]) public allowedRecipients; // spending whitelist
mapping(address => uint256) public perTxCap;           // max per transaction
mapping(address => uint256) public timeWindow;         // spending window

Core Functions

function deposit(uint256 wstETHAmount, address agent) external
function queryYield(address depositor) view returns (uint256)
function spendYield(address recipient, uint256 amount) external  // agent only
function withdrawPrincipal() external                             // depositor only
function setRecipientWhitelist(address[] recipients) external     // depositor only
function setPerTxCap(uint256 cap) external                        // depositor only

Security Invariants

Agent Interaction Pattern

1. Query available yield:

exec command="curl -s -X POST https://eth.llamarpc.com -H 'Content-Type: application/json' -d '{\"jsonrpc\":\"2.0\",\"method\":\"eth_call\",\"params\":[{\"to\":\"TREASURY_ADDRESS\",\"data\":\"0xQUERY_YIELD_SELECTOR+DEPOSITOR_ADDRESS\"},\"latest\"],\"id\":1}'"

2. Spend yield (agent pays for API call from yield balance):

3. Check permissions:

Use Cases

Supported Chains

Deploy on any chain with wstETH:

Integration with Ottie

Ottie can interact with treasury contracts via:

  1. crypto-wallet skill — query wstETH balances and approvals
  2. lido-mcp skill — exchange rate queries, wrap/unwrap operations
  3. lido-vault-monitor skill — track yield accrual and alert on changes
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.