@peridot-agent/agent-kit 0.2.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/README.md +414 -0
- package/dist/adapters/langchain/index.cjs +1753 -0
- package/dist/adapters/langchain/index.cjs.map +1 -0
- package/dist/adapters/langchain/index.d.cts +29 -0
- package/dist/adapters/langchain/index.d.ts +29 -0
- package/dist/adapters/langchain/index.js +1725 -0
- package/dist/adapters/langchain/index.js.map +1 -0
- package/dist/adapters/mcp/server.cjs +1777 -0
- package/dist/adapters/mcp/server.cjs.map +1 -0
- package/dist/adapters/mcp/server.d.cts +1 -0
- package/dist/adapters/mcp/server.d.ts +1 -0
- package/dist/adapters/mcp/server.js +1756 -0
- package/dist/adapters/mcp/server.js.map +1 -0
- package/dist/adapters/vercel-ai/index.cjs +1751 -0
- package/dist/adapters/vercel-ai/index.cjs.map +1 -0
- package/dist/adapters/vercel-ai/index.d.cts +34 -0
- package/dist/adapters/vercel-ai/index.d.ts +34 -0
- package/dist/adapters/vercel-ai/index.js +1723 -0
- package/dist/adapters/vercel-ai/index.js.map +1 -0
- package/dist/index.cjs +1806 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +880 -0
- package/dist/index.d.ts +880 -0
- package/dist/index.js +1737 -0
- package/dist/index.js.map +1 -0
- package/dist/types-Cg95um6s.d.cts +212 -0
- package/dist/types-Cg95um6s.d.ts +212 -0
- package/package.json +95 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { Address, Hex } from 'viem';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
interface PeridotConfig {
|
|
5
|
+
/** Peridot platform API base URL. Defaults to https://app.peridot.finance */
|
|
6
|
+
apiBaseUrl?: string;
|
|
7
|
+
/** Required for cross-chain operations (Biconomy compose/status). */
|
|
8
|
+
biconomyApiKey?: string;
|
|
9
|
+
/** Optional RPC URL overrides for direct contract reads. */
|
|
10
|
+
rpcUrls?: Partial<Record<number, string>>;
|
|
11
|
+
/** Defaults to 'mainnet'. */
|
|
12
|
+
network?: 'mainnet' | 'testnet';
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Feature categories — new feature modules (margin, liquidations) add their
|
|
16
|
+
* own category here so the MCP server and adapters can filter by category.
|
|
17
|
+
*/
|
|
18
|
+
type ToolCategory = 'lending' | 'margin' | 'liquidations' | 'info' | 'status';
|
|
19
|
+
interface ToolDefinition<TInput = unknown, TOutput = unknown> {
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
/** Zod schema used for runtime validation and LLM schema generation. */
|
|
23
|
+
inputSchema: z.ZodType<TInput>;
|
|
24
|
+
execute: (input: TInput, config: PeridotConfig) => Promise<TOutput> | TOutput;
|
|
25
|
+
category: ToolCategory;
|
|
26
|
+
}
|
|
27
|
+
interface MarketRates {
|
|
28
|
+
asset: string;
|
|
29
|
+
chainId: number;
|
|
30
|
+
/** Base lending supply APY from the interest rate model. */
|
|
31
|
+
supplyApyPct: number;
|
|
32
|
+
/** Base lending borrow APY from the interest rate model. */
|
|
33
|
+
borrowApyPct: number;
|
|
34
|
+
/** Additional supply APY paid in PERIDOT/ASTER rewards. */
|
|
35
|
+
peridotSupplyApyPct: number;
|
|
36
|
+
/** PERIDOT/ASTER rewards that offset the borrow cost. */
|
|
37
|
+
peridotBorrowApyPct: number;
|
|
38
|
+
/** Supply APY from an external boost source (Morpho vault, PancakeSwap LP fees, Magma staking). */
|
|
39
|
+
boostSourceSupplyApyPct: number;
|
|
40
|
+
/** Additional reward APY for boosted markets (e.g. Morpho reward tokens). */
|
|
41
|
+
boostRewardsSupplyApyPct: number;
|
|
42
|
+
/** Total supply APY = base + peridot + boost_source + boost_rewards. */
|
|
43
|
+
totalSupplyApyPct: number;
|
|
44
|
+
/** Net borrow APY = base borrow APY − peridot borrow reward APY. */
|
|
45
|
+
netBorrowApyPct: number;
|
|
46
|
+
tvlUsd: number;
|
|
47
|
+
utilizationPct: number;
|
|
48
|
+
liquidityUsd: number;
|
|
49
|
+
priceUsd: number;
|
|
50
|
+
collateralFactorPct: number;
|
|
51
|
+
updatedAt: string;
|
|
52
|
+
/** Seconds elapsed since updatedAt. Use this to detect stale market data. */
|
|
53
|
+
dataAgeSeconds: number;
|
|
54
|
+
/**
|
|
55
|
+
* False when the APY table has no entry for this asset/chain.
|
|
56
|
+
* All APY fields will be 0 — do NOT present them as real rates.
|
|
57
|
+
* Inform the user that yield data is not yet available.
|
|
58
|
+
*/
|
|
59
|
+
apyDataAvailable: boolean;
|
|
60
|
+
/** Present when apyDataAvailable=false or data is unusually stale (>5 min). */
|
|
61
|
+
warning?: string | undefined;
|
|
62
|
+
}
|
|
63
|
+
interface MarketSummary {
|
|
64
|
+
asset: string;
|
|
65
|
+
chainId: number;
|
|
66
|
+
priceUsd: number;
|
|
67
|
+
tvlUsd: number;
|
|
68
|
+
utilizationPct: number;
|
|
69
|
+
liquidityUsd: number;
|
|
70
|
+
collateralFactorPct: number;
|
|
71
|
+
updatedAt: string;
|
|
72
|
+
/** Seconds elapsed since updatedAt. Values above 300 indicate a stale data feed. */
|
|
73
|
+
dataAgeSeconds: number;
|
|
74
|
+
}
|
|
75
|
+
interface LeaderboardEntry {
|
|
76
|
+
rank: number;
|
|
77
|
+
address: string;
|
|
78
|
+
totalPoints: number;
|
|
79
|
+
supplyCount: number;
|
|
80
|
+
borrowCount: number;
|
|
81
|
+
repayCount: number;
|
|
82
|
+
redeemCount: number;
|
|
83
|
+
updatedAt: string;
|
|
84
|
+
}
|
|
85
|
+
interface UserPosition {
|
|
86
|
+
address: string;
|
|
87
|
+
totalSuppliedUsd: number;
|
|
88
|
+
totalBorrowedUsd: number;
|
|
89
|
+
netWorthUsd: number;
|
|
90
|
+
netApyPct: number;
|
|
91
|
+
/** Simplified ratio: totalSupplied / totalBorrowed. Null when no debt. */
|
|
92
|
+
healthFactor: number | null;
|
|
93
|
+
assets: Array<{
|
|
94
|
+
assetId: string;
|
|
95
|
+
suppliedUsd: number;
|
|
96
|
+
borrowedUsd: number;
|
|
97
|
+
netUsd: number;
|
|
98
|
+
}>;
|
|
99
|
+
transactions: {
|
|
100
|
+
supplyCount: number;
|
|
101
|
+
borrowCount: number;
|
|
102
|
+
repayCount: number;
|
|
103
|
+
redeemCount: number;
|
|
104
|
+
};
|
|
105
|
+
/** ISO timestamp of when this data was fetched. Portfolio data is indexed from chain events
|
|
106
|
+
* and may lag recent on-chain activity by up to ~60 seconds. */
|
|
107
|
+
fetchedAt: string;
|
|
108
|
+
}
|
|
109
|
+
interface SimulateBorrowResult {
|
|
110
|
+
currentHealthFactor: number | null;
|
|
111
|
+
projectedHealthFactor: number | null;
|
|
112
|
+
borrowAmountUsd: number;
|
|
113
|
+
isSafe: boolean;
|
|
114
|
+
riskLevel: 'safe' | 'moderate' | 'high' | 'critical' | 'liquidatable';
|
|
115
|
+
/** Maximum additional safe borrow in USD before health factor drops below 1.5 */
|
|
116
|
+
maxSafeBorrowUsd: number;
|
|
117
|
+
warning?: string | undefined;
|
|
118
|
+
}
|
|
119
|
+
interface AccountLiquidity {
|
|
120
|
+
address: string;
|
|
121
|
+
chainId: number;
|
|
122
|
+
/** Excess borrowing capacity in USD (0 means at limit). */
|
|
123
|
+
liquidityUsd: number;
|
|
124
|
+
/** How far underwater in USD (0 means healthy). */
|
|
125
|
+
shortfallUsd: number;
|
|
126
|
+
isHealthy: boolean;
|
|
127
|
+
}
|
|
128
|
+
interface LiquidatableAccount {
|
|
129
|
+
address: string;
|
|
130
|
+
chainId: number;
|
|
131
|
+
/** Remaining borrow capacity (0 when underwater). */
|
|
132
|
+
liquidityUsd: number;
|
|
133
|
+
/** How far underwater in USD — positive means liquidatable. */
|
|
134
|
+
shortfallUsd: number;
|
|
135
|
+
/** When this account was last health-checked by the scanner. */
|
|
136
|
+
checkedAt: string;
|
|
137
|
+
}
|
|
138
|
+
interface LiquidatablePositions {
|
|
139
|
+
accounts: LiquidatableAccount[];
|
|
140
|
+
count: number;
|
|
141
|
+
}
|
|
142
|
+
/** A single on-chain call within an intent. */
|
|
143
|
+
interface TransactionCall {
|
|
144
|
+
to: Address;
|
|
145
|
+
data: Hex;
|
|
146
|
+
value: bigint;
|
|
147
|
+
description: string;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Hub-chain intent — same-chain actions (user is already on BSC/Monad/Somnia).
|
|
151
|
+
* The `calls` array must be executed in order. User signs each with their wallet.
|
|
152
|
+
*/
|
|
153
|
+
interface HubTransactionIntent {
|
|
154
|
+
type: 'hub';
|
|
155
|
+
chainId: number;
|
|
156
|
+
calls: TransactionCall[];
|
|
157
|
+
summary: string;
|
|
158
|
+
/** Present when the action carries liquidation risk. */
|
|
159
|
+
warning?: string;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Cross-chain intent — user is on a spoke chain (Arbitrum, Base, etc.).
|
|
163
|
+
* Built via Biconomy MEE compose. The user does NOT sign individual calls;
|
|
164
|
+
* they sign the single Biconomy execute payload in their wallet/dApp.
|
|
165
|
+
*/
|
|
166
|
+
interface CrossChainIntent {
|
|
167
|
+
type: 'cross-chain';
|
|
168
|
+
sourceChainId: number;
|
|
169
|
+
destinationChainId: number;
|
|
170
|
+
summary: string;
|
|
171
|
+
/** Human-readable steps shown to the user before they sign. */
|
|
172
|
+
userSteps: string[];
|
|
173
|
+
/** The raw response from Biconomy /compose — pass this to /execute. */
|
|
174
|
+
biconomyInstructions: BiconomyResponse;
|
|
175
|
+
estimatedGas: string;
|
|
176
|
+
}
|
|
177
|
+
type TransactionIntent = HubTransactionIntent | CrossChainIntent;
|
|
178
|
+
interface TransactionStatus {
|
|
179
|
+
superTxHash: string;
|
|
180
|
+
status: 'pending' | 'processing' | 'success' | 'failed' | 'not_found';
|
|
181
|
+
chainTxHashes?: string[];
|
|
182
|
+
error?: string;
|
|
183
|
+
}
|
|
184
|
+
type ExecutionMode = 'eoa' | 'smart-account' | 'eoa-7702';
|
|
185
|
+
interface ComposeFlow {
|
|
186
|
+
type: '/instructions/build' | '/instructions/intent-simple' | '/instructions/intent';
|
|
187
|
+
data: Record<string, unknown>;
|
|
188
|
+
batch?: boolean;
|
|
189
|
+
}
|
|
190
|
+
interface ComposeRequest {
|
|
191
|
+
ownerAddress: Address;
|
|
192
|
+
mode: ExecutionMode;
|
|
193
|
+
composeFlows: ComposeFlow[];
|
|
194
|
+
}
|
|
195
|
+
interface BiconomyResponse {
|
|
196
|
+
instructions: Array<{
|
|
197
|
+
calls: Array<{
|
|
198
|
+
to: Address;
|
|
199
|
+
value: string;
|
|
200
|
+
functionSig: string;
|
|
201
|
+
inputParams: unknown[];
|
|
202
|
+
outputParams: unknown[];
|
|
203
|
+
}>;
|
|
204
|
+
chainId: number;
|
|
205
|
+
isComposable: boolean;
|
|
206
|
+
}>;
|
|
207
|
+
returnedData?: unknown[];
|
|
208
|
+
route?: unknown;
|
|
209
|
+
estimatedGas?: string;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export type { AccountLiquidity as A, BiconomyResponse as B, ComposeRequest as C, HubTransactionIntent as H, LiquidatablePositions as L, MarketSummary as M, PeridotConfig as P, SimulateBorrowResult as S, ToolDefinition as T, UserPosition as U, TransactionStatus as a, LeaderboardEntry as b, MarketRates as c, CrossChainIntent as d, ComposeFlow as e, ToolCategory as f, TransactionCall as g, TransactionIntent as h };
|
package/package.json
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@peridot-agent/agent-kit",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "AI Agent toolkit for Peridot DeFi money markets — read, simulate, and build transaction intents for lending, borrowing, and cross-chain operations",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/AsyncSan/peridot-agent-kit.git"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"require": "./dist/index.cjs"
|
|
16
|
+
},
|
|
17
|
+
"./langchain": {
|
|
18
|
+
"types": "./dist/adapters/langchain/index.d.ts",
|
|
19
|
+
"import": "./dist/adapters/langchain/index.js",
|
|
20
|
+
"require": "./dist/adapters/langchain/index.cjs"
|
|
21
|
+
},
|
|
22
|
+
"./vercel-ai": {
|
|
23
|
+
"types": "./dist/adapters/vercel-ai/index.d.ts",
|
|
24
|
+
"import": "./dist/adapters/vercel-ai/index.js",
|
|
25
|
+
"require": "./dist/adapters/vercel-ai/index.cjs"
|
|
26
|
+
},
|
|
27
|
+
"./mcp": {
|
|
28
|
+
"types": "./dist/adapters/mcp/server.d.ts",
|
|
29
|
+
"import": "./dist/adapters/mcp/server.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"main": "./dist/index.cjs",
|
|
33
|
+
"module": "./dist/index.js",
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"bin": {
|
|
36
|
+
"peridot-mcp": "./dist/adapters/mcp/server.js"
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"dist",
|
|
40
|
+
"README.md"
|
|
41
|
+
],
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
44
|
+
"decimal.js": "^10.6.0",
|
|
45
|
+
"viem": "^2.0.0",
|
|
46
|
+
"zod": "^3.22.0",
|
|
47
|
+
"zod-to-json-schema": "^3.22.0"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@langchain/core": ">=0.2.0",
|
|
51
|
+
"ai": ">=3.0.0"
|
|
52
|
+
},
|
|
53
|
+
"peerDependenciesMeta": {
|
|
54
|
+
"@langchain/core": {
|
|
55
|
+
"optional": true
|
|
56
|
+
},
|
|
57
|
+
"ai": {
|
|
58
|
+
"optional": true
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@changesets/cli": "^2.27.0",
|
|
63
|
+
"@langchain/core": "^0.2.0",
|
|
64
|
+
"@types/node": "^20.0.0",
|
|
65
|
+
"@typescript-eslint/eslint-plugin": "^7.0.0",
|
|
66
|
+
"@typescript-eslint/parser": "^7.0.0",
|
|
67
|
+
"@vitest/coverage-v8": "^1.6.0",
|
|
68
|
+
"ai": "^3.0.0",
|
|
69
|
+
"eslint": "^8.57.0",
|
|
70
|
+
"openai": "^6.32.0",
|
|
71
|
+
"tsup": "^8.0.0",
|
|
72
|
+
"tsx": "^4.7.0",
|
|
73
|
+
"typescript": "^5.4.0",
|
|
74
|
+
"vitest": "^1.6.0"
|
|
75
|
+
},
|
|
76
|
+
"engines": {
|
|
77
|
+
"node": ">=18.0.0"
|
|
78
|
+
},
|
|
79
|
+
"scripts": {
|
|
80
|
+
"build": "tsup",
|
|
81
|
+
"dev": "tsup --watch",
|
|
82
|
+
"typecheck": "tsc --noEmit",
|
|
83
|
+
"lint": "eslint src scripts --ext .ts",
|
|
84
|
+
"lint:fix": "eslint src scripts --ext .ts --fix",
|
|
85
|
+
"test": "vitest run",
|
|
86
|
+
"test:watch": "vitest",
|
|
87
|
+
"test:integration": "vitest run --config vitest.integration.config.ts",
|
|
88
|
+
"test:routing": "npx tsx scripts/test-tool-routing.ts",
|
|
89
|
+
"test:coverage": "vitest run --coverage",
|
|
90
|
+
"changeset": "changeset",
|
|
91
|
+
"version-packages": "changeset version",
|
|
92
|
+
"release": "pnpm build && changeset publish",
|
|
93
|
+
"clean": "rm -rf dist"
|
|
94
|
+
}
|
|
95
|
+
}
|