@anywalletkit/protocol-lending-mellow-evm

中文文档
0.4.2发布于 2026/11/03Apache-2.0TypeScriptESM + CJS构建来源已验证近 30 天下载 2161

A simple package that lets @anywalletkit/wallet-evm wallet accounts use Mellow Core Vaults (Lido EarnETH / EarnUSD and any vault on the same contracts): supply through the sync or async deposit queue, redeem and claim through the redeem queue, read the po

原始使用文档
文档目录8 节
  1. Install
  2. What a Mellow Core Vault is
  3. Usage
  4. Configuration
  5. Fail-closed rules
  6. Build and tests
  7. License
  8. Activity

@anywalletkit/protocol-lending-mellow-evm

npm

A simple package that lets @anywalletkit/wallet-evm wallet accounts use Mellow Core Vaults — Lido's Earn vaults (EarnETH, EarnUSD, stRATEGY) and any other vault on the same contracts: supply through the vault's synchronous or asynchronous deposit queue, redeem and claim through the redeem queue, read the position, fees, oracle reports and APY.

Install

npm install @anywalletkit/protocol-lending-mellow-evm @anywalletkit/core
# or: pnpm add @anywalletkit/protocol-lending-mellow-evm @anywalletkit/core  ·  yarn add @anywalletkit/protocol-lending-mellow-evm @anywalletkit/core

On npm: @anywalletkit/protocol-lending-mellow-evm, published from the release workflow with provenance.

Built on the LendingProtocol type in @anywalletkit/core, the way the Morpho module expresses ERC-4626 vaults: supply puts an asset into the vault, withdraw takes it out. Mellow's withdrawal is two-phase (request → oracle report → claim), so the module adds getWithdrawalRequests / claimWithdrawals on top; borrow / repay reject — a vault does not lend.

The mechanics are extracted from a production wallet (React Native/Hermes) where deposit (sync and async), cancel, claim-shares, redeem and claim were exercised with real funds on EarnETH and EarnUSD through the direct port this module was lifted from. Verification status of the module itself (2026-09-07): 12 offline tests; verify:live discovers both Lido vaults on-chain and finds exactly the queue addresses that production wallet had hard-coded, and proves the supply / redeem plans with eth_call. The wallet now runs on the module; a funded cycle through it is the next step.

What a Mellow Core Vault is

