mantle-agent-kit-sdk 1.0.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/.env.example ADDED
@@ -0,0 +1,18 @@
1
+ # Platform Configuration (Required)
2
+ # Your unique APP_ID for the Mantle Agent Kit
3
+ APP_ID=your_app_id_here
4
+
5
+ # Optional: Custom platform URL (defaults to https://mantle-x402.vercel.app)
6
+ # PLATFORM_URL=https://mantle-x402.vercel.app
7
+
8
+ # Your wallet private key (for agent initialization)
9
+ PRIVATE_KEY=0xYOUR_PRIVATE_KEY_HERE
10
+
11
+ # OKX DEX Aggregator API Keys (Required for OKX methods)
12
+ # OKX_API_KEY=your_okx_api_key
13
+ # OKX_SECRET_KEY=your_okx_secret_key
14
+ # OKX_API_PASSPHRASE=your_okx_passphrase
15
+ # OKX_PROJECT_ID=your_okx_project_id
16
+
17
+ # 1inch API Key (Optional - for higher rate limits)
18
+ # ONEINCH_API_KEY=your_1inch_api_key
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Mantle Agent Kit Contributors
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,405 @@
1
+ # Mantle Agent Kit
2
+
3
+ TypeScript SDK for seamless integration with DeFi protocols on Mantle Network. Provides unified interfaces for swaps, lending, liquid staking, and cross-chain operations.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install mantle-agent-kit
9
+ # or
10
+ bun install mantle-agent-kit
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ```typescript
16
+ import { MNTAgentKit } from "mantle-agent-kit";
17
+
18
+ // Initialize agent with private key and network
19
+ const agent = new MNTAgentKit("0xYOUR_PRIVATE_KEY", "mainnet");
20
+
21
+ // Initialize with platform validation (validates APP_ID from environment)
22
+ await agent.initialize();
23
+
24
+ // Execute a native token transfer
25
+ const txHash = await agent.sendTransaction(
26
+ "0xRecipientAddress",
27
+ "1000000000000000000" // 1 MNT in wei
28
+ );
29
+ ```
30
+
31
+ ## Supported Protocols
32
+
33
+ ### DEX Aggregators
34
+ - **OKX DEX Aggregator** - Multi-source liquidity aggregation with HMAC authentication
35
+ - **1inch** - Pathfinder algorithm for optimal swap routes (optional API key)
36
+ - **OpenOcean** - Cross-DEX aggregation for best execution prices
37
+
38
+ ### Native Mantle DEXs
39
+ - **Agni Finance** - Leading DEX on Mantle with concentrated liquidity (Uniswap V3 architecture)
40
+ - **Merchant Moe** - Liquidity Book DEX with dynamic fee tiers (TraderJoe V2.1 architecture)
41
+ - **Uniswap V3** - Direct integration with canonical Uniswap V3 contracts
42
+
43
+ ### Lending Protocols
44
+ - **Lendle** - Mantle's primary lending market with supply, borrow, and collateralization (Aave V2 architecture)
45
+
46
+ ### Liquid Staking
47
+ - **mETH Protocol** - Mantle's native liquid staking derivative for Ethereum
48
+
49
+ ### Cross-Chain Infrastructure
50
+ - **Squid Router** - Seamless cross-chain swaps via Axelar network
51
+
52
+ ## API Reference
53
+
54
+ ### Token Transfers
55
+
56
+ Send native MNT tokens to any address.
57
+
58
+ ```typescript
59
+ await agent.sendTransaction(
60
+ recipientAddress: Address,
61
+ amount: string // in wei
62
+ ): Promise<Address>
63
+ ```
64
+
65
+ ### DEX Operations
66
+
67
+ #### OKX DEX Aggregator
68
+
69
+ ```typescript
70
+ // Get optimal swap quote
71
+ const quote = await agent.getSwapQuote(
72
+ fromTokenAddress: string,
73
+ toTokenAddress: string,
74
+ amount: string,
75
+ slippagePercentage?: string // default: "0.5"
76
+ );
77
+
78
+ // Execute swap
79
+ const txHash = await agent.executeSwap(
80
+ fromTokenAddress: string,
81
+ toTokenAddress: string,
82
+ amount: string,
83
+ slippagePercentage?: string // default: "0.5"
84
+ );
85
+ ```
86
+
87
+ #### 1inch
88
+
89
+ ```typescript
90
+ const quote = await agent.get1inchQuote(
91
+ fromToken: Address,
92
+ toToken: Address,
93
+ amount: string
94
+ );
95
+
96
+ const txHash = await agent.swapOn1inch(
97
+ fromToken: Address,
98
+ toToken: Address,
99
+ amount: string,
100
+ slippage?: number // default: 0.5
101
+ );
102
+ ```
103
+
104
+ #### OpenOcean
105
+
106
+ ```typescript
107
+ const quote = await agent.getOpenOceanQuote(
108
+ fromToken: Address,
109
+ toToken: Address,
110
+ amount: string
111
+ );
112
+
113
+ const txHash = await agent.swapOnOpenOcean(
114
+ fromToken: Address,
115
+ toToken: Address,
116
+ amount: string,
117
+ slippage?: number // default: 0.5
118
+ );
119
+ ```
120
+
121
+ #### Uniswap V3
122
+
123
+ ```typescript
124
+ const quote = await agent.getUniswapQuote(
125
+ fromToken: Address,
126
+ toToken: Address,
127
+ amount: string
128
+ );
129
+
130
+ const txHash = await agent.swapOnUniswap(
131
+ fromToken: Address,
132
+ toToken: Address,
133
+ amount: string,
134
+ slippage?: number // default: 0.5
135
+ );
136
+ ```
137
+
138
+ #### Agni Finance
139
+
140
+ ```typescript
141
+ const txHash = await agent.agniSwap(
142
+ tokenIn: Address,
143
+ tokenOut: Address,
144
+ amountIn: string,
145
+ slippagePercent?: number, // default: 0.5
146
+ feeTier?: number // optional: 500, 3000, 10000
147
+ );
148
+ ```
149
+
150
+ #### Merchant Moe
151
+
152
+ ```typescript
153
+ const txHash = await agent.merchantMoeSwap(
154
+ tokenIn: Address,
155
+ tokenOut: Address,
156
+ amountIn: string,
157
+ slippagePercent?: number // default: 0.5
158
+ );
159
+ ```
160
+
161
+ ### Lendle Lending Protocol
162
+
163
+ #### Supply Assets
164
+
165
+ Deposit tokens to earn yield and use as collateral.
166
+
167
+ ```typescript
168
+ const txHash = await agent.lendleSupply(
169
+ tokenAddress: Address,
170
+ amount: string
171
+ );
172
+ ```
173
+
174
+ #### Withdraw Assets
175
+
176
+ Withdraw previously supplied tokens.
177
+
178
+ ```typescript
179
+ const txHash = await agent.lendleWithdraw(
180
+ tokenAddress: Address,
181
+ amount: string,
182
+ to?: Address // optional recipient
183
+ );
184
+ ```
185
+
186
+ #### Borrow Assets
187
+
188
+ Borrow against supplied collateral.
189
+
190
+ ```typescript
191
+ const txHash = await agent.lendleBorrow(
192
+ tokenAddress: Address,
193
+ amount: string,
194
+ interestRateMode?: 1 | 2, // 1 = stable, 2 = variable (default)
195
+ onBehalfOf?: Address // optional
196
+ );
197
+ ```
198
+
199
+ #### Repay Debt
200
+
201
+ Repay borrowed assets.
202
+
203
+ ```typescript
204
+ const txHash = await agent.lendleRepay(
205
+ tokenAddress: Address,
206
+ amount: string,
207
+ rateMode?: 1 | 2, // 1 = stable, 2 = variable (default)
208
+ onBehalfOf?: Address // optional
209
+ );
210
+ ```
211
+
212
+ ### mETH Protocol
213
+
214
+ Access Mantle's liquid staking token address.
215
+
216
+ ```typescript
217
+ const methAddress = agent.getMethTokenAddress();
218
+ // Returns: 0xcDA86A272531e8640cD7F1a92c01839911B90bb0 (mainnet)
219
+ ```
220
+
221
+ Note: To stake ETH for mETH, use the [official mETH interface](https://www.mantle-meth.xyz/).
222
+
223
+ ### Cross-Chain Operations
224
+
225
+ #### Squid Router
226
+
227
+ Execute cross-chain swaps via Axelar network.
228
+
229
+ ```typescript
230
+ // Get cross-chain route
231
+ const route = await agent.getSquidRoute(
232
+ fromToken: Address,
233
+ toToken: Address,
234
+ fromChain: number, // LayerZero chain ID
235
+ toChain: number,
236
+ amount: string,
237
+ slippage?: number // default: 1
238
+ );
239
+
240
+ // Execute cross-chain swap
241
+ const txHash = await agent.crossChainSwapViaSquid(
242
+ fromToken: Address,
243
+ toToken: Address,
244
+ fromChain: number,
245
+ toChain: number,
246
+ amount: string,
247
+ slippage?: number // default: 1
248
+ );
249
+ ```
250
+
251
+ ## Configuration
252
+
253
+ ### Environment Variables
254
+
255
+ #### Platform Configuration (Required)
256
+
257
+ The Mantle Agent Kit requires an APP_ID for platform validation and authentication.
258
+
259
+ ```env
260
+ APP_ID=your_app_id_here
261
+
262
+ # Optional: Custom platform URL (defaults to https://mantle-x402.vercel.app)
263
+ PLATFORM_URL=https://mantle-x402.vercel.app
264
+ ```
265
+
266
+ **What is APP_ID?**
267
+
268
+ APP_ID is a unique identifier that authenticates your application and validates access to the Mantle Agent Kit. When you call `agent.initialize()`, it validates your APP_ID with the platform API and returns your project configuration (name, payout address, network, status).
269
+
270
+ #### OKX DEX (Required for OKX methods)
271
+
272
+ ```env
273
+ OKX_API_KEY=your_api_key
274
+ OKX_SECRET_KEY=your_secret_key
275
+ OKX_API_PASSPHRASE=your_passphrase
276
+ OKX_PROJECT_ID=your_project_id
277
+ ```
278
+
279
+ #### 1inch (Optional - Higher rate limits)
280
+
281
+ ```env
282
+ ONEINCH_API_KEY=your_api_key
283
+ ```
284
+
285
+ ### Network Configuration
286
+
287
+ The SDK supports both Mantle mainnet and testnet:
288
+
289
+ - **Mainnet**: Chain ID 5000
290
+ - **Testnet**: Chain ID 5003 (Sepolia)
291
+
292
+ ```typescript
293
+ const mainnetAgent = new MNTAgentKit(privateKey, "mainnet");
294
+ const testnetAgent = new MNTAgentKit(privateKey, "testnet");
295
+ ```
296
+
297
+ ## Contract Addresses
298
+
299
+ All protocol contract addresses are pre-configured for Mantle Mainnet:
300
+
301
+ **Lendle Protocol**
302
+ - LendingPool: `0xCFa5aE7c2CE8Fadc6426C1ff872cA45378Fb7cF3`
303
+ - DataProvider: `0xD0E0b5e99c8a36f4c5234cd1E90CFc5C2Bb58A69`
304
+
305
+ **Agni Finance**
306
+ - Factory: `0x25780dc8Fc3cfBD75F33bFDAB65e969b603b2035`
307
+ - SwapRouter: `0x319B69888b0d11cEC22caA5034e25FfFBDc88421`
308
+ - NonfungiblePositionManager: `0x9C9e335A3BC0EF6F66F44390c383D0bB7a0A34f0`
309
+
310
+ **Merchant Moe**
311
+ - LBRouter: `0x013e138EF6008ae5FDFDE29700e3f2Bc61d21E3a`
312
+ - LBFactory: `0xa6630671775c4EA2743840F9A5016dCf2A104054`
313
+ - LBQuoter: `0xFa1ec885c522Ee2c06aFCfBC66E88a88ca09EEED`
314
+
315
+ **mETH Protocol**
316
+ - mETH Token: `0xcDA86A272531e8640cD7F1a92c01839911B90bb0`
317
+
318
+ **Uniswap V3**
319
+ - SwapRouter: `0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45`
320
+ - QuoterV2: `0x61fFE014bA17989E743c5F6cB21bF9697530B21e`
321
+
322
+ Verify current addresses on [Mantlescan](https://mantlescan.xyz).
323
+
324
+ ## Advanced Usage
325
+
326
+ ### Accessing Protocol Constants
327
+
328
+ Import protocol-specific constants for advanced integrations:
329
+
330
+ ```typescript
331
+ import {
332
+ AgniConstants,
333
+ LendleConstants,
334
+ MerchantMoeConstants,
335
+ MethConstants,
336
+ UniswapConstants,
337
+ } from "mantle-agent-kit";
338
+
339
+ // Example: Get Lendle pool address
340
+ const poolAddress = LendleConstants.LENDING_POOL.mainnet;
341
+ ```
342
+
343
+ ### Type Definitions
344
+
345
+ Import utility types for type-safe development:
346
+
347
+ ```typescript
348
+ import type { UserAccountData, ProjectConfig } from "mantle-agent-kit";
349
+
350
+ // UserAccountData returned from Lendle user queries
351
+ // ProjectConfig returned from platform validation
352
+ ```
353
+
354
+ ### Accessing Project Configuration
355
+
356
+ After initializing the agent, you can access the validated project configuration:
357
+
358
+ ```typescript
359
+ const agent = new MNTAgentKit(privateKey, "mainnet");
360
+ await agent.initialize();
361
+
362
+ // Access validated project config
363
+ console.log("Project Name:", agent.projectConfig?.name);
364
+ console.log("Payout Address:", agent.projectConfig?.payTo);
365
+ console.log("Network:", agent.projectConfig?.network);
366
+ console.log("Status:", agent.projectConfig?.status);
367
+ ```
368
+
369
+ ## Development
370
+
371
+ ### Build from Source
372
+
373
+ ```bash
374
+ # Install dependencies
375
+ bun install
376
+
377
+ # Build package
378
+ bun run build
379
+
380
+ # Type check
381
+ bun run typecheck
382
+ ```
383
+
384
+ ### Package Structure
385
+
386
+ ```
387
+ dist/
388
+ ├── index.js # ESM build
389
+ ├── index.cjs # CommonJS build
390
+ ├── index.d.ts # TypeScript declarations
391
+ └── *.map # Source maps
392
+ ```
393
+
394
+ ## License
395
+
396
+ MIT
397
+
398
+ ## Resources
399
+
400
+ - [Mantle Network Documentation](https://docs.mantle.xyz/)
401
+ - [Mantlescan Explorer](https://mantlescan.xyz/)
402
+ - [Lendle Protocol](https://lendle.xyz/)
403
+ - [Agni Finance](https://agni.finance/)
404
+ - [Merchant Moe](https://merchantmoe.com/)
405
+ - [mETH Protocol](https://www.mantle-meth.xyz/)