@lombard.finance/sdk-agent 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-2026 Lombard Finance
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,183 @@
1
+ # @lombard.finance/sdk-agent
2
+
3
+ AI agent tools for the [Lombard protocol](https://lombard.finance). Give any LLM the ability to stake Bitcoin, check balances, deploy to DeFi vaults, and interact with Morpho Blue lending markets.
4
+
5
+ Framework-agnostic core with ready-made adapters for [Vercel AI SDK](https://sdk.vercel.ai/) and [LangChain](https://js.langchain.com/).
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @lombard.finance/sdk-agent
11
+ # or
12
+ yarn add @lombard.finance/sdk-agent
13
+ ```
14
+
15
+ ### Peer Dependencies
16
+
17
+ `viem` is required. Framework adapters are optional, install whichever you use:
18
+
19
+ ```bash
20
+ # Required
21
+ npm install viem
22
+
23
+ # For Vercel AI SDK
24
+ npm install ai
25
+
26
+ # For LangChain
27
+ npm install @langchain/core
28
+ ```
29
+
30
+ ## Quick Start
31
+
32
+ ### Vercel AI SDK
33
+
34
+ ```typescript
35
+ import { lombardTools } from "@lombard.finance/sdk-agent/vercel";
36
+ import { LOMBARD_SYSTEM_PROMPT } from "@lombard.finance/sdk-agent";
37
+ import { streamText } from "ai";
38
+
39
+ const result = streamText({
40
+ model: yourModel,
41
+ system: LOMBARD_SYSTEM_PROMPT,
42
+ tools: lombardTools,
43
+ messages,
44
+ });
45
+ ```
46
+
47
+ ### LangChain
48
+
49
+ ```typescript
50
+ import { lombardLangChainTools } from "@lombard.finance/sdk-agent/langchain";
51
+ import { LOMBARD_SYSTEM_PROMPT } from "@lombard.finance/sdk-agent";
52
+
53
+ const agent = createReactAgent({
54
+ llm: yourModel,
55
+ tools: lombardLangChainTools,
56
+ messageModifier: LOMBARD_SYSTEM_PROMPT,
57
+ });
58
+ ```
59
+
60
+ ### Framework-Agnostic
61
+
62
+ ```typescript
63
+ import { allTools, toolsByName } from "@lombard.finance/sdk-agent";
64
+
65
+ // allTools: array of all tool definitions
66
+ // toolsByName: record keyed by tool name
67
+
68
+ // Each tool has:
69
+ // - name, description (for LLM context)
70
+ // - schema (Zod) and parameters (JSON Schema)
71
+ // - execute(params) -> Promise<result>
72
+ ```
73
+
74
+ ## Available Tools
75
+
76
+ ### Balances and Rates
77
+
78
+ | Tool | Description |
79
+ | ---- | ----------- |
80
+ | `get_lbtc_balance` | Check LBTC balance for a wallet on any supported chain |
81
+ | `get_btcb_balance` | Check BTC.b (cross-chain Bitcoin) balance |
82
+ | `get_balance` | Get both LBTC and BTC.b balances in a single call |
83
+ | `get_token_balance` | Check any ERC-20 token balance by contract address |
84
+ | `get_exchange_rate` | Current LBTC/BTC exchange rate and minimum stake amount |
85
+ | `get_lbtc_apy` | Current LBTC base staking APY |
86
+
87
+ ### BTC Staking (Native Bitcoin)
88
+
89
+ | Tool | Description |
90
+ | ---- | ----------- |
91
+ | `get_deposit_btc_address` | Get a BTC deposit address for staking, or instructions to generate one |
92
+ | `check_fee_authorization` | Check fee authorization status before address generation |
93
+ | `prepare_btc_deposit` | Generate a new BTC deposit address (triggers wallet signing) |
94
+ | `get_deposit_status` | Track deposit confirmations and claimability |
95
+ | `prepare_claim_deposit` | Claim a notarized deposit to mint LBTC |
96
+
97
+ ### Stake and Unstake (EVM)
98
+
99
+ | Tool | Description |
100
+ | ---- | ----------- |
101
+ | `prepare_stake` | Prepare a BTC.b to LBTC stake transaction |
102
+ | `prepare_unstake` | Prepare an LBTC unstake transaction (to BTC or BTC.b) |
103
+ | `get_unstake_status` | Track unstake and redemption status |
104
+
105
+ ### Bitcoin Earn (Vaults)
106
+
107
+ | Tool | Description |
108
+ | ---- | ----------- |
109
+ | `get_strategies` | List available yield strategies with APY and TVL |
110
+ | `get_opportunities` | Browse LBTC DeFi opportunities across protocols |
111
+ | `get_vault_positions` | Check Bitcoin Earn positions (shares and LBTC value) |
112
+ | `prepare_deploy_to_vault` | Deploy LBTC into Bitcoin Earn for additional yield |
113
+ | `prepare_vault_withdrawal` | Withdraw from Bitcoin Earn |
114
+
115
+ ### Morpho Blue (Lending and Borrowing)
116
+
117
+ | Tool | Description |
118
+ | ---- | ----------- |
119
+ | `get_morpho_lbtc_markets` | List Morpho Blue markets where LBTC is collateral |
120
+ | `prepare_morpho_supply_collateral` | Supply LBTC as collateral on Morpho Blue |
121
+ | `prepare_morpho_borrow` | Borrow against LBTC collateral |
122
+ | `prepare_morpho_repay` | Repay borrowed assets |
123
+ | `get_morpho_position` | Check collateral, borrows, LTV, and health status |
124
+
125
+ ## System Prompt
126
+
127
+ The package includes `LOMBARD_SYSTEM_PROMPT`, a curated prompt that teaches any LLM how to guide users through:
128
+
129
+ - Native BTC staking (deposit, confirm, claim LBTC)
130
+ - BTC.b to LBTC staking on EVM chains
131
+ - Yield strategies and Bitcoin Earn deployment
132
+ - Morpho Blue collateral supply and borrowing
133
+ - Error handling and common edge cases
134
+
135
+ Use it as-is or extend it with your own context:
136
+
137
+ ```typescript
138
+ import { LOMBARD_SYSTEM_PROMPT } from "@lombard.finance/sdk-agent";
139
+
140
+ const customPrompt = `${LOMBARD_SYSTEM_PROMPT}\n\nAdditional context: ...`;
141
+ ```
142
+
143
+ ## Supported Chains
144
+
145
+ | Chain | Chain ID | Environment |
146
+ | ----- | -------- | ----------- |
147
+ | Ethereum | 1 | Production |
148
+ | Base | 8453 | Production |
149
+ | Sepolia | 11155111 | Testnet |
150
+ | Base Sepolia | 84532 | Testnet |
151
+
152
+ ## Architecture
153
+
154
+ Tools follow a **read vs. write** pattern:
155
+
156
+ - **Read tools** execute immediately and return current state (balances, rates, statuses, market data)
157
+ - **Write tools** return transaction parameters for the user's wallet to sign (no private keys needed)
158
+
159
+ Every tool definition includes both a **Zod schema** (for TypeScript and frameworks that accept Zod) and a **JSON Schema** (for everything else):
160
+
161
+ ```typescript
162
+ import {
163
+ StakeZod, // Zod schema
164
+ StakeSchema, // JSON Schema equivalent
165
+ } from "@lombard.finance/sdk-agent";
166
+ ```
167
+
168
+ ## Configuration
169
+
170
+ | Variable | Default | Description |
171
+ | -------- | ------- | ----------- |
172
+ | `LOMBARD_PARTNER_ID` | none | Partner ID for BTC deposit address generation |
173
+ | `LOMBARD_BFF_URL` | `https://bff.prod.lombard-fi.com` | Backend API URL |
174
+
175
+ ## Requirements
176
+
177
+ - **Node.js**: 18+
178
+ - **TypeScript**: 5.0+
179
+ - **viem**: 2.21+
180
+
181
+ ## License
182
+
183
+ MIT
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Canonical glossary of Lombard-related on-chain assets.
3
+ *
4
+ * The SDK keeps the source of truth for token addresses (getLbtcContractAddresses,
5
+ * BTCE_VAULT_CONTRACTS, getTokenContractInfo). This module is the agent's
6
+ * structured awareness of *what each asset is conceptually* — which one is
7
+ * yield-bearing, which one is just bridged BTC, which one is the vault share —
8
+ * so the LLM never has to guess and never tells the user "I'm not familiar
9
+ * with that token."
10
+ *
11
+ * Anything new added to the SDK that the agent should advertise should be
12
+ * added here. The `get_token_info` tool reads from this module, and the
13
+ * glossary string is appended to the system prompt at module load.
14
+ */
15
+ import { type ChainId } from "@lombard.finance/sdk";
16
+ export interface LombardAsset {
17
+ /** Canonical short symbol (LBTC, BTC.b, BTCe, ...). */
18
+ symbol: string;
19
+ /** Other names the LLM might encounter in conversation. */
20
+ aliases: string[];
21
+ /** Full human-readable name. */
22
+ name: string;
23
+ /** One-sentence summary the LLM can quote when asked "what is X?". */
24
+ description: string;
25
+ /** Whether Lombard issues this asset (vs. a third-party token we surface). */
26
+ isLombardIssued: boolean;
27
+ /** Whether holding the asset accrues yield over time. */
28
+ isYieldBearing: boolean;
29
+ decimals: number;
30
+ /**
31
+ * Known per-chain addresses, keyed by EVM chain ID. May be partial: assets
32
+ * deployed on chains not enumerated here are still discoverable through
33
+ * get_token_info's address argument or the SDK's getTokenContractInfo.
34
+ */
35
+ addresses: Partial<Record<number, string>>;
36
+ /** Optional extra notes for the LLM. */
37
+ notes?: string;
38
+ }
39
+ /**
40
+ * Lombard's user-facing asset roster. Order is intentional: assets users
41
+ * interact with most directly come first.
42
+ */
43
+ export declare const LOMBARD_ASSETS: LombardAsset[];
44
+ /**
45
+ * Resolves a free-text query to a single LombardAsset, matching against
46
+ * canonical symbol first, then aliases (case-insensitive). Returns undefined
47
+ * if no match.
48
+ */
49
+ export declare function resolveAssetByName(query: string): LombardAsset | undefined;
50
+ /**
51
+ * Resolves a contract address (case-insensitive) to a LombardAsset, scoped
52
+ * to the given chainId. Only returns a hit when the address is in the
53
+ * asset's pre-computed map; callers wanting to resolve arbitrary addresses
54
+ * should fall back to getTokenContractInfo.
55
+ */
56
+ export declare function resolveAssetByAddress(chainId: ChainId | number, address: string): LombardAsset | undefined;
57
+ /** Builds the markdown glossary that's appended to the system prompt. */
58
+ export declare function buildAssetGlossary(): string;
59
+ /** Pre-built glossary string (computed once at module load). */
60
+ export declare const LOMBARD_ASSETS_GLOSSARY: string;
61
+ //# sourceMappingURL=assets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../src/assets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAEL,KAAK,OAAO,EAGb,MAAM,sBAAsB,CAAC;AAE9B,MAAM,WAAW,YAAY;IAC3B,uDAAuD;IACvD,MAAM,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,sEAAsE;IACtE,WAAW,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,eAAe,EAAE,OAAO,CAAC;IACzB,yDAAyD;IACzD,cAAc,EAAE,OAAO,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC3C,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAYD;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,YAAY,EAsCxC,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAQ1E;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,OAAO,GAAG,MAAM,EACzB,OAAO,EAAE,MAAM,GACd,YAAY,GAAG,SAAS,CAQ1B;AAED,yEAAyE;AACzE,wBAAgB,kBAAkB,IAAI,MAAM,CAe3C;AAED,gEAAgE;AAChE,eAAO,MAAM,uBAAuB,QAAuB,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { ChainId, Env } from "@lombard.finance/sdk";
2
+ import type { Chain } from "viem";
3
+ export interface ChainConfig {
4
+ chain: Chain;
5
+ chainId: ChainId;
6
+ env: Env;
7
+ name: string;
8
+ }
9
+ export declare const SUPPORTED_CHAINS: Record<number, ChainConfig>;
10
+ export declare function getChainConfig(chainId: number): ChainConfig;
11
+ //# sourceMappingURL=chains.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../src/chains.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAGlC,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,GAAG,CAAC;IACT,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAKxD,CAAC;AAEF,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CAO3D"}
package/dist/index.cjs ADDED
@@ -0,0 +1,78 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./tools.cjs"),t=`You are an assistant for the Lombard protocol. Lombard issues LBTC, a yield-bearing receipt token for BTC staked via Babylon. LBTC accrues yield, so 1 LBTC is always worth more than 1 BTC; never assume 1:1 — always fetch the live rate with get_exchange_rate.
2
+
3
+ Networks: Ethereum and Base are production. Sepolia and Base Sepolia are development/test environments. Bitcoin Earn (vault yield) and strategy data are mainnet-only.
4
+
5
+ # Core rules
6
+
7
+ Validate first, act second. Never call a prepare_* tool with missing, placeholder, or inferred values. If a required field is absent (e.g. a Bitcoin recipient address for an LBTC → BTC unstake) or you are not sure of a constraint (minimum amount, address format), ask the user. Do not pull values from prior context unless the user just referenced them. If a prepare_* tool returns "valid: false", list the missing or invalid fields verbatim, ask the user to provide them, and stop — do not retry until the user supplies them.
8
+
9
+ Use the wallet's connected chain as default. Each turn this prompt is extended with the user's wallet context (address, chainId, chainName). When the user asks for a balance / deposit / operation without naming a chain, use the connected chain and say so ("Showing your balance on {chainName}. Want me to check the other supported networks too?"). Do not silently default to Ethereum mainnet.
10
+
11
+ Emit full data. Never truncate or abbreviate addresses, transaction hashes, amounts, or market IDs. Always emit the canonical full-length value. The chat UI handles display formatting.
12
+
13
+ Stay in-app. Complete all operations here. Never tell the user to open Etherscan, the Lombard web app, Morpho's website, or any other external interface — unless it is the only path to recover from a documented failure mode.
14
+
15
+ Concise replies. Lead with the answer. Skip filler ("Let me check…", "I'll look into…"). After a step completes, briefly propose the next logical action and offer to do it.
16
+
17
+ # Canonical URLs (never improvise)
18
+
19
+ Use these URLs verbatim when recovery requires linking the user off-app. Do NOT shorten, abbreviate, or guess URLs from memory — only these strings are valid:
20
+
21
+ - Lombard web app: https://www.lombard.finance/app/
22
+ - Lombard docs: https://docs.lombard.finance
23
+ - Etherscan (Ethereum mainnet): https://etherscan.io
24
+ - Etherscan (Sepolia): https://sepolia.etherscan.io
25
+ - Basescan (Base mainnet): https://basescan.org
26
+ - Basescan (Base Sepolia): https://sepolia.basescan.org
27
+
28
+ If a recovery path requires a URL not listed above, say so and stop — do not invent one. Specifically, "app.lombard.finance" is NOT a valid host; the correct host is "www.lombard.finance" with the "/app/" path.
29
+
30
+ # Workflows
31
+
32
+ Native BTC deposits (two distinct flows — pick based on what the user wants to receive):
33
+
34
+ (A) BTC → LBTC (yield-bearing): the user receives LBTC, which accrues Babylon staking yield over time.
35
+ 1. Call get_deposit_btc_address. If an address is returned, display it. Stop — do not call prepare_btc_deposit.
36
+ 2. If no address exists, call check_fee_authorization. If hasValidSignature is true, tell the user the wallet will only need to confirm the address (no fresh fee signature).
37
+ 3. Call prepare_btc_deposit. The wallet prompts only when fee auth is missing or expired.
38
+ 4. After the address is returned, tell the user to send BTC, track with get_deposit_status, and use prepare_claim_deposit once claimable.
39
+
40
+ (B) BTC → BTC.b (cross-chain wrapped BTC, NOT yield-bearing): the user receives BTC.b on the destination EVM chain.
41
+ 1. Call prepare_btc_to_btcb_deposit with the user's address and chainId. The wallet prompts for the required authorization, then a unique BTC deposit address is generated.
42
+ 2. Tell the user to send BTC and track via get_deposit_status.
43
+
44
+ When the user says "I want to deposit BTC", ask which output they want (LBTC or BTC.b) and explain the difference: LBTC accrues yield; BTC.b is cross-chain wrapped BTC, not yield-bearing. Never tell the user BTC → BTC.b is unsupported — it is supported via prepare_btc_to_btcb_deposit.
45
+
46
+ EVM stake / unstake / redeem:
47
+ - prepare_stake: BTC.b → LBTC on the connected chain.
48
+ - prepare_unstake: LBTC → BTC or BTC.b. When outputAsset is "BTC", you MUST collect a Bitcoin destination address from the user before calling the tool. Valid formats: bc1.../1.../3... on mainnet; tb1.../m.../n.../2... on Sepolia or Base Sepolia. Numeric strings, EVM addresses, or addresses inferred from earlier turns are invalid — re-prompt the user.
49
+ - prepare_redeem_btcb: BTC.b → native BTC. Use this when the user holds BTC.b and wants real Bitcoin back (not LBTC). Same Bitcoin recipient address validation rules as prepare_unstake to BTC. Do NOT use prepare_unstake for BTC.b; prepare_unstake operates on LBTC only.
50
+
51
+ Bitcoin Earn withdrawals (only one active withdrawal per user per vault):
52
+ - prepare_vault_withdrawal performs a pre-flight check via getEarnWithdrawals. If an active withdrawal already exists, it returns valid:false with the existing withdrawal's details (shareAmount, txHash, deadline). Tell the user about that withdrawal and offer prepare_cancel_withdrawal — do NOT call prepare_vault_withdrawal again until the existing one is cancelled.
53
+ - prepare_cancel_withdrawal looks up the user's active withdrawal and returns the cancel transaction parameters. If there is no active withdrawal it refuses with valid:false; surface that to the user instead of guessing.
54
+
55
+ Yield / DeFi:
56
+ 1. get_opportunities — cross-protocol LBTC and BTC.b opportunities.
57
+ 2. get_strategies — Bitcoin Earn (mainnet-only): APY + TVL.
58
+ 3. get_morpho_lbtc_markets — Morpho lending markets where LBTC is collateral.
59
+ Present trade-offs and let the user choose. Bitcoin Earn is Lombard's vault product (built on the Veda vault protocol); always refer to it as "Bitcoin Earn".
60
+
61
+ Morpho Blue:
62
+ 1. get_morpho_lbtc_markets to list markets (APY, TVL, LLTV).
63
+ 2. prepare_morpho_supply_collateral with the chosen market ID and amount.
64
+ 3. Immediately offer prepare_morpho_borrow afterward.
65
+ 4. Use get_morpho_position to check positions after writes.
66
+
67
+ Token balance by name (e.g. "my USDC balance"): call get_morpho_lbtc_markets first to find the token's loanAssetAddress, then call get_token_balance with that address.
68
+
69
+ # Error handling
70
+
71
+ - "bad captcha" / 401: the partner ID isn't accepted on this network. Direct the user to https://www.lombard.finance/app/ (use exactly this URL — see Canonical URLs).
72
+ - HTTP 500 / "Internal Server Error" / "code: 13": a backend issue on the deposit-address service, usually transient on testnet. Tell the user it's a backend issue, suggest retrying in a moment, and offer https://www.lombard.finance/app/ as a workaround. Do not retry the tool more than twice.
73
+ - "Active signature already exists for this user": the user is already authorized. Call check_fee_authorization to confirm, then call get_deposit_btc_address — they do not need to sign again.
74
+ - Fee authorization expired: call prepare_btc_deposit to re-sign.
75
+ - Insufficient balance / chain mismatch: explain plainly and suggest the fix (top up / switch network).
76
+ - Tool returns "valid: false": list the missing or invalid fields verbatim and ask the user to provide them.`,a=`${t}
77
+
78
+ ${e.LOMBARD_ASSETS_GLOSSARY}`;exports.AddressAndChainSchema=e.AddressAndChainSchema;exports.AddressAndChainZod=e.AddressAndChainZod;exports.BalanceSchema=e.BalanceSchema;exports.BalanceZod=e.BalanceZod;exports.CHAIN_ID_DESCRIPTION=e.CHAIN_ID_DESCRIPTION;exports.ClaimDepositSchema=e.ClaimDepositSchema;exports.ClaimDepositZod=e.ClaimDepositZod;exports.DeployToVaultSchema=e.DeployToVaultSchema;exports.DeployToVaultZod=e.DeployToVaultZod;exports.DepositBtcSchema=e.DepositBtcSchema;exports.DepositBtcZod=e.DepositBtcZod;exports.ExchangeRateSchema=e.ExchangeRateSchema;exports.ExchangeRateZod=e.ExchangeRateZod;exports.LOMBARD_ASSETS=e.LOMBARD_ASSETS;exports.LOMBARD_ASSETS_GLOSSARY=e.LOMBARD_ASSETS_GLOSSARY;exports.LbtcApySchema=e.LbtcApySchema;exports.LbtcApyZod=e.LbtcApyZod;exports.MorphoBorrowSchema=e.MorphoBorrowSchema;exports.MorphoBorrowZod=e.MorphoBorrowZod;exports.MorphoLbtcMarketsSchema=e.MorphoLbtcMarketsSchema;exports.MorphoLbtcMarketsZod=e.MorphoLbtcMarketsZod;exports.MorphoPositionSchema=e.MorphoPositionSchema;exports.MorphoPositionZod=e.MorphoPositionZod;exports.MorphoRepaySchema=e.MorphoRepaySchema;exports.MorphoRepayZod=e.MorphoRepayZod;exports.MorphoSupplyCollateralSchema=e.MorphoSupplyCollateralSchema;exports.MorphoSupplyCollateralZod=e.MorphoSupplyCollateralZod;exports.OpportunitiesSchema=e.OpportunitiesSchema;exports.OpportunitiesZod=e.OpportunitiesZod;exports.RedeemBtcbSchema=e.RedeemBtcbSchema;exports.RedeemBtcbZod=e.RedeemBtcbZod;exports.SUPPORTED_CHAINS=e.SUPPORTED_CHAINS;exports.StakeSchema=e.StakeSchema;exports.StakeZod=e.StakeZod;exports.StrategiesSchema=e.StrategiesSchema;exports.StrategiesZod=e.StrategiesZod;exports.TokenBalanceSchema=e.TokenBalanceSchema;exports.TokenBalanceZod=e.TokenBalanceZod;exports.TokenInfoSchema=e.TokenInfoSchema;exports.TokenInfoZod=e.TokenInfoZod;exports.UnstakeSchema=e.UnstakeSchema;exports.UnstakeZod=e.UnstakeZod;exports.VaultWithdrawalSchema=e.VaultWithdrawalSchema;exports.VaultWithdrawalZod=e.VaultWithdrawalZod;exports.allTools=e.allTools;exports.amount=e.amount;exports.buildAssetGlossary=e.buildAssetGlossary;exports.chainId=e.chainId;exports.checkFeeAuthorization=e.checkFeeAuthorization;exports.evmAddress=e.evmAddress;exports.getBalance=e.getBalance;exports.getBtcbBalance=e.getBtcbBalance;exports.getChainConfig=e.getChainConfig;exports.getDepositBtcAddress=e.getDepositBtcAddress;exports.getDepositStatusTool=e.getDepositStatusTool;exports.getExchangeRate=e.getExchangeRate;exports.getLbtcApy=e.getLbtcApy;exports.getLbtcBalance=e.getLbtcBalance;exports.getMorphoLbtcMarkets=e.getMorphoLbtcMarkets;exports.getMorphoPosition=e.getMorphoPosition;exports.getOpportunities=e.getOpportunities;exports.getStrategies=e.getStrategies;exports.getTokenBalance=e.getTokenBalance;exports.getTokenInfo=e.getTokenInfo;exports.getUnstakeStatusTool=e.getUnstakeStatusTool;exports.getVaultPositions=e.getVaultPositions;exports.prepareBtcDeposit=e.prepareBtcDeposit;exports.prepareBtcToBtcbDeposit=e.prepareBtcToBtcbDeposit;exports.prepareCancelWithdrawal=e.prepareCancelWithdrawal;exports.prepareClaimDeposit=e.prepareClaimDeposit;exports.prepareDeployToVault=e.prepareDeployToVault;exports.prepareMorphoBorrow=e.prepareMorphoBorrow;exports.prepareMorphoRepay=e.prepareMorphoRepay;exports.prepareMorphoSupplyCollateral=e.prepareMorphoSupplyCollateral;exports.prepareRedeemBtcb=e.prepareRedeemBtcb;exports.prepareStake=e.prepareStake;exports.prepareUnstake=e.prepareUnstake;exports.prepareVaultWithdrawal=e.prepareVaultWithdrawal;exports.resolveAssetByAddress=e.resolveAssetByAddress;exports.resolveAssetByName=e.resolveAssetByName;exports.toolsByName=e.toolsByName;exports.LOMBARD_SYSTEM_PROMPT=a;
@@ -0,0 +1,6 @@
1
+ export { buildAssetGlossary, LOMBARD_ASSETS, LOMBARD_ASSETS_GLOSSARY, type LombardAsset, resolveAssetByAddress, resolveAssetByName, } from "./assets";
2
+ export { type ChainConfig, getChainConfig, SUPPORTED_CHAINS } from "./chains";
3
+ export { LOMBARD_SYSTEM_PROMPT } from "./prompt";
4
+ export { AddressAndChainSchema, AddressAndChainZod, amount, BalanceSchema, BalanceZod, CHAIN_ID_DESCRIPTION, chainId, ClaimDepositSchema, ClaimDepositZod, DeployToVaultSchema, DeployToVaultZod, DepositBtcSchema, DepositBtcZod, evmAddress, ExchangeRateSchema, ExchangeRateZod, LbtcApySchema, LbtcApyZod, MorphoBorrowSchema, MorphoBorrowZod, MorphoLbtcMarketsSchema, MorphoLbtcMarketsZod, MorphoPositionSchema, MorphoPositionZod, MorphoRepaySchema, MorphoRepayZod, MorphoSupplyCollateralSchema, MorphoSupplyCollateralZod, OpportunitiesSchema, OpportunitiesZod, RedeemBtcbSchema, RedeemBtcbZod, StakeSchema, StakeZod, StrategiesSchema, StrategiesZod, TokenBalanceSchema, TokenBalanceZod, TokenInfoSchema, TokenInfoZod, UnstakeSchema, UnstakeZod, VaultWithdrawalSchema, VaultWithdrawalZod, } from "./schemas";
5
+ export { allTools, checkFeeAuthorization, getBalance, getBtcbBalance, getDepositBtcAddress, getDepositStatusTool, getExchangeRate, getLbtcApy, getLbtcBalance, getMorphoLbtcMarkets, getMorphoPosition, getOpportunities, getStrategies, getTokenBalance, getTokenInfo, getUnstakeStatusTool, getVaultPositions, prepareBtcDeposit, prepareBtcToBtcbDeposit, prepareCancelWithdrawal, prepareClaimDeposit, prepareDeployToVault, prepareMorphoBorrow, prepareMorphoRepay, prepareMorphoSupplyCollateral, prepareRedeemBtcb, prepareStake, prepareUnstake, prepareVaultWithdrawal, type ToolDefinition, toolsByName, } from "./tools";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,uBAAuB,EACvB,KAAK,YAAY,EACjB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,KAAK,WAAW,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,MAAM,EACN,aAAa,EACb,UAAU,EACV,oBAAoB,EACpB,OAAO,EACP,kBAAkB,EAClB,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,uBAAuB,EACvB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,4BAA4B,EAC5B,yBAAyB,EACzB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,QAAQ,EACR,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,YAAY,EACZ,aAAa,EACb,UAAU,EACV,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,QAAQ,EACR,qBAAqB,EACrB,UAAU,EACV,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,UAAU,EACV,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,6BAA6B,EAC7B,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,sBAAsB,EACtB,KAAK,cAAc,EACnB,WAAW,GACZ,MAAM,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,164 @@
1
+ import { L as e } from "./tools.js";
2
+ import { A as i, a as n, B as l, b as p, C as h, c as d, d as c, D as u, e as m, f, g as w, E as b, h as B, i as g, j as T, k as _, M as y, l as k, m as C, n as v, o as S, p as L, q as A, r as M, s as D, t as E, O as I, u as x, R, v as Z, S as N, w as U, x as V, y as O, z as P, T as W, F as q, G as z, H as Y, U as H, I as F, V as j, J as G, K as $, N as J, P as K, Q, W as X, X as ee, Y as ae, Z as te, _ as se, $ as re, a0 as oe, a1 as ie, a2 as ne, a3 as le, a4 as pe, a5 as he, a6 as de, a7 as ce, a8 as ue, a9 as me, aa as fe, ab as we, ac as be, ad as Be, ae as ge, af as Te, ag as _e, ah as ye, ai as ke, aj as Ce, ak as ve, al as Se, am as Le, an as Ae, ao as Me, ap as De, aq as Ee } from "./tools.js";
3
+ const a = `You are an assistant for the Lombard protocol. Lombard issues LBTC, a yield-bearing receipt token for BTC staked via Babylon. LBTC accrues yield, so 1 LBTC is always worth more than 1 BTC; never assume 1:1 — always fetch the live rate with get_exchange_rate.
4
+
5
+ Networks: Ethereum and Base are production. Sepolia and Base Sepolia are development/test environments. Bitcoin Earn (vault yield) and strategy data are mainnet-only.
6
+
7
+ # Core rules
8
+
9
+ Validate first, act second. Never call a prepare_* tool with missing, placeholder, or inferred values. If a required field is absent (e.g. a Bitcoin recipient address for an LBTC → BTC unstake) or you are not sure of a constraint (minimum amount, address format), ask the user. Do not pull values from prior context unless the user just referenced them. If a prepare_* tool returns "valid: false", list the missing or invalid fields verbatim, ask the user to provide them, and stop — do not retry until the user supplies them.
10
+
11
+ Use the wallet's connected chain as default. Each turn this prompt is extended with the user's wallet context (address, chainId, chainName). When the user asks for a balance / deposit / operation without naming a chain, use the connected chain and say so ("Showing your balance on {chainName}. Want me to check the other supported networks too?"). Do not silently default to Ethereum mainnet.
12
+
13
+ Emit full data. Never truncate or abbreviate addresses, transaction hashes, amounts, or market IDs. Always emit the canonical full-length value. The chat UI handles display formatting.
14
+
15
+ Stay in-app. Complete all operations here. Never tell the user to open Etherscan, the Lombard web app, Morpho's website, or any other external interface — unless it is the only path to recover from a documented failure mode.
16
+
17
+ Concise replies. Lead with the answer. Skip filler ("Let me check…", "I'll look into…"). After a step completes, briefly propose the next logical action and offer to do it.
18
+
19
+ # Canonical URLs (never improvise)
20
+
21
+ Use these URLs verbatim when recovery requires linking the user off-app. Do NOT shorten, abbreviate, or guess URLs from memory — only these strings are valid:
22
+
23
+ - Lombard web app: https://www.lombard.finance/app/
24
+ - Lombard docs: https://docs.lombard.finance
25
+ - Etherscan (Ethereum mainnet): https://etherscan.io
26
+ - Etherscan (Sepolia): https://sepolia.etherscan.io
27
+ - Basescan (Base mainnet): https://basescan.org
28
+ - Basescan (Base Sepolia): https://sepolia.basescan.org
29
+
30
+ If a recovery path requires a URL not listed above, say so and stop — do not invent one. Specifically, "app.lombard.finance" is NOT a valid host; the correct host is "www.lombard.finance" with the "/app/" path.
31
+
32
+ # Workflows
33
+
34
+ Native BTC deposits (two distinct flows — pick based on what the user wants to receive):
35
+
36
+ (A) BTC → LBTC (yield-bearing): the user receives LBTC, which accrues Babylon staking yield over time.
37
+ 1. Call get_deposit_btc_address. If an address is returned, display it. Stop — do not call prepare_btc_deposit.
38
+ 2. If no address exists, call check_fee_authorization. If hasValidSignature is true, tell the user the wallet will only need to confirm the address (no fresh fee signature).
39
+ 3. Call prepare_btc_deposit. The wallet prompts only when fee auth is missing or expired.
40
+ 4. After the address is returned, tell the user to send BTC, track with get_deposit_status, and use prepare_claim_deposit once claimable.
41
+
42
+ (B) BTC → BTC.b (cross-chain wrapped BTC, NOT yield-bearing): the user receives BTC.b on the destination EVM chain.
43
+ 1. Call prepare_btc_to_btcb_deposit with the user's address and chainId. The wallet prompts for the required authorization, then a unique BTC deposit address is generated.
44
+ 2. Tell the user to send BTC and track via get_deposit_status.
45
+
46
+ When the user says "I want to deposit BTC", ask which output they want (LBTC or BTC.b) and explain the difference: LBTC accrues yield; BTC.b is cross-chain wrapped BTC, not yield-bearing. Never tell the user BTC → BTC.b is unsupported — it is supported via prepare_btc_to_btcb_deposit.
47
+
48
+ EVM stake / unstake / redeem:
49
+ - prepare_stake: BTC.b → LBTC on the connected chain.
50
+ - prepare_unstake: LBTC → BTC or BTC.b. When outputAsset is "BTC", you MUST collect a Bitcoin destination address from the user before calling the tool. Valid formats: bc1.../1.../3... on mainnet; tb1.../m.../n.../2... on Sepolia or Base Sepolia. Numeric strings, EVM addresses, or addresses inferred from earlier turns are invalid — re-prompt the user.
51
+ - prepare_redeem_btcb: BTC.b → native BTC. Use this when the user holds BTC.b and wants real Bitcoin back (not LBTC). Same Bitcoin recipient address validation rules as prepare_unstake to BTC. Do NOT use prepare_unstake for BTC.b; prepare_unstake operates on LBTC only.
52
+
53
+ Bitcoin Earn withdrawals (only one active withdrawal per user per vault):
54
+ - prepare_vault_withdrawal performs a pre-flight check via getEarnWithdrawals. If an active withdrawal already exists, it returns valid:false with the existing withdrawal's details (shareAmount, txHash, deadline). Tell the user about that withdrawal and offer prepare_cancel_withdrawal — do NOT call prepare_vault_withdrawal again until the existing one is cancelled.
55
+ - prepare_cancel_withdrawal looks up the user's active withdrawal and returns the cancel transaction parameters. If there is no active withdrawal it refuses with valid:false; surface that to the user instead of guessing.
56
+
57
+ Yield / DeFi:
58
+ 1. get_opportunities — cross-protocol LBTC and BTC.b opportunities.
59
+ 2. get_strategies — Bitcoin Earn (mainnet-only): APY + TVL.
60
+ 3. get_morpho_lbtc_markets — Morpho lending markets where LBTC is collateral.
61
+ Present trade-offs and let the user choose. Bitcoin Earn is Lombard's vault product (built on the Veda vault protocol); always refer to it as "Bitcoin Earn".
62
+
63
+ Morpho Blue:
64
+ 1. get_morpho_lbtc_markets to list markets (APY, TVL, LLTV).
65
+ 2. prepare_morpho_supply_collateral with the chosen market ID and amount.
66
+ 3. Immediately offer prepare_morpho_borrow afterward.
67
+ 4. Use get_morpho_position to check positions after writes.
68
+
69
+ Token balance by name (e.g. "my USDC balance"): call get_morpho_lbtc_markets first to find the token's loanAssetAddress, then call get_token_balance with that address.
70
+
71
+ # Error handling
72
+
73
+ - "bad captcha" / 401: the partner ID isn't accepted on this network. Direct the user to https://www.lombard.finance/app/ (use exactly this URL — see Canonical URLs).
74
+ - HTTP 500 / "Internal Server Error" / "code: 13": a backend issue on the deposit-address service, usually transient on testnet. Tell the user it's a backend issue, suggest retrying in a moment, and offer https://www.lombard.finance/app/ as a workaround. Do not retry the tool more than twice.
75
+ - "Active signature already exists for this user": the user is already authorized. Call check_fee_authorization to confirm, then call get_deposit_btc_address — they do not need to sign again.
76
+ - Fee authorization expired: call prepare_btc_deposit to re-sign.
77
+ - Insufficient balance / chain mismatch: explain plainly and suggest the fix (top up / switch network).
78
+ - Tool returns "valid: false": list the missing or invalid fields verbatim and ask the user to provide them.`, s = `${a}
79
+
80
+ ${e}`;
81
+ export {
82
+ i as AddressAndChainSchema,
83
+ n as AddressAndChainZod,
84
+ l as BalanceSchema,
85
+ p as BalanceZod,
86
+ h as CHAIN_ID_DESCRIPTION,
87
+ d as ClaimDepositSchema,
88
+ c as ClaimDepositZod,
89
+ u as DeployToVaultSchema,
90
+ m as DeployToVaultZod,
91
+ f as DepositBtcSchema,
92
+ w as DepositBtcZod,
93
+ b as ExchangeRateSchema,
94
+ B as ExchangeRateZod,
95
+ g as LOMBARD_ASSETS,
96
+ e as LOMBARD_ASSETS_GLOSSARY,
97
+ s as LOMBARD_SYSTEM_PROMPT,
98
+ T as LbtcApySchema,
99
+ _ as LbtcApyZod,
100
+ y as MorphoBorrowSchema,
101
+ k as MorphoBorrowZod,
102
+ C as MorphoLbtcMarketsSchema,
103
+ v as MorphoLbtcMarketsZod,
104
+ S as MorphoPositionSchema,
105
+ L as MorphoPositionZod,
106
+ A as MorphoRepaySchema,
107
+ M as MorphoRepayZod,
108
+ D as MorphoSupplyCollateralSchema,
109
+ E as MorphoSupplyCollateralZod,
110
+ I as OpportunitiesSchema,
111
+ x as OpportunitiesZod,
112
+ R as RedeemBtcbSchema,
113
+ Z as RedeemBtcbZod,
114
+ N as SUPPORTED_CHAINS,
115
+ U as StakeSchema,
116
+ V as StakeZod,
117
+ O as StrategiesSchema,
118
+ P as StrategiesZod,
119
+ W as TokenBalanceSchema,
120
+ q as TokenBalanceZod,
121
+ z as TokenInfoSchema,
122
+ Y as TokenInfoZod,
123
+ H as UnstakeSchema,
124
+ F as UnstakeZod,
125
+ j as VaultWithdrawalSchema,
126
+ G as VaultWithdrawalZod,
127
+ $ as allTools,
128
+ J as amount,
129
+ K as buildAssetGlossary,
130
+ Q as chainId,
131
+ X as checkFeeAuthorization,
132
+ ee as evmAddress,
133
+ ae as getBalance,
134
+ te as getBtcbBalance,
135
+ se as getChainConfig,
136
+ re as getDepositBtcAddress,
137
+ oe as getDepositStatusTool,
138
+ ie as getExchangeRate,
139
+ ne as getLbtcApy,
140
+ le as getLbtcBalance,
141
+ pe as getMorphoLbtcMarkets,
142
+ he as getMorphoPosition,
143
+ de as getOpportunities,
144
+ ce as getStrategies,
145
+ ue as getTokenBalance,
146
+ me as getTokenInfo,
147
+ fe as getUnstakeStatusTool,
148
+ we as getVaultPositions,
149
+ be as prepareBtcDeposit,
150
+ Be as prepareBtcToBtcbDeposit,
151
+ ge as prepareCancelWithdrawal,
152
+ Te as prepareClaimDeposit,
153
+ _e as prepareDeployToVault,
154
+ ye as prepareMorphoBorrow,
155
+ ke as prepareMorphoRepay,
156
+ Ce as prepareMorphoSupplyCollateral,
157
+ ve as prepareRedeemBtcb,
158
+ Se as prepareStake,
159
+ Le as prepareUnstake,
160
+ Ae as prepareVaultWithdrawal,
161
+ Me as resolveAssetByAddress,
162
+ De as resolveAssetByName,
163
+ Ee as toolsByName
164
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@langchain/core/tools"),e=require("./tools.cjs");function n(o){return t.tool(async a=>JSON.stringify(await o.execute(a)),{name:o.name,description:o.description,schema:o.schema})}const i=e.allTools.map(n);exports.lombardLangChainTools=i;exports.toLangChainTool=n;
@@ -0,0 +1,4 @@
1
+ import { type ToolDefinition } from "./tools";
2
+ export declare function toLangChainTool(def: ToolDefinition<any, any>): import("@langchain/core/tools").DynamicStructuredTool<import("zod").ZodType<any, import("zod").ZodTypeDef, any>, any, any, string>;
3
+ export declare const lombardLangChainTools: import("@langchain/core/tools").DynamicStructuredTool<import("zod").ZodType<any, import("zod").ZodTypeDef, any>, any, any, string>[];
4
+ //# sourceMappingURL=langchain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"langchain.d.ts","sourceRoot":"","sources":["../src/langchain.ts"],"names":[],"mappings":"AAaA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AAGxD,wBAAgB,eAAe,CAAC,GAAG,EAAE,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,sIAS5D;AAED,eAAO,MAAM,qBAAqB,sIAAgC,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { tool as n } from "@langchain/core/tools";
2
+ import { K as t } from "./tools.js";
3
+ function i(o) {
4
+ return n(
5
+ async (a) => JSON.stringify(await o.execute(a)),
6
+ {
7
+ name: o.name,
8
+ description: o.description,
9
+ schema: o.schema
10
+ }
11
+ );
12
+ }
13
+ const s = t.map(i);
14
+ export {
15
+ s as lombardLangChainTools,
16
+ i as toLangChainTool
17
+ };