Skip to content

CLI: Lend commands#423

Draft
its-everdred wants to merge 21 commits intomainfrom
feat/cli-lend
Draft

CLI: Lend commands#423
its-everdred wants to merge 21 commits intomainfrom
feat/cli-lend

Conversation

@its-everdred
Copy link
Copy Markdown
Collaborator

@its-everdred its-everdred commented Apr 24, 2026

Fixes #409. Adds the lend namespace on top of the CLI scaffolding: read-only actions lend markets / actions lend market and wallet-scoped wallet lend open / close / position.

SDK → CLI

actions.lend.getMarkets({asset?, chainId?})   -> actions lend markets [--asset <s>] [--chain <n>]
actions.lend.getMarket({address, chainId})    -> actions lend market --market <name>
wallet.lend.getPosition({marketId})           -> actions wallet lend position --market <name>
wallet.lend.openPosition({..., approvalMode}) -> actions wallet lend open --market <n> --amount <n> [--approval-mode <exact|max>]
wallet.lend.closePosition({...})              -> actions wallet lend close --market <n> (--amount <n> | --max)

Output

{
  "action": "open",
  "market": { "name": "Gauntlet USDC", "address": "0x...", "chainId": 84532, "provider": "morpho" },
  "asset":  { "symbol": "USDC_DEMO" },
  "amount": 10,
  "transactions": [ { "transactionHash": "0x...", "status": "success", ... } ]
}

transactions is always an array (1-2 receipts on EOA: optional approval + position call). Read commands return the SDK shape verbatim with bigints stringified.

Notable

  • Typed ActionsError mapping in output/errors.tsChainNotSupportedError, InvalidParamsError, ProviderNotConfiguredError etc. become structured validation / config envelopes; viem ContractFunctionRevertedError becomes onchain.
  • Default-deny receipts — anything that isn't status === 'success' (EOA) or success === true (UserOp) becomes code: "onchain" exit 5; a misbehaving RPC can't silently report success.
  • Strict --amount — rejects scientific notation, hex, signs, whitespace, bigint suffixes, and integer parts above MAX_SAFE_INTEGER.
  • Market collision detection — two providers normalising to the same name throw validation instead of silently picking the first.
  • Generic helpers (parseAmount, WalletTransactionReceipt, toReceiptArray, ensureOnchainSuccess) live in cli/src/utils/. open and close share a runLendAction backbone.

159 tests pass.

Out of scope (follow-ups)

  • lendProvider on the read-side LendMarket payload — needs an SDK field.
  • Post-trade LendMarketPosition in the open/close envelope — extra RPC per write.
  • Typed getLendProviders(config) SDK accessor so the CLI doesn't string-skip the settings sibling.

@its-everdred its-everdred mentioned this pull request Apr 24, 2026
12 tasks
@its-everdred its-everdred changed the title cli: lend namespace (#409) CLI: Lend commands May 4, 2026
Base automatically changed from feat/cli-scaffolding to main May 5, 2026 01:43
@netlify
Copy link
Copy Markdown

netlify Bot commented May 5, 2026

Deploy Preview for actions-ui ready!

Name Link
🔨 Latest commit 5af37cc
🔍 Latest deploy log https://app.netlify.com/projects/actions-ui/deploys/69f9fa1e60c6210008b097e3
😎 Deploy Preview https://deploy-preview-423--actions-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

afterEach(() => setJsonMode(false))

const ANVIL_ACCOUNT_0 =
'0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DRY, import this from 1 place

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI: lend namespace

1 participant