A Core Vault holds LP money that a curator allocates across DeFi (Aave, Uniswap, Pendle, Morpho, …) through sub-vaults whose calls are restricted by an on-chain verifier. LPs hold vault shares (earnETH, earnUSD, …), priced by the vault's oracle once per report (Lido's vaults: at most every 20 hours). Money moves through per-asset queues the vault lists itself:

  • Deposit, synchronous queue — shares are minted in the same transaction at the latest report's price; reverts when the report is stale. The module tries it first (instant: true) after proving the call with eth_call.
  • Deposit, asynchronous queue — one open request per account, priced by the next report at least depositInterval after it (1 h on Lido's vaults). Once priced, the shares count in the balance without any action; claimShares only moves them physically. Cancellable until priced.
  • Redeem queue — redeem(shares) burns shares at once; the request is not cancellable; the next report at least redeemInterval later (1–2 days on Lido's vaults) prices it, the curator pulls liquidity, then claim pays the asset. Lido quotes "instant to ~72 h".

Fees (in shares, read from the vault's FeeManager): deposit, redeem, performance and a yearly protocol fee. Lido EarnETH today: 15 % performance, 0.2 %/yr protocol, no deposit / redeem fee.

Nothing is configured by hand for a preset: the vault reports its share manager, oracle, fee manager, assets and queues on-chain, and the module classifies each queue by the methods it answers (an async deposit queue has requestOf, a redeem queue has requestsOf; signature-based queues are skipped). Every queue call (deposits, redemptions, cancels and claims) goes only to a queue the package pins, though: the preset's shipped queues (re-checked against the chain on 2026-10-28). The RPC's queueAt picks among them and is never the authority — a user-added or tampered RPC naming its own queue is refused before any approval. A custom vault, or a preset's vault passed by address without preset, takes the expected queue addresses in queues: {deposit, redeem}, and the same option admits a queue Mellow adds before the package catches up.

Usage

import WalletManagerEvm from '@anywalletkit/wallet-evm'
import MellowProtocolEvm from '@anywalletkit/protocol-lending-mellow-evm'

const wallet = new WalletManagerEvm(seed, { provider: 'https://ethereum-rpc.publicnode.com' })
const account = await wallet.getAccount(0)

const earnUsd = new MellowProtocolEvm(account, { preset: 'lido-earn-usd' }) // or { vault: '0x…' }

// What the vault is: components, assets and queues (discovered on-chain), fees, oracle parameters
const vault = await earnUsd.getVaultData()

// Supply 100 USDT — approve (awaited) + deposit; sync queue when it can mint at once, else the async request
const USDT = '0xdAC17F958D2ee523a2206206994597C13D831ec7'
const { fee, sharesOut, instant } = await earnUsd.quoteSupply({ token: USDT, amount: 100_000_000n })
const { hash } = await earnUsd.supply({ token: USDT, amount: 100_000_000n })

// Position: shares, value at the latest report, what sits in the queues
const position = await earnUsd.getPosition({ token: USDT })

// Withdraw half — amount is in SHARES; the request burns them now, the payout comes after the next report
await earnUsd.withdraw({ token: USDT, amount: position.shares / 2n })

// Later: what is claimable, then claim (one transaction per payout asset)
const { requests, claimable } = await earnUsd.getWithdrawalRequests()
if (claimable.length) await earnUsd.claimWithdrawals({ token: USDT })

// Decoration
await earnUsd.getApr()     // percent, from Mellow's registry
await earnUsd.getStats()   // { apy, tvlUsd, withdrawAvgSeconds }

Presets: lido-earn-eth, lido-earn-usd, and — gated by a deposit whitelist at the time of writing — lido-strategy, lido-conservative-earn-usd, lido-experimental-earn-usd (see note on each entry of MELLOW_ADDRESS_MAP). Native ETH is token: 'native' (EarnETH). A read-only account ({ getAddress }) is enough for every view; writes need an account with sendTransaction({ to, data, value }).

Configuration

new MellowProtocolEvm(account, {
  vault: '0x6a37…249e',        // any Core Vault; or preset: 'lido-earn-eth' | 'lido-earn-usd'
  provider: eip1193OrUrl,      // default: the account's provider
  instant: true,               // sync deposit queue first, async fallback
  referral: '0x…',             // forwarded to the deposit queues
  registry: 'https://api.mellow.finance/v1/vaults' | null, // APY / TVL / withdrawal time — decoration only
  maxRedeemRequests: 50
})

Fail-closed rules

  • a queue is used only after the vault confirms it (hasQueue), its direction (isDepositQueue) and that it is not paused — right before the transaction, not from a cached list;
  • a suspicious oracle report (deviation above the vault's threshold) refuses supply and withdraw quotes instead of pricing blindly;
  • a vault with a deposit whitelist, minting or burning paused is refused;
  • a second async deposit request is refused while one is open (the contract would revert anyway; the module says why);
  • the sync deposit is proven with eth_call before it is sent — and proven again after an approval was mined, falling back to the async queue if the report went stale in between;
  • Ethereum's USDT gets its allowance reset to zero before a raise;
  • withdraw amounts are shares, the only unit known before the report; the quoted payout is an estimate at the latest report, after the redeem fee.

Build and tests

TypeScript, built with tsup to dist/ (ESM + CJS + types); one runtime dependency (viem) for the RPC client and ABI coding.

npm run build          # tsup → dist/
npm test               # vitest: unit tests over a stubbed EIP-1193 provider (selectors of the real contracts) + conformance
npm run verify:live    # on-chain discovery vs. the known Lido deployments, position reads, eth_call proofs — no keys

License

Apache-2.0

Activity

describeActivity(tx, { own }) labels Mellow transactions for a wallet's history, offline and synchronously. Deposits and redemptions are calls on a vault's queues (DepositQueue / RedeemQueue), which the module normally discovers on-chain, so the offline rule is: the selector is a queue method — deposit(uint224,address,bytes32[]) → supply "Deposited ", cancelDepositRequest() → withdraw "Cancelled deposit of ", DepositQueue claim(address) → claim "Claimed ", redeem(uint256) → withdraw "Requested withdrawal of ", RedeemQueue claim(address,uint32[]) → claim "Claimed " — and either the called contract is a queue a preset listed when it was last verified (MELLOW_ADDRESS_MAP[1][key].queues, read on 2026-10-14) or the receipt touches a known vault / share token (a preset's vault / shareManager, or the vault this instance targets). Writes never use the recorded queues; they are for recognizing history only. Subtitle "Mellow · Ethereum", counterparty the queue; assetsIn / assetsOut are the wallet's net movements with preset share tokens labelled (earnETH, earnUSD, …).

Fixtures in fixtures/activity/ are the test wallet's funded runs (EarnETH deposit ETH + claim shares, EarnUSD deposit USDT, redeem, claim, cancelDepositRequest; 2026-09-01 … 09-11); negatives/ holds a Lido submit and an SSV stake.

版本与发布记录

@anywalletkit/protocol-lending-mellow-evm 共发布 12 个版本,首次发布于 2026/10/25;过去 12 个月发布了 12 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.4.2latest2026/11/035 天前
0.4.12026/10/309 天前
0.4.02026/10/2910 天前
0.3.82026/10/2811 天前
0.3.72026/10/2712 天前
0.3.62026/10/2612 天前

关于 @anywalletkit/protocol-lending-mellow-evm 的常见问题

@anywalletkit/protocol-lending-mellow-evm 是什么?

A simple package that lets @anywalletkit/wallet-evm wallet accounts use Mellow Core Vaults (Lido EarnETH / EarnUSD and any vault on the same contracts): supply through the sync or async deposit queue, redeem and claim through the redeem queue, read the po

如何安装 @anywalletkit/protocol-lending-mellow-evm?

在项目目录运行 npm install @anywalletkit/protocol-lending-mellow-evm,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@anywalletkit/core(0.8.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@anywalletkit/protocol-lending-mellow-evm 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@anywalletkit/protocol-lending-mellow-evm 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@anywalletkit/protocol-lending-mellow-evm 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@anywalletkit/protocol-lending-mellow-evm 可以商用吗?

@anywalletkit/protocol-lending-mellow-evm 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@anywalletkit/protocol-lending-mellow-evm 的下载量有多少?

根据 npm 官方下载统计,@anywalletkit/protocol-lending-mellow-evm 在 2026/10/06 – 2026/11/04 这 30 天内被下载 2,161 次,日均约 72 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@anywalletkit/protocol-lending-mellow-evm 还在维护吗?

最新版本 0.4.2 发布于 2026/11/03(5 天前);至今共发布 12 个版本,其中过去 12 个月发布了 12 个;首次发布于 2026/10/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。